Mercurial Hosting > luan
comparison src/luan/modules/PackageLuan.java @ 1563:8fbcc4747091
remove LuanFunction.luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 09 Nov 2020 01:37:57 -0700 |
parents | b89212fd04b5 |
children | c922446f53aa |
comparison
equal
deleted
inserted
replaced
1562:b89212fd04b5 | 1563:8fbcc4747091 |
---|---|
18 | 18 |
19 public static LuanFunction requireFn(Luan luan) { | 19 public static LuanFunction requireFn(Luan luan) { |
20 LuanFunction fn = (LuanFunction)luan.registry().get("Package.require"); | 20 LuanFunction fn = (LuanFunction)luan.registry().get("Package.require"); |
21 if( fn == null ) { | 21 if( fn == null ) { |
22 try { | 22 try { |
23 fn = new LuanJavaFunction(luan,PackageLuan.class.getMethod("require",Luan.class,String.class),null); | 23 fn = new LuanJavaFunction(PackageLuan.class.getMethod("require",Luan.class,String.class),null); |
24 } catch(NoSuchMethodException e) { | 24 } catch(NoSuchMethodException e) { |
25 throw new RuntimeException(e); | 25 throw new RuntimeException(e); |
26 } | 26 } |
27 luan.registry().put("Package.require",fn); | 27 luan.registry().put("Package.require",fn); |
28 } | 28 } |
62 } catch(IOException e) { | 62 } catch(IOException e) { |
63 throw new RuntimeException(e); | 63 throw new RuntimeException(e); |
64 } | 64 } |
65 LuanFunction loader = luan.load(src,modName,true); | 65 LuanFunction loader = luan.load(src,modName,true); |
66 mod = Luan.first( | 66 mod = Luan.first( |
67 loader.call(modName) | 67 loader.call(luan,modName) |
68 ); | 68 ); |
69 if( mod == null ) | 69 if( mod == null ) |
70 throw new RuntimeException(); | 70 throw new RuntimeException(); |
71 } else if( modName.startsWith("java:") ) { | 71 } else if( modName.startsWith("java:") ) { |
72 mod = JavaLuan.load(luan,modName.substring(5)); | 72 mod = JavaLuan.load(luan,modName.substring(5)); |
77 if( src == null ) { | 77 if( src == null ) { |
78 mod = Boolean.FALSE; | 78 mod = Boolean.FALSE; |
79 } else { | 79 } else { |
80 LuanFunction loader = luan.load(src,modName,true); | 80 LuanFunction loader = luan.load(src,modName,true); |
81 mod = Luan.first( | 81 mod = Luan.first( |
82 loader.call(modName) | 82 loader.call(luan,modName) |
83 ); | 83 ); |
84 if( mod == null ) { | 84 if( mod == null ) { |
85 mod = loaded.rawGet(modName); | 85 mod = loaded.rawGet(modName); |
86 if( mod != null ) | 86 if( mod != null ) |
87 return mod; | 87 return mod; |
101 } catch(LuanException e) { | 101 } catch(LuanException e) { |
102 throw new RuntimeException(e); | 102 throw new RuntimeException(e); |
103 } | 103 } |
104 Luan.Security security = Luan.setSecurity(luan,null); | 104 Luan.Security security = Luan.setSecurity(luan,null); |
105 try { | 105 try { |
106 return (String)Luan.first(boot.fn(luan,"read").call(uri)); | 106 return (String)Luan.first(boot.fn("read").call(luan,uri)); |
107 } catch(LuanException e) { | 107 } catch(LuanException e) { |
108 return null; | 108 return null; |
109 } finally { | 109 } finally { |
110 if( security != null ) | 110 if( security != null ) |
111 Luan.setSecurity(luan,security); | 111 Luan.setSecurity(luan,security); |