Ejemplo n.º 1
0
        public override TypeReference ResolveType(Application app, Page page)
        {
            MethodDefinition meth = page.GetMethod (Name);

            ResolvedType = meth.ReturnType;
            return ResolvedType;
        }
Ejemplo n.º 2
0
        public override void Emit(Application app, Page page, ILProcessor processor)
        {
            MethodDefinition meth = page.GetMethod (Name);

            processor.Emit (OpCodes.Ldarg_0);
            processor.Emit (OpCodes.Ldarg_1);
            processor.Emit (OpCodes.Ldarg_2);

            for (int i = 2; i < meth.Parameters.Count; i++) {
                if (i - 2 < Arguments.Count) {
                    Arguments [i - 2].Emit (app, page, processor);
                    continue;
                }
                ParameterDefinition p = meth.Parameters [i];
                if (!p.HasConstant)
                    throw new Exception ("Illegal invoke statement, incorrect number of parameters.");
                object constant = p.Constant;
                if (constant is string)
                    processor.Emit (OpCodes.Ldstr, (string) constant);
                else if (constant is int)
                    processor.Emit (OpCodes.Ldc_I4, (int) constant);
                else if (constant is double)
                    processor.Emit (OpCodes.Ldc_R4, (double) constant);
                else
                    throw new Exception (String.Format ("Illegal default argument type {0}", constant));
            }

            processor.Emit (OpCodes.Call, meth);
        }