Exemple #1
0
        internal override void EmitSet(ILGenerator ilg, bool preserve)
        {
            var push = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___pushWorkarea) as MethodSymbol;
            var pop  = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___popWorkarea) as MethodSymbol;
            var temp = preserve ? ilg.DeclareLocal(Datatype.Type) : null;
            var v    = ilg.DeclareLocal(Compilation.Get(NativeType.Usual).Type);

            ilg.Emit(OpCodes.Stloc, v.LocalIndex);
            Alias.Emit(ilg);
            ilg.Emit(OpCodes.Call, push.Method);
            ilg.BeginExceptionBlock();
            ilg.Emit(OpCodes.Ldloc, v.LocalIndex);
            Field.EmitSet(ilg, preserve);
            if (preserve)
            {
                ilg.Emit(OpCodes.Stloc, temp.LocalIndex);
            }
            ilg.BeginFinallyBlock();
            ilg.Emit(OpCodes.Call, pop.Method);
            ilg.EndExceptionBlock();
            if (preserve)
            {
                ilg.Emit(OpCodes.Ldloc, temp.LocalIndex);
            }
        }
Exemple #2
0
        internal override void EmitSet(ILGenerator ilg, bool preserve)
        {
            var v = ilg.DeclareLocal(Compilation.Get(NativeType.Usual).Type);

            ilg.Emit(OpCodes.Stloc, v.LocalIndex);
            if (Alias != null)
            {
                Alias.Emit(ilg);
            }
            Field.Emit(ilg);
            ilg.Emit(OpCodes.Ldloc, v.LocalIndex);
            MethodSymbol m;

            if (Alias != null)
            {
                m = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___FieldSetWa) as MethodSymbol;
            }
            else
            {
                m = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___FieldSet) as MethodSymbol;
            }

            ilg.Emit(OpCodes.Call, m.Method);
            if (!preserve)
            {
                ilg.Emit(OpCodes.Pop);
            }
        }
Exemple #3
0
        internal override void EmitSet(ILGenerator ilg, bool preserve)
        {
            var push  = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___pushWorkarea) as MethodSymbol;
            var pop   = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___popWorkarea) as MethodSymbol;
            var dirty = ilg.DeclareLocal(Compilation.Get(NativeType.Boolean).Type);
            var v     = ilg.DeclareLocal(Compilation.Get(NativeType.Usual).Type);

            ilg.Emit(OpCodes.Stloc, v.LocalIndex);
            Alias.Emit(ilg);
            ilg.Emit(OpCodes.Call, push.Method);
            ilg.Emit(OpCodes.Ldc_I4_1);
            ilg.Emit(OpCodes.Stloc, dirty.LocalIndex);
            ilg.Emit(OpCodes.Ldloc, v.LocalIndex);
            Field.EmitSet(ilg, preserve);
            ilg.Emit(OpCodes.Ldc_I4_0);
            ilg.Emit(OpCodes.Stloc, dirty.LocalIndex);
            ilg.Emit(OpCodes.Call, pop.Method);
            Stmt.FinallyClauses.Add(() => {
                var skip = ilg.DefineLabel();
                ilg.Emit(OpCodes.Ldloc, dirty.LocalIndex);
                ilg.Emit(OpCodes.Brfalse_S, skip);
                ilg.Emit(OpCodes.Call, pop.Method);
                ilg.MarkLabel(skip);
            });
        }
Exemple #4
0
        internal override void Emit(ILGenerator ilg, bool preserve)
        {
            if (Alias != null)
            {
                Alias.Emit(ilg);
            }
            Field.Emit(ilg);
            MethodSymbol m;

            if (Alias != null)
            {
                m = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___FieldGetWa) as MethodSymbol;
            }
            else
            {
                m = Compilation.Get(WellKnownMembers.XSharp_RT_Functions___FieldGet) as MethodSymbol;
            }
            ilg.Emit(OpCodes.Call, m.Method);
            if (!preserve)
            {
                ilg.Emit(OpCodes.Pop);
            }
        }