Mercurial Hosting > luan
comparison src/luan/impl/LuanParser.java @ 1333:25746915a241
merge Luan and LuanState
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Feb 2019 22:33:40 -0700 |
parents | f41919741100 |
children | e0cf0d108a77 |
comparison
equal
deleted
inserted
replaced
1332:11b7e11f9ed5 | 1333:25746915a241 |
---|---|
7 import java.util.Arrays; | 7 import java.util.Arrays; |
8 import java.util.List; | 8 import java.util.List; |
9 import java.util.ArrayList; | 9 import java.util.ArrayList; |
10 import java.util.concurrent.atomic.AtomicInteger; | 10 import java.util.concurrent.atomic.AtomicInteger; |
11 import luan.Luan; | 11 import luan.Luan; |
12 import luan.LuanState; | |
13 import luan.LuanTable; | 12 import luan.LuanTable; |
14 import luan.modules.PackageLuan; | 13 import luan.modules.PackageLuan; |
15 | 14 |
16 | 15 |
17 final class LuanParser { | 16 final class LuanParser { |
2010 return "" | 2009 return "" |
2011 +"package luan.impl; " | 2010 +"package luan.impl; " |
2012 +"import luan.LuanClosure; " | 2011 +"import luan.LuanClosure; " |
2013 +"import luan.Luan; " | 2012 +"import luan.Luan; " |
2014 +"import luan.LuanFunction; " | 2013 +"import luan.LuanFunction; " |
2015 +"import luan.LuanState; " | |
2016 +"import luan.LuanException; " | 2014 +"import luan.LuanException; " |
2017 +"import luan.modules.PackageLuan; " | 2015 +"import luan.modules.PackageLuan; " |
2018 | 2016 |
2019 +"public class " + className +" extends LuanClosure { " | 2017 +"public class " + className +" extends LuanClosure { " |
2020 +"public "+className+"(boolean javaOk,String sourceName) throws LuanException { " | 2018 +"public "+className+"(boolean javaOk,String sourceName) throws LuanException { " |
2021 +"super("+upValueSymbols.size()+",javaOk,sourceName); " | 2019 +"super("+upValueSymbols.size()+",javaOk,sourceName); " |
2022 + init(upValueSymbols) | 2020 + init(upValueSymbols) |
2023 +"} " | 2021 +"} " |
2024 | 2022 |
2025 +"@Override public Object doCall(LuanState luan,Object[] args) throws LuanException { " | 2023 +"@Override public Object doCall(Luan luan,Object[] args) throws LuanException { " |
2026 +"final Pointer[] parentUpValues = upValues; " | 2024 +"final Pointer[] parentUpValues = upValues; " |
2027 +"Object t; " | 2025 +"Object t; " |
2028 +"Object[] a; " | 2026 +"Object[] a; " |
2029 + stmts | 2027 + stmts |
2030 +"\n} " | 2028 +"\n} " |
2040 exp.add( "" | 2038 exp.add( "" |
2041 +"new LuanClosure("+upValueSymbols.size()+",javaOk,sourceName) { " | 2039 +"new LuanClosure("+upValueSymbols.size()+",javaOk,sourceName) { " |
2042 +"{ " | 2040 +"{ " |
2043 + init(upValueSymbols) | 2041 + init(upValueSymbols) |
2044 +"} " | 2042 +"} " |
2045 +"@Override public Object doCall(LuanState luan,Object[] args) throws LuanException { " | 2043 +"@Override public Object doCall(Luan luan,Object[] args) throws LuanException { " |
2046 ); | 2044 ); |
2047 if( name != null ) { | 2045 if( name != null ) { |
2048 exp.add( "" | 2046 exp.add( "" |
2049 +"return _" + name + "(luan,args); " | 2047 +"return _" + name + "(luan,args); " |
2050 +"} " | 2048 +"} " |
2051 +"private Object _" + name + "(LuanState luan,Object[] args) throws LuanException { " | 2049 +"private Object _" + name + "(Luan luan,Object[] args) throws LuanException { " |
2052 ); | 2050 ); |
2053 } | 2051 } |
2054 exp.add( "" | 2052 exp.add( "" |
2055 +"final Pointer[] parentUpValues = upValues; " | 2053 +"final Pointer[] parentUpValues = upValues; " |
2056 +"Object t; " | 2054 +"Object t; " |