@@ -1592,24 +1592,34 @@ function deserializeVariableDeclarationKind(pos) {
15921592}
15931593
15941594function deserializeVariableDeclarator ( pos ) {
1595- let start = deserializeU32 ( pos ) ,
1596- end = deserializeU32 ( pos + 4 ) ,
1597- previousParent = parent ,
1598- node = ( parent = {
1595+ let previousParent = parent ,
1596+ variableDeclarator = ( parent = {
15991597 __proto__ : NodeProto ,
16001598 type : 'VariableDeclarator' ,
16011599 id : null ,
16021600 init : null ,
1603- definite : deserializeBool ( pos + 57 ) ,
1604- start,
1605- end,
1606- range : [ start , end ] ,
1607- parent,
1601+ definite : false ,
1602+ start : deserializeU32 ( pos ) ,
1603+ end : deserializeU32 ( pos + 4 ) ,
1604+ range : [ deserializeU32 ( pos ) , deserializeU32 ( pos + 4 ) ] ,
1605+ parent : previousParent ,
16081606 } ) ;
1609- node . id = deserializeBindingPattern ( pos + 8 ) ;
1610- node . init = deserializeOptionExpression ( pos + 40 ) ;
1607+ variableDeclarator . id = deserializeBindingPattern ( pos + 8 ) ;
1608+ {
1609+ parent = variableDeclarator . id ;
1610+ let typeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 24 ) ;
1611+ variableDeclarator . id . typeAnnotation = typeAnnotation ;
1612+ // Extend id span to include type annotation
1613+ if ( typeAnnotation !== null ) {
1614+ variableDeclarator . id . end = typeAnnotation . end ;
1615+ variableDeclarator . id . range [ 1 ] = typeAnnotation . end ;
1616+ }
1617+ parent = variableDeclarator ;
1618+ variableDeclarator . definite = deserializeBool ( pos + 49 ) ;
1619+ }
1620+ variableDeclarator . init = deserializeOptionExpression ( pos + 32 ) ;
16111621 parent = previousParent ;
1612- return node ;
1622+ return variableDeclarator ;
16131623}
16141624
16151625function deserializeEmptyStatement ( pos ) {
@@ -2088,13 +2098,26 @@ function deserializeCatchClause(pos) {
20882098 parent,
20892099 } ) ;
20902100 node . param = deserializeOptionCatchParameter ( pos + 8 ) ;
2091- node . body = deserializeBoxBlockStatement ( pos + 48 ) ;
2101+ node . body = deserializeBoxBlockStatement ( pos + 40 ) ;
20922102 parent = previousParent ;
20932103 return node ;
20942104}
20952105
20962106function deserializeCatchParameter ( pos ) {
2097- return deserializeBindingPattern ( pos + 8 ) ;
2107+ let previousParent = parent ,
2108+ pattern = deserializeBindingPattern ( pos + 8 ) ;
2109+ {
2110+ parent = pattern ;
2111+ let typeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 24 ) ;
2112+ pattern . typeAnnotation = typeAnnotation ;
2113+ // Extend pattern span to include type annotation
2114+ if ( typeAnnotation !== null ) {
2115+ pattern . end = typeAnnotation . end ;
2116+ pattern . range [ 1 ] = typeAnnotation . end ;
2117+ }
2118+ parent = previousParent ;
2119+ }
2120+ return pattern ;
20982121}
20992122
21002123function deserializeDebuggerStatement ( pos ) {
@@ -2111,18 +2134,6 @@ function deserializeDebuggerStatement(pos) {
21112134}
21122135
21132136function deserializeBindingPattern ( pos ) {
2114- let pattern = deserializeBindingPatternKind ( pos ) ;
2115- {
2116- let previousParent = parent ;
2117- parent = pattern ;
2118- pattern . optional = deserializeBool ( pos + 24 ) ;
2119- pattern . typeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 16 ) ;
2120- parent = previousParent ;
2121- }
2122- return pattern ;
2123- }
2124-
2125- function deserializeBindingPatternKind ( pos ) {
21262137 switch ( uint8 [ pos ] ) {
21272138 case 0 :
21282139 return deserializeBoxBindingIdentifier ( pos + 8 ) ;
@@ -2133,7 +2144,7 @@ function deserializeBindingPatternKind(pos) {
21332144 case 3 :
21342145 return deserializeBoxAssignmentPattern ( pos + 8 ) ;
21352146 default :
2136- throw Error ( `Unexpected discriminant ${ uint8 [ pos ] } for BindingPatternKind ` ) ;
2147+ throw Error ( `Unexpected discriminant ${ uint8 [ pos ] } for BindingPattern ` ) ;
21372148 }
21382149}
21392150
@@ -2156,7 +2167,7 @@ function deserializeAssignmentPattern(pos) {
21562167 } ) ;
21572168 node . decorators = [ ] ;
21582169 node . left = deserializeBindingPattern ( pos + 8 ) ;
2159- node . right = deserializeExpression ( pos + 40 ) ;
2170+ node . right = deserializeExpression ( pos + 24 ) ;
21602171 node . optional = false ;
21612172 parent = previousParent ;
21622173 return node ;
@@ -2199,8 +2210,8 @@ function deserializeBindingProperty(pos) {
21992210 key : null ,
22002211 value : null ,
22012212 method : null ,
2202- shorthand : deserializeBool ( pos + 56 ) ,
2203- computed : deserializeBool ( pos + 57 ) ,
2213+ shorthand : deserializeBool ( pos + 40 ) ,
2214+ computed : deserializeBool ( pos + 41 ) ,
22042215 optional : null ,
22052216 start,
22062217 end,
@@ -2329,34 +2340,86 @@ function deserializeFormalParameters(pos) {
23292340 type : 'RestElement' ,
23302341 decorators : [ ] ,
23312342 argument : null ,
2332- optional : deserializeBool ( pos + 32 ) ,
2343+ optional : false ,
23332344 typeAnnotation : null ,
23342345 value : null ,
2335- start : ( start = deserializeU32 ( pos ) ) ,
2336- end : ( end = deserializeU32 ( pos + 4 ) ) ,
2346+ start : ( start = deserializeU32 ( pos + 8 ) ) ,
2347+ end : ( end = deserializeU32 ( pos + 12 ) ) ,
23372348 range : [ start , end ] ,
2338- parent,
2349+ parent : previousParent ,
23392350 } ) ;
2340- rest . argument = deserializeBindingPatternKind ( pos + 8 ) ;
2341- rest . typeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 24 ) ;
2351+ rest . argument = deserializeBindingPattern ( pos + 16 ) ;
2352+ rest . typeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 32 ) ;
2353+ // If there's a type annotation, extend the end to include it
2354+ if ( rest . typeAnnotation !== null ) {
2355+ end = rest . typeAnnotation . end ;
2356+ rest . end = end ;
2357+ rest . range [ 1 ] = end ;
2358+ }
23422359 params . push ( rest ) ;
23432360 parent = previousParent ;
23442361 }
23452362 return params ;
23462363}
23472364
23482365function deserializeFormalParameter ( pos ) {
2349- let param ;
2366+ let param ,
2367+ previousParent = parent ,
2368+ hasInitializer = uint32 [ ( pos + 56 ) >> 2 ] !== 0 && uint32 [ ( pos + 60 ) >> 2 ] !== 0 ;
23502369 {
2351- let accessibility = deserializeOptionTSAccessibility ( pos + 64 ) ,
2352- readonly = deserializeBool ( pos + 65 ) ,
2353- override = deserializeBool ( pos + 66 ) ,
2354- previousParent = parent ;
2370+ let accessibility = deserializeOptionTSAccessibility ( pos + 65 ) ,
2371+ readonly = deserializeBool ( pos + 66 ) ,
2372+ override = deserializeBool ( pos + 67 ) ;
23552373 if ( accessibility === null && ! readonly && ! override ) {
2356- param = parent = deserializeBindingPatternKind ( pos + 32 ) ;
2357- param . decorators = deserializeVecDecorator ( pos + 8 ) ;
2358- param . optional = deserializeBool ( pos + 56 ) ;
2359- param . typeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 48 ) ;
2374+ let optional = deserializeBool ( pos + 64 ) ;
2375+ if ( hasInitializer ) {
2376+ let start , end ;
2377+ param = parent = {
2378+ __proto__ : NodeProto ,
2379+ type : 'AssignmentPattern' ,
2380+ decorators : null ,
2381+ left : null ,
2382+ right : null ,
2383+ optional,
2384+ typeAnnotation : null ,
2385+ start : ( start = deserializeU32 ( pos ) ) ,
2386+ end : ( end = deserializeU32 ( pos + 4 ) ) ,
2387+ range : [ start , end ] ,
2388+ parent : previousParent ,
2389+ } ;
2390+ param . decorators = deserializeVecDecorator ( pos + 8 ) ;
2391+ param . left = deserializeBindingPattern ( pos + 32 ) ;
2392+ param . left . decorators = [ ] ;
2393+ param . left . optional = false ;
2394+ parent = param . left ;
2395+ let leftTypeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 48 ) ;
2396+ param . left . typeAnnotation = leftTypeAnnotation ;
2397+ // Extend left span to include type annotation
2398+ if ( leftTypeAnnotation !== null ) {
2399+ param . left . end = leftTypeAnnotation . end ;
2400+ param . left . range [ 1 ] = leftTypeAnnotation . end ;
2401+ }
2402+ parent = param ;
2403+ param . right = deserializeOptionBoxExpression ( pos + 56 ) ;
2404+ } else {
2405+ param = deserializeBindingPattern ( pos + 32 ) ;
2406+ param . parent = previousParent ;
2407+ parent = param ;
2408+ param . decorators = deserializeVecDecorator ( pos + 8 ) ;
2409+ param . optional = optional ;
2410+ let typeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 48 ) ;
2411+ param . typeAnnotation = typeAnnotation ;
2412+ // Extend param span to include type annotation or optional marker
2413+ if ( typeAnnotation !== null ) {
2414+ param . end = typeAnnotation . end ;
2415+ param . range [ 1 ] = typeAnnotation . end ;
2416+ } else if ( optional ) {
2417+ // Optional marker '?' is included in FormalParameter span
2418+ param . end = deserializeU32 ( pos + 4 ) ;
2419+ param . range [ 1 ] = deserializeU32 ( pos + 4 ) ;
2420+ }
2421+ parent = previousParent ;
2422+ }
23602423 } else {
23612424 let start , end ;
23622425 param = parent = {
@@ -2371,13 +2434,67 @@ function deserializeFormalParameter(pos) {
23712434 start : ( start = deserializeU32 ( pos ) ) ,
23722435 end : ( end = deserializeU32 ( pos + 4 ) ) ,
23732436 range : [ start , end ] ,
2374- parent,
2437+ parent : previousParent ,
23752438 } ;
23762439 param . decorators = deserializeVecDecorator ( pos + 8 ) ;
2377- param . parameter = deserializeBindingPattern ( pos + 32 ) ;
2440+ if ( hasInitializer ) {
2441+ // Wrap in AssignmentPattern for TSParameterProperty with initializer
2442+ let pattern = deserializeBindingPattern ( pos + 32 ) ,
2443+ initializer = deserializeOptionBoxExpression ( pos + 56 ) ,
2444+ assignStart ,
2445+ assignEnd ,
2446+ assignParam = ( parent = {
2447+ __proto__ : NodeProto ,
2448+ type : 'AssignmentPattern' ,
2449+ decorators : [ ] ,
2450+ left : null ,
2451+ right : null ,
2452+ optional : false ,
2453+ typeAnnotation : null ,
2454+ start : ( assignStart = pattern . start ) ,
2455+ end : ( assignEnd = initializer . end ) ,
2456+ range : [ assignStart , assignEnd ] ,
2457+ parent : param ,
2458+ } ) ;
2459+ assignParam . left = pattern ;
2460+ pattern . parent = assignParam ;
2461+ pattern . decorators = [ ] ;
2462+ pattern . optional = false ;
2463+ parent = pattern ;
2464+ let patternTypeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 48 ) ;
2465+ pattern . typeAnnotation = patternTypeAnnotation ;
2466+ // Extend pattern span to include type annotation
2467+ if ( patternTypeAnnotation !== null ) {
2468+ pattern . end = patternTypeAnnotation . end ;
2469+ pattern . range [ 1 ] = patternTypeAnnotation . end ;
2470+ }
2471+ parent = assignParam ;
2472+ assignParam . right = initializer ;
2473+ initializer !== null && ( initializer . parent = assignParam ) ;
2474+ param . parameter = assignParam ;
2475+ } else {
2476+ param . parameter = deserializeBindingPattern ( pos + 32 ) ;
2477+ param . parameter . decorators = [ ] ;
2478+ let paramOptional = deserializeBool ( pos + 64 ) ;
2479+ param . parameter . optional = paramOptional ;
2480+ parent = param . parameter ;
2481+ let paramTypeAnnotation = deserializeOptionBoxTSTypeAnnotation ( pos + 48 ) ;
2482+ param . parameter . typeAnnotation = paramTypeAnnotation ;
2483+ // Extend parameter span to include type annotation or optional marker
2484+ if ( paramTypeAnnotation !== null ) {
2485+ param . parameter . end = paramTypeAnnotation . end ;
2486+ param . parameter . range [ 1 ] = paramTypeAnnotation . end ;
2487+ } else if ( paramOptional ) {
2488+ // Optional marker '?' is included in FormalParameter span
2489+ let paramEnd = deserializeU32 ( pos + 4 ) ;
2490+ param . parameter . end = paramEnd ;
2491+ param . parameter . range [ 1 ] = paramEnd ;
2492+ }
2493+ parent = param ;
2494+ }
23782495 }
2379- parent = previousParent ;
23802496 }
2497+ parent = previousParent ;
23812498 return param ;
23822499}
23832500
@@ -6308,14 +6425,23 @@ function deserializeVecVariableDeclarator(pos) {
63086425 let arr = [ ] ,
63096426 pos32 = pos >> 2 ;
63106427 pos = uint32 [ pos32 ] ;
6311- let endPos = pos + uint32 [ pos32 + 2 ] * 64 ;
6428+ let endPos = pos + uint32 [ pos32 + 2 ] * 56 ;
63126429 for ( ; pos !== endPos ; ) {
63136430 arr . push ( deserializeVariableDeclarator ( pos ) ) ;
6314- pos += 64 ;
6431+ pos += 56 ;
63156432 }
63166433 return arr ;
63176434}
63186435
6436+ function deserializeBoxTSTypeAnnotation ( pos ) {
6437+ return deserializeTSTypeAnnotation ( uint32 [ pos >> 2 ] ) ;
6438+ }
6439+
6440+ function deserializeOptionBoxTSTypeAnnotation ( pos ) {
6441+ if ( uint32 [ pos >> 2 ] === 0 && uint32 [ ( pos + 4 ) >> 2 ] === 0 ) return null ;
6442+ return deserializeBoxTSTypeAnnotation ( pos ) ;
6443+ }
6444+
63196445function deserializeOptionStatement ( pos ) {
63206446 if ( uint8 [ pos ] === 70 ) return null ;
63216447 return deserializeStatement ( pos ) ;
@@ -6358,19 +6484,10 @@ function deserializeOptionBoxBlockStatement(pos) {
63586484}
63596485
63606486function deserializeOptionCatchParameter ( pos ) {
6361- if ( uint8 [ pos + 32 ] === 2 ) return null ;
6487+ if ( uint8 [ pos + 8 ] === 4 ) return null ;
63626488 return deserializeCatchParameter ( pos ) ;
63636489}
63646490
6365- function deserializeBoxTSTypeAnnotation ( pos ) {
6366- return deserializeTSTypeAnnotation ( uint32 [ pos >> 2 ] ) ;
6367- }
6368-
6369- function deserializeOptionBoxTSTypeAnnotation ( pos ) {
6370- if ( uint32 [ pos >> 2 ] === 0 && uint32 [ ( pos + 4 ) >> 2 ] === 0 ) return null ;
6371- return deserializeBoxTSTypeAnnotation ( pos ) ;
6372- }
6373-
63746491function deserializeBoxBindingIdentifier ( pos ) {
63756492 return deserializeBindingIdentifier ( uint32 [ pos >> 2 ] ) ;
63766493}
@@ -6391,10 +6508,10 @@ function deserializeVecBindingProperty(pos) {
63916508 let arr = [ ] ,
63926509 pos32 = pos >> 2 ;
63936510 pos = uint32 [ pos32 ] ;
6394- let endPos = pos + uint32 [ pos32 + 2 ] * 64 ;
6511+ let endPos = pos + uint32 [ pos32 + 2 ] * 48 ;
63956512 for ( ; pos !== endPos ; ) {
63966513 arr . push ( deserializeBindingProperty ( pos ) ) ;
6397- pos += 64 ;
6514+ pos += 48 ;
63986515 }
63996516 return arr ;
64006517}
@@ -6409,18 +6526,18 @@ function deserializeOptionBoxBindingRestElement(pos) {
64096526}
64106527
64116528function deserializeOptionBindingPattern ( pos ) {
6412- if ( uint8 [ pos + 24 ] === 2 ) return null ;
6529+ if ( uint8 [ pos ] === 4 ) return null ;
64136530 return deserializeBindingPattern ( pos ) ;
64146531}
64156532
64166533function deserializeVecOptionBindingPattern ( pos ) {
64176534 let arr = [ ] ,
64186535 pos32 = pos >> 2 ;
64196536 pos = uint32 [ pos32 ] ;
6420- let endPos = pos + uint32 [ pos32 + 2 ] * 32 ;
6537+ let endPos = pos + uint32 [ pos32 + 2 ] * 16 ;
64216538 for ( ; pos !== endPos ; ) {
64226539 arr . push ( deserializeOptionBindingPattern ( pos ) ) ;
6423- pos += 32 ;
6540+ pos += 16 ;
64246541 }
64256542 return arr ;
64266543}
@@ -6485,6 +6602,15 @@ function deserializeVecDecorator(pos) {
64856602 return arr ;
64866603}
64876604
6605+ function deserializeBoxExpression ( pos ) {
6606+ return deserializeExpression ( uint32 [ pos >> 2 ] ) ;
6607+ }
6608+
6609+ function deserializeOptionBoxExpression ( pos ) {
6610+ if ( uint32 [ pos >> 2 ] === 0 && uint32 [ ( pos + 4 ) >> 2 ] === 0 ) return null ;
6611+ return deserializeBoxExpression ( pos ) ;
6612+ }
6613+
64886614function deserializeOptionTSAccessibility ( pos ) {
64896615 if ( uint8 [ pos ] === 3 ) return null ;
64906616 return deserializeTSAccessibility ( pos ) ;
0 commit comments