Module: Ionize::Php::Translate::CompositeStringStatements

Included in:
Statements
Defined in:
lib/ionize/translate/composite_string_statements.rb

Instance Method Summary collapse

Instance Method Details

#handle_array_lookup_node(node) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/ionize/translate/composite_string_statements.rb', line 55

def handle_array_lookup_node(node)
  param = if node =~ /(\$.*?)\[(\$.*)\]/
            match = node.match(/(\$.*?)\[(\$.*)\]/)
            [:lvar, match[2].to_s.gsub("$", "").to_sym]
          elsif node =~ /(\$.*?)\[(.*)\]/
            match = node.match(/(\$.*?)\[(.*)\]/)
            [:str, match[2]]
          end
  [:evstr, [:call, transform(:variable => match[1]), :[], [:array, param]]]
end

#handle_array_lookup_within_string(node) ⇒ Object



51
52
53
# File 'lib/ionize/translate/composite_string_statements.rb', line 51

def handle_array_lookup_within_string(node)
  transform(node)
end

#handle_composite_double_string(node) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/ionize/translate/composite_string_statements.rb', line 66

def handle_composite_double_string(node)
  initial = transform(node.first)
  body    = transform(node.second)

  if body.composite_node?
    [:dstr, initial] + body
  else
    [:dstr, initial, body]
  end
end

#handle_double_quoted_string_node(node) ⇒ Object



32
33
34
35
36
37
# File 'lib/ionize/translate/composite_string_statements.rb', line 32

def handle_double_quoted_string_node(node)
  #        puts "double_quoted_string_node #{node.inspect}"
  #        string = eval(node)
  string = node
  (string.empty?) ? nil : [:str, string]
end

#handle_double_string_within_string(node) ⇒ Object



43
44
45
# File 'lib/ionize/translate/composite_string_statements.rb', line 43

def handle_double_string_within_string(node)
  transform(node)
end

#handle_multiple_nodes(node) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ionize/translate/composite_string_statements.rb', line 5

def handle_multiple_nodes(node)
  debug "Multiple nodes #{node.inspect}"

  first  = transform(node.first) 
  second = transform(node.second)

  debug "Multiple nodes results #{first.inspect} #{second.inspect}"
  
  if second.nil?
    first
  elsif second.composite_node?
    if first.composite_node?
      first + second
    else
      [first] + second
    end
  elsif first.composite_node?
    first + [second]
  else
    [first, second]
  end
end

#handle_open_double_quoted_string(node) ⇒ Object



28
29
30
# File 'lib/ionize/translate/composite_string_statements.rb', line 28

def handle_open_double_quoted_string(node)
  node
end

#handle_single_node(node) ⇒ Object



39
40
41
# File 'lib/ionize/translate/composite_string_statements.rb', line 39

def handle_single_node(node)
  transform(node)
end

#handle_variable_within_string(node) ⇒ Object



47
48
49
# File 'lib/ionize/translate/composite_string_statements.rb', line 47

def handle_variable_within_string(node)
  [:evstr, transform(node.first)]
end