当前位置: 首页>>代码示例>>Java>>正文


Java LuaTable.insert方法代码示例

本文整理汇总了Java中org.luaj.vm2.LuaTable.insert方法的典型用法代码示例。如果您正苦于以下问题:Java LuaTable.insert方法的具体用法?Java LuaTable.insert怎么用?Java LuaTable.insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.luaj.vm2.LuaTable的用法示例。


在下文中一共展示了LuaTable.insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
	switch (args.narg()) {
	case 0: case 1: {
		return argerror(2, "value expected");
	}
	case 2: {
		LuaTable table = args.arg1().checktable();
		table.insert(table.length()+1,args.arg(2));
		return NONE;
	}
	default: {
		args.arg1().checktable().insert(args.checkint(2),args.arg(3));
		return NONE;
	}
	}
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:17,代码来源:TableLib.java

示例2: invoke

import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
    int a = 1;
    LuaThread thread = args.isthread(a) ? args.checkthread(a++) : globals.running;
    LuaValue func = args.arg(a++);
    String what = args.optjstring(a++, "flnStu");
    DebugLib.CallStack callstack = callstack(thread);

    // find the stack info
    DebugLib.CallFrame frame;
    if (func.isnumber()) {
        frame = callstack.getCallFrame(func.toint());
        if (frame == null)
            return NONE;
        func = frame.f;
    } else if (func.isfunction()) {
        frame = callstack.findCallFrame(func);
    } else {
        return argerror(a - 2, "function or level");
    }

    // start a table
    DebugInfo ar = callstack.auxgetinfo(what, (LuaFunction) func, frame);
    LuaTable info = new LuaTable();
    if (what.indexOf('S') >= 0) {
        info.set(WHAT, LUA);
        info.set(SOURCE, valueOf(ar.source));
        info.set(SHORT_SRC, valueOf(ar.short_src));
        info.set(LINEDEFINED, valueOf(ar.linedefined));
        info.set(LASTLINEDEFINED, valueOf(ar.lastlinedefined));
    }
    if (what.indexOf('l') >= 0) {
        info.set(CURRENTLINE, valueOf(ar.currentline));
    }
    if (what.indexOf('u') >= 0) {
        info.set(NUPS, valueOf(ar.nups));
        info.set(NPARAMS, valueOf(ar.nparams));
        info.set(ISVARARG, ar.isvararg ? ONE : ZERO);
    }
    if (what.indexOf('n') >= 0) {
        info.set(NAME, LuaValue.valueOf(ar.name != null ? ar.name : "?"));
        info.set(NAMEWHAT, LuaValue.valueOf(ar.namewhat));
    }
    if (what.indexOf('t') >= 0) {
        info.set(ISTAILCALL, ZERO);
    }
    if (what.indexOf('L') >= 0) {
        LuaTable lines = new LuaTable();
        info.set(ACTIVELINES, lines);
        DebugLib.CallFrame cf;
        for (int l = 1; (cf = callstack.getCallFrame(l)) != null; ++l)
            if (cf.f == func)
                lines.insert(-1, valueOf(cf.currentline()));
    }
    if (what.indexOf('f') >= 0) {
        if (func != null)
            info.set(FUNC, func);
    }
    return info;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:60,代码来源:DebugLib.java

示例3: invoke

import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public Varargs invoke(Varargs args) {
	int a=1;
	LuaThread thread = args.isthread(a)? args.checkthread(a++): globals.running; 
	LuaValue func = args.arg(a++);
	String what = args.optjstring(a++, "flnStu");
	DebugLib.CallStack callstack = callstack(thread);

	// find the stack info
	DebugLib.CallFrame frame;
	if ( func.isnumber() ) {
		frame = callstack.getCallFrame(func.toint());
		if (frame == null)
			return NONE;
		func = frame.f;
	} else if ( func.isfunction() ) {
		frame = callstack.findCallFrame(func);
	} else {
		return argerror(a-2, "function or level");
	}

	// start a table
	DebugInfo ar = callstack.auxgetinfo(what, (LuaFunction) func, frame);
	LuaTable info = new LuaTable();
	if (what.indexOf('S') >= 0) {
		info.set(WHAT, LUA);
		info.set(SOURCE, valueOf(ar.source));
		info.set(SHORT_SRC, valueOf(ar.short_src));
		info.set(LINEDEFINED, valueOf(ar.linedefined));
		info.set(LASTLINEDEFINED, valueOf(ar.lastlinedefined));
	}
	if (what.indexOf('l') >= 0) {
		info.set( CURRENTLINE, valueOf(ar.currentline) );
	}
	if (what.indexOf('u') >= 0) {
		info.set(NUPS, valueOf(ar.nups));
		info.set(NPARAMS, valueOf(ar.nparams));
		info.set(ISVARARG, ar.isvararg? ONE: ZERO);
	}
	if (what.indexOf('n') >= 0) {
		info.set(NAME, LuaValue.valueOf(ar.name!=null? ar.name: "?"));
		info.set(NAMEWHAT, LuaValue.valueOf(ar.namewhat));
	}
	if (what.indexOf('t') >= 0) {
		info.set(ISTAILCALL, ZERO);
	}
	if (what.indexOf('L') >= 0) {
		LuaTable lines = new LuaTable();
		info.set(ACTIVELINES, lines);
		DebugLib.CallFrame cf;
		for (int l = 1; (cf=callstack.getCallFrame(l)) != null; ++l)
			if (cf.f == func)
				lines.insert(-1, valueOf(cf.currentline()));
	}
	if (what.indexOf('f') >= 0) {
		if (func != null)
			info.set( FUNC, func );
	}
	return info;
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:60,代码来源:DebugLib.java


注:本文中的org.luaj.vm2.LuaTable.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。