Esempio n. 1
0
            protected override ILStatement GenerateWriteInternal(ILValue prop, ILValue liaison, ILValue buffer)
            {
                ILBlock block = new ILBlock();

                if (IsPolymorphic())
                {
                    ILLocal type = block.CreateCementedLocal(prop.GetILTypeEX());

                    block.AddStatement(
                        new ILIf(
                            liaison.GetILField(nested_liaison_field).GetILInvoke("ValidateEX", prop).GetILIsFalse(),
                            GenerateInitialize(liaison, type)
                            )
                        );

                    block.AddStatement(buffer.GetILInvoke("WriteType", type));
                }
                else
                {
                    block.AddStatement(
                        new ILIf(
                            liaison.GetILField(nested_liaison_field).GetILIsNull(),
                            GenerateInitialize(liaison, GetPropType())
                            )
                        );
                }

                block.AddStatement(liaison.GetILField(nested_liaison_field).GetILInvoke("Write", prop, GetUpdateInterval(), buffer));
                return(block);
            }
Esempio n. 2
0
        static public IsFingerEquivolentOperation CreateIsFingerEquivolentOperation(this Type item)
        {
            MethodInfoEX equals_ex_method = typeof(TypeExtensions_Finger_Create).GetStaticMethod <object, object>("EqualsEX");

            return(item.CreateDynamicMethodDelegate <IsFingerEquivolentOperation>("IsFingerEquivolent_" + item.Name, delegate(MethodBase method) {
                ILBlock body = new ILBlock();

                ILLocal obj1 = body.CreateNamedLocal(item, "obj1", method.GetTechnicalILParameter(0));
                ILLocal obj2 = body.CreateNamedLocal(item, "obj2", method.GetTechnicalILParameter(1));

                body.AddStatement(new ILIf(
                                      obj1.GetILIsNotNull()& obj2.GetILIsNotNull(),

                                      new ILBlock(delegate(ILBlock block) {
                    foreach (FieldInfo field in item.GetAllInstanceFields())
                    {
                        block.AddStatement(new ILIf(
                                               equals_ex_method.GetStaticILMethodInvokation(
                                                   obj1.GetILField(field),
                                                   obj2.GetILField(field)
                                                   ).GetILIsFalse(),
                                               new ILReturn(false)
                                               ));
                    }

                    block.AddStatement(new ILReturn(true));
                })
                                      ));

                body.AddStatement(new ILReturn(false));
                return body;
            }));
        }
Esempio n. 3
0
            static private ILStatement GenerateInspectedObjectWrite_Polymorphic(ILValue value, ILValue buffer)
            {
                ILBlock block = new ILBlock();
                ILLocal type  = block.CreateCementedLocal(value.GetILTypeEX());

                block.AddStatement(buffer.GetILInvoke("WriteType", type));
                block.AddStatement(
                    new ILIf(
                        type.GetILIsNotNull(),
                        typeof(TypeSerializer).GetILInvoke("WriteObject", value)
                        )
                    );

                return(block);
            }
Esempio n. 4
0
        public Operation <object, TyonContext> CompileInstanceSystemObject(TyonObject tyon_object)
        {
            return(this.GetType().CreateDynamicMethodDelegate <Operation <object, TyonContext> >(delegate(ILValue c) {
                block = new ILBlock();
                context = c;

                tyon_object.CompileInitialize(this);
                ILLocal local = tyon_object.CompileLocal(this);

                block.AddStatement(new ILReturn(local));
                return block;
            }));
        }
Esempio n. 5
0
        static public FingerPrintOperation CreateFingerPrintOperation(this Type item)
        {
            MethodInfoEX get_hash_code_ex_method = typeof(TypeExtensions_Finger_Create).GetStaticMethod <object>("GetHashCodeEX");

            return(item.CreateDynamicMethodDelegate <FingerPrintOperation>("FingerPrint_" + item.Name, delegate(MethodBase method){
                ILBlock body = new ILBlock();

                ILLocal obj = body.CreateNamedLocal(item, "this", method.GetTechnicalILParameter(0));
                ILLocal hash = body.CreateNamedLocal(typeof(int), "hash", 17);

                foreach (FieldInfo field in item.GetAllInstanceFields())
                {
                    body.AddStatement(
                        new ILAssign(
                            hash,
                            hash * 23 + get_hash_code_ex_method.GetStaticILMethodInvokation(obj.GetILField(field))
                            )
                        );
                }

                body.AddStatement(new ILReturn(hash));
                return body;
            }));
        }
Esempio n. 6
0
            public bool WriteWithLiaison(object target, Interval field_update_interval, object liaison, Buffer buffer)
            {
                if (object_liaison_writer == null)
                {
                    object_liaison_writer = GetTargetType().CreateDynamicMethodDelegateWithForcedParameterTypes <ObjectLiaisonWriter>(delegate(ILValue il_target, ILValue il_field_update_interval, ILValue il_liaison, ILValue il_buffer) {
                        ILBlock block = new ILBlock();

                        ILLocal il_to_return = block.CreateNamedLocal(typeof(bool), "to_return");

                        block.AddStatements(
                            target_serializer_prop_groups
                            .Convert(g => g.GenerateWrite(il_target, il_field_update_interval, type_update_interval, il_liaison, il_to_return, il_buffer))
                            );

                        block.AddStatement(new ILReturn(il_to_return));
                        return(block);
                    }, GetTargetType(), typeof(Interval), GetLiaisonType(), typeof(Buffer));
                }

                return(object_liaison_writer(target, field_update_interval, liaison, buffer));
            }
Esempio n. 7
0
 public void AddStatement(ILStatement statement)
 {
     block.AddStatement(statement);
 }