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

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: Rebased against master, plus fixes. Only 4 tests failing (+2 in TurboFan) 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
« no previous file with comments | « src/variables.h ('k') | src/x64/full-codegen-x64.cc » ('j') | 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 14 matching lines...) Expand all
25 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL"; 25 case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL";
26 case INTERNAL: return "INTERNAL"; 26 case INTERNAL: return "INTERNAL";
27 case TEMPORARY: return "TEMPORARY"; 27 case TEMPORARY: return "TEMPORARY";
28 } 28 }
29 UNREACHABLE(); 29 UNREACHABLE();
30 return NULL; 30 return NULL;
31 } 31 }
32 32
33 33
34 Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode, 34 Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode,
35 bool is_valid_ref, Kind kind, 35 Kind kind, InitializationFlag initialization_flag,
36 InitializationFlag initialization_flag,
37 MaybeAssignedFlag maybe_assigned_flag) 36 MaybeAssignedFlag maybe_assigned_flag)
38 : scope_(scope), 37 : scope_(scope),
39 name_(name), 38 name_(name),
40 mode_(mode), 39 mode_(mode),
41 kind_(kind), 40 kind_(kind),
42 location_(UNALLOCATED), 41 location_(UNALLOCATED),
43 index_(-1), 42 index_(-1),
44 initializer_position_(RelocInfo::kNoPosition), 43 initializer_position_(RelocInfo::kNoPosition),
45 local_if_not_shadowed_(NULL), 44 local_if_not_shadowed_(NULL),
46 is_valid_ref_(is_valid_ref),
47 force_context_allocation_(false), 45 force_context_allocation_(false),
48 is_used_(false), 46 is_used_(false),
49 initialization_flag_(initialization_flag), 47 initialization_flag_(initialization_flag),
50 maybe_assigned_(maybe_assigned_flag) { 48 maybe_assigned_(maybe_assigned_flag) {
51 // Var declared variables never need initialization. 49 // Var declared variables never need initialization.
52 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); 50 DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization));
53 } 51 }
54 52
55 53
56 bool Variable::IsGlobalObjectProperty() const { 54 bool Variable::IsGlobalObjectProperty() const {
57 // Temporaries are never global, they must always be allocated in the 55 // Temporaries are never global, they must always be allocated in the
58 // activation frame. 56 // activation frame.
59 return (IsDynamicVariableMode(mode_) || 57 return (IsDynamicVariableMode(mode_) ||
60 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) 58 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)))
61 && scope_ != NULL && scope_->is_script_scope(); 59 && scope_ != NULL && scope_->is_script_scope();
62 } 60 }
63 61
64 62
65 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { 63 int Variable::CompareIndex(Variable* const* v, Variable* const* w) {
66 int x = (*v)->index(); 64 int x = (*v)->index();
67 int y = (*w)->index(); 65 int y = (*w)->index();
68 // Consider sorting them according to type as well? 66 // Consider sorting them according to type as well?
69 return x - y; 67 return x - y;
70 } 68 }
71 69
72 } } // namespace v8::internal 70 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « 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