Revision: 5328
Author: [email protected]
Date: Tue Aug 24 05:56:45 2010
Log: Introduce a new intermediate AST node for encapsulating the
increment part of a count operation.
Review URL: http://codereview.chromium.org/3150032
http://code.google.com/p/v8/source/detail?r=5328
Modified:
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/codegen.cc
/branches/bleeding_edge/src/data-flow.cc
/branches/bleeding_edge/src/full-codegen.cc
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/prettyprinter.cc
/branches/bleeding_edge/src/rewriter.cc
=======================================
--- /branches/bleeding_edge/src/ast.h Tue Aug 24 02:04:17 2010
+++ /branches/bleeding_edge/src/ast.h Tue Aug 24 05:56:45 2010
@@ -89,6 +89,7 @@
V(CallNew) \
V(CallRuntime) \
V(UnaryOperation) \
+ V(IncrementOperation) \
V(CountOperation) \
V(BinaryOperation) \
V(CompareOperation) \
@@ -1248,12 +1249,29 @@
};
-class CountOperation: public Expression {
+class IncrementOperation: public Expression {
public:
- CountOperation(bool is_prefix, Token::Value op, Expression* expression)
- : is_prefix_(is_prefix), op_(op), expression_(expression) {
+ IncrementOperation(Token::Value op, Expression* expr)
+ : op_(op), expression_(expr) {
ASSERT(Token::IsCountOp(op));
}
+
+ Token::Value op() const { return op_; }
+ bool is_increment() { return op_ == Token::INC; }
+ Expression* expression() const { return expression_; }
+
+ virtual void Accept(AstVisitor* v);
+
+ private:
+ Token::Value op_;
+ Expression* expression_;
+};
+
+
+class CountOperation: public Expression {
+ public:
+ CountOperation(bool is_prefix, IncrementOperation* increment)
+ : is_prefix_(is_prefix), increment_(increment) { }
virtual void Accept(AstVisitor* v);
@@ -1261,18 +1279,20 @@
bool is_prefix() const { return is_prefix_; }
bool is_postfix() const { return !is_prefix_; }
- Token::Value op() const { return op_; }
+
+ Token::Value op() const { return increment_->op(); }
Token::Value binary_op() {
- return op_ == Token::INC ? Token::ADD : Token::SUB;
- }
- Expression* expression() const { return expression_; }
+ return (op() == Token::INC) ? Token::ADD : Token::SUB;
+ }
+
+ Expression* expression() const { return increment_->expression(); }
+ IncrementOperation* increment() const { return increment_; }
virtual void MarkAsStatement() { is_prefix_ = true; }
private:
bool is_prefix_;
- Token::Value op_;
- Expression* expression_;
+ IncrementOperation* increment_;
};
=======================================
--- /branches/bleeding_edge/src/codegen.cc Mon Aug 9 06:12:02 2010
+++ /branches/bleeding_edge/src/codegen.cc Tue Aug 24 05:56:45 2010
@@ -337,6 +337,11 @@
// declaration the global variables and functions.
DeclareGlobals(array);
}
+
+
+void CodeGenerator::VisitIncrementOperation(IncrementOperation* expr) {
+ UNREACHABLE();
+}
// List of special runtime calls which are generated inline. For some of
these
=======================================
--- /branches/bleeding_edge/src/data-flow.cc Tue Aug 24 00:26:49 2010
+++ /branches/bleeding_edge/src/data-flow.cc Tue Aug 24 05:56:45 2010
@@ -467,6 +467,12 @@
MarkIfTrivial(expr->expression());
Visit(expr->expression());
}
+
+
+void AssignedVariablesAnalyzer::VisitIncrementOperation(
+ IncrementOperation* expr) {
+ UNREACHABLE();
+}
void AssignedVariablesAnalyzer::VisitCountOperation(CountOperation* expr) {
=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Tue Aug 24 02:04:17 2010
+++ /branches/bleeding_edge/src/full-codegen.cc Tue Aug 24 05:56:45 2010
@@ -213,6 +213,12 @@
// Throw is breakable if the expression is.
Visit(expr->exception());
}
+
+
+void BreakableStatementChecker::VisitIncrementOperation(
+ IncrementOperation* expr) {
+ UNREACHABLE();
+}
void BreakableStatementChecker::VisitProperty(Property* expr) {
@@ -1012,6 +1018,11 @@
__ CallRuntime(Runtime::kThrow, 1);
// Never returns here.
}
+
+
+void FullCodeGenerator::VisitIncrementOperation(IncrementOperation* expr) {
+ UNREACHABLE();
+}
int FullCodeGenerator::TryFinally::Exit(int stack_depth) {
=======================================
--- /branches/bleeding_edge/src/parser.cc Tue Aug 24 03:53:44 2010
+++ /branches/bleeding_edge/src/parser.cc Tue Aug 24 05:56:45 2010
@@ -3086,7 +3086,8 @@
Handle<String> type = Factory::invalid_lhs_in_prefix_op_symbol();
expression = NewThrowReferenceError(type);
}
- return NEW(CountOperation(true /* prefix */, op, expression));
+ IncrementOperation* increment = NEW(IncrementOperation(op,
expression));
+ return NEW(CountOperation(true /* prefix */, increment));
} else {
return ParsePostfixExpression(ok);
@@ -3109,7 +3110,8 @@
expression = NewThrowReferenceError(type);
}
Token::Value next = Next();
- expression = NEW(CountOperation(false /* postfix */, next,
expression));
+ IncrementOperation* increment = NEW(IncrementOperation(next,
expression));
+ expression = NEW(CountOperation(false /* postfix */, increment));
}
return expression;
}
=======================================
--- /branches/bleeding_edge/src/prettyprinter.cc Tue Aug 24 00:26:49 2010
+++ /branches/bleeding_edge/src/prettyprinter.cc Tue Aug 24 05:56:45 2010
@@ -374,6 +374,11 @@
Visit(node->expression());
Print(")");
}
+
+
+void PrettyPrinter::VisitIncrementOperation(IncrementOperation* node) {
+ UNREACHABLE();
+}
void PrettyPrinter::VisitCountOperation(CountOperation* node) {
@@ -1075,6 +1080,11 @@
void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
PrintIndentedVisit(Token::Name(node->op()), node->expression());
}
+
+
+void AstPrinter::VisitIncrementOperation(IncrementOperation* node) {
+ UNREACHABLE();
+}
void AstPrinter::VisitCountOperation(CountOperation* node) {
@@ -1475,6 +1485,11 @@
}
Visit(expr->expression());
}
+
+
+void JsonAstBuilder::VisitIncrementOperation(IncrementOperation* expr) {
+ UNREACHABLE();
+}
void JsonAstBuilder::VisitCountOperation(CountOperation* expr) {
=======================================
--- /branches/bleeding_edge/src/rewriter.cc Tue Aug 24 00:26:49 2010
+++ /branches/bleeding_edge/src/rewriter.cc Tue Aug 24 05:56:45 2010
@@ -34,7 +34,6 @@
namespace v8 {
namespace internal {
-
class AstOptimizer: public AstVisitor {
public:
explicit AstOptimizer() : has_function_literal_(false) {}
@@ -434,6 +433,11 @@
node->expression()->set_to_int32(true);
}
}
+
+
+void AstOptimizer::VisitIncrementOperation(IncrementOperation* node) {
+ UNREACHABLE();
+}
void AstOptimizer::VisitCountOperation(CountOperation* node) {
@@ -945,6 +949,11 @@
USE(node);
UNREACHABLE();
}
+
+
+void Processor::VisitIncrementOperation(IncrementOperation* node) {
+ UNREACHABLE();
+}
void Processor::VisitCountOperation(CountOperation* node) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev