ExitFunctionDeclaration 函数声明,设置函数的返回类型
(ctx *parser.FunctionDeclarationContext)
| 71 | |
| 72 | // ExitFunctionDeclaration 函数声明,设置函数的返回类型 |
| 73 | func (t *TypeResolver) ExitFunctionDeclaration(ctx *parser.FunctionDeclarationContext) { |
| 74 | // TypeScopeResolver.EnterFunctionDeclaration() 写入的数据 |
| 75 | function := t.at.GetNode2Scope()[ctx] |
| 76 | if ctx.TypeTypeOrVoid() != nil { |
| 77 | // ExitTypeTypeOrVoid 设置的返回值类型 |
| 78 | returnType := t.at.GetTypeOfNode()[ctx.TypeTypeOrVoid()] |
| 79 | switch function.(type) { |
| 80 | case *symbol.Func: |
| 81 | function.(*symbol.Func).SetReturnType(returnType) |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | switch function.(type) { |
| 86 | case *symbol.Func: |
| 87 | fn := function.(*symbol.Func) |
| 88 | scope := t.at.FindEncloseScopeOfNode(ctx) |
| 89 | found := t.at.FindFunction(scope, fn.GetName(), fn.GetParameterType()) |
| 90 | if found != nil && found != function && found.GetName() != symbol.OperatorName { |
| 91 | t.at.Log(ctx, fmt.Sprintf("%s already declared in this block", found.GetName())) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | } |
| 96 | |
| 97 | // ExitFormalParameter 函数入参,设置函数入参类型 |
| 98 | func (t *TypeResolver) ExitFormalParameter(ctx *parser.FormalParameterContext) { |
nothing calls this directly
no test coverage detected