Revision: 17187
Author: rossb...@chromium.org
Date: Mon Oct 14 11:06:15 2013 UTC
Log: Unify handling of position info in AST, part 3
* Turn CaseClause into a proper AstNode
R=yang...@chromium.org
BUG=
Review URL: https://codereview.chromium.org/23684058
http://code.google.com/p/v8/source/detail?r=17187
Modified:
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/full-codegen.cc
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/prettyprinter.cc
/branches/bleeding_edge/src/rewriter.cc
/branches/bleeding_edge/src/typing.cc
=======================================
--- /branches/bleeding_edge/src/ast.cc Mon Oct 14 09:24:58 2013 UTC
+++ /branches/bleeding_edge/src/ast.cc Mon Oct 14 11:06:15 2013 UTC
@@ -1034,9 +1034,9 @@
Expression* label,
ZoneList<Statement*>* statements,
int pos)
- : label_(label),
+ : AstNode(pos),
+ label_(label),
statements_(statements),
- position_(pos),
compare_type_(Type::None(), isolate),
compare_id_(AstNode::GetNextId(isolate)),
entry_id_(AstNode::GetNextId(isolate)) {
@@ -1078,6 +1078,7 @@
REGULAR_NODE(BreakStatement)
REGULAR_NODE(ReturnStatement)
REGULAR_NODE(SwitchStatement)
+REGULAR_NODE(CaseClause)
REGULAR_NODE(Conditional)
REGULAR_NODE(Literal)
REGULAR_NODE(ArrayLiteral)
=======================================
--- /branches/bleeding_edge/src/ast.h Mon Oct 14 09:41:41 2013 UTC
+++ /branches/bleeding_edge/src/ast.h Mon Oct 14 11:06:15 2013 UTC
@@ -117,11 +117,15 @@
V(CompareOperation) \
V(ThisFunction)
+#define AUXILIARY_NODE_LIST(V) \
+ V(CaseClause)
+
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
MODULE_NODE_LIST(V) \
STATEMENT_NODE_LIST(V) \
- EXPRESSION_NODE_LIST(V)
+ EXPRESSION_NODE_LIST(V) \
+ AUXILIARY_NODE_LIST(V)
// Forward declarations
class AstConstructionVisitor;
@@ -1102,12 +1106,9 @@
};
-class CaseClause V8_FINAL : public ZoneObject {
+class CaseClause V8_FINAL : public AstNode {
public:
- CaseClause(Isolate* isolate,
- Expression* label,
- ZoneList<Statement*>* statements,
- int pos);
+ DECLARE_NODE_TYPE(CaseClause)
bool is_default() const { return label_ == NULL; }
Expression* label() const {
@@ -1116,9 +1117,6 @@
}
Label* body_target() { return &body_target_; }
ZoneList<Statement*>* statements() const { return statements_; }
-
- int position() const { return position_; }
- void set_position(int pos) { position_ = pos; }
BailoutId EntryId() const { return entry_id_; }
@@ -1128,10 +1126,14 @@
Handle<Type> compare_type() { return compare_type_; }
private:
+ CaseClause(Isolate* isolate,
+ Expression* label,
+ ZoneList<Statement*>* statements,
+ int pos);
+
Expression* label_;
Label body_target_;
ZoneList<Statement*>* statements_;
- int position_;
Handle<Type> compare_type_;
const TypeFeedbackId compare_id_;
@@ -3035,6 +3037,13 @@
EmptyStatement* NewEmptyStatement(int pos) {
return new(zone_) EmptyStatement(pos);
}
+
+ CaseClause* NewCaseClause(
+ Expression* label, ZoneList<Statement*>* statements, int pos) {
+ CaseClause* clause =
+ new(zone_) CaseClause(isolate_, label, statements, pos);
+ VISIT_AND_RETURN(CaseClause, clause)
+ }
Literal* NewLiteral(Handle<Object> handle, int pos) {
Literal* lit = new(zone_) Literal(isolate_, handle, pos);
=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Mon Oct 14 09:41:41 2013 UTC
+++ /branches/bleeding_edge/src/full-codegen.cc Mon Oct 14 11:06:15 2013 UTC
@@ -191,6 +191,10 @@
// The debugger statement is breakable.
is_breakable_ = true;
}
+
+
+void BreakableStatementChecker::VisitCaseClause(CaseClause* clause) {
+}
void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral*
expr) {
@@ -1513,6 +1517,11 @@
// Ignore the return value.
#endif
}
+
+
+void FullCodeGenerator::VisitCaseClause(CaseClause* clause) {
+ UNREACHABLE();
+}
void FullCodeGenerator::VisitConditional(Conditional* expr) {
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Oct 11 09:25:14 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc Mon Oct 14 11:06:15 2013 UTC
@@ -3967,6 +3967,11 @@
ASSERT(current_block()->HasPredecessor());
return Bailout(kDebuggerStatement);
}
+
+
+void HOptimizedGraphBuilder::VisitCaseClause(CaseClause* clause) {
+ UNREACHABLE();
+}
static Handle<SharedFunctionInfo> SearchSharedFunctionInfo(
=======================================
--- /branches/bleeding_edge/src/parser.cc Mon Oct 14 09:41:41 2013 UTC
+++ /branches/bleeding_edge/src/parser.cc Mon Oct 14 11:06:15 2013 UTC
@@ -2392,7 +2392,7 @@
statements->Add(stat, zone());
}
- return new(zone()) CaseClause(isolate(), label, statements, pos);
+ return factory()->NewCaseClause(label, statements, pos);
}
@@ -3231,7 +3231,7 @@
return factory()->NewCountOperation(op,
true /* prefix */,
expression,
- position()); //
TODO(rossberg): ???
+ position());
} else {
return ParsePostfixExpression(ok);
@@ -3267,7 +3267,7 @@
factory()->NewCountOperation(next,
false /* postfix */,
expression,
- position()); // TODO(rossberg): ???
+ position());
}
return expression;
}
=======================================
--- /branches/bleeding_edge/src/prettyprinter.cc Tue Oct 1 09:47:37 2013
UTC
+++ /branches/bleeding_edge/src/prettyprinter.cc Mon Oct 14 11:06:15 2013
UTC
@@ -200,9 +200,23 @@
Print(") { ");
ZoneList<CaseClause*>* cases = node->cases();
for (int i = 0; i < cases->length(); i++)
- PrintCaseClause(cases->at(i));
+ Visit(cases->at(i));
Print("}");
}
+
+
+void PrettyPrinter::VisitCaseClause(CaseClause* clause) {
+ if (clause->is_default()) {
+ Print("default");
+ } else {
+ Print("case ");
+ Visit(clause->label());
+ }
+ Print(": ");
+ PrintStatements(clause->statements());
+ if (clause->statements()->length() > 0)
+ Print(" ");
+}
void PrettyPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
@@ -618,20 +632,6 @@
PrintStatements(function->body());
Print(" }");
}
-
-
-void PrettyPrinter::PrintCaseClause(CaseClause* clause) {
- if (clause->is_default()) {
- Print("default");
- } else {
- Print("case ");
- Visit(clause->label());
- }
- Print(": ");
- PrintStatements(clause->statements());
- if (clause->statements()->length() > 0)
- Print(" ");
-}
//-----------------------------------------------------------------------------
@@ -759,18 +759,6 @@
Visit(arguments->at(i));
}
}
-
-
-void AstPrinter::PrintCaseClause(CaseClause* clause) {
- if (clause->is_default()) {
- IndentedScope indent(this, "DEFAULT");
- PrintStatements(clause->statements());
- } else {
- IndentedScope indent(this, "CASE");
- Visit(clause->label());
- PrintStatements(clause->statements());
- }
-}
void AstPrinter::VisitBlock(Block* node) {
@@ -900,7 +888,19 @@
PrintLabelsIndented(node->labels());
PrintIndentedVisit("TAG", node->tag());
for (int i = 0; i < node->cases()->length(); i++) {
- PrintCaseClause(node->cases()->at(i));
+ Visit(node->cases()->at(i));
+ }
+}
+
+
+void AstPrinter::VisitCaseClause(CaseClause* clause) {
+ if (clause->is_default()) {
+ IndentedScope indent(this, "DEFAULT");
+ PrintStatements(clause->statements());
+ } else {
+ IndentedScope indent(this, "CASE");
+ Visit(clause->label());
+ PrintStatements(clause->statements());
}
}
=======================================
--- /branches/bleeding_edge/src/rewriter.cc Mon Oct 14 09:24:58 2013 UTC
+++ /branches/bleeding_edge/src/rewriter.cc Mon Oct 14 11:06:15 2013 UTC
@@ -205,6 +205,11 @@
}
is_set_ = is_set_ && set_after_switch;
}
+
+
+void Processor::VisitCaseClause(CaseClause* clause) {
+ UNREACHABLE();
+}
void Processor::VisitContinueStatement(ContinueStatement* node) {
=======================================
--- /branches/bleeding_edge/src/typing.cc Fri Oct 11 16:41:34 2013 UTC
+++ /branches/bleeding_edge/src/typing.cc Mon Oct 14 11:06:15 2013 UTC
@@ -204,6 +204,11 @@
}
}
}
+
+
+void AstTyper::VisitCaseClause(CaseClause* clause) {
+ UNREACHABLE();
+}
void AstTyper::VisitDoWhileStatement(DoWhileStatement* stmt) {
--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.