Beispiel #1
0
 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);
 }
Beispiel #2
0
        //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.");
            }
        }
Beispiel #3
0
 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)");
     }
 }