Ejemplo n.º 1
0
        private SyntaxNode BindCall(CallNode node, Dictionary <string, string> environment)
        {
            string name;

            if (!environment.TryGetValue(node.funcName, out name))
            {
                throw new Exception("Unknow identifier: " + node.funcName);
            }
            List <SyntaxNode> boundValues = new List <SyntaxNode>();

            foreach (SyntaxNode val in node.values)
            {
                boundValues.Add(BindExpression(val, environment));
            }
            return(new CallNode(name, boundValues));
        }
Ejemplo n.º 2
0
        private string GenerateCall(CallNode node, List <Instruction> instructions)
        {
            string r          = GetRegister();
            string callString = node.funcName + "(";

            for (int i = 0; i < node.values.Count; i++)
            {
                callString += GenerateExpression(node.values[i], instructions);
                if (i == node.values.Count - 1)
                {
                    callString += ")";
                }
                else
                {
                    callString += ",";
                }
            }
            instructions.Add(new MoveInstruction(callString, r));
            return(r);
        }