Exemplo n.º 1
0
        public override void Resolve(CodeGen code_gen)
        {
            if (is_resolved)
            {
                return;
            }

            meth.Resolve(code_gen);
            peapi_method = code_gen.PEFile.AddMethodSpec(meth.PeapiMethod, sig.Resolve(code_gen));

            is_resolved = true;
        }
Exemplo n.º 2
0
 public override void Emit(CodeGen code_gen, MethodDef meth,
                           PEAPI.CILInstructions cil)
 {
     if (field_ref != null)
     {
         field_ref.Resolve(code_gen);
         cil.FieldInst(PEAPI.FieldOp.ldtoken,
                       field_ref.PeapiField);
     }
     else if (method_ref != null)
     {
         method_ref.Resolve(code_gen);
         cil.MethInst(PEAPI.MethodOp.ldtoken,
                      method_ref.PeapiMethod);
     }
     else if (type_ref != null)
     {
         type_ref.Resolve(code_gen);
         cil.TypeInst(PEAPI.TypeOp.ldtoken,
                      type_ref.PeapiType);
     }
 }
Exemplo n.º 3
0
        public void DefineContents(CodeGen code_gen)
        {
            ArrayList fielddef_list = new ArrayList();

            foreach (FieldDef fielddef in field_list)
            {
                if (is_enum_class && fielddef.Name == "value__")
                {
                    fielddef.Attributes |= PEAPI.FieldAttr.SpecialName | PEAPI.FieldAttr.RTSpecialName;
                }

                fielddef.Define(code_gen, classdef);
                fielddef_list.Add(fielddef.PeapiFieldDef);
            }

            classdef.SetFieldOrder(fielddef_list);

            foreach (MethodDef methoddef in method_list)
            {
                methoddef.Define(code_gen);
            }

            if (event_list != null)
            {
                foreach (EventDef eventdef in event_list)
                {
                    eventdef.Define(code_gen, classdef);
                }
            }

            if (property_list != null)
            {
                foreach (PropertyDef propdef in property_list)
                {
                    propdef.Define(code_gen, classdef);
                }
            }

            if (customattr_list != null)
            {
                foreach (CustomAttr customattr in customattr_list)
                {
                    customattr.AddTo(code_gen, classdef);
                    if (customattr.IsSuppressUnmanaged(code_gen))
                    {
                        classdef.AddAttribute(PEAPI.TypeAttr.HasSecurity);
                    }
                }
            }

            /// Add declarative security to this class
            if (decl_sec != null)
            {
                decl_sec.AddTo(code_gen, classdef);
                classdef.AddAttribute(PEAPI.TypeAttr.HasSecurity);
            }

            if (override_list != null)
            {
                foreach (DictionaryEntry entry in override_list)
                {
                    MethodDef       body        = (MethodDef)entry.Key;
                    DictionaryEntry decl        = (DictionaryEntry)entry.Value;
                    BaseTypeRef     parent_type = (BaseTypeRef)decl.Key;
                    parent_type.Resolve(code_gen);
                    string        over_name = (string)decl.Value;
                    BaseMethodRef over_meth = parent_type.GetMethodRef(body.RetType,
                                                                       body.CallConv, over_name, body.ParamTypeList(), body.GenParamCount);
                    over_meth.Resolve(code_gen);
                    classdef.AddMethodOverride(over_meth.PeapiMethod,
                                               body.PeapiMethodDef);
                }
            }

            if (override_long_list != null)
            {
                foreach (DictionaryEntry entry in override_long_list)
                {
                    string        sig  = (string)entry.Key;
                    BaseMethodRef decl = (BaseMethodRef)entry.Value;
                    MethodDef     body = (MethodDef)method_table[sig];
                    decl.Resolve(code_gen);
                    classdef.AddMethodOverride(decl.PeapiMethod,
                                               body.PeapiMethodDef);
                }
            }
        }
Exemplo n.º 4
0
 public void AddTo(CodeGen code_gen, PEAPI.MetaDataElement elem)
 {
     method_ref.Resolve(code_gen);
     code_gen.PEFile.AddCustomAttribute(method_ref.PeapiMethod, data, elem);
 }
Exemplo n.º 5
0
 public override void Emit(CodeGen code_gen, MethodDef meth,
                           PEAPI.CILInstructions cil)
 {
     operand.Resolve(code_gen);
     cil.MethInst(op, operand.PeapiMethod);
 }