Mercurial Hosting > luan
comparison src/luan/lib/PackageLib.java @ 88:6ca02b188dba
add LuanBit to clean up code;
add repr();
git-svn-id: https://luan-java.googlecode.com/svn/trunk@89 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 27 Feb 2013 23:50:32 +0000 |
parents | 6db8f286fa6c |
children | b1e87f1bcc13 |
comparison
equal
deleted
inserted
replaced
87:eaf37cfa30c2 | 88:6ca02b188dba |
---|---|
59 LuanTable searchers = (LuanTable)luan.get("package.searchers"); | 59 LuanTable searchers = (LuanTable)luan.get("package.searchers"); |
60 if( searchers == null ) | 60 if( searchers == null ) |
61 searchers = new LuanTable(Collections.<Object>singletonList(preloadSearcher)); | 61 searchers = new LuanTable(Collections.<Object>singletonList(preloadSearcher)); |
62 for( Object s : searchers.asList() ) { | 62 for( Object s : searchers.asList() ) { |
63 LuanFunction searcher = (LuanFunction)s; | 63 LuanFunction searcher = (LuanFunction)s; |
64 Object[] a = luan.call(searcher,LuanElement.JAVA,"<searcher>",modName); | 64 Object[] a = luan.JAVA.call(searcher,"<searcher>",modName); |
65 if( a.length >= 1 && a[0] instanceof LuanFunction ) { | 65 if( a.length >= 1 && a[0] instanceof LuanFunction ) { |
66 LuanFunction loader = (LuanFunction)a[0]; | 66 LuanFunction loader = (LuanFunction)a[0]; |
67 luan.call(loader,LuanElement.JAVA,"<loader>"); | 67 luan.JAVA.call(loader,"<loader>"); |
68 mod = (LuanTable)luan.loaded().get(modName); | 68 mod = (LuanTable)luan.loaded().get(modName); |
69 if( mod==null ) | 69 if( mod==null ) |
70 throw new LuanException( luan, LuanElement.JAVA, "module '"+modName+"' didn't define its module" ); | 70 throw luan.JAVA.exception( "module '"+modName+"' didn't define its module" ); |
71 break; | 71 break; |
72 } | 72 } |
73 } | 73 } |
74 if( mod == null ) | 74 if( mod == null ) |
75 throw new LuanException( luan, LuanElement.JAVA, "module '"+modName+"' not found" ); | 75 throw luan.JAVA.exception( "module '"+modName+"' not found" ); |
76 } | 76 } |
77 if( env != null ) | 77 if( env != null ) |
78 env.put(modName,mod); | 78 env.put(modName,mod); |
79 } | 79 } |
80 | 80 |
133 try { | 133 try { |
134 String src = Utils.read(url); | 134 String src = Utils.read(url); |
135 LuanFunction fn = BasicLib.load(luan,src,url.toString(),null); | 135 LuanFunction fn = BasicLib.load(luan,src,url.toString(),null); |
136 fn.call(luan,EMPTY); | 136 fn.call(luan,EMPTY); |
137 } catch(IOException e) { | 137 } catch(IOException e) { |
138 throw new LuanException(luan,LuanElement.JAVA,e); | 138 throw luan.JAVA.exception(e); |
139 } | 139 } |
140 } | 140 } |
141 }; | 141 }; |
142 | 142 |
143 public static final LuanFunction javaFileSearcher = new LuanFunction() { | 143 public static final LuanFunction javaFileSearcher = new LuanFunction() { |