Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/variables.cc

Issue 1024703004: Cleanups needed for this-scoping in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed codegen bits and Scope::has_this_declaration() Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/variables.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/ast.h" 7 #include "src/ast.h"
8 #include "src/scopes.h" 8 #include "src/scopes.h"
9 #include "src/variables.h" 9 #include "src/variables.h"
10 10
(...skipping 15 matching lines...) Expand all
26 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; 26 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL";
27 case INTERNAL: return "INTERNAL"; 27 case INTERNAL: return "INTERNAL";
28 case TEMPORARY: return "TEMPORARY"; 28 case TEMPORARY: return "TEMPORARY";
29 } 29 }
30 UNREACHABLE(); 30 UNREACHABLE();
31 return NULL; 31 return NULL;
32 } 32 }
33 33
34 34
35 Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode, 35 Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode,
36 bool is_valid_ref, Kind kind, 36 Kind kind, InitializationFlag initialization_flag,
37 InitializationFlag initialization_flag,
38 MaybeAssignedFlag maybe_assigned_flag) 37 MaybeAssignedFlag maybe_assigned_flag)
39 : scope_(scope), 38 : scope_(scope),
40 name_(name), 39 name_(name),
41 mode_(mode), 40 mode_(mode),
42 kind_(kind), 41 kind_(kind),
43 location_(UNALLOCATED), 42 location_(UNALLOCATED),
44 index_(-1), 43 index_(-1),
45 initializer_position_(RelocInfo::kNoPosition), 44 initializer_position_(RelocInfo::kNoPosition),
46 local_if_not_shadowed_(NULL), 45 local_if_not_shadowed_(NULL),
47 is_valid_ref_(is_valid_ref),
48 force_context_allocation_(false), 46 force_context_allocation_(false),
49 is_used_(false), 47 is_used_(false),
50 initialization_flag_(initialization_flag), 48 initialization_flag_(initialization_flag),
51 maybe_assigned_(maybe_assigned_flag) { 49 maybe_assigned_(maybe_assigned_flag) {
52 // Var declared variables never need initialization. 50 // Var declared variables never need initialization.
53 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); 51 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization));
54 } 52 }
55 53
56 54
57 bool Variable::IsGlobalObjectProperty() const { 55 bool Variable::IsGlobalObjectProperty() const {
58 // Temporaries are never global, they must always be allocated in the 56 // Temporaries are never global, they must always be allocated in the
59 // activation frame. 57 // activation frame.
60 return (IsDynamicVariableMode(mode_) || 58 return (IsDynamicVariableMode(mode_) ||
61 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) 59 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)))
62 && scope_ != NULL && scope_->is_script_scope(); 60 && scope_ != NULL && scope_->is_script_scope();
63 } 61 }
64 62
65 63
66 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { 64 int Variable::CompareIndex(Variable* const* v, Variable* const* w) {
67 int x = (*v)->index(); 65 int x = (*v)->index();
68 int y = (*w)->index(); 66 int y = (*w)->index();
69 // Consider sorting them according to type as well? 67 // Consider sorting them according to type as well?
70 return x - y; 68 return x - y;
71 } 69 }
72 70
73 } } // namespace v8::internal 71 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/variables.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698