Example #1
0
        private static int do_protectedmain()
        {
            BytePtr code = null;
            int     status;
            StkId   oldCBase   = CBase;
            jmp_buf myErrorJmp = new jmp_buf();
            jmp_buf oldErr     = errorJmp;

            errorJmp = myErrorJmp;
            try             //if (setjmp(myErrorJmp) == 0)
            {
                Object_ f = new Object_();
                lua_parse(ref code);
                tag(f, lua_Type.LUA_T_FUNCTION); bvalue(f, code);
                do_call(f, CBase, 0, CBase);
                status = 0;
            }
            catch (LongjmpException) {             //else {
                status = 1;
            }
            if (code != null)
            {
                luaI_free_BytePtr(ref code);
            }
            errorJmp = oldErr;
            CBase    = oldCBase;
            top      = new ObjectRef(stack, CBase);
            return(status);
        }
Example #2
0
        /*
        ** Execute a protected call. If function is null compiles the pre-set input.
        ** Leave nResults on the stack.
        */
        private static int do_protectedrun(Object_ function, int nResults)
        {
            jmp_buf myErrorJmp = new jmp_buf();
            int     status;
            StkId   oldCBase = CBase;
            jmp_buf oldErr   = errorJmp;

            errorJmp = myErrorJmp;
            try             //if (setjmp(myErrorJmp) == 0)
            {
                do_call(function, CBase, nResults, CBase);
                CnResults = ObjectRef.minus(top, stack) - CBase; /* number of results */
                CBase    += CnResults;                           /* incorporate results on the stack */
                status    = 0;
            }
            catch (LongjmpException)             //else
            {
                CBase  = oldCBase;
                top    = new ObjectRef(stack, CBase);
                status = 1;
            }
            errorJmp = oldErr;
            return(status);
        }
Example #3
0
 public static void longjmp(jmp_buf env, int val)
 {
     //throw new Exception("not implemented");
     throw new LongjmpException();
 }
Example #4
0
 public static int setjmp(jmp_buf env)
 {
     throw new Exception("not implemented, use try instead");
 }