// information.
void CodeForFunctionPosition(FunctionLiteral* fun);
void CodeForReturnPosition(FunctionLiteral* fun);
- void CodeForStatementPosition(Node* node);
+ void CodeForStatementPosition(AstNode* node);
void CodeForSourcePosition(int pos);
#ifdef DEBUG
// Nodes of the abstract syntax tree. Only concrete classes are
// enumerated here.
-#define NODE_LIST(V) \
+#define STATEMENT_NODE_LIST(V) \
V(Block) \
- V(Declaration) \
V(ExpressionStatement) \
V(EmptyStatement) \
V(IfStatement) \
V(ForInStatement) \
V(TryCatch) \
V(TryFinally) \
- V(DebuggerStatement) \
+ V(DebuggerStatement)
+
+#define EXPRESSION_NODE_LIST(V) \
V(FunctionLiteral) \
V(FunctionBoilerplateLiteral) \
V(Conditional) \
V(CompareOperation) \
V(ThisFunction)
+#define AST_NODE_LIST(V) \
+ V(Declaration) \
+ STATEMENT_NODE_LIST(V) \
+ EXPRESSION_NODE_LIST(V)
// Forward declarations
class TargetCollector;
typedef ZoneList<Handle<String> > ZoneStringList;
-class Node: public ZoneObject {
+class AstNode: public ZoneObject {
public:
- Node(): statement_pos_(RelocInfo::kNoPosition) { }
- virtual ~Node() { }
+ AstNode(): statement_pos_(RelocInfo::kNoPosition) { }
+ virtual ~AstNode() { }
virtual void Accept(AstVisitor* v) = 0;
// Type testing & conversion.
};
-class Statement: public Node {
+class Statement: public AstNode {
public:
virtual Statement* AsStatement() { return this; }
virtual ReturnStatement* AsReturnStatement() { return NULL; }
};
-class Expression: public Node {
+class Expression: public AstNode {
public:
virtual Expression* AsExpression() { return this; }
};
-class Declaration: public Node {
+class Declaration: public AstNode {
public:
Declaration(VariableProxy* proxy, Variable::Mode mode, FunctionLiteral* fun)
: proxy_(proxy),
// NOTE: TargetCollectors are represented as nodes to fit in the target
// stack in the compiler; this should probably be reworked.
-class TargetCollector: public Node {
+class TargetCollector: public AstNode {
public:
explicit TargetCollector(ZoneList<BreakTarget*>* targets)
: targets_(targets) {
virtual ~AstVisitor() { }
// Dispatch
- void Visit(Node* node) { node->Accept(this); }
+ void Visit(AstNode* node) { node->Accept(this); }
// Iteration
virtual void VisitStatements(ZoneList<Statement*>* statements);
}
-void CodeGenerator::CodeForStatementPosition(Node* node) {
+void CodeGenerator::CodeForStatementPosition(AstNode* node) {
if (FLAG_debug_info) {
int pos = node->statement_pos();
if (pos != RelocInfo::kNoPosition) {
// information.
void CodeForFunctionPosition(FunctionLiteral* fun);
void CodeForReturnPosition(FunctionLiteral* fun);
- void CodeForStatementPosition(Node* node);
+ void CodeForStatementPosition(AstNode* node);
void CodeForSourcePosition(int pos);
#ifdef DEBUG
class Target BASE_EMBEDDED {
public:
- Target(Parser* parser, Node* node)
+ Target(Parser* parser, AstNode* node)
: parser_(parser), node_(node), previous_(parser_->target_stack_) {
parser_->target_stack_ = this;
}
}
Target* previous() { return previous_; }
- Node* node() { return node_; }
+ AstNode* node() { return node_; }
private:
Parser* parser_;
- Node* node_;
+ AstNode* node_;
Target* previous_;
};
}
-const char* PrettyPrinter::Print(Node* node) {
+const char* PrettyPrinter::Print(AstNode* node) {
Init();
Visit(node);
return output_;
}
-void PrettyPrinter::PrintOut(Node* node) {
+void PrettyPrinter::PrintOut(AstNode* node) {
PrettyPrinter printer;
PrintF("%s", printer.Print(node));
}
}
-void AstPrinter::PrintIndentedVisit(const char* s, Node* node) {
+void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) {
IndentedScope indent(s);
Visit(node);
}
// The following routines print a node into a string.
// The result string is alive as long as the PrettyPrinter is alive.
- const char* Print(Node* node);
+ const char* Print(AstNode* node);
const char* PrintExpression(FunctionLiteral* program);
const char* PrintProgram(FunctionLiteral* program);
// Print a node to stdout.
- static void PrintOut(Node* node);
+ static void PrintOut(AstNode* node);
// Individual nodes
#define DEF_VISIT(type) \
private:
friend class IndentedScope;
void PrintIndented(const char* txt);
- void PrintIndentedVisit(const char* s, Node* node);
+ void PrintIndentedVisit(const char* s, AstNode* node);
void PrintStatements(ZoneList<Statement*>* statements);
void PrintDeclarations(ZoneList<Declaration*>* declarations);
class UsageComputer: public AstVisitor {
public:
- static bool Traverse(Node* node);
+ static bool Traverse(AstNode* node);
void VisitBlock(Block* node);
void VisitDeclaration(Declaration* node);
// ----------------------------------------------------------------------------
// Implementation of UsageComputer
-bool UsageComputer::Traverse(Node* node) {
+bool UsageComputer::Traverse(AstNode* node) {
UsageComputer uc(InitialWeight, false);
uc.Visit(node);
return !uc.HasStackOverflow();
#define DEF_VISIT(type) \
void Visit##type(type* node);
- NODE_LIST(DEF_VISIT)
+ AST_NODE_LIST(DEF_VISIT)
#undef DEF_VISIT
// Visit a statement and then spill the virtual frame if control flow can
// information.
void CodeForFunctionPosition(FunctionLiteral* fun);
void CodeForReturnPosition(FunctionLiteral* fun);
- void CodeForStatementPosition(Node* node);
+ void CodeForStatementPosition(AstNode* node);
void CodeForSourcePosition(int pos);
#ifdef DEBUG