From d32d92e2410a78181ff6c9c6a7b9e5dd62ac106d Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 12 Jun 2019 20:35:42 -0700 Subject: [PATCH] Fix c++11 compatibility. --- src/gmachine.hpp | 8 ++++---- src/parser.cpp | 6 +++--- src/type.cpp | 2 +- src/type.hpp | 1 + src/type_checker.hpp | 1 + src/type_manager.cpp | 6 +++--- src/type_manager.hpp | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/gmachine.hpp b/src/gmachine.hpp index d702ccc..d172031 100644 --- a/src/gmachine.hpp +++ b/src/gmachine.hpp @@ -15,12 +15,12 @@ namespace lily { struct instruction_slide : instruction { int amount; - + instruction_slide(int a) : amount(a) {} std::ostream& to_stream(std::ostream& os); void gen_llvm(llvm_context& ctx); }; - + struct instruction_alloc : instruction { int amount; @@ -44,7 +44,7 @@ namespace lily { struct instruction_push_global : instruction { std::string name; - + instruction_push_global(std::string n) : name(std::move(n)) {} std::ostream& to_stream(std::ostream& os); void gen_llvm(llvm_context& ctx); @@ -145,7 +145,7 @@ namespace lily { public: template T* add_instruction(Ts ... ts) { - auto new_inst = std::make_unique(ts...); + auto new_inst = std::unique_ptr(new T(ts...)); T* raw = new_inst.get(); instructions.push_back(std::move(new_inst)); return raw; diff --git a/src/parser.cpp b/src/parser.cpp index 6af2e32..e5661ff 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -117,7 +117,7 @@ namespace lily { ast_case* new_case = new ast_case(); ast_ptr case_ptr = ast_ptr(new_case); new_case->of = expr_tree(PGS_TREE_NT_CHILD(*c, 1), source); - + pgs_tree* branches = PGS_TREE_NT_CHILD(*c, 4); while(PGS_TREE_NT_COUNT(*branches) == 2) { pgs_tree* branch = PGS_TREE_NT_CHILD(*branches, 0); @@ -216,7 +216,7 @@ namespace lily { } static program_ptr build_program(pgs_tree* tree, const char* source) { - program_ptr prog = std::make_unique(); + program_ptr prog = std::unique_ptr(new program); pgs_tree* program = PGS_TREE_NT_CHILD(*tree, 0); do { @@ -239,7 +239,7 @@ namespace lily { if((err = pgs_do_all(&state, &into, s.c_str())) != PGS_NONE) { throw error("failed to parse input string"); } - + program_ptr prog = build_program(into, s.c_str()); prog->check(); pgs_free_tree(into); diff --git a/src/type.cpp b/src/type.cpp index 240b121..85a2769 100644 --- a/src/type.cpp +++ b/src/type.cpp @@ -4,7 +4,7 @@ namespace lily { type_data::constructor* type_data::create_constructor(const std::string& name, std::vector&& params) { - auto new_constructor = std::make_unique(); + auto new_constructor = std::unique_ptr(new constructor()); new_constructor->id = constructors.size(); new_constructor->parent = this; new_constructor->params = std::move(params); diff --git a/src/type.hpp b/src/type.hpp index 398d384..3f650a0 100644 --- a/src/type.hpp +++ b/src/type.hpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace lily { enum reserved_types { diff --git a/src/type_checker.hpp b/src/type_checker.hpp index e909b67..f5f36e7 100644 --- a/src/type_checker.hpp +++ b/src/type_checker.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include #include "type.hpp" #include "ast.hpp" diff --git a/src/type_manager.cpp b/src/type_manager.cpp index 7cc7f2d..0decc25 100644 --- a/src/type_manager.cpp +++ b/src/type_manager.cpp @@ -12,7 +12,7 @@ namespace lily { } type_internal* type_manager::create_int_type() { - auto new_type = std::make_unique(next_id++); + auto new_type = std::unique_ptr(new type_internal(next_id++)); type_internal* raw_ptr = new_type.get(); types.push_back(std::move(new_type)); type_names["Int"] = raw_ptr; @@ -20,7 +20,7 @@ namespace lily { } type_internal* type_manager::create_str_type() { - auto new_type = std::make_unique(next_id++); + auto new_type = std::unique_ptr(new type_internal(next_id++)); type_internal* raw_ptr = new_type.get(); types.push_back(std::move(new_type)); type_names["Str"] = raw_ptr; @@ -29,7 +29,7 @@ namespace lily { type_data* type_manager::create_data_type(const std::string& name) { if(type_names.count(name)) throw error("redefinition of type"); - auto new_type = std::make_unique(next_id++); + auto new_type = std::unique_ptr(new type_data(next_id++)); type_data* raw_ptr = new_type.get(); types.push_back(std::move(new_type)); type_names[name] = raw_ptr; diff --git a/src/type_manager.hpp b/src/type_manager.hpp index b861a4b..08a50df 100644 --- a/src/type_manager.hpp +++ b/src/type_manager.hpp @@ -21,7 +21,7 @@ namespace lily { type_data* create_data_type(const std::string& name); template T* create_type(Args...as) { - auto new_type = std::make_unique(as...); + auto new_type = std::unique_ptr(new T(as...)); T* raw_ptr = new_type.get(); types.push_back(std::move(new_type)); return raw_ptr;