diff --git a/go.mod b/go.mod index e5d9eb8b848..93bad8f5084 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/PuerkitoBio/goquery v1.6.1 github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5 github.com/andybalholm/brotli v1.0.3 - github.com/dop251/goja v0.0.0-20211211112501-fb27c91c26ed + github.com/dop251/goja v0.0.0-20211217115348-3f9136fa235d github.com/fatih/color v1.12.0 github.com/golang/protobuf v1.4.3 github.com/gorilla/websocket v1.4.2 diff --git a/go.sum b/go.sum index e4c1c848ef1..0f6b726f0ff 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16/II7vuEo/nHjodOg0p7+OiDpjX5t1E= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dop251/goja v0.0.0-20211211112501-fb27c91c26ed h1:93Xt1lY7ReTv+7uDM6UHe818CEvLLn5HE1gpB7d3MS8= -github.com/dop251/goja v0.0.0-20211211112501-fb27c91c26ed/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja v0.0.0-20211217115348-3f9136fa235d h1:XT7Qdmcuwgsgz4GXejX7R5Morysk2GOpeguYJ9JoF5c= +github.com/dop251/goja v0.0.0-20211217115348-3f9136fa235d/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= diff --git a/vendor/github.com/dop251/goja/compiler.go b/vendor/github.com/dop251/goja/compiler.go index 12359ed8438..136f67cb6fd 100644 --- a/vendor/github.com/dop251/goja/compiler.go +++ b/vendor/github.com/dop251/goja/compiler.go @@ -384,6 +384,13 @@ func (p *Program) sourceOffset(pc int) int { return 0 } +func (p *Program) addSrcMap(srcPos int) { + if len(p.srcMap) > 0 && p.srcMap[len(p.srcMap)-1].srcPos == srcPos { + return + } + p.srcMap = append(p.srcMap, srcMapItem{pc: len(p.code), srcPos: srcPos}) +} + func (s *scope) lookupName(name unistring.String) (binding *binding, noDynamics bool) { noDynamics = true toStash := false diff --git a/vendor/github.com/dop251/goja/compiler_expr.go b/vendor/github.com/dop251/goja/compiler_expr.go index 5bfeb8dba8c..40821746ca2 100644 --- a/vendor/github.com/dop251/goja/compiler_expr.go +++ b/vendor/github.com/dop251/goja/compiler_expr.go @@ -300,7 +300,7 @@ func (e *baseCompiledExpr) emitUnary(func(), func(), bool, bool) { func (e *baseCompiledExpr) addSrcMap() { if e.offset >= 0 { - e.c.p.srcMap = append(e.c.p.srcMap, srcMapItem{pc: len(e.c.p.code), srcPos: e.offset}) + e.c.p.addSrcMap(e.offset) } } diff --git a/vendor/github.com/dop251/goja/compiler_stmt.go b/vendor/github.com/dop251/goja/compiler_stmt.go index 05d3b875ce7..e658997d7d4 100644 --- a/vendor/github.com/dop251/goja/compiler_stmt.go +++ b/vendor/github.com/dop251/goja/compiler_stmt.go @@ -202,9 +202,13 @@ func (c *compiler) compileTryStatement(v *ast.TryStatement, needResult bool) { c.leaveBlock() } +func (c *compiler) addSrcMap(node ast.Node) { + c.p.addSrcMap(int(node.Idx0()) - 1) +} + func (c *compiler) compileThrowStatement(v *ast.ThrowStatement) { - //c.p.srcMap = append(c.p.srcMap, srcMapItem{pc: len(c.p.code), srcPos: int(v.Throw) - 1}) c.compileExpression(v.Argument).emitGetter(true) + c.addSrcMap(v) c.emit(throw) } @@ -752,6 +756,7 @@ func (c *compiler) emitVarAssign(name unistring.String, offset int, init compile if init != nil { c.emitVarRef(name, offset) c.emitNamed(init, name) + c.p.addSrcMap(offset) c.emit(initValueP) } } @@ -775,6 +780,7 @@ func (c *compiler) emitLexicalAssign(name unistring.String, offset int, init com } if init != nil { c.emitNamed(init, name) + c.p.addSrcMap(offset) } else { if isConst { c.throwSyntaxError(offset, "Missing initializer in const declaration") diff --git a/vendor/github.com/dop251/goja/parser/statement.go b/vendor/github.com/dop251/goja/parser/statement.go index 580d0440645..8c5320c5939 100644 --- a/vendor/github.com/dop251/goja/parser/statement.go +++ b/vendor/github.com/dop251/goja/parser/statement.go @@ -269,6 +269,7 @@ func (self *_parser) parseThrowStatement() ast.Statement { } node := &ast.ThrowStatement{ + Throw: idx, Argument: self.parseExpression(), } diff --git a/vendor/modules.txt b/vendor/modules.txt index 9b44def9b4d..d43f3e59e6a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -23,7 +23,7 @@ github.com/davecgh/go-spew/spew ## explicit github.com/dlclark/regexp2 github.com/dlclark/regexp2/syntax -# github.com/dop251/goja v0.0.0-20211211112501-fb27c91c26ed +# github.com/dop251/goja v0.0.0-20211217115348-3f9136fa235d ## explicit; go 1.14 github.com/dop251/goja github.com/dop251/goja/ast