[parser] Remove dead AST walk and helper function

Change-Id: I0895d9b9131a0c06edd3d1359c080b8b6830d236
Reviewed-on: https://chromium-review.googlesource.com/c/1443060
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59190}
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 849122e..fffc331 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -2535,65 +2535,6 @@
   return true;
 }
 
-Statement* Parser::BuildAssertIsCoercible(Variable* var,
-                                          ObjectLiteral* pattern) {
-  // if (var === null || var === undefined)
-  //     throw /* type error kNonCoercible) */;
-  auto source_position = pattern->position();
-  const AstRawString* property = ast_value_factory()->empty_string();
-  MessageTemplate msg = MessageTemplate::kNonCoercible;
-  for (ObjectLiteralProperty* literal_property : *pattern->properties()) {
-    Expression* key = literal_property->key();
-    if (key->IsPropertyName()) {
-      property = key->AsLiteral()->AsRawPropertyName();
-      msg = MessageTemplate::kNonCoercibleWithProperty;
-      source_position = key->position();
-      break;
-    }
-  }
-
-  Expression* condition = factory()->NewBinaryOperation(
-      Token::OR,
-      factory()->NewCompareOperation(
-          Token::EQ_STRICT, factory()->NewVariableProxy(var),
-          factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition),
-      factory()->NewCompareOperation(
-          Token::EQ_STRICT, factory()->NewVariableProxy(var),
-          factory()->NewNullLiteral(kNoSourcePosition), kNoSourcePosition),
-      kNoSourcePosition);
-  Expression* throw_type_error =
-      NewThrowTypeError(msg, property, source_position);
-  IfStatement* if_statement = factory()->NewIfStatement(
-      condition,
-      factory()->NewExpressionStatement(throw_type_error, kNoSourcePosition),
-      factory()->EmptyStatement(), kNoSourcePosition);
-  return if_statement;
-}
-
-class InitializerRewriter final
-    : public AstTraversalVisitor<InitializerRewriter> {
- public:
-  InitializerRewriter(uintptr_t stack_limit, Expression* root, Parser* parser)
-      : AstTraversalVisitor(stack_limit, root), parser_(parser) {}
-
- private:
-  // This is required so that the overriden Visit* methods can be
-  // called by the base class (template).
-  friend class AstTraversalVisitor<InitializerRewriter>;
-
-  // Code in function literals does not need to be eagerly rewritten, it will be
-  // rewritten when scheduled.
-  void VisitFunctionLiteral(FunctionLiteral* expr) {}
-
-  Parser* parser_;
-};
-
-void Parser::RewriteParameterInitializer(Expression* expr) {
-  if (has_error()) return;
-  InitializerRewriter rewriter(stack_limit_, expr, this);
-  rewriter.Run();
-}
-
 Block* Parser::BuildParameterInitializationBlock(
     const ParserFormalParameters& parameters) {
   DCHECK(!parameters.is_simple);
@@ -2607,19 +2548,6 @@
     if (parameter->initializer() != nullptr) {
       // IS_UNDEFINED($param) ? initializer : $param
 
-      if (parameter->initializer()->IsClassLiteral()) {
-        //  Initializers could have their own scopes. So set the scope
-        //  here if necessary.
-        BlockState block_state(
-            &scope_, parameter->initializer()->AsClassLiteral()->scope());
-
-        // Ensure initializer is rewritten
-        RewriteParameterInitializer(parameter->initializer());
-      } else {
-        // Ensure initializer is rewritten
-        RewriteParameterInitializer(parameter->initializer());
-      }
-
       auto condition = factory()->NewCompareOperation(
           Token::EQ_STRICT,
           factory()->NewVariableProxy(parameters.scope->parameter(index)),
diff --git a/src/parsing/parser.h b/src/parsing/parser.h
index c926935..a7d490f 100644
--- a/src/parsing/parser.h
+++ b/src/parsing/parser.h
@@ -436,8 +436,6 @@
   BreakableStatement* LookupBreakTarget(const AstRawString* label);
   IterationStatement* LookupContinueTarget(const AstRawString* label);
 
-  Statement* BuildAssertIsCoercible(Variable* var, ObjectLiteral* pattern);
-
   // Factory methods.
   FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super,
                                       int pos, int end_pos);
@@ -528,9 +526,6 @@
 
   Expression* RewriteSpreads(ArrayLiteral* lit);
 
-  friend class InitializerRewriter;
-  void RewriteParameterInitializer(Expression* expr);
-
   Expression* BuildInitialYield(int pos, FunctionKind kind);
   Assignment* BuildCreateJSGeneratorObject(int pos, FunctionKind kind);
 
@@ -539,8 +534,6 @@
                             MessageTemplate message, const AstRawString* arg,
                             int pos);
 
-  Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion,
-                                    IteratorType type, int pos);
   Statement* CheckCallable(Variable* var, Expression* error, int pos);
 
   void RewriteAsyncFunctionBody(ScopedPtrList<Statement>* body, Block* block,