main
Alpha Chen 2 years ago
parent aa02e46d9f
commit f9da923296

@ -44,6 +44,14 @@ module Lox
nil nil
end end
def visit_function(stmt)
declare(stmt.name)
define(stmt.name)
resolve_function(stmt)
nil
end
private private
def with_block def with_block
@ -74,5 +82,15 @@ module Lox
@interpreter.resolve(expr, depth) @interpreter.resolve(expr, depth)
end end
def resolve_function(fn)
with_scope do
fn.params.each do |param|
declare(param)
define(param)
end
resolve(fn.body)
end
end
end end
end end

Loading…
Cancel
Save