public static void main(String... args) throws IOException { OutputStreamWriter out = (OutputStreamWriter) RT.OUT.deref(); PrintWriter err = RT.errPrintWriter(); String path = System.getProperty(PATH_PROP); int count = args.length; if (path == null) { err.println( "ERROR: Must set system property " + PATH_PROP + "\nto the location for compiled .class files." + "\nThis directory must also be on your CLASSPATH."); System.exit(1); } boolean warnOnReflection = System.getProperty(REFLECTION_WARNING_PROP, "false").equals("true"); String uncheckedMathProp = System.getProperty(UNCHECKED_MATH_PROP); Object uncheckedMath = Boolean.FALSE; if ("true".equals(uncheckedMathProp)) uncheckedMath = Boolean.TRUE; else if ("warn-on-boxed".equals(uncheckedMathProp)) uncheckedMath = Keyword.intern("warn-on-boxed"); try { Var.pushThreadBindings( RT.map( compile_path, path, warn_on_reflection, warnOnReflection, unchecked_math, uncheckedMath)); for (String lib : args) { out.write("Compiling " + lib + " to " + path + '\n'); out.flush(); compile.invoke(Symbol.intern(lib)); } } finally { Var.popThreadBindings(); try { out.flush(); } catch (IOException e) { e.printStackTrace(err); } } }
public Object loadPT(IConstructor[] fileRef, String sourcePath, String sourceName) { IConstructor file = fileRef[0]; ISourceLocation loc = TreeAdapter.getLocation(file); int lineNumber = loc.getBeginLine(); Object ret = null; Var.pushThreadBindings( RT.map( LOADER, RT.makeClassLoader(), SOURCE_PATH, sourcePath, SOURCE, sourceName, METHOD, null, LOCAL_ENV, null, LOOP_LOCALS, null, NEXT_LOCAL_NUM, 0, RT.CURRENT_NS, RT.CURRENT_NS.deref(), LINE_BEFORE, lineNumber, LINE_AFTER, lineNumber, RT.UNCHECKED_MATH, RT.UNCHECKED_MATH.deref(), RT.WARN_ON_REFLECTION, RT.WARN_ON_REFLECTION.deref(), RT.DATA_READERS, RT.DATA_READERS.deref())); UPTRLispReader reader = new UPTRLispReader(vf, errors); try { if (TreeAdapter.isAmb(file)) { System.err.println("Amb"); } // File is start[File], so IConstructor file2 = (IConstructor) TreeAdapter.getArgs(file).get(1); IList args = TreeAdapter.getArgs(file2); // Probably only this is the list of forms; don't forget to fix // below. IList forms = TreeAdapter.getArgs((IConstructor) args.get(0)); IListWriter newArgs = vf.listWriter(); for (int i = 0; i < forms.length(); i++) { IConstructor form = (IConstructor) forms.get(i); // only forms, no literals at this level. UPTRLispReader.Pair p = reader.read(form); newArgs.append(p.tree); LINE_AFTER.set(TreeAdapter.getLocation(form).getEndLine()); ret = eval(p.obj, false); LINE_BEFORE.set(TreeAdapter.getLocation(form).getBeginLine()); if (i < forms.length() - 2) { i++; newArgs.append(forms.get(i)); // layout } } // Fix tree file2 = file2.set("args", newArgs.done()); file = file.set( "args", vf.list(TreeAdapter.getArgs(file).get(0), file2, TreeAdapter.getArgs(file).get(2))); } catch (UPTRLispReader.ReaderException e) { throw new CompilerException(sourcePath, e.line, e.getCause()); } finally { Var.popThreadBindings(); } fileRef[0] = file; return ret; }