mark used up the block stack

This commit is contained in:
leaf corcoran 2015-02-28 11:26:37 -08:00
parent b1ecc7defc
commit a79eb19f9e
2 changed files with 34 additions and 11 deletions

View File

@ -54,14 +54,34 @@ local LinterBlock
do do
local _parent_0 = Block local _parent_0 = Block
local _base_0 = { local _base_0 = {
lint_mark_used = function(self, name)
if self.lint_unused_names and self.lint_unused_names[name] then
self.lint_unused_names[name] = false
return
end
if self.parent then
return self.parent:lint_mark_used(name)
end
end,
lint_check_unused = function(self) lint_check_unused = function(self)
if not (self.lint_unused_names and next(self.lint_unused_names)) then if not (self.lint_unused_names and next(self.lint_unused_names)) then
return return
end end
local names_by_position = { } local names_by_position = { }
for name, pos in pairs(self.lint_unused_names) do for name, pos in pairs(self.lint_unused_names) do
names_by_position[pos] = names_by_position[pos] or { } local _continue_0 = false
insert(names_by_position[pos], name) repeat
if not (pos) then
_continue_0 = true
break
end
names_by_position[pos] = names_by_position[pos] or { }
insert(names_by_position[pos], name)
_continue_0 = true
until true
if not _continue_0 then
break
end
end end
local tuples local tuples
do do
@ -109,6 +129,7 @@ do
_with_0.render = self.render _with_0.render = self.render
_with_0.get_root_block = self.get_root_block _with_0.get_root_block = self.get_root_block
_with_0.lint_check_unused = self.lint_check_unused _with_0.lint_check_unused = self.lint_check_unused
_with_0.lint_mark_used = self.lint_mark_used
_with_0.value_compilers = self.value_compilers _with_0.value_compilers = self.value_compilers
_with_0.statement_compilers = self.statement_compilers _with_0.statement_compilers = self.statement_compilers
return _with_0 return _with_0
@ -137,12 +158,7 @@ do
val[-1] val[-1]
}) })
end end
do block:lint_mark_used(name)
local unused = block.lint_unused_names
if unused then
unused[name] = nil
end
end
return vc.ref(block, val) return vc.ref(block, val)
end end
}, { }, {

View File

@ -69,9 +69,7 @@ class LinterBlock extends Block
val[-1] val[-1]
} }
if unused = block.lint_unused_names block\lint_mark_used name
unused[name] = nil
vc.ref block, val vc.ref block, val
}, __index: vc }, __index: vc
@ -98,12 +96,20 @@ class LinterBlock extends Block
sc.assign block, node sc.assign block, node
}, __index: sc }, __index: sc
lint_mark_used: (name) =>
if @lint_unused_names and @lint_unused_names[name]
@lint_unused_names[name] = false
return
if @parent
@parent\lint_mark_used name
lint_check_unused: => lint_check_unused: =>
return unless @lint_unused_names and next @lint_unused_names return unless @lint_unused_names and next @lint_unused_names
names_by_position = {} names_by_position = {}
for name, pos in pairs @lint_unused_names for name, pos in pairs @lint_unused_names
continue unless pos
names_by_position[pos] or= {} names_by_position[pos] or= {}
insert names_by_position[pos], name insert names_by_position[pos], name
@ -127,6 +133,7 @@ class LinterBlock extends Block
.render = @render .render = @render
.get_root_block = @get_root_block .get_root_block = @get_root_block
.lint_check_unused = @lint_check_unused .lint_check_unused = @lint_check_unused
.lint_mark_used = @lint_mark_used
.value_compilers = @value_compilers .value_compilers = @value_compilers
.statement_compilers = @statement_compilers .statement_compilers = @statement_compilers