@@ -381,7 +381,7 @@ func (r *Runtime) stringproto_localeCompare(call FunctionCall) Value {
381381func (r * Runtime ) stringproto_match (call FunctionCall ) Value {
382382 r .checkObjectCoercible (call .This )
383383 regexp := call .Argument (0 )
384- if regexp != _undefined && regexp != _null {
384+ if _ , ok := regexp .( * Object ); ok {
385385 if matcher := toMethod (r .getV (regexp , SymMatch )); matcher != nil {
386386 return matcher (FunctionCall {
387387 This : regexp ,
@@ -412,14 +412,12 @@ func (r *Runtime) stringproto_match(call FunctionCall) Value {
412412func (r * Runtime ) stringproto_matchAll (call FunctionCall ) Value {
413413 r .checkObjectCoercible (call .This )
414414 regexp := call .Argument (0 )
415- if regexp != _undefined && regexp != _null {
415+ if o , ok := regexp .( * Object ); ok {
416416 if isRegexp (regexp ) {
417- if o , ok := regexp .(* Object ); ok {
418- flags := nilSafe (o .self .getStr ("flags" , nil ))
419- r .checkObjectCoercible (flags )
420- if ! strings .Contains (flags .toString ().String (), "g" ) {
421- panic (r .NewTypeError ("RegExp doesn't have global flag set" ))
422- }
417+ flags := nilSafe (o .self .getStr ("flags" , nil ))
418+ r .checkObjectCoercible (flags )
419+ if ! strings .Contains (flags .toString ().String (), "g" ) {
420+ panic (r .NewTypeError ("RegExp doesn't have global flag set" ))
423421 }
424422 }
425423 if matcher := toMethod (r .getV (regexp , SymMatchAll )); matcher != nil {
@@ -664,7 +662,7 @@ func (r *Runtime) stringproto_replace(call FunctionCall) Value {
664662 r .checkObjectCoercible (call .This )
665663 searchValue := call .Argument (0 )
666664 replaceValue := call .Argument (1 )
667- if searchValue != _undefined && searchValue != _null {
665+ if _ , ok := searchValue .( * Object ); ok {
668666 if replacer := toMethod (r .getV (searchValue , SymReplace )); replacer != nil {
669667 return replacer (FunctionCall {
670668 This : searchValue ,
@@ -689,14 +687,12 @@ func (r *Runtime) stringproto_replaceAll(call FunctionCall) Value {
689687 r .checkObjectCoercible (call .This )
690688 searchValue := call .Argument (0 )
691689 replaceValue := call .Argument (1 )
692- if searchValue != _undefined && searchValue != _null {
690+ if o , ok := searchValue .( * Object ); ok {
693691 if isRegexp (searchValue ) {
694- if o , ok := searchValue .(* Object ); ok {
695- flags := nilSafe (o .self .getStr ("flags" , nil ))
696- r .checkObjectCoercible (flags )
697- if ! strings .Contains (flags .toString ().String (), "g" ) {
698- panic (r .NewTypeError ("String.prototype.replaceAll called with a non-global RegExp argument" ))
699- }
692+ flags := nilSafe (o .self .getStr ("flags" , nil ))
693+ r .checkObjectCoercible (flags )
694+ if ! strings .Contains (flags .toString ().String (), "g" ) {
695+ panic (r .NewTypeError ("String.prototype.replaceAll called with a non-global RegExp argument" ))
700696 }
701697 }
702698 if replacer := toMethod (r .getV (searchValue , SymReplace )); replacer != nil {
@@ -726,7 +722,7 @@ func (r *Runtime) stringproto_replaceAll(call FunctionCall) Value {
726722func (r * Runtime ) stringproto_search (call FunctionCall ) Value {
727723 r .checkObjectCoercible (call .This )
728724 regexp := call .Argument (0 )
729- if regexp != _undefined && regexp != _null {
725+ if _ , ok := regexp .( * Object ); ok {
730726 if searcher := toMethod (r .getV (regexp , SymSearch )); searcher != nil {
731727 return searcher (FunctionCall {
732728 This : regexp ,
@@ -799,7 +795,7 @@ func (r *Runtime) stringproto_split(call FunctionCall) Value {
799795 r .checkObjectCoercible (call .This )
800796 separatorValue := call .Argument (0 )
801797 limitValue := call .Argument (1 )
802- if separatorValue != _undefined && separatorValue != _null {
798+ if _ , ok := separatorValue .( * Object ); ok {
803799 if splitter := toMethod (r .getV (separatorValue , SymSplit )); splitter != nil {
804800 return splitter (FunctionCall {
805801 This : separatorValue ,
0 commit comments