IProgressMonitor monitor) {
long t0 = System.nanoTime();
long te = 0;
long t1 = 0;
TList passes = null;
DCons pass = null;
int index;
{
if (monitor.isCanceled()) return global;
if (contents.length() == leng && contents.hashCode() == hash) {
return global; // nothing really updated here
}
msgHandler.clearMessages();
final IProgressMonitor myMonitor = monitor;
Lambda cancel = new Fun1<Boolean>() {
public Boolean eval(Object realworld) {
return myMonitor.isCanceled();
}
};
global = TGlobal.upd$sub(global, TSubSt.upd$cancelled(
TGlobal.sub(global),
cancel));
global = TGlobal.upd$sub(global, TSubSt.upd$numErrors(TGlobal.sub(global), 0));
global = TGlobal.upd$sub(global, TSubSt.upd$resErrors(TGlobal.sub(global), 0));
passes = frege.compiler.Main.passes.<TList>forced();
monitor.beginTask(this.getClass().getName() + " parsing",
1 + IListView__lbrack_rbrack.length(passes));
index = 0;
while (!monitor.isCanceled()
&& (pass = passes._Cons()) != null
&& errors(global) == 0
&& index < 2) { // do lexer and parser synchronized
t1 = System.nanoTime();
index++;
passes = pass.mem2.<TList>forced();
final TTuple2 adx = Delayed.<TTuple2>forced( pass.mem1 );
final Lazy action = index == 1 ? Main.lexPassIDE(contents) : Delayed.delayed(adx.mem1);
final String desc = Delayed.<String>forced(adx.mem2);
final TGlobal g = runSTIO(action, global);
te = System.nanoTime();
System.err.println(desc + " took "
+ (te-t1)/1000000 + "ms, cumulative "
+ (te-t0)/1000000 + "ms");
monitor.worked(1);
global = runSTG(Utilities.passDone, g);
}
if (achievement(global) >= achievement(goodglobal))
goodglobal = global; // when opening a file with errors
else {
// update token array in goodglobal
TToken[] toks = TSubSt.toks(TGlobal.sub(global));
goodglobal = TGlobal.upd$sub(goodglobal, TSubSt.upd$toks(
TGlobal.sub(goodglobal), toks));
}
// Array gtoks = TSubSt.toks(TGlobal.sub(global));
// System.err.println("global.toks==good.toks is " + (toks == gtoks));
}
int needed = (int) ((te-t0) / 1000000);
if (scanOnly && timeout - needed > 0 && errors(global) == 0 && !monitor.isCanceled())
try { Thread.sleep(timeout - needed); } catch (InterruptedException e) {}
t0 = System.nanoTime() - (te-t0);
while (!monitor.isCanceled()
&& errors(global) == 0
&& (pass = passes._Cons()) != null) { // do the rest unsynchronized
t1 = System.nanoTime();
passes = pass.mem2.<TList>forced();
index++;
final TTuple2 adx = Delayed.<TTuple2>forced( pass.mem1 );
final Lazy action = Delayed.delayed(adx.mem1);