comparison core/src/luan/impl/LuanParser.java @ 669:e320488819b6

minor fix
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 11 Apr 2016 16:00:44 -0600
parents 7780cafca27f
children 58ebfec6178b
comparison
equal deleted inserted replaced
668:7780cafca27f 669:e320488819b6
1715 1715
1716 ExpString expr() { 1716 ExpString expr() {
1717 if( isExpr ) 1717 if( isExpr )
1718 return this; 1718 return this;
1719 ExpString exp = new ExpString(true,isStmt); 1719 ExpString exp = new ExpString(true,isStmt);
1720 exp.list.add( "Luan.first(" );
1720 exp.list.addAll( list ); 1721 exp.list.addAll( list );
1722 exp.list.add( ")" );
1721 return exp; 1723 return exp;
1722 } 1724 }
1723 } 1725 }
1724 1726
1725 private ExpString expString(List<ExpString> list) { 1727 private ExpString expString(List<ExpString> list) {
1755 private static class StmtString { 1757 private static class StmtString {
1756 final List list = new ArrayList(); 1758 final List list = new ArrayList();
1757 boolean hasReturn = false; 1759 boolean hasReturn = false;
1758 } 1760 }
1759 1761
1760 private static Class toFnClass(StmtString stmt,int stackSize,int numArgs,boolean isVarArg,UpValue.Getter[] upValueGetters) { 1762 private static String concat(List list) {
1761 StringBuilder sb = new StringBuilder(); 1763 StringBuilder sb = new StringBuilder();
1762 for( Object o : stmt.list ) { 1764 for( Object o : list ) {
1763 if( o instanceof List ) throw new RuntimeException(); 1765 if( o instanceof List ) throw new RuntimeException();
1764 if( o instanceof ExpString ) throw new RuntimeException(); 1766 if( o instanceof ExpString ) throw new RuntimeException();
1765 if( o instanceof StmtString ) throw new RuntimeException(); 1767 if( o instanceof StmtString ) throw new RuntimeException();
1766 sb.append( o.toString() ); 1768 sb.append( o.toString() );
1767 } 1769 }
1768 String code = sb.toString(); 1770 return sb.toString();
1771 }
1772
1773 private static Class toFnClass(StmtString stmt,int stackSize,int numArgs,boolean isVarArg,UpValue.Getter[] upValueGetters) {
1774 String code = concat(stmt.list);
1769 //System.out.println("code:\n"+code); 1775 //System.out.println("code:\n"+code);
1770 1776
1771 int i = LuanImpl.addObj(upValueGetters); 1777 int i = LuanImpl.addObj(upValueGetters);
1772 String className = "EXP" + ++classCounter; 1778 String className = "EXP" + ++classCounter;
1773 String classCode = "" 1779 String classCode = ""