class Yadriggy::TypeChecker::FreeVarFinder
A type environement that collects free variables. {#bound_name?} records the given symbol as a free variable name when it obtains the type of that symbol from its parent type environment.
Attributes
free_variables[R]
Obtains collected free variables. @return [Hash<Symbol,Type>] a map from variable names to their types.
Public Class Methods
new(parent)
click to toggle source
Calls superclass method
Yadriggy::TypeChecker::TypeEnv::new
# File lib/yadriggy/typecheck.rb, line 110 def initialize(parent) super @free_variables = {} end
Public Instance Methods
bound_name?(name)
click to toggle source
# File lib/yadriggy/typecheck.rb, line 115 def bound_name?(name) type = @names[name.to_sym] if type.nil? t = @parent&.bound_name?(name) @free_variables[name.to_sym] = t unless t.nil? t else type end end