Example #1
0
        /**
         * public boolean hasPendingChanges() { return isToBeUpdated() || isToBeCreated() || isToBeDeleted(); }
         */
        protected void ImplementHasPendingChanges(PropertyInstance p_hasPendingChanges, PropertyInstance p_ToBeUpdated, PropertyInstance p_ToBeCreated,
                                                  PropertyInstance p_ToBeDeleted)
        {
            IMethodVisitor mg = VisitMethod(p_hasPendingChanges.Getter);

            p_hasPendingChanges = PropertyInstance.FindByTemplate(p_hasPendingChanges, false);
            p_hasPendingChanges.AddAnnotation(c_ignoreToBeUpdated);
            p_hasPendingChanges.AddAnnotation(c_fireThisOPC, p_ToBeCreated.Name);
            p_hasPendingChanges.AddAnnotation(c_fireThisOPC, p_ToBeUpdated.Name);
            p_hasPendingChanges.AddAnnotation(c_fireThisOPC, p_ToBeDeleted.Name);

            Label trueLabel = mg.NewLabel();

            mg.LoadThis();
            mg.InvokeVirtual(p_ToBeUpdated.Getter);
            mg.IfZCmp(CompareOperator.NE, trueLabel);

            mg.LoadThis();
            mg.InvokeVirtual(p_ToBeCreated.Getter);
            mg.IfZCmp(CompareOperator.NE, trueLabel);

            mg.LoadThis();
            mg.InvokeVirtual(p_ToBeDeleted.Getter);
            mg.IfZCmp(CompareOperator.NE, trueLabel);

            mg.Push(false);
            mg.ReturnValue();

            mg.Mark(trueLabel);
            mg.Push(true);
            mg.ReturnValue();
            mg.EndMethod();
        }
Example #2
0
 public virtual void Push <T>()
 {
     if (mv != null)
     {
         mv.Push <T>();
     }
 }
Example #3
0
        public static void CacheModificationInternalUpdate(PropertyInstance p_cacheModification, IMethodVisitor mg, Script script)
        {
            LocalVariableInfo loc_cacheModification = mg.NewLocal <ICacheModification>();
            LocalVariableInfo loc_oldActive         = mg.NewLocal <bool>();

            // ICacheModification cacheModification = this.cacheModification;
            mg.CallThisGetter(p_cacheModification);
            mg.StoreLocal(loc_cacheModification);

            // boolean oldInternalUpdate = cacheModification.isInternalUpdate();
            mg.LoadLocal(loc_cacheModification);
            mg.InvokeInterface(new MethodInstance(null, typeof(ICacheModification), typeof(bool), "get_InternalUpdate"));
            mg.StoreLocal(loc_oldActive);

            // callModificationInternalUpdate(cacheModification, oldInternalUpdate, true)
            mg.LoadLocal(loc_cacheModification);
            mg.LoadLocal(loc_oldActive);
            mg.Push(true);
            mg.InvokeStatic(m_callCacheModificationInternalUpdate);

            mg.TryFinally(script, delegate(IMethodVisitor mv2)
            {
                // callModificationInternalUpdate(cacheModification, oldInternalUpdate, false)
                mv2.LoadLocal(loc_cacheModification);
                mv2.LoadLocal(loc_oldActive);
                mv2.Push(false);
                mv2.InvokeStatic(m_callCacheModificationInternalUpdate);
            });
        }
