public void TwoFunctions() { var function = new Function(new FunctionFirm("main", VariableType.Void, new List <Argument>()), new Block(new List <Statement>() { new AssignmentStatement("c", new Call("add", new ConstantExpression(1), new ConstantExpression(2))) })); var addFirm = new FunctionFirm("add", VariableType.Void, new List <Argument> { new Argument(VariableType.Int, "a"), new Argument(VariableType.Int, "b") }); var add = new Function(addFirm, new Block(new List <Statement>() { new ReturnStatement(new ExpressionNode(Operator.Add, new ReferenceExpression("a"), new ReferenceExpression("b"))), })); var ast = new Program(new List <Function>() { function, add }); var scope = new SymbolTable(); var mainScope = scope.CreateChildScope(function); mainScope.AnnotateSymbol("T1"); mainScope.AnnotateSymbol("T2"); mainScope.AnnotateSymbol("T3"); mainScope.AnnotateSymbol("c"); var addScope = scope.CreateChildScope(add); addScope.AnnotateSymbol("T4"); addScope.AnnotateSymbol("a"); addScope.AnnotateSymbol("b"); AssertScope(ast, scope); }
public static IntermediateCode FunctionDefinition(FunctionFirm function) { return(new FunctionDefinitionCode(function)); }
public FunctionDefinitionCode(FunctionFirm firm) { Firm = firm; }