ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since d997f8e was
79308c8e,
checked in by Andrew Beach <ajbeach@…>, 7 years ago
|
First draft of maybe and result.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // result -- Contains the expected value or an error value. |
---|
8 | // |
---|
9 | // Author : Andrew Beach |
---|
10 | // Created On : Wed May 25 14:45:00 2017 |
---|
11 | // Last Modified By : Andrew Beach |
---|
12 | // Last Modified On : Wed May 25 16:57:00 2017 |
---|
13 | // Update Count : 1 |
---|
14 | // |
---|
15 | |
---|
16 | |
---|
17 | #ifndef RESULT_H |
---|
18 | #define RESULT_H |
---|
19 | |
---|
20 | |
---|
21 | // DO NOT USE DIRECTLY! |
---|
22 | forall(otype T, otype E) |
---|
23 | struct result { |
---|
24 | _Bool has_value; |
---|
25 | union { |
---|
26 | T value; |
---|
27 | E error; |
---|
28 | }; |
---|
29 | }; |
---|
30 | |
---|
31 | |
---|
32 | forall(otype T, otype E) |
---|
33 | void ?{}(result(T, E) * this); |
---|
34 | |
---|
35 | forall(otype T, otype E) |
---|
36 | void ?{}(result(T, E) * this, one_t, T value); |
---|
37 | |
---|
38 | forall(otype T, otype E) |
---|
39 | void ?{}(result(T, E) * this, zero_t, E error); |
---|
40 | |
---|
41 | forall(otype T, otype E) |
---|
42 | void ?{}(result(T, E) * this, result(T, E) other); |
---|
43 | |
---|
44 | forall(otype T, otype E) |
---|
45 | void ^?{}(result(T, E) * this); |
---|
46 | |
---|
47 | forall(otype T, otype E) |
---|
48 | _Bool ?!=?(result(T, E) this, zero_t); |
---|
49 | |
---|
50 | forall(otype T, otype E) |
---|
51 | result(T, E) result_value(T value); |
---|
52 | |
---|
53 | forall(otype T, otype E) |
---|
54 | result(T, E) result_error(E error); |
---|
55 | |
---|
56 | forall(otype T, otype E) |
---|
57 | _Bool has_value(result(T, E) * this); |
---|
58 | |
---|
59 | forall(otype T, otype E) |
---|
60 | T get(result(T, E) * this); |
---|
61 | |
---|
62 | forall(otype T, otype E) |
---|
63 | E get_error(result(T, E) * this); |
---|
64 | |
---|
65 | #endif // RESULT_H |
---|
Note: See
TracBrowser
for help on using the repository browser.