Example #1
0
            public AtomGetterMethodWeaver(AtomWeaverV2 weaver, PropertyDefinition property, FieldReference atomField)
            {
                _atomField = atomField;
                _property  = property;

                _atomDebugName  = $"{property.DeclaringType.FullName}::{property.Name}";
                _resultVariable = new VariableDefinition(property.PropertyType);

                _nullCheckEndInstruction  = Instruction.Create(OpCodes.Nop);
                _directEvalEndInstruction = Instruction.Create(OpCodes.Nop);
                _loadResultInstruction    = Instruction.Create(OpCodes.Ldloc, _resultVariable);

                var propertyType = property.PropertyType;

                _atomCreateMethod   = Helpers.MakeGenericMethod(weaver._atomCreateMethod, propertyType);
                _atomPullCtorMethod = Helpers.MakeHostInstanceGeneric(weaver._atomPullCtorMethod, propertyType);
                _tryEnterMethod     = Helpers.MakeHostInstanceGeneric(weaver._atomDirectEvalMethod, propertyType);
                _atomGetMethod      = Helpers.MakeHostInstanceGeneric(weaver._atomGetValueMethod, propertyType);

                var body = property.GetMethod.Body;

                body.InitLocals = true;
                body.Variables.Add(_resultVariable);
            }