Module: Rubex::AST::Statement::IfBlock::Helper
- Included in:
- Rubex::AST::Statement::IfBlock, Else, Elsif
- Defined in:
- lib/rubex/ast/statement/if_block/helper.rb
Instance Method Summary collapse
- #analyse_statement(local_scope) ⇒ Object
- #generate_code_for_statement(stat, code, local_scope, node) ⇒ Object
Instance Method Details
#analyse_statement(local_scope) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/rubex/ast/statement/if_block/helper.rb', line 6 def analyse_statement(local_scope) @statements.each do |stat| stat.analyse_statement local_scope end @if_tail&.analyse_statement(local_scope) end |
#generate_code_for_statement(stat, code, local_scope, node) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubex/ast/statement/if_block/helper.rb', line 14 def generate_code_for_statement(stat, code, local_scope, node) if stat != 'else' condition = node.expr.c_code(local_scope) expr_condition = node.expr.type.object? ? "RTEST(#{condition})" : condition code << "#{stat} (#{expr_condition}) " else code << stat.to_s end code.block do node.statements.each do |stat| stat.generate_code code, local_scope code.nl end end if stat != 'else' node.if_tail&.generate_code(code, local_scope) end end |