summaryrefslogtreecommitdiff
path: root/TypeIdentifier.cc
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-31 13:11:44 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-31 13:11:44 +0800
commit4a5bc55769804d003d6cd9f8c16eefb76bb53d1b (patch)
tree365756351275152391a812440f6a76b9f92cc854 /TypeIdentifier.cc
parentbd44c9eaef1f4dcbbd98d4489885566b6c7e5138 (diff)
full support of array, pointer and record stuffs
Diffstat (limited to 'TypeIdentifier.cc')
-rw-r--r--TypeIdentifier.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/TypeIdentifier.cc b/TypeIdentifier.cc
index 8f6894b..3a249da 100644
--- a/TypeIdentifier.cc
+++ b/TypeIdentifier.cc
@@ -54,4 +54,23 @@ std::shared_ptr<Type> ArrayTypeIdentifier::GetType() {
}
return type_;
}
-} // namespace pcc \ No newline at end of file
+
+RecordTypeIdentifier::RecordTypeIdentifier(Context* context,
+ std::list<Declaration>&& members)
+ : TypeIdentifier(context)
+ , members_(std::move(members)) {}
+
+std::shared_ptr<Type> RecordTypeIdentifier::GetType() {
+ if (type_ == nullptr) {
+ std::vector<RecordMember> MemberTypes(members_.size());
+ std::transform(members_.cbegin(), members_.cend(), MemberTypes.begin(),
+ [](const Declaration& member) {
+ return std::make_pair(
+ std::get<0>(member),
+ std::get<1>(member)->GetType());
+ });
+ type_ = context_->GetTypeManager()->CreateRecordType(MemberTypes);
+ }
+ return type_;
+}
+} // namespace pcc