File: error.bs

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (100 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use core:debug;

void errorOn(Int point, Int now) {
	if (point == now)
		throwError;
}

// Make sure the cleanup runs properly at various points in the function.
void basicException(Int point) {
	errorOn(point, 1);
	DbgVal a(5);
	{
		errorOn(point, 2);
		Dbg d(20);
		errorOn(point, 3);
		DbgVal v(10);
		errorOn(point, 4);
	}
	errorOn(point, 5);
	{
		DbgVal v(6);
		errorOn(point, 6);
	}
	errorOn(point, 7);
}

// How do we do with exceptions in other functions.
void fnException(Int point) {
	errorOn(point, 1);
	DbgVal r = dbgValFn(DbgVal(1), point);
	errorOn(point, 3);
}

DbgVal dbgValFn(DbgVal v, Int point) {
	errorOn(point, 2);
	v.set(3);
	v;
}

// How do we do with exceptions combined with thread switches?
void threadException(Int point) {
	errorOn(point, 1);
	DbgVal r = otherThreadError(DbgVal(1), point);
	errorOn(point, 4);
}

// Thread function for another thread.
DbgVal otherThreadError(DbgVal p, Int point) on Other {
	errorOn(point, 2);
	p.set(2);
	errorOn(point, 3);
	p;
}

// Throw an error during construction.
value ErrorAt {
	init(Int point, Int at) {
		init() {}
		errorOn(point, at);
	}
}

value ErrorBase {
	// Some members to initialize and keep track of. Try to initialize e1, v1, e2, but this order
	// is not neccessarily the initialization order chosen by Storm.
	ErrorAt e1;
	DbgVal v1;
	ErrorAt e2;

	init(Int point) {
		errorOn(point, 2);
		init() {
			e1(point, 3);
			v1(10);
			e2(point, 4);
		}
		errorOn(point, 5);
	}
}

value ErrorTest extends ErrorBase {
	// Some members.
	ErrorAt e4;
	DbgVal v2;
	ErrorAt e5;

	init(Int point) {
		errorOn(point, 1); // Error before initialization of super class.
		init(point) {
			e4(point, 6);
			v2(20);
			e5(point, 7);
		}
		errorOn(point, 8);
	}
}

void ctorError(Int point) {
	ErrorTest e(point);
}