private void WaddleFunctionDeclaration(FunctionDeclSyntax function) { WaddleBody(function.Body); if (_currentFunction?.Type is not null && function.Body.Statements.LastOrDefault() is not ReturnStmtSyntax) { throw new SemanticErrorException($"missing return statement in function {_currentFunction?.Name}"); } }
private void WaddleFunctionDeclaration(FunctionDeclSyntax functionSyntax) { var parameters = functionSyntax.Parameters.Select(param => new VariableDecl(param !.Name, param !.TypeSyntax.ToSymbol())).ToArray(); var function = new FunctionDecl(functionSyntax.Name, functionSyntax.ReturnType?.ToSymbol(), functionSyntax.Body.Statements .OfType <DeclStmtSyntax>() .Select(stmt => new VariableDecl(stmt.ParameterDeclSyntax.Name, stmt.ParameterDeclSyntax.TypeSyntax.ToSymbol())) .Concat(parameters), parameters); _functions.Add(function.Name, function); }
public virtual TResult Visit(FunctionDeclSyntax syntax) { return(DefaultResult); }
public void LeaveFunctionDeclaration(FunctionDeclSyntax syntax, WaddleContext ctx) { }
public bool EnterFunctionDeclaration(FunctionDeclSyntax syntax, WaddleContext ctx) { _currentFunction = _currentFunction = _functions[syntax.Name]; return(true); }