Put back every utility functions on the global scope, automatically prefixed with __ and set them dynamically as reserved on the lexer.

This commit is contained in:
matehat
2010-03-30 16:48:43 -04:00
parent 27fb3763b4
commit 97096696a2
13 changed files with 146 additions and 158 deletions

View File

@@ -843,13 +843,13 @@ exports.SplatNode: class SplatNode extends BaseNode
for trailing in @trailings
o.scope.assign(trailing.compile(o), "arguments[arguments.length - $@trailings.length + $i]")
i: + 1
"$name = Array.prototype.slice.call(arguments, $@index, arguments.length - ${@trailings.length})"
"$name = ${o.scope.utility('arraySlice')}.call(arguments, $@index, arguments.length - ${@trailings.length})"
# A compiling a splat as a destructuring assignment means slicing arguments
# from the right-hand-side's corresponding array.
compile_value: (o, name, index, trailings) ->
if trailings? then "Array.prototype.slice.call($name, $index, ${name}.length - $trailings)" \
else "Array.prototype.slice.call($name, $index)"
if trailings? then "${o.scope.utility('arraySlice')}.call($name, $index, ${name}.length - $trailings)" \
else "${o.scope.utility('arraySlice')}.call($name, $index)"
# Utility function that converts arbitrary number of elements, mixed with
# splats, to a proper array