Ejemplo n.º 1
0
        // Compile a function with given arguments
        void CompileBuiltin(BuiltinSymbol funcsym, NodeListParser nlp)
        {
            Logger.WriteLine(3, "CompileBuiltin {0} <{1}>", funcsym.Name, nlp);
            var ci = funcsym.CallInfo;

            for (int i = 0; i < ci.Arguments.Count; i++)
            {
                if (ci.ArgOptional[i] && nlp.Done)
                {
                    _gen.EmitLoadValue(null);
                }
                else if (ci.Arguments[i] == typeof(AttributeValue))
                {
                    _gen.EmitLoadValue(DefAttribute(nlp.GetIdent())); // special for attribute
                }
                // TODO: could possibly check for combo of boolean expected and undefined ident, and emit false
                else
                {
                    CompileArg(ci.Arguments[i], nlp);
                }
            }
            nlp.Expect(nlp.Done, "no more arguments for {0}", funcsym.Name);
            _gen.EmitCall(funcsym);
        }
Ejemplo n.º 2
0
 internal void EmitCall(BuiltinSymbol funcsym)
 {
     Logger.WriteLine(4, "Emit call {0}", funcsym);
     Emit(Opcodes.CALL, funcsym.CallInfo);
 }