Minor cleanups & trivial refactoring related to Ast.
authormarja@chromium.org <marja@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 3 Jun 2014 07:40:43 +0000 (07:40 +0000)
committermarja@chromium.org <marja@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 3 Jun 2014 07:40:43 +0000 (07:40 +0000)
1) Literal::IsNull, IsTrue and IsFalse were dead code, and not needed.
2) No need to use the node type constants outside the Ast; there is IsSomeNodeType().
3) AsSomeNodeType() != NULL -> IsSomeNodeType().

R=rossberg@chromium.org
BUG=

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21621 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/full-codegen-arm.cc
src/arm64/full-codegen-arm64.cc
src/ast.cc
src/ast.h
src/hydrogen.cc
src/ia32/full-codegen-ia32.cc
src/mips/full-codegen-mips.cc
src/parser.cc
src/x64/full-codegen-x64.cc
src/x87/full-codegen-x87.cc

index 5e3b62bf121d743a1903de347b0088cfb79958d1..7606969e24559518c60c77d35d1a29f1874fcbba 100644 (file)
@@ -2537,7 +2537,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
   // Assignment to a property, using a named store IC.
   Property* prop = expr->target()->AsProperty();
   ASSERT(prop != NULL);
-  ASSERT(prop->key()->AsLiteral() != NULL);
+  ASSERT(prop->key()->IsLiteral());
 
   // Record source code position before IC call.
   SetSourcePosition(expr->position());
index fb6cb079711670cc2da44b6e3b45194bfa34954b..d3c96dec1218dc98b5776c73c063319925083850 100644 (file)
@@ -2244,7 +2244,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
   // Assignment to a property, using a named store IC.
   Property* prop = expr->target()->AsProperty();
   ASSERT(prop != NULL);
-  ASSERT(prop->key()->AsLiteral() != NULL);
+  ASSERT(prop->key()->IsLiteral());
 
   // Record source code position before IC call.
   SetSourcePosition(expr->position());
index 303c442f8434301165ec8afd2106637cc410e8ac..e6bcec210ddce73eb3ac6c18baad25933d71ffce 100644 (file)
@@ -34,17 +34,17 @@ AST_NODE_LIST(DECL_ACCEPT)
 
 
 bool Expression::IsSmiLiteral() const {
-  return AsLiteral() != NULL && AsLiteral()->value()->IsSmi();
+  return IsLiteral() && AsLiteral()->value()->IsSmi();
 }
 
 
 bool Expression::IsStringLiteral() const {
-  return AsLiteral() != NULL && AsLiteral()->value()->IsString();
+  return IsLiteral() && AsLiteral()->value()->IsString();
 }
 
 
 bool Expression::IsNullLiteral() const {
-  return AsLiteral() != NULL && AsLiteral()->value()->IsNull();
+  return IsLiteral() && AsLiteral()->value()->IsNull();
 }
 
 
