Skip to content

Commit 764513c

Browse files
committed
Fix broken compile
1 parent 8b49083 commit 764513c

11 files changed

+2861
-19
lines changed

CMakeLists.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
cmake_minimum_required(VERSION 3.4.3)
22
project(RTBasic)
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
77

8-
find_package(LLVM REQUIRED CONFIG)
8+
find_package(LLVM REQUIRED CONFIG
9+
PATHS ${search_paths}
10+
NO_DEFAULT_PATH)
911

1012
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
1113
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
@@ -27,7 +29,7 @@ add_executable(rtbasic
2729

2830
# Find the libraries that correspond to the LLVM components
2931
# that we wish to use
30-
llvm_map_components_to_libnames(llvm_libs all)
32+
llvm_map_components_to_libnames(llvm_libs core support codegen)
3133

3234
# Link against LLVM libraries
33-
target_link_libraries(rtbasic LLVM-5.0)
35+
target_link_libraries(rtbasic LLVM)

LICENSE-third-party

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
License for https://github.com/mpark/variant:
2+
3+
Boost Software License - Version 1.0 - August 17th, 2003
4+
5+
Permission is hereby granted, free of charge, to any person or organization
6+
obtaining a copy of the software and accompanying documentation covered by
7+
this license (the "Software") to use, reproduce, display, distribute,
8+
execute, and transmit the Software, and to prepare derivative works of the
9+
Software, and to permit third-parties to whom the Software is furnished to
10+
do so, all subject to the following:
11+
12+
The copyright notices in the Software and this entire statement, including
13+
the above license grant, this restriction and the following disclaimer,
14+
must be included in all copies of the Software, in whole or in part, and
15+
all derivative works of the Software, unless such copies or derivative
16+
works are solely in the form of machine-executable object code generated by
17+
a source language processor.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.

ast.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <list>
55
#include <sstream>
66

7-
#include "boost/optional.hpp"
7+
#include <optional>
88

99
#include "ast.h"
1010
#include "controlflow.h"
@@ -244,7 +244,7 @@ struct OperatorInfo {
244244

245245
OperatorInfo(int p) : precedence(p), associativity(Left) {}
246246

247-
using Handle = boost::optional<const OperatorInfo&>;
247+
using Handle = std::optional<OperatorInfo>;
248248
static Handle get(const Token& tok);
249249
};
250250

@@ -258,7 +258,7 @@ OperatorInfo::Handle OperatorInfo::get(const Token& tok) {
258258
};
259259
auto it = operators.find(tok.tag);
260260
if (it == operators.end())
261-
return boost::none;
261+
return std::nullopt;
262262
return it->second;
263263
}
264264

codegen.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ llvm::Value* BlockAST::codegen() {
104104

105105
llvm::Value* NumberExprAST::codegen() {
106106
if (token().tag == Token::Double) {
107-
return ctx()->makeLiteralDouble(boost::get<double>(token().value));
107+
return ctx()->makeLiteralDouble(mpark::get<double>(*token().value));
108108
} else if (token().tag == Token::Integer) {
109-
return ctx()->makeLiteralInteger(boost::get<int64_t>(token().value));
109+
return ctx()->makeLiteralInteger(mpark::get<int64_t>(*token().value));
110110
} else {
111111
std::cerr << "Invalid token for number expr" << std::endl;
112112
return nullptr;

controlflow.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ std::string lexString(Lexer* lexer) {
1313
gotoName = labelTok.strValue;
1414
} else if (labelTok.tag == Token::Double) {
1515
std::stringstream ss;
16-
ss << boost::get<double>(labelTok.value);
16+
ss << mpark::get<double>(*labelTok.value);
1717
gotoName = ss.str();
1818
} else if (labelTok.tag == Token::Integer) {
1919
std::stringstream ss;
20-
ss << boost::get<int64_t>(labelTok.value);
20+
ss << mpark::get<int64_t>(*labelTok.value);
2121
gotoName = ss.str();
2222
}
2323
return gotoName;

lexer.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,16 @@ const CharToTagMap& charToTagMap() {
6161
std::ostream& operator<<(std::ostream& stream, const Token& tok) {
6262
if (!tok.strValue.empty()) {
6363
stream << "Tag: " << tok.tag << " value: \"" << tok.strValue << "\"";
64-
} else if (tok.value.empty()) {
64+
} else if (!tok.value.has_value()) {
6565
stream << "Tag: " << tok.tag;
6666
if (tok.tag == Token::Eof) {
6767
stream << " value: Eof";
6868
} else if (tok.tag == Token::Newline) {
6969
stream << " value: Newline";
7070
}
7171
} else {
72-
stream << "Tag: " << tok.tag << " value: " << tok.value;
72+
stream << "Tag: " << tok.tag << " value: ";
73+
mpark::visit([&](const auto val) { stream << val; }, *tok.value);
7374
}
7475

7576
auto prefix = tok.line->substr(0, tok.startPos);

lexer.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#pragma once
22

3-
#include <boost/variant.hpp>
3+
#include "variant.hpp"
44
#include <deque>
55
#include <istream>
6+
#include <optional>
67
#include <ostream>
78
#include <string>
89

@@ -97,8 +98,8 @@ struct Token {
9798
}
9899

99100
Tag tag = MaxTag;
100-
using NumValue = boost::variant<int64_t, double, char>;
101-
NumValue value;
101+
using NumValue = mpark::variant<int64_t, double, char>;
102+
std::optional<NumValue> value;
102103
std::string strValue;
103104

104105
std::shared_ptr<std::string> line;

main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int main(int argc, char** argv) {
125125
return 0;
126126
}
127127

128-
if (target->addPassesToEmitFile(passManager, *output, fileType)) {
128+
if (target->addPassesToEmitFile(passManager, *output, nullptr, fileType)) {
129129
std::cerr << "Cannot emit file of this type" << std::endl;
130130
return 1;
131131
}

variables.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ std::unique_ptr<ExprAST> DimAST::parse(const Token& tok, BasicContext* ctx) {
162162
if (tok.tag != Token::Integer) {
163163
throw ParseException(tok, "Expected integer list for array dimensions");
164164
}
165-
return boost::get<int64_t>(tok.value);
165+
return mpark::get<int64_t>(*tok.value);
166166
});
167167

168168
// Consume the RParens

variables.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class ArgumentAST : public VariableDeclartionAST {
146146
bool isGlobal() const override {
147147
return _isGlobal;
148148
}
149-
llvm::Type* nativeType() const;
149+
llvm::Type* nativeType() const override;
150150

151151
private:
152152
VariableType _parseType(const Token& name) {

0 commit comments

Comments
 (0)