Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ Track stack of nested sclass scopes for parser (pithyless)

[git-p4: depot-paths = "//src/flog/dev/": change = 8392]
  • Loading branch information...
commit 9ec60a50b1a3daf71ad788d0df9d6e0d654027dd 1 parent 63a28a2
@zenspider zenspider authored
Showing with 20 additions and 4 deletions.
  1. +4 −4 lib/flog.rb
  2. +16 −0 test/test_flog.rb
View
8 lib/flog.rb
@@ -371,7 +371,7 @@ def in_method(name, file, line)
def initialize option = {}
super()
@option = option
- @sclass = nil
+ @sclass = []
@class_stack = []
@method_stack = []
@method_locations = {}
@@ -697,7 +697,7 @@ def process_dasgn_curr(exp) # FIX: remove
alias :process_lasgn :process_dasgn_curr
def process_defn(exp)
- name = @sclass ? "::#{exp.shift}" : exp.shift
+ name = @sclass.empty? ? exp.shift : "::#{exp.shift}"
in_method name, exp.file, exp.line do
process_until_empty exp
end
@@ -813,12 +813,12 @@ def process_module(exp)
end
def process_sclass(exp)
- @sclass = true
+ @sclass.push(true)
penalize_by 0.5 do
process exp.shift # recv
process_until_empty exp
end
- @sclass = nil
+ @sclass.pop
add_to_score :sclass
s()
View
16 test/test_flog.rb
@@ -425,6 +425,22 @@ def test_process_defn_in_self
assert_in_delta 5.375, @flog.total
end
+ def test_process_defn_in_self_after_self
+ sexp = s(:sclass, s(:self),
+ s(:sclass, s(:self), s(:self)),
+ s(:defn, :x,
+ s(:args, :y),
+ s(:lit, 42)))
+
+ setup
+ @flog.process sexp
+
+ exp = {'main::x' => {:lit_fixnum => 0.375}, 'main#none' => {:sclass => 12.5}}
+ assert_equal exp, @flog.calls
+
+ assert_in_delta 12.875, @flog.total
+ end
+
def test_process_defs
@meth = "::x" # HACK, I don't like this
Please sign in to comment.
Something went wrong with that request. Please try again.