1
- var Node , Negatable , Lines , Literal , Key , Index , Value , Call , Clone , Obj , Arr , Op , Assign , Import , Of , Existence , Fun , Class , Super , Parens , Splat , Statement , Throw , Return , While , For , Try , Switch , Case , If , Comment , Util , SE , UTILITIES , LEVEL_TOP , LEVEL_PAREN , LEVEL_LIST , LEVEL_COND , LEVEL_OP , LEVEL_ACCESS , TAB , IDENTIFIER , _ref , __extends = function ( sub , sup ) {
1
+ var Node , Negatable , Lines , Literal , Key , Index , Value , Call , Clone , List , Obj , Arr , Op , Assign , Import , Of , Existence , Fun , Class , Super , Parens , Splat , Statement , Throw , Return , While , For , Try , Switch , Case , If , Comment , Util , SE , UTILITIES , LEVEL_TOP , LEVEL_PAREN , LEVEL_LIST , LEVEL_COND , LEVEL_OP , LEVEL_ACCESS , TAB , IDENTIFIER , _ref , __extends = function ( sub , sup ) {
2
2
function ctor ( ) { } ctor . prototype = ( sub . superclass = sup ) . prototype ;
3
3
return ( sub . prototype = new ctor ) . constructor = sub ;
4
4
} , __importAll = function ( obj , src ) { for ( var key in src ) obj [ key ] = src [ key ] ; return obj } ;
@@ -135,6 +135,7 @@ Node = (function(){
135
135
_proto . isComplex = YES ;
136
136
_proto . isStatement = NO ;
137
137
_proto . isAssignable = NO ;
138
+ _proto . isEmpty = NO ;
138
139
_proto . jumps = NO ;
139
140
_proto . assigns = NO ;
140
141
_proto . hasDefault = NO ;
@@ -319,6 +320,13 @@ exports.Literal = Literal = (function(_super){
319
320
return '"' + this . value + '"' ;
320
321
} ;
321
322
_proto . isComplex = NO ;
323
+ _proto . isEmpty = function ( ) {
324
+ switch ( this . value ) {
325
+ case 'void' :
326
+ case 'null' :
327
+ return true ;
328
+ }
329
+ } ;
322
330
_proto . isAssignable = function ( ) {
323
331
return IDENTIFIER . test ( this . value ) ;
324
332
} ;
@@ -756,6 +764,15 @@ exports.Clone = Clone = (function(_super){
756
764
} ;
757
765
return Clone ;
758
766
} ( Node ) ) ;
767
+ List = ( function ( _super ) {
768
+ var _proto = __extends ( List , _super ) . prototype ;
769
+ function List ( ) { } List . name = 'List' ;
770
+ _proto . children = [ 'items' ] ;
771
+ _proto . isEmpty = function ( ) {
772
+ return ! this . items . length ;
773
+ } ;
774
+ return List ;
775
+ } ( Node ) ) ;
759
776
exports . Obj = Obj = ( function ( _super ) {
760
777
var _proto = __extends ( Obj , _super ) . prototype ;
761
778
function _ctor ( ) { } _ctor . prototype = _proto ;
@@ -764,7 +781,6 @@ exports.Obj = Obj = (function(_super){
764
781
_this . items = items || [ ] ;
765
782
return _this ;
766
783
} Obj . name = 'Obj' ;
767
- _proto . children = [ 'items' ] ;
768
784
_proto . assigns = function ( it ) {
769
785
var node , _i , _ref , _len ;
770
786
for ( _i = 0 , _len = ( _ref = this . items ) . length ; _i < _len ; ++ _i ) {
@@ -829,7 +845,7 @@ exports.Obj = Obj = (function(_super){
829
845
}
830
846
} ;
831
847
return Obj ;
832
- } ( Node ) ) ;
848
+ } ( List ) ) ;
833
849
exports . Arr = Arr = ( function ( _super ) {
834
850
var _proto = __extends ( Arr , _super ) . prototype ;
835
851
function _ctor ( ) { } _ctor . prototype = _proto ;
@@ -863,7 +879,7 @@ exports.Arr = Arr = (function(_super){
863
879
}
864
880
} ;
865
881
return Arr ;
866
- } ( Obj ) ) ;
882
+ } ( List ) ) ;
867
883
exports . Op = Op = ( function ( _super ) {
868
884
var EQUALITY , COMPARER , _proto = __extends ( Op , _super ) . prototype ;
869
885
function _ctor ( ) { } _ctor . prototype = _proto ;
@@ -1045,7 +1061,11 @@ exports.Assign = Assign = (function(_super){
1045
1061
} ;
1046
1062
METHOD_DEF = / ^ (?: ( [ \s \S ] + ) \. p r o t o t y p e (? = \. ) | [ \s \S ] * ?) (?: (?: \. | ^ ) ( [ $ A - Z a - z _ \x7f - \uffff ] [ $ \w \x7f - \uffff ] * ) | \[ ( ( [ \" \' ] ) .+ ?\4| \d + ) ] ) $ / ;
1047
1063
_proto . compileNode = function ( o ) {
1048
- var left , right , name , that , val , code ;
1064
+ var right , left , name , that , val , code ;
1065
+ right = this . right ;
1066
+ if ( this . left . isEmpty ( ) ) {
1067
+ return right . compile ( o , LEVEL_ACCESS ) ;
1068
+ }
1049
1069
left = this . transleft ( o ) ;
1050
1070
if ( left . items ) {
1051
1071
if ( ! this . logic ) {
@@ -1056,7 +1076,6 @@ exports.Assign = Assign = (function(_super){
1056
1076
if ( this . logic ) {
1057
1077
return this . compileConditional ( o , left ) ;
1058
1078
}
1059
- right = this . right ;
1060
1079
if ( left . hasDefault ( ) ) {
1061
1080
right = Op ( left . op , right , left . second ) ;
1062
1081
left = left . first ;
@@ -1102,9 +1121,7 @@ exports.Assign = Assign = (function(_super){
1102
1121
_proto . compileDestructuring = function ( o , left ) {
1103
1122
var items , len , rite , rref , cache , list , code ;
1104
1123
items = left . items ;
1105
- if ( ! ( len = items . length ) ) {
1106
- return this . right . compile ( o , LEVEL_ACCESS ) ;
1107
- }
1124
+ len = items . length ;
1108
1125
rite = this . right . compile ( o , len === 1 ? LEVEL_ACCESS : LEVEL_LIST ) ;
1109
1126
if ( ( len > 1 || o . level ) && ( ! IDENTIFIER . test ( rite ) || left . assigns ( rite ) ) ) {
1110
1127
cache = "" + ( rref = o . scope . temporary ( 'ref' ) ) + " = " + rite ;
@@ -1133,7 +1150,7 @@ exports.Assign = Assign = (function(_super){
1133
1150
var i , node , len , val , ivar , start , inc , lr , _len , _results = [ ] ;
1134
1151
for ( i = 0 , _len = nodes . length ; i < _len ; ++ i ) {
1135
1152
node = nodes [ i ] ;
1136
- if ( node . items && ! node . items . length ) {
1153
+ if ( node . isEmpty ( ) ) {
1137
1154
continue ;
1138
1155
}
1139
1156
if ( node instanceof Splat ) {
@@ -1465,7 +1482,9 @@ exports.Fun = Fun = (function(_super){
1465
1482
} else if ( arg instanceof Splat ) {
1466
1483
arg = arg . it ;
1467
1484
}
1468
- if ( arg . isComplex ( ) ) {
1485
+ if ( arg . isEmpty ( ) ) {
1486
+ arg = Literal ( scope . temporary ( 'arg' ) ) ;
1487
+ } else if ( arg . isComplex ( ) ) {
1469
1488
val = ref = paramName ( o , p ) ;
1470
1489
if ( dfv ) {
1471
1490
val = Op ( p . op , ref , p . second ) ;
0 commit comments