diff core/src/luan/impl/LuanParser.java @ 179:bf9c7111a371

minor git-svn-id: https://luan-java.googlecode.com/svn/trunk@180 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 24 Jun 2014 00:05:53 +0000
parents bdbd4740121f
children 5351374efb6d
line wrap: on
line diff
--- a/core/src/luan/impl/LuanParser.java	Mon Jun 23 20:41:08 2014 +0000
+++ b/core/src/luan/impl/LuanParser.java	Tue Jun 24 00:05:53 2014 +0000
@@ -345,7 +345,21 @@
 		int start = parser.begin();
 		if( !Keyword("import",In.NOTHING) )
 			return parser.failure(null);
-		Expr importExpr = (Expr)nameVar(start,"require").expr();
+		Expr importExpr;
+		{
+			LuanSource.Element se = se(start);
+			int index = stackIndex("require");
+			if( index != -1 ) {
+				importExpr = new GetLocalVar(se,index);
+			} else {
+				index = upValueIndex("require");
+				if( index != -1 ) {
+					importExpr = new GetUpVar(se,index);
+				} else {
+					throw parser.exception("no local 'require' function, needed for import");
+				}
+			}
+		}
 		String modName = StringLiteral(In.NOTHING);
 		if( modName==null )
 			return parser.failure(null);