Use FunctionLiteral for class constructor
authorarv <arv@chromium.org>
Thu, 22 Jan 2015 06:17:11 +0000 (22:17 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 22 Jan 2015 06:17:17 +0000 (06:17 +0000)
Motivation: Code cleanup

BUG=None
LOG=N
R=adamk

Review URL: https://codereview.chromium.org/866533003

Cr-Commit-Position: refs/heads/master@{#26210}

src/ast.h
src/parser.cc

index 74d6461..dd49416 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -2621,7 +2621,7 @@ class ClassLiteral FINAL : public Expression {
   Scope* scope() const { return scope_; }
   VariableProxy* class_variable_proxy() const { return class_variable_proxy_; }
   Expression* extends() const { return extends_; }
-  Expression* constructor() const { return constructor_; }
+  FunctionLiteral* constructor() const { return constructor_; }
   ZoneList<Property*>* properties() const { return properties_; }
   int start_position() const { return position(); }
   int end_position() const { return end_position_; }
@@ -2634,7 +2634,7 @@ class ClassLiteral FINAL : public Expression {
  protected:
   ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope,
                VariableProxy* class_variable_proxy, Expression* extends,
-               Expression* constructor, ZoneList<Property*>* properties,
+               FunctionLiteral* constructor, ZoneList<Property*>* properties,
                int start_position, int end_position)
       : Expression(zone, start_position),
         raw_name_(name),
@@ -2653,7 +2653,7 @@ class ClassLiteral FINAL : public Expression {
   Scope* scope_;
   VariableProxy* class_variable_proxy_;
   Expression* extends_;
-  Expression* constructor_;
+  FunctionLiteral* constructor_;
   ZoneList<Property*>* properties_;
   int end_position_;
 };
@@ -3496,7 +3496,7 @@ class AstNodeFactory FINAL BASE_EMBEDDED {
 
   ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope,
                                 VariableProxy* proxy, Expression* extends,
-                                Expression* constructor,
+                                FunctionLiteral* constructor,
                                 ZoneList<ObjectLiteral::Property*>* properties,
                                 int start_position, int end_position) {
     return new (zone_)
index 6d1570b..ec98321 100644 (file)
@@ -4008,7 +4008,7 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
   }
 
   ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone());
-  Expression* constructor = NULL;
+  FunctionLiteral* constructor = NULL;
   bool has_seen_constructor = false;
 
   Expect(Token::LBRACE, CHECK_OK);
@@ -4024,7 +4024,8 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
                                 &has_seen_constructor, CHECK_OK);
 
     if (has_seen_constructor && constructor == NULL) {
-      constructor = GetPropertyValue(property);
+      constructor = GetPropertyValue(property)->AsFunctionLiteral();
+      DCHECK_NOT_NULL(constructor);
     } else {
       properties->Add(property, zone());
     }