Пример #1
0
        internal object Invoke(RuntimeMethod method, object instance, object[] parameters)
        {
            if (parameters == null)
            {
                parameters = Array <object> .Empty;
            }

            RuntimeInterpreter interpreter = null;

            lock (interpreters)
            {
                if (interpreters.Count > 0)
                {
                    interpreter = interpreters.Pop();
                }
            }
            if (interpreter == null)
            {
                interpreter = new RuntimeInterpreter(this);
            }

            try
            {
                return(interpreter.Invoke(method, instance, parameters));
            }
            finally
            {
                lock (interpreters)
                {
                    interpreters.Push(interpreter);
                }
            }
        }
Пример #2
0
 public static void PushObject(StackObject *esp, FastList <object> mObjects, object instance)
 {
     if (instance == null)
     {
         PushNull(esp);
     }
     else
     {
         esp->ObjectType = StackObjectType.Object;
         esp->Int32      = mObjects.Push(instance);
     }
 }
Пример #3
0
    public int AddString(string str)
    {
        // 在链表中查找索引,如果没找到则返回链表的Count
        int idx = table.IndexOf(str);

        if (idx != -1)
        {
            return(idx);
        }

        table.Push(str);

        return(++idx);
    }
    public int AddFunc(string name, int entryPoint)
    {
        if (GetFuncByName(name) != null)
        {
            return(ERROR_IDX);
        }

        var newFunc = new FuncNode {
            name = name, entryPoint = entryPoint, index = table.Length
        };

        table.Push(newFunc);

        return(newFunc.index);
    }
Пример #5
0
    public int AddSymbol(string ident, int size, int stackIndex, int funcIndex)
    {
        if (GetSymbolByIdent(ident, funcIndex) != null)
        {
            return(-1);
        }

        var newSym = new SymbolNode {
            ident = ident, stackIndex = stackIndex, funcIndex = funcIndex, index = table.Length
        };

        table.Push(newSym);

        return(newSym.index);
    }
    public int AddLabel(string ident, int targetIndex, int funcIndex)
    {
        if (GetLabelByIdent(ident, funcIndex) != null)
        {
            return(-1);
        }

        var newLabel = new LabelNode {
            ident = ident, targetIndex = targetIndex, funcIndex = funcIndex, index = table.Length
        };

        table.Push(newLabel);

        return(newLabel.index);
    }
Пример #7
0
 public static void InitObject(StackObject *esp, FastList <object> mObjects)
 {
     esp->ObjectType = StackObjectType.Object;
     esp->Int32      = mObjects.Push(null);
 }