OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/typing.h" | 5 #include "src/typing.h" |
6 | 6 |
7 #include "src/frames.h" | 7 #include "src/frames.h" |
8 #include "src/frames-inl.h" | 8 #include "src/frames-inl.h" |
9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
10 #include "src/parser.h" // for CompileTimeValue; TODO(rossberg): should move | 10 #include "src/parser.h" // for CompileTimeValue; TODO(rossberg): should move |
11 #include "src/scopes.h" | 11 #include "src/scopes.h" |
12 #include "src/splay-tree-inl.h" | 12 #include "src/splay-tree-inl.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 | 17 |
18 AstTyper::AstTyper(CompilationInfo* info) | 18 AstTyper::AstTyper(CompilationInfo* info) |
19 : info_(info), | 19 : info_(info), |
20 oracle_(info->isolate(), info->zone(), | 20 oracle_(info->isolate(), info->zone(), |
21 handle(info->closure()->shared()->code()), | 21 handle(info->closure()->shared()->code()), |
22 handle(info->closure()->shared()->feedback_vector()), | 22 handle(info->closure()->shared()->feedback_vector()), |
23 handle(info->closure()->context()->native_context())), | 23 handle(info->closure()->context()->native_context())), |
24 store_(info->zone()) { | 24 store_(info->zone()) { |
25 InitializeAstVisitor(info->isolate(), info->zone()); | 25 InitializeAstVisitor(info->isolate(), info->zone()); |
26 } | 26 } |
27 | 27 |
28 | 28 |
29 #define RECURSE(call) \ | |
30 do { \ | |
31 DCHECK(!visitor->HasStackOverflow()); \ | |
32 call; \ | |
33 if (visitor->HasStackOverflow()) return; \ | |
34 } while (false) | |
35 | |
36 void AstTyper::Run(CompilationInfo* info) { | |
37 AstTyper* visitor = new(info->zone()) AstTyper(info); | |
38 Scope* scope = info->scope(); | |
39 | |
40 RECURSE(visitor->VisitDeclarations(scope->declarations())); | |
41 RECURSE(visitor->VisitStatements(info->literal()->body())); | |
42 } | |
43 | |
44 #undef RECURSE | |
45 | |
46 | |
47 #ifdef OBJECT_PRINT | 29 #ifdef OBJECT_PRINT |
48 static void PrintObserved(Variable* var, Object* value, Type* type) { | 30 static void PrintObserved(Variable* var, Object* value, Type* type) { |
49 OFStream os(stdout); | 31 OFStream os(stdout); |
50 os << " observed " << (var->IsParameter() ? "param" : "local") << " "; | 32 os << " observed " << (var->IsParameter() ? "param" : "local") << " "; |
51 var->name()->Print(os); | 33 var->name()->Print(os); |
52 os << " : " << Brief(value) << " -> "; | 34 os << " : " << Brief(value) << " -> "; |
53 type->PrintTo(os); | 35 type->PrintTo(os); |
54 os << std::endl; | 36 os << std::endl; |
55 } | 37 } |
56 #endif // OBJECT_PRINT | 38 #endif // OBJECT_PRINT |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 97 |
116 | 98 |
117 #define RECURSE(call) \ | 99 #define RECURSE(call) \ |
118 do { \ | 100 do { \ |
119 DCHECK(!HasStackOverflow()); \ | 101 DCHECK(!HasStackOverflow()); \ |
120 call; \ | 102 call; \ |
121 if (HasStackOverflow()) return; \ | 103 if (HasStackOverflow()) return; \ |
122 } while (false) | 104 } while (false) |
123 | 105 |
124 | 106 |
| 107 void AstTyper::Run() { |
| 108 Scope* scope = info_->scope(); |
| 109 RECURSE(VisitDeclarations(scope->declarations())); |
| 110 RECURSE(VisitStatements(info_->literal()->body())); |
| 111 } |
| 112 |
| 113 |
125 void AstTyper::VisitStatements(ZoneList<Statement*>* stmts) { | 114 void AstTyper::VisitStatements(ZoneList<Statement*>* stmts) { |
126 for (int i = 0; i < stmts->length(); ++i) { | 115 for (int i = 0; i < stmts->length(); ++i) { |
127 Statement* stmt = stmts->at(i); | 116 Statement* stmt = stmts->at(i); |
128 RECURSE(Visit(stmt)); | 117 RECURSE(Visit(stmt)); |
129 if (stmt->IsJump()) break; | 118 if (stmt->IsJump()) break; |
130 } | 119 } |
131 } | 120 } |
132 | 121 |
133 | 122 |
134 void AstTyper::VisitBlock(Block* stmt) { | 123 void AstTyper::VisitBlock(Block* stmt) { |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 void AstTyper::VisitImportDeclaration(ImportDeclaration* declaration) { | 772 void AstTyper::VisitImportDeclaration(ImportDeclaration* declaration) { |
784 } | 773 } |
785 | 774 |
786 | 775 |
787 void AstTyper::VisitExportDeclaration(ExportDeclaration* declaration) { | 776 void AstTyper::VisitExportDeclaration(ExportDeclaration* declaration) { |
788 } | 777 } |
789 | 778 |
790 | 779 |
791 } // namespace internal | 780 } // namespace internal |
792 } // namespace v8 | 781 } // namespace v8 |
OLD | NEW |