Java Code Examples for org.luaj.vm2.Lua#OP_TFORLOOP
The following examples show how to use
org.luaj.vm2.Lua#OP_TFORLOOP .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicBlock.java From HtmlNative with Apache License 2.0 | 5 votes |
public static void visitBranches( Prototype p, BranchVisitor visitor ) { int sbx,j,c; int[] code = p.code; int n = code.length; for ( int i=0; i<n; i++ ) { int ins = code[i]; switch ( Lua.GET_OPCODE( ins ) ) { case Lua.OP_LOADBOOL: if ( 0 == Lua.GETARG_C(ins) ) break; if ( Lua.GET_OPCODE(code[i+1]) == Lua.OP_JMP ) throw new IllegalArgumentException("OP_LOADBOOL followed by jump at "+i); visitor.visitBranch( i, i+2 ); continue; case Lua.OP_EQ: case Lua.OP_LT: case Lua.OP_LE: case Lua.OP_TEST: case Lua.OP_TESTSET: if ( Lua.GET_OPCODE(code[i+1]) != Lua.OP_JMP ) throw new IllegalArgumentException("test not followed by jump at "+i); sbx = Lua.GETARG_sBx(code[i+1]); ++i; j = i + sbx + 1; visitor.visitBranch( i, j ); visitor.visitBranch( i, i+1 ); continue; case Lua.OP_TFORLOOP: case Lua.OP_FORLOOP: sbx = Lua.GETARG_sBx(ins); j = i + sbx + 1; visitor.visitBranch( i, j ); visitor.visitBranch( i, i+1 ); continue; case Lua.OP_JMP: case Lua.OP_FORPREP: sbx = Lua.GETARG_sBx(ins); j = i + sbx + 1; visitor.visitBranch( i, j ); continue; case Lua.OP_TAILCALL: case Lua.OP_RETURN: visitor.visitReturn( i ); continue; } if ( i+1<n && visitor.isbeg[i+1] ) visitor.visitBranch( i, i+1 ); } }
Example 2
Source File: UpvalInfo.java From HtmlNative with Apache License 2.0 | 5 votes |
private boolean isLoopVariable(VarInfo var) { if ( var.pc >= 0 ) { switch ( Lua.GET_OPCODE(pi.prototype.code[var.pc]) ) { case Lua.OP_TFORLOOP: case Lua.OP_FORLOOP: return true; } } return false; }
Example 3
Source File: UpvalInfo.java From luaj with MIT License | 5 votes |
private boolean isLoopVariable(VarInfo var) { if ( var.pc >= 0 ) { switch ( Lua.GET_OPCODE(pi.prototype.code[var.pc]) ) { case Lua.OP_TFORLOOP: case Lua.OP_FORLOOP: return true; } } return false; }
Example 4
Source File: BasicBlock.java From luaj with MIT License | 4 votes |
public static void visitBranches( Prototype p, BranchVisitor visitor ) { int sbx,j,c; int[] code = p.code; int n = code.length; for ( int i=0; i<n; i++ ) { int ins = code[i]; switch ( Lua.GET_OPCODE( ins ) ) { case Lua.OP_LOADBOOL: if ( 0 == Lua.GETARG_C(ins) ) break; if ( Lua.GET_OPCODE(code[i+1]) == Lua.OP_JMP ) throw new IllegalArgumentException("OP_LOADBOOL followed by jump at "+i); visitor.visitBranch( i, i+2 ); continue; case Lua.OP_EQ: case Lua.OP_LT: case Lua.OP_LE: case Lua.OP_TEST: case Lua.OP_TESTSET: if ( Lua.GET_OPCODE(code[i+1]) != Lua.OP_JMP ) throw new IllegalArgumentException("test not followed by jump at "+i); sbx = Lua.GETARG_sBx(code[i+1]); ++i; j = i + sbx + 1; visitor.visitBranch( i, j ); visitor.visitBranch( i, i+1 ); continue; case Lua.OP_TFORLOOP: case Lua.OP_FORLOOP: sbx = Lua.GETARG_sBx(ins); j = i + sbx + 1; visitor.visitBranch( i, j ); visitor.visitBranch( i, i+1 ); continue; case Lua.OP_JMP: case Lua.OP_FORPREP: sbx = Lua.GETARG_sBx(ins); j = i + sbx + 1; visitor.visitBranch( i, j ); continue; case Lua.OP_TAILCALL: case Lua.OP_RETURN: visitor.visitReturn( i ); continue; } if ( i+1<n && visitor.isbeg[i+1] ) visitor.visitBranch( i, i+1 ); } }