ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
with_gc
Last change
on this file since 84d58c5 was 64fc0ba, checked in by Thierry Delisle <tdelisle@…>, 8 years ago |
Added maybe and result to libcfa makefiles and made some minor fixes
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[79308c8e] | 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 |
|
---|
[64fc0ba] | 20 | #include <stdbool.h>
|
---|
[79308c8e] | 21 |
|
---|
| 22 | // DO NOT USE DIRECTLY!
|
---|
[64fc0ba] | 23 | forall(otype T, otype E)
|
---|
| 24 | union inner_result{
|
---|
| 25 | T value;
|
---|
| 26 | E error;
|
---|
| 27 | };
|
---|
| 28 |
|
---|
[79308c8e] | 29 | forall(otype T, otype E)
|
---|
| 30 | struct result {
|
---|
[64fc0ba] | 31 | bool has_value;
|
---|
| 32 | inner_result(T, E);
|
---|
[79308c8e] | 33 | };
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | forall(otype T, otype E)
|
---|
| 37 | void ?{}(result(T, E) * this);
|
---|
| 38 |
|
---|
| 39 | forall(otype T, otype E)
|
---|
| 40 | void ?{}(result(T, E) * this, one_t, T value);
|
---|
| 41 |
|
---|
| 42 | forall(otype T, otype E)
|
---|
| 43 | void ?{}(result(T, E) * this, zero_t, E error);
|
---|
| 44 |
|
---|
| 45 | forall(otype T, otype E)
|
---|
| 46 | void ?{}(result(T, E) * this, result(T, E) other);
|
---|
| 47 |
|
---|
| 48 | forall(otype T, otype E)
|
---|
| 49 | void ^?{}(result(T, E) * this);
|
---|
| 50 |
|
---|
| 51 | forall(otype T, otype E)
|
---|
[64fc0ba] | 52 | bool ?!=?(result(T, E) this, zero_t);
|
---|
[79308c8e] | 53 |
|
---|
| 54 | forall(otype T, otype E)
|
---|
| 55 | result(T, E) result_value(T value);
|
---|
| 56 |
|
---|
| 57 | forall(otype T, otype E)
|
---|
| 58 | result(T, E) result_error(E error);
|
---|
| 59 |
|
---|
| 60 | forall(otype T, otype E)
|
---|
[64fc0ba] | 61 | bool has_value(result(T, E) * this);
|
---|
[79308c8e] | 62 |
|
---|
| 63 | forall(otype T, otype E)
|
---|
| 64 | T get(result(T, E) * this);
|
---|
| 65 |
|
---|
| 66 | forall(otype T, otype E)
|
---|
| 67 | E get_error(result(T, E) * this);
|
---|
| 68 |
|
---|
| 69 | #endif // RESULT_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.