• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DumpState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.luaj.vm2.compiler.DumpState的典型用法代码示例。如果您正苦于以下问题:Java DumpState类的具体用法?Java DumpState怎么用?Java DumpState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DumpState类属于org.luaj.vm2.compiler包,在下文中一共展示了DumpState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: dump

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
/**
 * string.dump (function)
 * <p>
 * Returns a string containing a binary representation of the given function,
 * so that a later loadstring on this string returns a copy of the function.
 * function must be a Lua function without upvalues.
 * <p>
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump(LuaValue arg) {
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try {
		Prototype closure;
		if (f instanceof LuaClosure) {
			closure = ((LuaClosure) f).p;
		} else if (f instanceof IGetPrototype) {
			closure = ((IGetPrototype) f).getPrototype();
		} else {
			throw new LuaError("Cannot cast Java function (" + f.getClass().getName() + ")");
		}

		DumpState.dump(closure, baos, true);
		return LuaString.valueOf(baos.toByteArray());
	} catch (IOException e) {
		return error(e.getMessage());
	}
}
 
开发者ID:SquidDev,项目名称:luaj.luajc,代码行数:29,代码来源:StringLib.java


示例2: usageExit

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
private static void usageExit()
{
	//@formatter:off
	String usage =
		"usage: java -cp luaj-jse.jar luac [options] [filenames].\n" +
		"Available options are:\n" +
		"  -        process stdin\n" +
		"  -l       list\n" +
		"  -o name  output to file 'name' (default is \"luac.out\")\n" +
		"  -p       parse only\n" +
		"  -s       strip debug information\n" +
		"  -e       little endian format for numbers\n" +
		"  -i<n>    number format 'n', (n=0,1 or 4, default="+DumpState.NUMBER_FORMAT_DEFAULT+")\n" +
		"  -v       show version information\n" +
		"  --       stop handling options\n";
	//@formatter:on
	System.out.println(usage);
	System.exit(-1);
}
 
开发者ID:dwing4g,项目名称:luaj,代码行数:20,代码来源:luac.java


示例3: processScript

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
private static void processScript(InputStream script, String chunkname, OutputStream out) throws IOException
{
	try
	{
		// create the chunk
		Prototype chunk = LuaC.compile(script, chunkname);

		// list the chunk
		if(list)
		    Print.printCode(System.out, chunk);

		// write out the chunk
		if(!parseonly)
		{
			DumpState.dump(chunk, out, stripdebug, numberformat, littleendian);
		}
	}
	catch(Exception e)
	{
		e.printStackTrace(System.err);
	}
	finally
	{
		script.close();
	}
}
 
开发者ID:dwing4g,项目名称:luaj,代码行数:27,代码来源:luac.java


示例4: processScript

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
private void processScript( Globals globals, InputStream script, String chunkname, OutputStream out ) throws IOException {
	try {
        // create the chunk
        Prototype chunk = encoding != null?
        		globals.compilePrototype(new InputStreamReader(script, encoding), chunkname):
        		globals.compilePrototype(script, chunkname);

        // list the chunk
        if (list)
            Print.printCode(chunk);

        // write out the chunk
        if (!parseonly) {
            DumpState.dump(chunk, out, stripdebug, numberformat, littleendian);
        }
        
	} catch ( Exception e ) {
		e.printStackTrace( System.err );
	} finally {
		script.close();
	}
}
 
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:23,代码来源:luac.java


示例5: dump

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
/**
 * string.dump (function)
 *
 * Returns a string containing a binary representation of the given function,
 * so that a later loadstring on this string returns a copy of the function.
 * function must be a Lua function without upvalues.
 *
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump(LuaValue arg) {
    LuaValue f = arg.checkfunction();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        DumpState.dump(((LuaClosure) f).p, baos, true);
        return LuaString.valueOf(baos.toByteArray());
    } catch (IOException e) {
        return error(e.getMessage());
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:20,代码来源:StringLib.java


示例6: call

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
public LuaValue call(LuaValue arg) {
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try {
		DumpState.dump( ((LuaClosure)f).p, baos, true );
		return LuaString.valueUsing(baos.toByteArray());
	} catch (IOException e) {
		return error( e.getMessage() );
	}
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:11,代码来源:StringLib.java


示例7: dump

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
/** 
 * string.dump (function)
 * 
 * Returns a string containing a binary representation of the given function, 
 * so that a later loadstring on this string returns a copy of the function. 
 * function must be a Lua function without upvalues.
 *  
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump( LuaValue arg ) {
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try {
		DumpState.dump( ((LuaClosure)f).p, baos, true );
		return LuaString.valueOf(baos.toByteArray());
	} catch (IOException e) {
		return error( e.getMessage() );
	}
}
 
开发者ID:Cephrus,项目名称:Elite-Armageddon,代码行数:20,代码来源:StringLib.java


示例8: dump

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
/**
 * string.dump (function)
 *
 * Returns a string containing a binary representation of the given function,
 * so that a later loadstring on this string returns a copy of the function.
 * function must be a Lua function without upvalues.
 *
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump(LuaValue arg)
{
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try
	{
		DumpState.dump(((LuaClosure)f)._p, baos, true);
		return LuaString.valueOf(baos.toByteArray());
	}
	catch(IOException e)
	{
		return error(e.getMessage());
	}
}
 
开发者ID:dwing4g,项目名称:luaj,代码行数:24,代码来源:LibString.java


示例9: prepare

import org.luaj.vm2.compiler.DumpState; //导入依赖的package包/类
@Override
public void prepare() throws PreparationException
{
	String documentName = executable.getDocumentName();
	File dumpFile = ScripturianUtil.getFileForProgram( adapter.getCacheDir(), executable, position, LUO_SUFFIX );

	synchronized( dumpFile )
	{
		try
		{
			if( dumpFile.exists() )
			{
				byte[] bytes = ScripturianUtil.getBytes( dumpFile );
				bytesReference.compareAndSet( null, bytes );

				// We can't compile the bytes now, because we don't have an
				// execution context. So we'll finish preparing in
				// execute().
			}
			else
			{
				dumpFile.getParentFile().mkdirs();
				FileOutputStream out = new FileOutputStream( dumpFile );
				try
				{
					Prototype prototype = LuaC.instance.compile( new Utf8Encoder( new StringReader( sourceCode ) ), documentName );
					DumpState.dump( prototype, out, STRIP_DEBUG, NUMBER_FORMAT, LITTLE_ENDIAN );

					prototypeReference.compareAndSet( null, prototype );
				}
				finally
				{
					out.close();
				}
			}
		}
		catch( Exception x )
		{
			throw new PreparationException( executable.getDocumentName(), x );
		}
	}
}
 
开发者ID:tliron,项目名称:scripturian,代码行数:43,代码来源:LuajProgram.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XMLEntityResolver类代码示例发布时间:2022-05-23
下一篇:
Java Limit类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap