Example #1
0
        public void ToIL(ILScope s, ILGenerator g, ModuleBuilder m)
        {
            if (IsArgument)
            {
                switch (Index)
                {
                case 0:
                    g.Emit(OpCodes.Ldarg_0);
                    break;

                case 1:
                    g.Emit(OpCodes.Ldarg_1);
                    break;

                case 2:
                    g.Emit(OpCodes.Ldarg_2);
                    break;

                case 3:
                    g.Emit(OpCodes.Ldarg_3);
                    break;

                case var i when i <= 255:
                    g.Emit(OpCodes.Ldarg_S, Index);
                    break;

                default:
                    g.Emit(OpCodes.Ldarg, Index);
                    break;
                }
            }
            switch (Index)
            {
            case 0:
                g.Emit(OpCodes.Ldloc_0);
                break;

            case 1:
                g.Emit(OpCodes.Ldloc_1);
                break;

            case 2:
                g.Emit(OpCodes.Ldloc_2);
                break;

            case 3:
                g.Emit(OpCodes.Ldloc_3);
                break;

            case var i when i <= 255:
                g.Emit(OpCodes.Ldloc_S, Index);
                break;

            default:
                g.Emit(OpCodes.Ldloc, Index);
                break;
            }
        }
Example #2
0
 public ILVariable(ILScope scope, string name)
 {
     Index      = scope[name];
     IsArgument = false;
     if (Index != -1)
     {
         // TODO: search _this_ for classes. hopefully I can do it in Cream Puff though
         if (!scope.Arguments.Contains(name))
         {
             throw new Exception($"Variable {name} is neither a local variable nor an argument");
         }
         IsArgument = true;
     }
 }
Example #3
0
        public void ToIL(ILScope s, ILGenerator g, ModuleBuilder m)
        {
            var ms   = new MemoryStream();
            var name = s.FullName + "#static" + s.Statics++;
            var a    = Value.ToByteArray();

            f.Serialize(ms, a);
            m.DefineInitializedData(name, ms.GetBuffer(), FieldAttributes.Public);
            new ILInt32 {
                Value = Value.ToByteArray().Length
            }.ToIL(s, g, m);
            g.Emit(OpCodes.Newarr, typeof(byte));
            g.Emit(OpCodes.Ldfld, m.GetField(name));
            g.Emit(OpCodes.Call, ia);
            g.Emit(OpCodes.Newobj, c);
        }
Example #4
0
 public void ToIL(ILScope s, ILGenerator g, ModuleBuilder m) => g.Emit(OpCodes.Ldc_I4, Value);
Example #5
0
 public void ToIL(ILScope s, ILGenerator g, ModuleBuilder m) => ILGen(g, m);