01: /*
02: * CancelableContext.java
03: *
04: * Created on 2006/03/08, 0:51
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package pnuts.tools;
11:
12: import java.util.Properties;
13: import pnuts.compiler.CompilerPnutsImpl;
14: import pnuts.lang.Context;
15: import pnuts.lang.Implementation;
16: import pnuts.lang.Jump;
17: import pnuts.lang.PnutsImpl;
18:
19: /**
20: *
21: * @author tomatsu
22: */
23: class CancelableContext extends Context {
24: private boolean canceled;
25:
26: public void cancel() {
27: this .canceled = true;
28: }
29:
30: CancelableContext() {
31: Implementation impl = getImplementation();
32: if (impl instanceof CompilerPnutsImpl) {
33: ((PnutsImpl) impl).setProperty("pnuts.compiler.traceMode",
34: "true");
35: }
36: }
37:
38: CancelableContext(Context context) {
39: super (context);
40: }
41:
42: CancelableContext(Properties properties) {
43: super (properties);
44: Implementation impl = getImplementation();
45: if (impl instanceof CompilerPnutsImpl) {
46: ((PnutsImpl) impl).setProperty("pnuts.compiler.traceMode",
47: "true");
48: }
49: }
50:
51: protected void updateLine(int line) {
52: if (canceled) {
53: throw new Jump(null);
54: }
55: super.updateLine(line);
56: }
57: }
|