| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/ast/ast.h" | 5 #include "src/ast/ast.h" |
| 6 | 6 |
| 7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
| 8 |
| 9 #include "src/ast/prettyprinter.h" |
| 8 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| 9 #include "src/builtins.h" | 11 #include "src/builtins.h" |
| 10 #include "src/code-stubs.h" | 12 #include "src/code-stubs.h" |
| 11 #include "src/contexts.h" | 13 #include "src/contexts.h" |
| 12 #include "src/conversions.h" | 14 #include "src/conversions.h" |
| 13 #include "src/hashmap.h" | 15 #include "src/hashmap.h" |
| 14 #include "src/parsing/parser.h" | 16 #include "src/parsing/parser.h" |
| 15 #include "src/property.h" | 17 #include "src/property.h" |
| 16 #include "src/property-details.h" | 18 #include "src/property-details.h" |
| 17 #include "src/string-stream.h" | 19 #include "src/string-stream.h" |
| 18 #include "src/type-info.h" | 20 #include "src/type-info.h" |
| 19 | 21 |
| 20 namespace v8 { | 22 namespace v8 { |
| 21 namespace internal { | 23 namespace internal { |
| 22 | 24 |
| 23 // ---------------------------------------------------------------------------- | 25 // ---------------------------------------------------------------------------- |
| 24 // All the Accept member functions for each syntax tree node type. | 26 // All the Accept member functions for each syntax tree node type. |
| 25 | 27 |
| 26 #define DECL_ACCEPT(type) \ | 28 #define DECL_ACCEPT(type) \ |
| 27 void type::Accept(AstVisitor* v) { v->Visit##type(this); } | 29 void type::Accept(AstVisitor* v) { v->Visit##type(this); } |
| 28 AST_NODE_LIST(DECL_ACCEPT) | 30 AST_NODE_LIST(DECL_ACCEPT) |
| 29 #undef DECL_ACCEPT | 31 #undef DECL_ACCEPT |
| 30 | 32 |
| 31 | 33 |
| 32 // ---------------------------------------------------------------------------- | 34 // ---------------------------------------------------------------------------- |
| 33 // Implementation of other node functionality. | 35 // Implementation of other node functionality. |
| 34 | 36 |
| 37 #ifdef DEBUG |
| 38 |
| 39 void AstNode::PrintAst() { PrintAst(Isolate::Current()); } |
| 40 |
| 41 |
| 42 void AstNode::PrintAst(Isolate* isolate) { |
| 43 AstPrinter::PrintOut(isolate, this); |
| 44 } |
| 45 |
| 46 |
| 47 void AstNode::PrettyPrint() { PrettyPrint(Isolate::Current()); } |
| 48 |
| 49 |
| 50 void AstNode::PrettyPrint(Isolate* isolate) { |
| 51 PrettyPrinter::PrintOut(isolate, this); |
| 52 } |
| 53 |
| 54 #endif // DEBUG |
| 55 |
| 35 | 56 |
| 36 bool Expression::IsSmiLiteral() const { | 57 bool Expression::IsSmiLiteral() const { |
| 37 return IsLiteral() && AsLiteral()->value()->IsSmi(); | 58 return IsLiteral() && AsLiteral()->value()->IsSmi(); |
| 38 } | 59 } |
| 39 | 60 |
| 40 | 61 |
| 41 bool Expression::IsStringLiteral() const { | 62 bool Expression::IsStringLiteral() const { |
| 42 return IsLiteral() && AsLiteral()->value()->IsString(); | 63 return IsLiteral() && AsLiteral()->value()->IsString(); |
| 43 } | 64 } |
| 44 | 65 |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 bool Literal::Match(void* literal1, void* literal2) { | 838 bool Literal::Match(void* literal1, void* literal2) { |
| 818 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 839 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 819 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 840 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 820 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 841 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
| 821 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 842 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 822 } | 843 } |
| 823 | 844 |
| 824 | 845 |
| 825 } // namespace internal | 846 } // namespace internal |
| 826 } // namespace v8 | 847 } // namespace v8 |
| OLD | NEW |