Mercurial Hosting > luan
diff src/luan/modules/PackageLuan.java @ 798:9eccfede1094
fix cloning bug
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 06 Sep 2016 12:23:03 -0600 |
parents | c49980cdece6 |
children | 9c13a15a4002 |
line wrap: on
line diff
--- a/src/luan/modules/PackageLuan.java Tue Sep 06 11:50:30 2016 -0600 +++ b/src/luan/modules/PackageLuan.java Tue Sep 06 12:23:03 2016 -0600 @@ -8,6 +8,7 @@ import luan.LuanTable; import luan.LuanFunction; import luan.LuanJavaFunction; +import luan.LuanCloner; import luan.LuanException; @@ -86,7 +87,7 @@ } } - public static boolean wouldLoad(LuanState luan,String modName) throws LuanException { + private static boolean wouldLoad(LuanState luan,String modName) throws LuanException { LuanTable loaded = loaded(luan); if( loaded.rawGet(modName) != null ) return false; @@ -103,4 +104,16 @@ } } + public static void enableLoad(LuanState luan,String... mods) throws LuanException { + if( luan.isLocked ) { + for( String mod : mods ) { + if( wouldLoad(luan,mod) ) { + luan.isLocked = false; + luan.deepenClone(luan,new LuanCloner(LuanCloner.Type.COMPLETE)); + return; + } + } + } + } + }