lib/flay.rb in flay-2.12.0 vs lib/flay.rb in flay-2.12.1

- old
+ new

@@ -15,11 +15,11 @@ alias :binread :read unless RUBY19 end end class Flay - VERSION = "2.12.0" # :nodoc: + VERSION = "2.12.1" # :nodoc: class Item < Struct.new(:structural_hash, :name, :bonus, :mass, :locations) alias identical? bonus end @@ -226,14 +226,15 @@ end update_masses sorted = masses.sort_by { |h,m| + exp = hashes[h].first [-m, - hashes[h].first.file, - hashes[h].first.line, - hashes[h].first.first.to_s] + exp.file, + exp.line, + exp.sexp_type.to_s] } sorted.map { |hash, mass| nodes = hashes[hash] @@ -247,11 +248,11 @@ locs = nodes.sort_by { |x| [x.file, x.line] }.each_with_index.map { |x, i| extra = :fuzzy if x.modified? Location[x.file, x.line, extra] } - Item[hash, node.first, bonus, mass, locs] + Item[hash, node.sexp_type, bonus, mass, locs] }.compact end ## # Reset total and recalculate the masses for all nodes in +hashes+. @@ -577,11 +578,14 @@ s.line = o.line s.modified = o.modified s end + alias :[] :[] # needed for STRICT_SEXP + def [] a # :nodoc: + # TODO: figure out a way to make this STRICT_SEXP happy s = super if Sexp === s then s.file = self.file s.line = self.line s.modified = self.modified @@ -634,10 +638,10 @@ MAX_INT32 = 2 ** 32 - 1 # :nodoc: def pure_ruby_hash # :nodoc: see above hash = 0 - n = NODE_NAMES[first] + n = NODE_NAMES[sexp_type] raise "Bad lookup: #{first} in #{sexp.inspect}" unless n hash += n & MAX_INT32 hash += hash << 10 & MAX_INT32