Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: src/ast.h

Issue 3150032: Introduce a new intermediate AST node for encapsulating the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/codegen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
===================================================================
--- src/ast.h (revision 5326)
+++ src/ast.h (working copy)
@@ -89,6 +89,7 @@
V(CallNew) \
V(CallRuntime) \
V(UnaryOperation) \
+ V(IncrementOperation) \
V(CountOperation) \
V(BinaryOperation) \
V(CompareOperation) \
@@ -1248,31 +1249,50 @@
};
-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);
+
virtual CountOperation* AsCountOperation() { return this; }
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;
+ return (op() == Token::INC) ? Token::ADD : Token::SUB;
}
- Expression* expression() const { return expression_; }
+ 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_;
};
« no previous file with comments | « no previous file | src/codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698