Class: SFRP::Low::Function
Defined Under Namespace
Classes: Param
Instance Method Summary collapse
-
#initialize(static, name_str, type_str, params, stmts) ⇒ Function
constructor
A new instance of Function.
- #pretty_code ⇒ Object
- #pretty_code_prototype ⇒ Object
- #static? ⇒ Boolean
Methods inherited from Element
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_code ⇒ Object
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_prototype ⇒ Object
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
44 45 46 |
# File 'lib/sfrp/low/element.rb', line 44 def static? @static end |