Class: Rlang::Parser::Attr
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Log
included, logger, #logger, logger=
Constructor Details
#initialize(klass, name, wtype = WType::DEFAULT) ⇒ Attr
The name argument can either be the attribute name (e.g. :size) or an ivar name (e.g. :@size)
18
19
20
21
22
23
24
25
26
|
# File 'lib/rlang/parser/attr.rb', line 18
def initialize(klass, name, wtype=WType::DEFAULT)
@klass = klass
@name = name
@ivar = klass.wnode.create_ivar(:"@#{name}", wtype)
@getter = nil
@setter = nil
@export = false
logger.debug "Class attribute #{name} created"
end
|
Instance Attribute Details
Returns the value of attribute getter.
14
15
16
|
# File 'lib/rlang/parser/attr.rb', line 14
def getter
@getter
end
|
Returns the value of attribute ivar.
14
15
16
|
# File 'lib/rlang/parser/attr.rb', line 14
def ivar
@ivar
end
|
Returns the value of attribute klass.
14
15
16
|
# File 'lib/rlang/parser/attr.rb', line 14
def klass
@klass
end
|
Returns the value of attribute name.
14
15
16
|
# File 'lib/rlang/parser/attr.rb', line 14
def name
@name
end
|
Returns the value of attribute setter.
14
15
16
|
# File 'lib/rlang/parser/attr.rb', line 14
def setter
@setter
end
|
Instance Method Details
#attr_accessor ⇒ Object
42
43
44
|
# File 'lib/rlang/parser/attr.rb', line 42
def attr_accessor
[self.attr_reader, self.attr_writer]
end
|
#attr_reader ⇒ Object
28
29
30
31
32
33
|
# File 'lib/rlang/parser/attr.rb', line 28
def attr_reader
@getter = @klass.wnode.find_or_create_method(nil, self.getter_name, :instance, wtype)
@getter.export! if @export
logger.debug "Getter created: #{@getter}"
@getter
end
|
#attr_writer ⇒ Object
35
36
37
38
39
40
|
# File 'lib/rlang/parser/attr.rb', line 35
def attr_writer
@setter = @klass.wnode.find_or_create_method(nil, self.setter_name, :instance, wtype)
@setter.export! if @export
logger.debug "Setter created: #{@setter}"
@setter
end
|
46
47
48
|
# File 'lib/rlang/parser/attr.rb', line 46
def export!
@export = true
end
|
#getter_name ⇒ Object
66
67
68
|
# File 'lib/rlang/parser/attr.rb', line 66
def getter_name
@name
end
|
54
55
56
|
# File 'lib/rlang/parser/attr.rb', line 54
def offset
@ivar.offset
end
|
#setter_name ⇒ Object
70
71
72
|
# File 'lib/rlang/parser/attr.rb', line 70
def setter_name
"#{@name}=".to_sym
end
|
#wasm_name ⇒ Object
74
75
76
|
# File 'lib/rlang/parser/attr.rb', line 74
def wasm_name
"$#{@name}"
end
|
#wasm_type ⇒ Object
78
79
80
|
# File 'lib/rlang/parser/attr.rb', line 78
def wasm_type
self.wtype.wasm_type
end
|
50
51
52
|
# File 'lib/rlang/parser/attr.rb', line 50
def wtype
@ivar.wtype
end
|
#wtype=(wtype) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/rlang/parser/attr.rb', line 58
def wtype=(wtype)
@getter.wtype = wtype if @getter
@setter.wtype = wtype if @setter
@ivar.wtype = wtype
logger.debug "Attr/Getter/Setter/ivar wtype updated : #{@getter}"
end
|