Module: Ionize::Php::Translate::SwitchCaseStatements
- Included in:
- Statements
- Defined in:
- lib/ionize/translate/switch_case_statements.rb
Instance Method Summary collapse
- #handle_default_case(node) ⇒ Object
- #handle_line_statement(node) ⇒ Object
- #handle_multi_case(node) ⇒ Object
- #handle_one_case(node) ⇒ Object
- #handle_switch_case_statement(node) ⇒ Object
Instance Method Details
#handle_default_case(node) ⇒ Object
32 33 34 |
# File 'lib/ionize/translate/switch_case_statements.rb', line 32 def handle_default_case(node) transform(node.first) + [transform(node[3]).to_block] end |
#handle_line_statement(node) ⇒ Object
46 47 48 |
# File 'lib/ionize/translate/switch_case_statements.rb', line 46 def handle_line_statement(node) transform(node.first) end |
#handle_multi_case(node) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ionize/translate/switch_case_statements.rb', line 14 def handle_multi_case(node) debug "Multi_case #{node.inspect}" body = transform(node.first) debug "Multi case body #{body.inspect}" result = if body.composite_node? # Example: [:case, [:true]] + [[:when, ... ]] body + [send(:one_case, node[1..-1])] else # Example: [...] + [:when, ... ] [body] + [send(:one_case, node[1..-1])] end debug "Result is #{result.inspect}" result end |
#handle_one_case(node) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/ionize/translate/switch_case_statements.rb', line 36 def handle_one_case(node) case_body = if (result = transform(node[3])).nil? nil else result.to_block end [:when, [:array, transform(node.second)], case_body] end |
#handle_switch_case_statement(node) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/ionize/translate/switch_case_statements.rb', line 5 def handle_switch_case_statement(node) condition = transform(node.third) body = transform(node[5]) debug "Switch case condition #{condition.inspect}" debug "Switch case body #{body.inspect}" [:case, condition] + body end |