class WAG::Function
Attributes
label[R]
params[R]
Public Class Methods
new(label = nil)
click to toggle source
# File lib/wag/function.rb, line 10 def initialize(label = nil) @label = WAG::Label.from(label) if label @params = [] end
Public Instance Methods
param(label = nil, type)
click to toggle source
# File lib/wag/function.rb, line 15 def param(label = nil, type) @params.push(WAG::Param.new(type, label)) end
result(*types)
click to toggle source
# File lib/wag/function.rb, line 19 def result(*types) return @result if types.empty? @result = WAG::Result.new(*types) end
to_sexpr()
click to toggle source
# 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