Introduce typed semantic analysis pipeline

This commit is contained in:
pavel 2026-08-27 19:28:24 +02:00
commit f4cd4f4458
30 changed files with 2079 additions and 2381 deletions

View file

@ -171,9 +171,9 @@ func sqlChainResultType(expr Expr) (string, bool) {
}
switch terminal {
case "fetch":
return "Result<List<*" + resultType + ">, Error>", true
return "Result<List<" + resultType + ">, Error>", true
case "single":
return "Result<*" + resultType + ", Error>", true
return "Result<" + resultType + ", Error>", true
case "iterator":
return "Result<GotlinSQLIterator<" + resultType + ">, Error>", true
default:
@ -215,7 +215,7 @@ func (g *goGenerator) sqlClass(root CallExpr, operation string) (ClassDecl, erro
if len(root.TypeArgs) != 1 {
return ClassDecl{}, fmt.Errorf("sql.%s expects exactly one row type", operation)
}
class, ok := g.classes[root.TypeArgs[0]]
class, ok := g.semantic.Classes[root.TypeArgs[0]]
if !ok {
return ClassDecl{}, fmt.Errorf("SQL row class %q does not exist", root.TypeArgs[0])
}
@ -561,7 +561,7 @@ func (g *goGenerator) sqlProjection(call CallExpr, rowClass ClassDecl, method st
if !ok {
return ClassDecl{}, nil, fmt.Errorf("%s projection must construct a local data class", method)
}
projection, ok := g.classes[callee.Name]
projection, ok := g.semantic.Classes[callee.Name]
if !ok || !projection.Data {
return ClassDecl{}, nil, fmt.Errorf("%s projection type %s must be a data class", method, callee.Name)
}
@ -1190,10 +1190,6 @@ func stmtsMatch(stmts []Stmt, match func(Expr) bool) bool {
if exprMatches(s.Value, match) {
return true
}
case GoStmt:
if exprMatches(s.Value, match) {
return true
}
case DeferStmt:
if exprMatches(s.Value, match) {
return true
@ -1214,12 +1210,6 @@ func stmtsMatch(stmts []Stmt, match func(Expr) bool) bool {
if exprMatches(s.Source, match) || stmtsMatch(s.Body, match) {
return true
}
case SelectStmt:
for _, c := range s.Cases {
if exprMatches(c.Source, match) || stmtsMatch(c.Body, match) {
return true
}
}
case TryCatchStmt:
if stmtsMatch(s.TryBody, match) || stmtsMatch(s.CatchBody, match) {
return true
@ -1242,17 +1232,5 @@ func programExprMatches(program *Program, match func(Expr) bool) bool {
}
}
}
for _, worker := range program.Workers {
for _, field := range worker.Fields {
if exprMatches(field.Value, match) {
return true
}
}
for _, fn := range worker.Methods {
if stmtsMatch(fn.Body, match) {
return true
}
}
}
return false
}