Sha256: d7512d611c8c73ded567339508f42df1c15bb13a55cca2c56ae9a6c703037288
Contents?: true
Size: 1.15 KB
Versions: 29
Compression:
Stored size: 1.15 KB
Contents
module Ruby2JS class Converter # (lvasgn :a # (int 1)) # (gvasgn :$a # (int 1)) handle :lvasgn, :gvasgn do |name, value=nil| state = @state begin if value and value.type == :lvasgn and @state == :statement undecls = [] undecls << name unless @vars.include? name child = value while child and child.type == :lvasgn undecls << child.children[0] unless @vars.include? child.children[0] child = child.children[1] end unless undecls.empty? return parse s(:begin, *undecls.map {|uname| s(:lvasgn, uname)}, @ast), @state end end if state == :statement and @scope and not @vars.include?(name) var = 'var ' end if value put "#{ var }#{ name } = "; parse value else put "#{ var }#{ name }" end ensure if @scope @vars[name] = true elsif state == :statement @vars[name] ||= :pending else @vars[name] ||= :implicit # console, document, ... end end end end end
Version data entries
29 entries across 29 versions & 1 rubygems