diff --git a/go.mod b/go.mod index 35889101e13..181cd11cf1a 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/PuerkitoBio/goquery v1.8.1 github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5 github.com/andybalholm/brotli v1.0.5 - github.com/dop251/goja v0.0.0-20230919141708-865aea360f25 + github.com/dop251/goja v0.0.0-20230919151941-fc55792775de github.com/fatih/color v1.15.0 github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible github.com/golang/protobuf v1.5.3 diff --git a/go.sum b/go.sum index 29e286f09ab..2988552b9c5 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnm github.com/dlclark/regexp2 v1.9.0 h1:pTK/l/3qYIKaRXuHnEnIf7Y5NxfRPfpb7dis6/gdlVI= github.com/dlclark/regexp2 v1.9.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20230919141708-865aea360f25 h1:QMbwBGsztQRZO15o4qTPQif9Ipf4yz9KuCEJgNecomU= -github.com/dop251/goja v0.0.0-20230919141708-865aea360f25/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= +github.com/dop251/goja v0.0.0-20230919151941-fc55792775de h1:lA38Xtzr1Wo+iQdkN2E11ziKXJYRxLlzK/e2/fdxoEI= +github.com/dop251/goja v0.0.0-20230919151941-fc55792775de/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= diff --git a/vendor/github.com/dop251/goja/ast/node.go b/vendor/github.com/dop251/goja/ast/node.go index 176c1f3b035..3bec89db493 100644 --- a/vendor/github.com/dop251/goja/ast/node.go +++ b/vendor/github.com/dop251/goja/ast/node.go @@ -384,9 +384,10 @@ type ( } DoWhileStatement struct { - Do file.Idx - Test Expression - Body Statement + Do file.Idx + Test Expression + Body Statement + RightParenthesis file.Idx } EmptyStatement struct { @@ -442,6 +443,7 @@ type ( Discriminant Expression Default int Body []*CaseStatement + RightBrace file.Idx } ThrowStatement struct { @@ -669,8 +671,13 @@ func (self *TemplateElement) Idx0() file.Idx { return self.Idx } func (self *TemplateLiteral) Idx0() file.Idx { return self.OpenQuote } func (self *ThisExpression) Idx0() file.Idx { return self.Idx } func (self *SuperExpression) Idx0() file.Idx { return self.Idx } -func (self *UnaryExpression) Idx0() file.Idx { return self.Idx } -func (self *MetaProperty) Idx0() file.Idx { return self.Idx } +func (self *UnaryExpression) Idx0() file.Idx { + if self.Postfix { + return self.Operand.Idx0() + } + return self.Idx +} +func (self *MetaProperty) Idx0() file.Idx { return self.Idx } func (self *BadStatement) Idx0() file.Idx { return self.From } func (self *BlockStatement) Idx0() file.Idx { return self.LeftBrace } @@ -728,7 +735,7 @@ func (self *BinaryExpression) Idx1() file.Idx { return self.Right.Idx1() } func (self *BooleanLiteral) Idx1() file.Idx { return file.Idx(int(self.Idx) + len(self.Literal)) } func (self *BracketExpression) Idx1() file.Idx { return self.RightBracket + 1 } func (self *CallExpression) Idx1() file.Idx { return self.RightParenthesis + 1 } -func (self *ConditionalExpression) Idx1() file.Idx { return self.Test.Idx1() } +func (self *ConditionalExpression) Idx1() file.Idx { return self.Alternate.Idx1() } func (self *DotExpression) Idx1() file.Idx { return self.Identifier.Idx1() } func (self *PrivateDotExpression) Idx1() file.Idx { return self.Identifier.Idx1() } func (self *FunctionLiteral) Idx1() file.Idx { return self.Body.Idx1() } @@ -764,13 +771,18 @@ func (self *MetaProperty) Idx1() file.Idx { return self.Property.Idx1() } -func (self *BadStatement) Idx1() file.Idx { return self.To } -func (self *BlockStatement) Idx1() file.Idx { return self.RightBrace + 1 } -func (self *BranchStatement) Idx1() file.Idx { return self.Idx } +func (self *BadStatement) Idx1() file.Idx { return self.To } +func (self *BlockStatement) Idx1() file.Idx { return self.RightBrace + 1 } +func (self *BranchStatement) Idx1() file.Idx { + if self.Label == nil { + return file.Idx(int(self.Idx) + len(self.Token.String())) + } + return self.Label.Idx1() +} func (self *CaseStatement) Idx1() file.Idx { return self.Consequent[len(self.Consequent)-1].Idx1() } func (self *CatchStatement) Idx1() file.Idx { return self.Body.Idx1() } func (self *DebuggerStatement) Idx1() file.Idx { return self.Debugger + 8 } -func (self *DoWhileStatement) Idx1() file.Idx { return self.Test.Idx1() } +func (self *DoWhileStatement) Idx1() file.Idx { return self.RightParenthesis + 1 } func (self *EmptyStatement) Idx1() file.Idx { return self.Semicolon + 1 } func (self *ExpressionStatement) Idx1() file.Idx { return self.Expression.Idx1() } func (self *ForInStatement) Idx1() file.Idx { return self.Body.Idx1() } @@ -782,11 +794,16 @@ func (self *IfStatement) Idx1() file.Idx { } return self.Consequent.Idx1() } -func (self *LabelledStatement) Idx1() file.Idx { return self.Colon + 1 } +func (self *LabelledStatement) Idx1() file.Idx { return self.Statement.Idx1() } func (self *Program) Idx1() file.Idx { return self.Body[len(self.Body)-1].Idx1() } -func (self *ReturnStatement) Idx1() file.Idx { return self.Return + 6 } -func (self *SwitchStatement) Idx1() file.Idx { return self.Body[len(self.Body)-1].Idx1() } -func (self *ThrowStatement) Idx1() file.Idx { return self.Argument.Idx1() } +func (self *ReturnStatement) Idx1() file.Idx { + if self.Argument != nil { + return self.Argument.Idx1() + } + return self.Return + 6 +} +func (self *SwitchStatement) Idx1() file.Idx { return self.RightBrace + 1 } +func (self *ThrowStatement) Idx1() file.Idx { return self.Argument.Idx1() } func (self *TryStatement) Idx1() file.Idx { if self.Finally != nil { return self.Finally.Idx1() diff --git a/vendor/github.com/dop251/goja/parser/statement.go b/vendor/github.com/dop251/goja/parser/statement.go index adc220a388b..8ec5cdeb770 100644 --- a/vendor/github.com/dop251/goja/parser/statement.go +++ b/vendor/github.com/dop251/goja/parser/statement.go @@ -511,9 +511,10 @@ func (self *_parser) parseThrowStatement() ast.Statement { } func (self *_parser) parseSwitchStatement() ast.Statement { - self.expect(token.SWITCH) + idx := self.expect(token.SWITCH) self.expect(token.LEFT_PARENTHESIS) node := &ast.SwitchStatement{ + Switch: idx, Discriminant: self.parseExpression(), Default: -1, } @@ -529,6 +530,7 @@ func (self *_parser) parseSwitchStatement() ast.Statement { for index := 0; self.token != token.EOF; index++ { if self.token == token.RIGHT_BRACE { + node.RightBrace = self.idx self.next() break } @@ -547,11 +549,10 @@ func (self *_parser) parseSwitchStatement() ast.Statement { } func (self *_parser) parseWithStatement() ast.Statement { - self.expect(token.WITH) + node := &ast.WithStatement{} + node.With = self.expect(token.WITH) self.expect(token.LEFT_PARENTHESIS) - node := &ast.WithStatement{ - Object: self.parseExpression(), - } + node.Object = self.parseExpression() self.expect(token.RIGHT_PARENTHESIS) self.scope.allowLet = false node.Body = self.parseStatement() @@ -816,8 +817,8 @@ func (self *_parser) parseDoWhileStatement() ast.Statement { self.scope.inIteration = inIteration }() - self.expect(token.DO) node := &ast.DoWhileStatement{} + node.Do = self.expect(token.DO) if self.token == token.LEFT_BRACE { node.Body = self.parseBlockStatement() } else { @@ -828,7 +829,7 @@ func (self *_parser) parseDoWhileStatement() ast.Statement { self.expect(token.WHILE) self.expect(token.LEFT_PARENTHESIS) node.Test = self.parseExpression() - self.expect(token.RIGHT_PARENTHESIS) + node.RightParenthesis = self.expect(token.RIGHT_PARENTHESIS) if self.token == token.SEMICOLON { self.next() } @@ -837,10 +838,11 @@ func (self *_parser) parseDoWhileStatement() ast.Statement { } func (self *_parser) parseWhileStatement() ast.Statement { - self.expect(token.WHILE) + idx := self.expect(token.WHILE) self.expect(token.LEFT_PARENTHESIS) node := &ast.WhileStatement{ - Test: self.parseExpression(), + While: idx, + Test: self.parseExpression(), } self.expect(token.RIGHT_PARENTHESIS) node.Body = self.parseIterationStatement() diff --git a/vendor/modules.txt b/vendor/modules.txt index ef2bc5b774f..441bf4e3c96 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -101,7 +101,7 @@ github.com/dgryski/go-rendezvous ## explicit; go 1.13 github.com/dlclark/regexp2 github.com/dlclark/regexp2/syntax -# github.com/dop251/goja v0.0.0-20230919141708-865aea360f25 +# github.com/dop251/goja v0.0.0-20230919151941-fc55792775de ## explicit; go 1.16 github.com/dop251/goja github.com/dop251/goja/ast