public void Visit(NFunDef nFunDef) { currentFunction = semanticAnalyzer.GetFunctionSymbolByLexeme(nFunDef.AnchorToken.Lexeme); // No need to visit neither parameter list nor variable definition list NStmtList stmtList = (NStmtList)nFunDef[2]; Visit(stmtList); currentFunction = null; }
public string Visit(NFunDef nFunDef) { currentFunction = semanticAnalyzer.GetFunctionSymbolByLexeme(nFunDef.AnchorToken.Lexeme); string lexeme = nFunDef.AnchorToken.Lexeme; Node parameters = nFunDef[0]; Node varDefList = nFunDef[1]; Node stmtList = nFunDef[2]; string retVal = "\t.method public static hidebysig default int64 '" + lexeme + "' (" + Visit((dynamic)parameters) + ") cil managed {\n"; if (lexeme == "main") { retVal += "\t\t.entrypoint\n"; } retVal += Visit((dynamic)varDefList) + Visit((dynamic)stmtList) + "\t\tldc.i8 0\n" + "\t\tret\n" + "\t}\n"; currentFunction = null; return(retVal); }