}
}
}
}
CoverageInterpreter citer = null;
Interpreter iter = null;
if(coverage) {
citer = new CoverageInterpreter();
iter = citer;
} else {
iter = new Interpreter();
}
Runtime r = new Runtime(iter);
try {
r.init();
final IokeObject context = r.ground;
final Message mx = new Message(r, ".", null, true);
mx.setLine(0);
mx.setPosition(0);
final IokeObject message = r.createMessage(mx);
if(debug) {
r.debug = true;
}
if(argError != null) {
final IokeObject condition = IokeObject.as(IokeObject.getCellChain(r.condition,
message,
context,
"Error",
"CommandLine",
"DontUnderstandOption"), null).mimic(message, context);
condition.setCell("message", message);
condition.setCell("context", context);
condition.setCell("receiver", context);
condition.setCell("option", r.newText(argError));
r.errorCondition(condition);
}
if(cwd != null) {
r.setCurrentWorkingDirectory(cwd);
}
((IokeSystem)IokeObject.data(r.system)).setCurrentProgram("-e");
((IokeSystem)IokeObject.data(r.system)).addLoadPath(System.getProperty("ioke.lib", ".") + "/ioke");
((IokeSystem)IokeObject.data(r.system)).addLoadPath("lib/ioke");
for(String ss : loadDirs) {
((IokeSystem)IokeObject.data(r.system)).addLoadPath(ss);
}
for(String script : scripts) {
r.evaluateStream("-e", new StringReader(script), message, context);
}
if(readStdin) {
((IokeSystem)IokeObject.data(r.system)).setCurrentProgram("<stdin>");
r.evaluateStream("<stdin>", new InputStreamReader(System.in, "UTF-8"), message, context);
}
if(args.length > start) {
if(args.length > (start+1)) {
for(int i=start+1,j=args.length; i<j; i++) {
r.addArgument(args[i]);
}
}
String file = args[start];
if(file.startsWith("\"")) {
file = file.substring(1, file.length());
}
if(file.length() > 1 && file.charAt(file.length()-1) == '"') {
file = file.substring(0, file.length()-1);
}
((IokeSystem)IokeObject.data(r.system)).setCurrentProgram(file);
r.evaluateFile(file, message, context);
} else {
if(!readStdin && scripts.size() == 0 && !printedSomething) {
r.evaluateString("use(\"builtin/iik\"). IIk mainLoop", message, context);
}
}
if(coverage) {
citer.stopCovering();
Coverage.processCoverage(r, citer);
}
r.tearDown();
} catch(ControlFlow.Exit e) {
int exitVal = e.getExitValue();
try {
if(coverage) {
citer.stopCovering();
Coverage.processCoverage(r, citer);
}
r.tearDown();
} catch(ControlFlow.Exit e2) {