Reviewers: rossberg,

Message:
rossberg, ptal. Just some minor cleanups which I carved out of the symbol table
CL.

Description:
Minor cleanups & trivial refactoring related to Ast.

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().

[email protected]
BUG=

Please review this at https://codereview.chromium.org/298143004/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+16, -30 lines):
  M src/arm/full-codegen-arm.cc
  M src/arm64/full-codegen-arm64.cc
  M src/ast.h
  M src/ast.cc
  M src/hydrogen.cc
  M src/ia32/full-codegen-ia32.cc
  M src/mips/full-codegen-mips.cc
  M src/parser.cc
  M src/x64/full-codegen-x64.cc
  M src/x87/full-codegen-x87.cc


Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index ccde8b6b227901c07fd5be6e9beb1d5537400963..028fcd02058f195a1d56dfc195873fb2c00bae55 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -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: src/arm64/full-codegen-arm64.cc
diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 1dcdf3c1f9d2678934527149154814ecb3ae4563..e2daecb6482751f793522fdbdb26b1332dc3ead7 100644
--- a/src/arm64/full-codegen-arm64.cc
+++ b/src/arm64/full-codegen-arm64.cc
@@ -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: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 303c442f8434301165ec8afd2106637cc410e8ac..e6bcec210ddce73eb3ac6c18baad25933d71ffce 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -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: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 0115d988272c44e64f326d6f7377619824f2ea41..ba128b3c0c0103d57ed9865d968d8196c6b352e3 100644
--- 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: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 6059a2a65317b2d9dfba4505ad2ca835e339523e..5acd5130d6409b686344f6a8adc11698993e1a79 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -8885,7 +8885,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);
@@ -8912,7 +8912,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: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 88dad86da8379d1b09526661876cf8286bc33a31..4a00049ad61e53eab7da8715f5e2fe99d0365d85 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -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: src/mips/full-codegen-mips.cc
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index 5a47a7ce46e4f0ffe9c95d11cb8a07c16a7eb0b9..28a0b3fd3c70d482a64a186785c4be69a19196c1 100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -2538,7 +2538,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: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index a08148c5974f3de8fb882935b774afd1e0d20abf..49e76618ca6fbea9b0787b3ced1ca9050eeb37e5 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -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: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index 97c9c5cdebc0ef9b35bd9293a7f49ec090491a11..2271870a4bd3efeb2aad2be19a7eef91d23381fe 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -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: src/x87/full-codegen-x87.cc
diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc
index 06eaa21f311b8e4ab839e56a0976ca1d1d4ac457..cc77544933449b5b15b0585b1942e15397e93710 100644
--- a/src/x87/full-codegen-x87.cc
+++ b/src/x87/full-codegen-x87.cc
@@ -2460,7 +2460,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());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to