Skip to content

Commit

Permalink
Merge branch 'array-modification-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfurinn committed Apr 9, 2014
2 parents edc41da + 29164b4 commit 05809c0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/wongi-engine/alpha_memory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def wmes
copy.each do |wme|
y << wme unless wme.deleted?
end
@wmes.reject! &:deleted?
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/wongi-engine/beta/beta_memory.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Wongi::Engine

class BetaMemory < BetaNode
attr_reader :tokens

def initialize parent
super
Expand Down Expand Up @@ -61,7 +60,7 @@ def refresh_child child
end

def delete_token token
tokens.delete token
@tokens.delete token
end

# => TODO: investigate if we really need this
Expand Down
9 changes: 9 additions & 0 deletions lib/wongi-engine/beta/beta_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ def delete_token token
# => noop
end

def tokens
Enumerator.new do |y|
@tokens.dup.each do |token|
y << token unless token.deleted?
end
@tokens.reject! &:deleted?
end
end

private

def propagate_activation token, wme, assignments
Expand Down
1 change: 0 additions & 1 deletion lib/wongi-engine/beta/join_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def alpha= a
def alpha_activate wme
dp "JOIN alpha-activated with #{wme}"
collected = collect_assignments( wme )
dp "-TOKENS: #{self.parent.tokens.length}"
self.parent.tokens.each do |token|
dp "-MATCHING #{token}"
if matches?( token, wme ) && passes_filters?( token, wme, collected )
Expand Down
2 changes: 1 addition & 1 deletion lib/wongi-engine/beta/production_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize parent, actions

def beta_activate token, wme, assignments
super
generated = tokens.last
generated = @tokens.last
@actions.each do |action|
# @tokens.each do |t|
# action.execute t
Expand Down

0 comments on commit 05809c0

Please sign in to comment.