[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 |
---|
[58daf53] | 10 | // Created On : Wed May 24 14:45:00 2017 |
---|
[6b0b624] | 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Sat Jul 22 10:00:44 2017 |
---|
| 13 | // Update Count : 3 |
---|
[79308c8e] | 14 | // |
---|
| 15 | |
---|
[6b0b624] | 16 | #pragma once |
---|
[79308c8e] | 17 | |
---|
[64fc0ba] | 18 | #include <stdbool.h> |
---|
[79308c8e] | 19 | |
---|
| 20 | // DO NOT USE DIRECTLY! |
---|
[fd54fef] | 21 | forall(T, E) |
---|
[64fc0ba] | 22 | union inner_result{ |
---|
| 23 | T value; |
---|
| 24 | E error; |
---|
| 25 | }; |
---|
| 26 | |
---|
[fd54fef] | 27 | forall(T, E) |
---|
[79308c8e] | 28 | struct result { |
---|
[64fc0ba] | 29 | bool has_value; |
---|
[b1672e1] | 30 | inline union inner_result(T, E); |
---|
[79308c8e] | 31 | }; |
---|
| 32 | |
---|
| 33 | |
---|
[fd54fef] | 34 | forall(T, E) |
---|
[242a902] | 35 | void ?{}(result(T, E) & this); |
---|
[79308c8e] | 36 | |
---|
[fd54fef] | 37 | forall(T, E) |
---|
[242a902] | 38 | void ?{}(result(T, E) & this, one_t, T value); |
---|
[79308c8e] | 39 | |
---|
[fd54fef] | 40 | forall(T, E) |
---|
[242a902] | 41 | void ?{}(result(T, E) & this, zero_t, E error); |
---|
[79308c8e] | 42 | |
---|
[fd54fef] | 43 | forall(T, E) |
---|
[242a902] | 44 | void ?{}(result(T, E) & this, result(T, E) other); |
---|
[79308c8e] | 45 | |
---|
[fd54fef] | 46 | forall(T, E) |
---|
[242a902] | 47 | void ^?{}(result(T, E) & this); |
---|
[79308c8e] | 48 | |
---|
[fd54fef] | 49 | forall(T, E) |
---|
[242a902] | 50 | result(T, E) ?=?(result(T, E) & this, result(T, E) other); |
---|
[58daf53] | 51 | |
---|
[fd54fef] | 52 | forall(T, E) |
---|
[64fc0ba] | 53 | bool ?!=?(result(T, E) this, zero_t); |
---|
[79308c8e] | 54 | |
---|
[20877d2] | 55 | /* Wating for bug#11 to be fixed. |
---|
[fd54fef] | 56 | forall(T, E) |
---|
[79308c8e] | 57 | result(T, E) result_value(T value); |
---|
| 58 | |
---|
[fd54fef] | 59 | forall(T, E) |
---|
[79308c8e] | 60 | result(T, E) result_error(E error); |
---|
[20877d2] | 61 | */ |
---|
[79308c8e] | 62 | |
---|
[fd54fef] | 63 | forall(T, E) |
---|
[64fc0ba] | 64 | bool has_value(result(T, E) * this); |
---|
[79308c8e] | 65 | |
---|
[fd54fef] | 66 | forall(T, E) |
---|
[79308c8e] | 67 | T get(result(T, E) * this); |
---|
| 68 | |
---|
[fd54fef] | 69 | forall(T, E) |
---|
[79308c8e] | 70 | E get_error(result(T, E) * this); |
---|
| 71 | |
---|
[fd54fef] | 72 | forall(T, E) |
---|
[58daf53] | 73 | void set(result(T, E) * this, T value); |
---|
| 74 | |
---|
[fd54fef] | 75 | forall(T, E) |
---|
[58daf53] | 76 | void set_error(result(T, E) * this, E error); |
---|
| 77 | |
---|
[6b0b624] | 78 | // Local Variables: // |
---|
| 79 | // mode: c // |
---|
| 80 | // tab-width: 4 // |
---|
| 81 | // End: // |
---|