| ... | ... | @@ -22,6 +22,7 @@ pub const Node = struct { |
| 22 | 22 | StringLiteral, |
| 23 | 23 | UndefinedLiteral, |
| 24 | 24 | BuiltinCall, |
| 25 | Call, |
| 25 | 26 | LineComment, |
| 26 | 27 | TestDecl, |
| 27 | 28 | }; |
| ... | ... | @@ -41,6 +42,7 @@ pub const Node = struct { |
| 41 | 42 | Id.StringLiteral => @fieldParentPtr(NodeStringLiteral, "base", base).iterate(index), |
| 42 | 43 | Id.UndefinedLiteral => @fieldParentPtr(NodeUndefinedLiteral, "base", base).iterate(index), |
| 43 | 44 | Id.BuiltinCall => @fieldParentPtr(NodeBuiltinCall, "base", base).iterate(index), |
| 45 | Id.Call => @fieldParentPtr(NodeCall, "base", base).iterate(index), |
| 44 | 46 | Id.LineComment => @fieldParentPtr(NodeLineComment, "base", base).iterate(index), |
| 45 | 47 | Id.TestDecl => @fieldParentPtr(NodeTestDecl, "base", base).iterate(index), |
| 46 | 48 | }; |
| ... | ... | @@ -61,6 +63,7 @@ pub const Node = struct { |
| 61 | 63 | Id.StringLiteral => @fieldParentPtr(NodeStringLiteral, "base", base).firstToken(), |
| 62 | 64 | Id.UndefinedLiteral => @fieldParentPtr(NodeUndefinedLiteral, "base", base).firstToken(), |
| 63 | 65 | Id.BuiltinCall => @fieldParentPtr(NodeBuiltinCall, "base", base).firstToken(), |
| 66 | Id.Call => @fieldParentPtr(NodeCall, "base", base).firstToken(), |
| 64 | 67 | Id.LineComment => @fieldParentPtr(NodeLineComment, "base", base).firstToken(), |
| 65 | 68 | Id.TestDecl => @fieldParentPtr(NodeTestDecl, "base", base).firstToken(), |
| 66 | 69 | }; |
| ... | ... | @@ -81,6 +84,7 @@ pub const Node = struct { |
| 81 | 84 | Id.StringLiteral => @fieldParentPtr(NodeStringLiteral, "base", base).lastToken(), |
| 82 | 85 | Id.UndefinedLiteral => @fieldParentPtr(NodeUndefinedLiteral, "base", base).lastToken(), |
| 83 | 86 | Id.BuiltinCall => @fieldParentPtr(NodeBuiltinCall, "base", base).lastToken(), |
| 87 | Id.Call => @fieldParentPtr(NodeCall, "base", base).lastToken(), |
| 84 | 88 | Id.LineComment => @fieldParentPtr(NodeLineComment, "base", base).lastToken(), |
| 85 | 89 | Id.TestDecl => @fieldParentPtr(NodeTestDecl, "base", base).lastToken(), |
| 86 | 90 | }; |
| ... | ... | @@ -527,6 +531,33 @@ pub const NodeBuiltinCall = struct { |
| 527 | 531 | } |
| 528 | 532 | }; |
| 529 | 533 | |
| 534 | pub const NodeCall = struct { |
| 535 | base: Node, |
| 536 | callee: &Node, |
| 537 | params: ArrayList(&Node), |
| 538 | rparen_token: Token, |
| 539 | |
| 540 | pub fn iterate(self: &NodeCall, index: usize) ?&Node { |
| 541 | var i = index; |
| 542 | |
| 543 | if (i < 1) return self.callee; |
| 544 | i -= 1; |
| 545 | |
| 546 | if (i < self.params.len) return self.params.at(i); |
| 547 | i -= self.params.len; |
| 548 | |
| 549 | return null; |
| 550 | } |
| 551 | |
| 552 | pub fn firstToken(self: &NodeCall) Token { |
| 553 | return self.callee.firstToken(); |
| 554 | } |
| 555 | |
| 556 | pub fn lastToken(self: &NodeCall) Token { |
| 557 | return self.rparen_token; |
| 558 | } |
| 559 | }; |
| 560 | |
| 530 | 561 | pub const NodeStringLiteral = struct { |
| 531 | 562 | base: Node, |
| 532 | 563 | token: Token, |