BOAST 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/BOAST.gemspec +1 -1
  2. data/lib/BOAST/Transitions.rb +30 -38
  3. metadata +2 -2
data/BOAST.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'BOAST'
3
- s.version = "0.3"
3
+ s.version = "0.4"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://forge.imag.fr/projects/boast/"
@@ -1,47 +1,39 @@
1
1
  module BOAST
2
2
  module TypeTransition
3
- @@transitions = Hash::new { |hash, key| hash[key] = Hash::new{ |has, ke| has[ke] = 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
- match_type1 = @@transitions.keys.select { |e1| true if type1 <= e1 }
7
- raise "Unknown type!" if match_type1.length == 0
8
- match_type1.sort!
9
- #STDERR.puts match_type1.inspect
10
- match_type1.each { |t1|
11
- match_type2 = @@transitions[t1].keys.select{ |e2| true if type2 <= e2 }
12
- match_type2.sort!
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
- end
14
+ end
22
15
 
23
- def set_transition(type1, type2, operator, return_type)
24
- @@transitions[type1][type2][operator] = return_type
25
- end
16
+ def set_transition(type1, type2, operator, return_type)
17
+ @@transitions[[type1,type2]][operator] = return_type
18
+ end
26
19
 
27
- def transition(var1, var2, operator)
28
- signed = false
29
- size = nil
30
- return_type, operator = get_transition(var1.type.class, var2.type.class, operator)
31
- #STDERR.puts "#{return_type} : #{var1.type.class} #{operator} #{var2.type.class}"
32
- if var1.type.class <= return_type and var2.type.class <= return_type then
33
- signed = signed or var1.type.signed if var1.type.respond_to?(:signed)
34
- signed = signed or var2.type.signed if var2.type.respond_to?(:signed)
35
- if var1.type.respond_to?(:size) and var2.type.respond_to?(:size) then
36
- size = [var1.type.size, var2.type.size].max
37
- end
38
- [BOAST::Variable::new("dummy", return_type, :size => size, :signed => signed), operator]
39
- elsif var1.type.class <= return_type then
40
- return [var1, operator]
41
- elsif var2.type.class <= return_type then
42
- return [var2, operator]
43
- end
44
- end
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.3'
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 00:00:00.000000000 Z
12
+ date: 2014-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: narray