Class: SFRP::Poly::DSL::FuncProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/sfrp/poly/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(func_str, ret_type_annot = nil) ⇒ FuncProxy

Returns a new instance of FuncProxy.



84
85
86
87
88
89
# File 'lib/sfrp/poly/dsl.rb', line 84

def initialize(func_str, ret_type_annot = nil)
  @func_str = func_str
  @ret_type_annot = ret_type_annot || DSL.tv('%a0')
  @param_strs = []
  @type_annots = []
end

Instance Method Details

#exp(&block) ⇒ Object



100
101
102
# File 'lib/sfrp/poly/dsl.rb', line 100

def exp(&block)
  @exp = block.call
end

#ffi_str(str) ⇒ Object



96
97
98
# File 'lib/sfrp/poly/dsl.rb', line 96

def ffi_str(str)
  @ffi_str = str
end

#param(param_str, type_annot = nil) ⇒ Object



91
92
93
94
# File 'lib/sfrp/poly/dsl.rb', line 91

def param(param_str, type_annot = nil)
  @param_strs << param_str
  @type_annots << (type_annot || DSL.tv('%a' + @param_strs.size.to_s))
end

#to_funcObject



104
105
106
107
# File 'lib/sfrp/poly/dsl.rb', line 104

def to_func
  ftype_annot = FuncTypeAnnotation.new(@ret_type_annot, @type_annots)
  Function.new(@func_str, @param_strs, ftype_annot, @exp, @ffi_str)
end