| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
package ast |
| 7 |
|
| 8 |
import ( |
| 9 |
"github.com/robertkrimen/otto/file" |
| 10 |
"github.com/robertkrimen/otto/token" |
| 11 |
) |
| 12 |
|
| 13 |
|
| 14 |
type Node interface { |
| 15 |
Idx0() file.Idx |
| 16 |
Idx1() file.Idx |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
type Expression interface { |
| 21 |
Node |
| 22 |
expression() |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
type ArrayLiteral struct { |
| 27 |
Value []Expression |
| 28 |
LeftBracket file.Idx |
| 29 |
RightBracket file.Idx |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
func (al *ArrayLiteral) Idx0() file.Idx { |
| 34 |
return al.LeftBracket |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
func (al *ArrayLiteral) Idx1() file.Idx { |
| 39 |
return al.RightBracket + 1 |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
func (*ArrayLiteral) expression() {} |
| 44 |
|
| 45 |
|
| 46 |
type AssignExpression struct { |
| 47 |
Left Expression |
| 48 |
Right Expression |
| 49 |
Operator token.Token |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
func (ae *AssignExpression) Idx0() file.Idx { |
| 54 |
return ae.Left.Idx0() |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
func (ae *AssignExpression) Idx1() file.Idx { |
| 59 |
return ae.Right.Idx1() |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
func (*AssignExpression) expression() {} |
| 64 |
|
| 65 |
|
| 66 |
type BadExpression struct { |
| 67 |
From file.Idx |
| 68 |
To file.Idx |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
func (be *BadExpression) Idx0() file.Idx { |
| 73 |
return be.From |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
func (be *BadExpression) Idx1() file.Idx { |
| 78 |
return be.To |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
func (*BadExpression) expression() {} |
| 83 |
|
| 84 |
|
| 85 |
type BinaryExpression struct { |
| 86 |
Left Expression |
| 87 |
Right Expression |
| 88 |
Operator token.Token |
| 89 |
Comparison bool |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
func (be *BinaryExpression) Idx0() file.Idx { |
| 94 |
return be.Left.Idx0() |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
func (be *BinaryExpression) Idx1() file.Idx { |
| 99 |
return be.Right.Idx1() |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
func (*BinaryExpression) expression() {} |
| 104 |
|
| 105 |
|
| 106 |
type BooleanLiteral struct { |
| 107 |
Literal string |
| 108 |
Idx file.Idx |
| 109 |
Value bool |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
func (bl *BooleanLiteral) Idx0() file.Idx { |
| 114 |
return bl.Idx |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
func (bl *BooleanLiteral) Idx1() file.Idx { |
| 119 |
return file.Idx(int(bl.Idx) + len(bl.Literal)) |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
func (*BooleanLiteral) expression() {} |
| 124 |
|
| 125 |
|
| 126 |
type BracketExpression struct { |
| 127 |
Left Expression |
| 128 |
Member Expression |
| 129 |
LeftBracket file.Idx |
| 130 |
RightBracket file.Idx |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
func (be *BracketExpression) Idx0() file.Idx { |
| 135 |
return be.Left.Idx0() |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
func (be *BracketExpression) Idx1() file.Idx { |
| 140 |
return be.RightBracket + 1 |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
func (*BracketExpression) expression() {} |
| 145 |
|
| 146 |
|
| 147 |
type CallExpression struct { |
| 148 |
Callee Expression |
| 149 |
ArgumentList []Expression |
| 150 |
LeftParenthesis file.Idx |
| 151 |
RightParenthesis file.Idx |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
func (ce *CallExpression) Idx0() file.Idx { |
| 156 |
return ce.Callee.Idx0() |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
func (ce *CallExpression) Idx1() file.Idx { |
| 161 |
return ce.RightParenthesis + 1 |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
func (*CallExpression) expression() {} |
| 166 |
|
| 167 |
|
| 168 |
type ConditionalExpression struct { |
| 169 |
Test Expression |
| 170 |
Consequent Expression |
| 171 |
Alternate Expression |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
func (ce *ConditionalExpression) Idx0() file.Idx { |
| 176 |
return ce.Test.Idx0() |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
func (ce *ConditionalExpression) Idx1() file.Idx { |
| 181 |
return ce.Alternate.Idx1() |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
func (*ConditionalExpression) expression() {} |
| 186 |
|
| 187 |
|
| 188 |
type DotExpression struct { |
| 189 |
Left Expression |
| 190 |
Identifier *Identifier |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
func (de *DotExpression) Idx0() file.Idx { |
| 195 |
return de.Left.Idx0() |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
func (de *DotExpression) Idx1() file.Idx { |
| 200 |
return de.Identifier.Idx1() |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
func (*DotExpression) expression() {} |
| 205 |
|
| 206 |
|
| 207 |
type EmptyExpression struct { |
| 208 |
Begin file.Idx |
| 209 |
End file.Idx |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
func (ee *EmptyExpression) Idx0() file.Idx { |
| 214 |
return ee.Begin |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
func (ee *EmptyExpression) Idx1() file.Idx { |
| 219 |
return ee.End |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
func (*EmptyExpression) expression() {} |
| 224 |
|
| 225 |
|
| 226 |
type FunctionLiteral struct { |
| 227 |
Body Statement |
| 228 |
Name *Identifier |
| 229 |
ParameterList *ParameterList |
| 230 |
Source string |
| 231 |
DeclarationList []Declaration |
| 232 |
Function file.Idx |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
func (fl *FunctionLiteral) Idx0() file.Idx { |
| 237 |
return fl.Function |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
func (fl *FunctionLiteral) Idx1() file.Idx { |
| 242 |
return fl.Body.Idx1() |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
func (*FunctionLiteral) expression() {} |
| 247 |
|
| 248 |
|
| 249 |
type Identifier struct { |
| 250 |
Name string |
| 251 |
Idx file.Idx |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
func (i *Identifier) Idx0() file.Idx { |
| 256 |
return i.Idx |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
func (i *Identifier) Idx1() file.Idx { |
| 261 |
return file.Idx(int(i.Idx) + len(i.Name)) |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
func (*Identifier) expression() {} |
| 266 |
|
| 267 |
|
| 268 |
type NewExpression struct { |
| 269 |
Callee Expression |
| 270 |
ArgumentList []Expression |
| 271 |
New file.Idx |
| 272 |
LeftParenthesis file.Idx |
| 273 |
RightParenthesis file.Idx |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
func (ne *NewExpression) Idx0() file.Idx { |
| 278 |
return ne.New |
| 279 |
} |
| 280 |
|
| 281 |
|
| 282 |
func (ne *NewExpression) Idx1() file.Idx { |
| 283 |
if ne.RightParenthesis > 0 { |
| 284 |
return ne.RightParenthesis + 1 |
| 285 |
} |
| 286 |
return ne.Callee.Idx1() |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
func (*NewExpression) expression() {} |
| 291 |
|
| 292 |
|
| 293 |
type NullLiteral struct { |
| 294 |
Literal string |
| 295 |
Idx file.Idx |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
func (nl *NullLiteral) Idx0() file.Idx { |
| 300 |
return nl.Idx |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
func (nl *NullLiteral) Idx1() file.Idx { |
| 305 |
return file.Idx(int(nl.Idx) + 4) |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
func (*NullLiteral) expression() {} |
| 310 |
|
| 311 |
|
| 312 |
type NumberLiteral struct { |
| 313 |
Value interface{} |
| 314 |
Literal string |
| 315 |
Idx file.Idx |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
func (nl *NumberLiteral) Idx0() file.Idx { |
| 320 |
return nl.Idx |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
func (nl *NumberLiteral) Idx1() file.Idx { |
| 325 |
return file.Idx(int(nl.Idx) + len(nl.Literal)) |
| 326 |
} |
| 327 |
|
| 328 |
|
| 329 |
func (*NumberLiteral) expression() {} |
| 330 |
|
| 331 |
|
| 332 |
type ObjectLiteral struct { |
| 333 |
Value []Property |
| 334 |
LeftBrace file.Idx |
| 335 |
RightBrace file.Idx |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
func (ol *ObjectLiteral) Idx0() file.Idx { |
| 340 |
return ol.LeftBrace |
| 341 |
} |
| 342 |
|
| 343 |
|
| 344 |
func (ol *ObjectLiteral) Idx1() file.Idx { |
| 345 |
return ol.RightBrace + 1 |
| 346 |
} |
| 347 |
|
| 348 |
|
| 349 |
func (*ObjectLiteral) expression() {} |
| 350 |
|
| 351 |
|
| 352 |
type ParameterList struct { |
| 353 |
List []*Identifier |
| 354 |
Opening file.Idx |
| 355 |
Closing file.Idx |
| 356 |
} |
| 357 |
|
| 358 |
|
| 359 |
type Property struct { |
| 360 |
Value Expression |
| 361 |
Key string |
| 362 |
Kind string |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
type RegExpLiteral struct { |
| 367 |
Literal string |
| 368 |
Pattern string |
| 369 |
Flags string |
| 370 |
Value string |
| 371 |
Idx file.Idx |
| 372 |
} |
| 373 |
|
| 374 |
|
| 375 |
func (rl *RegExpLiteral) Idx0() file.Idx { |
| 376 |
return rl.Idx |
| 377 |
} |
| 378 |
|
| 379 |
|
| 380 |
func (rl *RegExpLiteral) Idx1() file.Idx { |
| 381 |
return file.Idx(int(rl.Idx) + len(rl.Literal)) |
| 382 |
} |
| 383 |
|
| 384 |
|
| 385 |
func (*RegExpLiteral) expression() {} |
| 386 |
|
| 387 |
|
| 388 |
type SequenceExpression struct { |
| 389 |
Sequence []Expression |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
func (se *SequenceExpression) Idx0() file.Idx { |
| 394 |
return se.Sequence[0].Idx0() |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
func (se *SequenceExpression) Idx1() file.Idx { |
| 399 |
return se.Sequence[len(se.Sequence)-1].Idx1() |
| 400 |
} |
| 401 |
|
| 402 |
|
| 403 |
func (*SequenceExpression) expression() {} |
| 404 |
|
| 405 |
|
| 406 |
type StringLiteral struct { |
| 407 |
Literal string |
| 408 |
Value string |
| 409 |
Idx file.Idx |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
func (sl *StringLiteral) Idx0() file.Idx { |
| 414 |
return sl.Idx |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
func (sl *StringLiteral) Idx1() file.Idx { |
| 419 |
return file.Idx(int(sl.Idx) + len(sl.Literal)) |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
func (*StringLiteral) expression() {} |
| 424 |
|
| 425 |
|
| 426 |
type ThisExpression struct { |
| 427 |
Idx file.Idx |
| 428 |
} |
| 429 |
|
| 430 |
|
| 431 |
func (te *ThisExpression) Idx0() file.Idx { |
| 432 |
return te.Idx |
| 433 |
} |
| 434 |
|
| 435 |
|
| 436 |
func (te *ThisExpression) Idx1() file.Idx { |
| 437 |
return te.Idx + 4 |
| 438 |
} |
| 439 |
|
| 440 |
|
| 441 |
func (*ThisExpression) expression() {} |
| 442 |
|
| 443 |
|
| 444 |
type UnaryExpression struct { |
| 445 |
Operand Expression |
| 446 |
Operator token.Token |
| 447 |
Idx file.Idx |
| 448 |
Postfix bool |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
func (ue *UnaryExpression) Idx0() file.Idx { |
| 453 |
if ue.Postfix { |
| 454 |
return ue.Operand.Idx0() |
| 455 |
} |
| 456 |
return ue.Idx |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
func (ue *UnaryExpression) Idx1() file.Idx { |
| 461 |
if ue.Postfix { |
| 462 |
return ue.Operand.Idx1() + 2 |
| 463 |
} |
| 464 |
return ue.Operand.Idx1() |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
func (*UnaryExpression) expression() {} |
| 469 |
|
| 470 |
|
| 471 |
type VariableExpression struct { |
| 472 |
Initializer Expression |
| 473 |
Name string |
| 474 |
Idx file.Idx |
| 475 |
} |
| 476 |
|
| 477 |
|
| 478 |
func (ve *VariableExpression) Idx0() file.Idx { |
| 479 |
return ve.Idx |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
func (ve *VariableExpression) Idx1() file.Idx { |
| 484 |
if ve.Initializer == nil { |
| 485 |
return file.Idx(int(ve.Idx) + len(ve.Name)) |
| 486 |
} |
| 487 |
return ve.Initializer.Idx1() |
| 488 |
} |
| 489 |
|
| 490 |
|
| 491 |
func (*VariableExpression) expression() {} |
| 492 |
|
| 493 |
|
| 494 |
type Statement interface { |
| 495 |
Node |
| 496 |
statement() |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
type BadStatement struct { |
| 501 |
From file.Idx |
| 502 |
To file.Idx |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
func (bs *BadStatement) Idx0() file.Idx { |
| 507 |
return bs.From |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
func (bs *BadStatement) Idx1() file.Idx { |
| 512 |
return bs.To |
| 513 |
} |
| 514 |
|
| 515 |
|
| 516 |
func (*BadStatement) statement() {} |
| 517 |
|
| 518 |
|
| 519 |
type BlockStatement struct { |
| 520 |
List []Statement |
| 521 |
LeftBrace file.Idx |
| 522 |
RightBrace file.Idx |
| 523 |
} |
| 524 |
|
| 525 |
|
| 526 |
func (bs *BlockStatement) Idx0() file.Idx { |
| 527 |
return bs.LeftBrace |
| 528 |
} |
| 529 |
|
| 530 |
|
| 531 |
func (bs *BlockStatement) Idx1() file.Idx { |
| 532 |
return bs.RightBrace + 1 |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
func (*BlockStatement) statement() {} |
| 537 |
|
| 538 |
|
| 539 |
type BranchStatement struct { |
| 540 |
Label *Identifier |
| 541 |
Idx file.Idx |
| 542 |
Token token.Token |
| 543 |
} |
| 544 |
|
| 545 |
|
| 546 |
func (bs *BranchStatement) Idx0() file.Idx { |
| 547 |
return bs.Idx |
| 548 |
} |
| 549 |
|
| 550 |
|
| 551 |
func (bs *BranchStatement) Idx1() file.Idx { |
| 552 |
if bs.Label == nil { |
| 553 |
return file.Idx(int(bs.Idx) + len(bs.Token.String())) |
| 554 |
} |
| 555 |
return bs.Label.Idx1() |
| 556 |
} |
| 557 |
|
| 558 |
|
| 559 |
func (*BranchStatement) statement() {} |
| 560 |
|
| 561 |
|
| 562 |
type CaseStatement struct { |
| 563 |
Test Expression |
| 564 |
Consequent []Statement |
| 565 |
Case file.Idx |
| 566 |
} |
| 567 |
|
| 568 |
|
| 569 |
func (cs *CaseStatement) Idx0() file.Idx { |
| 570 |
return cs.Case |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
func (cs *CaseStatement) Idx1() file.Idx { |
| 575 |
return cs.Consequent[len(cs.Consequent)-1].Idx1() |
| 576 |
} |
| 577 |
|
| 578 |
|
| 579 |
func (*CaseStatement) statement() {} |
| 580 |
|
| 581 |
|
| 582 |
type CatchStatement struct { |
| 583 |
Body Statement |
| 584 |
Parameter *Identifier |
| 585 |
Catch file.Idx |
| 586 |
} |
| 587 |
|
| 588 |
|
| 589 |
func (cs *CatchStatement) Idx0() file.Idx { |
| 590 |
return cs.Catch |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
func (cs *CatchStatement) Idx1() file.Idx { |
| 595 |
return cs.Body.Idx1() |
| 596 |
} |
| 597 |
|
| 598 |
|
| 599 |
func (*CatchStatement) statement() {} |
| 600 |
|
| 601 |
|
| 602 |
type DebuggerStatement struct { |
| 603 |
Debugger file.Idx |
| 604 |
} |
| 605 |
|
| 606 |
|
| 607 |
func (ds *DebuggerStatement) Idx0() file.Idx { |
| 608 |
return ds.Debugger |
| 609 |
} |
| 610 |
|
| 611 |
|
| 612 |
func (ds *DebuggerStatement) Idx1() file.Idx { |
| 613 |
return ds.Debugger + 8 |
| 614 |
} |
| 615 |
|
| 616 |
|
| 617 |
func (*DebuggerStatement) statement() {} |
| 618 |
|
| 619 |
|
| 620 |
type DoWhileStatement struct { |
| 621 |
Test Expression |
| 622 |
Body Statement |
| 623 |
Do file.Idx |
| 624 |
RightParenthesis file.Idx |
| 625 |
} |
| 626 |
|
| 627 |
|
| 628 |
func (dws *DoWhileStatement) Idx0() file.Idx { |
| 629 |
return dws.Do |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
func (dws *DoWhileStatement) Idx1() file.Idx { |
| 634 |
return dws.RightParenthesis + 1 |
| 635 |
} |
| 636 |
|
| 637 |
|
| 638 |
func (*DoWhileStatement) statement() {} |
| 639 |
|
| 640 |
|
| 641 |
type EmptyStatement struct { |
| 642 |
Semicolon file.Idx |
| 643 |
} |
| 644 |
|
| 645 |
|
| 646 |
func (es *EmptyStatement) Idx0() file.Idx { |
| 647 |
return es.Semicolon |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
func (es *EmptyStatement) Idx1() file.Idx { |
| 652 |
return es.Semicolon + 1 |
| 653 |
} |
| 654 |
|
| 655 |
|
| 656 |
func (*EmptyStatement) statement() {} |
| 657 |
|
| 658 |
|
| 659 |
type ExpressionStatement struct { |
| 660 |
Expression Expression |
| 661 |
} |
| 662 |
|
| 663 |
|
| 664 |
func (es *ExpressionStatement) Idx0() file.Idx { |
| 665 |
return es.Expression.Idx0() |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
func (es *ExpressionStatement) Idx1() file.Idx { |
| 670 |
return es.Expression.Idx1() |
| 671 |
} |
| 672 |
|
| 673 |
|
| 674 |
func (*ExpressionStatement) statement() {} |
| 675 |
|
| 676 |
|
| 677 |
type ForInStatement struct { |
| 678 |
Into Expression |
| 679 |
Source Expression |
| 680 |
Body Statement |
| 681 |
For file.Idx |
| 682 |
} |
| 683 |
|
| 684 |
|
| 685 |
func (fis *ForInStatement) Idx0() file.Idx { |
| 686 |
return fis.For |
| 687 |
} |
| 688 |
|
| 689 |
|
| 690 |
func (fis *ForInStatement) Idx1() file.Idx { |
| 691 |
return fis.Body.Idx1() |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
func (*ForInStatement) statement() {} |
| 696 |
|
| 697 |
|
| 698 |
type ForStatement struct { |
| 699 |
Initializer Expression |
| 700 |
Update Expression |
| 701 |
Test Expression |
| 702 |
Body Statement |
| 703 |
For file.Idx |
| 704 |
} |
| 705 |
|
| 706 |
|
| 707 |
func (fs *ForStatement) Idx0() file.Idx { |
| 708 |
return fs.For |
| 709 |
} |
| 710 |
|
| 711 |
|
| 712 |
func (fs *ForStatement) Idx1() file.Idx { |
| 713 |
return fs.Body.Idx1() |
| 714 |
} |
| 715 |
|
| 716 |
|
| 717 |
func (*ForStatement) statement() {} |
| 718 |
|
| 719 |
|
| 720 |
type FunctionStatement struct { |
| 721 |
Function *FunctionLiteral |
| 722 |
} |
| 723 |
|
| 724 |
|
| 725 |
func (fs *FunctionStatement) Idx0() file.Idx { |
| 726 |
return fs.Function.Idx0() |
| 727 |
} |
| 728 |
|
| 729 |
|
| 730 |
func (fs *FunctionStatement) Idx1() file.Idx { |
| 731 |
return fs.Function.Idx1() |
| 732 |
} |
| 733 |
|
| 734 |
|
| 735 |
func (*FunctionStatement) statement() {} |
| 736 |
|
| 737 |
|
| 738 |
type IfStatement struct { |
| 739 |
Test Expression |
| 740 |
Consequent Statement |
| 741 |
Alternate Statement |
| 742 |
If file.Idx |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
func (is *IfStatement) Idx0() file.Idx { |
| 747 |
return is.If |
| 748 |
} |
| 749 |
|
| 750 |
|
| 751 |
func (is *IfStatement) Idx1() file.Idx { |
| 752 |
if is.Alternate != nil { |
| 753 |
return is.Alternate.Idx1() |
| 754 |
} |
| 755 |
return is.Consequent.Idx1() |
| 756 |
} |
| 757 |
|
| 758 |
|
| 759 |
func (*IfStatement) statement() {} |
| 760 |
|
| 761 |
|
| 762 |
type LabelledStatement struct { |
| 763 |
Statement Statement |
| 764 |
Label *Identifier |
| 765 |
Colon file.Idx |
| 766 |
} |
| 767 |
|
| 768 |
|
| 769 |
func (ls *LabelledStatement) Idx0() file.Idx { |
| 770 |
return ls.Label.Idx0() |
| 771 |
} |
| 772 |
|
| 773 |
|
| 774 |
func (ls *LabelledStatement) Idx1() file.Idx { |
| 775 |
return ls.Statement.Idx1() |
| 776 |
} |
| 777 |
|
| 778 |
|
| 779 |
func (*LabelledStatement) statement() {} |
| 780 |
|
| 781 |
|
| 782 |
type ReturnStatement struct { |
| 783 |
Argument Expression |
| 784 |
Return file.Idx |
| 785 |
} |
| 786 |
|
| 787 |
|
| 788 |
func (rs *ReturnStatement) Idx0() file.Idx { |
| 789 |
return rs.Return |
| 790 |
} |
| 791 |
|
| 792 |
|
| 793 |
func (rs *ReturnStatement) Idx1() file.Idx { |
| 794 |
if rs.Argument != nil { |
| 795 |
return rs.Argument.Idx1() |
| 796 |
} |
| 797 |
return rs.Return + 6 |
| 798 |
} |
| 799 |
|
| 800 |
|
| 801 |
func (*ReturnStatement) statement() {} |
| 802 |
|
| 803 |
|
| 804 |
type SwitchStatement struct { |
| 805 |
Discriminant Expression |
| 806 |
Body []*CaseStatement |
| 807 |
Switch file.Idx |
| 808 |
Default int |
| 809 |
RightBrace file.Idx |
| 810 |
} |
| 811 |
|
| 812 |
|
| 813 |
func (ss *SwitchStatement) Idx0() file.Idx { |
| 814 |
return ss.Switch |
| 815 |
} |
| 816 |
|
| 817 |
|
| 818 |
func (ss *SwitchStatement) Idx1() file.Idx { |
| 819 |
return ss.RightBrace + 1 |
| 820 |
} |
| 821 |
|
| 822 |
|
| 823 |
func (*SwitchStatement) statement() {} |
| 824 |
|
| 825 |
|
| 826 |
type ThrowStatement struct { |
| 827 |
Argument Expression |
| 828 |
Throw file.Idx |
| 829 |
} |
| 830 |
|
| 831 |
|
| 832 |
func (ts *ThrowStatement) Idx0() file.Idx { |
| 833 |
return ts.Throw |
| 834 |
} |
| 835 |
|
| 836 |
|
| 837 |
func (ts *ThrowStatement) Idx1() file.Idx { |
| 838 |
return ts.Argument.Idx1() |
| 839 |
} |
| 840 |
|
| 841 |
|
| 842 |
func (*ThrowStatement) statement() {} |
| 843 |
|
| 844 |
|
| 845 |
type TryStatement struct { |
| 846 |
Body Statement |
| 847 |
Finally Statement |
| 848 |
Catch *CatchStatement |
| 849 |
Try file.Idx |
| 850 |
} |
| 851 |
|
| 852 |
|
| 853 |
func (ts *TryStatement) Idx0() file.Idx { |
| 854 |
return ts.Try |
| 855 |
} |
| 856 |
|
| 857 |
|
| 858 |
func (ts *TryStatement) Idx1() file.Idx { |
| 859 |
if ts.Finally != nil { |
| 860 |
return ts.Finally.Idx1() |
| 861 |
} |
| 862 |
return ts.Catch.Idx1() |
| 863 |
} |
| 864 |
|
| 865 |
|
| 866 |
func (*TryStatement) statement() {} |
| 867 |
|
| 868 |
|
| 869 |
type VariableStatement struct { |
| 870 |
List []Expression |
| 871 |
Var file.Idx |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
func (vs *VariableStatement) Idx0() file.Idx { |
| 876 |
return vs.Var |
| 877 |
} |
| 878 |
|
| 879 |
|
| 880 |
func (vs *VariableStatement) Idx1() file.Idx { |
| 881 |
return vs.List[len(vs.List)-1].Idx1() |
| 882 |
} |
| 883 |
|
| 884 |
|
| 885 |
func (*VariableStatement) statement() {} |
| 886 |
|
| 887 |
|
| 888 |
type WhileStatement struct { |
| 889 |
Test Expression |
| 890 |
Body Statement |
| 891 |
While file.Idx |
| 892 |
} |
| 893 |
|
| 894 |
|
| 895 |
func (ws *WhileStatement) Idx0() file.Idx { |
| 896 |
return ws.While |
| 897 |
} |
| 898 |
|
| 899 |
|
| 900 |
func (ws *WhileStatement) Idx1() file.Idx { |
| 901 |
return ws.Body.Idx1() |
| 902 |
} |
| 903 |
|
| 904 |
|
| 905 |
func (*WhileStatement) statement() {} |
| 906 |
|
| 907 |
|
| 908 |
type WithStatement struct { |
| 909 |
Object Expression |
| 910 |
Body Statement |
| 911 |
With file.Idx |
| 912 |
} |
| 913 |
|
| 914 |
|
| 915 |
func (ws *WithStatement) Idx0() file.Idx { |
| 916 |
return ws.With |
| 917 |
} |
| 918 |
|
| 919 |
|
| 920 |
func (ws *WithStatement) Idx1() file.Idx { |
| 921 |
return ws.Body.Idx1() |
| 922 |
} |
| 923 |
|
| 924 |
|
| 925 |
func (*WithStatement) statement() {} |
| 926 |
|
| 927 |
|
| 928 |
type Declaration interface { |
| 929 |
declaration() |
| 930 |
} |
| 931 |
|
| 932 |
|
| 933 |
type FunctionDeclaration struct { |
| 934 |
Function *FunctionLiteral |
| 935 |
} |
| 936 |
|
| 937 |
func (*FunctionDeclaration) declaration() {} |
| 938 |
|
| 939 |
|
| 940 |
type VariableDeclaration struct { |
| 941 |
List []*VariableExpression |
| 942 |
Var file.Idx |
| 943 |
} |
| 944 |
|
| 945 |
|
| 946 |
func (*VariableDeclaration) declaration() {} |
| 947 |
|
| 948 |
|
| 949 |
type Program struct { |
| 950 |
File *file.File |
| 951 |
Comments CommentMap |
| 952 |
Body []Statement |
| 953 |
DeclarationList []Declaration |
| 954 |
} |
| 955 |
|
| 956 |
|
| 957 |
func (p *Program) Idx0() file.Idx { |
| 958 |
return p.Body[0].Idx0() |
| 959 |
} |
| 960 |
|
| 961 |
|
| 962 |
func (p *Program) Idx1() file.Idx { |
| 963 |
return p.Body[len(p.Body)-1].Idx1() |
| 964 |
} |