Mercurial Hosting > luan
comparison src/luan/LuanState.java @ 59:5c9cadd0acce
move standard calls from CmdLine to LuanState
git-svn-id: https://luan-java.googlecode.com/svn/trunk@60 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 07 Jan 2013 03:36:28 +0000 |
parents | 8ede219cd111 |
children | f7e17cfb35f9 |
comparison
equal
deleted
inserted
replaced
58:d6c454b7f58c | 59:5c9cadd0acce |
---|---|
2 | 2 |
3 import java.io.InputStream; | 3 import java.io.InputStream; |
4 import java.io.PrintStream; | 4 import java.io.PrintStream; |
5 import java.util.List; | 5 import java.util.List; |
6 import java.util.ArrayList; | 6 import java.util.ArrayList; |
7 import luan.interp.LuanCompiler; | |
8 import luan.lib.BasicLib; | |
9 import luan.lib.JavaLib; | |
10 import luan.lib.MathLib; | |
11 import luan.lib.StringLib; | |
12 import luan.lib.TableLib; | |
13 import luan.lib.HtmlLib; | |
7 | 14 |
8 | 15 |
9 public abstract class LuanState { | 16 public abstract class LuanState { |
17 | |
18 public static LuanState newStandard() { | |
19 LuanState luan = LuanCompiler.newLuanState(); | |
20 BasicLib.register(luan); | |
21 JavaLib.register(luan); | |
22 MathLib.register(luan); | |
23 StringLib.register(luan); | |
24 TableLib.register(luan); | |
25 HtmlLib.register(luan); | |
26 return luan; | |
27 } | |
28 | |
29 public Object[] eval(String cmd,String sourceName) throws LuanException { | |
30 LuanFunction fn = BasicLib.load(this,cmd,sourceName); | |
31 return call(fn,null,null); | |
32 } | |
33 | |
34 | |
35 | |
10 private final LuanTable global = new LuanTable(); | 36 private final LuanTable global = new LuanTable(); |
11 private final List<MetatableGetter> mtGetters = new ArrayList<MetatableGetter>(); | 37 private final List<MetatableGetter> mtGetters = new ArrayList<MetatableGetter>(); |
12 final List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>(); | 38 final List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>(); |
13 | 39 |
14 public InputStream in = System.in; | 40 public InputStream in = System.in; |