Class: Steep::AST::Types::Name::Applying
Instance Attribute Summary collapse
Attributes inherited from Base
#location, #name
Instance Method Summary
collapse
#level_of_children
Constructor Details
#initialize(name:, args:, location: nil) ⇒ Applying
Returns a new instance of Applying.
30
31
32
33
|
# File 'lib/steep/ast/types/name.rb', line 30
def initialize(name:, args:, location: nil)
super(name: name, location: location)
@args = args
end
|
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
28
29
30
|
# File 'lib/steep/ast/types/name.rb', line 28
def args
@args
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
35
36
37
38
39
|
# File 'lib/steep/ast/types/name.rb', line 35
def ==(other)
other.class == self.class &&
other.name == name &&
other.args == args
end
|
#free_variables ⇒ Object
65
66
67
68
69
|
# File 'lib/steep/ast/types/name.rb', line 65
def free_variables
args.each.with_object(Set.new) do |type, vars|
vars.merge(type.free_variables)
end
end
|
#hash ⇒ Object
43
44
45
|
# File 'lib/steep/ast/types/name.rb', line 43
def hash
self.class.hash ^ name.hash ^ args.hash
end
|
#level ⇒ Object
73
74
75
|
# File 'lib/steep/ast/types/name.rb', line 73
def level
[0] + level_of_children(args)
end
|
#subst(s) ⇒ Object
59
60
61
62
63
|
# File 'lib/steep/ast/types/name.rb', line 59
def subst(s)
self.class.new(location: location,
name: name,
args: args.map {|a| a.subst(s) })
end
|
#to_s ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/steep/ast/types/name.rb', line 47
def to_s
if args.empty?
"#{name}"
else
"#{name}[#{args.join(", ")}]"
end
end
|
#with_location(new_location) ⇒ Object
55
56
57
|
# File 'lib/steep/ast/types/name.rb', line 55
def with_location(new_location)
self.class.new(name: name, args: args, location: new_location)
end
|