OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Declare an implicit global variable in this scope which must be a | 159 // Declare an implicit global variable in this scope which must be a |
160 // global scope. The variable was introduced (possibly from an inner | 160 // global scope. The variable was introduced (possibly from an inner |
161 // scope) by a reference to an unresolved variable with no intervening | 161 // scope) by a reference to an unresolved variable with no intervening |
162 // with statements or eval calls. | 162 // with statements or eval calls. |
163 Variable* DeclareGlobal(Handle<String> name); | 163 Variable* DeclareGlobal(Handle<String> name); |
164 | 164 |
165 // Create a new unresolved variable. | 165 // Create a new unresolved variable. |
166 template<class Visitor> | 166 template<class Visitor> |
167 VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory, | 167 VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory, |
168 Handle<String> name, | 168 Handle<String> name, |
169 int position = RelocInfo::kNoPosition, | 169 Interface* interface = Interface::NewValue(), |
170 Interface* interface = Interface::NewValue()) { | 170 int position = RelocInfo::kNoPosition) { |
171 // Note that we must not share the unresolved variables with | 171 // Note that we must not share the unresolved variables with |
172 // the same name because they may be removed selectively via | 172 // the same name because they may be removed selectively via |
173 // RemoveUnresolved(). | 173 // RemoveUnresolved(). |
174 ASSERT(!already_resolved()); | 174 ASSERT(!already_resolved()); |
175 VariableProxy* proxy = | 175 VariableProxy* proxy = |
176 factory->NewVariableProxy(name, false, position, interface); | 176 factory->NewVariableProxy(name, false, interface, position); |
177 unresolved_.Add(proxy, zone_); | 177 unresolved_.Add(proxy, zone_); |
178 return proxy; | 178 return proxy; |
179 } | 179 } |
180 | 180 |
181 // Remove a unresolved variable. During parsing, an unresolved variable | 181 // Remove a unresolved variable. During parsing, an unresolved variable |
182 // may have been added optimistically, but then only the variable name | 182 // may have been added optimistically, but then only the variable name |
183 // was used (typically for labels). If the variable was not declared, the | 183 // was used (typically for labels). If the variable was not declared, the |
184 // addition introduced a new unresolved variable which may end up being | 184 // addition introduced a new unresolved variable which may end up being |
185 // allocated globally as a "ghost" variable. RemoveUnresolved removes | 185 // allocated globally as a "ghost" variable. RemoveUnresolved removes |
186 // such a variable again if it was added; otherwise this is a no-op. | 186 // such a variable again if it was added; otherwise this is a no-op. |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 void SetDefaults(ScopeType type, | 616 void SetDefaults(ScopeType type, |
617 Scope* outer_scope, | 617 Scope* outer_scope, |
618 Handle<ScopeInfo> scope_info); | 618 Handle<ScopeInfo> scope_info); |
619 | 619 |
620 Zone* zone_; | 620 Zone* zone_; |
621 }; | 621 }; |
622 | 622 |
623 } } // namespace v8::internal | 623 } } // namespace v8::internal |
624 | 624 |
625 #endif // V8_SCOPES_H_ | 625 #endif // V8_SCOPES_H_ |
OLD | NEW |