Example #4
0
        protected void ImplementSetRelation(RelationMember[] relationMembers, FieldInstance[] f_relations)
        {
            MethodInstance template_m_setRelation = new MethodInstance(null, typeof(RootCacheValue), typeof(void), "SetRelation", typeof(int), typeof(IObjRef[]));

            IMethodVisitor mv       = VisitMethod(template_m_setRelation);
            Label          l_finish = mv.NewLabel();

            for (int relationIndex = 0, size = f_relations.Length; relationIndex < size; relationIndex++)
            {
                FieldInstance f_relation = f_relations[relationIndex];

                Label l_notEqual = mv.NewLabel();

                mv.LoadArg(0);
                mv.Push(relationIndex);

                mv.IfCmp(typeof(int), CompareOperator.NE, l_notEqual);

                mv.PutThisField(f_relation, delegate(IMethodVisitor mg)
                {
                    mg.LoadArg(1);
                });
                mv.GoTo(l_finish);
                mv.Mark(l_notEqual);
            }
            mv.ThrowException(typeof(ArgumentException), "Given relationIndex not known");
            mv.Mark(l_finish);
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #5
0
        public override void VisitEnd()
        {
            Type entityType = metaData.EntityType;
            {
                IMethodVisitor mv = VisitMethod(template_m_getEntityType);
                mv.Push(entityType);
                mv.ReturnValue();
                mv.EndMethod();
            }

            {
                IMethodVisitor mv = VisitMethod(template_m_getIdIndex);
                mv.Push(idIndex);
                mv.ReturnValue();
                mv.EndMethod();
            }

            FieldInstance f_id = ImplementNativeField(this, metaData.GetIdMemberByIdIndex(idIndex), template_m_getId, template_m_setId);

            if (f_id.Type.Type.IsPrimitive)
            {
                // id is a primitive type. So we use an improved version of the 3-tuple equals without boxing the id
                IMethodVisitor mv         = VisitMethod(template_m_isEqualTo);
                Label          l_notEqual = mv.NewLabel();

                mv.Push(entityType);
                mv.LoadArg(0);
                mv.IfCmp(typeof(Type), CompareOperator.NE, l_notEqual);

                mv.Push(idIndex);
                mv.LoadArg(1);
                mv.IfCmp(typeof(bool), CompareOperator.NE, l_notEqual);

                mv.GetThisField(f_id);
                mv.LoadArg(2);
                mv.Unbox(f_id.Type.Type);
                mv.IfCmp(f_id.Type.Type, CompareOperator.NE, l_notEqual);

                mv.Push(true);
                mv.ReturnValue();
                mv.Mark(l_notEqual);
                mv.Push(false);
                mv.ReturnValue();
                mv.EndMethod();
            }
            base.VisitEnd();
        }
Example #6
0
        protected void ImplementGetRealType(IPropertyInfo[] property)
        {
            IMethodVisitor mv = VisitMethod(template_m_getRealType);

            mv.Push(property[property.Length - 1].PropertyType);
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #7
0
        protected void ImplementGetDeclaringType(IPropertyInfo[] property)
        {
            IMethodVisitor mv = VisitMethod(template_m_getDeclaringType);

            mv.Push(declaringType);
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #8
0
        protected void ImplementCanWrite(IPropertyInfo[] property)
        {
            IMethodVisitor mv = VisitMethod(template_m_canWrite);

            mv.Push(property[property.Length - 1].IsWritable);
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #9
0
        protected void ImplementIsToMany(IPropertyInfo[] propertyPath)
        {
            IMethodVisitor mv = VisitMethod(template_m_isToMany);

            mv.Push(ListUtil.IsCollection(propertyPath[propertyPath.Length - 1].PropertyType));
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #10
0
        public void visitEnd()
        {
            // AbstractPrivilege.class;
            MethodInstance template_m_getPrimitivePropertyPrivilege = new MethodInstance(null, typeof(IPrivilege), typeof(IPropertyPrivilege),
                                                                                         "GetPrimitivePropertyPrivilege", typeof(int));

            MethodInstance template_m_setPrimitivePropertyPrivilege = new MethodInstance(null, MethodAttributes.Family, typeof(void), "SetPrimitivePropertyPrivilege",
                                                                                         typeof(int), typeof(IPropertyPrivilege));

            MethodInstance template_m_getRelationPropertyPrivilege = new MethodInstance(null, typeof(IPrivilege), typeof(IPropertyPrivilege),
                                                                                        "GetRelationPropertyPrivilege", typeof(int));

            MethodInstance template_m_setRelationPropertyPrivilege = new MethodInstance(null, MethodAttributes.Family, typeof(void), "SetRelationPropertyPrivilege",
                                                                                        typeof(int), typeof(IPropertyPrivilege));

            ImplementGetSetPropertyPrivilege(metaData.PrimitiveMembers, template_m_getPrimitivePropertyPrivilege, template_m_setPrimitivePropertyPrivilege);
            ImplementGetSetPropertyPrivilege(metaData.RelationMembers, template_m_getRelationPropertyPrivilege, template_m_setRelationPropertyPrivilege);

            {
                IMethodVisitor mg = VisitMethod(new MethodInstance(null, typeof(IPrivilege), typeof(bool), "get_CreateAllowed"));
                mg.Push(create);
                mg.ReturnValue();
                mg.EndMethod();
            }
            {
                IMethodVisitor mg = VisitMethod(new MethodInstance(null, typeof(IPrivilege), typeof(bool), "get_ReadAllowed"));
                mg.Push(read);
                mg.ReturnValue();
                mg.EndMethod();
            }
            {
                IMethodVisitor mg = VisitMethod(new MethodInstance(null, typeof(IPrivilege), typeof(bool), "get_UpdateAllowed"));
                mg.Push(update);
                mg.ReturnValue();
                mg.EndMethod();
            }
            {
                IMethodVisitor mg = VisitMethod(new MethodInstance(null, typeof(IPrivilege), typeof(bool), "get_DeleteAllowed"));
                mg.Push(delete);
                mg.ReturnValue();
                mg.EndMethod();
            }
            {
                IMethodVisitor mg = VisitMethod(new MethodInstance(null, typeof(IPrivilege), typeof(bool), "get_ExecuteAllowed"));
                mg.Push(execute);
                mg.ReturnValue();
                mg.EndMethod();
            }
            {
                IMethodVisitor mg = VisitMethod(new MethodInstance(null, typeof(IPrivilege), typeof(IPropertyPrivilege), "GetDefaultPropertyPrivilegeIfValid"));
                mg.PushNull();
                mg.ReturnValue();
                mg.EndMethod();
            }
            ImplementConstructor(template_m_setPrimitivePropertyPrivilege, template_m_setRelationPropertyPrivilege);
            base.VisitEnd();
        }
Example #11
0
        protected void ImplementGetEntityType()
        {
            MethodInstance template_m_getEntityType = new MethodInstance(null, typeof(RootCacheValue), typeof(Type), "getEntityType");

            IMethodVisitor mv = VisitMethod(template_m_getEntityType);

            mv.Push(metaData.EntityType);
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #12
0
        protected void ImplementGetPrimitives(Member[] primitiveMembers, FieldInstance[] f_primitives, FieldInstance[] f_nullFlags)
        {
            MethodInstance template_m_getPrimitives = new MethodInstance(null, typeof(RootCacheValue), typeof(Object[]), "GetPrimitives");

            IMethodVisitor mv = VisitMethod(template_m_getPrimitives);

            mv.Push(f_primitives.Length);
            mv.NewArray(objType);

            for (int primitiveIndex = 0, size = f_primitives.Length; primitiveIndex < size; primitiveIndex++)
            {
                FieldInstance f_primitive = f_primitives[primitiveIndex];
                FieldInstance f_nullFlag  = f_nullFlags[primitiveIndex];

                Label?l_fieldIsNull = null;

                if (f_nullFlag != null)
                {
                    l_fieldIsNull = mv.NewLabel();
                    // only do something if the field is non-null
                    mv.GetThisField(f_nullFlag);
                    mv.IfZCmp(CompareOperator.NE, l_fieldIsNull.Value);
                }
                // duplicate array instance on stack
                mv.Dup();

                mv.Push(primitiveIndex);
                mv.GetThisField(f_primitive);

                mv.ValueOf(f_primitive.Type.Type);
                mv.ArrayStore(objType);

                if (f_nullFlag != null)
                {
                    mv.Mark(l_fieldIsNull.Value);
                }
            }
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #13
0
        /**
         * public boolean isToBeCreated() { return get__Id() == null; }
         *
         * @param owner
         */
        protected PropertyInstance ImplementToBeCreated(PropertyInstance p_toBeCreated)
        {
            IMethodVisitor mg = VisitMethod(p_toBeCreated.Getter);

            p_toBeCreated = PropertyInstance.FindByTemplate(p_toBeCreated, false);
            Member idMember = metaData.IdMember;

            if (idMember is CompositeIdMember)
            {
                List <String> names = new List <String>();
                foreach (Member itemMember in ((CompositeIdMember)idMember).Members)
                {
                    names.Add(itemMember.Name);
                }
                p_toBeCreated.AddAnnotation(c_fireThisOPC, new Object[] { names.ToArray() });
            }
            else
            {
                p_toBeCreated.AddAnnotation(c_fireThisOPC, idMember.Name);
            }

            Label trueLabel = mg.NewLabel();

            mg.LoadThis();
            mg.InvokeVirtual(GetIdMethodCreator.GetGetId());

            mg.IfNull(trueLabel);

            mg.Push(false);
            mg.ReturnValue();

            mg.Mark(trueLabel);

            mg.Push(true);
            mg.ReturnValue();
            mg.EndMethod();
            return(p_toBeCreated);
        }
Example #14
0
        protected void ImplementGetRelations(RelationMember[] relationMembers, FieldInstance[] f_relations)
        {
            MethodInstance template_m_getRelations = new MethodInstance(null, typeof(RootCacheValue), typeof(IObjRef[][]), "GetRelations");

            IMethodVisitor mv = VisitMethod(template_m_getRelations);

            mv.Push(f_relations.Length);
            mv.NewArray(objRefArrayType);

            for (int relationIndex = 0, size = f_relations.Length; relationIndex < size; relationIndex++)
            {
                FieldInstance f_primitive = f_relations[relationIndex];

                // duplicate array instance on stack
                mv.Dup();

                mv.Push(relationIndex);
                mv.GetThisField(f_primitive);
                mv.ArrayStore(objRefArrayType);
            }
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #15
0
        protected void ImplementGetEntityType(IPropertyInfo[] property)
        {
            IMethodVisitor  mv         = VisitMethod(template_m_getEntityType);
            Type            entityType = this.entityType;
            IEntityMetaData metaData   = entityMetaDataProvider.GetMetaData(entityType, true);

            if (metaData != null)
            {
                entityType = metaData.EntityType;
            }
            mv.Push(entityType);
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #16
0
        protected void ImplementConstructor(MethodInstance template_m_setPrimitivePropertyPrivilege, MethodInstance template_m_setRelationPropertyPrivilege)
        {
            IBytecodeBehaviorState state       = State;
            ConstructorInfo        constructor = state.CurrentType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(bool), typeof(bool), typeof(bool), typeof(bool), typeof(bool),
                                                                                                                                                                           typeof(IPropertyPrivilege[]), typeof(IPropertyPrivilege[]) }, null);
            ConstructorInstance c_method = new ConstructorInstance(constructor);

            IMethodVisitor mg = VisitMethod(c_method);

            mg.LoadThis();
            mg.LoadArgs();
            mg.InvokeConstructor(c_method);

            Type propertyPrivilegeType = typeof(IPropertyPrivilege);

            for (int primitiveIndex = 0, size = metaData.PrimitiveMembers.Length; primitiveIndex < size; primitiveIndex++)
            {
                mg.LoadThis();
                mg.Push(primitiveIndex);
                mg.LoadArg(5);
                mg.Push(primitiveIndex);
                mg.ArrayLoad(propertyPrivilegeType);
                mg.InvokeVirtual(template_m_setPrimitivePropertyPrivilege);
            }
            for (int relationIndex = 0, size = metaData.RelationMembers.Length; relationIndex < size; relationIndex++)
            {
                mg.LoadThis();
                mg.Push(relationIndex);
                mg.LoadArg(6);
                mg.Push(relationIndex);
                mg.ArrayLoad(propertyPrivilegeType);
                mg.InvokeVirtual(template_m_setRelationPropertyPrivilege);
            }

            mg.ReturnValue();
            mg.EndMethod();
        }
Example #17
0
        protected void ImplementGetBaseType()
        {
            MethodInstance getBaseType = MethodInstance.FindByTemplate(template_m_getBaseType, true);

            if (getBaseType != null)
            {
                return;
            }
            IBytecodeBehaviorState state = State;
            IMethodVisitor         mg    = VisitMethod(template_m_getBaseType);

            mg.Push(state.OriginalType);
            mg.ReturnValue();
            mg.EndMethod();
        }
Example #18
0
        protected void ImplementGetName(IPropertyInfo[] property)
        {
            StringBuilder compositeName = new StringBuilder();

            for (int a = 0, size = property.Length; a < size; a++)
            {
                if (a > 0)
                {
                    compositeName.Append('.');
                }
                compositeName.Append(property[a].Name);
            }
            IMethodVisitor mv = VisitMethod(template_m_getName);

            mv.Push(compositeName.ToString());
            mv.ReturnValue();
            mv.EndMethod();
        }
Example #19
0
        public override void VisitEnd()
        {
            MethodInstance m_get__Id = MethodInstance.FindByTemplate(GetIdMethodCreator.template_m_entityEquals_getId, true);

            if (m_get__Id != null)
            {
                base.VisitEnd();
                return;
            }
            MethodInstance m_getEntityMetaData = EntityMetaDataHolderVisitor.GetImplementedGetEntityMetaData(this, metaData);
            IMethodVisitor mg = VisitMethod(GetIdMethodCreator.template_m_entityEquals_getId);

            mg.CallThisGetter(m_getEntityMetaData);
            mg.InvokeInterface(new MethodInstance(null, typeof(IEntityMetaData), typeof(PrimitiveMember), "get_IdMember"));
            mg.LoadThis();
            mg.Push(false);
            mg.InvokeVirtual(EntityMetaDataMemberVisitor.template_m_getValueWithFlag);
            mg.ReturnValue();
            mg.EndMethod();

            base.VisitEnd();
        }
Example #20
0
        protected void ImplementRelationGetter(String propertyName, MethodInstance m_getMethod_template, MethodInstance m_setMethod, int relationIndex,
                                               PropertyInstance p_valueHolderContainerTemplate, PropertyInstance p_targetCache, PropertyInstance p_relationMembers, FieldInstance f_initialized,
                                               FieldInstance f_objRefs)
        {
            // public String getPropertyName()
            // {
            // if (!PropertyName$initialized)
            // {
            // setPropertyName(RelationsGetterVisitor.valueHolderContainer_getValue(this, $relationMembers, get__IndexOfPropertyName(), $targetCache, $beanContext,
            // propertyName$objRefs));
            // }
            // return super.getPropertyName();
            // }
            Script script_getVHC;

            if (EmbeddedEnhancementHint.HasMemberPath(State.Context))
            {
                PropertyInstance p_rootEntity = EmbeddedTypeVisitor.GetRootEntityProperty(this);
                script_getVHC = delegate(IMethodVisitor mv)
                {
                    mv.CallThisGetter(p_rootEntity);
                };
            }
            else
            {
                script_getVHC = delegate(IMethodVisitor mv)
                {
                    // this
                    mv.LoadThis();
                };
            }

            MethodInstance m_getMethod;
            {
                PropertyInstance p_cacheModification = SetCacheModificationMethodCreator.GetCacheModificationPI(this);
                MethodInstance   m_getMethod_scoped  = new MethodInstance(State.NewType,
                                                                          MethodAttributes.HideBySig | MethodAttributes.Private | MethodAttributes.Final, NewType.VOID_TYPE, propertyName + "$DoInitialize");
                {
                    IMethodVisitor mg = VisitMethod(m_getMethod_scoped);

                    // this => for this.setPropertyName(...)
                    mg.LoadThis();
                    // call template.getValue(..)
                    mg.CallThisGetter(p_valueHolderContainerTemplate);
                    // getVhc()
                    script_getVHC.Invoke(mg);
                    // $relationMembers
                    mg.CallThisGetter(p_relationMembers);
                    // get__IndexOfPropertyName()
                    mg.Push(relationIndex);
                    // $targetCache
                    mg.CallThisGetter(p_targetCache);
                    // propertyName$objRefs
                    mg.GetThisField(f_objRefs);
                    mg.InvokeVirtual(m_template_getValue);
                    mg.CheckCast(m_setMethod.Parameters[0].Type);
                    mg.InvokeVirtual(m_setMethod);
                    mg.ReturnValue();
                    mg.EndMethod();
                }
                {
                    IMethodVisitor mg = base.VisitMethod(m_getMethod_template);
                    m_getMethod = mg.Method;
                    HideFromDebug(m_getMethod);
                    Label l_initialized = mg.NewLabel();
                    mg.GetThisField(f_initialized);
                    mg.PushEnum(ValueHolderState.INIT);
                    mg.IfCmp(typeof(ValueHolderState), CompareOperator.EQ, l_initialized);

                    SetCacheModificationMethodCreator.CacheModificationInternalUpdate(p_cacheModification, mg,
                                                                                      delegate(IMethodVisitor mv2)
                    {
                        mv2.LoadThis();
                        mv2.InvokeOnExactOwner(m_getMethod_scoped);
                    });

                    mg.Mark(l_initialized);
                    mg.LoadThis();
                    mg.InvokeSuperOfCurrentMethod();
                    mg.ReturnValue();
                    mg.EndMethod();
                }
            }

            // public String getPropertyName$NoInit()
            // {
            // return super.getPropertyName();
            // }
            {
                MethodInstance   m_getNoInit = m_getMethod_template.DeriveName(ValueHolderIEC.GetGetterNameOfRelationPropertyWithNoInit(propertyName));
                IMethodVisitor   mg          = base.VisitMethod(m_getNoInit);
                PropertyInstance p_getNoInit = PropertyInstance.FindByTemplate(propertyName + ValueHolderIEC.GetNoInitSuffix(), m_getNoInit.ReturnType, false);
                p_getNoInit.AddAnnotation(c_fireThisOPC, propertyName);
                p_getNoInit.AddAnnotation(c_fireTargetOPC, propertyName);
                mg.LoadThis();
                mg.InvokeSuper(m_getMethod);
                mg.ReturnValue();
                mg.EndMethod();
            }
        }
Example #21
0
        protected void ImplementPropertyChangeOnProperty(PropertyInstance propertyInfo,
                                                         PropertyInstance p_propertyChangeTemplate, MethodInstance m_firePropertyChange, FieldInstance f_propertyChangeSupport)
        {
            // add property change detection and notification
            if (propertyInfo.Getter == null || propertyInfo.Setter == null)
            {
                return;
            }
            if (InitializeEmbeddedMemberVisitor.IsEmbeddedMember(metaData, propertyInfo.Name))
            {
                return;
            }
            PropertyInstance p_getterMethodHandle = ImplementAssignedReadonlyProperty(propertyInfo.Name + "$MethodHandle",
                                                                                      new MethodHandleValueResolver(PropertyInfoProvider, propertyInfo.Name));
            Type           propertyType         = propertyInfo.PropertyType.Type;
            MethodInstance m_hasPropertyChanged = GetApplicableHasPropertyChangedOverload(propertyType);

            // check value type of last parameter
            bool isBoxingNeededForHasPropertyChanged = IsBoxingNeededForHasPropertyChangedOverload(m_hasPropertyChanged, propertyType);

            IMethodVisitor    mg              = VisitMethod(propertyInfo.Setter);
            Label             l_finish        = mg.NewLabel();
            Label             l_noOldValue    = mg.NewLabel();
            Label             l_noChangeCheck = mg.NewLabel();
            LocalVariableInfo loc_oldValue;

            if (isBoxingNeededForHasPropertyChanged)
            {
                loc_oldValue = mg.NewLocal(typeof(Object));
            }
            else
            {
                loc_oldValue = mg.NewLocal(propertyType);
            }
            LocalVariableInfo loc_valueChanged = mg.NewLocal <bool>();

            MethodInstance m_getSuper       = EnhancerUtil.GetSuperGetter(propertyInfo);
            bool           relationProperty = m_getSuper.Name.EndsWith(ValueHolderIEC.GetNoInitSuffix());

            // initialize flag with false
            mg.Push(false);
            mg.StoreLocal(loc_valueChanged);

            // initialize oldValue with null
            mg.PushNullOrZero(loc_oldValue.LocalType);
            mg.StoreLocal(loc_oldValue);

            if (relationProperty)
            {
                // check if a setter call to an UNINITIALIZED relation occured with value null
                // if it the case there would be no PCE because oldValue & newValue are both null
                // but we need a PCE in this special case
                Label         l_noSpecialHandling = mg.NewLabel();
                FieldInstance f_state             = State.GetAlreadyImplementedField(ValueHolderIEC.GetInitializedFieldName(propertyInfo.Name));
                mg.GetThisField(f_state);
                mg.PushEnum(ValueHolderState.INIT);
                mg.IfCmp(typeof(ValueHolderState), CompareOperator.EQ, l_noSpecialHandling);
                mg.Push(true);
                mg.StoreLocal(loc_valueChanged);
                mg.Mark(l_noSpecialHandling);
            }

            // check if value should be checked to decide for a PCE
            mg.LoadLocal(loc_valueChanged);
            mg.IfZCmp(CompareOperator.NE, l_noOldValue);

            // get old field value calling super property getter
            mg.LoadThis();
            mg.InvokeOnExactOwner(m_getSuper);
            if (isBoxingNeededForHasPropertyChanged)
            {
                mg.Box(propertyType);
            }
            mg.StoreLocal(loc_oldValue);

            mg.Mark(l_noOldValue);

            // set new field value calling super property setter
            mg.LoadThis();
            mg.LoadArg(0);
            mg.InvokeOnExactOwner(EnhancerUtil.GetSuperSetter(propertyInfo));
            mg.PopIfReturnValue(EnhancerUtil.GetSuperSetter(propertyInfo));

            // check if value should be checked to decide for a PCE
            mg.LoadLocal(loc_valueChanged);
            mg.IfZCmp(CompareOperator.NE, l_noChangeCheck);

            LocalVariableInfo loc_newValue = null;

            if (isBoxingNeededForHasPropertyChanged)
            {
                loc_newValue = mg.NewLocal(typeof(Object)); // loc_1  Object newValue
                // Object loc_1 = (Object)value;
                mg.LoadArg(0);
                mg.Box(propertyType);
                mg.StoreLocal(loc_newValue);
            }
            mg.CallThisGetter(p_propertyChangeTemplate);
            // call HasPropertyChanged (static)
            mg.LoadThis();              // "this" as Object obj
            mg.Push(propertyInfo.Name); // String propertyName
            mg.LoadLocal(loc_oldValue);
            if (loc_newValue != null)
            {
                mg.LoadLocal(loc_newValue);
            }
            else
            {
                mg.LoadArg(0);
            }
            mg.InvokeVirtual(m_hasPropertyChanged);
            //// if (!result)
            //// { return; }
            mg.IfZCmp(CompareOperator.EQ, l_finish);

            mg.Mark(l_noChangeCheck);
            // call firePropertyChange on this
            mg.LoadThis();
            // propertyChangeSupport
            mg.GetThisField(f_propertyChangeSupport);
            // property
            mg.CallThisGetter(p_getterMethodHandle);
            // oldValue
            mg.LoadLocal(loc_oldValue);
            if (!isBoxingNeededForHasPropertyChanged && propertyType.IsValueType)
            {
                // old value has not already been boxed but it is now necessary
                mg.ValueOf(propertyType);
            }
            // newValue
            if (loc_newValue != null)
            {
                mg.LoadLocal(loc_newValue);
            }
            else
            {
                mg.LoadArg(0);
                if (propertyType.IsValueType)
                {
                    mg.ValueOf(propertyType);
                }
            }
            // firePropertyChange(propertyChangeSupport, property, oldValue, newValue)
            mg.InvokeVirtual(m_firePropertyChange);

            // return
            mg.Mark(l_finish);
            mg.ReturnVoidOrThis();
            mg.EndMethod();
        }