summaryrefslogtreecommitdiff
path: root/Type.cc
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-31 17:49:34 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-31 17:49:34 +0800
commitc2c6e5c7e620c32e7f420e8b9ac21df8855b444c (patch)
treec790ec3650c2f6caed9b59b304bc6a8bbdef1da8 /Type.cc
parent4a5bc55769804d003d6cd9f8c16eefb76bb53d1b (diff)
support for extern functions
Diffstat (limited to 'Type.cc')
-rw-r--r--Type.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/Type.cc b/Type.cc
index 7ad0352..6167175 100644
--- a/Type.cc
+++ b/Type.cc
@@ -334,16 +334,17 @@ Value PointerType::CreatePointerSub(Value v0, Value v1, Context* context) {
FunctionType::FunctionType(std::shared_ptr<Type> ReturnType,
std::vector<std::shared_ptr<Type>> ArgTypes,
- std::string&& name)
+ std::string&& name, bool IsVariadic)
: Type(std::move(name), nullptr)
, ReturnType_(ReturnType)
- , ArgTypes_(ArgTypes) {
+ , ArgTypes_(ArgTypes)
+ , IsVariadic_(IsVariadic) {
std::vector<llvm::Type*> params(ArgTypes_.size());
std::transform(
ArgTypes_.cbegin(), ArgTypes_.cend(), params.begin(),
[](std::shared_ptr<Type> decl) { return decl->GetLLVMType(); });
- LLVMType_ =
- llvm::FunctionType::get(ReturnType_->GetLLVMType(), params, false);
+ LLVMType_ = llvm::FunctionType::get(ReturnType_->GetLLVMType(), params,
+ IsVariadic_);
}
std::shared_ptr<Type> FunctionType::GetReturnType() { return ReturnType_; }
@@ -352,6 +353,8 @@ std::vector<std::shared_ptr<Type>> FunctionType::GetArgTypes() {
return ArgTypes_;
}
+bool FunctionType::IsVariadic() { return IsVariadic_; }
+
RecordType::RecordType(const std::vector<RecordMember>& members,
std::string&& name)
: Type(std::move(name), nullptr) {