reverting ?= optimization, for the repl's sake.

This commit is contained in:
Jeremy Ashkenas
2010-11-01 22:32:04 -04:00
parent 187cda0c39
commit ebbe0babdb
2 changed files with 11 additions and 16 deletions

View File

@@ -882,7 +882,11 @@ exports.Code = class Code extends Base
if param.value then new Op '?', ref, param.value else ref
else
ref = param
exprs.push new Assign new Value(param.name), param.value, '?=' if param.value
if param.value
exprs.push new Op('||',
new Literal("#{param.name.value} != null"),
new Assign(param.name, param.value)
)
vars.push ref unless splats
scope.startLevel()
wasEmpty = @body.isEmpty()
@@ -1084,17 +1088,13 @@ exports.Op = class Op extends Base
if o.level < LEVEL_OP then code else "(#{code})"
compileExistence: (o) ->
if @first.isComplex() and o.level > LEVEL_TOP
if @first.isComplex()
ref = o.scope.freeVariable 'ref'
fst = new Parens new Assign new Literal(ref), @first
else
fst = @first
ref = fst.compile o
if o.level is LEVEL_TOP
end = " || #{@second.compile o, LEVEL_OP}"
else
end = " ? #{ref} : #{@second.compile o, LEVEL_LIST}"
new Existence(fst).compile(o) + end
new Existence(fst).compile(o) + " ? #{ref} : #{ @second.compile o, LEVEL_LIST }"
# Compile a unary **Op**.
compileUnary: (o) ->