| 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/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/char-predicates-inl.h" | 10 #include "src/char-predicates-inl.h" |
| (...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2204 if (is_const) { | 2204 if (is_const) { |
| 2205 arguments->Add(value, zone()); | 2205 arguments->Add(value, zone()); |
| 2206 value = NULL; // zap the value to avoid the unnecessary assignment | 2206 value = NULL; // zap the value to avoid the unnecessary assignment |
| 2207 | 2207 |
| 2208 // Construct the call to Runtime_InitializeConstGlobal | 2208 // Construct the call to Runtime_InitializeConstGlobal |
| 2209 // and add it to the initialization statement block. | 2209 // and add it to the initialization statement block. |
| 2210 // Note that the function does different things depending on | 2210 // Note that the function does different things depending on |
| 2211 // the number of arguments (1 or 2). | 2211 // the number of arguments (1 or 2). |
| 2212 initialize = factory()->NewCallRuntime( | 2212 initialize = factory()->NewCallRuntime( |
| 2213 isolate()->factory()->InitializeConstGlobal_string(), | 2213 isolate()->factory()->InitializeConstGlobal_string(), |
| 2214 Runtime::FunctionForId(Runtime::kHiddenInitializeConstGlobal), | 2214 Runtime::FunctionForId(Runtime::kInitializeConstGlobal), |
| 2215 arguments, pos); | 2215 arguments, pos); |
| 2216 } else { | 2216 } else { |
| 2217 // Add strict mode. | 2217 // Add strict mode. |
| 2218 // We may want to pass singleton to avoid Literal allocations. | 2218 // We may want to pass singleton to avoid Literal allocations. |
| 2219 StrictMode strict_mode = initialization_scope->strict_mode(); | 2219 StrictMode strict_mode = initialization_scope->strict_mode(); |
| 2220 arguments->Add(factory()->NewNumberLiteral(strict_mode, pos), zone()); | 2220 arguments->Add(factory()->NewNumberLiteral(strict_mode, pos), zone()); |
| 2221 | 2221 |
| 2222 // Be careful not to assign a value to the global variable if | 2222 // Be careful not to assign a value to the global variable if |
| 2223 // we're in a with. The initialization value should not | 2223 // we're in a with. The initialization value should not |
| 2224 // necessarily be stored in the global object in that case, | 2224 // necessarily be stored in the global object in that case, |
| (...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3661 RelocInfo::kNoPosition), | 3661 RelocInfo::kNoPosition), |
| 3662 RelocInfo::kNoPosition), zone()); | 3662 RelocInfo::kNoPosition), zone()); |
| 3663 } | 3663 } |
| 3664 | 3664 |
| 3665 // For generators, allocate and yield an iterator on function entry. | 3665 // For generators, allocate and yield an iterator on function entry. |
| 3666 if (is_generator) { | 3666 if (is_generator) { |
| 3667 ZoneList<Expression*>* arguments = | 3667 ZoneList<Expression*>* arguments = |
| 3668 new(zone()) ZoneList<Expression*>(0, zone()); | 3668 new(zone()) ZoneList<Expression*>(0, zone()); |
| 3669 CallRuntime* allocation = factory()->NewCallRuntime( | 3669 CallRuntime* allocation = factory()->NewCallRuntime( |
| 3670 isolate()->factory()->empty_string(), | 3670 isolate()->factory()->empty_string(), |
| 3671 Runtime::FunctionForId(Runtime::kHiddenCreateJSGeneratorObject), | 3671 Runtime::FunctionForId(Runtime::kCreateJSGeneratorObject), |
| 3672 arguments, pos); | 3672 arguments, pos); |
| 3673 VariableProxy* init_proxy = factory()->NewVariableProxy( | 3673 VariableProxy* init_proxy = factory()->NewVariableProxy( |
| 3674 function_state_->generator_object_variable()); | 3674 function_state_->generator_object_variable()); |
| 3675 Assignment* assignment = factory()->NewAssignment( | 3675 Assignment* assignment = factory()->NewAssignment( |
| 3676 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition); | 3676 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition); |
| 3677 VariableProxy* get_proxy = factory()->NewVariableProxy( | 3677 VariableProxy* get_proxy = factory()->NewVariableProxy( |
| 3678 function_state_->generator_object_variable()); | 3678 function_state_->generator_object_variable()); |
| 3679 Yield* yield = factory()->NewYield( | 3679 Yield* yield = factory()->NewYield( |
| 3680 get_proxy, assignment, Yield::INITIAL, RelocInfo::kNoPosition); | 3680 get_proxy, assignment, Yield::INITIAL, RelocInfo::kNoPosition); |
| 3681 body->Add(factory()->NewExpressionStatement( | 3681 body->Add(factory()->NewExpressionStatement( |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4807 ASSERT(info()->isolate()->has_pending_exception()); | 4807 ASSERT(info()->isolate()->has_pending_exception()); |
| 4808 } else { | 4808 } else { |
| 4809 result = ParseProgram(); | 4809 result = ParseProgram(); |
| 4810 } | 4810 } |
| 4811 } | 4811 } |
| 4812 info()->SetFunction(result); | 4812 info()->SetFunction(result); |
| 4813 return (result != NULL); | 4813 return (result != NULL); |
| 4814 } | 4814 } |
| 4815 | 4815 |
| 4816 } } // namespace v8::internal | 4816 } } // namespace v8::internal |
| OLD | NEW |