org.luaj.vm2.LocVars Java Examples

The following examples show how to use org.luaj.vm2.LocVars. 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: DumpState.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
void dumpDebug( Prototype f) throws IOException {
	int i, n;
	if (strip)
		dumpInt(0);
	else
		dumpString(f.source);
	n = strip ? 0 : f.lineinfo.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpInt(f.lineinfo[i]);
	n = strip ? 0 : f.locvars.length;
	dumpInt(n);
	for (i = 0; i < n; i++) {
		LocVars lvi = f.locvars[i];
		dumpString(lvi.varname);
		dumpInt(lvi.startpc);
		dumpInt(lvi.endpc);
	}
	n = strip ? 0 : f.upvalues.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpString(f.upvalues[i].name);
}
 
Example #2
Source File: DumpState.java    From luaj with MIT License 6 votes vote down vote up
void dumpDebug(final Prototype f) throws IOException {
	int i, n;
	if (strip)
		dumpInt(0);
	else
		dumpString(f.source);
	n = strip ? 0 : f.lineinfo.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpInt(f.lineinfo[i]);
	n = strip ? 0 : f.locvars.length;
	dumpInt(n);
	for (i = 0; i < n; i++) {
		LocVars lvi = f.locvars[i];
		dumpString(lvi.varname);
		dumpInt(lvi.startpc);
		dumpInt(lvi.endpc);
	}
	n = strip ? 0 : f.upvalues.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpString(f.upvalues[i].name);
}
 
Example #3
Source File: DumpState.java    From XPrivacyLua with GNU General Public License v3.0 6 votes vote down vote up
void dumpDebug(final Prototype f) throws IOException {
	int i, n;
	if (strip)
		dumpInt(0);
	else
		dumpString(f.source);
	n = strip ? 0 : f.lineinfo.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpInt(f.lineinfo[i]);
	n = strip ? 0 : f.locvars.length;
	dumpInt(n);
	for (i = 0; i < n; i++) {
		LocVars lvi = f.locvars[i];
		dumpString(lvi.varname);
		dumpInt(lvi.startpc);
		dumpInt(lvi.endpc);
	}
	n = strip ? 0 : f.upvalues.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpString(f.upvalues[i].name);
}
 
Example #4
Source File: JavaGen.java    From luaj with MIT License 6 votes vote down vote up
private JavaGen( ProtoInfo pi, String classname, String filename, boolean genmain ) {
	this.classname = classname;
	
	// build this class
	JavaBuilder builder = new JavaBuilder(pi, classname, filename);
	scanInstructions(pi, classname, builder);
	for (int i = 0; i < pi.prototype.locvars.length; ++i) {
		LocVars l = pi.prototype.locvars[i];
		builder.setVarStartEnd(i, l.startpc, l.endpc, l.varname.tojstring());
	}
	this.bytecode = builder.completeClass(genmain);
	
	// build sub-prototypes
	if ( pi.subprotos != null ) {
		int n = pi.subprotos.length;
		inners = new JavaGen[n];
		for ( int i=0; i<n; i++ )
			inners[i] = new JavaGen(pi.subprotos[i], pi.subprotos[i].name, filename, false);
	} else {
		inners = null;
	}
}
 
Example #5
Source File: DumpState.java    From HtmlNative with Apache License 2.0 6 votes vote down vote up
void dumpDebug(final Prototype f) throws IOException {
	int i, n;
	if (strip)
		dumpInt(0);
	else
		dumpString(f.source);
	n = strip ? 0 : f.lineinfo.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpInt(f.lineinfo[i]);
	n = strip ? 0 : f.locvars.length;
	dumpInt(n);
	for (i = 0; i < n; i++) {
		LocVars lvi = f.locvars[i];
		dumpString(lvi.varname);
		dumpInt(lvi.startpc);
		dumpInt(lvi.endpc);
	}
	n = strip ? 0 : f.upvalues.length;
	dumpInt(n);
	for (i = 0; i < n; i++)
		dumpString(f.upvalues[i].name);
}
 
