本文整理汇总了Java中org.luaj.vm2.Lua.GETARG_B属性的典型用法代码示例。如果您正苦于以下问题:Java Lua.GETARG_B属性的具体用法?Java Lua.GETARG_B怎么用?Java Lua.GETARG_B使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.luaj.vm2.Lua
的用法示例。
在下文中一共展示了Lua.GETARG_B属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findUpvalues
private void findUpvalues() {
int[] code = prototype.code;
int n = code.length;
// propogate to inner prototypes
String[] names = findInnerprotoNames();
for ( int pc=0; pc<n; pc++ ) {
if ( Lua.GET_OPCODE(code[pc]) == Lua.OP_CLOSURE ) {
int bx = Lua.GETARG_Bx(code[pc]);
Prototype newp = prototype.p[bx];
UpvalInfo[] newu = new UpvalInfo[newp.upvalues.length];
String newname = name + "$" + names[bx];
for ( int j=0; j<newp.upvalues.length; ++j ) {
Upvaldesc u = newp.upvalues[j];
newu[j] = u.instack? findOpenUp(pc,u.idx) : upvals[u.idx];
}
subprotos[bx] = new ProtoInfo(newp, newname, newu);
}
}
// mark all upvalues that are written locally as read/write
for ( int pc=0; pc<n; pc++ ) {
if ( Lua.GET_OPCODE(code[pc]) == Lua.OP_SETUPVAL )
upvals[Lua.GETARG_B(code[pc])].rw = true;
}
}
示例2: 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 */
}
}
示例3: findUpvalues
/**
* Find upvalues and create child prototypes
*/
public void findUpvalues() {
int[] code = info.prototype.code;
int n = code.length;
// Propagate to inner prototypes
for (int pc = 0; pc < n; pc++) {
if (Lua.GET_OPCODE(code[pc]) == Lua.OP_CLOSURE) {
int bx = Lua.GETARG_Bx(code[pc]);
Prototype childPrototype = info.prototype.p[bx];
String childName = info.name + "$" + bx;
UpvalueInfo[] childUpvalues = null;
if (childPrototype.nups > 0) {
childUpvalues = new UpvalueInfo[childPrototype.nups];
for (int j = 0; j < childPrototype.nups; ++j) {
int i = code[++pc];
int b = Lua.GETARG_B(i);
childUpvalues[j] = (i & 4) != 0 ? info.upvalues[b] : findOpenUp(pc, b);
}
}
info.subprotos[bx] = new ProtoInfo(childPrototype, info.loader, childName, childUpvalues);
}
}
// Mark all upvalues that are written locally as read/write
for (int instruction : code) {
if (Lua.GET_OPCODE(instruction) == Lua.OP_SETUPVAL) {
info.upvalues[Lua.GETARG_B(instruction)].readWrite = true;
}
}
}
示例4: 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];
}