BOAST 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/BOAST.gemspec +1 -1
- data/lib/BOAST/Transitions.rb +30 -38
- metadata +2 -2
data/BOAST.gemspec
CHANGED
data/lib/BOAST/Transitions.rb
CHANGED
@@ -1,47 +1,39 @@
|
|
1
1
|
module BOAST
|
2
2
|
module TypeTransition
|
3
|
-
@@transitions = Hash::new { |hash, key| hash[key] = Hash::new
|
3
|
+
@@transitions = Hash::new { |hash, key| hash[key] = Hash::new }
|
4
4
|
def get_transition(type1, type2, operator)
|
5
5
|
#STDERR.puts @@transitions.inspect
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#STDERR.puts match_type2.inspect
|
14
|
-
match_type2.each { |t2|
|
15
|
-
#STDERR.puts @@transitions[t1][t2].inspect
|
16
|
-
return [@@transitions[t1][t2][operator], operator] if @@transitions[t1][t2][operator]
|
17
|
-
return [@@transitions[t1][t2][:default], operator] if @@transitions[t1][t2][:default]
|
18
|
-
}
|
19
|
-
}
|
6
|
+
#STDERR.puts @@transitions[t1][t2].inspec
|
7
|
+
ops = @@transitions[[type1,type2]]
|
8
|
+
raise "Types #{[type1,type2]} have no relation!" if not ops
|
9
|
+
t = ops[operator]
|
10
|
+
return [t,operator] if t
|
11
|
+
t = ops[:default]
|
12
|
+
return [t,operator] if t
|
20
13
|
raise "Unresolvable transition!"
|
21
|
-
|
14
|
+
end
|
22
15
|
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
def set_transition(type1, type2, operator, return_type)
|
17
|
+
@@transitions[[type1,type2]][operator] = return_type
|
18
|
+
end
|
26
19
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
20
|
+
def transition(var1, var2, operator)
|
21
|
+
signed = false
|
22
|
+
size = nil
|
23
|
+
return_type, operator = get_transition(var1.type.class, var2.type.class, operator)
|
24
|
+
#STDERR.puts "#{return_type} : #{var1.type.class} #{operator} #{var2.type.class}"
|
25
|
+
if var1.type.class == return_type and var2.type.class == return_type then
|
26
|
+
signed = signed or var1.type.signed if var1.type.respond_to?(:signed)
|
27
|
+
signed = signed or var2.type.signed if var2.type.respond_to?(:signed)
|
28
|
+
if var1.type.respond_to?(:size) and var2.type.respond_to?(:size) then
|
29
|
+
size = [var1.type.size, var2.type.size].max
|
30
|
+
end
|
31
|
+
[BOAST::Variable::new("dummy", return_type, :size => size, :signed => signed), operator]
|
32
|
+
elsif var1.type.class == return_type then
|
33
|
+
return [var1, operator]
|
34
|
+
elsif var2.type.class == return_type then
|
35
|
+
return [var2, operator]
|
36
|
+
end
|
37
|
+
end
|
45
38
|
end
|
46
|
-
|
47
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BOAST
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: narray
|