LCOV - code coverage report
Current view: top level - src/torque - declaration-visitor.h (source / functions) Hit Total Coverage
Test: app.info Lines: 21 21 100.0 %
Date: 2019-01-20 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright 2017 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_TORQUE_DECLARATION_VISITOR_H_
       6             : #define V8_TORQUE_DECLARATION_VISITOR_H_
       7             : 
       8             : #include <set>
       9             : #include <string>
      10             : 
      11             : #include "src/base/macros.h"
      12             : #include "src/torque/declarations.h"
      13             : #include "src/torque/file-visitor.h"
      14             : #include "src/torque/global-context.h"
      15             : #include "src/torque/types.h"
      16             : #include "src/torque/utils.h"
      17             : 
      18             : namespace v8 {
      19             : namespace internal {
      20             : namespace torque {
      21             : 
      22             : class DeclarationVisitor : public FileVisitor {
      23             :  public:
      24           1 :   void Visit(Ast* ast) {
      25           1 :     CurrentScope::Scope current_namespace(GlobalContext::GetDefaultNamespace());
      26         672 :     for (Declaration* child : ast->declarations()) Visit(child);
      27           1 :   }
      28             : 
      29             :   void Visit(Declaration* decl);
      30             : 
      31          21 :   Namespace* GetOrCreateNamespace(const std::string& name) {
      32             :     std::vector<Namespace*> existing_namespaces = FilterDeclarables<Namespace>(
      33          63 :         Declarations::TryLookupShallow(QualifiedName(name)));
      34          21 :     if (existing_namespaces.empty()) {
      35           9 :       return Declarations::DeclareNamespace(name);
      36             :     }
      37             :     DCHECK_EQ(1, existing_namespaces.size());
      38          12 :     return existing_namespaces.front();
      39             :   }
      40             : 
      41          21 :   void Visit(NamespaceDeclaration* decl) {
      42          21 :     CurrentScope::Scope current_scope(GetOrCreateNamespace(decl->name));
      43         462 :     for (Declaration* child : decl->declarations) Visit(child);
      44          21 :   }
      45             : 
      46             :   void Visit(TypeDeclaration* decl);
      47             : 
      48             :   void DeclareMethods(AggregateType* container,
      49             :                       const std::vector<Declaration*>& methods);
      50             :   void Visit(StructDeclaration* decl);
      51             :   void Visit(ClassDeclaration* decl);
      52             : 
      53          17 :   void Visit(TypeAliasDeclaration* decl) {
      54          17 :     const Type* type = Declarations::GetType(decl->type);
      55          34 :     type->AddAlias(decl->name);
      56          17 :     Declarations::DeclareType(decl->name, type, true);
      57          17 :   }
      58             : 
      59             :   Builtin* CreateBuiltin(BuiltinDeclaration* decl, std::string external_name,
      60             :                          std::string readable_name, Signature signature,
      61             :                          base::Optional<Statement*> body);
      62          14 :   void Visit(ExternalBuiltinDeclaration* decl, const Signature& signature,
      63             :              base::Optional<Statement*> body) {
      64             :     Declarations::Declare(
      65             :         decl->name,
      66          42 :         CreateBuiltin(decl, decl->name, decl->name, signature, base::nullopt));
      67          14 :   }
      68             : 
      69             :   void Visit(ExternalRuntimeDeclaration* decl, const Signature& sig,
      70             :              base::Optional<Statement*> body);
      71             :   void Visit(ExternalMacroDeclaration* decl, const Signature& sig,
      72             :              base::Optional<Statement*> body);
      73             :   void Visit(TorqueBuiltinDeclaration* decl, const Signature& signature,
      74             :              base::Optional<Statement*> body);
      75             :   void Visit(TorqueMacroDeclaration* decl, const Signature& signature,
      76             :              base::Optional<Statement*> body);
      77             :   void Visit(IntrinsicDeclaration* decl, const Signature& signature,
      78             :              base::Optional<Statement*> body);
      79             : 
      80             :   void Visit(CallableNode* decl, const Signature& signature,
      81             :              base::Optional<Statement*> body);
      82             : 
      83             :   void Visit(ConstDeclaration* decl);
      84             :   void Visit(StandardDeclaration* decl);
      85             :   void Visit(GenericDeclaration* decl);
      86             :   void Visit(SpecializationDeclaration* decl);
      87             :   void Visit(ExternConstDeclaration* decl);
      88             :   void Visit(CppIncludeDeclaration* decl);
      89             : 
      90             :   Signature MakeSpecializedSignature(const SpecializationKey& key);
      91             :   Callable* SpecializeImplicit(const SpecializationKey& key);
      92             :   Callable* Specialize(const SpecializationKey& key, CallableNode* declaration,
      93             :                        base::Optional<const CallableNodeSignature*> signature,
      94             :                        base::Optional<Statement*> body);
      95             : 
      96             :  private:
      97             :   void DeclareSpecializedTypes(const SpecializationKey& key);
      98             : };
      99             : 
     100             : }  // namespace torque
     101             : }  // namespace internal
     102             : }  // namespace v8
     103             : 
     104             : #endif  // V8_TORQUE_DECLARATION_VISITOR_H_

Generated by: LCOV version 1.10