lib/cpee/processtransformation/structures.rb in cpee-1.3.159 vs lib/cpee/processtransformation/structures.rb in cpee-1.3.160
- old
+ new
@@ -72,12 +72,12 @@
@sub.length
end
end #}}}
class Break < Node
- def initialize(context,incoming)
- super context, '-1', :break, 'BREAK', incoming, []
+ def initialize(context)
+ super context, '-1', :break, 'BREAK', 1, []
end
end
class Alternative < Array #{{{
include Container
@@ -99,35 +99,31 @@
def initialize(id)
@container = true
@id = id
end
end #}}}
- class InfiniteLoop < Array #{{{
+ class Loop #{{{
include Container
- def condition?; false; end
+ include Struct
+ include Enumerable
+ attr_reader :id, :sub, :mode
+ attr_accessor :type, :condition, :condition_type
attr_reader :attributes
- attr_accessor :id, :type
- def initialize(id)
- @container = true
- @id = id
- @type = :loop
- @attributes = {}
- end
- end #}}}
- class Loop < Array #{{{
- include Container
- attr_accessor :id, :type, :condition, :condition_type
- attr_reader :attributes
def condition?; true; end
def initialize(id)
@container = true
@id = id
@type = :loop
+ @mode = :exclusive
@condition = []
+ @sub = []
@condition_type = nil
@attributes = {}
end
+ def new_branch
+ (@sub << Alternative.new(@id)).last
+ end
end #}}}
class Parallel #{{{
include Container
include Struct
@@ -328,28 +324,26 @@
def include_in_all?(e)
num = 0
self.each{|n| num += 1 if n.include?(e)}
num == self.length
end
- def same_position_in_all?(e,i)
- num = 0
- self.each{|n| num += 1 if n[i] == e}
- num == self.length
+
+ def aaa
+ puts 'rrr'
end
def all_loops?
num = 0
self.each{|n| num += 1 if n.first == n.last }
num == self.length
end
-
def add_breaks(context)
trueloops = self.find_all{ |t| t.last == t.first }.length
- tb = Break.new(context,1)
+ tb = Break.new(context)
if trueloops == self.length
- self << [self.first_node] ### the blank conditional so that we get a break
+ self << [nil,tb]
else
self.each do |t|
t << tb unless t.last == t.first ### an explicit break
end
end
@@ -398,27 +392,18 @@
end
end
def extend
# find largest common
- max = nil
+ max = []
sh = self.shortest
sh = sh[0..-2] if sh.first == sh.last
sh.each_with_index do |e,i|
- if self.same_position_in_all?(e,i)
- max = e
- else
- break
- end
+ max << e if self.include_in_all?(e)
end
+ max = max.last
- # all before the largest common are just copied, so incoming should be 1
- sh.each do |e|
- break if e == max
- e.incoming = 1
- end
-
# if last is the largest common do nothing
# else append from last to largest common
self.each do |t|
unless t.last == max
last = t.last
@@ -428,10 +413,9 @@
end
end
end
end
- max.incoming = self.length + 1
max
end
def segment_by_loops(loops)
# supress loops