comparison src/luan/CmdLine.java @ 35:e51906de0f11

implement metatables git-svn-id: https://luan-java.googlecode.com/svn/trunk@36 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 18 Dec 2012 07:05:58 +0000
parents 0cdc1da466ee
children 2a35154aec14
comparison
equal deleted inserted replaced
34:0cdc1da466ee 35:e51906de0f11
6 import luan.lib.BasicLib; 6 import luan.lib.BasicLib;
7 import luan.interp.LuaCompiler; 7 import luan.interp.LuaCompiler;
8 8
9 9
10 public class CmdLine { 10 public class CmdLine {
11 static final String version = "Luan 0.0";
12 11
13 public static void main(String[] args) throws Exception { 12 public static void main(String[] args) throws Exception {
14 LuaState lua = LuaCompiler.newLuaState(); 13 LuaState lua = LuaCompiler.newLuaState();
15 BasicLib.register(lua); 14 BasicLib.register(lua);
16 boolean interactive = false; 15 boolean interactive = false;
54 } 53 }
55 i++; 54 i++;
56 } 55 }
57 } 56 }
58 if( showVersion ) 57 if( showVersion )
59 System.out.println(version); 58 System.out.println(Lua.version);
60 if( i < args.length ) { 59 if( i < args.length ) {
61 String file = args[i++]; 60 String file = args[i++];
62 Object[] varArgs = new Object[args.length-1]; 61 Object[] varArgs = new Object[args.length-1];
63 System.arraycopy(args,1,varArgs,0,varArgs.length); 62 System.arraycopy(args,1,varArgs,0,varArgs.length);
64 LuaTable argsTable = new LuaTable(); 63 LuaTable argsTable = new LuaTable();
65 for( int j=0; j<args.length; j++ ) { 64 for( int j=0; j<args.length; j++ ) {
66 argsTable.set( new LuaNumber(j), args[j] ); 65 argsTable.put( new LuaNumber(j), args[j] );
67 } 66 }
68 lua.global().set("arg",argsTable); 67 lua.global().put("arg",argsTable);
69 try { 68 try {
70 LuaFunction fn = BasicLib.loadfile(lua,file); 69 LuaFunction fn = BasicLib.loadfile(lua,file);
71 fn.call(lua,varArgs); 70 fn.call(lua,varArgs);
72 } catch(LuaException e) { 71 } catch(LuaException e) {
73 // System.err.println(e.getMessage()); 72 // System.err.println(e.getMessage());