changeset 369:85bf9f0379aa

template statements no longer depend on 'Io' being defined
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 17 Apr 2015 06:25:38 -0600
parents 2af805677fc4
children 7999601586b1
files core/src/luan/impl/LuanParser.java
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/impl/LuanParser.java	Fri Apr 17 05:16:07 2015 -0600
+++ b/core/src/luan/impl/LuanParser.java	Fri Apr 17 06:25:38 2015 -0600
@@ -265,16 +265,17 @@
 
 	private Stmt TemplateStmt() throws ParseException {
 		int start = parser.currentIndex();
-		Expressions exp = TemplateExpressions(In.NOTHING);
-		if( exp == null )
+		Expressions exprs = TemplateExpressions(In.NOTHING);
+		if( exprs == null )
 			return null;
-		Expr fnExp = (Expr)nameVar(start,"Io").expr();
-		LuanSource.Element se = se(start,"stdout");
-		fnExp = new IndexExpr( se, fnExp, new ConstExpr(se,"stdout") );
+		LuanSource.Element se = se(start,"require 'luan:Io'");
+		FnCall requireCall = new FnCall( se, new ConstExpr(se,PackageLuan.requireFn), new ConstExpr(se,"luan:Io") );
+		se = se(start,"stdout");
+		Expr stdoutExp = new IndexExpr( se, expr(requireCall), new ConstExpr(se,"stdout") );
 		se = se(start,"write");
-		fnExp = new IndexExpr( se, fnExp, new ConstExpr(se,"write") );
-		FnCall fnCall = new FnCall( se(start), fnExp, exp );
-		return new ExpressionsStmt(fnCall);
+		Expr writeExp = new IndexExpr( se, stdoutExp, new ConstExpr(se,"write") );
+		FnCall writeCall = new FnCall( se(start), writeExp, exprs );
+		return new ExpressionsStmt(writeCall);
 	}
 
 	private Expressions TemplateExpressions(In in) throws ParseException {