コード例 #1
0
        private CallExp CreateCallExp(List <Node> parameters)
        {
            parameters.CheckLength(2);
            var node = new CallExp
            {
                MethodName = (TokenNode)parameters[0],
                Arguments  = ((NodeList)parameters[1])?.Nodes.Cast <Expression>().ToList()
            };

            node.AddChildren(node.MethodName);
            node.AddChildren(node.Arguments?.ToArray());

            return(node);
        }
コード例 #2
0
ファイル: codegen.cs プロジェクト: ydunk/masters
 public void CallExp(CallExp e)
 {
     for (int i = 0; i < e.Params.Length; i++)
     {
         e.Params[i].Visit(this);
     }
     if (e.System)
     {
         il.Emit(OpCodes.Call, ((typeof(LispRuntime)).GetMethod(e.FunctionName)));
     }
     else
     {
         il.Emit(OpCodes.Call, (MethodInfo)Functions[e.FunctionName]);
     }
 }
コード例 #3
0
ファイル: typecheck.cs プロジェクト: ydunk/masters
    public void CallExp(CallExp e)
    {
        if (!e.System)
        {
            if (e.FunctionName == CurrentFuncName)
            {
                for (int i = 0; i < e.Params.Length; i++)
                {
                    e.Params[i].Visit(this);
                }

                e.ExpType = typeof(void);            //Recursive Function. Return type unknown.
            }
            else
            {
                FunctionDef f = (FunctionDef)Functions[e.FunctionName];
                for (int i = 0; i < e.Params.Length; i++)
                {
                    e.Params[i].Visit(this);
                    CheckAny(ref e.Params[i], (Type)f.Params[i]);
                }
                e.ExpType = f.ExpType;
            }
        }
        else
        {
            FunctionDef f = (FunctionDef)Functions[e.FunctionName];
            for (int i = 0; i < e.Params.Length; i++)
            {
                e.Params[i].Visit(this);
                CheckAny(ref e.Params[i], (Type)f.Params[i]);
            }
            //ExpType of System functions is set while parsing itself.
            //e.ExpType = (Type)Functions[e.FunctionName];
        }
    }