...
Note that in case no type check matches, the error has to be re-thrown! This code can be omitted if the original code contains a catch
clause with an untyped or *
typed error variable.
Operators
TODO
&&=
TODO
||=
Besides as
and is
, which are discussed in the Interfaces
section, only two operators are known to be missing in JavaScript, namely short-circuit-and-assignment (&&=
) and short-circuit-or-assignment (||=
).
For both operators, the trick is that both the left-hand-side and right-hand-side expression are not evaluated too often. To achieve this, we introduce auxiliary variables like for for each
. The code transformation examples are for &&=
only, as ||=
works analogously.
Simple Pattern:
ActionScript:
Code Block |
---|
<identifier> &&= <rhs>
|
JavaScript:
Code Block |
---|
<identifier> = <identifier> && <rhs>
|
Complex Pattern:
If the left-hand-side can be split into two expressions, where the first evaluates to some object and the second to some property, do so and rewrite:
ActionScript:
Code Block |
---|
<exp1>[<exp2>] &&= <rhs>
|
JavaScript:
Code Block |
---|
var $0 = <exp1>, $1 = <exp2>;
$0[$1] = $0[$1] && <rhs>;
|
Note that foo().y
is the same as foo()'y'
and thus also matches this pattern.TODO