cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject [11/15] pre-compile CoffeeScript files in server
Date Thu, 04 Sep 2014 12:37:13 GMT
http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/03084bdb/weinre.server/node_modules/coffee-script/lib/coffee-script/nodes.js
----------------------------------------------------------------------
diff --git a/weinre.server/node_modules/coffee-script/lib/coffee-script/nodes.js b/weinre.server/node_modules/coffee-script/lib/coffee-script/nodes.js
index 799b68e..52c99a9 100644
--- a/weinre.server/node_modules/coffee-script/lib/coffee-script/nodes.js
+++ b/weinre.server/node_modules/coffee-script/lib/coffee-script/nodes.js
@@ -1,18 +1,23 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.8.0
 (function() {
-  var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref, _ref1,
+  var Access, Arr, Assign, Base, Block, Call, Class, Code, CodeFragment, Comment, Existence, Expansion, Extends, For, HEXNUM, IDENTIFIER, IDENTIFIER_STR, IS_REGEX, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, NUMBER, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isLiteralArguments, isLiteralThis, last, locationDataToString, merge, multident, parseNum, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1,
     __hasProp = {}.hasOwnProperty,
     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
-    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
+    __slice = [].slice;
+
+  Error.stackTraceLimit = Infinity;
 
   Scope = require('./scope').Scope;
 
   _ref = require('./lexer'), RESERVED = _ref.RESERVED, STRICT_PROSCRIBED = _ref.STRICT_PROSCRIBED;
 
-  _ref1 = require('./helpers'), compact = _ref1.compact, flatten = _ref1.flatten, extend = _ref1.extend, merge = _ref1.merge, del = _ref1.del, starts = _ref1.starts, ends = _ref1.ends, last = _ref1.last;
+  _ref1 = require('./helpers'), compact = _ref1.compact, flatten = _ref1.flatten, extend = _ref1.extend, merge = _ref1.merge, del = _ref1.del, starts = _ref1.starts, ends = _ref1.ends, last = _ref1.last, some = _ref1.some, addLocationDataFn = _ref1.addLocationDataFn, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError;
 
   exports.extend = extend;
 
+  exports.addLocationDataFn = addLocationDataFn;
+
   YES = function() {
     return true;
   };
@@ -30,11 +35,43 @@
     return this;
   };
 
-  exports.Base = Base = (function() {
+  exports.CodeFragment = CodeFragment = (function() {
+    function CodeFragment(parent, code) {
+      var _ref2;
+      this.code = "" + code;
+      this.locationData = parent != null ? parent.locationData : void 0;
+      this.type = (parent != null ? (_ref2 = parent.constructor) != null ? _ref2.name : void 0 : void 0) || 'unknown';
+    }
 
+    CodeFragment.prototype.toString = function() {
+      return "" + this.code + (this.locationData ? ": " + locationDataToString(this.locationData) : '');
+    };
+
+    return CodeFragment;
+
+  })();
+
+  fragmentsToText = function(fragments) {
+    var fragment;
+    return ((function() {
+      var _i, _len, _results;
+      _results = [];
+      for (_i = 0, _len = fragments.length; _i < _len; _i++) {
+        fragment = fragments[_i];
+        _results.push(fragment.code);
+      }
+      return _results;
+    })()).join('');
+  };
+
+  exports.Base = Base = (function() {
     function Base() {}
 
     Base.prototype.compile = function(o, lvl) {
+      return fragmentsToText(this.compileToFragments(o, lvl));
+    };
+
+    Base.prototype.compileToFragments = function(o, lvl) {
       var node;
       o = extend({}, o);
       if (lvl) {
@@ -50,36 +87,44 @@
     };
 
     Base.prototype.compileClosure = function(o) {
-      if (this.jumps()) {
-        throw SyntaxError('cannot use a pure statement in an expression.');
+      var args, argumentsNode, func, jumpNode, meth;
+      if (jumpNode = this.jumps()) {
+        jumpNode.error('cannot use a pure statement in an expression');
       }
       o.sharedScope = true;
-      return Closure.wrap(this).compileNode(o);
+      func = new Code([], Block.wrap([this]));
+      args = [];
+      if ((argumentsNode = this.contains(isLiteralArguments)) || this.contains(isLiteralThis)) {
+        args = [new Literal('this')];
+        if (argumentsNode) {
+          meth = 'apply';
+          args.push(new Literal('arguments'));
+        } else {
+          meth = 'call';
+        }
+        func = new Value(func, [new Access(new Literal(meth))]);
+      }
+      return (new Call(func, args)).compileNode(o);
     };
 
     Base.prototype.cache = function(o, level, reused) {
       var ref, sub;
       if (!this.isComplex()) {
-        ref = level ? this.compile(o, level) : this;
+        ref = level ? this.compileToFragments(o, level) : this;
         return [ref, ref];
       } else {
         ref = new Literal(reused || o.scope.freeVariable('ref'));
         sub = new Assign(ref, this);
         if (level) {
-          return [sub.compile(o, level), ref.value];
+          return [sub.compileToFragments(o, level), [this.makeCode(ref.value)]];
         } else {
           return [sub, ref];
         }
       }
     };
 
-    Base.prototype.compileLoopReference = function(o, name) {
-      var src, tmp;
-      src = tmp = this.compile(o, LEVEL_LIST);
-      if (!((-Infinity < +src && +src < Infinity) || IDENTIFIER.test(src) && o.scope.check(src, true))) {
-        src = "" + (tmp = o.scope.freeVariable(name)) + " = " + src;
-      }
-      return [src, tmp];
+    Base.prototype.cacheToCodeFragments = function(cacheValues) {
+      return [fragmentsToText(cacheValues[0]), fragmentsToText(cacheValues[1])];
     };
 
     Base.prototype.makeReturn = function(res) {
@@ -93,21 +138,15 @@
     };
 
     Base.prototype.contains = function(pred) {
-      var contains;
-      contains = false;
-      this.traverseChildren(false, function(node) {
-        if (pred(node)) {
-          contains = true;
+      var node;
+      node = void 0;
+      this.traverseChildren(false, function(n) {
+        if (pred(n)) {
+          node = n;
           return false;
         }
       });
-      return contains;
-    };
-
-    Base.prototype.containsType = function(type) {
-      return this instanceof type || this.contains(function(node) {
-        return node instanceof type;
-      });
+      return node;
     };
 
     Base.prototype.lastNonComment = function(list) {
@@ -162,10 +201,11 @@
 
     Base.prototype.traverseChildren = function(crossScope, func) {
       return this.eachChild(function(child) {
-        if (func(child) === false) {
-          return false;
+        var recur;
+        recur = func(child);
+        if (recur !== false) {
+          return child.traverseChildren(crossScope, func);
         }
-        return child.traverseChildren(crossScope, func);
       });
     };
 
@@ -200,12 +240,46 @@
 
     Base.prototype.assigns = NO;
 
+    Base.prototype.updateLocationDataIfMissing = function(locationData) {
+      if (this.locationData) {
+        return this;
+      }
+      this.locationData = locationData;
+      return this.eachChild(function(child) {
+        return child.updateLocationDataIfMissing(locationData);
+      });
+    };
+
+    Base.prototype.error = function(message) {
+      return throwSyntaxError(message, this.locationData);
+    };
+
+    Base.prototype.makeCode = function(code) {
+      return new CodeFragment(this, code);
+    };
+
+    Base.prototype.wrapInBraces = function(fragments) {
+      return [].concat(this.makeCode('('), fragments, this.makeCode(')'));
+    };
+
+    Base.prototype.joinFragmentArrays = function(fragmentsList, joinStr) {
+      var answer, fragments, i, _i, _len;
+      answer = [];
+      for (i = _i = 0, _len = fragmentsList.length; _i < _len; i = ++_i) {
+        fragments = fragmentsList[i];
+        if (i) {
+          answer.push(this.makeCode(joinStr));
+        }
+        answer = answer.concat(fragments);
+      }
+      return answer;
+    };
+
     return Base;
 
   })();
 
   exports.Block = Block = (function(_super) {
-
     __extends(Block, _super);
 
     function Block(nodes) {
@@ -253,12 +327,12 @@
     };
 
     Block.prototype.jumps = function(o) {
-      var exp, _i, _len, _ref2;
+      var exp, jumpNode, _i, _len, _ref2;
       _ref2 = this.expressions;
       for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
         exp = _ref2[_i];
-        if (exp.jumps(o)) {
-          return exp;
+        if (jumpNode = exp.jumps(o)) {
+          return jumpNode;
         }
       }
     };
@@ -279,72 +353,79 @@
       return this;
     };
 
-    Block.prototype.compile = function(o, level) {
+    Block.prototype.compileToFragments = function(o, level) {
       if (o == null) {
         o = {};
       }
       if (o.scope) {
-        return Block.__super__.compile.call(this, o, level);
+        return Block.__super__.compileToFragments.call(this, o, level);
       } else {
         return this.compileRoot(o);
       }
     };
 
     Block.prototype.compileNode = function(o) {
-      var code, codes, node, top, _i, _len, _ref2;
+      var answer, compiledNodes, fragments, index, node, top, _i, _len, _ref2;
       this.tab = o.indent;
       top = o.level === LEVEL_TOP;
-      codes = [];
+      compiledNodes = [];
       _ref2 = this.expressions;
-      for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
-        node = _ref2[_i];
+      for (index = _i = 0, _len = _ref2.length; _i < _len; index = ++_i) {
+        node = _ref2[index];
         node = node.unwrapAll();
         node = node.unfoldSoak(o) || node;
         if (node instanceof Block) {
-          codes.push(node.compileNode(o));
+          compiledNodes.push(node.compileNode(o));
         } else if (top) {
           node.front = true;
-          code = node.compile(o);
+          fragments = node.compileToFragments(o);
           if (!node.isStatement(o)) {
-            code = "" + this.tab + code + ";";
-            if (node instanceof Literal) {
-              code = "" + code + "\n";
-            }
+            fragments.unshift(this.makeCode("" + this.tab));
+            fragments.push(this.makeCode(";"));
           }
-          codes.push(code);
+          compiledNodes.push(fragments);
         } else {
-          codes.push(node.compile(o, LEVEL_LIST));
+          compiledNodes.push(node.compileToFragments(o, LEVEL_LIST));
         }
       }
       if (top) {
         if (this.spaced) {
-          return "\n" + (codes.join('\n\n')) + "\n";
+          return [].concat(this.joinFragmentArrays(compiledNodes, '\n\n'), this.makeCode("\n"));
         } else {
-          return codes.join('\n');
+          return this.joinFragmentArrays(compiledNodes, '\n');
         }
       }
-      code = codes.join(', ') || 'void 0';
-      if (codes.length > 1 && o.level >= LEVEL_LIST) {
-        return "(" + code + ")";
+      if (compiledNodes.length) {
+        answer = this.joinFragmentArrays(compiledNodes, ', ');
+      } else {
+        answer = [this.makeCode("void 0")];
+      }
+      if (compiledNodes.length > 1 && o.level >= LEVEL_LIST) {
+        return this.wrapInBraces(answer);
       } else {
-        return code;
+        return answer;
       }
     };
 
     Block.prototype.compileRoot = function(o) {
-      var code, exp, i, prelude, preludeExps, rest;
+      var exp, fragments, i, name, prelude, preludeExps, rest, _i, _len, _ref2;
       o.indent = o.bare ? '' : TAB;
-      o.scope = new Scope(null, this, null);
       o.level = LEVEL_TOP;
       this.spaced = true;
-      prelude = "";
+      o.scope = new Scope(null, this, null);
+      _ref2 = o.locals || [];
+      for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+        name = _ref2[_i];
+        o.scope.parameter(name);
+      }
+      prelude = [];
       if (!o.bare) {
         preludeExps = (function() {
-          var _i, _len, _ref2, _results;
-          _ref2 = this.expressions;
+          var _j, _len1, _ref3, _results;
+          _ref3 = this.expressions;
           _results = [];
-          for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
-            exp = _ref2[i];
+          for (i = _j = 0, _len1 = _ref3.length; _j < _len1; i = ++_j) {
+            exp = _ref3[i];
             if (!(exp.unwrap() instanceof Comment)) {
               break;
             }
@@ -355,22 +436,24 @@
         rest = this.expressions.slice(preludeExps.length);
         this.expressions = preludeExps;
         if (preludeExps.length) {
-          prelude = "" + (this.compileNode(merge(o, {
+          prelude = this.compileNode(merge(o, {
             indent: ''
-          }))) + "\n";
+          }));
+          prelude.push(this.makeCode("\n"));
         }
         this.expressions = rest;
       }
-      code = this.compileWithDeclarations(o);
+      fragments = this.compileWithDeclarations(o);
       if (o.bare) {
-        return code;
+        return fragments;
       }
-      return "" + prelude + "(function() {\n" + code + "\n}).call(this);\n";
+      return [].concat(prelude, this.makeCode("(function() {\n"), fragments, this.makeCode("\n}).call(this);\n"));
     };
 
     Block.prototype.compileWithDeclarations = function(o) {
-      var assigns, code, declars, exp, i, post, rest, scope, spaced, _i, _len, _ref2, _ref3, _ref4;
-      code = post = '';
+      var assigns, declars, exp, fragments, i, post, rest, scope, spaced, _i, _len, _ref2, _ref3, _ref4;
+      fragments = [];
+      post = [];
       _ref2 = this.expressions;
       for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
         exp = _ref2[i];
@@ -385,7 +468,7 @@
       if (i) {
         rest = this.expressions.splice(i, 9e9);
         _ref3 = [this.spaced, false], spaced = _ref3[0], this.spaced = _ref3[1];
-        _ref4 = [this.compileNode(o), spaced], code = _ref4[0], this.spaced = _ref4[1];
+        _ref4 = [this.compileNode(o), spaced], fragments = _ref4[0], this.spaced = _ref4[1];
         this.expressions = rest;
       }
       post = this.compileNode(o);
@@ -395,22 +478,24 @@
         assigns = scope.hasAssignments;
         if (declars || assigns) {
           if (i) {
-            code += '\n';
+            fragments.push(this.makeCode('\n'));
           }
-          code += "" + this.tab + "var ";
+          fragments.push(this.makeCode("" + this.tab + "var "));
           if (declars) {
-            code += scope.declaredVariables().join(', ');
+            fragments.push(this.makeCode(scope.declaredVariables().join(', ')));
           }
           if (assigns) {
             if (declars) {
-              code += ",\n" + (this.tab + TAB);
+              fragments.push(this.makeCode(",\n" + (this.tab + TAB)));
             }
-            code += scope.assignedVariables().join(",\n" + (this.tab + TAB));
+            fragments.push(this.makeCode(scope.assignedVariables().join(",\n" + (this.tab + TAB))));
           }
-          code += ';\n';
+          fragments.push(this.makeCode(";\n" + (this.spaced ? '\n' : '')));
+        } else if (fragments.length && post.length) {
+          fragments.push(this.makeCode("\n"));
         }
       }
-      return code + post;
+      return fragments.concat(post);
     };
 
     Block.wrap = function(nodes) {
@@ -425,7 +510,6 @@
   })(Base);
 
   exports.Literal = Literal = (function(_super) {
-
     __extends(Literal, _super);
 
     function Literal(value) {
@@ -465,13 +549,10 @@
     };
 
     Literal.prototype.compileNode = function(o) {
-      var code, _ref2;
+      var answer, code, _ref2;
       code = this.value === 'this' ? ((_ref2 = o.scope.method) != null ? _ref2.bound : void 0) ? o.scope.method.context : this.value : this.value.reserved ? "\"" + this.value + "\"" : this.value;
-      if (this.isStatement()) {
-        return "" + this.tab + code + ";";
-      } else {
-        return code;
-      }
+      answer = this.isStatement() ? "" + this.tab + code + ";" : code;
+      return [this.makeCode(answer)];
     };
 
     Literal.prototype.toString = function() {
@@ -483,7 +564,6 @@
   })(Base);
 
   exports.Undefined = (function(_super) {
-
     __extends(Undefined, _super);
 
     function Undefined() {
@@ -495,11 +575,7 @@
     Undefined.prototype.isComplex = NO;
 
     Undefined.prototype.compileNode = function(o) {
-      if (o.level >= LEVEL_ACCESS) {
-        return '(void 0)';
-      } else {
-        return 'void 0';
-      }
+      return [this.makeCode(o.level >= LEVEL_ACCESS ? '(void 0)' : 'void 0')];
     };
 
     return Undefined;
@@ -507,7 +583,6 @@
   })(Base);
 
   exports.Null = (function(_super) {
-
     __extends(Null, _super);
 
     function Null() {
@@ -519,7 +594,7 @@
     Null.prototype.isComplex = NO;
 
     Null.prototype.compileNode = function() {
-      return "null";
+      return [this.makeCode("null")];
     };
 
     return Null;
@@ -527,7 +602,6 @@
   })(Base);
 
   exports.Bool = (function(_super) {
-
     __extends(Bool, _super);
 
     Bool.prototype.isAssignable = NO;
@@ -535,7 +609,7 @@
     Bool.prototype.isComplex = NO;
 
     Bool.prototype.compileNode = function() {
-      return this.val;
+      return [this.makeCode(this.val)];
     };
 
     function Bool(val) {
@@ -547,13 +621,10 @@
   })(Base);
 
   exports.Return = Return = (function(_super) {
-
     __extends(Return, _super);
 
-    function Return(expr) {
-      if (expr && !expr.unwrap().isUndefined) {
-        this.expression = expr;
-      }
+    function Return(expression) {
+      this.expression = expression;
     }
 
     Return.prototype.children = ['expression'];
@@ -564,18 +635,25 @@
 
     Return.prototype.jumps = THIS;
 
-    Return.prototype.compile = function(o, level) {
+    Return.prototype.compileToFragments = function(o, level) {
       var expr, _ref2;
       expr = (_ref2 = this.expression) != null ? _ref2.makeReturn() : void 0;
       if (expr && !(expr instanceof Return)) {
-        return expr.compile(o, level);
+        return expr.compileToFragments(o, level);
       } else {
-        return Return.__super__.compile.call(this, o, level);
+        return Return.__super__.compileToFragments.call(this, o, level);
       }
     };
 
     Return.prototype.compileNode = function(o) {
-      return this.tab + ("return" + [this.expression ? " " + (this.expression.compile(o, LEVEL_PAREN)) : void 0] + ";");
+      var answer;
+      answer = [];
+      answer.push(this.makeCode(this.tab + ("return" + (this.expression ? " " : ""))));
+      if (this.expression) {
+        answer = answer.concat(this.expression.compileToFragments(o, LEVEL_PAREN));
+      }
+      answer.push(this.makeCode(";"));
+      return answer;
     };
 
     return Return;
@@ -583,7 +661,6 @@
   })(Base);
 
   exports.Value = Value = (function(_super) {
-
     __extends(Value, _super);
 
     function Value(base, props, tag) {
@@ -609,8 +686,16 @@
       return !!this.properties.length;
     };
 
+    Value.prototype.bareLiteral = function(type) {
+      return !this.properties.length && this.base instanceof type;
+    };
+
     Value.prototype.isArray = function() {
-      return !this.properties.length && this.base instanceof Arr;
+      return this.bareLiteral(Arr);
+    };
+
+    Value.prototype.isRange = function() {
+      return this.bareLiteral(Range);
     };
 
     Value.prototype.isComplex = function() {
@@ -622,11 +707,15 @@
     };
 
     Value.prototype.isSimpleNumber = function() {
-      return this.base instanceof Literal && SIMPLENUM.test(this.base.value);
+      return this.bareLiteral(Literal) && SIMPLENUM.test(this.base.value);
     };
 
     Value.prototype.isString = function() {
-      return this.base instanceof Literal && IS_STRING.test(this.base.value);
+      return this.bareLiteral(Literal) && IS_STRING.test(this.base.value);
+    };
+
+    Value.prototype.isRegex = function() {
+      return this.bareLiteral(Literal) && IS_REGEX.test(this.base.value);
     };
 
     Value.prototype.isAtomic = function() {
@@ -641,6 +730,10 @@
       return true;
     };
 
+    Value.prototype.isNotCallable = function() {
+      return this.isSimpleNumber() || this.isString() || this.isRegex() || this.isArray() || this.isRange() || this.isSplice() || this.isObject();
+    };
+
     Value.prototype.isStatement = function(o) {
       return !this.properties.length && this.base.isStatement(o);
     };
@@ -664,6 +757,11 @@
       return last(this.properties) instanceof Slice;
     };
 
+    Value.prototype.looksStatic = function(className) {
+      var _ref2;
+      return this.base.value === className && this.properties.length && ((_ref2 = this.properties[0].name) != null ? _ref2.value : void 0) !== 'prototype';
+    };
+
     Value.prototype.unwrap = function() {
       if (this.properties.length) {
         return this;
@@ -695,53 +793,49 @@
     };
 
     Value.prototype.compileNode = function(o) {
-      var code, prop, props, _i, _len;
+      var fragments, prop, props, _i, _len;
       this.base.front = this.front;
       props = this.properties;
-      code = this.base.compile(o, props.length ? LEVEL_ACCESS : null);
-      if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(code)) {
-        code = "" + code + ".";
+      fragments = this.base.compileToFragments(o, (props.length ? LEVEL_ACCESS : null));
+      if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(fragmentsToText(fragments))) {
+        fragments.push(this.makeCode('.'));
       }
       for (_i = 0, _len = props.length; _i < _len; _i++) {
         prop = props[_i];
-        code += prop.compile(o);
+        fragments.push.apply(fragments, prop.compileToFragments(o));
       }
-      return code;
+      return fragments;
     };
 
     Value.prototype.unfoldSoak = function(o) {
-      var result,
-        _this = this;
-      if (this.unfoldedSoak != null) {
-        return this.unfoldedSoak;
-      }
-      result = (function() {
-        var fst, i, ifn, prop, ref, snd, _i, _len, _ref2;
-        if (ifn = _this.base.unfoldSoak(o)) {
-          Array.prototype.push.apply(ifn.body.properties, _this.properties);
-          return ifn;
-        }
-        _ref2 = _this.properties;
-        for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
-          prop = _ref2[i];
-          if (!prop.soak) {
-            continue;
+      return this.unfoldedSoak != null ? this.unfoldedSoak : this.unfoldedSoak = (function(_this) {
+        return function() {
+          var fst, i, ifn, prop, ref, snd, _i, _len, _ref2, _ref3;
+          if (ifn = _this.base.unfoldSoak(o)) {
+            (_ref2 = ifn.body.properties).push.apply(_ref2, _this.properties);
+            return ifn;
           }
-          prop.soak = false;
-          fst = new Value(_this.base, _this.properties.slice(0, i));
-          snd = new Value(_this.base, _this.properties.slice(i));
-          if (fst.isComplex()) {
-            ref = new Literal(o.scope.freeVariable('ref'));
-            fst = new Parens(new Assign(ref, fst));
-            snd.base = ref;
+          _ref3 = _this.properties;
+          for (i = _i = 0, _len = _ref3.length; _i < _len; i = ++_i) {
+            prop = _ref3[i];
+            if (!prop.soak) {
+              continue;
+            }
+            prop.soak = false;
+            fst = new Value(_this.base, _this.properties.slice(0, i));
+            snd = new Value(_this.base, _this.properties.slice(i));
+            if (fst.isComplex()) {
+              ref = new Literal(o.scope.freeVariable('ref'));
+              fst = new Parens(new Assign(ref, fst));
+              snd.base = ref;
+            }
+            return new If(new Existence(fst), snd, {
+              soak: true
+            });
           }
-          return new If(new Existence(fst), snd, {
-            soak: true
-          });
-        }
-        return null;
-      })();
-      return this.unfoldedSoak = result || false;
+          return false;
+        };
+      })(this)();
     };
 
     return Value;
@@ -749,7 +843,6 @@
   })(Base);
 
   exports.Comment = Comment = (function(_super) {
-
     __extends(Comment, _super);
 
     function Comment(comment) {
@@ -761,12 +854,13 @@
     Comment.prototype.makeReturn = THIS;
 
     Comment.prototype.compileNode = function(o, level) {
-      var code;
-      code = '/*' + multident(this.comment, this.tab) + ("\n" + this.tab + "*/\n");
+      var code, comment;
+      comment = this.comment.replace(/^(\s*)#/gm, "$1 *");
+      code = "/*" + (multident(comment, this.tab)) + (__indexOf.call(comment, '\n') >= 0 ? "\n" + this.tab : '') + " */";
       if ((level || o.level) === LEVEL_TOP) {
         code = o.indent + code;
       }
-      return code;
+      return [this.makeCode("\n"), this.makeCode(code)];
     };
 
     return Comment;
@@ -774,7 +868,6 @@
   })(Base);
 
   exports.Call = Call = (function(_super) {
-
     __extends(Call, _super);
 
     function Call(variable, args, soak) {
@@ -783,6 +876,9 @@
       this.isNew = false;
       this.isSuper = variable === 'super';
       this.variable = this.isSuper ? null : variable;
+      if (variable instanceof Value && variable.isNotCallable()) {
+        variable.error("literal is not a function");
+      }
     }
 
     Call.prototype.children = ['variable', 'args'];
@@ -799,24 +895,19 @@
     };
 
     Call.prototype.superReference = function(o) {
-      var accesses, method, name;
+      var accesses, method;
       method = o.scope.namedMethod();
-      if (!method) {
-        throw SyntaxError('cannot call super outside of a function.');
-      }
-      name = method.name;
-      if (name == null) {
-        throw SyntaxError('cannot call super on an anonymous function.');
-      }
-      if (method.klass) {
+      if (method != null ? method.klass : void 0) {
         accesses = [new Access(new Literal('__super__'))];
         if (method["static"]) {
           accesses.push(new Access(new Literal('constructor')));
         }
-        accesses.push(new Access(new Literal(name)));
+        accesses.push(new Access(new Literal(method.name)));
         return (new Value(new Literal(method.klass), accesses)).compile(o);
+      } else if (method != null ? method.ctor : void 0) {
+        return "" + method.name + ".__super__.constructor";
       } else {
-        return "" + name + ".__super__.constructor";
+        return this.error('cannot call super outside of an instance method.');
       }
     };
 
@@ -876,88 +967,71 @@
       return ifn;
     };
 
-    Call.prototype.filterImplicitObjects = function(list) {
-      var node, nodes, obj, prop, properties, _i, _j, _len, _len1, _ref2;
-      nodes = [];
-      for (_i = 0, _len = list.length; _i < _len; _i++) {
-        node = list[_i];
-        if (!((typeof node.isObject === "function" ? node.isObject() : void 0) && node.base.generated)) {
-          nodes.push(node);
-          continue;
-        }
-        obj = null;
-        _ref2 = node.base.properties;
-        for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
-          prop = _ref2[_j];
-          if (prop instanceof Assign || prop instanceof Comment) {
-            if (!obj) {
-              nodes.push(obj = new Obj(properties = [], true));
-            }
-            properties.push(prop);
-          } else {
-            nodes.push(prop);
-            obj = null;
-          }
-        }
-      }
-      return nodes;
-    };
-
     Call.prototype.compileNode = function(o) {
-      var arg, args, code, _ref2;
+      var arg, argIndex, compiledArgs, compiledArray, fragments, preface, _i, _len, _ref2, _ref3;
       if ((_ref2 = this.variable) != null) {
         _ref2.front = this.front;
       }
-      if (code = Splat.compileSplattedArray(o, this.args, true)) {
-        return this.compileSplat(o, code);
+      compiledArray = Splat.compileSplattedArray(o, this.args, true);
+      if (compiledArray.length) {
+        return this.compileSplat(o, compiledArray);
       }
-      args = this.filterImplicitObjects(this.args);
-      args = ((function() {
-        var _i, _len, _results;
-        _results = [];
-        for (_i = 0, _len = args.length; _i < _len; _i++) {
-          arg = args[_i];
-          _results.push(arg.compile(o, LEVEL_LIST));
+      compiledArgs = [];
+      _ref3 = this.args;
+      for (argIndex = _i = 0, _len = _ref3.length; _i < _len; argIndex = ++_i) {
+        arg = _ref3[argIndex];
+        if (argIndex) {
+          compiledArgs.push(this.makeCode(", "));
         }
-        return _results;
-      })()).join(', ');
+        compiledArgs.push.apply(compiledArgs, arg.compileToFragments(o, LEVEL_LIST));
+      }
+      fragments = [];
       if (this.isSuper) {
-        return this.superReference(o) + (".call(" + (this.superThis(o)) + (args && ', ' + args) + ")");
+        preface = this.superReference(o) + (".call(" + (this.superThis(o)));
+        if (compiledArgs.length) {
+          preface += ", ";
+        }
+        fragments.push(this.makeCode(preface));
       } else {
-        return (this.isNew ? 'new ' : '') + this.variable.compile(o, LEVEL_ACCESS) + ("(" + args + ")");
+        if (this.isNew) {
+          fragments.push(this.makeCode('new '));
+        }
+        fragments.push.apply(fragments, this.variable.compileToFragments(o, LEVEL_ACCESS));
+        fragments.push(this.makeCode("("));
       }
-    };
-
-    Call.prototype.compileSuper = function(args, o) {
-      return "" + (this.superReference(o)) + ".call(" + (this.superThis(o)) + (args.length ? ', ' : '') + args + ")";
+      fragments.push.apply(fragments, compiledArgs);
+      fragments.push(this.makeCode(")"));
+      return fragments;
     };
 
     Call.prototype.compileSplat = function(o, splatArgs) {
-      var base, fun, idt, name, ref;
+      var answer, base, fun, idt, name, ref;
       if (this.isSuper) {
-        return "" + (this.superReference(o)) + ".apply(" + (this.superThis(o)) + ", " + splatArgs + ")";
+        return [].concat(this.makeCode("" + (this.superReference(o)) + ".apply(" + (this.superThis(o)) + ", "), splatArgs, this.makeCode(")"));
       }
       if (this.isNew) {
         idt = this.tab + TAB;
-        return "(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args), t = typeof result;\n" + idt + "return t == \"object\" || t == \"function\" ? result || child : child;\n" + this.tab + "})(" + (this.variable.compile(o, LEVEL_LIST)) + ", " + splatArgs + ", function(){})";
+        return [].concat(this.makeCode("(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args);\n" + idt + "return Object(result) === result ? result : child;\n" + this.tab + "})("), this.variable.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), splatArgs, this.makeCode(", function(){})"));
       }
+      answer = [];
       base = new Value(this.variable);
       if ((name = base.properties.pop()) && base.isComplex()) {
         ref = o.scope.freeVariable('ref');
-        fun = "(" + ref + " = " + (base.compile(o, LEVEL_LIST)) + ")" + (name.compile(o));
+        answer = answer.concat(this.makeCode("(" + ref + " = "), base.compileToFragments(o, LEVEL_LIST), this.makeCode(")"), name.compileToFragments(o));
       } else {
-        fun = base.compile(o, LEVEL_ACCESS);
-        if (SIMPLENUM.test(fun)) {
-          fun = "(" + fun + ")";
+        fun = base.compileToFragments(o, LEVEL_ACCESS);
+        if (SIMPLENUM.test(fragmentsToText(fun))) {
+          fun = this.wrapInBraces(fun);
         }
         if (name) {
-          ref = fun;
-          fun += name.compile(o);
+          ref = fragmentsToText(fun);
+          fun.push.apply(fun, name.compileToFragments(o));
         } else {
           ref = 'null';
         }
+        answer = answer.concat(fun);
       }
-      return "" + fun + ".apply(" + ref + ", " + splatArgs + ")";
+      return answer = answer.concat(this.makeCode(".apply(" + ref + ", "), splatArgs, this.makeCode(")"));
     };
 
     return Call;
@@ -965,7 +1039,6 @@
   })(Base);
 
   exports.Extends = Extends = (function(_super) {
-
     __extends(Extends, _super);
 
     function Extends(child, parent) {
@@ -975,8 +1048,8 @@
 
     Extends.prototype.children = ['child', 'parent'];
 
-    Extends.prototype.compile = function(o) {
-      return new Call(new Value(new Literal(utility('extends'))), [this.child, this.parent]).compile(o);
+    Extends.prototype.compileToFragments = function(o) {
+      return new Call(new Value(new Literal(utility('extends'))), [this.child, this.parent]).compileToFragments(o);
     };
 
     return Extends;
@@ -984,7 +1057,6 @@
   })(Base);
 
   exports.Access = Access = (function(_super) {
-
     __extends(Access, _super);
 
     function Access(name, tag) {
@@ -995,14 +1067,16 @@
 
     Access.prototype.children = ['name'];
 
-    Access.prototype.compile = function(o) {
+    Access.prototype.compileToFragments = function(o) {
       var name;
-      name = this.name.compile(o);
-      if (IDENTIFIER.test(name)) {
-        return "." + name;
+      name = this.name.compileToFragments(o);
+      if (IDENTIFIER.test(fragmentsToText(name))) {
+        name.unshift(this.makeCode("."));
       } else {
-        return "[" + name + "]";
+        name.unshift(this.makeCode("["));
+        name.push(this.makeCode("]"));
       }
+      return name;
     };
 
     Access.prototype.isComplex = NO;
@@ -1012,7 +1086,6 @@
   })(Base);
 
   exports.Index = Index = (function(_super) {
-
     __extends(Index, _super);
 
     function Index(index) {
@@ -1021,8 +1094,8 @@
 
     Index.prototype.children = ['index'];
 
-    Index.prototype.compile = function(o) {
-      return "[" + (this.index.compile(o, LEVEL_PAREN)) + "]";
+    Index.prototype.compileToFragments = function(o) {
+      return [].concat(this.makeCode("["), this.index.compileToFragments(o, LEVEL_PAREN), this.makeCode("]"));
     };
 
     Index.prototype.isComplex = function() {
@@ -1034,7 +1107,6 @@
   })(Base);
 
   exports.Range = Range = (function(_super) {
-
     __extends(Range, _super);
 
     Range.prototype.children = ['from', 'to'];
@@ -1051,14 +1123,14 @@
       o = merge(o, {
         top: true
       });
-      _ref2 = this.from.cache(o, LEVEL_LIST), this.fromC = _ref2[0], this.fromVar = _ref2[1];
-      _ref3 = this.to.cache(o, LEVEL_LIST), this.toC = _ref3[0], this.toVar = _ref3[1];
+      _ref2 = this.cacheToCodeFragments(this.from.cache(o, LEVEL_LIST)), this.fromC = _ref2[0], this.fromVar = _ref2[1];
+      _ref3 = this.cacheToCodeFragments(this.to.cache(o, LEVEL_LIST)), this.toC = _ref3[0], this.toVar = _ref3[1];
       if (step = del(o, 'step')) {
-        _ref4 = step.cache(o, LEVEL_LIST), this.step = _ref4[0], this.stepVar = _ref4[1];
+        _ref4 = this.cacheToCodeFragments(step.cache(o, LEVEL_LIST)), this.step = _ref4[0], this.stepVar = _ref4[1];
       }
-      _ref5 = [this.fromVar.match(SIMPLENUM), this.toVar.match(SIMPLENUM)], this.fromNum = _ref5[0], this.toNum = _ref5[1];
+      _ref5 = [this.fromVar.match(NUMBER), this.toVar.match(NUMBER)], this.fromNum = _ref5[0], this.toNum = _ref5[1];
       if (this.stepVar) {
-        return this.stepNum = this.stepVar.match(SIMPLENUM);
+        return this.stepNum = this.stepVar.match(NUMBER);
       }
     };
 
@@ -1082,7 +1154,7 @@
         varPart += ", " + this.step;
       }
       _ref2 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref2[0], gt = _ref2[1];
-      condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [+this.fromNum, +this.toNum], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar);
+      condPart = this.stepNum ? parseNum(this.stepNum[0]) > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [parseNum(this.fromNum[0]), parseNum(this.toNum[0])], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar);
       stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--";
       if (namedIndex) {
         varPart = "" + idxName + " = " + varPart;
@@ -1090,7 +1162,7 @@
       if (namedIndex) {
         stepPart = "" + idxName + " = " + stepPart;
       }
-      return "" + varPart + "; " + condPart + "; " + stepPart;
+      return [this.makeCode("" + varPart + "; " + condPart + "; " + stepPart)];
     };
 
     Range.prototype.compileArray = function(o) {
@@ -1104,7 +1176,7 @@
         if (this.exclusive) {
           range.pop();
         }
-        return "[" + (range.join(', ')) + "]";
+        return [this.makeCode("[" + (range.join(', ')) + "]")];
       }
       idt = this.tab + TAB;
       i = o.scope.freeVariable('i');
@@ -1112,7 +1184,7 @@
       pre = "\n" + idt + result + " = [];";
       if (this.fromNum && this.toNum) {
         o.index = i;
-        body = this.compileNode(o);
+        body = fragmentsToText(this.compileNode(o));
       } else {
         vars = ("" + i + " = " + this.fromC) + (this.toC !== this.toVar ? ", " + this.toC : '');
         cond = "" + this.fromVar + " <= " + this.toVar;
@@ -1120,14 +1192,12 @@
       }
       post = "{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + o.indent;
       hasArgs = function(node) {
-        return node != null ? node.contains(function(n) {
-          return n instanceof Literal && n.value === 'arguments' && !n.asKey;
-        }) : void 0;
+        return node != null ? node.contains(isLiteralArguments) : void 0;
       };
       if (hasArgs(this.from) || hasArgs(this.to)) {
         args = ', arguments';
       }
-      return "(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).apply(this" + (args != null ? args : '') + ")";
+      return [this.makeCode("(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).apply(this" + (args != null ? args : '') + ")")];
     };
 
     return Range;
@@ -1135,7 +1205,6 @@
   })(Base);
 
   exports.Slice = Slice = (function(_super) {
-
     __extends(Slice, _super);
 
     Slice.prototype.children = ['range'];
@@ -1146,14 +1215,17 @@
     }
 
     Slice.prototype.compileNode = function(o) {
-      var compiled, from, fromStr, to, toStr, _ref2;
+      var compiled, compiledText, from, fromCompiled, to, toStr, _ref2;
       _ref2 = this.range, to = _ref2.to, from = _ref2.from;
-      fromStr = from && from.compile(o, LEVEL_PAREN) || '0';
-      compiled = to && to.compile(o, LEVEL_PAREN);
-      if (to && !(!this.range.exclusive && +compiled === -1)) {
-        toStr = ', ' + (this.range.exclusive ? compiled : SIMPLENUM.test(compiled) ? "" + (+compiled + 1) : (compiled = to.compile(o, LEVEL_ACCESS), "" + compiled + " + 1 || 9e9"));
+      fromCompiled = from && from.compileToFragments(o, LEVEL_PAREN) || [this.makeCode('0')];
+      if (to) {
+        compiled = to.compileToFragments(o, LEVEL_PAREN);
+        compiledText = fragmentsToText(compiled);
+        if (!(!this.range.exclusive && +compiledText === -1)) {
+          toStr = ', ' + (this.range.exclusive ? compiledText : SIMPLENUM.test(compiledText) ? "" + (+compiledText + 1) : (compiled = to.compileToFragments(o, LEVEL_ACCESS), "+" + (fragmentsToText(compiled)) + " + 1 || 9e9"));
+        }
       }
-      return ".slice(" + fromStr + (toStr || '') + ")";
+      return [this.makeCode(".slice(" + (fragmentsToText(fromCompiled)) + (toStr || '') + ")")];
     };
 
     return Slice;
@@ -1161,7 +1233,6 @@
   })(Base);
 
   exports.Obj = Obj = (function(_super) {
-
     __extends(Obj, _super);
 
     function Obj(props, generated) {
@@ -1172,62 +1243,52 @@
     Obj.prototype.children = ['properties'];
 
     Obj.prototype.compileNode = function(o) {
-      var i, idt, indent, join, lastNoncom, node, obj, prop, propName, propNames, props, _i, _j, _len, _len1, _ref2;
+      var answer, i, idt, indent, join, lastNoncom, node, prop, props, _i, _j, _len, _len1;
       props = this.properties;
-      propNames = [];
-      _ref2 = this.properties;
-      for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
-        prop = _ref2[_i];
-        if (prop.isComplex()) {
-          prop = prop.variable;
-        }
-        if (prop != null) {
-          propName = prop.unwrapAll().value.toString();
-          if (__indexOf.call(propNames, propName) >= 0) {
-            throw SyntaxError("multiple object literal properties named \"" + propName + "\"");
-          }
-          propNames.push(propName);
-        }
-      }
       if (!props.length) {
-        return (this.front ? '({})' : '{}');
+        return [this.makeCode(this.front ? '({})' : '{}')];
       }
       if (this.generated) {
-        for (_j = 0, _len1 = props.length; _j < _len1; _j++) {
-          node = props[_j];
+        for (_i = 0, _len = props.length; _i < _len; _i++) {
+          node = props[_i];
           if (node instanceof Value) {
-            throw new Error('cannot have an implicit value in an implicit object');
+            node.error('cannot have an implicit value in an implicit object');
           }
         }
       }
       idt = o.indent += TAB;
       lastNoncom = this.lastNonComment(this.properties);
-      props = (function() {
-        var _k, _len2, _results;
-        _results = [];
-        for (i = _k = 0, _len2 = props.length; _k < _len2; i = ++_k) {
-          prop = props[i];
-          join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n';
-          indent = prop instanceof Comment ? '' : idt;
-          if (prop instanceof Value && prop["this"]) {
-            prop = new Assign(prop.properties[0].name, prop, 'object');
-          }
-          if (!(prop instanceof Comment)) {
-            if (!(prop instanceof Assign)) {
-              prop = new Assign(prop, prop, 'object');
-            }
-            (prop.variable.base || prop.variable).asKey = true;
+      answer = [];
+      for (i = _j = 0, _len1 = props.length; _j < _len1; i = ++_j) {
+        prop = props[i];
+        join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n';
+        indent = prop instanceof Comment ? '' : idt;
+        if (prop instanceof Assign && prop.variable instanceof Value && prop.variable.hasProperties()) {
+          prop.variable.error('Invalid object key');
+        }
+        if (prop instanceof Value && prop["this"]) {
+          prop = new Assign(prop.properties[0].name, prop, 'object');
+        }
+        if (!(prop instanceof Comment)) {
+          if (!(prop instanceof Assign)) {
+            prop = new Assign(prop, prop, 'object');
           }
-          _results.push(indent + prop.compile(o, LEVEL_TOP) + join);
+          (prop.variable.base || prop.variable).asKey = true;
         }
-        return _results;
-      })();
-      props = props.join('');
-      obj = "{" + (props && '\n' + props + '\n' + this.tab) + "}";
+        if (indent) {
+          answer.push(this.makeCode(indent));
+        }
+        answer.push.apply(answer, prop.compileToFragments(o, LEVEL_TOP));
+        if (join) {
+          answer.push(this.makeCode(join));
+        }
+      }
+      answer.unshift(this.makeCode("{" + (props.length && '\n')));
+      answer.push(this.makeCode("" + (props.length && '\n' + this.tab) + "}"));
       if (this.front) {
-        return "(" + obj + ")";
+        return this.wrapInBraces(answer);
       } else {
-        return obj;
+        return answer;
       }
     };
 
@@ -1248,7 +1309,6 @@
   })(Base);
 
   exports.Arr = Arr = (function(_super) {
-
     __extends(Arr, _super);
 
     function Arr(objs) {
@@ -1257,32 +1317,42 @@
 
     Arr.prototype.children = ['objects'];
 
-    Arr.prototype.filterImplicitObjects = Call.prototype.filterImplicitObjects;
-
     Arr.prototype.compileNode = function(o) {
-      var code, obj, objs;
+      var answer, compiledObjs, fragments, index, obj, _i, _len;
       if (!this.objects.length) {
-        return '[]';
+        return [this.makeCode('[]')];
       }
       o.indent += TAB;
-      objs = this.filterImplicitObjects(this.objects);
-      if (code = Splat.compileSplattedArray(o, objs)) {
-        return code;
-      }
-      code = ((function() {
-        var _i, _len, _results;
+      answer = Splat.compileSplattedArray(o, this.objects);
+      if (answer.length) {
+        return answer;
+      }
+      answer = [];
+      compiledObjs = (function() {
+        var _i, _len, _ref2, _results;
+        _ref2 = this.objects;
         _results = [];
-        for (_i = 0, _len = objs.length; _i < _len; _i++) {
-          obj = objs[_i];
-          _results.push(obj.compile(o, LEVEL_LIST));
+        for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+          obj = _ref2[_i];
+          _results.push(obj.compileToFragments(o, LEVEL_LIST));
         }
         return _results;
-      })()).join(', ');
-      if (code.indexOf('\n') >= 0) {
-        return "[\n" + o.indent + code + "\n" + this.tab + "]";
+      }).call(this);
+      for (index = _i = 0, _len = compiledObjs.length; _i < _len; index = ++_i) {
+        fragments = compiledObjs[index];
+        if (index) {
+          answer.push(this.makeCode(", "));
+        }
+        answer.push.apply(answer, fragments);
+      }
+      if (fragmentsToText(answer).indexOf('\n') >= 0) {
+        answer.unshift(this.makeCode("[\n" + o.indent));
+        answer.push(this.makeCode("\n" + this.tab + "]"));
       } else {
-        return "[" + code + "]";
+        answer.unshift(this.makeCode("["));
+        answer.push(this.makeCode("]"));
       }
+      return answer;
     };
 
     Arr.prototype.assigns = function(name) {
@@ -1302,7 +1372,6 @@
   })(Base);
 
   exports.Class = Class = (function(_super) {
-
     __extends(Class, _super);
 
     function Class(variable, parent, body) {
@@ -1322,7 +1391,7 @@
       }
       decl = (tail = last(this.variable.properties)) ? tail instanceof Access && tail.name.value : this.variable.base.value;
       if (__indexOf.call(STRICT_PROSCRIBED, decl) >= 0) {
-        throw SyntaxError("variable name may not be " + decl);
+        this.variable.error("class variable name may not be " + decl);
       }
       return decl && (decl = IDENTIFIER.test(decl) && decl);
     };
@@ -1344,16 +1413,12 @@
     };
 
     Class.prototype.addBoundFunctions = function(o) {
-      var bvar, lhs, _i, _len, _ref2, _results;
-      if (this.boundFuncs.length) {
-        _ref2 = this.boundFuncs;
-        _results = [];
-        for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
-          bvar = _ref2[_i];
-          lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o);
-          _results.push(this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)")));
-        }
-        return _results;
+      var bvar, lhs, _i, _len, _ref2;
+      _ref2 = this.boundFuncs;
+      for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+        bvar = _ref2[_i];
+        lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o);
+        this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)"));
       }
     };
 
@@ -1370,23 +1435,20 @@
             func = assign.value;
             if (base.value === 'constructor') {
               if (this.ctor) {
-                throw new Error('cannot define more than one constructor in a class');
+                assign.error('cannot define more than one constructor in a class');
               }
               if (func.bound) {
-                throw new Error('cannot define a constructor as a bound function');
+                assign.error('cannot define a constructor as a bound function');
               }
               if (func instanceof Code) {
                 assign = this.ctor = func;
               } else {
-                this.externalCtor = o.scope.freeVariable('class');
+                this.externalCtor = o.classScope.freeVariable('class');
                 assign = new Assign(new Literal(this.externalCtor), func);
               }
             } else {
               if (assign.variable["this"]) {
                 func["static"] = true;
-                if (func.bound) {
-                  func.context = name;
-                }
               } else {
                 assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]);
                 if (func instanceof Code && func.bound) {
@@ -1404,23 +1466,29 @@
     };
 
     Class.prototype.walkBody = function(name, o) {
-      var _this = this;
-      return this.traverseChildren(false, function(child) {
-        var exps, i, node, _i, _len, _ref2;
-        if (child instanceof Class) {
-          return false;
-        }
-        if (child instanceof Block) {
-          _ref2 = exps = child.expressions;
-          for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
-            node = _ref2[i];
-            if (node instanceof Value && node.isObject(true)) {
-              exps[i] = _this.addProperties(node, name, o);
+      return this.traverseChildren(false, (function(_this) {
+        return function(child) {
+          var cont, exps, i, node, _i, _len, _ref2;
+          cont = true;
+          if (child instanceof Class) {
+            return false;
+          }
+          if (child instanceof Block) {
+            _ref2 = exps = child.expressions;
+            for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
+              node = _ref2[i];
+              if (node instanceof Assign && node.variable.looksStatic(name)) {
+                node.value["static"] = true;
+              } else if (node instanceof Value && node.isObject(true)) {
+                cont = false;
+                exps[i] = _this.addProperties(node, name, o);
+              }
             }
+            child.expressions = exps = flatten(exps);
           }
-          return child.expressions = exps = flatten(exps);
-        }
-      });
+          return cont && !(child instanceof Class);
+        };
+      })(this));
     };
 
     Class.prototype.hoistDirectivePrologue = function() {
@@ -1436,11 +1504,10 @@
     Class.prototype.ensureConstructor = function(name) {
       if (!this.ctor) {
         this.ctor = new Code;
-        if (this.parent) {
-          this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)"));
-        }
         if (this.externalCtor) {
           this.ctor.body.push(new Literal("" + this.externalCtor + ".apply(this, arguments)"));
+        } else if (this.parent) {
+          this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)"));
         }
         this.ctor.body.makeReturn();
         this.body.expressions.unshift(this.ctor);
@@ -1451,37 +1518,40 @@
     };
 
     Class.prototype.compileNode = function(o) {
-      var call, decl, klass, lname, name, params, _ref2;
-      decl = this.determineName();
-      name = decl || '_Class';
+      var args, argumentsNode, func, jumpNode, klass, lname, name, superClass, _ref2;
+      if (jumpNode = this.body.jumps()) {
+        jumpNode.error('Class bodies cannot contain pure statements');
+      }
+      if (argumentsNode = this.body.contains(isLiteralArguments)) {
+        argumentsNode.error("Class bodies shouldn't reference arguments");
+      }
+      name = this.determineName() || '_Class';
       if (name.reserved) {
         name = "_" + name;
       }
       lname = new Literal(name);
+      func = new Code([], Block.wrap([this.body]));
+      args = [];
+      o.classScope = func.makeScope(o.scope);
       this.hoistDirectivePrologue();
       this.setContext(name);
       this.walkBody(name, o);
       this.ensureConstructor(name);
+      this.addBoundFunctions(o);
       this.body.spaced = true;
-      if (!(this.ctor instanceof Code)) {
-        this.body.expressions.unshift(this.ctor);
-      }
       this.body.expressions.push(lname);
-      (_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives);
-      this.addBoundFunctions(o);
-      call = Closure.wrap(this.body);
       if (this.parent) {
-        this.superClass = new Literal(o.scope.freeVariable('super', false));
-        this.body.expressions.unshift(new Extends(lname, this.superClass));
-        call.args.push(this.parent);
-        params = call.variable.params || call.variable.base.params;
-        params.push(new Param(this.superClass));
+        superClass = new Literal(o.classScope.freeVariable('super', false));
+        this.body.expressions.unshift(new Extends(lname, superClass));
+        func.params.push(new Param(superClass));
+        args.push(this.parent);
       }
-      klass = new Parens(call, true);
+      (_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives);
+      klass = new Parens(new Call(func, args));
       if (this.variable) {
         klass = new Assign(this.variable, klass);
       }
-      return klass.compile(o);
+      return klass.compileToFragments(o);
     };
 
     return Class;
@@ -1489,7 +1559,6 @@
   })(Base);
 
   exports.Assign = Assign = (function(_super) {
-
     __extends(Assign, _super);
 
     function Assign(variable, value, context, options) {
@@ -1501,7 +1570,7 @@
       this.subpattern = options && options.subpattern;
       forbidden = (_ref2 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0);
       if (forbidden && this.context !== 'object') {
-        throw SyntaxError("variable name may not be \"" + name + "\"");
+        this.variable.error("variable name may not be \"" + name + "\"");
       }
     }
 
@@ -1520,7 +1589,7 @@
     };
 
     Assign.prototype.compileNode = function(o) {
-      var isValue, match, name, val, varBase, _ref2, _ref3, _ref4, _ref5;
+      var answer, compiledName, isValue, match, name, val, varBase, _ref2, _ref3, _ref4, _ref5;
       if (isValue = this.variable instanceof Value) {
         if (this.variable.isArray() || this.variable.isObject()) {
           return this.compilePatternMatch(o);
@@ -1531,11 +1600,16 @@
         if ((_ref2 = this.context) === '||=' || _ref2 === '&&=' || _ref2 === '?=') {
           return this.compileConditional(o);
         }
+        if ((_ref3 = this.context) === '**=' || _ref3 === '//=' || _ref3 === '%%=') {
+          return this.compileSpecialMath(o);
+        }
       }
-      name = this.variable.compile(o, LEVEL_LIST);
+      compiledName = this.variable.compileToFragments(o, LEVEL_LIST);
+      name = fragmentsToText(compiledName);
       if (!this.context) {
-        if (!(varBase = this.variable.unwrapAll()).isAssignable()) {
-          throw SyntaxError("\"" + (this.variable.compile(o)) + "\" cannot be assigned.");
+        varBase = this.variable.unwrapAll();
+        if (!varBase.isAssignable()) {
+          this.variable.error("\"" + (this.variable.compile(o)) + "\" cannot be assigned");
         }
         if (!(typeof varBase.hasProperties === "function" ? varBase.hasProperties() : void 0)) {
           if (this.param) {
@@ -1546,32 +1620,32 @@
         }
       }
       if (this.value instanceof Code && (match = METHOD_DEF.exec(name))) {
-        if (match[1]) {
+        if (match[2]) {
           this.value.klass = match[1];
         }
-        this.value.name = (_ref3 = (_ref4 = (_ref5 = match[2]) != null ? _ref5 : match[3]) != null ? _ref4 : match[4]) != null ? _ref3 : match[5];
+        this.value.name = (_ref4 = (_ref5 = match[3]) != null ? _ref5 : match[4]) != null ? _ref4 : match[5];
       }
-      val = this.value.compile(o, LEVEL_LIST);
+      val = this.value.compileToFragments(o, LEVEL_LIST);
       if (this.context === 'object') {
-        return "" + name + ": " + val;
+        return compiledName.concat(this.makeCode(": "), val);
       }
-      val = name + (" " + (this.context || '=') + " ") + val;
+      answer = compiledName.concat(this.makeCode(" " + (this.context || '=') + " "), val);
       if (o.level <= LEVEL_LIST) {
-        return val;
+        return answer;
       } else {
-        return "(" + val + ")";
+        return this.wrapInBraces(answer);
       }
     };
 
     Assign.prototype.compilePatternMatch = function(o) {
-      var acc, assigns, code, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
+      var acc, assigns, code, expandedIdx, fragments, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, top, val, value, vvar, vvarText, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
       top = o.level === LEVEL_TOP;
       value = this.value;
       objects = this.variable.base.objects;
       if (!(olen = objects.length)) {
-        code = value.compile(o);
+        code = value.compileToFragments(o);
         if (o.level >= LEVEL_OP) {
-          return "(" + code + ")";
+          return this.wrapInBraces(code);
         } else {
           return code;
         }
@@ -1581,108 +1655,136 @@
         if (obj instanceof Assign) {
           _ref2 = obj, (_ref3 = _ref2.variable, idx = _ref3.base), obj = _ref2.value;
         } else {
-          if (obj.base instanceof Parens) {
-            _ref4 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref4[0], idx = _ref4[1];
-          } else {
-            idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0);
-          }
+          idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0);
         }
         acc = IDENTIFIER.test(idx.unwrap().value || 0);
         value = new Value(value);
         value.properties.push(new (acc ? Access : Index)(idx));
-        if (_ref5 = obj.unwrap().value, __indexOf.call(RESERVED, _ref5) >= 0) {
-          throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (value.compile(o)));
+        if (_ref4 = obj.unwrap().value, __indexOf.call(RESERVED, _ref4) >= 0) {
+          obj.error("assignment to a reserved word: " + (obj.compile(o)));
         }
         return new Assign(obj, value, null, {
           param: this.param
-        }).compile(o, LEVEL_TOP);
+        }).compileToFragments(o, LEVEL_TOP);
       }
-      vvar = value.compile(o, LEVEL_LIST);
+      vvar = value.compileToFragments(o, LEVEL_LIST);
+      vvarText = fragmentsToText(vvar);
       assigns = [];
-      splat = false;
-      if (!IDENTIFIER.test(vvar) || this.variable.assigns(vvar)) {
-        assigns.push("" + (ref = o.scope.freeVariable('ref')) + " = " + vvar);
-        vvar = ref;
+      expandedIdx = false;
+      if (!IDENTIFIER.test(vvarText) || this.variable.assigns(vvarText)) {
+        assigns.push([this.makeCode("" + (ref = o.scope.freeVariable('ref')) + " = ")].concat(__slice.call(vvar)));
+        vvar = [this.makeCode(ref)];
+        vvarText = ref;
       }
       for (i = _i = 0, _len = objects.length; _i < _len; i = ++_i) {
         obj = objects[i];
         idx = i;
         if (isObject) {
           if (obj instanceof Assign) {
-            _ref6 = obj, (_ref7 = _ref6.variable, idx = _ref7.base), obj = _ref6.value;
+            _ref5 = obj, (_ref6 = _ref5.variable, idx = _ref6.base), obj = _ref5.value;
           } else {
             if (obj.base instanceof Parens) {
-              _ref8 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref8[0], idx = _ref8[1];
+              _ref7 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref7[0], idx = _ref7[1];
             } else {
               idx = obj["this"] ? obj.properties[0].name : obj;
             }
           }
         }
-        if (!splat && obj instanceof Splat) {
+        if (!expandedIdx && obj instanceof Splat) {
           name = obj.name.unwrap().value;
           obj = obj.unwrap();
-          val = "" + olen + " <= " + vvar + ".length ? " + (utility('slice')) + ".call(" + vvar + ", " + i;
+          val = "" + olen + " <= " + vvarText + ".length ? " + (utility('slice')) + ".call(" + vvarText + ", " + i;
           if (rest = olen - i - 1) {
             ivar = o.scope.freeVariable('i');
-            val += ", " + ivar + " = " + vvar + ".length - " + rest + ") : (" + ivar + " = " + i + ", [])";
+            val += ", " + ivar + " = " + vvarText + ".length - " + rest + ") : (" + ivar + " = " + i + ", [])";
           } else {
             val += ") : []";
           }
           val = new Literal(val);
-          splat = "" + ivar + "++";
+          expandedIdx = "" + ivar + "++";
+        } else if (!expandedIdx && obj instanceof Expansion) {
+          if (rest = olen - i - 1) {
+            if (rest === 1) {
+              expandedIdx = "" + vvarText + ".length - 1";
+            } else {
+              ivar = o.scope.freeVariable('i');
+              val = new Literal("" + ivar + " = " + vvarText + ".length - " + rest);
+              expandedIdx = "" + ivar + "++";
+              assigns.push(val.compileToFragments(o, LEVEL_LIST));
+            }
+          }
+          continue;
         } else {
           name = obj.unwrap().value;
-          if (obj instanceof Splat) {
-            obj = obj.name.compile(o);
-            throw new SyntaxError("multiple splats are disallowed in an assignment: " + obj + "...");
+          if (obj instanceof Splat || obj instanceof Expansion) {
+            obj.error("multiple splats/expansions are disallowed in an assignment");
           }
           if (typeof idx === 'number') {
-            idx = new Literal(splat || idx);
+            idx = new Literal(expandedIdx || idx);
             acc = false;
           } else {
             acc = isObject && IDENTIFIER.test(idx.unwrap().value || 0);
           }
-          val = new Value(new Literal(vvar), [new (acc ? Access : Index)(idx)]);
+          val = new Value(new Literal(vvarText), [new (acc ? Access : Index)(idx)]);
         }
         if ((name != null) && __indexOf.call(RESERVED, name) >= 0) {
-          throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (val.compile(o)));
+          obj.error("assignment to a reserved word: " + (obj.compile(o)));
         }
         assigns.push(new Assign(obj, val, null, {
           param: this.param,
           subpattern: true
-        }).compile(o, LEVEL_LIST));
+        }).compileToFragments(o, LEVEL_LIST));
       }
       if (!(top || this.subpattern)) {
         assigns.push(vvar);
       }
-      code = assigns.join(', ');
+      fragments = this.joinFragmentArrays(assigns, ', ');
       if (o.level < LEVEL_LIST) {
-        return code;
+        return fragments;
       } else {
-        return "(" + code + ")";
+        return this.wrapInBraces(fragments);
       }
     };
 
     Assign.prototype.compileConditional = function(o) {
-      var left, right, _ref2;
+      var fragments, left, right, _ref2;
       _ref2 = this.variable.cacheReference(o), left = _ref2[0], right = _ref2[1];
       if (!left.properties.length && left.base instanceof Literal && left.base.value !== "this" && !o.scope.check(left.base.value)) {
-        throw new Error("the variable \"" + left.base.value + "\" can't be assigned with " + this.context + " because it has not been defined.");
+        this.variable.error("the variable \"" + left.base.value + "\" can't be assigned with " + this.context + " because it has not been declared before");
       }
       if (__indexOf.call(this.context, "?") >= 0) {
         o.isExistentialEquals = true;
+        return new If(new Existence(left), right, {
+          type: 'if'
+        }).addElse(new Assign(right, this.value, '=')).compileToFragments(o);
+      } else {
+        fragments = new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compileToFragments(o);
+        if (o.level <= LEVEL_LIST) {
+          return fragments;
+        } else {
+          return this.wrapInBraces(fragments);
+        }
       }
-      return new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compile(o);
+    };
+
+    Assign.prototype.compileSpecialMath = function(o) {
+      var left, right, _ref2;
+      _ref2 = this.variable.cacheReference(o), left = _ref2[0], right = _ref2[1];
+      return new Assign(left, new Op(this.context.slice(0, -1), right, this.value)).compileToFragments(o);
     };
 
     Assign.prototype.compileSplice = function(o) {
-      var code, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref2, _ref3, _ref4;
+      var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref2, _ref3, _ref4;
       _ref2 = this.variable.properties.pop().range, from = _ref2.from, to = _ref2.to, exclusive = _ref2.exclusive;
       name = this.variable.compile(o);
-      _ref3 = (from != null ? from.cache(o, LEVEL_OP) : void 0) || ['0', '0'], fromDecl = _ref3[0], fromRef = _ref3[1];
+      if (from) {
+        _ref3 = this.cacheToCodeFragments(from.cache(o, LEVEL_OP)), fromDecl = _ref3[0], fromRef = _ref3[1];
+      } else {
+        fromDecl = fromRef = '0';
+      }
       if (to) {
-        if ((from != null ? from.isSimpleNumber() : void 0) && to.isSimpleNumber()) {
-          to = +to.compile(o) - +fromRef;
+        if (from instanceof Value && from.isSimpleNumber() && to instanceof Value && to.isSimpleNumber()) {
+          to = to.compile(o) - fromRef;
           if (!exclusive) {
             to += 1;
           }
@@ -1696,11 +1798,11 @@
         to = "9e9";
       }
       _ref4 = this.value.cache(o, LEVEL_LIST), valDef = _ref4[0], valRef = _ref4[1];
-      code = "[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat(" + valDef + ")), " + valRef;
+      answer = [].concat(this.makeCode("[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat("), valDef, this.makeCode(")), "), valRef);
       if (o.level > LEVEL_TOP) {
-        return "(" + code + ")";
+        return this.wrapInBraces(answer);
       } else {
-        return code;
+        return answer;
       }
     };
 
@@ -1709,16 +1811,12 @@
   })(Base);
 
   exports.Code = Code = (function(_super) {
-
     __extends(Code, _super);
 
     function Code(params, body, tag) {
       this.params = params || [];
       this.body = body || new Block;
       this.bound = tag === 'boundfunc';
-      if (this.bound) {
-        this.context = '_this';
-      }
     }
 
     Code.prototype.children = ['params', 'body'];
@@ -1729,31 +1827,48 @@
 
     Code.prototype.jumps = NO;
 
+    Code.prototype.makeScope = function(parentScope) {
+      return new Scope(parentScope, this.body, this);
+    };
+
     Code.prototype.compileNode = function(o) {
-      var code, exprs, i, idt, lit, name, p, param, params, ref, splats, uniqs, val, wasEmpty, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
-      o.scope = new Scope(o.scope, this.body, this);
+      var answer, boundfunc, code, exprs, i, lit, p, param, params, ref, splats, uniqs, val, wasEmpty, wrapper, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
+      if (this.bound && ((_ref2 = o.scope.method) != null ? _ref2.bound : void 0)) {
+        this.context = o.scope.method.context;
+      }
+      if (this.bound && !this.context) {
+        this.context = '_this';
+        wrapper = new Code([new Param(new Literal(this.context))], new Block([this]));
+        boundfunc = new Call(wrapper, [new Literal('this')]);
+        boundfunc.updateLocationDataIfMissing(this.locationData);
+        return boundfunc.compileNode(o);
+      }
+      o.scope = del(o, 'classScope') || this.makeScope(o.scope);
       o.scope.shared = del(o, 'sharedScope');
       o.indent += TAB;
       delete o.bare;
       delete o.isExistentialEquals;
       params = [];
       exprs = [];
-      _ref2 = this.paramNames();
-      for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
-        name = _ref2[_i];
-        if (!o.scope.check(name)) {
-          o.scope.parameter(name);
+      _ref3 = this.params;
+      for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
+        param = _ref3[_i];
+        if (!(param instanceof Expansion)) {
+          o.scope.parameter(param.asReference(o));
         }
       }
-      _ref3 = this.params;
-      for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
-        param = _ref3[_j];
-        if (!param.splat) {
+      _ref4 = this.params;
+      for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
+        param = _ref4[_j];
+        if (!(param.splat || param instanceof Expansion)) {
           continue;
         }
-        _ref4 = this.params;
-        for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
-          p = _ref4[_k].name;
+        _ref5 = this.params;
+        for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) {
+          p = _ref5[_k].name;
+          if (!(!(param instanceof Expansion))) {
+            continue;
+          }
           if (p["this"]) {
             p = p.properties[0].name;
           }
@@ -1762,20 +1877,20 @@
           }
         }
         splats = new Assign(new Value(new Arr((function() {
-          var _l, _len3, _ref5, _results;
-          _ref5 = this.params;
+          var _l, _len3, _ref6, _results;
+          _ref6 = this.params;
           _results = [];
-          for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
-            p = _ref5[_l];
+          for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) {
+            p = _ref6[_l];
             _results.push(p.asReference(o));
           }
           return _results;
         }).call(this))), new Value(new Literal('arguments')));
         break;
       }
-      _ref5 = this.params;
-      for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
-        param = _ref5[_l];
+      _ref6 = this.params;
+      for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) {
+        param = _ref6[_l];
         if (param.isComplex()) {
           val = ref = param.asReference(o);
           if (param.value) {
@@ -1801,60 +1916,60 @@
         exprs.unshift(splats);
       }
       if (exprs.length) {
-        (_ref6 = this.body.expressions).unshift.apply(_ref6, exprs);
+        (_ref7 = this.body.expressions).unshift.apply(_ref7, exprs);
       }
       for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) {
         p = params[i];
-        o.scope.parameter(params[i] = p.compile(o));
+        params[i] = p.compileToFragments(o);
+        o.scope.parameter(fragmentsToText(params[i]));
       }
       uniqs = [];
-      _ref7 = this.paramNames();
-      for (_n = 0, _len5 = _ref7.length; _n < _len5; _n++) {
-        name = _ref7[_n];
+      this.eachParamName(function(name, node) {
         if (__indexOf.call(uniqs, name) >= 0) {
-          throw SyntaxError("multiple parameters named '" + name + "'");
+          node.error("multiple parameters named '" + name + "'");
         }
-        uniqs.push(name);
-      }
+        return uniqs.push(name);
+      });
       if (!(wasEmpty || this.noReturn)) {
         this.body.makeReturn();
       }
-      if (this.bound) {
-        if ((_ref8 = o.scope.parent.method) != null ? _ref8.bound : void 0) {
-          this.bound = this.context = o.scope.parent.method.context;
-        } else if (!this["static"]) {
-          o.scope.parent.assign('_this', 'this');
-        }
-      }
-      idt = o.indent;
       code = 'function';
       if (this.ctor) {
         code += ' ' + this.name;
       }
-      code += '(' + params.join(', ') + ') {';
+      code += '(';
+      answer = [this.makeCode(code)];
+      for (i = _n = 0, _len5 = params.length; _n < _len5; i = ++_n) {
+        p = params[i];
+        if (i) {
+          answer.push(this.makeCode(", "));
+        }
+        answer.push.apply(answer, p);
+      }
+      answer.push(this.makeCode(') {'));
       if (!this.body.isEmpty()) {
-        code += "\n" + (this.body.compileWithDeclarations(o)) + "\n" + this.tab;
+        answer = answer.concat(this.makeCode("\n"), this.body.compileWithDeclarations(o), this.makeCode("\n" + this.tab));
       }
-      code += '}';
+      answer.push(this.makeCode('}'));
       if (this.ctor) {
-        return this.tab + code;
+        return [this.makeCode(this.tab)].concat(__slice.call(answer));
       }
       if (this.front || (o.level >= LEVEL_ACCESS)) {
-        return "(" + code + ")";
+        return this.wrapInBraces(answer);
       } else {
-        return code;
+        return answer;
       }
     };
 
-    Code.prototype.paramNames = function() {
-      var names, param, _i, _len, _ref2;
-      names = [];
+    Code.prototype.eachParamName = function(iterator) {
+      var param, _i, _len, _ref2, _results;
       _ref2 = this.params;
+      _results = [];
       for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
         param = _ref2[_i];
-        names.push.apply(names, param.names());
+        _results.push(param.eachName(iterator));
       }
-      return names;
+      return _results;
     };
 
     Code.prototype.traverseChildren = function(crossScope, func) {
@@ -1868,7 +1983,6 @@
   })(Base);
 
   exports.Param = Param = (function(_super) {
-
     __extends(Param, _super);
 
     function Param(name, value, splat) {
@@ -1877,14 +1991,14 @@
       this.value = value;
       this.splat = splat;
       if (_ref2 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) {
-        throw SyntaxError("parameter name \"" + name + "\" is not allowed");
+        this.name.error("parameter name \"" + name + "\" is not allowed");
       }
     }
 
     Param.prototype.children = ['name', 'value'];
 
-    Param.prototype.compile = function(o) {
-      return this.name.compile(o, LEVEL_LIST);
+    Param.prototype.compileToFragments = function(o) {
+      return this.name.compileToFragments(o, LEVEL_LIST);
     };
 
     Param.prototype.asReference = function(o) {
@@ -1905,6 +2019,7 @@
       if (this.splat) {
         node = new Splat(node);
       }
+      node.updateLocationDataIfMissing(this.locationData);
       return this.reference = node;
     };
 
@@ -1912,47 +2027,44 @@
       return this.name.isComplex();
     };
 
-    Param.prototype.names = function(name) {
-      var atParam, names, obj, _i, _len, _ref2;
+    Param.prototype.eachName = function(iterator, name) {
+      var atParam, node, obj, _i, _len, _ref2;
       if (name == null) {
         name = this.name;
       }
       atParam = function(obj) {
-        var value;
-        value = obj.properties[0].name.value;
-        if (value.reserved) {
-          return [];
-        } else {
-          return [value];
+        var node;
+        node = obj.properties[0].name;
+        if (!node.value.reserved) {
+          return iterator(node.value, node);
         }
       };
       if (name instanceof Literal) {
-        return [name.value];
+        return iterator(name.value, name);
       }
       if (name instanceof Value) {
         return atParam(name);
       }
-      names = [];
       _ref2 = name.objects;
       for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
         obj = _ref2[_i];
         if (obj instanceof Assign) {
-          names.push(obj.value.unwrap().value);
+          this.eachName(iterator, obj.value.unwrap());
         } else if (obj instanceof Splat) {
-          names.push(obj.name.unwrap().value);
+          node = obj.name.unwrap();
+          iterator(node.value, node);
         } else if (obj instanceof Value) {
           if (obj.isArray() || obj.isObject()) {
-            names.push.apply(names, this.names(obj.base));
+            this.eachName(iterator, obj.base);
           } else if (obj["this"]) {
-            names.push.apply(names, atParam(obj));
+            atParam(obj);
           } else {
-            names.push(obj.base.value);
+            iterator(obj.base.value, obj.base);
           }
-        } else {
-          throw SyntaxError("illegal parameter " + (obj.compile()));
+        } else if (!(obj instanceof Expansion)) {
+          obj.error("illegal parameter " + (obj.compile()));
         }
       }
-      return names;
     };
 
     return Param;
@@ -1960,7 +2072,6 @@
   })(Base);
 
   exports.Splat = Splat = (function(_super) {
-
     __extends(Splat, _super);
 
     Splat.prototype.children = ['name'];
@@ -1975,12 +2086,8 @@
       return this.name.assigns(name);
     };
 
-    Splat.prototype.compile = function(o) {
-      if (this.index != null) {
-        return this.compileParam(o);
-      } else {
-        return this.name.compile(o);
-      }
+    Splat.prototype.compileToFragments = function(o) {
+      return this.name.compileToFragments(o);
     };
 
     Splat.prototype.unwrap = function() {
@@ -1988,29 +2095,32 @@
     };
 
     Splat.compileSplattedArray = function(o, list, apply) {
-      var args, base, code, i, index, node, _i, _len;
+      var args, base, compiledNode, concatPart, fragments, i, index, node, _i, _len;
       index = -1;
       while ((node = list[++index]) && !(node instanceof Splat)) {
         continue;
       }
       if (index >= list.length) {
-        return '';
+        return [];
       }
       if (list.length === 1) {
-        code = list[0].compile(o, LEVEL_LIST);
+        node = list[0];
+        fragments = node.compileToFragments(o, LEVEL_LIST);
         if (apply) {
-          return code;
+          return fragments;
         }
-        return "" + (utility('slice')) + ".call(" + code + ")";
+        return [].concat(node.makeCode("" + (utility('slice')) + ".call("), fragments, node.makeCode(")"));
       }
       args = list.slice(index);
       for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
         node = args[i];
-        code = node.compile(o, LEVEL_LIST);
-        args[i] = node instanceof Splat ? "" + (utility('slice')) + ".call(" + code + ")" : "[" + code + "]";
+        compiledNode = node.compileToFragments(o, LEVEL_LIST);
+        args[i] = node instanceof Splat ? [].concat(node.makeCode("" + (utility('slice')) + ".call("), compiledNode, node.makeCode(")")) : [].concat(node.makeCode("["), compiledNode, node.makeCode("]"));
       }
       if (index === 0) {
-        return args[0] + (".concat(" + (args.slice(1).join(', ')) + ")");
+        node = list[0];
+        concatPart = node.joinFragmentArrays(args.slice(1), ', ');
+        return args[0].concat(node.makeCode(".concat("), concatPart, node.makeCode(")"));
       }
       base = (function() {
         var _j, _len1, _ref2, _results;
@@ -2018,19 +2128,43 @@
         _results = [];
         for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
           node = _ref2[_j];
-          _results.push(node.compile(o, LEVEL_LIST));
+          _results.push(node.compileToFragments(o, LEVEL_LIST));
         }
         return _results;
       })();
-      return "[" + (base.join(', ')) + "].concat(" + (args.join(', ')) + ")";
+      base = list[0].joinFragmentArrays(base, ', ');
+      concatPart = list[index].joinFragmentArrays(args, ', ');
+      return [].concat(list[0].makeCode("["), base, list[index].makeCode("].concat("), concatPart, (last(list)).makeCode(")"));
     };
 
     return Splat;
 
   })(Base);
 
-  exports.While = While = (function(_super) {
+  exports.Expansion = Expansion = (function(_super) {
+    __extends(Expansion, _super);
+
+    function Expansion() {
+      return Expansion.__super__.constructor.apply(this, arguments);
+    }
+
+    Expansion.prototype.isComplex = NO;
+
+    Expansion.prototype.compileNode = function(o) {
+      return this.error('Expansion must be used inside a destructuring assignment or parameter list');
+    };
+
+    Expansion.prototype.asReference = function(o) {
+      return this;
+    };
+
+    Expansion.prototype.eachName = function(iterator) {};
+
+    return Expansion;
+
+  })(Base);
 
+  exports.While = While = (function(_super) {
     __extends(While, _super);
 
     function While(condition, options) {
@@ -2059,29 +2193,29 @@
     };
 
     While.prototype.jumps = function() {
-      var expressions, node, _i, _len;
+      var expressions, jumpNode, node, _i, _len;
       expressions = this.body.expressions;
       if (!expressions.length) {
         return false;
       }
       for (_i = 0, _len = expressions.length; _i < _len; _i++) {
         node = expressions[_i];
-        if (node.jumps({
+        if (jumpNode = node.jumps({
           loop: true
         })) {
-          return node;
+          return jumpNode;
         }
       }
       return false;
     };
 
     While.prototype.compileNode = function(o) {
-      var body, code, rvar, set;
+      var answer, body, rvar, set;
       o.indent += TAB;
       set = '';
       body = this.body;
       if (body.isEmpty()) {
-        body = '';
+        body = this.makeCode('');
       } else {
         if (this.returns) {
           body.makeReturn(rvar = o.scope.freeVariable('results'));
@@ -2096,13 +2230,13 @@
             }
           }
         }
-        body = "\n" + (body.compile(o, LEVEL_TOP)) + "\n" + this.tab;
+        body = [].concat(this.makeCode("\n"), body.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab));
       }
-      code = set + this.tab + ("while (" + (this.condition.compile(o, LEVEL_PAREN)) + ") {" + body + "}");
+      answer = [].concat(this.makeCode(set + this.tab + "while ("), this.condition.compileToFragments(o, LEVEL_PAREN), this.makeCode(") {"), body, this.makeCode("}"));
       if (this.returns) {
-        code += "\n" + this.tab + "return " + rvar + ";";
+        answer.push(this.makeCode("\n" + this.tab + "return " + rvar + ";"));
       }
-      return code;
+      return answer;
     };
 
     return While;
@@ -2224,16 +2358,16 @@
     };
 
     Op.prototype.compileNode = function(o) {
-      var code, isChain, _ref2, _ref3;
+      var answer, isChain, lhs, rhs, _ref2, _ref3;
       isChain = this.isChainable() && this.first.isChainable();
       if (!isChain) {
         this.first.front = this.front;
       }
       if (this.operator === 'delete' && o.scope.check(this.first.unwrapAll().value)) {
-        throw SyntaxError('delete operand may not be argument or var');
+        this.error('delete operand may not be argument or var');
       }
       if (((_ref2 = this.operator) === '--' || _ref2 === '++') && (_ref3 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref3) >= 0)) {
-        throw SyntaxError('prefix increment/decrement may not have eval or arguments operand');
+        this.error("cannot increment/decrement \"" + (this.first.unwrapAll().value) + "\"");
       }
       if (this.isUnary()) {
         return this.compileUnary(o);
@@ -2241,23 +2375,33 @@
       if (isChain) {
         return this.compileChain(o);
       }
-      if (this.operator === '?') {
-        return this.compileExistence(o);
-      }
-      code = this.first.compile(o, LEVEL_OP) + ' ' + this.operator + ' ' + this.second.compile(o, LEVEL_OP);
-      if (o.level <= LEVEL_OP) {
-        return code;
-      } else {
-        return "(" + code + ")";
+      switch (this.operator) {
+        case '?':
+          return this.compileExistence(o);
+        case '**':
+          return this.compilePower(o);
+        case '//':
+          return this.compileFloorDivision(o);
+        case '%%':
+          return this.compileModulo(o);
+        default:
+          lhs = this.first.compileToFragments(o, LEVEL_OP);
+          rhs = this.second.compileToFragments(o, LEVEL_OP);
+          answer = [].concat(lhs, this.makeCode(" " + this.operator + " "), rhs);
+          if (o.level <= LEVEL_OP) {
+            return answer;
+          } else {
+            return this.wrapInBraces(answer);
+          }
       }
     };
 
     Op.prototype.compileChain = function(o) {
-      var code, fst, shared, _ref2;
+      var fragments, fst, shared, _ref2;
       _ref2 = this.first.second.cache(o), this.first.second = _ref2[0], shared = _ref2[1];
-      fst = this.first.compile(o, LEVEL_OP);
-      code = "" + fst + " " + (this.invert ? '&&' : '||') + " " + (shared.compile(o)) + " " + this.operator + " " + (this.second.compile(o, LEVEL_OP));
-      return "(" + code + ")";
+      fst = this.first.compileToFragments(o, LEVEL_OP);
+      fragments = fst.concat(this.makeCode(" " + (this.invert ? '&&' : '||') + " "), shared.compileToFragments(o), this.makeCode(" " + this.operator + " "), this.second.compileToFragments(o, LEVEL_OP));
+      return this.wrapInBraces(fragments);
     };
 
     Op.prototype.compileExistence = function(o) {
@@ -2271,27 +2415,52 @@
       }
       return new If(new Existence(fst), ref, {
         type: 'if'
-      }).addElse(this.second).compile(o);
+      }).addElse(this.second).compileToFragments(o);
     };
 
     Op.prototype.compileUnary = function(o) {
       var op, parts, plusMinus;
+      parts = [];
+      op = this.operator;
+      parts.push([this.makeCode(op)]);
+      if (op === '!' && this.first instanceof Existence) {
+        this.first.negated = !this.first.negated;
+        return this.first.compileToFragments(o);
+      }
       if (o.level >= LEVEL_ACCESS) {
-        return (new Parens(this)).compile(o);
+        return (new Parens(this)).compileToFragments(o);
       }
-      parts = [op = this.operator];
       plusMinus = op === '+' || op === '-';
       if ((op === 'new' || op === 'typeof' || op === 'delete') || plusMinus && this.first instanceof Op && this.first.operator === op) {
-        parts.push(' ');
+        parts.push([this.makeCode(' ')]);
       }
       if ((plusMinus && this.first instanceof Op) || (op === 'new' && this.first.isStatement(o))) {
         this.first = new Parens(this.first);
       }
-      parts.push(this.first.compile(o, LEVEL_OP));
+      parts.push(this.first.compileToFragments(o, LEVEL_OP));
       if (this.flip) {
         parts.reverse();
       }
-      return parts.join('');
+      return this.joinFragmentArrays(parts, '');
+    };
+
+    Op.prototype.compilePower = function(o) {
+      var pow;
+      pow = new Value(new Literal('Math'), [new Access(new Literal('pow'))]);
+      return new Call(pow, [this.first, this.second]).compileToFragments(o);
+    };
+
+    Op.prototype.compileFloorDivision = function(o) {
+      var div, floor;
+      floor = new Value(new Literal('Math'), [new Access(new Literal('floor'))]);
+      div = new Op('/', this.first, this.second);
+      return new Call(floor, [div]).compileToFragments(o);
+    };
+
+    Op.prototype.compileModulo = function(o) {
+      var mod;
+      mod = new Value(new Literal(utility('modulo')));
+      return new Call(mod, [this.first, this.second]).compileToFragments(o);
     };
 
     Op.prototype.toString = function(idt) {
@@ -2303,7 +2472,6 @@
   })(Base);
 
   exports.In = In = (function(_super) {
-
     __extends(In, _super);
 
     function In(object, array) {
@@ -2317,7 +2485,7 @@
 
     In.prototype.compileNode = function(o) {
       var hasSplat, obj, _i, _len, _ref2;
-      if (this.array instanceof Value && this.array.isArray()) {
+      if (this.array instanceof Value && this.array.isArray() && this.array.base.objects.length) {
         _ref2 = this.array.base.objects;
         for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
           obj = _ref2[_i];
@@ -2335,42 +2503,37 @@
     };
 
     In.prototype.compileOrTest = function(o) {
-      var cmp, cnj, i, item, ref, sub, tests, _ref2, _ref3;
-      if (this.array.base.objects.length === 0) {
-        return "" + (!!this.negated);
-      }
+      var cmp, cnj, i, item, ref, sub, tests, _i, _len, _ref2, _ref3, _ref4;
       _ref2 = this.object.cache(o, LEVEL_OP), sub = _ref2[0], 

<TRUNCATED>

Mime
View raw message