 
   # The **IfNode** only compiles into a statement if either of its bodies needs
   # to be a statement. Otherwise a ternary is safe.
-  isStatement: ->
-    @statement or= !!(@tags.statement or @bodyNode().isStatement() or (@elseBody and @elseBodyNode().isStatement()))
+  isStatement: (o) ->
+    @statement or= !!((o and o.top) or @tags.statement or @bodyNode().isStatement(o) or (@elseBody and @elseBodyNode().isStatement(o)))
 
   compileCondition: (o) ->
     (cond.compile(o) for cond in flatten([@condition])).join(' || ')
 
   compileNode: (o) ->
-    if o.top or @isStatement() then @compileStatement(o) else @compileTernary(o)
+    if @isStatement(o) then @compileStatement(o) else @compileTernary(o)
 
   makeReturn: ->
     if @isStatement()

  compileNode: (o) ->
    top  = del o, 'top'
    code = @expression.compile(o)
    if @isStatement()
      return (if top then @tab + code + ';' else code)
    l    = code.length
    code = code.substr(o, l-1) if code.substr(l-1, 1) is ';'

  compileExpression: (node, o) ->
    @tab = o.indent
    compiledNode = node.compile merge o, top: true
    if node.isStatement(o) then compiledNode else "#{@idt()}#{compiledNode};"

# Wrap up the given nodes as an **Expressions**, unless it already happens
# to be one.
