Class: Rlang::Parser::MEthod
Overview
Note: Cannot use Method as class name because it’s already used by Ruby
Constant Summary
collapse
- METHOD_TYPES =
[:instance, :class]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Log
included, logger, #logger, logger=
Constructor Details
#initialize(name, klass, wtype, method_type) ⇒ MEthod
Returns a new instance of MEthod.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rlang/parser/method.rb', line 22
def initialize(name, klass, wtype, method_type)
raise "Wrong method wtype argument: #{wtype.inspect}" unless wtype.is_a? WType
@name = name
@klass = klass
@wtype = wtype || WType::DEFAULT
@method_type = method_type
raise "Unknown method type: #{method_type}" unless METHOD_TYPES.include? @method_type
@wnode = nil logger.debug "Method created #{name} in class #{klass.name} / ID:#{self}"
@margs = [] @lvars = []
@export_name = nil
end
|
Instance Attribute Details
#export_as ⇒ Object
Returns the value of attribute export_as.
18
19
20
|
# File 'lib/rlang/parser/method.rb', line 18
def export_as
@export_as
end
|
#export_name ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/rlang/parser/method.rb', line 84
def export_name
return @export_name if @export_name
name = @name.to_s.sub(/\[\]/, 'brackets').to_sym
if self.instance?
"#{@klass.path_name.downcase}_i_#{name}"
else
"#{@klass.path_name.downcase}_c_#{name}"
end
end
|
Returns the value of attribute klass.
18
19
20
|
# File 'lib/rlang/parser/method.rb', line 18
def klass
@klass
end
|
Returns the value of attribute lvars.
18
19
20
|
# File 'lib/rlang/parser/method.rb', line 18
def lvars
@lvars
end
|
Returns the value of attribute margs.
18
19
20
|
# File 'lib/rlang/parser/method.rb', line 18
def margs
@margs
end
|
#method_type ⇒ Object
Returns the value of attribute method_type.
16
17
18
|
# File 'lib/rlang/parser/method.rb', line 16
def method_type
@method_type
end
|
Returns the value of attribute name.
16
17
18
|
# File 'lib/rlang/parser/method.rb', line 16
def name
@name
end
|
Returns the value of attribute wnode.
16
17
18
|
# File 'lib/rlang/parser/method.rb', line 16
def wnode
@wnode
end
|
Returns the value of attribute wtype.
16
17
18
|
# File 'lib/rlang/parser/method.rb', line 16
def wtype
@wtype
end
|
Instance Method Details
57
58
59
|
# File 'lib/rlang/parser/method.rb', line 57
def class!
@method_type = :class
end
|
#class? ⇒ Boolean
61
62
63
|
# File 'lib/rlang/parser/method.rb', line 61
def class?
@method_type == :class
end
|
#export!(export_name = nil) ⇒ Object
103
104
105
106
|
# File 'lib/rlang/parser/method.rb', line 103
def export!(export_name=nil)
@export_name = export_name
Export.new(self)
end
|
#export_wasm_code ⇒ Object
108
109
110
|
# File 'lib/rlang/parser/method.rb', line 108
def export_wasm_code
'(export "%s" (func %s))' % [self.export_name, self.wasm_name]
end
|
#implemented? ⇒ Boolean
44
45
46
|
# File 'lib/rlang/parser/method.rb', line 44
def implemented?
!@wnode.nil?
end
|
#imported! ⇒ Object
95
96
97
|
# File 'lib/rlang/parser/method.rb', line 95
def imported!
@imported = true
end
|
#imported? ⇒ Boolean
99
100
101
|
# File 'lib/rlang/parser/method.rb', line 99
def imported?
@imported
end
|
#instance! ⇒ Object
48
49
50
|
# File 'lib/rlang/parser/method.rb', line 48
def instance!
@method_type = :instance
end
|
#instance? ⇒ Boolean
52
53
54
55
|
# File 'lib/rlang/parser/method.rb', line 52
def instance?
@method_type == :instance
end
|
#wasm_name ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'lib/rlang/parser/method.rb', line 70
def wasm_name
name = @name.to_s.sub(/\[\]/, 'brackets').to_sym
if self.instance?
"$#{@klass.path_name}##{name}"
else
"$#{@klass.path_name}::#{name}"
end
end
|
#wasm_type ⇒ Object
80
81
82
|
# File 'lib/rlang/parser/method.rb', line 80
def wasm_type
@wtype.wasm_type
end
|