comparison core/src/luan/modules/PackageLuan.java @ 427:dae264ad6a7b

fix LuanTable.put() to use metatables
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 01 May 2015 19:29:07 -0600
parents 23a93c118042
children c6bcb8859b93
comparison
equal deleted inserted replaced
426:23a93c118042 427:dae264ad6a7b
25 25
26 public static LuanTable loaded(LuanState luan) { 26 public static LuanTable loaded(LuanState luan) {
27 LuanTable tbl = (LuanTable)luan.registry().rawGet("Package.loaded"); 27 LuanTable tbl = (LuanTable)luan.registry().rawGet("Package.loaded");
28 if( tbl == null ) { 28 if( tbl == null ) {
29 tbl = new LuanTable(); 29 tbl = new LuanTable();
30 luan.registry().put("Package.loaded",tbl); 30 luan.registry().rawPut("Package.loaded",tbl);
31 } 31 }
32 return tbl; 32 return tbl;
33 } 33 }
34 34
35 public static Object require(LuanState luan,String modName) throws LuanException { 35 public static Object require(LuanState luan,String modName) throws LuanException {
54 Object result = Luan.first( 54 Object result = Luan.first(
55 luan.call(loader,"<require \""+modName+"\">",new Object[]{modName}) 55 luan.call(loader,"<require \""+modName+"\">",new Object[]{modName})
56 ); 56 );
57 mod = result!=null ? result : env; 57 mod = result!=null ? result : env;
58 } 58 }
59 loaded.put(modName,mod); 59 loaded.rawPut(modName,mod);
60 } 60 }
61 return mod; 61 return mod;
62 } 62 }
63 63
64 static String read(LuanState luan,String uri) throws LuanException { 64 static String read(LuanState luan,String uri) throws LuanException {