lib/cpee/processtransformation/structures.rb in cpee-1.3.153 vs lib/cpee/processtransformation/structures.rb in cpee-1.3.154
- old
+ new
@@ -39,17 +39,18 @@
end
end
class Node #{{{
include Container
- @@niceid = -1
+ @@niceid = {}
attr_reader :id, :label, :niceid
attr_reader :endpoints, :methods, :parameters, :attributes
attr_accessor :script, :script_id, :script_var, :script_type, :incoming, :outgoing, :type
- def initialize(id,type,label,incoming,outgoing)
+ def initialize(context,id,type,label,incoming,outgoing)
+ @@niceid[context] ||= -1
+ @niceid = (@@niceid[context] += 1)
@id = id
- @niceid = (@@niceid += 1)
@type = type
@label = label
@endpoints = []
@methods = []
@script = nil
@@ -71,12 +72,12 @@
@sub.length
end
end #}}}
class Break < Node
- def initialize(incoming)
- super '-1', :break, 'BREAK', incoming, []
+ def initialize(context,incoming)
+ super context, '-1', :break, 'BREAK', incoming, []
end
end
class Alternative < Array #{{{
include Container
@@ -281,11 +282,11 @@
def first_node
self.first.first
end
def second_nodes
- self.map { |t| t[1] }
+ self.map { |t| t.length > 1 ? t[1] : t[0] }
end
def shortest
self.min_by{|e|e.length}
end
@@ -336,16 +337,16 @@
self.each{|n| num += 1 if n.first == n.last }
num == self.length
end
- def add_breaks
+ def add_breaks(context)
trueloops = self.find_all{ |t| t.last == t.first }.length
if trueloops == self.length
self << [self.first_node] ### the blank conditional so that we get a break
else
self.each do |t|
- t << Break.new(1) unless t.last == t.first ### an explicit break
+ t << Break.new(context,1) unless t.last == t.first ### an explicit break
end
end
end
def loops