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

Side by Side Diff: src/variables.cc

Issue 722001: Add IsStackAllocated helper for variables. (Closed)
Patch Set: Created 10 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 Variable* Variable::AsVariable() { 78 Variable* Variable::AsVariable() {
79 return rewrite_ == NULL || rewrite_->AsSlot() != NULL ? this : NULL; 79 return rewrite_ == NULL || rewrite_->AsSlot() != NULL ? this : NULL;
80 } 80 }
81 81
82 82
83 Slot* Variable::slot() const { 83 Slot* Variable::slot() const {
84 return rewrite_ != NULL ? rewrite_->AsSlot() : NULL; 84 return rewrite_ != NULL ? rewrite_->AsSlot() : NULL;
85 } 85 }
86 86
87 87
88 bool Variable::IsStackAllocated() const {
89 Slot* s = slot();
90 return s != NULL && s->IsStackAllocated();
91 }
92
93
88 Variable::Variable(Scope* scope, 94 Variable::Variable(Scope* scope,
89 Handle<String> name, 95 Handle<String> name,
90 Mode mode, 96 Mode mode,
91 bool is_valid_LHS, 97 bool is_valid_LHS,
92 Kind kind) 98 Kind kind)
93 : scope_(scope), 99 : scope_(scope),
94 name_(name), 100 name_(name),
95 mode_(mode), 101 mode_(mode),
96 is_valid_LHS_(is_valid_LHS), 102 is_valid_LHS_(is_valid_LHS),
97 kind_(kind), 103 kind_(kind),
98 local_if_not_shadowed_(NULL), 104 local_if_not_shadowed_(NULL),
99 is_accessed_from_inner_scope_(false), 105 is_accessed_from_inner_scope_(false),
100 is_used_(false), 106 is_used_(false),
101 rewrite_(NULL) { 107 rewrite_(NULL) {
102 // names must be canonicalized for fast equality checks 108 // names must be canonicalized for fast equality checks
103 ASSERT(name->IsSymbol()); 109 ASSERT(name->IsSymbol());
104 } 110 }
105 111
106 112
107 bool Variable::is_global() const { 113 bool Variable::is_global() const {
108 // Temporaries are never global, they must always be allocated in the 114 // Temporaries are never global, they must always be allocated in the
109 // activation frame. 115 // activation frame.
110 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope(); 116 return mode_ != TEMPORARY && scope_ != NULL && scope_->is_global_scope();
111 } 117 }
112 118
113 } } // namespace v8::internal 119 } } // 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