Class: Rlang::Parser::Module
Direct Known Subclasses
Klass
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Log
included, logger, #logger, logger=
Constructor Details
#initialize(const, scope_class) ⇒ Module
Returns a new instance of Module.
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/rlang/parser/module.rb', line 18
def initialize(const, scope_class)
@const = const
logger.debug "scope_class: #{scope_class}"
@const.scope_class = scope_class
@wtype = WType.new(@const.path_name)
@size = 0
@wnode = nil
@super_class = nil
@attrs = [] @ivars = [] @cvars = [] @consts = [] @methods = [] @offset = 0
@modules = [] @includes = [] @prepends = [] @extends = []
@extended = false
@included = false
@prepended = false
@const.value = self
logger.debug "Created Class/Module #{@const} / #{self}"
end
|
Instance Attribute Details
Returns the value of attribute attrs.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def attrs
@attrs
end
|
Returns the value of attribute const.
13
14
15
|
# File 'lib/rlang/parser/module.rb', line 13
def const
@const
end
|
Returns the value of attribute consts.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def consts
@consts
end
|
Returns the value of attribute cvars.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def cvars
@cvars
end
|
Returns the value of attribute extends.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def extends
@extends
end
|
Returns the value of attribute includes.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def includes
@includes
end
|
Returns the value of attribute ivars.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def ivars
@ivars
end
|
Returns the value of attribute methods.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def methods
@methods
end
|
Returns the value of attribute offset.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def offset
@offset
end
|
Returns the value of attribute wnode.
14
15
16
|
# File 'lib/rlang/parser/module.rb', line 14
def wnode
@wnode
end
|
Returns the value of attribute wtype.
13
14
15
|
# File 'lib/rlang/parser/module.rb', line 13
def wtype
@wtype
end
|
Instance Method Details
#ancestors ⇒ Object
100
101
102
103
|
# File 'lib/rlang/parser/module.rb', line 100
def ancestors
@prepends.reverse + [self] + @includes.reverse + @extends.reverse + \
(@super_class ? @super_class.ancestors : [])
end
|
#const_get(name) ⇒ Object
105
106
107
|
# File 'lib/rlang/parser/module.rb', line 105
def const_get(name)
consts.find { |c| c.name == name}
end
|
#delete_class_methods ⇒ Object
113
114
115
|
# File 'lib/rlang/parser/module.rb', line 113
def delete_class_methods
self.methods.select { |m| m.class? }.each { |m| m.wnode.delete!; @methods.delete(m) }
end
|
#delete_instance_methods ⇒ Object
109
110
111
|
# File 'lib/rlang/parser/module.rb', line 109
def delete_instance_methods
@methods.select { |m| m.instance? }.each { |m| m.wnode.delete!; @methods.delete(m) }
end
|
#extend(klass) ⇒ Object
95
96
97
98
|
# File 'lib/rlang/parser/module.rb', line 95
def extend(klass)
@modules |= [klass]
@extends |= [klass]
end
|
#extended! ⇒ Object
135
|
# File 'lib/rlang/parser/module.rb', line 135
def extended!; @extended = true; end
|
#extended? ⇒ Boolean
134
|
# File 'lib/rlang/parser/module.rb', line 134
def extended?; @extended; end
|
#include(klass) ⇒ Object
85
86
87
88
|
# File 'lib/rlang/parser/module.rb', line 85
def include(klass)
@modules |= [klass]
@includes |= [klass]
end
|
#included! ⇒ Object
138
|
# File 'lib/rlang/parser/module.rb', line 138
def included!; @included = true; end
|
#included? ⇒ Boolean
137
|
# File 'lib/rlang/parser/module.rb', line 137
def included?; @included; end
|
61
62
63
|
# File 'lib/rlang/parser/module.rb', line 61
def name
@const.name
end
|
Do not include the top class Object in nesting
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/rlang/parser/module.rb', line 74
def nesting
sk = nil; k = self; n = [k]
while (sk = k.const.scope_class) && (sk != k) && !sk.object_class?
logger.debug "k: #{k.name}/#{k}, sk: #{sk.name}/#{sk}, sk.object_class? #{sk.object_class?}"
n.unshift(sk)
k = sk
end
logger.debug "Class#nesting : #{n.map(&:name)}"
n
end
|
#object_class? ⇒ Boolean
57
58
59
|
# File 'lib/rlang/parser/module.rb', line 57
def object_class?
self.const.name == :Object && self.const.scope_class == self
end
|
65
66
67
|
# File 'lib/rlang/parser/module.rb', line 65
def path
@const.path
end
|
#path_name ⇒ Object
69
70
71
|
# File 'lib/rlang/parser/module.rb', line 69
def path_name
@const.path_name
end
|
#prepend(klass) ⇒ Object
90
91
92
93
|
# File 'lib/rlang/parser/module.rb', line 90
def prepend(klass)
@modules |= [klass]
@prepends |= [klass]
end
|
#prepended! ⇒ Object
141
|
# File 'lib/rlang/parser/module.rb', line 141
def prepended!; @prepended = true; end
|
#prepended? ⇒ Boolean
140
|
# File 'lib/rlang/parser/module.rb', line 140
def prepended?; @prepended; end
|
117
118
119
|
# File 'lib/rlang/parser/module.rb', line 117
def size
@offset
end
|
#wasm_name ⇒ Object
126
127
128
|
# File 'lib/rlang/parser/module.rb', line 126
def wasm_name
@name
end
|
#wasm_type ⇒ Object
130
131
132
|
# File 'lib/rlang/parser/module.rb', line 130
def wasm_type
@wtype.wasm_type
end
|