Example #6
Source File: LexState.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
int registerlocalvar(LuaString varname) {
    FuncState fs = this.fs;
    Prototype f = fs.f;
    if (f.locvars == null || fs.nlocvars + 1 > f.locvars.length)
        f.locvars = LuaC.realloc(f.locvars, fs.nlocvars * 2 + 1);
    f.locvars[fs.nlocvars] = new LocVars(varname, 0, 0);
    return fs.nlocvars++;
}
 
Example #7
Source File: LexState.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
int registerlocalvar(LuaString varname) {
	FuncState fs = this.fs;
	Prototype f = fs.f;
	if (f.locvars == null || fs.nlocvars + 1 > f.locvars.length)
		f.locvars = realloc( f.locvars, fs.nlocvars*2+1 );
	f.locvars[fs.nlocvars] = new LocVars(varname,0,0);
	return fs.nlocvars++;
}
 
Example #8
Source File: LexState.java    From luaj with MIT License 5 votes vote down vote up
int registerlocalvar(LuaString varname) {
	FuncState fs = this.fs;
	Prototype f = fs.f;
	if (f.locvars == null || fs.nlocvars + 1 > f.locvars.length)
		f.locvars = realloc( f.locvars, fs.nlocvars*2+1 );
	f.locvars[fs.nlocvars] = new LocVars(varname,0,0);
	return fs.nlocvars++;
}
 
Example #9
Source File: LexState.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
int registerlocalvar(LuaString varname) {
	FuncState fs = this.fs;
	Prototype f = fs.f;
	if (f.locvars == null || fs.nlocvars + 1 > f.locvars.length)
		f.locvars = realloc( f.locvars, fs.nlocvars*2+1 );
	f.locvars[fs.nlocvars] = new LocVars(varname,0,0);
	return fs.nlocvars++;
}
 
Example #10
Source File: Constants.java    From luaj with MIT License 4 votes vote down vote up
static LocVars[] realloc(LocVars[] v, int n) {
	LocVars[] a = new LocVars[n];
	if ( v != null )
		System.arraycopy(v, 0, a, 0, Math.min(v.length,n));
	return a;
}
 
Example #11
Source File: FuncState.java    From luaj with MIT License 4 votes vote down vote up
LocVars getlocvar(int i) {
	int idx = ls.dyd.actvar[firstlocal + i].idx;
	_assert(idx < nlocvars);
	return f.locvars[idx];
}
 
Example #12
Source File: Constants.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
static LocVars[] realloc(LocVars[] v, int n) {
	LocVars[] a = new LocVars[n];
	if ( v != null )
		System.arraycopy(v, 0, a, 0, Math.min(v.length,n));
	return a;
}
 
Example #13
Source File: FuncState.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
LocVars getlocvar(int i) {
	int idx = ls.dyd.actvar[firstlocal + i].idx;
	_assert(idx < nlocvars);
	return f.locvars[idx];
}
 
Example #14
Source File: Constants.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
static LocVars[] realloc(LocVars[] v, int n) {
	LocVars[] a = new LocVars[n];
	if ( v != null )
		System.arraycopy(v, 0, a, 0, Math.min(v.length,n));
	return a;
}
 
Example #15
Source File: FuncState.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
LocVars getlocvar(int i) {
	int idx = ls.dyd.actvar[firstlocal + i].idx;
	_assert(idx < nlocvars);
	return f.locvars[idx];
}
 
Example #16
Source File: LuaC.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
static LocVars[] realloc(LocVars[] v, int n) {
    LocVars[] a = new LocVars[n];
    if (v != null)
        System.arraycopy(v, 0, a, 0, Math.min(v.length, n));
    return a;
}
 
Example #17
Source File: FuncState.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
LocVars getlocvar(int i) {
	int idx = ls.dyd.actvar[firstlocal + i].idx;
	_assert(idx < nlocvars);
	return f.locvars[idx];
}