lib/minjs/ecma262/exp.rb in minjs-0.1.10 vs lib/minjs/ecma262/exp.rb in minjs-0.2.0
- old
+ new
@@ -425,21 +425,23 @@
@name = name
@args = args
end
def priority
- PRIORITY_LEFT_HAND_SIDE + ((args && args.length == 0) ? 1 : 0)
+ PRIORITY_LEFT_HAND_SIDE + ((args == nil) ? 1 : 0)
end
def deep_dup
self.class.new(@name,
@args ? @args.collect{|x| x.deep_dup} : nil)
end
def replace(from, to)
if @name .eql? from
@name = from
+ elsif @args .eql? from
+ @args = to
elsif @args and (idx = @args.index(from))
@args[idx] = to
end
end
@@ -456,10 +458,11 @@
def ==(obj)
self.class == obj.class and @name == obj.name and @args == obj.args
end
def to_js(options = {})
- if @args and @args.length > 0
+ #TODO => simple_replacement
+ if @args# and @args.length > 0
args = @args.collect{|x| x.to_js(options)}.join(",")
concat options, :new, @name, '(', args, ')'
else
concat options, :new, @name
end