Esempio n. 1
0
        public override void Visit(Model.Bytecode.LoadMethodAddressInstruction instruction)
        {
            Cecil.Cil.OpCode op = Cecil.Cil.OpCodes.Ldftn;

            if (instruction.Operation == AnalysisNet.Bytecode.LoadMethodAddressOperation.Virtual)
            {
                op = Cecil.Cil.OpCodes.Ldvirtftn;
            }

            Cecil.Cil.Instruction cilIns = processor.Create(op, referenceGenerator.MethodReference(instruction.Method));
            Result = new List <Mono.Cecil.Cil.Instruction>()
            {
                cilIns
            };
        }
Esempio n. 2
0
        public void PropertyDefinitions(AnalysisNet.Types.TypeDefinition analysisNetType, Cecil.TypeDefinition cecilTypeDef)
        {
            foreach (AnalysisNet.Types.PropertyDefinition analysisNetProp in analysisNetType.PropertyDefinitions)
            {
                Cecil.PropertyDefinition cecilProp = new Cecil.PropertyDefinition(analysisNetProp.Name,
                                                                                  Cecil.PropertyAttributes.None,
                                                                                  ReferenceGenerator.TypeReference(analysisNetProp.PropertyType));

                if (analysisNetProp.Getter != null)
                {
                    Cecil.MethodDefinition getterDef = ReferenceGenerator.MethodReference(analysisNetProp.Getter).Resolve();
                    cecilProp.GetMethod = getterDef;
                }
                if (analysisNetProp.Setter != null)
                {
                    Cecil.MethodDefinition setterDef = ReferenceGenerator.MethodReference(analysisNetProp.Setter).Resolve();
                    cecilProp.SetMethod = setterDef;
                }

                SetCustomAttributes(analysisNetProp.Attributes, cecilProp.CustomAttributes);

                // Properties.Add sets this field
                //cecilProp.DeclaringType = ReferenceGenerator.TypeReference(analysisNetType).Resolve();
                cecilTypeDef.Properties.Add(cecilProp);
            }
        }
Esempio n. 3
0
        private void SetOverrides(AnalysisNet.Types.MethodDefinition methodDefinition, Cecil.MethodDefinition methodDef)
        {
            ISet <AnalysisNet.Types.MethodImplementation>        impls        = methodDefinition.ContainingType.ExplicitOverrides;
            IEnumerable <AnalysisNet.Types.MethodImplementation> matchedImpls = impls.Where(impl => methodDefinition.MatchReference(impl.ImplementingMethod));

            methodDef.Overrides.AddRange(matchedImpls.Select(impl => ReferenceGenerator.MethodReference(impl.ImplementedMethod)));
        }