v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
type-visitor.h
Go to the documentation of this file.
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_TYPE_VISITOR_H_
6#define V8_TORQUE_TYPE_VISITOR_H_
7
8#include <optional>
9
10#include "src/torque/ast.h"
11#include "src/torque/types.h"
12
13namespace v8::internal::torque {
14
15class Scope;
16
18 public:
19 static TypeVector ComputeTypeVector(const std::vector<TypeExpression*>& v) {
21 for (TypeExpression* t : v) {
22 result.push_back(ComputeType(t));
23 }
24 return result;
25 }
26
27 static const Type* ComputeType(TypeExpression* type_expression);
29 ClassType* class_type, const ClassDeclaration* class_declaration);
30 static void VisitStructMethods(StructType* struct_type,
31 const StructDeclaration* struct_declaration);
33 // Can return either StructType or BitFieldStructType, since they can both be
34 // used in struct expressions like `MyStruct{ a: 0, b: foo }`
36 TypeExpression* type_expression,
37 const std::vector<const Type*>& term_argument_types);
38
39 private:
40 friend class TypeAlias;
41 friend class TypeOracle;
42 static const Type* ComputeType(
43 TypeDeclaration* decl,
44 MaybeSpecializationKey specialized_from = std::nullopt,
45 Scope* specialization_requester = nullptr);
46 static const AbstractType* ComputeType(
47 AbstractTypeDeclaration* decl, MaybeSpecializationKey specialized_from);
48 static const Type* ComputeType(TypeAliasDeclaration* decl,
49 MaybeSpecializationKey specialized_from);
50 static const BitFieldStructType* ComputeType(
52 static const StructType* ComputeType(StructDeclaration* decl,
53 MaybeSpecializationKey specialized_from);
54 static const ClassType* ComputeType(ClassDeclaration* decl,
55 MaybeSpecializationKey specialized_from);
56};
57
58} // namespace v8::internal::torque
59
60#endif // V8_TORQUE_TYPE_VISITOR_H_
static TypeVector ComputeTypeVector(const std::vector< TypeExpression * > &v)
static void VisitStructMethods(StructType *struct_type, const StructDeclaration *struct_declaration)
static const Type * ComputeType(TypeExpression *type_expression)
static Signature MakeSignature(const CallableDeclaration *declaration)
static const Type * ComputeTypeForStructExpression(TypeExpression *type_expression, const std::vector< const Type * > &term_argument_types)
static void VisitClassFieldsAndMethods(ClassType *class_type, const ClassDeclaration *class_declaration)
ZoneVector< RpoNumber > & result
std::optional< SpecializationKey< GenericType > > MaybeSpecializationKey
Definition types.h:93
std::vector< const Type * > TypeVector
Definition types.h:85
Symbol declaration