Class: RDL::Type::AnnotatedArgType
- Inherits:
-
Type
show all
- Defined in:
- lib/rdl/types/annotated_arg.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Type
#canonical, leq, #nil_type?, #to_contract
Constructor Details
Note: Named argument types aren’t hashconsed.
10
11
12
13
14
15
16
|
# File 'lib/rdl/types/annotated_arg.rb', line 10
def initialize(name, type)
@name = name
@type = type
raise RuntimeError, "Attempt to create annotated type with non-type" unless type.is_a? Type
raise RuntimeError, "Attempt to create doubly annotated type" if type.is_a? AnnotatedArgType
super()
end
|
Instance Attribute Details
Returns the value of attribute name.
5
6
7
|
# File 'lib/rdl/types/annotated_arg.rb', line 5
def name
@name
end
|
Returns the value of attribute type.
6
7
8
|
# File 'lib/rdl/types/annotated_arg.rb', line 6
def type
@type
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
22
23
24
25
26
|
# File 'lib/rdl/types/annotated_arg.rb', line 22
def ==(other) return false if other.nil?
other = other.canonical
return (other.instance_of? AnnotatedArgType) && (other.name == @name) && (other.type == @type)
end
|
48
49
50
|
# File 'lib/rdl/types/annotated_arg.rb', line 48
def copy
return AnnotatedArgType.new(@name, @type.copy)
end
|
doesn’t have a match method - queries shouldn’t have annotations in them
32
33
34
|
# File 'lib/rdl/types/annotated_arg.rb', line 32
def hash return (57 + @name.hash) * @type.hash
end
|
#instantiate(inst) ⇒ Object
40
41
42
|
# File 'lib/rdl/types/annotated_arg.rb', line 40
def instantiate(inst)
return AnnotatedArgType.new(@name, @type.instantiate(inst))
end
|
#member?(obj, *args) ⇒ Boolean
36
37
38
|
# File 'lib/rdl/types/annotated_arg.rb', line 36
def member?(obj, *args)
@type.member?(obj, *args)
end
|
#optional? ⇒ Boolean
52
53
54
|
# File 'lib/rdl/types/annotated_arg.rb', line 52
def optional?
return type.optional?
end
|
18
19
20
|
# File 'lib/rdl/types/annotated_arg.rb', line 18
def to_s
return "#{@type.to_s} #{@name}"
end
|
#vararg? ⇒ Boolean
56
57
58
|
# File 'lib/rdl/types/annotated_arg.rb', line 56
def vararg?
return type.vararg?
end
|
44
45
46
|
# File 'lib/rdl/types/annotated_arg.rb', line 44
def widen
return AnnotatedArgType.new(@name, @type.widen)
end
|