| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 483 |
| 484 int Scope::ContextChainLength(Scope* scope) { | 484 int Scope::ContextChainLength(Scope* scope) { |
| 485 int n = 0; | 485 int n = 0; |
| 486 for (Scope* s = this; s != scope; s = s->outer_scope_) { | 486 for (Scope* s = this; s != scope; s = s->outer_scope_) { |
| 487 ASSERT(s != NULL); // scope must be in the scope chain | 487 ASSERT(s != NULL); // scope must be in the scope chain |
| 488 if (s->num_heap_slots() > 0) n++; | 488 if (s->num_heap_slots() > 0) n++; |
| 489 } | 489 } |
| 490 return n; | 490 return n; |
| 491 } | 491 } |
| 492 | 492 |
| 493 // In strict mode, arguments are const. |
| 494 void Scope::SetAttributesConst() { |
| 495 Variable* arguments = LocalLookup(Factory::arguments_symbol()); |
| 496 ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly |
| 497 ASSERT(arguments->mode() == Variable::VAR); |
| 498 arguments->set_mode(Variable::CONST); |
| 499 } |
| 493 | 500 |
| 494 #ifdef DEBUG | 501 #ifdef DEBUG |
| 495 static const char* Header(Scope::Type type) { | 502 static const char* Header(Scope::Type type) { |
| 496 switch (type) { | 503 switch (type) { |
| 497 case Scope::EVAL_SCOPE: return "eval"; | 504 case Scope::EVAL_SCOPE: return "eval"; |
| 498 case Scope::FUNCTION_SCOPE: return "function"; | 505 case Scope::FUNCTION_SCOPE: return "function"; |
| 499 case Scope::GLOBAL_SCOPE: return "global"; | 506 case Scope::GLOBAL_SCOPE: return "global"; |
| 500 } | 507 } |
| 501 UNREACHABLE(); | 508 UNREACHABLE(); |
| 502 return NULL; | 509 return NULL; |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && | 1062 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && |
| 1056 !must_have_local_context) { | 1063 !must_have_local_context) { |
| 1057 num_heap_slots_ = 0; | 1064 num_heap_slots_ = 0; |
| 1058 } | 1065 } |
| 1059 | 1066 |
| 1060 // Allocation done. | 1067 // Allocation done. |
| 1061 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); | 1068 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); |
| 1062 } | 1069 } |
| 1063 | 1070 |
| 1064 } } // namespace v8::internal | 1071 } } // namespace v8::internal |
| OLD | NEW |