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

Side by Side Diff: src/ast.h

Issue 6810015: Remove unnecessary AST node for ++ and -- operations. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 V(ObjectLiteral) \ 81 V(ObjectLiteral) \
82 V(ArrayLiteral) \ 82 V(ArrayLiteral) \
83 V(CatchExtensionObject) \ 83 V(CatchExtensionObject) \
84 V(Assignment) \ 84 V(Assignment) \
85 V(Throw) \ 85 V(Throw) \
86 V(Property) \ 86 V(Property) \
87 V(Call) \ 87 V(Call) \
88 V(CallNew) \ 88 V(CallNew) \
89 V(CallRuntime) \ 89 V(CallRuntime) \
90 V(UnaryOperation) \ 90 V(UnaryOperation) \
91 V(IncrementOperation) \
92 V(CountOperation) \ 91 V(CountOperation) \
93 V(BinaryOperation) \ 92 V(BinaryOperation) \
94 V(CompareOperation) \ 93 V(CompareOperation) \
95 V(CompareToNull) \ 94 V(CompareToNull) \
96 V(ThisFunction) 95 V(ThisFunction)
97 96
98 #define AST_NODE_LIST(V) \ 97 #define AST_NODE_LIST(V) \
99 V(Declaration) \ 98 V(Declaration) \
100 STATEMENT_NODE_LIST(V) \ 99 STATEMENT_NODE_LIST(V) \
101 EXPRESSION_NODE_LIST(V) 100 EXPRESSION_NODE_LIST(V)
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 Token::Value op_; 1479 Token::Value op_;
1481 Expression* left_; 1480 Expression* left_;
1482 Expression* right_; 1481 Expression* right_;
1483 int pos_; 1482 int pos_;
1484 // The short-circuit logical operations have an AST ID for their 1483 // The short-circuit logical operations have an AST ID for their
1485 // right-hand subexpression. 1484 // right-hand subexpression.
1486 int right_id_; 1485 int right_id_;
1487 }; 1486 };
1488 1487
1489 1488
1490 class IncrementOperation: public Expression {
1491 public:
1492 IncrementOperation(Token::Value op, Expression* expr)
1493 : op_(op), expression_(expr) {
1494 ASSERT(Token::IsCountOp(op));
1495 }
1496
1497 DECLARE_NODE_TYPE(IncrementOperation)
1498
1499 Token::Value op() const { return op_; }
1500 bool is_increment() { return op_ == Token::INC; }
1501 Expression* expression() const { return expression_; }
1502
1503 private:
1504 Token::Value op_;
1505 Expression* expression_;
1506 int pos_;
1507 };
1508
1509
1510 class CountOperation: public Expression { 1489 class CountOperation: public Expression {
1511 public: 1490 public:
1512 CountOperation(bool is_prefix, IncrementOperation* increment, int pos) 1491 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos)
1513 : is_prefix_(is_prefix), increment_(increment), pos_(pos), 1492 : op_(op),
1514 assignment_id_(GetNextId()) { 1493 is_prefix_(is_prefix),
1515 } 1494 expression_(expr),
1495 pos_(pos),
1496 assignment_id_(GetNextId()),
1497 count_id_(GetNextId()) { }
1516 1498
1517 DECLARE_NODE_TYPE(CountOperation) 1499 DECLARE_NODE_TYPE(CountOperation)
1518 1500
1519 bool is_prefix() const { return is_prefix_; } 1501 bool is_prefix() const { return is_prefix_; }
1520 bool is_postfix() const { return !is_prefix_; } 1502 bool is_postfix() const { return !is_prefix_; }
1521 1503
1522 Token::Value op() const { return increment_->op(); } 1504 Token::Value op() const { return op_; }
1523 Token::Value binary_op() { 1505 Token::Value binary_op() {
1524 return (op() == Token::INC) ? Token::ADD : Token::SUB; 1506 return (op() == Token::INC) ? Token::ADD : Token::SUB;
1525 } 1507 }
1526 1508
1527 Expression* expression() const { return increment_->expression(); } 1509 Expression* expression() const { return expression_; }
1528 IncrementOperation* increment() const { return increment_; }
1529 int position() const { return pos_; } 1510 int position() const { return pos_; }
1530 1511
1531 virtual void MarkAsStatement() { is_prefix_ = true; } 1512 virtual void MarkAsStatement() { is_prefix_ = true; }
1532 1513
1533 virtual bool IsInlineable() const; 1514 virtual bool IsInlineable() const;
1534 1515
1535 // Bailout support. 1516 // Bailout support.
1536 int AssignmentId() const { return assignment_id_; } 1517 int AssignmentId() const { return assignment_id_; }
1518 int CountId() const { return count_id_; }
1537 1519
1538 private: 1520 private:
1521 Token::Value op_;
1539 bool is_prefix_; 1522 bool is_prefix_;
1540 IncrementOperation* increment_; 1523 Expression* expression_;
1541 int pos_; 1524 int pos_;
1542 int assignment_id_; 1525 int assignment_id_;
1526 int count_id_;
1543 }; 1527 };
1544 1528
1545 1529
1546 class CompareOperation: public Expression { 1530 class CompareOperation: public Expression {
1547 public: 1531 public:
1548 CompareOperation(Token::Value op, 1532 CompareOperation(Token::Value op,
1549 Expression* left, 1533 Expression* left,
1550 Expression* right, 1534 Expression* right,
1551 int pos) 1535 int pos)
1552 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { 1536 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) {
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 2209
2226 private: 2210 private:
2227 Isolate* isolate_; 2211 Isolate* isolate_;
2228 bool stack_overflow_; 2212 bool stack_overflow_;
2229 }; 2213 };
2230 2214
2231 2215
2232 } } // namespace v8::internal 2216 } } // namespace v8::internal
2233 2217
2234 #endif // V8_AST_H_ 2218 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698