Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ensure the #names salt never repeats

  • Loading branch information...
commit eca3970064418bf7529968391961ffce18329e47 1 parent d804800
@vito authored
Showing with 9 additions and 11 deletions.
  1. +9 −11 lib/atomy/ast/node.rb
View
20 lib/atomy/ast/node.rb
@@ -508,29 +508,23 @@ def initialize(line, body)
@body = body
end
- def sprinkle_salt(g, by)
- skip_salt = g.new_label
-
- g.push_cpath_top
- g.find_const :Atomy
- g.find_const :CodeLoader
- g.send :compiled?, 0
- g.git skip_salt
+ def sprinkle_salt(g, diff)
+ return if diff == 0
g.push_cpath_top
g.find_const :Atomy
g.find_const :Macro
g.find_const :Environment
- g.push by
+ g.push diff
g.send :salt!, 1
g.pop
-
- skip_salt.set!
end
def bytecode(g)
pos(g)
+ before = Atomy::Macro::Environment.salt
+
@body.each.with_index do |n, i|
n.compile(g)
@@ -541,6 +535,10 @@ def bytecode(g)
g.pop unless i + 1 == @body.size
end
+
+ after = Atomy::Macro::Environment.salt
+
+ sprinkle_salt(g, after - before)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.