haml-more 0.4.0.c → 0.4.0.d
Sign up to get free protection for your applications and to get access to all the features.
- data/vendor/coffee-script/Cakefile +8 -0
- data/vendor/coffee-script/Rakefile +11 -0
- data/vendor/coffee-script/documentation/index.html.erb +85 -50
- data/vendor/coffee-script/documentation/js/aliases.js +1 -1
- data/vendor/coffee-script/documentation/js/arguments.js +1 -1
- data/vendor/coffee-script/documentation/js/array_comprehensions.js +1 -1
- data/vendor/coffee-script/documentation/js/assignment.js +1 -1
- data/vendor/coffee-script/documentation/js/cake_tasks.js +1 -1
- data/vendor/coffee-script/documentation/js/comparisons.js +1 -1
- data/vendor/coffee-script/documentation/js/conditionals.js +1 -1
- data/vendor/coffee-script/documentation/js/embedded.js +1 -1
- data/vendor/coffee-script/documentation/js/existence.js +1 -1
- data/vendor/coffee-script/documentation/js/expressions.js +1 -1
- data/vendor/coffee-script/documentation/js/expressions_assignment.js +1 -1
- data/vendor/coffee-script/documentation/js/expressions_comprehension.js +1 -1
- data/vendor/coffee-script/documentation/js/expressions_try.js +1 -1
- data/vendor/coffee-script/documentation/js/fat_arrow.js +1 -1
- data/vendor/coffee-script/documentation/js/functions.js +1 -1
- data/vendor/coffee-script/documentation/js/heredocs.js +1 -1
- data/vendor/coffee-script/documentation/js/multiple_return_values.js +1 -1
- data/vendor/coffee-script/documentation/js/object_comprehensions.js +1 -1
- data/vendor/coffee-script/documentation/js/object_extraction.js +1 -1
- data/vendor/coffee-script/documentation/js/objects_and_arrays.js +1 -1
- data/vendor/coffee-script/documentation/js/overview.js +1 -1
- data/vendor/coffee-script/documentation/js/parallel_assignment.js +1 -1
- data/vendor/coffee-script/documentation/js/range_comprehensions.js +1 -1
- data/vendor/coffee-script/documentation/js/scope.js +1 -1
- data/vendor/coffee-script/documentation/js/slices.js +1 -1
- data/vendor/coffee-script/documentation/js/soaks.js +1 -1
- data/vendor/coffee-script/documentation/js/splats.js +1 -1
- data/vendor/coffee-script/documentation/js/splices.js +1 -1
- data/vendor/coffee-script/documentation/js/strings.js +1 -1
- data/vendor/coffee-script/documentation/js/super.js +1 -1
- data/vendor/coffee-script/documentation/js/switch.js +1 -1
- data/vendor/coffee-script/documentation/js/try.js +1 -1
- data/vendor/coffee-script/documentation/js/while.js +1 -1
- data/vendor/coffee-script/extras/EXTRAS +9 -1
- data/vendor/coffee-script/extras/coffee-script.js +1 -0
- data/vendor/coffee-script/index.html +83 -48
- data/vendor/coffee-script/lib/cake.js +30 -32
- data/vendor/coffee-script/lib/coffee-script.js +12 -16
- data/vendor/coffee-script/lib/command_line.js +64 -74
- data/vendor/coffee-script/lib/grammar.js +1 -1
- data/vendor/coffee-script/lib/lexer.js +1 -1
- data/vendor/coffee-script/lib/narwhal.js +1 -1
- data/vendor/coffee-script/lib/nodes.js +48 -44
- data/vendor/coffee-script/lib/optparse.js +11 -17
- data/vendor/coffee-script/lib/repl.js +1 -1
- data/vendor/coffee-script/lib/rewriter.js +1 -1
- data/vendor/coffee-script/lib/scope.js +1 -1
- data/vendor/coffee-script/package.json +1 -1
- data/vendor/coffee-script/src/cake.coffee +15 -15
- data/vendor/coffee-script/src/coffee-script.coffee +6 -6
- data/vendor/coffee-script/src/command_line.coffee +43 -39
- data/vendor/coffee-script/src/nodes.coffee +43 -41
- data/vendor/coffee-script/src/optparse.coffee +6 -13
- data/vendor/coffee-script/test/test_destructuring_assignment.coffee +6 -0
- metadata +7 -6
@@ -1,4 +1,6 @@
|
|
1
1
|
# `cake` is a simplified version of Make (Rake, Jake) for CoffeeScript.
|
2
|
+
# You define tasks with names and descriptions in a Cakefile, and can call them
|
3
|
+
# from the command line, or invoke them from other tasks.
|
2
4
|
|
3
5
|
fs: require 'fs'
|
4
6
|
path: require 'path'
|
@@ -6,11 +8,7 @@ coffee: require 'coffee-script'
|
|
6
8
|
|
7
9
|
tasks: {}
|
8
10
|
|
9
|
-
|
10
|
-
process.stdio.writeError('No such task: "' + task + '"\n')
|
11
|
-
process.exit(1)
|
12
|
-
|
13
|
-
# Mixin the Cake functionality.
|
11
|
+
# Mixin the top-level Cake functions for Cakefiles to use.
|
14
12
|
process.mixin {
|
15
13
|
|
16
14
|
# Define a task with a name, a description, and the action itself.
|
@@ -23,13 +21,6 @@ process.mixin {
|
|
23
21
|
tasks[name].action()
|
24
22
|
}
|
25
23
|
|
26
|
-
# Display the list of Cake tasks.
|
27
|
-
print_tasks: ->
|
28
|
-
for name, task of tasks
|
29
|
-
spaces: 20 - name.length
|
30
|
-
spaces: if spaces > 0 then (' ' for i in [0..spaces]).join('') else ''
|
31
|
-
puts "cake " + name + spaces + ' # ' + task.description
|
32
|
-
|
33
24
|
# Running `cake` runs the tasks you pass asynchronously (node-style), or
|
34
25
|
# prints them out, with no arguments.
|
35
26
|
exports.run: ->
|
@@ -39,7 +30,16 @@ exports.run: ->
|
|
39
30
|
fs.readFile 'Cakefile', (err, source) ->
|
40
31
|
eval coffee.compile source
|
41
32
|
return print_tasks() unless args.length
|
42
|
-
for arg in args
|
43
|
-
no_such_task arg unless tasks[arg]
|
44
|
-
tasks[arg].action()
|
33
|
+
invoke arg for arg in args
|
45
34
|
|
35
|
+
# Display the list of Cake tasks.
|
36
|
+
print_tasks: ->
|
37
|
+
for name, task of tasks
|
38
|
+
spaces: 20 - name.length
|
39
|
+
spaces: if spaces > 0 then (' ' for i in [0..spaces]).join('') else ''
|
40
|
+
puts "cake " + name + spaces + ' # ' + task.description
|
41
|
+
|
42
|
+
# Print an error and exit when attempting to all an undefined task.
|
43
|
+
no_such_task: (task) ->
|
44
|
+
process.stdio.writeError('No such task: "' + task + '"\n')
|
45
|
+
process.exit(1)
|
@@ -24,7 +24,7 @@ parser.lexer: {
|
|
24
24
|
showPosition: -> @pos
|
25
25
|
}
|
26
26
|
|
27
|
-
exports.VERSION: '0.5.
|
27
|
+
exports.VERSION: '0.5.2'
|
28
28
|
|
29
29
|
# Compile CoffeeScript to JavaScript, using the Coffee/Jison compiler.
|
30
30
|
exports.compile: (code, options) ->
|
@@ -38,8 +38,8 @@ exports.tokenize: (code) ->
|
|
38
38
|
exports.tree: (code) ->
|
39
39
|
parser.parse lexer.tokenize code
|
40
40
|
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
# Activate CoffeeScript in the browser by having it compile and eval
|
42
|
+
# all script tags with a content-type of text/coffeescript.
|
43
|
+
if document? and document.getElementsByTagName
|
44
|
+
for tag in document.getElementsByTagName('script') when tag.type is 'text/coffeescript'
|
45
|
+
eval exports.compile tag.innerHTML
|
@@ -1,7 +1,7 @@
|
|
1
|
-
fs:
|
2
|
-
path:
|
3
|
-
|
4
|
-
|
1
|
+
fs: require 'fs'
|
2
|
+
path: require 'path'
|
3
|
+
optparse: require 'optparse'
|
4
|
+
CoffeeScript: require 'coffee-script'
|
5
5
|
|
6
6
|
BANNER: '''
|
7
7
|
coffee compiles CoffeeScript source files into JavaScript.
|
@@ -17,10 +17,11 @@ SWITCHES: [
|
|
17
17
|
['-w', '--watch', 'watch scripts for changes, and recompile']
|
18
18
|
['-p', '--print', 'print the compiled JavaScript to stdout']
|
19
19
|
['-l', '--lint', 'pipe the compiled JavaScript through JSLint']
|
20
|
+
['-s', '--stdio', 'listen for and compile scripts over stdio']
|
20
21
|
['-e', '--eval', 'compile a string from the command line']
|
22
|
+
['-n', '--no-wrap', 'compile without the top-level function wrapper']
|
21
23
|
['-t', '--tokens', 'print the tokens that the lexer produces']
|
22
24
|
['-tr','--tree', 'print the parse tree that Jison produces']
|
23
|
-
['-n', '--no-wrap', 'compile without the top-level function wrapper']
|
24
25
|
['-v', '--version', 'display CoffeeScript version']
|
25
26
|
['-h', '--help', 'display this help message']
|
26
27
|
]
|
@@ -32,9 +33,12 @@ option_parser: null
|
|
32
33
|
# The CommandLine handles all of the functionality of the `coffee` utility.
|
33
34
|
exports.run: ->
|
34
35
|
parse_options()
|
35
|
-
return
|
36
|
-
return
|
37
|
-
|
36
|
+
return usage() if options.help
|
37
|
+
return version() if options.version
|
38
|
+
return require 'repl' if options.interactive
|
39
|
+
return compile_stdio() if options.stdio
|
40
|
+
return compile_script 'unknown', sources[0] if options.eval
|
41
|
+
return usage() unless sources.length
|
38
42
|
separator: sources.indexOf '--'
|
39
43
|
flags: []
|
40
44
|
if separator >= 0
|
@@ -52,7 +56,7 @@ usage: ->
|
|
52
56
|
|
53
57
|
# The "--version" message.
|
54
58
|
version: ->
|
55
|
-
puts "CoffeeScript version " +
|
59
|
+
puts "CoffeeScript version " + CoffeeScript.VERSION
|
56
60
|
process.exit 0
|
57
61
|
|
58
62
|
# Compiles the source CoffeeScript, returning the desired JavaScript, tokens,
|
@@ -62,23 +66,30 @@ compile_scripts: ->
|
|
62
66
|
fs.readFile source, (err, code) -> compile_script(source, code)
|
63
67
|
compile(source) for source in sources
|
64
68
|
|
65
|
-
|
66
69
|
# Compile a single source script, containing the given code, according to the
|
67
70
|
# requested options. Both compile_scripts and watch_scripts share this method.
|
68
71
|
compile_script: (source, code) ->
|
69
|
-
|
70
|
-
o: if opts.no_wrap then {no_wrap: true} else {}
|
72
|
+
o: options
|
71
73
|
try
|
72
|
-
if
|
73
|
-
else if
|
74
|
+
if o.tokens then print_tokens CoffeeScript.tokenize code
|
75
|
+
else if o.tree then puts CoffeeScript.tree(code).toString()
|
74
76
|
else
|
75
|
-
js:
|
76
|
-
if
|
77
|
-
else if
|
78
|
-
else if
|
79
|
-
else
|
77
|
+
js: CoffeeScript.compile code, compile_options()
|
78
|
+
if o.run then eval js
|
79
|
+
else if o.lint then lint js
|
80
|
+
else if o.print or o.eval then print js
|
81
|
+
else write_js source, js
|
80
82
|
catch err
|
81
|
-
if
|
83
|
+
if o.watch then puts err.message else throw err
|
84
|
+
|
85
|
+
# Listen for and compile scripts over stdio.
|
86
|
+
compile_stdio: ->
|
87
|
+
code: ''
|
88
|
+
process.stdio.open()
|
89
|
+
process.stdio.addListener 'data', (string) ->
|
90
|
+
code += string if string
|
91
|
+
process.stdio.addListener 'close', ->
|
92
|
+
process.stdio.write CoffeeScript.compile code, compile_options()
|
82
93
|
|
83
94
|
# Watch a list of source CoffeeScript files, recompiling them every time the
|
84
95
|
# files are updated.
|
@@ -106,25 +117,18 @@ lint: (js) ->
|
|
106
117
|
jsl.write js
|
107
118
|
jsl.close()
|
108
119
|
|
120
|
+
# Pretty-print a token stream.
|
121
|
+
print_tokens: (tokens) ->
|
122
|
+
strings: for token in tokens
|
123
|
+
'[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']'
|
124
|
+
puts strings.join(' ')
|
125
|
+
|
109
126
|
# Use OptionParser for all the options.
|
110
127
|
parse_options: ->
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
oparser.add 'interactive', -> opts.interactive: true
|
116
|
-
oparser.add 'run', -> opts.run: true
|
117
|
-
oparser.add 'output', (dir) -> opts.output: dir
|
118
|
-
oparser.add 'watch', -> opts.watch: true
|
119
|
-
oparser.add 'print', -> opts.print: true
|
120
|
-
oparser.add 'lint', -> opts.lint: true
|
121
|
-
oparser.add 'eval', -> opts.eval: true
|
122
|
-
oparser.add 'tokens', -> opts.tokens: true
|
123
|
-
oparser.add 'tree', -> opts.tree: true
|
124
|
-
oparser.add 'no-wrap', -> opts.no_wrap: true
|
125
|
-
oparser.add 'help', => usage()
|
126
|
-
oparser.add 'version', => version()
|
127
|
-
|
128
|
-
paths: oparser.parse(process.ARGV)
|
129
|
-
sources: paths[2...paths.length]
|
128
|
+
option_parser: new optparse.OptionParser SWITCHES, BANNER
|
129
|
+
options: option_parser.parse(process.ARGV)
|
130
|
+
sources: options.arguments[2...options.arguments.length]
|
130
131
|
|
132
|
+
# The options to pass to the CoffeeScript compiler.
|
133
|
+
compile_options: ->
|
134
|
+
if options['no-wrap'] then {no_wrap: true} else {}
|
@@ -54,13 +54,13 @@ statement: (klass, only) ->
|
|
54
54
|
# generated code should be wrapped up in a closure. An options hash is passed
|
55
55
|
# and cloned throughout, containing messages from higher in the AST,
|
56
56
|
# information about the current scope, and indentation level.
|
57
|
-
|
57
|
+
BaseNode: exports.BaseNode: ->
|
58
58
|
|
59
59
|
# This is extremely important -- we convert JS statements into expressions
|
60
60
|
# by wrapping them in a closure, only if it's possible, and we're not at
|
61
61
|
# the top level of a block (which would be unnecessary), and we haven't
|
62
62
|
# already been asked to return the result.
|
63
|
-
|
63
|
+
BaseNode::compile: (o) ->
|
64
64
|
@options: merge o or {}
|
65
65
|
@indent: o.indent
|
66
66
|
del @options, 'operation' unless @operation_sensitive()
|
@@ -72,46 +72,46 @@ Node::compile: (o) ->
|
|
72
72
|
|
73
73
|
# Statements converted into expressions share scope with their parent
|
74
74
|
# closure, to preserve JavaScript-style lexical scope.
|
75
|
-
|
75
|
+
BaseNode::compile_closure: (o) ->
|
76
76
|
@indent: o.indent
|
77
77
|
o.shared_scope: o.scope
|
78
78
|
ClosureNode.wrap(this).compile(o)
|
79
79
|
|
80
80
|
# If the code generation wishes to use the result of a complex expression
|
81
81
|
# in multiple places, ensure that the expression is only ever evaluated once.
|
82
|
-
|
82
|
+
BaseNode::compile_reference: (o) ->
|
83
83
|
reference: new LiteralNode(o.scope.free_variable())
|
84
84
|
compiled: new AssignNode(reference, this)
|
85
85
|
[compiled, reference]
|
86
86
|
|
87
87
|
# Quick short method for the current indentation level, plus tabbing in.
|
88
|
-
|
88
|
+
BaseNode::idt: (tabs) ->
|
89
89
|
idt: (@indent || '')
|
90
90
|
idt += TAB for i in [0...(tabs or 0)]
|
91
91
|
idt
|
92
92
|
|
93
93
|
# Does this node, or any of its children, contain a node of a certain kind?
|
94
|
-
|
94
|
+
BaseNode::contains: (block) ->
|
95
95
|
for node in @children
|
96
96
|
return true if block(node)
|
97
|
-
return true if node instanceof
|
97
|
+
return true if node instanceof BaseNode and node.contains block
|
98
98
|
false
|
99
99
|
|
100
100
|
# toString representation of the node, for inspecting the parse tree.
|
101
|
-
|
101
|
+
BaseNode::toString: (idt) ->
|
102
102
|
idt ||= ''
|
103
103
|
'\n' + idt + @type + (child.toString(idt + TAB) for child in @children).join('')
|
104
104
|
|
105
105
|
# Default implementations of the common node methods.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
BaseNode::unwrap: -> this
|
107
|
+
BaseNode::children: []
|
108
|
+
BaseNode::is_statement: -> false
|
109
|
+
BaseNode::is_statement_only: -> false
|
110
|
+
BaseNode::top_sensitive: -> false
|
111
|
+
BaseNode::operation_sensitive: -> false
|
112
112
|
|
113
113
|
# A collection of nodes, each one representing an expression.
|
114
|
-
Expressions: exports.Expressions: inherit
|
114
|
+
Expressions: exports.Expressions: inherit BaseNode, {
|
115
115
|
type: 'Expressions'
|
116
116
|
|
117
117
|
constructor: (nodes) ->
|
@@ -144,7 +144,7 @@ Expressions: exports.Expressions: inherit Node, {
|
|
144
144
|
|
145
145
|
compile: (o) ->
|
146
146
|
o ||= {}
|
147
|
-
if o.scope then
|
147
|
+
if o.scope then BaseNode::compile.call(this, o) else @compile_root(o)
|
148
148
|
|
149
149
|
# Compile each expression in the Expressions body.
|
150
150
|
compile_node: (o) ->
|
@@ -156,7 +156,7 @@ Expressions: exports.Expressions: inherit Node, {
|
|
156
156
|
o.scope: new Scope(null, this, null)
|
157
157
|
code: if o.globals then @compile_node(o) else @compile_with_declarations(o)
|
158
158
|
code: code.replace(TRAILING_WHITESPACE, '')
|
159
|
-
if o.no_wrap then code else "(function(){\n"+code+"\n})()
|
159
|
+
if o.no_wrap then code else "(function(){\n"+code+"\n})();\n"
|
160
160
|
|
161
161
|
# Compile the expressions body, with declarations of all inner variables
|
162
162
|
# pushed up to the top.
|
@@ -192,7 +192,7 @@ statement Expressions
|
|
192
192
|
|
193
193
|
# Literals are static values that can be passed through directly into
|
194
194
|
# JavaScript without translation, eg.: strings, numbers, true, false, null...
|
195
|
-
LiteralNode: exports.LiteralNode: inherit
|
195
|
+
LiteralNode: exports.LiteralNode: inherit BaseNode, {
|
196
196
|
type: 'Literal'
|
197
197
|
|
198
198
|
constructor: (value) ->
|
@@ -217,7 +217,7 @@ LiteralNode: exports.LiteralNode: inherit Node, {
|
|
217
217
|
LiteralNode::is_statement_only: LiteralNode::is_statement
|
218
218
|
|
219
219
|
# Return an expression, or wrap it in a closure and return it.
|
220
|
-
ReturnNode: exports.ReturnNode: inherit
|
220
|
+
ReturnNode: exports.ReturnNode: inherit BaseNode, {
|
221
221
|
type: 'Return'
|
222
222
|
|
223
223
|
constructor: (expression) ->
|
@@ -233,7 +233,7 @@ ReturnNode: exports.ReturnNode: inherit Node, {
|
|
233
233
|
statement ReturnNode, true
|
234
234
|
|
235
235
|
# A value, indexed or dotted into, or vanilla.
|
236
|
-
ValueNode: exports.ValueNode: inherit
|
236
|
+
ValueNode: exports.ValueNode: inherit BaseNode, {
|
237
237
|
type: 'Value'
|
238
238
|
|
239
239
|
SOAK: " == undefined ? undefined : "
|
@@ -302,7 +302,7 @@ ValueNode: exports.ValueNode: inherit Node, {
|
|
302
302
|
|
303
303
|
# Pass through CoffeeScript comments into JavaScript comments at the
|
304
304
|
# same position.
|
305
|
-
CommentNode: exports.CommentNode: inherit
|
305
|
+
CommentNode: exports.CommentNode: inherit BaseNode, {
|
306
306
|
type: 'Comment'
|
307
307
|
|
308
308
|
constructor: (lines) ->
|
@@ -318,7 +318,7 @@ statement CommentNode
|
|
318
318
|
|
319
319
|
# Node for a function invocation. Takes care of converting super() calls into
|
320
320
|
# calls against the prototype's function of the same name.
|
321
|
-
CallNode: exports.CallNode: inherit
|
321
|
+
CallNode: exports.CallNode: inherit BaseNode, {
|
322
322
|
type: 'Call'
|
323
323
|
|
324
324
|
constructor: (variable, args) ->
|
@@ -366,7 +366,7 @@ CallNode: exports.CallNode: inherit Node, {
|
|
366
366
|
|
367
367
|
# Node to extend an object's prototype with an ancestor object.
|
368
368
|
# After goog.inherits from the Closure Library.
|
369
|
-
ExtendsNode: exports.ExtendsNode: inherit
|
369
|
+
ExtendsNode: exports.ExtendsNode: inherit BaseNode, {
|
370
370
|
type: 'Extends'
|
371
371
|
|
372
372
|
constructor: (child, parent) ->
|
@@ -399,7 +399,7 @@ statement ExtendsNode
|
|
399
399
|
|
400
400
|
# A dotted accessor into a part of a value, or the :: shorthand for
|
401
401
|
# an accessor into the object's prototype.
|
402
|
-
AccessorNode: exports.AccessorNode: inherit
|
402
|
+
AccessorNode: exports.AccessorNode: inherit BaseNode, {
|
403
403
|
type: 'Accessor'
|
404
404
|
|
405
405
|
constructor: (name, tag) ->
|
@@ -414,7 +414,7 @@ AccessorNode: exports.AccessorNode: inherit Node, {
|
|
414
414
|
}
|
415
415
|
|
416
416
|
# An indexed accessor into a part of an array or object.
|
417
|
-
IndexNode: exports.IndexNode: inherit
|
417
|
+
IndexNode: exports.IndexNode: inherit BaseNode, {
|
418
418
|
type: 'Index'
|
419
419
|
|
420
420
|
constructor: (index, tag) ->
|
@@ -429,7 +429,7 @@ IndexNode: exports.IndexNode: inherit Node, {
|
|
429
429
|
|
430
430
|
# A range literal. Ranges can be used to extract portions (slices) of arrays,
|
431
431
|
# or to specify a range for list comprehensions.
|
432
|
-
RangeNode: exports.RangeNode: inherit
|
432
|
+
RangeNode: exports.RangeNode: inherit BaseNode, {
|
433
433
|
type: 'Range'
|
434
434
|
|
435
435
|
constructor: (from, to, exclusive) ->
|
@@ -469,7 +469,7 @@ RangeNode: exports.RangeNode: inherit Node, {
|
|
469
469
|
# An array slice literal. Unlike JavaScript's Array#slice, the second parameter
|
470
470
|
# specifies the index of the end of the slice (just like the first parameter)
|
471
471
|
# is the index of the beginning.
|
472
|
-
SliceNode: exports.SliceNode: inherit
|
472
|
+
SliceNode: exports.SliceNode: inherit BaseNode, {
|
473
473
|
type: 'Slice'
|
474
474
|
|
475
475
|
constructor: (range) ->
|
@@ -485,7 +485,7 @@ SliceNode: exports.SliceNode: inherit Node, {
|
|
485
485
|
}
|
486
486
|
|
487
487
|
# An object literal.
|
488
|
-
ObjectNode: exports.ObjectNode: inherit
|
488
|
+
ObjectNode: exports.ObjectNode: inherit BaseNode, {
|
489
489
|
type: 'Object'
|
490
490
|
|
491
491
|
constructor: (props) ->
|
@@ -512,7 +512,7 @@ ObjectNode: exports.ObjectNode: inherit Node, {
|
|
512
512
|
}
|
513
513
|
|
514
514
|
# An array literal.
|
515
|
-
ArrayNode: exports.ArrayNode: inherit
|
515
|
+
ArrayNode: exports.ArrayNode: inherit BaseNode, {
|
516
516
|
type: 'Array'
|
517
517
|
|
518
518
|
constructor: (objects) ->
|
@@ -559,7 +559,7 @@ ClosureNode: exports.ClosureNode: {
|
|
559
559
|
}
|
560
560
|
|
561
561
|
# Setting the value of a local variable, or the value of an object property.
|
562
|
-
AssignNode: exports.AssignNode: inherit
|
562
|
+
AssignNode: exports.AssignNode: inherit BaseNode, {
|
563
563
|
type: 'Assign'
|
564
564
|
|
565
565
|
PROTO_ASSIGN: /^(\S+)\.prototype/
|
@@ -617,7 +617,9 @@ AssignNode: exports.AssignNode: inherit Node, {
|
|
617
617
|
idx: new LiteralNode(idx) unless typeof idx is 'object'
|
618
618
|
val: new ValueNode(new LiteralNode(val_var), [new access_class(idx)])
|
619
619
|
assigns.push(new AssignNode(obj, val).compile(o))
|
620
|
-
assigns.join("\n")
|
620
|
+
code: assigns.join("\n")
|
621
|
+
code += '\n' + @idt() + 'return ' + @variable.compile(o) + ';' if o.returns
|
622
|
+
code
|
621
623
|
|
622
624
|
compile_splice: (o) ->
|
623
625
|
name: @variable.compile(merge(o, {only_first: true}))
|
@@ -632,7 +634,7 @@ AssignNode: exports.AssignNode: inherit Node, {
|
|
632
634
|
|
633
635
|
# A function definition. The only node that creates a new Scope.
|
634
636
|
# A CodeNode does not have any children -- they're within the new scope.
|
635
|
-
CodeNode: exports.CodeNode: inherit
|
637
|
+
CodeNode: exports.CodeNode: inherit BaseNode, {
|
636
638
|
type: 'Code'
|
637
639
|
|
638
640
|
constructor: (params, body, tag) ->
|
@@ -676,7 +678,7 @@ CodeNode: exports.CodeNode: inherit Node, {
|
|
676
678
|
|
677
679
|
# A splat, either as a parameter to a function, an argument to a call,
|
678
680
|
# or in a destructuring assignment.
|
679
|
-
SplatNode: exports.SplatNode: inherit
|
681
|
+
SplatNode: exports.SplatNode: inherit BaseNode, {
|
680
682
|
type: 'Splat'
|
681
683
|
|
682
684
|
constructor: (name) ->
|
@@ -699,7 +701,7 @@ SplatNode: exports.SplatNode: inherit Node, {
|
|
699
701
|
|
700
702
|
# A while loop, the only sort of low-level loop exposed by CoffeeScript. From
|
701
703
|
# it, all other loops can be manufactured.
|
702
|
-
WhileNode: exports.WhileNode: inherit
|
704
|
+
WhileNode: exports.WhileNode: inherit BaseNode, {
|
703
705
|
type: 'While'
|
704
706
|
|
705
707
|
constructor: (condition, opts) ->
|
@@ -737,7 +739,7 @@ statement WhileNode
|
|
737
739
|
|
738
740
|
# Simple Arithmetic and logical operations. Performs some conversion from
|
739
741
|
# CoffeeScript operations into their JavaScript equivalents.
|
740
|
-
OpNode: exports.OpNode: inherit
|
742
|
+
OpNode: exports.OpNode: inherit BaseNode, {
|
741
743
|
type: 'Op'
|
742
744
|
|
743
745
|
CONVERSIONS: {
|
@@ -801,7 +803,7 @@ OpNode: exports.OpNode: inherit Node, {
|
|
801
803
|
}
|
802
804
|
|
803
805
|
# A try/catch/finally block.
|
804
|
-
TryNode: exports.TryNode: inherit
|
806
|
+
TryNode: exports.TryNode: inherit BaseNode, {
|
805
807
|
type: 'Try'
|
806
808
|
|
807
809
|
constructor: (attempt, error, recovery, ensure) ->
|
@@ -822,7 +824,7 @@ TryNode: exports.TryNode: inherit Node, {
|
|
822
824
|
statement TryNode
|
823
825
|
|
824
826
|
# Throw an exception.
|
825
|
-
ThrowNode: exports.ThrowNode: inherit
|
827
|
+
ThrowNode: exports.ThrowNode: inherit BaseNode, {
|
826
828
|
type: 'Throw'
|
827
829
|
|
828
830
|
constructor: (expression) ->
|
@@ -837,7 +839,7 @@ ThrowNode: exports.ThrowNode: inherit Node, {
|
|
837
839
|
statement ThrowNode, true
|
838
840
|
|
839
841
|
# Check an expression for existence (meaning not null or undefined).
|
840
|
-
ExistenceNode: exports.ExistenceNode: inherit
|
842
|
+
ExistenceNode: exports.ExistenceNode: inherit BaseNode, {
|
841
843
|
type: 'Existence'
|
842
844
|
|
843
845
|
constructor: (expression) ->
|
@@ -856,7 +858,7 @@ ExistenceNode.compile_test: (o, variable) ->
|
|
856
858
|
'(typeof ' + first.compile(o) + ' !== "undefined" && ' + second.compile(o) + ' !== null)'
|
857
859
|
|
858
860
|
# An extra set of parentheses, specified explicitly in the source.
|
859
|
-
ParentheticalNode: exports.ParentheticalNode: inherit
|
861
|
+
ParentheticalNode: exports.ParentheticalNode: inherit BaseNode, {
|
860
862
|
type: 'Paren'
|
861
863
|
|
862
864
|
constructor: (expression) ->
|
@@ -879,7 +881,7 @@ ParentheticalNode: exports.ParentheticalNode: inherit Node, {
|
|
879
881
|
# into a for loop. Also acts as an expression, able to return the result
|
880
882
|
# of the comprehenion. Unlike Python array comprehensions, it's able to pass
|
881
883
|
# the current index of the loop as a second parameter.
|
882
|
-
ForNode: exports.ForNode: inherit
|
884
|
+
ForNode: exports.ForNode: inherit BaseNode, {
|
883
885
|
type: 'For'
|
884
886
|
|
885
887
|
constructor: (body, source, name, index) ->
|
@@ -949,7 +951,7 @@ statement ForNode
|
|
949
951
|
# expression by pushing down requested returns to the expression bodies.
|
950
952
|
# Single-expression IfNodes are compiled into ternary operators if possible,
|
951
953
|
# because ternaries are first-class returnable assignable expressions.
|
952
|
-
IfNode: exports.IfNode: inherit
|
954
|
+
IfNode: exports.IfNode: inherit BaseNode, {
|
953
955
|
type: 'If'
|
954
956
|
|
955
957
|
constructor: (condition, body, else_body, tags) ->
|