@@ -192,7 +192,7 @@ ObjectLiteralProperty::ObjectLiteralProperty(
     kind_ = PROTOTYPE;
   } else if (value_->AsMaterializedLiteral() != NULL) {
     kind_ = MATERIALIZED_LITERAL;
-  } else if (value_->AsLiteral() != NULL) {
+  } else if (value_->IsLiteral()) {
     kind_ = CONSTANT;
   } else {
     kind_ = COMPUTED;
@@ -390,7 +390,7 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
 
 Handle<Object> MaterializedLiteral::GetBoilerplateValue(Expression* expression,
                                                         Isolate* isolate) {
-  if (expression->AsLiteral() != NULL) {
+  if (expression->IsLiteral()) {
     return expression->AsLiteral()->value();
   }
   if (CompileTimeValue::IsCompileTimeValue(expression)) {
@@ -499,7 +499,7 @@ static bool IsVoidOfLiteral(Expression* expr) {
   UnaryOperation* maybe_unary = expr->AsUnaryOperation();
   return maybe_unary != NULL &&
       maybe_unary->op() == Token::VOID &&
-      maybe_unary->expression()->AsLiteral() != NULL;
+      maybe_unary->expression()->IsLiteral();
 }
 
 
index e2ea93354688c3fd82a379cf91321995f50918f4..5f696b584eb50951a1741093f609e77eee4274c8 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -1352,20 +1352,6 @@ class Literal V8_FINAL : public Expression {
     return !value_->BooleanValue();
   }
 
-  // Identity testers.
-  bool IsNull() const {
-    ASSERT(!value_.is_null());
-    return value_->IsNull();
-  }
-  bool IsTrue() const {
-    ASSERT(!value_.is_null());
-    return value_->IsTrue();
-  }
-  bool IsFalse() const {
-    ASSERT(!value_.is_null());
-    return value_->IsFalse();
-  }
-
   Handle<Object> value() const { return value_; }
 
   // Support for using Literal as a HashMap key. NOTE: Currently, this works
index 49fd879bdc4f397062db5cf791668a2658cebf42..8486a8371c02bf858521da2d908344773119d1f2 100644 (file)
@@ -9149,7 +9149,7 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
   CHECK_ALIVE(VisitForValue(arguments->at(kObjectArg)));
   HValue* obj = Pop();
 
-  if (arguments->at(kArrayIdArg)->node_type() != AstNode::kLiteral) {
+  if (arguments->at(kArrayIdArg)->IsLiteral()) {
     // This should never happen in real use, but can happen when fuzzing.
     // Just bail out.
     Bailout(kNeedSmiLiteral);
@@ -9176,7 +9176,7 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
   HValue* byte_offset;
   bool is_zero_byte_offset;
 
-  if (arguments->at(kByteOffsetArg)->node_type() == AstNode::kLiteral
+  if (arguments->at(kByteOffsetArg)->IsLiteral()
       && Smi::FromInt(0) ==
       *static_cast<Literal*>(arguments->at(kByteOffsetArg))->value()) {
     byte_offset = Add<HConstant>(static_cast<int32_t>(0));
index aa1af8e3ffd1e77384543bb85a312f703e535647..8ed505e6db1f9013960c3d10c6f3aa71d78301f5 100644 (file)
@@ -2476,7 +2476,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
 
   Property* prop = expr->target()->AsProperty();
   ASSERT(prop != NULL);
-  ASSERT(prop->key()->AsLiteral() != NULL);
+  ASSERT(prop->key()->IsLiteral());
 
   // Record source code position before IC call.
   SetSourcePosition(expr->position());
index 97df4714581319b29b0f1d7e9bf70ee96cc349b6..f71189df8dd4c3b71efcccfe2450f60db41beb0e 100644 (file)
@@ -2548,7 +2548,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
   // Assignment to a property, using a named store IC.
   Property* prop = expr->target()->AsProperty();
   ASSERT(prop != NULL);
-  ASSERT(prop->key()->AsLiteral() != NULL);
+  ASSERT(prop->key()->IsLiteral());
 
   // Record source code position before IC call.
   SetSourcePosition(expr->position());
index a08148c5974f3de8fb882935b774afd1e0d20abf..49e76618ca6fbea9b0787b3ced1ca9050eeb37e5 100644 (file)
@@ -525,7 +525,7 @@ Expression* ParserTraits::BuildUnaryExpression(
     Expression* expression, Token::Value op, int pos,
     AstNodeFactory<AstConstructionVisitor>* factory) {
   ASSERT(expression != NULL);
-  if (expression->AsLiteral() != NULL) {
+  if (expression->IsLiteral()) {
     Handle<Object> literal = expression->AsLiteral()->value();
     if (op == Token::NOT) {
       // Convert the literal to a boolean condition and negate it.
@@ -3224,7 +3224,7 @@ void Parser::ReportInvalidCachedData(Handle<String> name, bool* ok) {
 
 
 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) {
-  if (expression->AsLiteral() != NULL) return true;
+  if (expression->IsLiteral()) return true;
   MaterializedLiteral* lit = expression->AsMaterializedLiteral();
   return lit != NULL && lit->is_simple();
 }
index a031a59eae531f2bd6b606c292eb433824add4de..5c85cd65bc89fe31670107839b212236dbc74157 100644 (file)
@@ -2477,7 +2477,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
   // Assignment to a property, using a named store IC.
   Property* prop = expr->target()->AsProperty();
   ASSERT(prop != NULL);
-  ASSERT(prop->key()->AsLiteral() != NULL);
+  ASSERT(prop->key()->IsLiteral());
 
   // Record source code position before IC call.
   SetSourcePosition(expr->position());
index ef7f567730cbc8a18849703b1da64b259d2a141f..c888b6e8798fef2d8e4cb134689c936c6ea5b8dd 100644 (file)
@@ -2470,7 +2470,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
 
   Property* prop = expr->target()->AsProperty();
   ASSERT(prop != NULL);
-  ASSERT(prop->key()->AsLiteral() != NULL);
+  ASSERT(prop->key()->IsLiteral());
 
   // Record source code position before IC call.
   SetSourcePosition(expr->position());