emfrp 0.1.1 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +20 -0
  3. data/Gemfile +0 -2
  4. data/README.md +45 -12
  5. data/bin/emfrp +4 -1
  6. data/examples/LCDClock/LCDClock.c +580 -0
  7. data/examples/LCDClock/LCDClock.h +6 -0
  8. data/examples/LCDClock/LCDClock.mfrp +93 -0
  9. data/examples/LCDClock/LCDClockMain.c +42 -0
  10. data/examples/LCDClock/LCDClock_LPC1768.bin +0 -0
  11. data/examples/LCDClock/README.md +24 -0
  12. data/examples/LCDClock/graph.dot +55 -0
  13. data/examples/LCDClock/graph.png +0 -0
  14. data/examples/LCDPositioner/LCDPositioner.mfrp +30 -30
  15. data/examples/LCDPositioner/LCDPositionerMain.c +15 -15
  16. data/examples/MostDistantPoint/MostDistantPoint.mfrp +25 -25
  17. data/examples/MostDistantPoint/MostDistantPointMain.c +14 -14
  18. data/lib/emfrp/compile/c/alloc.rb +200 -200
  19. data/lib/emfrp/compile/c/codegen.rb +18 -18
  20. data/lib/emfrp/compile/c/codegen_context.rb +218 -218
  21. data/lib/emfrp/compile/c/monofy.rb +187 -185
  22. data/lib/emfrp/compile/c/syntax_codegen.rb +365 -364
  23. data/lib/emfrp/compile/c/syntax_exp_codegen.rb +121 -119
  24. data/lib/emfrp/compile/graphviz/graphviz.rb +53 -53
  25. data/lib/emfrp/compile_error.rb +95 -95
  26. data/lib/emfrp/interpreter/command_manager.rb +367 -367
  27. data/lib/emfrp/interpreter/evaluater.rb +146 -146
  28. data/lib/emfrp/interpreter/file_loader.rb +52 -52
  29. data/lib/emfrp/interpreter/interpreter.rb +200 -195
  30. data/lib/emfrp/parser/expression.rb +386 -386
  31. data/lib/emfrp/parser/misc.rb +184 -184
  32. data/lib/emfrp/parser/newnode_convert.rb +72 -72
  33. data/lib/emfrp/parser/operator.rb +25 -25
  34. data/lib/emfrp/parser/parser.rb +150 -150
  35. data/lib/emfrp/parser/parsing_error.rb +49 -49
  36. data/lib/emfrp/parser/toplevel.rb +555 -555
  37. data/lib/emfrp/pre_convert/pre_convert.rb +32 -32
  38. data/lib/emfrp/syntax.rb +171 -171
  39. data/lib/emfrp/typing/typing_error.rb +47 -47
  40. data/lib/emfrp/typing/union_type.rb +197 -197
  41. data/lib/emfrp/version.rb +1 -1
  42. data/mfrp_include/Std.mfrp +122 -122
  43. data/tests/Rakefile +8 -8
  44. data/tests/Rakefile.common +27 -27
  45. data/tests/command/Rakefile +2 -2
  46. data/tests/command/ReplaceNode.mfrp +39 -39
  47. data/tests/compiler/AtlastDependency/AtlastDependency.mfrp +7 -0
  48. data/tests/compiler/AtlastDependency/AtlastDependencyMain.c +19 -0
  49. data/tests/compiler/AtlastDependency/Rakefile +2 -0
  50. data/tests/compiler/AtlastDependency/actual_out.txt +10 -0
  51. data/tests/compiler/AtlastDependency/expected_out.txt +10 -0
  52. data/tests/compiler/AtlastDependency/in.txt +0 -0
  53. data/tests/compiler/ComplexDataType/ComplexDataType.mfrp +14 -14
  54. data/tests/compiler/ComplexDataType/ComplexDataTypeMain.c +15 -15
  55. data/tests/compiler/ComplexDataType/Rakefile +2 -2
  56. data/tests/compiler/ComplexDataType/expected_out.txt +0 -0
  57. data/tests/compiler/ComplexDataType/in.txt +5 -5
  58. data/tests/compiler/GCLifeTime/GCLifeTime.mfrp +13 -0
  59. data/tests/compiler/GCLifeTime/GCLifeTimeMain.c +17 -0
  60. data/tests/compiler/GCLifeTime/Rakefile +2 -0
  61. data/tests/compiler/GCLifeTime/actual_out.txt +10 -0
  62. data/tests/compiler/GCLifeTime/expected_out.txt +10 -0
  63. data/tests/compiler/GCLifeTime/in.txt +10 -0
  64. data/tests/compiler/LCDClock/LCDClock.mfrp +90 -0
  65. data/tests/compiler/LCDClock/LCDClockMain.c +26 -0
  66. data/tests/compiler/LCDClock/Rakefile +2 -0
  67. data/tests/compiler/LCDClock/actual_out.txt +60 -0
  68. data/tests/compiler/LCDClock/expected_out.txt +60 -0
  69. data/tests/compiler/LCDClock/in.txt +60 -0
  70. data/tests/compiler/LCDPositioner/LCDPositioner.mfrp +30 -30
  71. data/tests/compiler/LCDPositioner/LCDPositionerMain.c +15 -15
  72. data/tests/compiler/LCDPositioner/Rakefile +2 -2
  73. data/tests/compiler/LCDPositioner/graph.dot +0 -0
  74. data/tests/compiler/LCDPositioner/graph.png +0 -0
  75. data/tests/compiler/NestedMatch/NestedMatch.mfrp +29 -0
  76. data/tests/compiler/NestedMatch/NestedMatchMain.c +20 -0
  77. data/tests/compiler/NestedMatch/Rakefile +2 -0
  78. data/tests/compiler/NestedMatch/actual_out.txt +10 -0
  79. data/tests/compiler/NestedMatch/expected_out.txt +10 -0
  80. data/tests/compiler/NestedMatch/in.txt +10 -0
  81. data/tests/compiler/Rakefile +8 -8
  82. data/tests/compiler/Rakefile.common +23 -23
  83. data/tests/compiler/SubModuleInit/Delay2.mfrp +7 -0
  84. data/tests/compiler/SubModuleInit/Rakefile +2 -0
  85. data/tests/compiler/SubModuleInit/SubModuleInit.mfrp +7 -0
  86. data/tests/compiler/SubModuleInit/SubModuleInitMain.c +17 -0
  87. data/tests/compiler/SubModuleInit/actual_out.txt +10 -0
  88. data/tests/compiler/SubModuleInit/expected_out.txt +10 -0
  89. data/tests/compiler/SubModuleInit/in.txt +10 -0
  90. data/tests/compiler/UseData/Rakefile +2 -2
  91. data/tests/compiler/UseData/UseData.mfrp +8 -8
  92. data/tests/compiler/UseSubModule/Rakefile +2 -2
  93. data/tests/compiler/UseSubModule/SubModule.mfrp +8 -8
  94. data/tests/compiler/UseSubModule/SubModule2.mfrp +5 -5
  95. data/tests/compiler/UseSubModule/UseSubModule.mfrp +11 -11
  96. data/tests/core/FromAnnotation.mfrp +18 -18
  97. data/tests/core/Last.mfrp +10 -10
  98. data/tests/core/Rakefile +2 -2
  99. data/tests/core/TypingTest.mfrp +11 -11
  100. data/tests/core/WithoutInputs.mfrp +19 -19
  101. data/tests/load_time_error/Rakefile +32 -32
  102. data/tests/load_time_error/TypeMismatch.mfrp +4 -4
  103. metadata +43 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 61e335460dfc357d7b07dcffb638789a93033478
