| 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/base/platform/platform.h" |     9 #include "src/base/platform/platform.h" | 
|    10 #include "src/bootstrapper.h" |    10 #include "src/bootstrapper.h" | 
| (...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2179         StrictMode strict_mode = initialization_scope->strict_mode(); |  2179         StrictMode strict_mode = initialization_scope->strict_mode(); | 
|  2180         arguments->Add(factory()->NewNumberLiteral(strict_mode, pos), zone()); |  2180         arguments->Add(factory()->NewNumberLiteral(strict_mode, pos), zone()); | 
|  2181  |  2181  | 
|  2182         // Be careful not to assign a value to the global variable if |  2182         // Be careful not to assign a value to the global variable if | 
|  2183         // we're in a with. The initialization value should not |  2183         // we're in a with. The initialization value should not | 
|  2184         // necessarily be stored in the global object in that case, |  2184         // necessarily be stored in the global object in that case, | 
|  2185         // which is why we need to generate a separate assignment node. |  2185         // which is why we need to generate a separate assignment node. | 
|  2186         if (value != NULL && !inside_with()) { |  2186         if (value != NULL && !inside_with()) { | 
|  2187           arguments->Add(value, zone()); |  2187           arguments->Add(value, zone()); | 
|  2188           value = NULL;  // zap the value to avoid the unnecessary assignment |  2188           value = NULL;  // zap the value to avoid the unnecessary assignment | 
 |  2189           // Construct the call to Runtime_InitializeVarGlobal | 
 |  2190           // and add it to the initialization statement block. | 
 |  2191           initialize = factory()->NewCallRuntime( | 
 |  2192               ast_value_factory_->initialize_var_global_string(), | 
 |  2193               Runtime::FunctionForId(Runtime::kInitializeVarGlobal), arguments, | 
 |  2194               pos); | 
 |  2195         } else { | 
 |  2196           initialize = NULL; | 
|  2189         } |  2197         } | 
|  2190  |  | 
|  2191         // Construct the call to Runtime_InitializeVarGlobal |  | 
|  2192         // and add it to the initialization statement block. |  | 
|  2193         // Note that the function does different things depending on |  | 
|  2194         // the number of arguments (2 or 3). |  | 
|  2195         initialize = factory()->NewCallRuntime( |  | 
|  2196             ast_value_factory_->initialize_var_global_string(), |  | 
|  2197             Runtime::FunctionForId(Runtime::kInitializeVarGlobal), |  | 
|  2198             arguments, pos); |  | 
|  2199       } |  2198       } | 
|  2200  |  2199  | 
|  2201       block->AddStatement( |  2200       if (initialize != NULL) { | 
|  2202           factory()->NewExpressionStatement(initialize, RelocInfo::kNoPosition), |  2201         block->AddStatement(factory()->NewExpressionStatement( | 
|  2203           zone()); |  2202                                 initialize, RelocInfo::kNoPosition), | 
 |  2203                             zone()); | 
 |  2204       } | 
|  2204     } else if (needs_init) { |  2205     } else if (needs_init) { | 
|  2205       // Constant initializations always assign to the declared constant which |  2206       // Constant initializations always assign to the declared constant which | 
|  2206       // is always at the function scope level. This is only relevant for |  2207       // is always at the function scope level. This is only relevant for | 
|  2207       // dynamically looked-up variables and constants (the start context for |  2208       // dynamically looked-up variables and constants (the start context for | 
|  2208       // constant lookups is always the function context, while it is the top |  2209       // constant lookups is always the function context, while it is the top | 
|  2209       // context for var declared variables). Sigh... |  2210       // context for var declared variables). Sigh... | 
|  2210       // For 'let' and 'const' declared variables in harmony mode the |  2211       // For 'let' and 'const' declared variables in harmony mode the | 
|  2211       // initialization also always assigns to the declared variable. |  2212       // initialization also always assigns to the declared variable. | 
|  2212       ASSERT(proxy != NULL); |  2213       ASSERT(proxy != NULL); | 
|  2213       ASSERT(proxy->var() != NULL); |  2214       ASSERT(proxy->var() != NULL); | 
| (...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4791     info()->SetAstValueFactory(ast_value_factory_); |  4792     info()->SetAstValueFactory(ast_value_factory_); | 
|  4792   } |  4793   } | 
|  4793   ast_value_factory_ = NULL; |  4794   ast_value_factory_ = NULL; | 
|  4794  |  4795  | 
|  4795   InternalizeUseCounts(); |  4796   InternalizeUseCounts(); | 
|  4796  |  4797  | 
|  4797   return (result != NULL); |  4798   return (result != NULL); | 
|  4798 } |  4799 } | 
|  4799  |  4800  | 
|  4800 } }  // namespace v8::internal |  4801 } }  // namespace v8::internal | 
| OLD | NEW |