source: tests/simpleGenericTriple.cfa @ 6cb7a92

arm-ehjacob/cs343-translationnew-ast-unique-expr
Last change on this file since 6cb7a92 was fd54fef, checked in by Michael Brooks <mlbrooks@…>, 9 months ago

Converting the project to use the new syntax for otype, dtype and ttytpe.

Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.

  • Property mode set to 100644
File size: 1.0 KB
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
16forall(T)
17struct T3 {
18        T f0, f1, f2;
19};
20
21forall(T | { T ?+?(T, T); })
22T3(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
27int main() {
28  int x1 = 123, x3 = 456;
29  double x2 = 999.123;
30  struct T3(int) Li = { x1, (int)x2, x3 };
31  struct T3(int) Ri = { 9, 2, 3 };
32  struct T3(int) reti = Li+Ri;
33  printf("%d %d %d\n", reti.f0, reti.f1, reti.f2);
34
35  struct T3(double) Ld = { x1, x2, x3 };
36  struct T3(double) Rd = { 9, 2, 3 };
37  struct T3(double) retd = Ld+Rd;
38  printf("%g %g %g\n", retd.f0, retd.f1, retd.f2);
39}
40
41// Local Variables: //
42// tab-width: 4 //
43// End: //
Note: See TracBrowser for help on using the repository browser.