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 0f35657 was 33a7b6d, checked in by Rob Schluntz <rschlunt@…>, 9 years ago |
|
changed use of formal types to actual types for boxing return parameters and passing type variables, fix bug where generic struct's members would change types when a member is accessed on a concrete instantiation
|
-
Property mode
set to
100644
|
|
File size:
858 bytes
|
| Line | |
|---|
| 1 | //
|
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 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 | // simpleGenericTriple.c --
|
|---|
| 8 | //
|
|---|
| 9 | // Author : Rob Schluntz
|
|---|
| 10 | // Created On : Tue Nov 15 17:24:32 2016
|
|---|
| 11 | // Last Modified By : Rob Schluntz
|
|---|
| 12 | // Last Modified On : Tue Nov 15 17:27:28 2016
|
|---|
| 13 | // Update Count : 3
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | forall(otype T)
|
|---|
| 17 | struct T3 {
|
|---|
| 18 | T f0, f1, f2;
|
|---|
| 19 | };
|
|---|
| 20 |
|
|---|
| 21 | forall(otype T | { T ?+?(T, T); })
|
|---|
| 22 | T3(T) ?+?(T3(T) x, T3(T) y) {
|
|---|
| 23 | T3(T) z = { x.f0+y.f0, x.f1+y.f1, x.f2+y.f2 };
|
|---|
| 24 | return z;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | int main() {
|
|---|
| 28 | int x1 = 123, x3 = 456;
|
|---|
| 29 | double x2 = 999.123;
|
|---|
| 30 | struct T3(int) L = { x1, x2, x3 };
|
|---|
| 31 | struct T3(int) R = { 9, 2, 3 };
|
|---|
| 32 | struct T3(int) ret = L+R;
|
|---|
| 33 | printf("%d %d %d\n", ret.f0, ret.f1, ret.f2);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | // Local Variables: //
|
|---|
| 37 | // tab-width: 4 //
|
|---|
| 38 | // End: //
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.