ICE() public static method

public static ICE ( string s ) : void
s string
return void
示例#1
0
        public void LoadConst(IAsm a)
        {
            int value = Convert.ToInt32(a.getInsn());

            if (value > 127 || value < -128) /* if must use long form */
            {
                il.Emit(OpCodes.Ldc_I4, value);
            }
            else if (value > 8 || value < -1) /* if must use medium form */
            {
                il.Emit(OpCodes.Ldc_I4_S, value);
            }
            else if (value == -1)
            {
                il.Emit(OpCodes.Ldc_I4_M1);
            }
            else                /* else use short form */
            {
                Object o = opcodehash["ldc.i4." + a.getInsn()];
                if (o == null)
                {
                    Io.ICE("Could not find opcode for (Ldc_I4_" + a.getInsn() + ")");
                }
                il.Emit((OpCode)o);
            }
        }
示例#2
0
文件: iasm.cs 项目: ydunk/masters
 public void setComment(String c)
 {
     if (comment != null)
     {
         Io.ICE("Comment overwrite");
     }
     comment = c;
 }
示例#3
0
        void genLoad(Var e)
        {
            int id = e.getClassId();

            if (e == null)
            {
                Io.ICE("Load instruction with no variable ptr");
            }
            if (e.getLocalToken() != null)
            {
                //    LocalToken lt = (LocalToken) e.getLocalToken();
                LocalBuilder lt = (LocalBuilder)e.getLocalToken();
                il.Emit(OpCodes.Ldloc, lt);
            }
            else if (e.getFieldBuilder() != null)
            {
                FieldBuilder fb = (FieldBuilder)e.getFieldBuilder();
                if (id == Tok.T_STATIC)
                {
                    il.Emit(OpCodes.Ldsfld, fb);
                }
                else
                {
                    il.Emit(OpCodes.Ldfld, fb);
                }
            }
            else
            {
                int index = e.getIndex();
                if (id == Tok.T_PARAM)
                {
                    if (index <= 256)
                    {
                        il.Emit(OpCodes.Ldarg_S, index);
                    }
                    else
                    {
                        il.Emit(OpCodes.Ldarg, index);
                    }
                }
                else if (id == Tok.T_AUTO || id == Tok.T_DEFCLASS)
                {
                    if (index <= 256)
                    {
                        il.Emit(OpCodes.Ldloc_S, e.getIndex());
                    }
                    else
                    {
                        il.Emit(OpCodes.Ldloc, e.getIndex());
                    }
                }
                else
                {
                    Io.ICE("Instruction load of unknown class ("
                           + e.getClassId() + ")");
                }
            }
        }
示例#4
0
        public void Branch(IAsm a)
        {
            Object o = opcodehash[a.getInsn()];

            if (o == null)
            {
                Io.ICE("Instruction branch opcode (" + a.getInsn() + ") not found in hash");
            }
            il.Emit((OpCode)o, (Label)getILLabel(a));
        }
示例#5
0
        public void Insn(IAsm a)
        {
            Object o = opcodehash[a.getInsn()];

            if (o == null)
            {
                Io.ICE("Instruction opcode (" + a.getInsn() + ") not found in hash");
            }
            il.Emit((OpCode)o);
        }
示例#6
0
        public void Store(IAsm a)
        {
            Var e  = a.getVar();
            int id = e.getClassId();

            if (e == null)
            {
                Io.ICE("Store instruction with no variable ptr");
            }
            if (e.getLocalToken() != null)
            {
                //    LocalToken lt = (LocalToken) e.getLocalToken();
                LocalBuilder lt = (LocalBuilder)e.getLocalToken();
                il.Emit(OpCodes.Stloc, lt);
            }
            else if (e.getFieldBuilder() != null)
            {
                FieldBuilder fb = (FieldBuilder)e.getFieldBuilder();
                if (id == Tok.T_STATIC)
                {
                    il.Emit(OpCodes.Stsfld, fb);
                }
                else
                {
                    il.Emit(OpCodes.Stfld, fb);
                }
            }
            else
            {
                int index = e.getIndex();
                if (id == Tok.T_PARAM)
                {
                    if (index <= 256)
                    {
                        il.Emit(OpCodes.Starg_S, index);
                    }
                    else
                    {
                        il.Emit(OpCodes.Starg, index);
                    }
                }
                else if (id == Tok.T_AUTO || id == Tok.T_DEFCLASS)
                {
                    il.Emit(OpCodes.Stloc, index);
                }
                else
                {
                    Io.ICE("Instruction load of unknown class ("
                           + e.getClassId() + ")");
                }
            }
        }
