diff --git a/lib/command.js b/lib/command.js index bec08e73..fa2fe2e3 100644 --- a/lib/command.js +++ b/lib/command.js @@ -15,7 +15,7 @@ return process.binding('stdio').writeError(line + '\n'); }; BANNER = 'Usage: coffee [options] path/to/script.coffee'; - SWITCHES = [['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-j', '--join [FILE]', 'concatenate the scripts before compiling'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-b', '--bare', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['--nodejs [ARGS]', 'pass options through to the "node" binary'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']]; + SWITCHES = [['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-j', '--join [FILE]', 'concatenate the scripts before compiling'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JavaScript Lint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-b', '--bare', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['--nodejs [ARGS]', 'pass options through to the "node" binary'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']]; opts = {}; sources = []; contents = []; diff --git a/lib/nodes.js b/lib/nodes.js index ebf6db1b..ab78fa9d 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1096,24 +1096,19 @@ return this.ctor.noReturn = true; }; Class.prototype.compileNode = function(o) { - var decl, extension, klass, lname, name; + var decl, klass, lname, name; decl = this.determineName(); name = decl || this.name || '_Class'; lname = new Literal(name); this.setContext(name); this.walkBody(name); this.ensureConstructor(name); + if (this.parent) { + this.body.expressions.unshift(new Extends(lname, this.parent)); + } if (!(this.ctor instanceof Code)) { this.body.expressions.unshift(this.ctor); } - if (this.parent) { - extension = new Extends(lname, this.parent); - if (this.ctor instanceof Code) { - this.body.expressions.unshift(extension); - } else { - this.body.expressions.splice(1, 0, extension); - } - } this.body.expressions.push(lname); this.addBoundFunctions(o); klass = new Parens(Closure.wrap(this.body), true); diff --git a/src/nodes.coffee b/src/nodes.coffee index 18cb3fcf..55f493df 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -875,13 +875,8 @@ exports.Class = class Class extends Base @setContext name @walkBody name @ensureConstructor name + @body.expressions.unshift new Extends lname, @parent if @parent @body.expressions.unshift @ctor unless @ctor instanceof Code - if @parent - extension = new Extends lname, @parent - if @ctor instanceof Code - @body.expressions.unshift extension - else - @body.expressions.splice 1, 0, extension @body.expressions.push lname @addBoundFunctions o