Summary Files Commits Branches @commit @diff @stats
path: root / src / System.cl
blob: 12f2210c40531749242d2c1970117aeb438de1ca (plain) (blame)
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
-- "Global" constructs

class System inherits IO {
	void: Object <- while false loop 0 pool;

	or(p: Bool, q: Bool) : Bool {
		if p then true
		else
			if q then true
			else false
			fi
		fi
	};

	and(p: Bool, q: Bool) : Bool {
		if p then
			if q then true
			else false
			fi
		else false
		fi
	};

	assert(condition: Bool, method_name: String, error_msg: String) : Object {
		if not condition then
			{
				out_string("\n")
				.out_string("Assertion failed at ")
				.out_string(type_name())
				.out_string(".")
				.out_string(method_name)
				.out_string("(): ")
				.out_string(error_msg)
				.out_string("\n");
				abort();
			}
		else
			void
		fi
	};

	not_implemented(method_name: String) : Object {{
		out_string("\n")
		.out_string("Method ")
		.out_string(type_name())
		.out_string(".")
		.out_string(method_name)
		.out_string("() isn't implemented!")
		.out_string("\n");
		abort();
	}};
	not_implemented_retint(method_name: String) : Int {{
		not_implemented(method_name);
		0;
	}};
	not_implemented_retstr(method_name: String) : String {{
		not_implemented(method_name);
		"";
	}};
};