5 #ifndef V8_TORQUE_DECLARATION_VISITOR_H_ 6 #define V8_TORQUE_DECLARATION_VISITOR_H_ 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" 24 void Visit(
Ast* ast) {
25 CurrentScope::Scope current_namespace(GlobalContext::GetDefaultNamespace());
26 for (
Declaration* child : ast->declarations()) Visit(child);
31 Namespace* GetOrCreateNamespace(
const std::string& name) {
32 std::vector<Namespace*> existing_namespaces = FilterDeclarables<Namespace>(
34 if (existing_namespaces.empty()) {
35 return Declarations::DeclareNamespace(name);
37 DCHECK_EQ(1, existing_namespaces.size());
38 return existing_namespaces.front();
42 CurrentScope::Scope current_scope(GetOrCreateNamespace(decl->name));
43 for (
Declaration* child : decl->declarations) Visit(child);
49 const Type*
type = Declarations::GetType(decl->type);
50 type->AddAlias(decl->name);
51 Declarations::DeclareType(decl->name,
type,
true);
55 std::string readable_name,
Signature signature,
59 Declarations::Declare(
61 CreateBuiltin(decl, decl->name, decl->name, signature, base::nullopt));
99 #endif // V8_TORQUE_DECLARATION_VISITOR_H_