Mercurial Hosting > luan
comparison src/luan/LuanState.java @ 141:c2ee8a717b73
move loading of standard modules to luan
git-svn-id: https://luan-java.googlecode.com/svn/trunk@142 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 13 Jun 2014 16:37:49 +0000 |
parents | f4ce03ff6b2f |
children | 05f8c21160ef |
comparison
equal
deleted
inserted
replaced
140:f4ce03ff6b2f | 141:c2ee8a717b73 |
---|---|
129 t = (LuanTable)obj; | 129 t = (LuanTable)obj; |
130 } | 130 } |
131 return t.put(a[a.length-1],value); | 131 return t.put(a[a.length-1],value); |
132 } | 132 } |
133 | 133 |
134 public final void load(String modName,LuanFunction loader) throws LuanException { | 134 private final void load(String modName,LuanFunction loader) throws LuanException { |
135 preload.put(modName,loader); | 135 preload.put(modName,loader); |
136 Object mod = PackageLib.require(this,modName); | 136 Object mod = PackageLib.require(this,modName); |
137 if( mod==null ) | 137 if( mod==null ) |
138 throw new RuntimeException(); | 138 throw new RuntimeException(); |
139 global.put(modName,mod); | 139 global.put(modName,mod); |
140 } | 140 } |
141 | 141 |
142 public static LuanState newStandard() { | 142 public static LuanState newStandard() { |
143 try { | 143 try { |
144 LuanState luan = LuanCompiler.newLuanState(); | 144 LuanState luan = LuanCompiler.newLuanState(); |
145 luan.load(BasicLib.NAME,BasicLib.LOADER); | |
146 luan.load(PackageLib.NAME,PackageLib.LOADER); | 145 luan.load(PackageLib.NAME,PackageLib.LOADER); |
147 luan.load(MathLib.NAME,MathLib.LOADER); | |
148 luan.load(StringLib.NAME,StringLib.LOADER); | |
149 luan.load(TableLib.NAME,TableLib.LOADER); | |
150 luan.load(HtmlLib.NAME,HtmlLib.LOADER); | |
151 luan.load(BinaryLib.NAME,BinaryLib.LOADER); | |
152 luan.load(IoLib.NAME,IoLib.LOADER); | |
153 luan.load(ThreadLib.NAME,ThreadLib.LOADER); | |
154 BasicLib.do_java_resource(luan,"luan/lib/init.luan"); | 146 BasicLib.do_java_resource(luan,"luan/lib/init.luan"); |
155 luan.preload.put(JavaLib.NAME,JavaLib.LOADER); | |
156 luan.preload.put(HttpLib.NAME,HttpLib.LOADER); | |
157 return luan; | 147 return luan; |
158 } catch(LuanException e) { | 148 } catch(LuanException e) { |
159 throw new RuntimeException(e); | 149 throw new RuntimeException(e); |
160 } | 150 } |
161 } | 151 } |