diff src/luan/modules/PackageLuan.java @ 1580:2975c932864d

require options
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 10 Feb 2021 23:56:59 -0700
parents c922446f53aa
children a37ffe2d1b14
line wrap: on
line diff
--- a/src/luan/modules/PackageLuan.java	Wed Feb 10 22:49:47 2021 -0700
+++ b/src/luan/modules/PackageLuan.java	Wed Feb 10 23:56:59 2021 -0700
@@ -21,7 +21,7 @@
 		LuanFunction fn = (LuanFunction)luan.registry().get("Package.require");
 		if( fn == null ) {
 			try {
-				fn = new LuanJavaFunction(PackageLuan.class.getMethod("require",Luan.class,String.class),null);
+				fn = new LuanJavaFunction(PackageLuan.class.getMethod("require",Luan.class,String.class,LuanTable.class),null);
 			} catch(NoSuchMethodException e) {
 				throw new RuntimeException(e);
 			}
@@ -39,18 +39,18 @@
 		return map;
 	}
 
-	public static Object require(Luan luan,String modName) throws LuanException {
+	public static Object require(Luan luan,String modName,LuanTable options) throws LuanException {
 		if( "java".equals(modName) ) {
 			JavaLuan.java(luan);
 			return true;
 		}
-		Object mod = load(luan,modName);
+		Object mod = load(luan,modName,options);
 		if( mod.equals(Boolean.FALSE) )
 			throw new LuanException( "module '"+modName+"' not found" );
 		return mod;
 	}
 
-	public static Object load(Luan luan,String modName) throws LuanException {
+	public static Object load(Luan luan,String modName,LuanTable options) throws LuanException {
 		Map loaded = loaded(luan);
 		Object mod = loaded.get(modName);
 		if( mod == null ) {
@@ -74,7 +74,7 @@
 				if( mod == null )
 					mod = Boolean.FALSE;
 			} else {
-				String src = read(luan,modName);
+				String src = read(luan,modName,options);
 				if( src == null ) {
 					mod = Boolean.FALSE;
 				} else {
@@ -95,7 +95,7 @@
 		return mod;
 	}
 
-	static String read(Luan luan,String uri) {
+	static String read(Luan luan,String uri,LuanTable options) {
 		LuanTable boot;
 		try {
 			boot = (LuanTable)luan.require("luan:Boot.luan");
@@ -104,7 +104,7 @@
 		}
 		Luan.Security security = Luan.setSecurity(luan,null);
 		try {
-			return (String)Luan.first(boot.fn("read").call(luan,uri));
+			return (String)Luan.first(boot.fn("read").call(luan,uri,options));
 		} catch(LuanException e) {
 			return null;
 		} finally {