public override AstNode VisitMainClass(MainClass ast) { var mainMethod = new Method() { Name = "Main", IsStatic = true }; mainMethod.ReturnType = PrimaryType.Void; var codeType = ast.Type as CodeClassType; codeType.StaticMethods.Add(mainMethod); return ast; }
public override AstNode VisitMainClass(MainClass ast) { m_currentType = ast.Type as CodeClassType; Debug.Assert(m_currentType.Methods.Count == 0); Debug.Assert(m_currentType.StaticMethods.Count == 1); m_currentMethod = m_currentType.StaticMethods[0]; m_currentVariableIndex = 0; m_currentMethodParameters = new VariableCollection<Parameter>() { new Parameter() { Name = ast.ArgName.Value, Type = ArrayType.StrArray } }; m_currentMethodVariables = new VariableCollection<VariableInfo>(); foreach (var statement in ast.Statements) { Visit(statement); } return ast; }
public override AstNode VisitMethodDecl(MethodDecl ast) { m_currentMethod = ast.MethodInfo; m_currentVariableIndex = 0; m_currentMethodParameters = new VariableCollection<Parameter>(); foreach (var param in m_currentMethod.Parameters) { m_currentMethodParameters.Add(param); } m_currentMethodVariables = new VariableCollection<VariableInfo>(); if (ast.Statements == null || ast.ReturnExpression == null) { m_errorManager.AddError(c_SE_NotSupported, ast.Name.Span, "A method must have body defined"); return ast; } foreach (var statement in ast.Statements) { Visit(statement); } Visit(ast.ReturnExpression); return ast; }
public override AstNode VisitMethodDecl(MethodDecl ast) { m_currentMethod = ast.MethodInfo; m_currentMethodParameters = new VariableCollection<Parameter>(); foreach (var param in m_currentMethod.Parameters) { m_currentMethodParameters.Add(param); } m_currentMethodVariables = new VariableCollection<VariableInfo>(); foreach (var statement in ast.Statements) { Visit(statement); } Visit(ast.ReturnExpression); return ast; }