Warning: session_start(): open(/var/lib/php/sessions/sess_h1at9eilqve2gscdl5uioi4ddg, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
cprint FreezeStackDemo {
transient bool shouldFreeze;
start-thread {
print(myFunc(5));
print(myFunc_v2(5));
set shouldFreeze;
try {
myFunc_v2(5);
} catch FreezeStackException e {
print("Frozen stack:");
pnlStruct(e.stack);
new VStack stack;
stack.pushAll(reversed(e.stack));
stepAll(stack);
print(stack.latestResult);
}
}
S myFunc(int n) {
if (n >= 100) n = 100;
if (n <= 0) ret "base";
ret n + " " + myFunc(n-1);
}
class FreezeStackException extends Exception {
L stack = new L;
void add(VStack.Computable entry) { stack.add(entry); }
}
srecord myFunc_vstack(int n) implements VStack.Computable {
public void step(VStack stack, O subResult) {
if (stack.hasSubResult())
stack._return(n + " " + subResult);
else {
if (n >= 100) n = 100;
if (n <= 0) stack._return("base+");
stack.push(new myFunc_vstack(n-1));
}
}
}
S myFunc_v2(int n) throws FreezeStackException {
try {
if (n >= 100) n = 100;
if (n <= 0) if (shouldFreeze) throw freezeStack(); else ret "base";
ret n + " " + myFunc_v2(n-1);
} on fail FreezeStackException e {
e.add(new myFunc_vstack(n));
}
}
FreezeStackException freezeStack() throws FreezeStackException {
throw new FreezeStackException;
}
}