Class: WLang::Compiler::StaticMerger

Inherits:
Filter
  • Object
show all
Defined in:
lib/wlang/compiler/static_merger.rb

Instance Method Summary collapse

Methods included from Filter::ClassMethods

#recurse_on

Methods included from Filter::InstanceMethods

#recurse

Instance Method Details

#on_strconcat(*exps) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wlang/compiler/static_merger.rb', line 5

def on_strconcat(*exps)
  result = [:strconcat]
  text = nil

  exps.each do |exp|
    if exp.first == :static
      if text
        text << exp.last
      else
        text = exp.last.dup
        result << [:static, text]
      end
    else
      result << compile(exp)
      text = nil
    end
  end

  result
end