Beispiel #1
0
        /*
        ** Report bug building a message and sending it to lua_error function.
        */
        public static void lua_reportbug(CharPtr s)
        {
            CharPtr msg = new CharPtr(new char[MAXFUNCSTACK * 80]);

            strcpy(msg, s);
            if (lua_debugline != 0)
            {
                if (funcStack != null)
                {
                    FuncStackNode func = funcStack;
                    int           line = lua_debugline;
                    sprintf(strchr(msg, (char)0), "\n\tactive stack:\n");
                    do
                    {
                        sprintf(strchr(msg, (char)0),
                                "\t-> function \"%s\" at file \"%s\":%u\n",
                                lua_constant[func.function].str, func.file, line);
                        line = func.line;
                        func = func.next;
                        lua_popfunction();
                    } while (func != null);
                }
                else
                {
                    sprintf(strchr(msg, (char)0),
                            "\n\tin statement begining at line %u of file \"%s\"",
                            lua_debugline, lua_filename());
                }
            }
            lua_error(msg);
        }
Beispiel #2
0
        /*
        ** Called to execute RESET opcode, this function pops a function from
        ** function stack.
        */
        public static void lua_popfunction()
        {
            FuncStackNode temp = funcStack;

            if (temp == null)
            {
                return;
            }
            --nfuncstack;
            lua_debugline = temp.line;
            funcStack     = temp.next;
            luaI_free_FuncStackNode(ref temp);
        }
Beispiel #3
0
        /*
        ** Called to execute  SETFUNCTION opcode, this function pushs a function into
        ** function stack.
        */
        public static void lua_pushfunction(CharPtr file, Word function)
        {
            FuncStackNode newNode;

            if (nfuncstack++ >= MAXFUNCSTACK)
            {
                lua_reportbug("function stack overflow");
            }
            newNode          = new_FuncStackNode();
            newNode.function = function;
            newNode.file     = new CharPtr(file);
            newNode.line     = lua_debugline;
            newNode.next     = funcStack;
            funcStack        = newNode;
        }
Beispiel #4
0
 public static void luaI_free_FuncStackNode(ref FuncStackNode block)
 {
     block = null;            //*((int *)block) = -1;  /* to catch errors */
     //free(block);
 }