public override void CaseAFunctioncall(AFunctioncall node) { InAFunctioncall(node); if (node.GetEol() != null) { node.GetEol().Apply(this); } if (node.GetRparen() != null) { node.GetRparen().Apply(this); } if (node.GetArguments() != null) { node.GetArguments().Apply(this); } if (node.GetLparen() != null) { node.GetLparen().Apply(this); } if (node.GetId() != null) { node.GetId().Apply(this); } OutAFunctioncall(node); }
//functioncall public override void OutAFunctioncall(AFunctioncall node) { Definition idDef, exprDef; String funcName = node.GetId().Text; // ensure id has been declared if (!(_currentSymbolTable.TryGetValue(funcName, out idDef) || _globalSymbolTable.TryGetValue(funcName, out idDef))) { Console.WriteLine("[" + node.GetId().Line + "] : " + funcName + " is not defined."); // ensure id is a method } else if (!(idDef is MethodDefinition)) { Console.WriteLine("[" + node.GetId().Line + "] : " + funcName + " is not a method."); // ensure argument is decorated } else if (!_decoratedParseTree.TryGetValue(node.GetParams(), out exprDef)) { Console.WriteLine("[" + node.GetId().Line + "] : argument was not decorated."); // Ensure that expr is a string or basic type } else if (!(exprDef is StringTypeDefinition) || !(exprDef is BasicTypeDefinition)) { Console.WriteLine("[" + node.GetId().Line + "] : language only allows strings and basic types as arguments."); } }
public override void OutAFunctioncall(AFunctioncall node) { if (node.GetId().Text.Equals("Print")) { _output.WriteLine("\tcall void [mscorlib]System.Console::Write(string)"); } if (node.GetId().Text.Equals("NewLine")) { _output.WriteLine("\tldstr \"\\n\""); _output.WriteLine("\tcall void [mscorlib]System.Console::Write(string)"); } if (node.GetId().Text.Equals("PrintInt")) { _output.WriteLine("\tcall void [mscorlib]System.Console::Write(int32)"); } if (node.GetId().Text.Equals("PrintFloat")) { _output.WriteLine("\tcall void [mscorlib]System.Console::Write(float32)"); } }