Infer coroutine effects automatically
This commit is contained in:
parent
bac1183593
commit
5b30e49486
15 changed files with 339 additions and 103 deletions
|
|
@ -21,6 +21,7 @@ type Symbol struct {
|
|||
Type Type
|
||||
Mutable bool
|
||||
Decl any
|
||||
Effects Effect
|
||||
}
|
||||
|
||||
type Scope struct {
|
||||
|
|
@ -56,17 +57,18 @@ type ClassSymbol struct {
|
|||
}
|
||||
|
||||
type SemanticProgram struct {
|
||||
Syntax *Program
|
||||
Global *Scope
|
||||
Classes map[string]ClassDecl
|
||||
ClassInfo map[string]*ClassSymbol
|
||||
Functions map[string]FunctionDecl
|
||||
Enums map[string]EnumDecl
|
||||
Imports map[string]bool
|
||||
GoPackages map[string]*gotypes.Package
|
||||
HIR *HIRProgram
|
||||
Mappings *mappingState
|
||||
Diagnostics []SemanticDiagnostic
|
||||
Syntax *Program
|
||||
Global *Scope
|
||||
Classes map[string]ClassDecl
|
||||
ClassInfo map[string]*ClassSymbol
|
||||
Functions map[string]FunctionDecl
|
||||
Enums map[string]EnumDecl
|
||||
Imports map[string]bool
|
||||
GoPackages map[string]*gotypes.Package
|
||||
HIR *HIRProgram
|
||||
Mappings *mappingState
|
||||
Diagnostics []SemanticDiagnostic
|
||||
FunctionEffects map[string]Effect
|
||||
}
|
||||
|
||||
func Analyze(program *Program) (*SemanticProgram, error) {
|
||||
|
|
@ -91,15 +93,16 @@ func AnalyzeWithContext(program *Program, additional []*Program) (*SemanticProgr
|
|||
|
||||
func analyzeProgram(program *Program, additional []*Program) (*SemanticProgram, error) {
|
||||
semantic := &SemanticProgram{
|
||||
Syntax: program,
|
||||
Global: NewScope(nil),
|
||||
Classes: map[string]ClassDecl{},
|
||||
ClassInfo: map[string]*ClassSymbol{},
|
||||
Functions: map[string]FunctionDecl{},
|
||||
Enums: map[string]EnumDecl{},
|
||||
Imports: map[string]bool{},
|
||||
GoPackages: map[string]*gotypes.Package{},
|
||||
Mappings: &mappingState{functions: map[string]string{}},
|
||||
Syntax: program,
|
||||
Global: NewScope(nil),
|
||||
Classes: map[string]ClassDecl{},
|
||||
ClassInfo: map[string]*ClassSymbol{},
|
||||
Functions: map[string]FunctionDecl{},
|
||||
Enums: map[string]EnumDecl{},
|
||||
Imports: map[string]bool{},
|
||||
GoPackages: map[string]*gotypes.Package{},
|
||||
Mappings: &mappingState{functions: map[string]string{}},
|
||||
FunctionEffects: map[string]Effect{},
|
||||
}
|
||||
programs := append([]*Program{program}, additional...)
|
||||
for _, source := range programs {
|
||||
|
|
@ -198,6 +201,7 @@ func analyzeProgram(program *Program, additional []*Program) (*SemanticProgram,
|
|||
if err := resolver.resolve(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inferCoroutineEffects(semantic)
|
||||
return semantic, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue