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 #ifndef V8_CRANKSHAFT_TYPING_H_ | 5 #ifndef V8_CRANKSHAFT_TYPING_H_ |
6 #define V8_CRANKSHAFT_TYPING_H_ | 6 #define V8_CRANKSHAFT_TYPING_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast/ast-type-bounds.h" | 9 #include "src/ast/ast-type-bounds.h" |
10 #include "src/ast/ast-types.h" | 10 #include "src/ast/ast-types.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 Effects EnterEffects() { | 61 Effects EnterEffects() { |
62 store_ = store_.Push(); | 62 store_ = store_.Push(); |
63 return store_.Top(); | 63 return store_.Top(); |
64 } | 64 } |
65 void ExitEffects() { store_ = store_.Pop(); } | 65 void ExitEffects() { store_ = store_.Pop(); } |
66 | 66 |
67 int parameter_index(int index) { return -index - 2; } | 67 int parameter_index(int index) { return -index - 2; } |
68 int stack_local_index(int index) { return index; } | 68 int stack_local_index(int index) { return index; } |
69 | 69 |
70 int variable_index(Variable* var) { | 70 int variable_index(Variable* var); |
71 // Stack locals have the range [0 .. l] | |
72 // Parameters have the range [-1 .. p] | |
73 // We map this to [-p-2 .. -1, 0 .. l] | |
74 return var->IsStackLocal() ? stack_local_index(var->index()) : | |
75 var->IsParameter() ? parameter_index(var->index()) : kNoVar; | |
76 } | |
77 | 71 |
78 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 72 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
79 void VisitStatements(ZoneList<Statement*>* statements); | 73 void VisitStatements(ZoneList<Statement*>* statements); |
80 | 74 |
81 #define DECLARE_VISIT(type) void Visit##type(type* node); | 75 #define DECLARE_VISIT(type) void Visit##type(type* node); |
82 AST_NODE_LIST(DECLARE_VISIT) | 76 AST_NODE_LIST(DECLARE_VISIT) |
83 #undef DECLARE_VISIT | 77 #undef DECLARE_VISIT |
84 | 78 |
85 DISALLOW_COPY_AND_ASSIGN(AstTyper); | 79 DISALLOW_COPY_AND_ASSIGN(AstTyper); |
86 }; | 80 }; |
87 | 81 |
88 } // namespace internal | 82 } // namespace internal |
89 } // namespace v8 | 83 } // namespace v8 |
90 | 84 |
91 #endif // V8_CRANKSHAFT_TYPING_H_ | 85 #endif // V8_CRANKSHAFT_TYPING_H_ |
OLD | NEW |