Mercurial Hosting > luan
diff core/src/luan/impl/LuanParser.java @ 680:ecd436959855
improve template statements
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 14 Apr 2016 16:38:30 -0600 |
parents | 43522473599d |
children | f1c935be546d |
line wrap: on
line diff
--- a/core/src/luan/impl/LuanParser.java Thu Apr 14 15:19:25 2016 -0600 +++ b/core/src/luan/impl/LuanParser.java Thu Apr 14 16:38:30 2016 -0600 @@ -183,6 +183,7 @@ private Frame frame; private final Parser parser; private final Stmts top; + private boolean hasTemplateWrite = false; LuanParser(String sourceName,String sourceText) { // this.source = source; @@ -372,14 +373,14 @@ Expr exprs = TemplateExpressions(In.NOTHING); if( exprs == null ) return null; - Expr requireCall = new Expr(Val.SINGLE,false); - requireCall.add( "PackageLuan.require(luan,\"luan:Io\")" ); - Expr stdoutExp = indexExpStr( requireCall.single(), constExpStr("stdout") ); - Expr writeExp = indexExpStr( stdoutExp, constExpStr("write") ); - Expr writeCall = callExpStr( writeExp, exprs ); + if( !hasTemplateWrite ) { + top.add(0,"final LuanFunction template_write = Luan.checkFunction(luan.index(PackageLuan.require(luan,\"luan:Io\"),\"template_write\")); "); + hasTemplateWrite = true; + } Stmts stmt = new Stmts(); - stmt.addAll( writeCall ); - stmt.add( "; " ); + stmt.add( "template_write.call(luan," ); + stmt.addAll( exprs.array() ); + stmt.add( "); " ); return stmt; }