comparison src/luan/impl/LuanParser.java @ 1434:56fb5cd8228d

cache compiled code in temp files
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 29 Dec 2019 15:25:07 -0700
parents 514b7a62fe27
children 6c830be6be98
comparison
equal deleted inserted replaced
1433:5f038be65271 1434:56fb5cd8228d
166 return sym != null ? sym : getUpSym(name); 166 return sym != null ? sym : getUpSym(name);
167 } 167 }
168 168
169 } 169 }
170 170
171 private static AtomicInteger classCounter = new AtomicInteger();
172 private int innerCounter = 0; 171 private int innerCounter = 0;
173 private final List<Inner> inners = new ArrayList<Inner>(); 172 private final List<Inner> inners = new ArrayList<Inner>();
174 173
175 private Frame frame; 174 private Frame frame;
176 private final Parser parser; 175 private final Parser parser;
235 inners.add(inner); 234 inners.add(inner);
236 return inner.toInnerFnExp( frame.upValueSymbols ); 235 return inner.toInnerFnExp( frame.upValueSymbols );
237 // return toFnExp( stmt, frame.upValueSymbols, name ); 236 // return toFnExp( stmt, frame.upValueSymbols, name );
238 } 237 }
239 238
240 Class RequiredModule() throws ParseException { 239 Compiled RequiredModule() throws ParseException {
241 GetRequiredModule(); 240 GetRequiredModule();
242 String className = "EXP" + classCounter.incrementAndGet(); 241 String className = "EXP";
243 String classCode = toFnString( top, frame.upValueSymbols, className, inners ); 242 String classCode = toFnString( top, frame.upValueSymbols, className, inners );
244 try { 243 return Compiled.compile("luan.impl."+className,parser.sourceName,classCode);
245 return LuanJavaCompiler.compile("luan.impl."+className,parser.sourceName,classCode);
246 } catch(ClassNotFoundException e) {
247 throw new RuntimeException(e);
248 }
249 } 244 }
250 245
251 String RequiredModuleSource() throws ParseException { 246 String RequiredModuleSource() throws ParseException {
252 GetRequiredModule(); 247 GetRequiredModule();
253 String className = "EXP" + classCounter.incrementAndGet(); 248 String className = "EXP";
254 return toFnString( top, frame.upValueSymbols, className, inners ); 249 return toFnString( top, frame.upValueSymbols, className, inners );
255 } 250 }
256 251
257 void GetRequiredModule() throws ParseException { 252 void GetRequiredModule() throws ParseException {
258 //Spaces(); 253 //Spaces();