本文整理汇总了Java中se.krka.kahlua.vm.Prototype类的典型用法代码示例。如果您正苦于以下问题:Java Prototype类的具体用法?Java Prototype怎么用?Java Prototype使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Prototype类属于se.krka.kahlua.vm包,在下文中一共展示了Prototype类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close_func
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
void close_func() {
FuncState fs = this.fs;
Prototype f = fs.f;
f.isVararg = fs.isVararg != 0;
this.removevars(0);
fs.ret(0, 0); /* final return */
f.code = FuncState.realloc(f.code, fs.pc);
f.lines = FuncState.realloc(f.lines, fs.pc);
// f.sizelineinfo = fs.pc;
f.constants = FuncState.realloc(f.constants, fs.nk);
f.prototypes = FuncState.realloc(f.prototypes, fs.np);
fs.locvars = FuncState.realloc(fs.locvars, fs.nlocvars);
// f.sizelocvars = fs.nlocvars;
fs.upvalues = FuncState.realloc(fs.upvalues, f.numUpvalues);
// FuncState._assert (CheckCode.checkcode(f));
FuncState._assert(fs.bl == null);
this.fs = fs.prev;
// L.top -= 2; /* remove table and prototype from the stack */
// /* last token read was anchored in defunct function; must reanchor it
// */
// if (fs!=null) ls.anchor_token();
}
示例2: FuncState
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
FuncState(KahluaParser lexState) {
Prototype f = new Prototype();
if ( lexState.fs!=null )
f.name = lexState.fs.f.name;
this.f = f;
this.prev = lexState.fs; /* linked list of funcstates */
this.ls = lexState;
lexState.fs = this;
this.pc = 0;
this.lasttarget = -1;
this.jpc = KahluaParser.NO_JUMP;
this.freereg = 0;
this.nk = 0;
this.np = 0;
this.nlocvars = 0;
this.nactvar = 0;
this.bl = null;
f.maxStacksize = 2; /* registers 0/1 are always valid */
//fs.h = new LTable();
this.htable = new Hashtable();
}
示例3: addk
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
int addk(Object v) {
int idx;
if (v == null) return 0;
if (this.htable.containsKey(v)) {
idx = ((Integer) htable.get(v)).intValue();
} else {
idx = this.nk;
this.htable.put(v, new Integer(idx));
final Prototype f = this.f;
if (f.constants == null || nk + 1 >= f.constants.length)
f.constants = realloc( f.constants, nk*2 + 1 );
if (v == NULL_OBJECT) {
v = null;
}
f.constants[this.nk++] = v;
}
return idx;
}
示例4: loadByteCodeFromResource
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
public static LuaClosure loadByteCodeFromResource(String name, KahluaTable environment) {
InputStream stream = null;
try {
stream = new FileInputStream(new File(name + ".lbc"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if (stream == null) {
return null;
} else {
try {
return Prototype.loadByteCode(stream, environment);
} catch (IOException arg3) {
throw new RuntimeException(arg3.getMessage());
}
}
}
示例5: pushclosure
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
void pushclosure(FuncState func, ExpDesc v) {
FuncState fs = this.fs;
Prototype f = fs.f;
if (f.prototypes == null || fs.np + 1 > f.prototypes.length)
f.prototypes = FuncState.realloc(f.prototypes, fs.np * 2 + 1);
f.prototypes[fs.np++] = func.f;
v.init(VRELOCABLE, fs.codeABx(FuncState.OP_CLOSURE, 0, fs.np - 1));
for (int i = 0; i < func.f.numUpvalues; i++) {
int o = (func.upvalues_k[i] == VLOCAL) ? FuncState.OP_MOVE
: FuncState.OP_GETUPVAL;
fs.codeABC(o, 0, func.upvalues_info[i], 0);
}
}
示例6: code
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
int code(int instruction, int line) {
Prototype f = this.f;
this.dischargejpc(); /* `pc' will change */
/* put new instruction in code array */
if (f.code == null || this.pc + 1 > f.code.length)
f.code = realloc(f.code, this.pc * 2 + 1);
f.code[this.pc] = instruction;
/* save corresponding line information */
if (f.lines == null || this.pc + 1 > f.lines.length)
f.lines = realloc(f.lines,
this.pc * 2 + 1);
f.lines[this.pc] = line;
return this.pc++;
}
示例7: parlist
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
void parlist() {
//log.info(">>> parlist");
/* parlist -> [ param { `,' param } ] */
FuncState fs = this.fs;
Prototype f = fs.f;
int nparams = 0;
fs.isVararg = 0;
if (this.t != RPAREN) { /* is `parlist' not empty? */
do {
PsiBuilder.Marker parm = builder.mark();
// PsiBuilder.Marker mark = builder.mark();
if (this.t == NAME) {
/* param . NAME */
String name = this.str_checkname();
// mark.done(LOCAL_NAME_DECL);
this.new_localvar(name, nparams++);
parm.done(PARAMETER);
// break;
} else if (this.t == ELLIPSIS) { /* param . `...' */
this.next();
// mark.done(LOCAL_NAME_DECL);
parm.done(PARAMETER);
fs.isVararg |= FuncState.VARARG_ISVARARG;
// break;
} else {
// mark.drop();
parm.drop();
this.syntaxerror("<name> or " + LUA_QL("...") + " expected");
}
} while ((fs.isVararg == 0) && this.testnext(COMMA));
}
this.adjustlocalvars(nparams);
f.numParams = (fs.nactvar - (fs.isVararg & FuncState.VARARG_HASARG));
fs.reserveregs(fs.nactvar); /* reserve register for parameters */
//log.info("<<< parlist");
}
示例8: realloc
import se.krka.kahlua.vm.Prototype; //导入依赖的package包/类
static Prototype[] realloc(Prototype[] v, int n) {
Prototype[] a = new Prototype[n];
if ( v != null )
System.arraycopy(v, 0, a, 0, Math.min(v.length,n));
return a;
}