 # scope, and indentation level.
 exports.Base = class Base
 
+  constructor: ->
+    @icedContinuationBlock = null
+
+    # iced AST node flags -- since we make several passes through the
+    # tree setting these bits, we'll actually just flip bits in the nodes,
+    # rather than setting function pointers to YES or NO.
+    @icedLoopFlag        = false
+    @icedNodeFlag        = false
+    @icedGotCpsSplitFlag = false
+    @icedCpsPivotFlag    = false
+    @icedHasAutocbFlag   = false
+    @icedFoundArguments  = false
+    @icedParentAwait     = null
+    @icedCallContinuationFlag = false
+
+  # Common logic for determining whether to wrap this node in a closure before
   compile: (o, lvl) ->
     fragmentsToText @compileToFragments o, lvl
 

    o.level  = lvl if lvl
    node     = @unfoldSoak(o) or this
    node.tab = o.indent
    if o.level is LEVEL_TOP or not node.isStatement(o)
      node.compileNode o
    else
      node.compileClosure o

  # `toString` representation of the node, for inspecting the parse tree.
  # This is what `coffee --nodes` prints out.
  toString: (idt = '', name = @constructor.name) ->
    extras = [] 
    extras.push "A" if @icedNodeFlag
    extras.push "L" if @icedLoopFlag
    extras.push "P" if @icedCpsPivotFlag
    extras.push "C" if @icedHasAutocbFlag
    extras.push "D" if @icedParentAwait
    extras.push "G" if @icedFoundArguments
    if extras.length
      extras = " (" + extras.join('') + ")"
    tree = '\n' + idt + name
    tree = '\n' + idt + name
    tree += '?' if @soak
    tree += extras
    @eachChild (node) -> tree += node.toString idt + TAB
    if @icedContinuationBlock
      idt += TAB
      tree += '\n' + idt + "Continuation"
      tree += @icedContinuationBlock.toString idt + TAB
    tree

  # Passes each child to a function, breaking when the function returns `false`.
