Mercurial Hosting > luan
comparison core/src/luan/modules/BasicLuan.java @ 264:9e0d4452e649
implement URL style module names
git-svn-id: https://luan-java.googlecode.com/svn/trunk@265 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 29 Oct 2014 03:50:59 +0000 |
parents | f1f7d8c7e94e |
children | 454a486d9c19 |
comparison
equal
deleted
inserted
replaced
263:54873a389f80 | 264:9e0d4452e649 |
---|---|
72 allowExpr = false; | 72 allowExpr = false; |
73 return LuanCompiler.compile(luan,new LuanSource(sourceName,text),env,allowExpr); | 73 return LuanCompiler.compile(luan,new LuanSource(sourceName,text),env,allowExpr); |
74 } | 74 } |
75 | 75 |
76 public static LuanFunction load_file(LuanState luan,String fileName) throws LuanException { | 76 public static LuanFunction load_file(LuanState luan,String fileName) throws LuanException { |
77 try { | 77 LuanTable t = fileName==null ? IoLuan.stdin.table() : IoLuan.get(luan,fileName,false); |
78 String src; | 78 if( t == null ) |
79 if( fileName==null ) { | 79 throw luan.exception( "file '"+fileName+"' not found" ); |
80 src = Utils.readAll(new InputStreamReader(System.in)); | 80 LuanFunction loader = (LuanFunction)t.get("loader"); |
81 } else { | 81 return (LuanFunction)Luan.first(luan.call(loader,new Object[]{fileName})); |
82 LuanTable t = IoLuan.get(luan,fileName); | |
83 if( t == null ) | |
84 throw luan.exception( "file '"+fileName+"' not found" ); | |
85 LuanFunction fn = (LuanFunction)t.get("read_text"); | |
86 src = (String)Luan.first(luan.call(fn)); | |
87 } | |
88 return load(luan,src,fileName,null,false); | |
89 } catch(IOException e) { | |
90 throw luan.exception(e); | |
91 } | |
92 } | 82 } |
93 | 83 |
94 public static Object do_file(LuanState luan,String fileName) throws LuanException { | 84 public static Object do_file(LuanState luan,String fileName) throws LuanException { |
95 LuanFunction fn = load_file(luan,fileName); | 85 LuanFunction fn = load_file(luan,fileName); |
96 return luan.call(fn); | 86 return luan.call(fn); |