本文整理汇总了Java中org.luaj.vm2.Lua.OP_RETURN属性的典型用法代码示例。如果您正苦于以下问题:Java Lua.OP_RETURN属性的具体用法?Java Lua.OP_RETURN怎么用?Java Lua.OP_RETURN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.luaj.vm2.Lua
的用法示例。
在下文中一共展示了Lua.OP_RETURN属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkopenop
static boolean checkopenop(Prototype pt, int pc)
{
int i = pt.code[(pc) + 1];
switch(Lua.GET_OPCODE(i))
{
case Lua.OP_CALL:
case Lua.OP_TAILCALL:
case Lua.OP_RETURN:
case Lua.OP_SETLIST:
{
if(!(Lua.GETARG_B(i) == 0)) return false;
return true;
}
default:
return false; /* invalid instruction after an open call */
}
}
示例2: precheck
static boolean precheck(Prototype pt)
{
if(!(pt.maxstacksize <= MAXSTACK)) return false;
lua_assert(pt.numparams + (pt.is_vararg & Lua.VARARG_HASARG) <= pt.maxstacksize);
lua_assert((pt.is_vararg & Lua.VARARG_NEEDSARG) == 0
|| (pt.is_vararg & Lua.VARARG_HASARG) != 0);
if(!(pt.upvalues.length <= pt.nups)) return false;
if(!(pt.lineinfo.length == pt.code.length || pt.lineinfo.length == 0)) return false;
if(!(Lua.GET_OPCODE(pt.code[pt.code.length - 1]) == Lua.OP_RETURN)) return false;
return true;
}
示例3: 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 );
}
}
示例4: 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);
}
}
}
示例5: JavaBuilder
public JavaBuilder(ProtoInfo pi, String classname, String filename) {
this.pi = pi;
this.p = pi.prototype;
this.classname = classname;
// what class to inherit from
superclassType = p.numparams;
if ( p.is_vararg != 0 || superclassType >= SUPERTYPE_VARARGS )
superclassType = SUPERTYPE_VARARGS;
for ( int i=0, n=p.code.length; i<n; i++ ) {
int inst = p.code[i];
int o = Lua.GET_OPCODE(inst);
if ( (o == Lua.OP_TAILCALL) ||
((o == Lua.OP_RETURN) && (Lua.GETARG_B(inst) < 1 || Lua.GETARG_B(inst) > 2)) ) {
superclassType = SUPERTYPE_VARARGS;
break;
}
}
// create class generator
cg = new ClassGen(classname, SUPER_NAME_N[superclassType], filename,
Constants.ACC_PUBLIC | Constants.ACC_SUPER, null);
cp = cg.getConstantPool(); // cg creates constant pool
// main instruction lists
factory = new InstructionFactory(cg);
init = new InstructionList();
main = new InstructionList();
// create the fields
for ( int i=0; i<p.upvalues.length; i++ ) {
boolean isrw = pi.isReadWriteUpvalue( pi.upvals[i] );
Type uptype = isrw? (Type) TYPE_LOCALUPVALUE: (Type) TYPE_LUAVALUE;
FieldGen fg = new FieldGen(0, uptype, upvalueName(i), cp);
cg.addField(fg.getField());
}
// create the method
mg = new MethodGen( Constants.ACC_PUBLIC | Constants.ACC_FINAL, // access flags
RETURN_TYPE_N[superclassType], // return type
ARG_TYPES_N[superclassType], // argument types
ARG_NAMES_N[superclassType], // arg names
METH_NAME_N[superclassType],
STR_LUAVALUE, // method, defining class
main, cp);
// initialize the values in the slots
initializeSlots();
// initialize branching
int nc = p.code.length;
targets = new int[nc];
branches = new BranchInstruction[nc];
branchDestHandles = new InstructionHandle[nc];
lastInstrHandles = new InstructionHandle[nc];
}