| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_VARIABLES_H_ | 28 #ifndef V8_VARIABLES_H_ |
| 29 #define V8_VARIABLES_H_ | 29 #define V8_VARIABLES_H_ |
| 30 | 30 |
| 31 #include "zone.h" | 31 #include "zone.h" |
| 32 #include "interface.h" |
| 32 | 33 |
| 33 namespace v8 { | 34 namespace v8 { |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 // The AST refers to variables via VariableProxies - placeholders for the actual | 37 // The AST refers to variables via VariableProxies - placeholders for the actual |
| 37 // variables. Variables themselves are never directly referred to from the AST, | 38 // variables. Variables themselves are never directly referred to from the AST, |
| 38 // they are maintained by scopes, and referred to from VariableProxies and Slots | 39 // they are maintained by scopes, and referred to from VariableProxies and Slots |
| 39 // after binding and variable allocation. | 40 // after binding and variable allocation. |
| 40 | 41 |
| 41 class Variable: public ZoneObject { | 42 class Variable: public ZoneObject { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 71 // context object on the heap, with lookup starting at the current | 72 // context object on the heap, with lookup starting at the current |
| 72 // context. index() is invalid. | 73 // context. index() is invalid. |
| 73 LOOKUP | 74 LOOKUP |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 Variable(Scope* scope, | 77 Variable(Scope* scope, |
| 77 Handle<String> name, | 78 Handle<String> name, |
| 78 VariableMode mode, | 79 VariableMode mode, |
| 79 bool is_valid_lhs, | 80 bool is_valid_lhs, |
| 80 Kind kind, | 81 Kind kind, |
| 81 InitializationFlag initialization_flag); | 82 InitializationFlag initialization_flag, |
| 83 Interface* interface = Interface::NewValue()); |
| 82 | 84 |
| 83 // Printing support | 85 // Printing support |
| 84 static const char* Mode2String(VariableMode mode); | 86 static const char* Mode2String(VariableMode mode); |
| 85 | 87 |
| 86 bool IsValidLeftHandSide() { return is_valid_LHS_; } | 88 bool IsValidLeftHandSide() { return is_valid_LHS_; } |
| 87 | 89 |
| 88 // The source code for an eval() call may refer to a variable that is | 90 // The source code for an eval() call may refer to a variable that is |
| 89 // in an outer scope about which we don't know anything (it may not | 91 // in an outer scope about which we don't know anything (it may not |
| 90 // be the global scope). scope() is NULL in that case. Currently the | 92 // be the global scope). scope() is NULL in that case. Currently the |
| 91 // scope is only used to follow the context chain length. | 93 // scope is only used to follow the context chain length. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 148 |
| 147 void set_local_if_not_shadowed(Variable* local) { | 149 void set_local_if_not_shadowed(Variable* local) { |
| 148 local_if_not_shadowed_ = local; | 150 local_if_not_shadowed_ = local; |
| 149 } | 151 } |
| 150 | 152 |
| 151 Location location() const { return location_; } | 153 Location location() const { return location_; } |
| 152 int index() const { return index_; } | 154 int index() const { return index_; } |
| 153 InitializationFlag initialization_flag() const { | 155 InitializationFlag initialization_flag() const { |
| 154 return initialization_flag_; | 156 return initialization_flag_; |
| 155 } | 157 } |
| 158 Interface* interface() const { return interface_; } |
| 156 | 159 |
| 157 void AllocateTo(Location location, int index) { | 160 void AllocateTo(Location location, int index) { |
| 158 location_ = location; | 161 location_ = location; |
| 159 index_ = index; | 162 index_ = index; |
| 160 } | 163 } |
| 161 | 164 |
| 162 static int CompareIndex(Variable* const* v, Variable* const* w); | 165 static int CompareIndex(Variable* const* v, Variable* const* w); |
| 163 | 166 |
| 164 private: | 167 private: |
| 165 Scope* scope_; | 168 Scope* scope_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 176 // binding scope (exclusive). | 179 // binding scope (exclusive). |
| 177 Variable* local_if_not_shadowed_; | 180 Variable* local_if_not_shadowed_; |
| 178 | 181 |
| 179 // Valid as a LHS? (const and this are not valid LHS, for example) | 182 // Valid as a LHS? (const and this are not valid LHS, for example) |
| 180 bool is_valid_LHS_; | 183 bool is_valid_LHS_; |
| 181 | 184 |
| 182 // Usage info. | 185 // Usage info. |
| 183 bool force_context_allocation_; // set by variable resolver | 186 bool force_context_allocation_; // set by variable resolver |
| 184 bool is_used_; | 187 bool is_used_; |
| 185 InitializationFlag initialization_flag_; | 188 InitializationFlag initialization_flag_; |
| 189 |
| 190 // Module type info. |
| 191 Interface* interface_; |
| 186 }; | 192 }; |
| 187 | 193 |
| 188 | 194 |
| 189 } } // namespace v8::internal | 195 } } // namespace v8::internal |
| 190 | 196 |
| 191 #endif // V8_VARIABLES_H_ | 197 #endif // V8_VARIABLES_H_ |
| OLD | NEW |