Last change
on this file since 389fbf5 was fd54fef, checked in by Michael Brooks <mlbrooks@…>, 5 years 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:
478 bytes
|
Rev | Line | |
---|
[73abe95] | 1 | #include <fstream.hfa>
|
---|
[4328016] | 2 |
|
---|
| 3 | // [unsigned, unsigned] offset_to_index(unsigned offset, unsigned sx, unsigned sy)
|
---|
| 4 | // {
|
---|
| 5 | // return [offset / sx, offset % sy];
|
---|
| 6 | // }
|
---|
| 7 |
|
---|
[fd54fef] | 8 | forall(index_t)
|
---|
[200fcb3] | 9 | index_t offset_to_index(unsigned offset, index_t size) {
|
---|
[4328016] | 10 | return [offset / size.0, offset % size.1];
|
---|
| 11 | }
|
---|
| 12 |
|
---|
[200fcb3] | 13 | int main(int argc, char* argv[]) {
|
---|
[4328016] | 14 | unsigned x = 0, y = 0, i = 0;
|
---|
| 15 | unsigned sx = 4, sy = 4;
|
---|
| 16 |
|
---|
| 17 | i = 6;
|
---|
| 18 | [x, y] = offset_to_index(6, [sx, sy]);
|
---|
| 19 |
|
---|
[200fcb3] | 20 | sout | x | ' ' | y;
|
---|
[4328016] | 21 |
|
---|
| 22 | return 0;
|
---|
| 23 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.