Пример #1
0
        public void Emit(CompilerErrorCollection errors, MethodBuilder m)
        {
            //Set the parameters
            //ParameterBuilder[] parms = new ParameterInfo[args.Length];
            for (int i = 0; i < args.Length; i++)
            {
                m.DefineParameter(i + 1, ParameterAttributes.None, args[i].Name);
            }

            ILGenerator gen = m.GetILGenerator();

            //Define the IT variable
            LocalRef it = locals["IT"] as LocalRef;

            DefineLocal(gen, it);

            statements.Process(this, errors, gen);

            statements.Emit(this, gen);

            //Cast the IT variable to our return type and return it
            if (m.ReturnType != typeof(void))
            {
                gen.Emit(OpCodes.Ldloc, it.Local);
                Expression.EmitCast(gen, it.Type, m.ReturnType);
            }
            gen.Emit(OpCodes.Ret);
        }
Пример #2
0
 public void DefineLocal(ILGenerator gen, LocalRef l)
 {
     l.Local = gen.DeclareLocal(l.Type);
     if (program.compileropts.IncludeDebugInformation)
     {
         l.Local.SetLocalSymInfo(l.Name);
     }
 }
Пример #3
0
        public LOLMethod(FunctionRef info, LOLProgram prog)
        {
            this.info    = info;
            this.args    = new ArgumentRef[info.Arity + (info.IsVariadic ? 1 : 0)];
            this.program = prog;
            this.locals  = new Scope(prog.globals);

            LocalRef it = new LocalRef("IT");

            locals.AddSymbol(it);
        }