예제 #1
0
 public IILLocal DeclareLocal(Type type, string name = null, bool pinned = false)
 {
     var result = new ILLocal(type, name, pinned, _lastLocalIndex);
     _lastLocalIndex++;
     _instructions.Add(result);
     return result;
 }
예제 #2
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);
            }
예제 #3
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;
            }));
        }
예제 #4
0
 /// <summary>
 /// Constructs a new mapping handler.
 /// </summary>
 /// <param name="argumentLocal">The unsafe target argument array.</param>
 /// <param name="argumentOffset">The target argument offset.</param>
 public MappingHandler(
     ILLocal argumentLocal,
     int argumentOffset)
 {
     ArgumentLocal  = argumentLocal;
     ArgumentOffset = argumentOffset;
 }
예제 #5
0
        public IILLocal DeclareLocal(Type type, string name = null, bool pinned = false)
        {
            var result = new ILLocal(type, name, pinned, _lastLocalIndex);

            _lastLocalIndex++;
            _instructions.Add(result);
            return(result);
        }
예제 #6
0
 /// <summary>
 /// Constructs a new mapping handler.
 /// </summary>
 /// <param name="parent">The parent mapper.</param>
 /// <param name="kernelLocal">The local variable holding the associated kernel reference.</param>
 /// <param name="resultLocal">The local variable holding the result API status.</param>
 public MappingHandler(
     CLArgumentMapper parent,
     ILLocal kernelLocal,
     ILLocal resultLocal)
 {
     Parent      = parent;
     KernelLocal = kernelLocal;
     ResultLocal = resultLocal;
 }
예제 #7
0
            public ILValue GenerateRead(ILValue buffer)
            {
                return(new ILLoadStatement(delegate(ILBlock block) {
                    ILLocal value = block.CreateCementedLocal(new ILNew(target_type));

                    block.AddStatement(GenerateReadInto(value, buffer));
                    return value;
                }));
            }
예제 #8
0
 /// <summary>
 /// Constructs a new mapping handler.
 /// </summary>
 /// <param name="parent">The parent mapper.</param>
 /// <param name="kernelLocal">
 /// The local variable holding the associated kernel reference.
 /// </param>
 /// <param name="resultLocal">
 /// The local variable holding the result API status.
 /// </param>
 /// <param name="startIndex">The start argument index.</param>
 public MappingHandler(
     CLArgumentMapper parent,
     ILLocal kernelLocal,
     ILLocal resultLocal,
     int startIndex)
 {
     Parent      = parent;
     KernelLocal = kernelLocal;
     ResultLocal = resultLocal;
     StartIndex  = startIndex;
 }
예제 #9
0
        public ILLocal DefineLocal(TyonObject obj, ILValue value)
        {
            ILLocal local = block.CreateCementedLocal(value);

            object_to_local.Add(obj, local);

            if (obj.GetTyonAddress() != null)
            {
                internal_address_to_local.Add(obj.GetTyonAddress(), local);
            }

            return(local);
        }
예제 #10
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;
            }));
        }
예제 #11
0
        public ILLocal CompileLocal(TyonCompiler compiler)
        {
            ILLocal local = compiler.ResolveObject(this);

            if (local == null)
            {
                local = compiler.DefineLocal(
                    this,
                    GetTyonType().CompileInstanceSystemObject(compiler, GetTyonValueList().CompileValues(compiler))
                    );
            }

            CompilePushToSystemObject(local, compiler);
            return(local);
        }
예제 #12
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);
            }
예제 #13
0
        public void CompileInitialize(TyonCompiler compiler)
        {
            ILLocal local = compiler.ResolveObject(this);

            if (local == null && GetTyonValueList() == null)
            {
                local = compiler.DefineLocal(
                    this,
                    GetTyonType().CompileInstanceSystemObject(compiler)
                    );
            }

            GetTyonValueList().IfNotNull(l => l.CompileInitialization(compiler));
            GetTyonVariables().Process(v => v.CompileInitialize(compiler));
        }
예제 #14
0
        public Process <object, TyonContext> CompilePushToSystemObject(TyonObject tyon_object)
        {
            Type type = tyon_object.GetTyonType().GetSystemType(this);

            return(this.GetType().CreateDynamicMethodDelegate <Process <object, TyonContext> >(delegate(ILValue t, ILValue c) {
                block = new ILBlock();
                context = c;

                ILLocal local = DefineLocal(tyon_object, t.GetILExplicitCast(type));

                tyon_object.CompileInitialize(this);
                tyon_object.CompilePushToSystemObject(local, this);

                return block;
            }));
        }
예제 #15
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));
            }
예제 #16
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;
            }));
        }
예제 #17
0
 /// <summary>
 /// Constructs a new local source.
 /// </summary>
 /// <param name="local">The current local.</param>
 public LocalSource(ILLocal local)
 {
     Local = local;
 }
예제 #18
0
 /// <summary>
 /// Constructs a new local target.
 /// </summary>
 /// <param name="local">The current local.</param>
 public LocalTarget(ILLocal local)
 {
     Local = local;
 }
예제 #19
0
 public void CompilePushToSystemObject(ILLocal obj, TyonCompiler compiler)
 {
     GetTyonVariables().Process(v => v.CompilePushToSystemObject(obj, compiler));
 }