Changeset 3453 for devel-tools/trunk
- Timestamp:
- Feb 29, 2008, 6:25:36 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/core/builder/RfpBuilder.java
r3444 r3453 33 33 import org.refal.plus.Expr; 34 34 import org.refal.plus.Reference; 35 import org.refal.plus.Result; 35 36 import org.refal.plus.comp.FormatReader; 36 37 import org.refal.plus.rfpdt.comp.Checker; … … 43 44 44 45 public class RfpBuilder extends IncrementalProjectBuilder { 45 private class ExternalCompilerEnvironment implements org.refal.plus.comp.CompilerEnvironment { 46 private final IFile file; 47 private final String moduleName; 48 49 public ExternalCompilerEnvironment (IFile file) { 50 this.file = file; 51 this.moduleName = RfpBuilder.getModuleName(file); 52 } 53 54 public Reader getImplemReader () { 55 try { 56 InputStream inputStream = file.getContents(); 57 String charSet = file.getCharset(); 58 return new InputStreamReader(inputStream, charSet); 59 } catch (Exception e) { 60 return null; 61 } 62 } 63 64 public Reader getInterfReader (String moduleName) { 65 IFile rfiFile = getIFile(moduleName, "rfi"); 66 if (rfiFile.exists()) { 67 try { 68 InputStream inputStream = rfiFile.getContents(); 69 String charSet = rfiFile.getCharset(); 70 return new InputStreamReader(inputStream, charSet); 71 } catch (Exception e) { 72 return null; 73 } 74 } 75 76 Reader interfReader = getRfiFileFromJar(moduleName); 77 if (interfReader == null) 78 interfReader = getInterfReaderFromClass(moduleName); 79 return interfReader; 80 } 81 82 public String getModuleName () { 83 return moduleName; 84 } 85 86 public void makeClass (String className, byte[] bytes) { 87 IFile classFile = getIFile(className, "class"); 88 InputStream inputStream = new ByteArrayInputStream(bytes); 89 try { 90 classFile.create(inputStream, true, null); 91 inputStream.close(); 92 classFile.setDerived(true); 93 } catch (Exception e) { 94 RfpCorePlugin.log(e); 95 } 46 private void makeClass (String className, byte[] bytes) { 47 IFile classFile = getIFile(className, "class"); 48 InputStream inputStream = new ByteArrayInputStream(bytes); 49 try { 50 classFile.create(inputStream, true, null); 51 inputStream.close(); 52 classFile.setDerived(true); 53 } catch (Exception e) { 54 RfpCorePlugin.log(e); 96 55 } 97 56 } … … 292 251 } 293 252 253 @SuppressWarnings("unchecked") 294 254 private void checkAndCompileModuleImplem (IResource resource) { 295 255 if (!isRfFile(resource)) … … 302 262 if (environment.getMsgHandler().getErrorCount() > 0) 303 263 return; 304 ExternalCompilerEnvironment externalCompilerEnvironment = new ExternalCompilerEnvironment(file); 305 try { 306 Expr env = new Expr(new Reference<org.refal.plus.comp.CompilerEnvironment>(externalCompilerEnvironment)); 264 try { 307 265 Expr ast = RefalASGenerator.generateAS(astImplem); 308 266 Expr list = CallListGenerator.generateAS(astImplem); 309 org.refal.plus.compiler.rfpc.CompileASToJBC2(env, ast, list); 267 Result res = new Result(); 268 org.refal.plus.compiler.rfpc.CompileASToJBC2(ast, list, res); 269 for (Comparable<?> p : res.getExpr()) { 270 Expr e = (Expr) p; 271 String name = (String) e.at(0); 272 Reference<byte[]> jbc = (Reference<byte[]>) e.at(1); 273 makeClass(name, jbc.object); 274 } 310 275 } catch (org.refal.plus.RefalException e) { 311 276 System.err.println(e); … … 487 452 } 488 453 489 private Reader getRfiFileFromJar (String moduleName) {490 ClassLoader classLoader = this.getClass().getClassLoader();491 InputStream inputStream = classLoader.getResourceAsStream(moduleName + ".rfi");492 return inputStream == null ? null : new InputStreamReader(inputStream);493 }494 495 private Reader getInterfReaderFromClass (String moduleName) {496 String formats = null;497 try {498 IFile classFile = getIFile(moduleName, "class");499 if (classFile.exists()) {500 InputStream inputStream = classFile.getContents();501 formats = FormatReader.ReadFormatsFromClass(inputStream);502 inputStream.close();503 } else {504 ClassLoader classLoader = this.getClass().getClassLoader();505 InputStream inputStream = classLoader.getResourceAsStream(moduleName + ".class");506 if (inputStream != null)507 formats = FormatReader.ReadFormatsFromClass(inputStream);508 inputStream.close();509 }510 } catch (Exception e) {511 RfpCorePlugin.log(e);512 }513 return formats == null ? null : new StringReader(formats);514 }515 516 454 private void incrementalBuild (IResourceDelta delta, IProgressMonitor monitor) throws CoreException { 517 455 SortedSet<String> modulesToRecompile = collectModulesToRecompile(delta);
Note: See TracChangeset
for help on using the changeset viewer.