5 #ifndef V8_TORQUE_DECLARATIONS_H_ 6 #define V8_TORQUE_DECLARATIONS_H_ 10 #include "src/torque/declarable.h" 11 #include "src/torque/utils.h" 17 static constexpr
const char*
const kFromConstexprMacroName =
"FromConstexpr";
18 static constexpr
const char* kTrueLabelName =
"_True";
19 static constexpr
const char* kFalseLabelName =
"_False";
22 std::vector<T*> FilterDeclarables(
const std::vector<Declarable*> list) {
23 std::vector<T*> result;
24 for (Declarable* declarable : list) {
25 if (T* t = T::DynamicCast(declarable)) {
34 static std::vector<Declarable*> TryLookup(
const QualifiedName& name) {
35 return CurrentScope::Get()->Lookup(name);
38 static std::vector<Declarable*> TryLookupShallow(
const QualifiedName& name) {
39 return CurrentScope::Get()->LookupShallow(name);
44 return FilterDeclarables<T>(TryLookup(name));
47 static std::vector<Declarable*> Lookup(
const QualifiedName& name) {
48 std::vector<Declarable*> d = TryLookup(name);
51 s <<
"cannot find \"" << name <<
"\"";
57 static std::vector<Declarable*> LookupGlobalScope(
const std::string& name);
60 static const Type* LookupType(std::string name);
61 static const Type* LookupGlobalType(
const std::string& name);
64 static Builtin* FindSomeInternalBuiltinWithType(
69 static Macro* TryLookupMacro(
const std::string& name,
70 const TypeVector& types);
73 static std::vector<Generic*> LookupGeneric(
const std::string& name);
76 static Namespace* DeclareNamespace(
const std::string& name);
79 const std::string& name,
bool transient,
const std::string& generated,
83 static void DeclareType(
const std::string& name,
const Type*
type,
86 static void DeclareStruct(
const std::string& name,
87 const std::vector<NameAndType>& fields);
89 static Macro* CreateMacro(std::string external_name,
90 std::string readable_name,
94 static Macro* DeclareMacro(
95 const std::string& name,
97 const Signature& signature,
bool transitioning,
100 static Intrinsic* CreateIntrinsic(
const std::string& name,
103 static Intrinsic* DeclareIntrinsic(
const std::string& name,
106 static Builtin* CreateBuiltin(std::string external_name,
107 std::string readable_name, Builtin::Kind kind,
110 static Builtin* DeclareBuiltin(
const std::string& name, Builtin::Kind kind,
111 const Signature& signature,
bool transitioning,
114 static RuntimeFunction* DeclareRuntimeFunction(
const std::string& name,
118 static void DeclareExternConstant(
const std::string& name,
const Type*
type,
124 static Generic* DeclareGeneric(
const std::string& name,
128 static T* Declare(
const std::string& name,
T* d) {
129 CurrentScope::Get()->AddDeclarable(name, d);
133 static T* Declare(
const std::string& name, std::unique_ptr<T> d) {
134 return CurrentScope::Get()->AddDeclarable(name,
135 RegisterDeclarable(std::move(d)));
138 static std::string GetGeneratedCallableName(
139 const std::string& name,
const TypeVector& specialized_types);
146 #endif // V8_TORQUE_DECLARATIONS_H_