Mercurial Hosting > luan
changeset 688:f99f51bc5bea
fix up-values
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 18 Apr 2016 15:46:05 -0600 |
parents | fc08c3b42010 |
children | 51a134a8c89b |
files | core/src/luan/impl/LuanParser.java core/src/luan/modules/parsers/Theme.java |
diffstat | 2 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
diff -r fc08c3b42010 -r f99f51bc5bea core/src/luan/impl/LuanParser.java --- a/core/src/luan/impl/LuanParser.java Mon Apr 18 01:08:35 2016 -0600 +++ b/core/src/luan/impl/LuanParser.java Mon Apr 18 15:46:05 2016 -0600 @@ -148,12 +148,16 @@ if( upSym.name.equals(name) ) return upSym; } - for( Frame f=parent; f!=null; f=f.parent ) { - LocalSym sym = f.getLocalSym(name); + if( parent != null ) { + LocalSym sym = parent.getLocalSym(name); if( sym != null ) { sym.isPointer = true; return addUpSym(name,sym.javaName); } + UpSym upSym = parent.getUpSym(name); + if( upSym != null ) { + return addUpSym(name,"parentUpValues["+upSym.i+"]"); + } } return null; } @@ -1933,6 +1937,7 @@ +"} " +"@Override public Object doCall(LuanState luan,Object[] args) throws LuanException { " + +"final Pointer[] parentUpValues = upValues; " +"Object t; " +"Object[] a; " + stmts @@ -1961,6 +1966,7 @@ ); } exp.add( "" + +"final Pointer[] parentUpValues = upValues; " +"Object t; " +"Object[] a; " );
diff -r fc08c3b42010 -r f99f51bc5bea core/src/luan/modules/parsers/Theme.java --- a/core/src/luan/modules/parsers/Theme.java Mon Apr 18 01:08:35 2016 -0600 +++ b/core/src/luan/modules/parsers/Theme.java Mon Apr 18 15:46:05 2016 -0600 @@ -60,14 +60,13 @@ if( !parser.match('}') ) throw exception("unclosed define tag"); String block = parseBody("define:"+name); - String rtn = "function M." + name + "(env) " + block + "end; "; + String rtn = "function M." + name + "(env) " + block + " end; "; return parser.success(rtn); } private String parseBody(String tagName) throws ParseException { StringBuilder stmts = new StringBuilder(); int start = parser.currentIndex(); - stmts.append( "%>" ); int end = start; while( !matchEndTag(tagName) ) { if( parser.endOfInput() ) { @@ -92,7 +91,6 @@ end = parser.currentIndex(); } addText(start,end,stmts); - stmts.append( "<% "); return stmts.toString(); } @@ -107,7 +105,7 @@ private void addText(int start,int end,StringBuilder stmts) { if( start < end ) { - stmts.append( parser.text.substring(start,end) ); + stmts.append( "%>" ).append( parser.text.substring(start,end) ).append( "<%" ); } } @@ -123,7 +121,7 @@ if( !parser.match('}') ) return parser.failure(null); String block = parseBody("block:"+name); - String rtn = "<% env."+ name + "( env, function(env) " + block + "end) %>"; + String rtn = " env."+ name + "( env, function(env) " + block + "end); "; // String rtn = "<% env." + tag.name + "(" + (tag.attrs.isEmpty() ? "nil" : table(tag.attrs)) + ",env,function(env) %>" + block + "<% end) %>"; return parser.success(rtn); } @@ -138,7 +136,7 @@ if( !parser.match('}') ) return parser.failure(null); // rtn = "<% env." + name + (attrs.isEmpty() ? "()" : table(attrs)) + " %>"; - String rtn = "<% env." + name + "(env) %>"; + String rtn = " env." + name + "(env); "; return parser.success(rtn); }