Adding AstNode::PrettyPrint and AstNode::PrintAst
BUG= Review URL: https://codereview.chromium.org/1587543003 Cr-Commit-Position: refs/heads/master@{#33323}
This commit is contained in:
parent
be2210bcc4
commit
b0119907ac
@ -5,6 +5,8 @@
|
||||
#include "src/ast/ast.h"
|
||||
|
||||
#include <cmath> // For isfinite.
|
||||
|
||||
#include "src/ast/prettyprinter.h"
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/builtins.h"
|
||||
#include "src/code-stubs.h"
|
||||
@ -32,6 +34,25 @@ AST_NODE_LIST(DECL_ACCEPT)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Implementation of other node functionality.
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
void AstNode::PrintAst() { PrintAst(Isolate::Current()); }
|
||||
|
||||
|
||||
void AstNode::PrintAst(Isolate* isolate) {
|
||||
AstPrinter::PrintOut(isolate, this);
|
||||
}
|
||||
|
||||
|
||||
void AstNode::PrettyPrint() { PrettyPrint(Isolate::Current()); }
|
||||
|
||||
|
||||
void AstNode::PrettyPrint(Isolate* isolate) {
|
||||
PrettyPrinter::PrintOut(isolate, this);
|
||||
}
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
|
||||
bool Expression::IsSmiLiteral() const {
|
||||
return IsLiteral() && AsLiteral()->value()->IsSmi();
|
||||
|
@ -196,6 +196,13 @@ class AstNode: public ZoneObject {
|
||||
virtual NodeType node_type() const = 0;
|
||||
int position() const { return position_; }
|
||||
|
||||
#ifdef DEBUG
|
||||
void PrettyPrint(Isolate* isolate);
|
||||
void PrettyPrint();
|
||||
void PrintAst(Isolate* isolate);
|
||||
void PrintAst();
|
||||
#endif // DEBUG
|
||||
|
||||
// Type testing & conversion functions overridden by concrete subclasses.
|
||||
#define DECLARE_NODE_FUNCTIONS(type) \
|
||||
bool Is##type() const { return node_type() == AstNode::k##type; } \
|
||||
|
Loading…
Reference in New Issue
Block a user