emfrp 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47841f28c3f4f205e6ffd86414321a77b8f94600
4
- data.tar.gz: e6652a888ebe7432b7c4b8b95523cf7c6f350a29
3
+ metadata.gz: b22236346a774cffb9cf18b119085b0177a0aab6
4
+ data.tar.gz: f0aeb3ec0dd857f2ba08678f0a34b8398bd529a9
5
5
  SHA512:
6
- metadata.gz: f49280862f5de248a70dcd7b7aaf7ad2912273ece39531961815b4e4e2ac928d63a47a3cd7cde8eac4ab4726a400bb54c1685bd6beb5e96c2f0a55cf5a2f0ed6
7
- data.tar.gz: 12c38a3ab709acbdc13e544f716f2c598e2869f3871bfee00ac0d9b6abf854c89c948e67bf8ea69846e2ee33710815743d3315a7bb0185a811f67563211bd625
6
+ metadata.gz: bbbbb76bac2428193c34ce526269dfa8d524116de18f419a6d1536809eb655449e3f7c186511ea99bad08fca175a7c501092bb05381a6e4c7b3a5812b3534610
7
+ data.tar.gz: 29135f70e0b9607465857decad838a735ef00dd93db938a1b5b98dc17b53af31eeaaff244be759578ad06dc9704373bcf435c374c5abea53f00dec8e9bcefeec
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Emfrp
2
4
  class Monofy
3
5
  IType = Struct.new(:typing, :type_def) do
@@ -32,14 +34,14 @@ module Emfrp
32
34
 
33
35
  def used_nodes
34
36
  used = []
37
+ visited = Set.new
35
38
  f = proc do |n|
36
39
  used << n
40
+ visited << n[:name]
37
41
  n[:params].each do |p|
38
42
  pn = @top[:dict][:node_space][p[:name][:desc]].get
39
43
  if pn.is_a?(NodeDef)
40
- if p[:last]
41
- used << pn
42
- else
44
+ if !visited.include?(p[:name])
43
45
  f.call(pn)
44
46
  end
45
47
  end
@@ -55,7 +55,7 @@ module Emfrp
55
55
  stmts << "#{ct.tref(self)} #{vname};"
56
56
  left = self[:exp]
57
57
  if left.is_a?(VarRef)
58
- left_vname = ct.escape_name(left[:name][:desc])
58
+ left_vname = left[:binder].get.var_name(ct, left[:name][:desc])
59
59
  else
60
60
  left_vname = "_tmp%03d" % ct.uniq_id_gen
61
61
  stmts.unshift "#{ct.tref(left)} #{left_vname};"
@@ -94,7 +94,7 @@ module Emfrp
94
94
  if type_def.enum?(ct)
95
95
  conds << "#{receiver} == #{tvalue_id}"
96
96
  else
97
- conds << "#{receiver}" + accessor + "tvalue_type == " + tvalue_id.to_s
97
+ conds << "#{receiver}" + accessor + "tvalue_id == " + tvalue_id.to_s
98
98
  end
99
99
  end
100
100
  new_receiver = "#{receiver}" + accessor + "value." + pattern[:name][:desc]
@@ -11,7 +11,7 @@ module Emfrp
11
11
  input[:name][:desc] << "##{uniq_key}"
