summaryrefslogtreecommitdiff
path: root/node/FunctionNode.cc
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-06-03 02:36:05 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-06-03 02:36:05 +0800
commit2d6ab4b7f207a746a7caaa93466b410cbe328626 (patch)
tree570a2d7776e616309149adf065acc474c0c0de98 /node/FunctionNode.cc
parentcd1466f30c146e12faa0db7e1b53b508bf2274c6 (diff)
support for short, int64 and AST dump
Diffstat (limited to 'node/FunctionNode.cc')
-rw-r--r--node/FunctionNode.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/node/FunctionNode.cc b/node/FunctionNode.cc
index 4fb5138..eaf2a0d 100644
--- a/node/FunctionNode.cc
+++ b/node/FunctionNode.cc
@@ -1,3 +1,4 @@
+#include <iterator>
#include <memory>
#include <vector>
@@ -31,9 +32,10 @@ Value FunctionNode::CodeGen() {
llvm::Module* module = context_->GetModule();
llvm::IRBuilder<>* builder = context_->GetBuilder();
TypeManager* manager = context_->GetTypeManager();
- std::vector<std::shared_ptr<Type>> params(arguments_.size());
+ std::vector<std::shared_ptr<Type>> params;
+ params.reserve(arguments_.size());
std::transform(
- arguments_.cbegin(), arguments_.cend(), params.begin(),
+ arguments_.cbegin(), arguments_.cend(), std::back_inserter(params),
[](const Declaration& decl) { return std::get<1>(decl)->GetType(); });
std::shared_ptr<Type> ReturnType = ReturnTypeIdentifier_->GetType();
std::shared_ptr<FunctionType> type =
@@ -104,9 +106,10 @@ Value ExternNode::CodeGen() {
llvm::Module* module = context_->GetModule();
llvm::IRBuilder<>* builder = context_->GetBuilder();
TypeManager* manager = context_->GetTypeManager();
- std::vector<std::shared_ptr<Type>> params(arguments_.size());
+ std::vector<std::shared_ptr<Type>> params;
+ params.reserve(arguments_.size());
std::transform(
- arguments_.cbegin(), arguments_.cend(), params.begin(),
+ arguments_.cbegin(), arguments_.cend(), std::back_inserter(params),
[](const Declaration& decl) { return std::get<1>(decl)->GetType(); });
std::shared_ptr<Type> ReturnType = ReturnTypeIdentifier_->GetType();
std::shared_ptr<FunctionType> type =