Class: WAG::Function
- Inherits:
-
Object
- Object
- WAG::Function
- Includes:
- Encodable, Instructable
- Defined in:
- lib/wag/function.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(label = nil) ⇒ Function
constructor
A new instance of Function.
- #param(label = nil, type) ⇒ Object
- #result(*types) ⇒ Object
- #to_sexpr ⇒ Object
Methods included from Encodable
Methods included from Instructable
#f32, #f64, #i32, #i64, #local, #memory
Constructor Details
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/wag/function.rb', line 8 def label @label end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/wag/function.rb', line 8 def params @params end |
Instance Method Details
#param(label = nil, type) ⇒ Object
15 16 17 |
# File 'lib/wag/function.rb', line 15 def param(label = nil, type) @params.push(WAG::Param.new(type, label)) end |
#result(*types) ⇒ Object
19 20 21 22 23 |
# File 'lib/wag/function.rb', line 19 def result(*types) return @result if types.empty? @result = WAG::Result.new(*types) end |
#to_sexpr ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/wag/function.rb', line 25 def to_sexpr [:func].tap do |func| func.push(@label.to_sexpr) if @label func.concat(@params.map(&:to_sexpr)) unless @params.empty? func.push(@result.to_sexpr) if @result end end |