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