12
12
  top[:nodes] << NodeDef.new(
13
13
  :name => input[:name],
14
- :init_exp => nil,
14
+ :init_exp => input[:init_exp],
15
15
  :params => nil,
16
16
  :type => nil,
17
17
  :exp => arg_exp,
@@ -56,14 +56,14 @@ module Emfrp
56
56
  width = lines[ln].chars.take_while{|c| c == "\s"}.size
57
57
  ((ln+1)..(len-1)).each do |ln2|
58
58
  width2 = lines[ln2].chars.take_while{|c| c == "\s"}.size
59
- if lines[ln2].strip == ""
59
+ if ln2 == len - 1
60
+ lines[ln2] << " :endcase"
61
+ break
62
+ elsif lines[ln2].strip == ""
60
63
  next
61
64
  elsif width2 <= width
62
65
  lines[ln2 - 1] << " :endcase"
63
66
  break
64
- elsif ln2 == len - 1
65
- lines[ln2] << " :endcase"
66
- break
67
67
  end
68
68
  end
69
69
  end
data/lib/emfrp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Emfrp
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,7 @@
1
+ module AtlastDependency out delay3A use Std
2
+
3
+ node init[0] a = a@last + 1
4
+ node init[0] delayA = a@last
5
+ node init[0] delay2A = delayA@last
6
+ node init[0] delay3A = delay2A@last
7
+
@@ -0,0 +1,19 @@
1
+ #include "AtlastDependency.h"
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ int i = 0;
6
+
7
+ void Input() {
8
+ }
9
+
10
+ void Output(int* delay3A) {
11
+ printf("%d\n", *delay3A);
12
+ if (++i == 10) {
13
+ exit(0);
14
+ }
15
+ }
16
+
17
+ int main() {
18
+ ActivateAtlastDependency();
19
+ }
@@ -0,0 +1,2 @@
1
+ NAME = "AtlastDependency"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
@@ -0,0 +1,10 @@
1
+ 0
2
+ 0
3
+ 0
4
+ 1
5
+ 2
6
+ 3
7
+ 4
8
+ 5
9
+ 6
10
+ 7
@@ -0,0 +1,10 @@
1
+ 0
2
+ 0
3
+ 0
4
+ 1
5
+ 2
6
+ 3
7
+ 4
8
+ 5
9
+ 6
10
+ 7
File without changes
@@ -0,0 +1,29 @@
1
+ module NestedMatch
2
+ in tag : Int, value : Int
3
+ out x
4
+ use Std
5
+
6
+ type Tag = T1 | T21 | T22 | T33 | T34
7
+ type InnerA = Inner1(Int) | Inner2(Int,Int)
8
+ type InnerB = Inner3(Int) | Inner4(Int,Int)
9
+ type Outer = Outer1(Int) | Outer2(InnerA) | Outer3(InnerB)
10
+
11
+ node mid =
12
+ tag of:
13
+ 0 -> Outer1(value)
14
+ 1 -> Outer2(Inner1(value))
15
+ 2 -> Outer2(Inner2(value,0))
16
+ 3 -> Outer3(Inner3(value))
17
+ 4 -> Outer3(Inner4(value,0))
18
+ _ -> Outer1(-1)
19
+
20
+ node x =
21
+ mid of:
22
+ Outer1(a) -> a
23
+ Outer2(innerA) -> innerA of:
24
+ Inner1(a) -> a
25
+ Inner2(a, _) -> a
26
+ Outer3(innerB) -> innerB of:
27
+ Inner3(a) -> a
28
+ Inner4(a, _) -> a
29
+
@@ -0,0 +1,20 @@
1
+ #include "NestedMatch.h"
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ void Input(int* tag, int* value) {
6
+ static int counter = 0;
7
+ *tag = counter;
8
+ counter = (counter + 1) % 5;
9
+ if (scanf("%d", value) == EOF) {
10
+ exit(0);
11
+ }
12
+ }
13
+
14
+ void Output(int* x) {
15
+ printf("%d\n", *x);
16
+ }
17
+
18
+ int main() {
19
+ ActivateNestedMatch();
20
+ }
@@ -0,0 +1,2 @@
1
+ NAME = "NestedMatch"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
@@ -0,0 +1,10 @@
1
+ 5
2
+ 10
3
+ 15
4
+ 20
5
+ 25
6
+ 30
7
+ 25
8
+ 40
9
+ 45
10
+ 50
@@ -0,0 +1,10 @@
1
+ 5
2
+ 10
3
+ 15
4
+ 20
5
+ 25
6
+ 30
7
+ 25
8
+ 40
9
+ 45
10
+ 50
@@ -0,0 +1,10 @@
1
+ 5
2
+ 10
3
+ 15
4
+ 20
5
+ 25
6
+ 30
7
+ 25
8
+ 40
9
+ 45
10
+ 50
@@ -0,0 +1,7 @@
1
+ module Delay2
2
+ in input(0) : Int
3
+ out delay2 : Int
4
+ use Std
5
+
6
+ node init[0] mid = input@last
7
+ node delay2 = mid@last
@@ -0,0 +1,2 @@
1
+ NAME = "SubModuleInit"
2
+ load File.expand_path('../../Rakefile.common', __FILE__)
@@ -0,0 +1,7 @@
1
+ module SubModuleInit
2
+ in x : Int, y : Int
3
+ out delay2X : Int, delay2Y : Int
4
+ use Std
5
+
6
+ newnode delay2X = Delay2(x)
7
+ newnode delay2Y = Delay2(y)
@@ -0,0 +1,17 @@
1
+ #include "SubModuleInit.h"
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ void Input(int* x, int* y) {
6
+ if (scanf("%d %d", x, y) == EOF) {
7
+ exit(0);
8
+ }
9
+ }
10
+
11
+ void Output(int* delay2X, int* delay2Y) {
12
+ printf("%d %d\n", *delay2X, *delay2Y);
13
+ }
14
+
15
+ int main() {
16
+ ActivateSubModuleInit();
17
+ }
@@ -0,0 +1,10 @@
1
+ 0 0
2
+ 0 0
3
+ 1 2
4
+ 3 4
5
+ 5 6
6
+ 7 8
7
+ 9 10
8
+ 11 12
9
+ 13 14
10
+ 15 16
@@ -0,0 +1,10 @@
1
+ 0 0
2
+ 0 0
3
+ 1 2
4
+ 3 4
5
+ 5 6
6
+ 7 8
7
+ 9 10
8
+ 11 12
9
+ 13 14
10
+ 15 16
@@ -0,0 +1,10 @@
1
+ 1 2
2
+ 3 4
3
+ 5 6
4
+ 7 8
5
+ 9 10
6
+ 11 12
7
+ 13 14
8
+ 15 16
9
+ 17 18
10
+ 19 20
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emfrp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kensuke Sawada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-12 00:00:00.000000000 Z
11
+ date: 2019-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -138,6 +138,12 @@ files:
138
138
  - tests/Rakefile.common
139
139
  - tests/command/Rakefile
140
140
  - tests/command/ReplaceNode.mfrp
141
+ - tests/compiler/AtlastDependency/AtlastDependency.mfrp
142
+ - tests/compiler/AtlastDependency/AtlastDependencyMain.c
143
+ - tests/compiler/AtlastDependency/Rakefile
144
+ - tests/compiler/AtlastDependency/actual_out.txt
145
+ - tests/compiler/AtlastDependency/expected_out.txt
146
+ - tests/compiler/AtlastDependency/in.txt
141
147
  - tests/compiler/ComplexDataType/ComplexDataType.mfrp
142
148
  - tests/compiler/ComplexDataType/ComplexDataTypeMain.c
143
149
  - tests/compiler/ComplexDataType/Rakefile
@@ -159,8 +165,21 @@ files:
159
165
  - tests/compiler/LCDPositioner/graph.dot
160
166
  - tests/compiler/LCDPositioner/graph.png
161
167
  - tests/compiler/LCDPositioner/in.txt
168
+ - tests/compiler/NestedMatch/NestedMatch.mfrp
169
+ - tests/compiler/NestedMatch/NestedMatchMain.c
170
+ - tests/compiler/NestedMatch/Rakefile
171
+ - tests/compiler/NestedMatch/actual_out.txt
172
+ - tests/compiler/NestedMatch/expected_out.txt
173
+ - tests/compiler/NestedMatch/in.txt
162
174
  - tests/compiler/Rakefile
163
175
  - tests/compiler/Rakefile.common
176
+ - tests/compiler/SubModuleInit/Delay2.mfrp
177
+ - tests/compiler/SubModuleInit/Rakefile
178
+ - tests/compiler/SubModuleInit/SubModuleInit.mfrp
179
+ - tests/compiler/SubModuleInit/SubModuleInitMain.c
180
+ - tests/compiler/SubModuleInit/actual_out.txt
181
+ - tests/compiler/SubModuleInit/expected_out.txt
182
+ - tests/compiler/SubModuleInit/in.txt
164
183
  - tests/compiler/UseData/Rakefile
165
184
  - tests/compiler/UseData/UseData.mfrp
166
185
  - tests/compiler/UseData/UseDataMain.c
@@ -204,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
223
  version: '0'
205
224
  requirements: []
206
225
  rubyforge_project:
207
- rubygems_version: 2.6.11
226
+ rubygems_version: 2.5.2.2
208
227
  signing_key:
209
228
  specification_version: 4
210
229
  summary: A compier of Emfrp, a FRP language for small embeded systems.