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

Side by Side Diff: tools/gn/functions.h

Issue 2630983002: Reland "Change GN to disallow reading args defined in the same..." (Closed)
Patch Set: Created 3 years, 11 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 | « tools/gn/docs/reference.md ('k') | tools/gn/functions.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium 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 #ifndef TOOLS_GN_FUNCTIONS_H_ 5 #ifndef TOOLS_GN_FUNCTIONS_H_
6 #define TOOLS_GN_FUNCTIONS_H_ 6 #define TOOLS_GN_FUNCTIONS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 Value RunFunction(Scope* scope, 408 Value RunFunction(Scope* scope,
409 const FunctionCallNode* function, 409 const FunctionCallNode* function,
410 const ListNode* args_list, 410 const ListNode* args_list,
411 BlockNode* block, // Optional. 411 BlockNode* block, // Optional.
412 Err* err); 412 Err* err);
413 413
414 } // namespace functions 414 } // namespace functions
415 415
416 // Helper functions ----------------------------------------------------------- 416 // Helper functions -----------------------------------------------------------
417 417
418 // Validates that the scope that a value is defined in is not the scope
419 // of the current declare_args() call, if that's what we're in. It is
420 // illegal to read a value from inside the same declare_args() call, since
421 // the overrides will not have been applied yet (see `gn help declare_args`
422 // for more).
423 bool EnsureNotReadingFromSameDeclareArgs(const ParseNode* node,
424 const Scope* cur_scope,
425 const Scope* val_scope,
426 Err* err);
427
418 // Verifies that the current scope is not processing an import. If it is, it 428 // Verifies that the current scope is not processing an import. If it is, it
419 // will set the error, blame the given parse node for it, and return false. 429 // will set the error, blame the given parse node for it, and return false.
420 bool EnsureNotProcessingImport(const ParseNode* node, 430 bool EnsureNotProcessingImport(const ParseNode* node,
421 const Scope* scope, 431 const Scope* scope,
422 Err* err); 432 Err* err);
423 433
424 // Like EnsureNotProcessingImport but checks for running the build config. 434 // Like EnsureNotProcessingImport but checks for running the build config.
425 bool EnsureNotProcessingBuildConfig(const ParseNode* node, 435 bool EnsureNotProcessingBuildConfig(const ParseNode* node,
426 const Scope* scope, 436 const Scope* scope,
427 Err* err); 437 Err* err);
(...skipping 28 matching lines...) Expand all
456 466
457 // Returns the name of the toolchain for the given scope. 467 // Returns the name of the toolchain for the given scope.
458 const Label& ToolchainLabelForScope(const Scope* scope); 468 const Label& ToolchainLabelForScope(const Scope* scope);
459 469
460 // Generates a label for the given scope, using the current directory and 470 // Generates a label for the given scope, using the current directory and
461 // toolchain, and the given name. 471 // toolchain, and the given name.
462 Label MakeLabelForScope(const Scope* scope, 472 Label MakeLabelForScope(const Scope* scope,
463 const FunctionCallNode* function, 473 const FunctionCallNode* function,
464 const std::string& name); 474 const std::string& name);
465 475
466 // Some tyesp of blocks can't be nested inside other ones. For such cases, 476 // Some types of blocks can't be nested inside other ones. For such cases,
467 // instantiate this object upon entering the block and Enter() will fail if 477 // instantiate this object upon entering the block and Enter() will fail if
468 // there is already another non-nestable block on the stack. 478 // there is already another non-nestable block on the stack.
469 class NonNestableBlock { 479 class NonNestableBlock {
470 public: 480 public:
471 // type_description is a string that will be used in error messages 481 // type_description is a string that will be used in error messages
472 // describing the type of the block, for example, "template" or "config". 482 // describing the type of the block, for example, "template" or "config".
473 NonNestableBlock(Scope* scope, 483 NonNestableBlock(Scope* scope,
474 const FunctionCallNode* function, 484 const FunctionCallNode* function,
475 const char* type_description); 485 const char* type_description);
476 ~NonNestableBlock(); 486 ~NonNestableBlock();
477 487
478 bool Enter(Err* err); 488 bool Enter(Err* err);
479 489
480 private: 490 private:
481 // Used as a void* key for the Scope to track our property. The actual value 491 // Used as a void* key for the Scope to track our property. The actual value
482 // is never used. 492 // is never used.
483 static const int kKey; 493 static const int kKey;
484 494
485 Scope* scope_; 495 Scope* scope_;
486 const FunctionCallNode* function_; 496 const FunctionCallNode* function_;
487 const char* type_description_; 497 const char* type_description_;
488 498
489 // Set to true when the key is added to the scope so we don't try to 499 // Set to true when the key is added to the scope so we don't try to
490 // delete nonexistant keys which will cause assertions. 500 // delete nonexistant keys which will cause assertions.
491 bool key_added_; 501 bool key_added_;
492 }; 502 };
493 503
494 #endif // TOOLS_GN_FUNCTIONS_H_ 504 #endif // TOOLS_GN_FUNCTIONS_H_
OLDNEW
« no previous file with comments | « tools/gn/docs/reference.md ('k') | tools/gn/functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698