Пример #1
0
        public void Store(IAsm a)
        {
            if (a.getVar() == null)
            {
                io.ICE("store instruction with no variable ptr");
            }
            Var e = localvars.FindByName(a.getVar().getName());

            if (e == null)
            {
                e = a.getVar();
            }
            int id = e.getClassId();

            if (e.getLocalToken() != null)
            {
                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() + ")");
                        }
                    }
                }
            }
        }
Пример #2
0
Файл: exe.cs Проект: master/plil
        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()+")");
                        }
                    }
                }
            }
        }
Пример #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() + ")");
                        }
                    }
                }
            }
        }