blob: 88ba228635099c6773aecea77104e4c08de49b3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fstream>
#include <iostream>
#include "src/torque/declarable.h"
namespace v8 {
namespace internal {
namespace torque {
bool Type::IsSubtypeOf(const Type* supertype) const {
const Type* subtype = this;
while (subtype != nullptr) {
if (subtype == supertype) return true;
subtype = subtype->parent();
}
return false;
}
bool Type::IsAbstractName(const std::string& name) const {
if (!IsAbstractType()) return false;
return AbstractType::cast(this)->name() == name;
}
std::string AbstractType::GetGeneratedTNodeTypeName() const {
std::string result = GetGeneratedTypeName();
DCHECK_EQ(result.substr(0, 6), "TNode<");
result = result.substr(6, result.length() - 7);
return result;
}
std::string FunctionPointerType::ToString() const {
std::stringstream result;
result << "builtin (";
bool first = true;
for (const Type* t : parameter_types_) {
if (!first) {
result << ", ";
first = false;
}
result << t;
}
result << ") => " << return_type_;
return result.str();
}
std::string FunctionPointerType::MangledName() const {
std::stringstream result;
result << "FT";
bool first = true;
for (const Type* t : parameter_types_) {
if (!first) {
result << ", ";
first = false;
}
std::string arg_type_string = t->MangledName();
result << arg_type_string.size() << arg_type_string;
}
std::string return_type_string = return_type_->MangledName();
result << return_type_string.size() << return_type_string;
return result.str();
}
} // namespace torque
} // namespace internal
} // namespace v8
|