4
- data.tar.gz: a8c3b82e4f36de3062ed97f3535cb6a1c5b32cbc
2
+ SHA256:
3
+ metadata.gz: 3bb6e058adc6864bf467bc7729cd9001270ce9ff8883a7edd40e9a188b9f9cf4
4
+ data.tar.gz: 467b05af26c0ec4f95a7110262dc1c5838a99d58200e431708fd3debca94109a
5
5
  SHA512:
6
- metadata.gz: 106c4bdd43fd5fea6f6f8fc800e25ce1f8b50c34bcec336a0a006bb3517d6c55d94152a530e81e03deb66095927622e1523b5235f6e059c9d5567434d3ba08e0
7
- data.tar.gz: 8791d44c0b27d9097f583b803c39ff7f54abc2334ed3227ed07b17fb79eb1ba6a653d9d770d2f455de9ad0c5c260b51cb02a52ef8cfab1b8ed3106b908308912
6
+ metadata.gz: 868bfed528dcc35241bfb1ea80233621bfc96e439a18f064f987cbeebca8fcb44511408c4b0b687874fac88fc1d88364187e4310c7d2d15a1d5d24dba2c6fd99
7
+ data.tar.gz: dfab0b1629d14506003314213632ac46c90b156ec9b3388b32fd22cfd61f7d5929e9c0bcf68f76ca9c5898db2d5820a8701b6ad8a35623c3c814f6c12050815e
@@ -0,0 +1,20 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ bundle install --jobs 4 --retry 3
19
+ cd tests && bundle exec rake
20
+
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in emfrp.gemspec
4
4
  gemspec
5
- colorize
6
- parser_combinator
data/README.md CHANGED
@@ -1,28 +1,61 @@
1
1
  # Emfrp
2
2
 
3
- Pure Functional Programming with your microcomputer.
3
+ Pure Functional Reactive Programming Language for Small-Scale Embedded Systems
4
4
 
5
- # Requirement
5
+ ## Installation
6
6
 
