Class: SFRP::Low::Function

Inherits:
Element
  • Object
show all
Defined in:
lib/sfrp/low/element.rb

Defined Under Namespace

Classes: Param

Instance Method Summary collapse

Methods inherited from Element

#to_s

Constructor Details

#initialize(static, name_str, type_str, params, stmts) ⇒ Function

Returns a new instance of Function.



36
37
38
39
40
41
42
# File 'lib/sfrp/low/element.rb', line 36

def initialize(static, name_str, type_str, params, stmts)
  @static = static
  @name_str = name_str
  @type_str = type_str
  @params = params
  @stmts = stmts
end

Instance Method Details

#pretty_codeObject



48
49
50
51
52
# File 'lib/sfrp/low/element.rb', line 48

def pretty_code
  inner = @stmts.map { |s| s.pretty_code(1) + "\n" }.join
  param = @params.map { |pa| "#{pa.type_str} #{pa.var_str}" }.join(', ')
  "#{@type_str} #{@name_str}(#{param}) {\n#{inner}}"
end

#pretty_code_prototypeObject



54
55
56
# File 'lib/sfrp/low/element.rb', line 54

def pretty_code_prototype
  "#{@type_str} #{@name_str}(#{@params.map(&:type_str).join(', ')});"
end

#static?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/sfrp/low/element.rb', line 44

def static?
  @static
end