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

Side by Side Diff: src/variables.cc

Issue 883823002: Implement proper scoping for "this" in arrow functions Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mjsunit/debug-scopes: Skip "this" the same as "arguments" Created 5 years, 10 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
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, Interface* interface) 37 MaybeAssignedFlag maybe_assigned_flag, Interface* interface)
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 interface_(interface) { 50 interface_(interface) {
53 // Var declared variables never need initialization. 51 // Var declared variables never need initialization.
54 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); 52 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization));
55 } 53 }
56 54
57 55
58 bool Variable::IsGlobalObjectProperty() const { 56 bool Variable::IsGlobalObjectProperty() const {
59 // Temporaries are never global, they must always be allocated in the 57 // Temporaries are never global, they must always be allocated in the
60 // activation frame. 58 // activation frame.
61 return (IsDynamicVariableMode(mode_) || 59 return (IsDynamicVariableMode(mode_) ||
62 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) 60 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)))
63 && scope_ != NULL && scope_->is_script_scope(); 61 && scope_ != NULL && scope_->is_script_scope();
64 } 62 }
65 63
66 64
67 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { 65 int Variable::CompareIndex(Variable* const* v, Variable* const* w) {
68 int x = (*v)->index(); 66 int x = (*v)->index();
69 int y = (*w)->index(); 67 int y = (*w)->index();
70 // Consider sorting them according to type as well? 68 // Consider sorting them according to type as well?
71 return x - y; 69 return x - y;
72 } 70 }
73 71
74 } } // namespace v8::internal 72 } } // namespace v8::internal
OLDNEW
« src/scopes.h ('K') | « src/variables.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698