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

Side by Side Diff: src/scopes.cc

Issue 6976025: Simplify the Scope API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Clarify comment. Created 9 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/scopes.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 359 }
360 360
361 361
362 Variable* Scope::DeclareFunctionVar(Handle<String> name) { 362 Variable* Scope::DeclareFunctionVar(Handle<String> name) {
363 ASSERT(is_function_scope() && function_ == NULL); 363 ASSERT(is_function_scope() && function_ == NULL);
364 function_ = new Variable(this, name, Variable::CONST, true, Variable::NORMAL); 364 function_ = new Variable(this, name, Variable::CONST, true, Variable::NORMAL);
365 return function_; 365 return function_;
366 } 366 }
367 367
368 368
369 Variable* Scope::DeclareLocal(Handle<String> name, 369 void Scope::DeclareParameter(Handle<String> name) {
370 Variable::Mode mode,
371 LocalType type) {
372 // DYNAMIC variables are introduces during variable allocation,
373 // INTERNAL variables are allocated explicitly, and TEMPORARY
374 // variables are allocated via NewTemporary().
375 ASSERT(!resolved()); 370 ASSERT(!resolved());
371 ASSERT(is_function_scope());
372 Variable* var =
373 variables_.Declare(this, name, Variable::VAR, true, Variable::NORMAL);
374 params_.Add(var);
375 }
376
377
378 Variable* Scope::DeclareLocal(Handle<String> name, Variable::Mode mode) {
379 ASSERT(!resolved());
380 // This function handles VAR and CONST modes. DYNAMIC variables are
381 // introduces during variable allocation, INTERNAL variables are allocated
382 // explicitly, and TEMPORARY variables are allocated via NewTemporary().
376 ASSERT(mode == Variable::VAR || mode == Variable::CONST); 383 ASSERT(mode == Variable::VAR || mode == Variable::CONST);
377 if (type == VAR_OR_CONST) { 384 ++num_var_or_const_;
378 num_var_or_const_++;
379 }
380 return variables_.Declare(this, name, mode, true, Variable::NORMAL); 385 return variables_.Declare(this, name, mode, true, Variable::NORMAL);
381 } 386 }
382 387
383 388
384 Variable* Scope::DeclareGlobal(Handle<String> name) { 389 Variable* Scope::DeclareGlobal(Handle<String> name) {
385 ASSERT(is_global_scope()); 390 ASSERT(is_global_scope());
386 return variables_.Declare(this, name, Variable::DYNAMIC_GLOBAL, true, 391 return variables_.Declare(this, name, Variable::DYNAMIC_GLOBAL, true,
387 Variable::NORMAL); 392 Variable::NORMAL);
388 } 393 }
389 394
390 395
391 void Scope::AddParameter(Variable* var) {
392 ASSERT(is_function_scope());
393 ASSERT(LocalLookup(var->name()) == var);
394 params_.Add(var);
395 }
396
397
398 VariableProxy* Scope::NewUnresolved(Handle<String> name, 396 VariableProxy* Scope::NewUnresolved(Handle<String> name,
399 bool inside_with, 397 bool inside_with,
400 int position) { 398 int position) {
401 // Note that we must not share the unresolved variables with 399 // Note that we must not share the unresolved variables with
402 // the same name because they may be removed selectively via 400 // the same name because they may be removed selectively via
403 // RemoveUnresolved(). 401 // RemoveUnresolved().
404 ASSERT(!resolved()); 402 ASSERT(!resolved());
405 VariableProxy* proxy = new VariableProxy(name, false, inside_with, position); 403 VariableProxy* proxy = new VariableProxy(name, false, inside_with, position);
406 unresolved_.Add(proxy); 404 unresolved_.Add(proxy);
407 return proxy; 405 return proxy;
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1139 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1142 !must_have_local_context) { 1140 !must_have_local_context) {
1143 num_heap_slots_ = 0; 1141 num_heap_slots_ = 0;
1144 } 1142 }
1145 1143
1146 // Allocation done. 1144 // Allocation done.
1147 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1145 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1148 } 1146 }
1149 1147
1150 } } // namespace v8::internal 1148 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698