本文整理汇总了Java中org.luaj.vm2.Lua.OP_JMP属性的典型用法代码示例。如果您正苦于以下问题:Java Lua.OP_JMP属性的具体用法?Java Lua.OP_JMP怎么用?Java Lua.OP_JMP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.luaj.vm2.Lua
的用法示例。
在下文中一共展示了Lua.OP_JMP属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: debugBytecode
/** Called by Closures on bytecode execution */
public static void debugBytecode(int pc, Varargs extras, int top)
{
DebugState ds = getDebugState();
if(ds.inhook)
return;
DebugInfo di = ds.getDebugInfo();
if(TRACE) Print.printState(di._closure, pc, di._stack, top, di._varargs);
di.bytecode(pc, extras, top);
if(ds.hookcount > 0)
{
if(++ds.hookcodes >= ds.hookcount)
{
ds.hookcodes = 0;
ds.callHookFunc(ds, COUNT, LuaValue.NIL);
}
}
if(ds.hookline)
{
int newline = di.currentline();
if(newline != ds.line)
{
int c = di._closure._p.code[pc];
if((c & 0x3f) != Lua.OP_JMP || ((c >>> 14) - 0x1ffff) >= 0)
{
ds.line = newline;
ds.callHookFunc(ds, LINE, LuaValue.valueOf(newline));
}
}
}
}
示例2: visitBranches
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 );
}
}
示例3: visitBranches
public final void visitBranches(Prototype p) {
int branchOffset, branchTo;
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);
}
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:
case Lua.OP_TFORLOOP:
if (Lua.GET_OPCODE(code[i + 1]) != Lua.OP_JMP) {
throw new IllegalArgumentException("test not followed by jump at " + i);
}
branchOffset = Lua.GETARG_sBx(code[i + 1]);
++i;
branchTo = i + branchOffset + 1;
visitBranch(i, branchTo);
visitBranch(i, i + 1);
continue;
case Lua.OP_FORLOOP:
branchOffset = Lua.GETARG_sBx(ins);
branchTo = i + branchOffset + 1;
visitBranch(i, branchTo);
visitBranch(i, i + 1);
continue;
case Lua.OP_JMP:
case Lua.OP_FORPREP:
branchOffset = Lua.GETARG_sBx(ins);
branchTo = i + branchOffset + 1;
visitBranch(i, branchTo);
continue;
case Lua.OP_TAILCALL:
case Lua.OP_RETURN:
visitReturn(i);
continue;
}
if (i + 1 < n && isBeginning[i + 1]) {
visitBranch(i, i + 1);
}
}
}