5 #ifndef V8_TORQUE_TYPE_ORACLE_H_ 6 #define V8_TORQUE_TYPE_ORACLE_H_ 8 #include "src/torque/contextual.h" 9 #include "src/torque/declarable.h" 10 #include "src/torque/declarations.h" 11 #include "src/torque/types.h" 12 #include "src/torque/utils.h" 21 const Type* parent, std::string name,
bool transient,
22 std::string generated,
26 std::move(generated), non_constexpr_version);
27 Get().nominal_types_.push_back(std::unique_ptr<AbstractType>(result));
32 const std::string& name,
const std::vector<NameAndType>& fields) {
34 Get().struct_types_.push_back(std::unique_ptr<StructType>(result));
39 TypeVector argument_types,
const Type* return_type) {
41 const Type* code_type =
self.GetBuiltinType(CODE_TYPE_STRING);
44 self.all_function_pointer_types_.size()));
45 if (result->function_pointer_type_id() ==
46 self.all_function_pointer_types_.size()) {
47 self.all_function_pointer_types_.push_back(result);
52 static const std::vector<const FunctionPointerType*>&
53 AllFunctionPointerTypes() {
54 return Get().all_function_pointer_types_;
61 return Get().union_types_.Add(std::move(
type));
64 static const Type* GetUnionType(
const Type* a,
const Type* b) {
65 if (a->IsSubtypeOf(b))
return b;
66 if (b->IsSubtypeOf(a))
return a;
67 UnionType result = UnionType::FromType(a);
69 return GetUnionType(std::move(result));
72 static const TopType* GetTopType(std::string reason,
73 const Type* source_type) {
75 Get().top_types_.push_back(std::unique_ptr<TopType>(result));
79 static const Type* GetArgumentsType() {
80 return Get().GetBuiltinType(ARGUMENTS_TYPE_STRING);
83 static const Type* GetBoolType() {
84 return Get().GetBuiltinType(BOOL_TYPE_STRING);
87 static const Type* GetConstexprBoolType() {
88 return Get().GetBuiltinType(CONSTEXPR_BOOL_TYPE_STRING);
91 static const Type* GetVoidType() {
92 return Get().GetBuiltinType(VOID_TYPE_STRING);
95 static const Type* GetObjectType() {
96 return Get().GetBuiltinType(OBJECT_TYPE_STRING);
99 static const Type* GetConstStringType() {
100 return Get().GetBuiltinType(CONST_STRING_TYPE_STRING);
103 static const Type* GetIntPtrType() {
104 return Get().GetBuiltinType(INTPTR_TYPE_STRING);
107 static const Type* GetNeverType() {
108 return Get().GetBuiltinType(NEVER_TYPE_STRING);
111 static const Type* GetConstInt31Type() {
112 return Get().GetBuiltinType(CONST_INT31_TYPE_STRING);
115 static bool IsImplicitlyConvertableFrom(
const Type* to,
const Type* from) {
117 Declarations::LookupGeneric(kFromConstexprMacroName)) {
119 from_constexpr->GetSpecialization({to})) {
120 if ((*specialization)->signature().GetExplicitTypes() ==
130 const Type* GetBuiltinType(
const std::string& name) {
131 return Declarations::LookupGlobalType(name);
135 std::vector<const FunctionPointerType*> all_function_pointer_types_;
137 std::vector<std::unique_ptr<Type>> nominal_types_;
138 std::vector<std::unique_ptr<Type>> struct_types_;
139 std::vector<std::unique_ptr<Type>> top_types_;
146 #endif // V8_TORQUE_TYPE_ORACLE_H_