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

Side by Side Diff: src/variables.cc

Issue 345573002: Infer whether a variable is assigned (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A few more tests Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/variables.h ('k') | test/cctest/test-parsing.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 name_(name), 43 name_(name),
44 mode_(mode), 44 mode_(mode),
45 kind_(kind), 45 kind_(kind),
46 location_(UNALLOCATED), 46 location_(UNALLOCATED),
47 index_(-1), 47 index_(-1),
48 initializer_position_(RelocInfo::kNoPosition), 48 initializer_position_(RelocInfo::kNoPosition),
49 local_if_not_shadowed_(NULL), 49 local_if_not_shadowed_(NULL),
50 is_valid_ref_(is_valid_ref), 50 is_valid_ref_(is_valid_ref),
51 force_context_allocation_(false), 51 force_context_allocation_(false),
52 is_used_(false), 52 is_used_(false),
53 maybe_assigned_(false),
53 initialization_flag_(initialization_flag), 54 initialization_flag_(initialization_flag),
54 interface_(interface) { 55 interface_(interface) {
55 // Names must be canonicalized for fast equality checks. 56 // Names must be canonicalized for fast equality checks.
56 ASSERT(name->IsInternalizedString()); 57 ASSERT(name->IsInternalizedString());
57 // Var declared variables never need initialization. 58 // Var declared variables never need initialization.
58 ASSERT(!(mode == VAR && initialization_flag == kNeedsInitialization)); 59 ASSERT(!(mode == VAR && initialization_flag == kNeedsInitialization));
59 } 60 }
60 61
61 62
62 bool Variable::IsGlobalObjectProperty() const { 63 bool Variable::IsGlobalObjectProperty() const {
63 // Temporaries are never global, they must always be allocated in the 64 // Temporaries are never global, they must always be allocated in the
64 // activation frame. 65 // activation frame.
65 return (IsDynamicVariableMode(mode_) || 66 return (IsDynamicVariableMode(mode_) ||
66 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_))) 67 (IsDeclaredVariableMode(mode_) && !IsLexicalVariableMode(mode_)))
67 && scope_ != NULL && scope_->is_global_scope(); 68 && scope_ != NULL && scope_->is_global_scope();
68 } 69 }
69 70
70 71
71 int Variable::CompareIndex(Variable* const* v, Variable* const* w) { 72 int Variable::CompareIndex(Variable* const* v, Variable* const* w) {
72 int x = (*v)->index(); 73 int x = (*v)->index();
73 int y = (*w)->index(); 74 int y = (*w)->index();
74 // Consider sorting them according to type as well? 75 // Consider sorting them according to type as well?
75 return x - y; 76 return x - y;
76 } 77 }
77 78
78 } } // namespace v8::internal 79 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/variables.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698