7
- * Ruby2.0 or later (and it's Gem client)
7
+ Requirement
8
+ * Ruby 2.0 or later (and it's Gem client)
9
+ * C (or C++) compiler for your favorite target platform
8
10
 
9
- ## Installation
10
- You can get executables via RubyGems.
11
- ```sh
11
+ ### via RubyGems
12
+
13
+ Just type the following command.
14
+ ```
12
15
  $ gem install emfrp
13
16
  ```
17
+ You are all set. Enjoy!
14
18
 
15
- # Command-line-interpreter (REPL)
19
+ ### from Source
20
+
21
+ Install `Bundler` if it is not installed.
16
22
  ```sh
17
- $ emfrpi
23
+ $ gem install bundler
18
24
  ```
19
25
 
20
- # Compiler
26
+ Clone this repository and install from the cloned source as follows.
21
27
  ```sh
22
- $ emfrp <src-file>
28
+ $ cd emfrp
29
+ $ rake install
23
30
  ```
24
31
 
32
+ ***NOTE***
33
+ Some environments require that you need to be an administrator to perform `gem install` or `rake install`.
34
+
25
35
  ## Usage
36
+ Command-line-interpreter (REPL)
37
+ ```sh
38
+ $ emfrpi
39
+ ```
40
+
41
+ Compiler
42
+ ```sh
43
+ $ emfrp [options] <src-file>
44
+ ```
45
+
46
+ Options
47
+ * `--nomain`
48
+ does not generate _main_ file
49
+ * `--cpp`
50
+ generates `.cpp` instead of `.c`
51
+
52
+ See the wiki of this repository for details.
53
+
54
+ ## Sample Code
55
+
56
+ * [emfrp_samples](https://github.com/psg-titech/emfrp_samples)
57
+
26
58
 
27
- Here is a (temporary) easy introduction:
28
- https://github.com/sawaken/emfrp/wiki
59
+ ## History
60
+ Originally developed by [Kensuke Sawada](https://github.com/sawaken)
61
+ * [Paper](http://www.psg.c.titech.ac.jp/posts/2016-03-15-CROW2016.html)
data/bin/emfrp CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
 
4
+ require 'optparse'
4
5
  require 'emfrp'
5
6
 
7
+ opts = ARGV.getopts("", "cpp", "nomain")
8
+
6
9
  unless ARGV[0]
7
10
  puts "usage: emfrp <emfrp-module-file-path>"
8
11
  exit(1)
@@ -10,7 +13,7 @@ end
10
13
 
11
14
  begin
12
15
  inter = Emfrp::Interpreter.new(Emfrp::IncludeDirs, STDOUT, ARGV[0])
13
- if inter.compile_default()
16
+ if inter.compile_default(opts["cpp"], !opts["nomain"])
14
17
  exit(1)
15
18
  end
16
19
  rescue Emfrp::Interpreter::InterpreterError
@@ -0,0 +1,580 @@
1
+ #include "LCDClock.h"
2
+ /* Primitive functions (Macros) */
3
+ #define _anpersand_anpersand(a, b) (a && b)
4
+ #define _eq__eq_(a, b) (a == b)
5
+ #define _exclamation__eq_(a, b) (a != b)
6
+ #define _parcent_(a, b) (a % b)
7
+ #define _plus_(a, b) (a + b)
8
+ #define _lt_(a, b) (a < b)
9
+ #define _slash_(a, b) (a / b)
10
+ #define _at__exclamation_(a) (!a)
11
+ /* Data types */
12
+ struct Time{
13
+ int mark;
14
+ union {
15
+ struct {
16
+ int member0;
17
+ int member1;
18
+ int member2;
19
+ }Time;
20
+ }value;
21
+ };
22
+ struct Tuple3_Int_Int_Int{
23
+ int mark;
24
+ union {
25
+ struct {
26
+ int member0;
27
+ int member1;
28
+ int member2;
29
+ }Tuple3;
30
+ }value;
31
+ };
32
+ struct Tuple3_Bool_Bool_Bool{
33
+ int mark;
34
+ union {
35
+ struct {
36
+ int member0;
37
+ int member1;
38
+ int member2;
39
+ }Tuple3;
40
+ }value;
41
+ };
42
+ /* Global variables */
43
+ int node_memory_btnMode[2];
44
+ int node_memory_btnNext[2];
45
+ int node_memory_btnRotate[2];
46
+ int node_memory_pulse100ms[2];
47
+ int node_memory_counter[2];
48
+ int node_memory_curMode[2];
49
+ int node_memory_curPos[2];
50
+ int node_memory_pulse1s[2];
51
+ int node_memory_flash[2];
52
+ struct Tuple3_Int_Int_Int* node_memory_anonymous69880537178160[2];
53
+ struct Tuple3_Bool_Bool_Bool* node_memory_anonymous69880541228320[2];
54
+ int node_memory_dh[2];
55
+ int node_memory_dm[2];
56
+ int node_memory_ds[2];
57
+ int node_memory_maskHour[2];
58
+ int node_memory_maskMin[2];
59
+ int node_memory_maskSec[2];
60
+ struct Time* node_memory_curTime[2];
61
+ int node_memory_hour[2];
62
+ int node_memory_min[2];
63
+ int node_memory_sec[2];
64
+ struct Time memory_Time[3];
65
+ int size_Time = 3;
66
+ int counter_Time = 0;
67
+ struct Tuple3_Int_Int_Int memory_Tuple3_Int_Int_Int[1];
68
+ int size_Tuple3_Int_Int_Int = 1;
69
+ int counter_Tuple3_Int_Int_Int = 0;
70
+ struct Tuple3_Bool_Bool_Bool memory_Tuple3_Bool_Bool_Bool[1];
71
+ int size_Tuple3_Bool_Bool_Bool = 1;
72
+ int counter_Tuple3_Bool_Bool_Bool = 0;
73
+ int Counter = 1;
74
+ int NodeSize = 17;
75
+ /* Static prototypes */
76
+ static struct Time* Time_0(int, int, int);
77
+ static void mark_Time(struct Time*, int);
78
+ static struct Tuple3_Int_Int_Int* Tuple3_0(int, int, int);
79
+ static void mark_Tuple3_Int_Int_Int(struct Tuple3_Int_Int_Int*, int);
80
+ static struct Tuple3_Bool_Bool_Bool* Tuple3_1(int, int, int);
81
+ static void mark_Tuple3_Bool_Bool_Bool(struct Tuple3_Bool_Bool_Bool*, int);
82
+ static int init_btnMode();
83
+ static int init_btnNext();
84
+ static int init_btnRotate();
85
+ static int node_counter(int, int, int*);
86
+ static int init_counter();
87
+ static int node_curMode(int, int, int, int*);
88
+ static int init_curMode();
89
+ static int node_curPos(int, int, int, int*);
90
+ static int init_curPos();
91
+ static int node_pulse1s(int, int, int*);
92
+ static int node_flash(int, int*);
93
+ static int node_anonymous69880537178160(int, int, int, int, struct Tuple3_Int_Int_Int**);
94
+ static int node_anonymous69880541228320(int, int, int, struct Tuple3_Bool_Bool_Bool**);
95
+ static int node_dh(struct Tuple3_Int_Int_Int*, int*);
96
+ static int node_dm(struct Tuple3_Int_Int_Int*, int*);
97
+ static int node_ds(struct Tuple3_Int_Int_Int*, int*);
98
+ static int node_maskHour(struct Tuple3_Bool_Bool_Bool*, int*);
99
+ static int node_maskMin(struct Tuple3_Bool_Bool_Bool*, int*);
100
+ static int node_maskSec(struct Tuple3_Bool_Bool_Bool*, int*);
101
+ static int node_curTime(int, struct Time*, int, int, int, struct Time**);
102
+ static struct Time* init_curTime();
103
+ static int node_hour(struct Time*, int*);
104
+ static int init_hour();
105
+ static int node_min(struct Time*, int*);
106
+ static int init_min();
107
+ static int node_sec(struct Time*, int*);
108
+ static int init_sec();
109
+ static struct Time* roundingTime_0(struct Time*, int, int, int);
110
+ static struct Time* proceedTime_0(struct Time*);
111
+ static int editable_0(int);
112
+ static int positiveEdge_0(int, int);
113
+ static int nextMode_0(int);
114
+ static int nextPos_0(int);
115
+ static void refreshMark();
116
+ extern void Input(int*, int*, int*, int*);
117
+ extern void Output(int*, int*, int*, int*, int*, int*);
118
+ /* Functions, Constructors, GCMarkers, etc... */
119
+ static struct Time* Time_0(int member0, int member1, int member2) {
120
+ struct Time* x;
121
+ while (1) {
122
+ counter_Time++;
123
+ counter_Time %= size_Time;
124
+ if (memory_Time[counter_Time].mark < Counter) { x = memory_Time + counter_Time; break; }
125
+ }
126
+ x->value.Time.member0 = member0;
127
+ x->value.Time.member1 = member1;
128
+ x->value.Time.member2 = member2;
129
+ return x;
130
+ }
131
+ static void mark_Time(struct Time* x, int mark) {
132
+ x->mark = mark;
133
+ }
134
+ static struct Tuple3_Int_Int_Int* Tuple3_0(int member0, int member1, int member2) {
135
+ struct Tuple3_Int_Int_Int* x;
136
+ while (1) {
137
+ counter_Tuple3_Int_Int_Int++;
138
+ counter_Tuple3_Int_Int_Int %= size_Tuple3_Int_Int_Int;
139
+ if (memory_Tuple3_Int_Int_Int[counter_Tuple3_Int_Int_Int].mark < Counter) { x = memory_Tuple3_Int_Int_Int + counter_Tuple3_Int_Int_Int; break; }
140
+ }
141
+ x->value.Tuple3.member0 = member0;
142
+ x->value.Tuple3.member1 = member1;
143
+ x->value.Tuple3.member2 = member2;
144
+ return x;
145
+ }
146
+ static void mark_Tuple3_Int_Int_Int(struct Tuple3_Int_Int_Int* x, int mark) {
147
+ x->mark = mark;
148
+ }
149
+ static struct Tuple3_Bool_Bool_Bool* Tuple3_1(int member0, int member1, int member2) {
150
+ struct Tuple3_Bool_Bool_Bool* x;
151
+ while (1) {
152
+ counter_Tuple3_Bool_Bool_Bool++;
153
+ counter_Tuple3_Bool_Bool_Bool %= size_Tuple3_Bool_Bool_Bool;
154
+ if (memory_Tuple3_Bool_Bool_Bool[counter_Tuple3_Bool_Bool_Bool].mark < Counter) { x = memory_Tuple3_Bool_Bool_Bool + counter_Tuple3_Bool_Bool_Bool; break; }
155
+ }
156
+ x->value.Tuple3.member0 = member0;
157
+ x->value.Tuple3.member1 = member1;
158
+ x->value.Tuple3.member2 = member2;
159
+ return x;
160
+ }
161
+ static void mark_Tuple3_Bool_Bool_Bool(struct Tuple3_Bool_Bool_Bool* x, int mark) {
162
+ x->mark = mark;
163
+ }
164
+ static int init_btnMode() {
165
+ return 0;
166
+ }
167
+ static int init_btnNext() {
168
+ return 0;
169
+ }
170
+ static int init_btnRotate() {
171
+ return 0;
172
+ }
173
+ static int node_counter(int pulse100ms, int counter_at_last, int* output) {
174
+ int _tmp000;
175
+ if (pulse100ms == 1) {
176
+ _tmp000 = _plus_(counter_at_last, 1);
177
+ }
178
+ else if (pulse100ms == 0) {
179
+ _tmp000 = counter_at_last;
180
+ }
181
+ *output = _parcent_(_tmp000, 10);
182
+ return 1;
183
+ }
184
+ static int init_counter() {
185
+ return 0;
186
+ }
187
+ static int node_curMode(int btnMode_at_last, int btnMode, int curMode_at_last, int* output) {
188
+ int _tmp002;
189
+ int _tmp001;
190
+ _tmp002 = positiveEdge_0(btnMode_at_last, btnMode);
191
+ if (_tmp002 == 1) {
192
+ _tmp001 = nextMode_0(curMode_at_last);
193
+ }
194
+ else if (_tmp002 == 0) {
195
+ _tmp001 = curMode_at_last;
196
+ }
197
+ *output = _tmp001;
198
+ return 1;
199
+ }
200
+ static int init_curMode() {
201
+ return 0;
202
+ }
203
+ static int node_curPos(int btnNext_at_last, int btnNext, int curPos_at_last, int* output) {
204
+ int _tmp004;
205
+ int _tmp003;
206
+ _tmp004 = positiveEdge_0(btnNext_at_last, btnNext);
207
+ if (_tmp004 == 1) {
208
+ _tmp003 = nextPos_0(curPos_at_last);
209
+ }
210
+ else if (_tmp004 == 0) {
211
+ _tmp003 = curPos_at_last;
212
+ }
213
+ *output = _tmp003;
214
+ return 1;
215
+ }
216
+ static int init_curPos() {
217
+ return 0;
218
+ }
219
+ static int node_pulse1s(int counter, int counter_at_last, int* output) {
220
+ *output = _anpersand_anpersand(_eq__eq_(counter, 0), _exclamation__eq_(counter_at_last, 0));
221
+ return 1;
222
+ }
223
+ static int node_flash(int counter, int* output) {
224
+ *output = _lt_(counter, 5);
225
+ return 1;
226
+ }
227
+ static int node_anonymous69880537178160(int curMode, int btnRotate_at_last, int btnRotate, int curPos, struct Tuple3_Int_Int_Int** output) {
228
+ int _tmp006;
229
+ struct Tuple3_Int_Int_Int* _tmp005;
230
+ _tmp006 = _anpersand_anpersand(editable_0(curMode), positiveEdge_0(btnRotate_at_last, btnRotate));
231
+ if (_tmp006 == 1) {
232
+ struct Tuple3_Int_Int_Int* _tmp007;
233
+ if (curPos == 0) {
234
+ _tmp007 = Tuple3_0(1, 0, 0);
235
+ }
236
+ else if (curPos == 1) {
237
+ _tmp007 = Tuple3_0(0, 1, 0);
238
+ }
239
+ else if (curPos == 2) {
240
+ _tmp007 = Tuple3_0(0, 0, 1);
241
+ }
242
+ _tmp005 = _tmp007;
243
+ }
244
+ else if (_tmp006 == 0) {
245
+ _tmp005 = Tuple3_0(0, 0, 0);
246
+ }
247
+ *output = _tmp005;
248
+ return 1;
249
+ }
250
+ static int node_anonymous69880541228320(int curMode, int flash, int curPos, struct Tuple3_Bool_Bool_Bool** output) {
251
+ int _tmp009;
252
+ struct Tuple3_Bool_Bool_Bool* _tmp008;
253
+ _tmp009 = _anpersand_anpersand(editable_0(curMode), flash);
254
+ if (_tmp009 == 1) {
255
+ struct Tuple3_Bool_Bool_Bool* _tmp010;
256
+ if (curPos == 0) {
257
+ _tmp010 = Tuple3_1(1, 0, 0);
258
+ }
259
+ else if (curPos == 1) {
260
+ _tmp010 = Tuple3_1(0, 1, 0);
261
+ }
262
+ else if (curPos == 2) {
263
+ _tmp010 = Tuple3_1(0, 0, 1);
264
+ }
265
+ _tmp008 = _tmp010;
266
+ }
267
+ else if (_tmp009 == 0) {
268
+ _tmp008 = Tuple3_1(0, 0, 0);
269
+ }
270
+ *output = _tmp008;
271
+ return 1;
272
+ }
273
+ static int node_dh(struct Tuple3_Int_Int_Int* anonymous69880537178160, int* output) {
274
+ int _tmp011;
275
+ if (1) {
276
+ int pvar0_dh = anonymous69880537178160->value.Tuple3.member0;
277
+ int pvar0_dm = anonymous69880537178160->value.Tuple3.member1;
278
+ int pvar0_ds = anonymous69880537178160->value.Tuple3.member2;
279
+ _tmp011 = pvar0_dh;
280
+ }
281
+ *output = _tmp011;
282
+ return 1;
283
+ }
284
+ static int node_dm(struct Tuple3_Int_Int_Int* anonymous69880537178160, int* output) {
285
+ int _tmp012;
286
+ if (1) {
287
+ int pvar1_dh = anonymous69880537178160->value.Tuple3.member0;
288
+ int pvar1_dm = anonymous69880537178160->value.Tuple3.member1;
289
+ int pvar1_ds = anonymous69880537178160->value.Tuple3.member2;
290
+ _tmp012 = pvar1_dm;
291
+ }
292
+ *output = _tmp012;
293
+ return 1;
294
+ }
295
+ static int node_ds(struct Tuple3_Int_Int_Int* anonymous69880537178160, int* output) {
296
+ int _tmp013;
297
+ if (1) {
298
+ int pvar2_dh = anonymous69880537178160->value.Tuple3.member0;
299
+ int pvar2_dm = anonymous69880537178160->value.Tuple3.member1;
300
+ int pvar2_ds = anonymous69880537178160->value.Tuple3.member2;
301
+ _tmp013 = pvar2_ds;
302
+ }
303
+ *output = _tmp013;
304
+ return 1;
305
+ }
306
+ static int node_maskHour(struct Tuple3_Bool_Bool_Bool* anonymous69880541228320, int* output) {
307
+ int _tmp014;
308
+ if (1) {
309
+ int pvar3_maskHour = anonymous69880541228320->value.Tuple3.member0;
310
+ int pvar3_maskMin = anonymous69880541228320->value.Tuple3.member1;
311
+ int pvar3_maskSec = anonymous69880541228320->value.Tuple3.member2;
312
+ _tmp014 = pvar3_maskHour;
313
+ }
314
+ *output = _tmp014;
315
+ return 1;
316
+ }
317
+ static int node_maskMin(struct Tuple3_Bool_Bool_Bool* anonymous69880541228320, int* output) {
318
+ int _tmp015;
319
+ if (1) {
320
+ int pvar4_maskHour = anonymous69880541228320->value.Tuple3.member0;
321
+ int pvar4_maskMin = anonymous69880541228320->value.Tuple3.member1;
322
+ int pvar4_maskSec = anonymous69880541228320->value.Tuple3.member2;
323
+ _tmp015 = pvar4_maskMin;
324
+ }
325
+ *output = _tmp015;
326
+ return 1;
327
+ }
328
+ static int node_maskSec(struct Tuple3_Bool_Bool_Bool* anonymous69880541228320, int* output) {
329
+ int _tmp016;
330
+ if (1) {
331
+ int pvar5_maskHour = anonymous69880541228320->value.Tuple3.member0;
332
+ int pvar5_maskMin = anonymous69880541228320->value.Tuple3.member1;
333
+ int pvar5_maskSec = anonymous69880541228320->value.Tuple3.member2;
334
+ _tmp016 = pvar5_maskSec;
335
+ }
336
+ *output = _tmp016;
337
+ return 1;
338
+ }
339
+ static int node_curTime(int pulse1s, struct Time* curTime_at_last, int dh, int dm, int ds, struct Time** output) {
340
+ struct Time* _tmp017;
341
+ if (pulse1s == 1) {
342
+ _tmp017 = roundingTime_0(proceedTime_0(curTime_at_last), dh, dm, ds);
343
+ }
344
+ else if (pulse1s == 0) {
345
+ _tmp017 = roundingTime_0(curTime_at_last, dh, dm, ds);
346
+ }
347
+ *output = _tmp017;
348
+ return 1;
349
+ }
350
+ static struct Time* init_curTime() {
351
+ return Time_0(0, 0, 0);
352
+ }
353
+ static int node_hour(struct Time* curTime, int* output) {
354
+ int _tmp018;
355
+ if (1) {
356
+ struct Time* pvar6_curTime = curTime;
357
+ int pvar6_hour = curTime->value.Time.member0;
358
+ int pvar6_min = curTime->value.Time.member1;
359
+ int pvar6_sec = curTime->value.Time.member2;
360
+ _tmp018 = pvar6_hour;
361
+ }
362
+ *output = _tmp018;
363
+ return 1;
364
+ }
365
+ static int init_hour() {
366
+ struct Time* _tmp020;
367
+ int _tmp019;
368
+ _tmp020 = Time_0(0, 0, 0);
369
+ if (1) {
370
+ struct Time* pvar7_curTime = _tmp020;
371
+ int pvar7_hour = _tmp020->value.Time.member0;
372
+ int pvar7_min = _tmp020->value.Time.member1;
373
+ int pvar7_sec = _tmp020->value.Time.member2;
374
+ _tmp019 = pvar7_hour;
375
+ }
376
+ return _tmp019;
377
+ }
378
+ static int node_min(struct Time* curTime, int* output) {
379
+ int _tmp021;
380
+ if (1) {
381
+ struct Time* pvar8_curTime = curTime;
382
+ int pvar8_hour = curTime->value.Time.member0;
383
+ int pvar8_min = curTime->value.Time.member1;
384
+ int pvar8_sec = curTime->value.Time.member2;
385
+ _tmp021 = pvar8_min;
386
+ }
387
+ *output = _tmp021;
388
+ return 1;
389
+ }
390
+ static int init_min() {
391
+ struct Time* _tmp023;
392
+ int _tmp022;
393
+ _tmp023 = Time_0(0, 0, 0);
394
+ if (1) {
395
+ struct Time* pvar9_curTime = _tmp023;
396
+ int pvar9_hour = _tmp023->value.Time.member0;
397
+ int pvar9_min = _tmp023->value.Time.member1;
398
+ int pvar9_sec = _tmp023->value.Time.member2;
399
+ _tmp022 = pvar9_min;
400
+ }
401
+ return _tmp022;
402
+ }
403
+ static int node_sec(struct Time* curTime, int* output) {
404
+ int _tmp024;
405
+ if (1) {
406
+ struct Time* pvar10_curTime = curTime;
407
+ int pvar10_hour = curTime->value.Time.member0;
408
+ int pvar10_min = curTime->value.Time.member1;
409
+ int pvar10_sec = curTime->value.Time.member2;
410
+ _tmp024 = pvar10_sec;
411
+ }
412
+ *output = _tmp024;
413
+ return 1;
414
+ }
415
+ static int init_sec() {
416
+ struct Time* _tmp026;
417
+ int _tmp025;
418
+ _tmp026 = Time_0(0, 0, 0);
419
+ if (1) {
420
+ struct Time* pvar11_curTime = _tmp026;
421
+ int pvar11_hour = _tmp026->value.Time.member0;
422
+ int pvar11_min = _tmp026->value.Time.member1;
423
+ int pvar11_sec = _tmp026->value.Time.member2;
424
+ _tmp025 = pvar11_sec;
425
+ }
426
+ return _tmp025;
427
+ }
428
+ static struct Time* roundingTime_0(struct Time* t, int dh, int dm, int ds) {
429
+ struct Time* _tmp027;
430
+ if (1) {
431
+ int pvar12_h = t->value.Time.member0;
432
+ int pvar12_m = t->value.Time.member1;
433
+ int pvar12_s = t->value.Time.member2;
434
+ _tmp027 = Time_0(_parcent_(_plus_(pvar12_h, dh), 24), _parcent_(_plus_(pvar12_m, dm), 60), _parcent_(_plus_(pvar12_s, ds), 60));
435
+ }
436
+ return _tmp027;
437
+ }
438
+ static struct Time* proceedTime_0(struct Time* t) {
439
+ struct Time* _tmp028;
440
+ if (1) {
441
+ int _tmp030;
442
+ int pvar13_h = t->value.Time.member0;
443
+ int pvar13_m = t->value.Time.member1;
444
+ int pvar13_s = t->value.Time.member2;
445
+ struct Time* _tmp029;
446
+ _tmp030 = _plus_(pvar13_s, 1);
447
+ if (1) {
448
+ int _tmp032;
449
+ int pvar14_newS = _tmp030;
450
+ struct Time* _tmp031;
451
+ _tmp032 = _plus_(pvar13_m, _slash_(pvar14_newS, 60));
452
+ if (1) {
453
+ int _tmp034;
454
+ int pvar15_newM = _tmp032;
455
+ struct Time* _tmp033;
456
+ _tmp034 = _plus_(pvar13_h, _slash_(pvar15_newM, 60));
457
+ if (1) {
458
+ int pvar16_newH = _tmp034;
459
+ _tmp033 = Time_0(_parcent_(pvar16_newH, 24), _parcent_(pvar15_newM, 60), _parcent_(pvar14_newS, 60));
460
+ }
461
+ _tmp031 = _tmp033;
462
+ }
463
+ _tmp029 = _tmp031;
464
+ }
465
+ _tmp028 = _tmp029;
466
+ }
467
+ return _tmp028;
468
+ }
469
+ static int editable_0(int m) {
470
+ int _tmp035;
471
+ if (m == 0) {
472
+ _tmp035 = 0;
473
+ }
474
+ else if (m == 1) {
475
+ _tmp035 = 1;
476
+ }
477
+ return _tmp035;
478
+ }
479
+ static int positiveEdge_0(int a, int b) {
480
+ return _anpersand_anpersand(_at__exclamation_(a), b);
481
+ }
482
+ static int nextMode_0(int m) {
483
+ int _tmp036;
484
+ if (m == 0) {
485
+ _tmp036 = 1;
486
+ }
487
+ else if (m == 1) {
488
+ _tmp036 = 0;
489
+ }
490
+ return _tmp036;
491
+ }
492
+ static int nextPos_0(int p) {
493
+ int _tmp037;
494
+ if (p == 0) {
495
+ _tmp037 = 1;
496
+ }
497
+ else if (p == 1) {
498
+ _tmp037 = 2;
499
+ }
500
+ else if (p == 2) {
501
+ _tmp037 = 0;
502
+ }
503
+ return _tmp037;
504
+ }
505
+ static void refreshMark() {
506
+ int i;
507
+ for (i = 0; i < size_Time; i++) {
508
+ if (memory_Time[i].mark < Counter) memory_Time[i].mark = 0;
509
+ else memory_Time[i].mark -= Counter - 1;
510
+ }
511
+ for (i = 0; i < size_Tuple3_Int_Int_Int; i++) {
512
+ if (memory_Tuple3_Int_Int_Int[i].mark < Counter) memory_Tuple3_Int_Int_Int[i].mark = 0;
513
+ else memory_Tuple3_Int_Int_Int[i].mark -= Counter - 1;
514
+ }
515
+ for (i = 0; i < size_Tuple3_Bool_Bool_Bool; i++) {
516
+ if (memory_Tuple3_Bool_Bool_Bool[i].mark < Counter) memory_Tuple3_Bool_Bool_Bool[i].mark = 0;
517
+ else memory_Tuple3_Bool_Bool_Bool[i].mark -= Counter - 1;
518
+ }
519
+ }
520
+ void ActivateLCDClock() {
521
+ int current_side = 0, last_side = 1;
522
+ node_memory_btnMode[last_side] = init_btnMode();
523
+ node_memory_btnNext[last_side] = init_btnNext();
524
+ node_memory_btnRotate[last_side] = init_btnRotate();
525
+ node_memory_counter[last_side] = init_counter();
526
+ node_memory_curMode[last_side] = init_curMode();
527
+ node_memory_curPos[last_side] = init_curPos();
528
+ node_memory_curTime[last_side] = init_curTime();
529
+ mark_Time(node_memory_curTime[last_side], 14);
530
+ node_memory_hour[last_side] = init_hour();
531
+ node_memory_min[last_side] = init_min();
532
+ node_memory_sec[last_side] = init_sec();
533
+ Counter = NodeSize + 1;
534
+ refreshMark();
535
+ while (1) {
536
+ Counter = 1;
537
+ Input(&node_memory_btnMode[current_side], &node_memory_btnNext[current_side], &node_memory_btnRotate[current_side], &node_memory_pulse100ms[current_side]);
538
+ node_counter(node_memory_pulse100ms[current_side], node_memory_counter[last_side], &node_memory_counter[current_side]);
539
+ Counter++;
540
+ node_curMode(node_memory_btnMode[last_side], node_memory_btnMode[current_side], node_memory_curMode[last_side], &node_memory_curMode[current_side]);
541
+ Counter++;
542
+ node_curPos(node_memory_btnNext[last_side], node_memory_btnNext[current_side], node_memory_curPos[last_side], &node_memory_curPos[current_side]);
543
+ Counter++;
544
+ node_pulse1s(node_memory_counter[current_side], node_memory_counter[last_side], &node_memory_pulse1s[current_side]);
545
+ Counter++;
546
+ node_flash(node_memory_counter[current_side], &node_memory_flash[current_side]);
547
+ Counter++;
548
+ node_anonymous69880537178160(node_memory_curMode[current_side], node_memory_btnRotate[last_side], node_memory_btnRotate[current_side], node_memory_curPos[current_side], &node_memory_anonymous69880537178160[current_side]);
549
+ mark_Tuple3_Int_Int_Int(node_memory_anonymous69880537178160[current_side], Counter + 4);
550
+ Counter++;
551
+ node_anonymous69880541228320(node_memory_curMode[current_side], node_memory_flash[current_side], node_memory_curPos[current_side], &node_memory_anonymous69880541228320[current_side]);
552
+ mark_Tuple3_Bool_Bool_Bool(node_memory_anonymous69880541228320[current_side], Counter + 6);
553
+ Counter++;
554
+ node_dh(node_memory_anonymous69880537178160[current_side], &node_memory_dh[current_side]);
555
+ Counter++;
556
+ node_dm(node_memory_anonymous69880537178160[current_side], &node_memory_dm[current_side]);
557
+ Counter++;
558
+ node_ds(node_memory_anonymous69880537178160[current_side], &node_memory_ds[current_side]);
559
+ Counter++;
560
+ node_maskHour(node_memory_anonymous69880541228320[current_side], &node_memory_maskHour[current_side]);
561
+ Counter++;
562
+ node_maskMin(node_memory_anonymous69880541228320[current_side], &node_memory_maskMin[current_side]);
563
+ Counter++;
564
+ node_maskSec(node_memory_anonymous69880541228320[current_side], &node_memory_maskSec[current_side]);
565
+ Counter++;
566
+ node_curTime(node_memory_pulse1s[current_side], node_memory_curTime[last_side], node_memory_dh[current_side], node_memory_dm[current_side], node_memory_ds[current_side], &node_memory_curTime[current_side]);
567
+ mark_Time(node_memory_curTime[current_side], Counter + 17);
568
+ Counter++;
569
+ node_hour(node_memory_curTime[current_side], &node_memory_hour[current_side]);
570
+ Counter++;
571
+ node_min(node_memory_curTime[current_side], &node_memory_min[current_side]);
572
+ Counter++;
573
+ node_sec(node_memory_curTime[current_side], &node_memory_sec[current_side]);
574
+ Counter++;
575
+ Output(&node_memory_hour[current_side], &node_memory_min[current_side], &node_memory_sec[current_side], &node_memory_maskHour[current_side], &node_memory_maskMin[current_side], &node_memory_maskSec[current_side]);
576
+ refreshMark();
577
+ current_side ^= 1;
578
+ last_side ^= 1;
579
+ }
580
+ }