exports.Value = class Value extends Base
constructor: (base, props, tag, isDefaultValue = no) ->
super()
- return base if not props and base instanceof Value
diff --git a/docs/v2/annotated-source/nodes.html b/docs/v2/annotated-source/nodes.html index cf60b5e1..ee70c642 100644 --- a/docs/v2/annotated-source/nodes.html +++ b/docs/v2/annotated-source/nodes.html @@ -1928,7 +1928,11 @@ or vanilla.
exports.Value = class Value extends Base
constructor: (base, props, tag, isDefaultValue = no) ->
super()
- return base if not props and base instanceof Value
When Parens
block includes a StatementLiteral
(e.g. (b; break) for a in arr
),
-it won’t compile since Parens
((b; break)
) is compiled as Value
and
-pure statement (break
) can’t be used in an expression.
-For this reasons, we return Block
instead of Parens
.
return base.unwrap() if base instanceof Parens and base.contains (n) -> n instanceof StatementLiteral
- @base = base
- @properties = props or []
- @[tag] = yes if tag
- @isDefaultValue = isDefaultValue
If this is a @foo =
assignment, if there are comments on @
move them
to be on foo
.
foo
.
- Add a property (or properties ) Access
to the list.
foo
.
- Some boolean checks for the benefit of other nodes.
@@ -2050,11 +2032,11 @@ to be onfoo
.
- The value can be unwrapped as its inner node, if there are no attached properties.
@@ -2067,11 +2049,11 @@ properties. -A reference has base part (this
value) and name part.
We cache them separately for compiling complex expressions.
@@ -2097,11 +2079,11 @@ We cache them separately for compiling complex expressions.
-
We compile a value to JavaScript by compiling and joining each property. Things get much more interesting if the chain of properties has soak @@ -2118,11 +2100,11 @@ evaluate anything twice when building the soak chain.
-Cached fragments enable correct order of the compilation, and reuse of variables in the scope. @@ -2146,11 +2128,11 @@ Example: -
Unfold a soak into an If
: a?.b
-> a.b if a?
Comment delimited by ###
(becoming /* */
).
Unindent multiline comments. They will be reindented later.
@@ -2246,11 +2228,11 @@ Example: -Don’t rely on fragment.type
, which can break when the compiler is minified.
Comment running from #
to the end of a line (becoming //
).
Don’t rely on fragment.type
, which can break when the compiler is minified.
Node for a function invocation.
@@ -2350,11 +2332,11 @@ Example: -@variable
never gets output as a result of this node getting created as
part of RegexWithInterpolations
, so for that case move any comments to
@@ -2371,11 +2353,11 @@ the grammar.
When setting the location, we sometimes need to update the start location to
account for a newly-discovered new
operator to the left of us. This
@@ -2398,11 +2380,11 @@ expands the range on the left, but not the right.
Tag this invocation as creating a new instance.
@@ -2420,11 +2402,11 @@ expands the range on the left, but not the right. -Soaked chained invocations unfold into if/else ternary structures.
@@ -2465,11 +2447,11 @@ expands the range on the left, but not the right. -Compile a vanilla function call.
@@ -2483,11 +2465,11 @@ expands the range on the left, but not the right. -If variable is Accessor
fragments are cached and used later
in Value::compileNode
to ensure correct order of the compilation,
@@ -2531,11 +2513,11 @@ Example:
-
Catch invalid CSX attributes:
@@ -2559,11 +2541,11 @@ Example: -Takes care of converting super()
calls into calls against the prototype’s
function of the same name.
@@ -2603,11 +2585,11 @@ expression.
If we might be in an expression we need to cache and return the result
@@ -2641,11 +2623,11 @@ exports.Super = class -A super()
call gets compiled to e.g. super.method()
, which means
the method
property name gets compiled for the first time here, and
@@ -2668,11 +2650,11 @@ that they’re there for the later compilation.
Regexes with interpolations are in fact just a variation of a Call
(a
RegExp()
call to be precise) with a StringWithInterpolations
inside.
Node to extend an object’s prototype with an ancestor object.
After goog.inherits
from the
@@ -2755,11 +2737,11 @@ After goog.inherits
from the
-
Hooks one constructor into another’s prototype chain.
@@ -2771,11 +2753,11 @@ Aftergoog.inherits
from the
- goog.inherits
from the
- A .
access into a property of a value, or the ::
shorthand for
an access into the object’s prototype.
A [ ... ]
indexed access into an array or object.
A range literal. Ranges can be used to extract portions (slices) of arrays, to specify a range for comprehensions, or as a value, to be expanded into the @@ -2891,11 +2873,11 @@ corresponding array of integers at runtime.
-Compiles the range’s source variables – where it starts and where it ends. But only if they need to be cached to avoid double evaluation.
@@ -2915,11 +2897,11 @@ But only if they need to be cached to avoid double evaluation. -When compiled normally, the range returns the contents of the for loop needed to iterate over the values in the range. Used by comprehensions.
@@ -2933,11 +2915,11 @@ needed to iterate over the values in the range. Used by comprehensions. -Set up endpoints.
@@ -2959,11 +2941,11 @@ needed to iterate over the values in the range. Used by comprehensions. -Generate the condition.
@@ -2974,11 +2956,11 @@ needed to iterate over the values in the range. Used by comprehensions. -Always check if the step
isn’t zero to avoid the infinite loop.
Generate the step.
@@ -3031,11 +3016,11 @@ needed to iterate over the values in the range. Used by comprehensions. -The final loop body.
@@ -3046,11 +3031,11 @@ needed to iterate over the values in the range. Used by comprehensions. -When used as a value, expand the range into the equivalent array.
@@ -3081,11 +3066,11 @@ needed to iterate over the values in the range. Used by comprehensions. -An array slice literal. Unlike JavaScript’s Array#slice
, the second parameter
specifies the index of the end of the slice, just as the first parameter
@@ -3116,11 +3101,11 @@ is the index of the beginning.
We have to be careful when trying to slice through the end of the array,
9e9
is used because not all implementations respect undefined
or 1/0
.
@@ -3134,11 +3119,11 @@ is the index of the beginning.
Handle an expression in the property access, e.g. a[!b in c..]
.
An object literal, nothing fancy.
@@ -3202,11 +3187,11 @@ is the index of the beginning. -Check for reserved words.
@@ -3227,11 +3212,11 @@ is the index of the beginning. -Check if object contains splat.
@@ -3250,11 +3235,11 @@ is the index of the beginning. -Object spread properties. https://github.com/tc39/proposal-object-rest-spread/blob/master/Spread.md
@@ -3268,11 +3253,11 @@ is the index of the beginning. -CSX attributes
@@ -3283,11 +3268,11 @@ is the index of the beginning. -If this object is the left-hand side of an assignment, all its children are too.
@@ -3342,11 +3327,11 @@ are too. -{ [foo()] }
output as { [ref = foo()]: ref }
.
{ [expression] }
output as { [expression]: expression }
.
Object spread properties. https://github.com/tc39/proposal-object-rest-spread/blob/master/Spread.md
obj2 = {a: 1, obj..., c: 3, d: 4}
→ obj2 = _extends({}, {a: 1}, obj, {c: 3, d: 4})
Store object spreads.
@@ -3454,11 +3439,11 @@ are too. -An array literal.
@@ -3507,11 +3492,11 @@ are too. -Detect if Elisions
at the beginning of the array are processed (e.g. [, , , a]).
Let compileCommentFragments
know to intersperse block comments
into the fragments created when compiling this array.
If this array is the left-hand side of an assignment, all its children are too.
@@ -3564,11 +3549,11 @@ are too. -If compiledObjs
includes newlines, we will output this as a multiline
array (i.e. with a newline and indentation after the [
). If an element
@@ -3591,11 +3576,11 @@ first element’s line comments get output before or after the array.
Add ‘, ‘ if all Elisions
from the beginning of the array are processed (e.g. [, , , a]) and
element isn’t Elision
or last element is Elision
(e.g. [a,,b,,])
Elision
or last element is Elision
(e.
- Elision
or last element is Elision
(e.
- The CoffeeScript class definition. Initialize a Class with its name, an optional superclass, and a body.
@@ -3671,11 +3656,11 @@ exports.Class = class -Special handling to allow class expr.A extends A
declarations
Anonymous classes are only valid in expressions
@@ -3746,11 +3731,11 @@ exports.Class = class -Figure out the appropriate name for this class
@@ -3821,11 +3806,11 @@ exports.Class = class -Add an expression to the class initializer
This is the key method for determining whether an expression in a class
@@ -3854,11 +3839,11 @@ opposed to the Object.defineProperty
method).
Checks if the given node is a valid ES class initializer method.
@@ -3872,11 +3857,11 @@ opposed to theObject.defineProperty
method).
- Returns a configured class initializer method
@@ -3973,11 +3958,11 @@ exports.ExecutableClassBody = +Traverse the class’s children and:
Make class/prototype assignments for invalid ES properties
@@ -4049,11 +4034,11 @@ exports.ExecutableClassBody = +The class scope is not available yet, so return the assignment to update later
@@ -4075,11 +4060,11 @@ exports.ExecutableClassBody = +Prevent exporting an anonymous class; all exported members must be named
@@ -4221,11 +4206,11 @@ exports.ModuleSpecifier = cl -The name of the variable entering the local scope
@@ -4251,11 +4236,11 @@ exports.ImportSpecifier = cl -Per the spec, symbols can’t be imported multiple times
(e.g. import { foo, foo } from 'lib'
is invalid)
The Assign is used to assign a local variable to value, or to set the property of an object – including within object literals.
@@ -4329,11 +4314,11 @@ property of an object – including within object literals. -Compile an assignment, delegating to compileDestructuring
or
compileSplice
if appropriate. Keep track of the name of the base object
@@ -4349,11 +4334,11 @@ has not been seen yet within the current scope, declare it.
When compiling @variable
, remember if it is part of a function parameter.
If @variable
is an array or an object, we’re destructuring;
if it’s also isAssignable()
, the destructuring syntax is supported
@@ -4382,11 +4367,11 @@ and convert this ES-unsupported destructuring into acceptable output.
This is the left-hand side of an assignment; let Arr
and Obj
know that, so that those nodes know that they’re assignable as
@@ -4399,11 +4384,11 @@ destructured variables.
Check if @variable contains Obj with splats.
@@ -4415,11 +4400,11 @@ destructured variables. -Object destructuring. Can be removed once ES proposal hits Stage 4.
@@ -4446,11 +4431,11 @@ destructured variables. -moduleDeclaration
can be 'import'
or 'export'
.
If this assignment identifier has one or more herecomments
attached, output them as part of the declarations line (unless
@@ -4517,11 +4502,11 @@ the comment to be between the class name and the {
.
Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assignment_without_declaration, if we’re destructuring without declaring, the destructuring assignment must be wrapped in parentheses. @@ -4538,11 +4523,11 @@ The assignment is wrapped in parentheses if ‘o.level’ has lower precedence t -
Check object destructuring variable for rest elements; can be removed once ES proposal hits Stage 4.
@@ -4554,11 +4539,11 @@ can be removed once ES proposal hits Stage 4. -Returns a safe (cached) reference to the key for a given property
@@ -4574,11 +4559,11 @@ can be removed once ES proposal hits Stage 4. -Returns the name of a given property for use with excludeProps
Property names are quoted (e.g. a: b
-> ‘a’), and everything else uses the key reference
@@ -4597,11 +4582,11 @@ Property names are quoted (e.g. a: b
-> ‘a’), and everything
-
Recursive function for searching and storing rest elements in objects.
e.g. {[properties...]} = source
.
{[properties...]} = source
.
- prop is k: expr
, we need to check expr
for nested splats
{[properties...]} = source
.
- prop is k = {...}
{[properties...]} = source
.
- prop is k: {...}
{[properties...]} = source
.
- prop is k: {...} = default
{[properties...]} = source
.
- Remove rest element from the properties after iteration
@@ -4713,11 +4698,11 @@ e.g.{[properties...]} = source
.
- Cache the value for reuse with rest elements.
@@ -4732,11 +4717,11 @@ e.g.{[properties...]} = source
.
- Find all rest elements.
@@ -4758,11 +4743,11 @@ e.g.{[properties...]} = source
.
- Remove leading tab and trailing semicolon
@@ -4776,11 +4761,11 @@ e.g.{[properties...]} = source
.
- Brief implementation of recursive pattern matching, when assigning array or object literals to a value. Peeks at their properties to assign inner names.
@@ -4796,11 +4781,11 @@ object literals to a value. Peeks at their properties to assign inner names. -Special-case for {} = a
and [] = a
(empty patterns).
Compile to simply a
.
a
.
- Disallow [...] = a
for some reason. (Could be equivalent to [] = a
?)
a
.
-