示例#7
0
 public void EndModule()
 {
     try
     {
         String s = Io.GetOutputFilename();
         appbuild.Save(s);
         Console.WriteLine("Saving assembly as " + s);
     }
     catch (Exception e)
     {
         Io.ICE(e.ToString());
     }
 }
示例#8
0
/*
 * determine the IL static type
 */
        Type ilSType(bool sign, int type)
        {
            if (sign)
            {
                switch (type)
                {
                case Tok.T_CHAR:          return(Type.GetType("System.SByte"));

                case Tok.T_SHORT:         return(Type.GetType("System.Int16"));

                case Tok.T_DEFTYPE:       return(Type.GetType("System.Int32"));

                case Tok.T_INT:           return(Type.GetType("System.Int32"));

                case Tok.T_LONG:          return(Type.GetType("System.Int32"));

                case Tok.T_FLOAT:         return(Type.GetType("System.Single"));

                case Tok.T_DOUBLE:        return(Type.GetType("System.Double"));

                case Tok.T_VOID:          return(null);

                default:
                    Io.ICE("Unhandled type " + type);
                    return(null);
                }
            }
            else
            {
                switch (type)
                {
                case Tok.T_CHAR:          return(Type.GetType("U1"));

                case Tok.T_SHORT:         return(Type.GetType("U2"));

                case Tok.T_DEFTYPE:       return(Type.GetType("U4"));

                case Tok.T_INT:           return(Type.GetType("U4"));

                case Tok.T_LONG:          return(Type.GetType("U4"));

                default:
                    Io.ICE("Unhandled type " + type);
                    return(null);
                }
            }
        }
        void dataType(Var e)
        {
            int id = tok.getId();

#if DEBUG
            Console.WriteLine("dataType1 token=[" + tok + "]\n");
#endif
            e.setSign(Tok.T_SIGNED);
            if (id == Tok.T_SIGNED || id == Tok.T_UNSIGNED)
            {
                e.setSign(id);
                tok.scan();
                id = tok.getId();
#if DEBUG
                Console.WriteLine("dataType2 token=[" + tok + "]\n");
#endif
            }
            if (id == Tok.T_VOID || id == Tok.T_INT)
            {
                e.setTypeId(id);
                tok.scan();
#if DEBUG
                Console.WriteLine("dataType3 token=[" + tok + "]\n");
#endif
            }
            else if (id == Tok.T_LONG)
            {
                Io.ICE("Unhandled type LONG");
            }
            else if (id == Tok.T_CHAR)
            {
                Io.ICE("Unhandled type CHAR");
            }
            else if (id == Tok.T_FLOAT)
            {
                Io.ICE("Unhandled type FLOAT");
            }
            else if (id == Tok.T_DOUBLE)
            {
                Io.ICE("Unhandled type DOUBLE");
            }
            else
            {
                e.setTypeId(Tok.T_DEFTYPE);
            }
        }
示例#10
0
        public void Call(IAsm a)
        {
            Var    func = a.getVar();
            Object o    = func.getMethodBuilder(); // get previous declared reference

            if (o == null)
            {
                Io.ICE("No previous extern for (" + func.getName() + ")");
            }
            MethodBuilder mb = (MethodBuilder)o;

//  il.Emit(OpCodes.Ldc_I4_0);	// push 0 for the "this" ptr
//  VarList x = func.getParams(); /* get any params */
//  if (x.Length() > 0)
//    {
//    int max = x.Length();
//    for (int i = 0; i < max; i++)
//      {
//      Var e = x.FindByIndex(i);
//      genLoad(e);
//      }
//    }
            il.Emit(OpCodes.Call, mb); // call the MethodBuilder
        }