Mercurial Hosting > luan
diff src/luan/modules/PackageLuan.java @ 1578:c922446f53aa
immutable threading
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 08 Feb 2021 14:16:19 -0700 |
parents | 8fbcc4747091 |
children | 2975c932864d |
line wrap: on
line diff
--- a/src/luan/modules/PackageLuan.java Sun Jan 31 16:04:39 2021 -0700 +++ b/src/luan/modules/PackageLuan.java Mon Feb 08 14:16:19 2021 -0700 @@ -5,12 +5,13 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collections; +import java.util.Map; +import java.util.HashMap; import goodjava.io.IoUtils; import luan.Luan; import luan.LuanTable; import luan.LuanFunction; import luan.LuanJavaFunction; -import luan.LuanCloner; import luan.LuanException; @@ -29,13 +30,13 @@ return fn; } - public static LuanTable loaded(Luan luan) { - LuanTable tbl = (LuanTable)luan.registry().get("Package.loaded"); - if( tbl == null ) { - tbl = new LuanTable(); - luan.registry().put("Package.loaded",tbl); + public static Map loaded(Luan luan) { + Map map = (Map)luan.registry().get("Package.loaded"); + if( map == null ) { + map = new HashMap(); + luan.registry().put("Package.loaded",map); } - return tbl; + return map; } public static Object require(Luan luan,String modName) throws LuanException { @@ -50,8 +51,8 @@ } public static Object load(Luan luan,String modName) throws LuanException { - LuanTable loaded = loaded(luan); - Object mod = loaded.rawGet(modName); + Map loaded = loaded(luan); + Object mod = loaded.get(modName); if( mod == null ) { if( modName.equals("luan:Boot.luan") ) { String src; @@ -82,14 +83,14 @@ loader.call(luan,modName) ); if( mod == null ) { - mod = loaded.rawGet(modName); + mod = loaded.get(modName); if( mod != null ) return mod; throw new LuanException( "module '"+modName+"' returned nil" ); } } } - loaded.rawPut(modName,mod); + loaded.put(modName,mod); } return mod; }