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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/parser.h" | 10 #include "src/parser.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 VariableMap::~VariableMap() {} | 29 VariableMap::~VariableMap() {} |
30 | 30 |
31 | 31 |
32 Variable* VariableMap::Declare(Scope* scope, const AstRawString* name, | 32 Variable* VariableMap::Declare(Scope* scope, const AstRawString* name, |
33 VariableMode mode, Variable::Kind kind, | 33 VariableMode mode, Variable::Kind kind, |
34 InitializationFlag initialization_flag, | 34 InitializationFlag initialization_flag, |
35 MaybeAssignedFlag maybe_assigned_flag) { | 35 MaybeAssignedFlag maybe_assigned_flag) { |
36 // AstRawStrings are unambiguous, i.e., the same string is always represented | 36 // AstRawStrings are unambiguous, i.e., the same string is always represented |
37 // by the same AstRawString*. | 37 // by the same AstRawString*. |
38 // FIXME(marja): fix the type of Lookup. | 38 // FIXME(marja): fix the type of Lookup. |
39 Entry* p = ZoneHashMap::Lookup(const_cast<AstRawString*>(name), name->hash(), | 39 Entry* p = |
40 true, ZoneAllocationPolicy(zone())); | 40 ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(), |
| 41 ZoneAllocationPolicy(zone())); |
41 if (p->value == NULL) { | 42 if (p->value == NULL) { |
42 // The variable has not been declared yet -> insert it. | 43 // The variable has not been declared yet -> insert it. |
43 DCHECK(p->key == name); | 44 DCHECK(p->key == name); |
44 p->value = new (zone()) Variable(scope, name, mode, kind, | 45 p->value = new (zone()) Variable(scope, name, mode, kind, |
45 initialization_flag, maybe_assigned_flag); | 46 initialization_flag, maybe_assigned_flag); |
46 } | 47 } |
47 return reinterpret_cast<Variable*>(p->value); | 48 return reinterpret_cast<Variable*>(p->value); |
48 } | 49 } |
49 | 50 |
50 | 51 |
51 Variable* VariableMap::Lookup(const AstRawString* name) { | 52 Variable* VariableMap::Lookup(const AstRawString* name) { |
52 Entry* p = ZoneHashMap::Lookup(const_cast<AstRawString*>(name), name->hash(), | 53 Entry* p = ZoneHashMap::Lookup(const_cast<AstRawString*>(name), name->hash()); |
53 false, ZoneAllocationPolicy(NULL)); | |
54 if (p != NULL) { | 54 if (p != NULL) { |
55 DCHECK(reinterpret_cast<const AstRawString*>(p->key) == name); | 55 DCHECK(reinterpret_cast<const AstRawString*>(p->key) == name); |
56 DCHECK(p->value != NULL); | 56 DCHECK(p->value != NULL); |
57 return reinterpret_cast<Variable*>(p->value); | 57 return reinterpret_cast<Variable*>(p->value); |
58 } | 58 } |
59 return NULL; | 59 return NULL; |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 // ---------------------------------------------------------------------------- | 63 // ---------------------------------------------------------------------------- |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); | 1462 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); |
1463 } | 1463 } |
1464 | 1464 |
1465 | 1465 |
1466 int Scope::ContextLocalCount() const { | 1466 int Scope::ContextLocalCount() const { |
1467 if (num_heap_slots() == 0) return 0; | 1467 if (num_heap_slots() == 0) return 0; |
1468 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1468 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1469 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1469 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1470 } | 1470 } |
1471 } } // namespace v8::internal | 1471 } } // namespace v8::internal |
OLD | NEW |