Mercurial Hosting > luan
diff 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 |
line wrap: on
line diff
--- a/core/src/luan/modules/BasicLuan.java Wed Oct 29 00:02:14 2014 +0000 +++ b/core/src/luan/modules/BasicLuan.java Wed Oct 29 03:50:59 2014 +0000 @@ -74,21 +74,11 @@ } public static LuanFunction load_file(LuanState luan,String fileName) throws LuanException { - try { - String src; - if( fileName==null ) { - src = Utils.readAll(new InputStreamReader(System.in)); - } else { - LuanTable t = IoLuan.get(luan,fileName); - if( t == null ) - throw luan.exception( "file '"+fileName+"' not found" ); - LuanFunction fn = (LuanFunction)t.get("read_text"); - src = (String)Luan.first(luan.call(fn)); - } - return load(luan,src,fileName,null,false); - } catch(IOException e) { - throw luan.exception(e); - } + LuanTable t = fileName==null ? IoLuan.stdin.table() : IoLuan.get(luan,fileName,false); + if( t == null ) + throw luan.exception( "file '"+fileName+"' not found" ); + LuanFunction loader = (LuanFunction)t.get("loader"); + return (LuanFunction)Luan.first(luan.call(loader,new Object[]{fileName})); } public static Object do_file(LuanState luan,String fileName) throws LuanException {