| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 static bool Match(void* key1, void* key2) { | 70 static bool Match(void* key1, void* key2) { |
| 71 String* name1 = *reinterpret_cast<String**>(key1); | 71 String* name1 = *reinterpret_cast<String**>(key1); |
| 72 String* name2 = *reinterpret_cast<String**>(key2); | 72 String* name2 = *reinterpret_cast<String**>(key2); |
| 73 ASSERT(name1->IsSymbol()); | 73 ASSERT(name1->IsSymbol()); |
| 74 ASSERT(name2->IsSymbol()); | 74 ASSERT(name2->IsSymbol()); |
| 75 return name1 == name2; | 75 return name1 == name2; |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 // Dummy constructor | |
| 80 VariableMap::VariableMap(bool gotta_love_static_overloading) : HashMap() {} | |
| 81 | |
| 82 VariableMap::VariableMap() : HashMap(Match, &LocalsMapAllocator, 8) {} | 79 VariableMap::VariableMap() : HashMap(Match, &LocalsMapAllocator, 8) {} |
| 83 VariableMap::~VariableMap() {} | 80 VariableMap::~VariableMap() {} |
| 84 | 81 |
| 85 | 82 |
| 86 Variable* VariableMap::Declare(Scope* scope, | 83 Variable* VariableMap::Declare(Scope* scope, |
| 87 Handle<String> name, | 84 Handle<String> name, |
| 88 VariableMode mode, | 85 VariableMode mode, |
| 89 bool is_valid_lhs, | 86 bool is_valid_lhs, |
| 90 Variable::Kind kind) { | 87 Variable::Kind kind) { |
| 91 HashMap::Entry* p = HashMap::Lookup(name.location(), name->Hash(), true); | 88 HashMap::Entry* p = HashMap::Lookup(name.location(), name->Hash(), true); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 105 ASSERT(p->value != NULL); | 102 ASSERT(p->value != NULL); |
| 106 return reinterpret_cast<Variable*>(p->value); | 103 return reinterpret_cast<Variable*>(p->value); |
| 107 } | 104 } |
| 108 return NULL; | 105 return NULL; |
| 109 } | 106 } |
| 110 | 107 |
| 111 | 108 |
| 112 // ---------------------------------------------------------------------------- | 109 // ---------------------------------------------------------------------------- |
| 113 // Implementation of Scope | 110 // Implementation of Scope |
| 114 | 111 |
| 115 | |
| 116 // Dummy constructor | |
| 117 Scope::Scope(ScopeType type) | |
| 118 : isolate_(Isolate::Current()), | |
| 119 inner_scopes_(0), | |
| 120 variables_(false), | |
| 121 temps_(0), | |
| 122 params_(0), | |
| 123 unresolved_(0), | |
| 124 decls_(0), | |
| 125 already_resolved_(false) { | |
| 126 SetDefaults(type, NULL, Handle<SerializedScopeInfo>::null()); | |
| 127 } | |
| 128 | |
| 129 | |
| 130 Scope::Scope(Scope* outer_scope, ScopeType type) | 112 Scope::Scope(Scope* outer_scope, ScopeType type) |
| 131 : isolate_(Isolate::Current()), | 113 : isolate_(Isolate::Current()), |
| 132 inner_scopes_(4), | 114 inner_scopes_(4), |
| 133 variables_(), | 115 variables_(), |
| 134 temps_(4), | 116 temps_(4), |
| 135 params_(4), | 117 params_(4), |
| 136 unresolved_(16), | 118 unresolved_(16), |
| 137 decls_(4), | 119 decls_(4), |
| 138 already_resolved_(false) { | 120 already_resolved_(false) { |
| 139 SetDefaults(type, outer_scope, Handle<SerializedScopeInfo>::null()); | 121 SetDefaults(type, outer_scope, Handle<SerializedScopeInfo>::null()); |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && | 1142 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && |
| 1161 !must_have_local_context) { | 1143 !must_have_local_context) { |
| 1162 num_heap_slots_ = 0; | 1144 num_heap_slots_ = 0; |
| 1163 } | 1145 } |
| 1164 | 1146 |
| 1165 // Allocation done. | 1147 // Allocation done. |
| 1166 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); | 1148 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); |
| 1167 } | 1149 } |
| 1168 | 1150 |
| 1169 } } // namespace v8::internal | 1151 } } // namespace v8::internal |
| OLD | NEW |