 exports.SliceNode: class SliceNode extends BaseNode
   type: 'Slice'
 
-  code: '''
+  slice_code: '''
         function __slice(array, from, to, exclusive) {
             return array.slice(
               (from < 0 ? from + array.length : from || 0),

    soaked:   false
    only:     del(o, 'only_first')
    op:       del(o, 'operation')
    props:    if only then @properties[0...@properties.length - 1] else @properties
    baseline: @base.compile o
    baseline: "($baseline)" if @base instanceof ObjectNode and @has_properties()

          }
        '''

  splice_code: '''
        function __splice(array, from, to, exclusive, replace) {
            var _a;
            return array.splice.apply(
              array,
              [_a = (from < 0 ? from + array.length : from || 0), (to < 0 ? to + array.length : to || array.length) + (exclusive ? 0 : 1) - _a].concat(replace)
            );
          }
        '''

  constructor: (range) ->
    @children: [@range: range]
    this

  compile_node: (o) ->
    from:       @range.from.compile(o)
    to:         @range.to.compile(o)
    plus_part:  if @range.exclusive then '' else ' + 1'
    ".slice($from, $to$plus_part)"

  compile_splice: (o) ->
    o.scope.assign('__splice', @splice_code, true) if o.scope?
    array:      del o, 'array'
    replace:    del o, 'replace'
    from:       if @range.from? then @range.from else literal('null')
    to:         if @range.to? then @range.to else literal('null')
    exclusive:  if @range.exclusive then 'true' else 'false'
    ref:        new ValueNode literal('__splice')
    call:       new CallNode ref, [literal(array), from, to, literal(exclusive), replace]
    call.compile(o)

  compile_slice: (o) ->
    o.scope.assign('__slice', @slice_code, true) if o.scope?
    array:      del o, 'array'
    from:       if @range.from? then @range.from else literal('null')
    to:         if @range.to? then @range.to else literal('null')
