Reformat files with the new clang-format config
This commit is contained in:
parent
65b6aa4020
commit
782c786baf
|
@ -10,4 +10,9 @@ AllowShortLoopsOnASingleLine: false
|
|||
AlignConsecutiveMacros: true
|
||||
ForEachMacros: []
|
||||
IndentWidth: 2
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
AlignConsecutiveBitFields: Consecutive
|
||||
AlignEscapedNewlines: Left
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
IncludeBlocks: Regroup
|
||||
...
|
||||
|
|
|
@ -23,12 +23,14 @@
|
|||
*/
|
||||
|
||||
#include "serene/serene.h"
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/namespace.h"
|
||||
#include "serene/reader/reader.h"
|
||||
#include "serene/reader/semantics.h"
|
||||
#include "serene/slir/generatable.h"
|
||||
#include "serene/slir/slir.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <llvm/Support/CommandLine.h>
|
||||
|
||||
|
@ -77,8 +79,8 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
auto &ast = maybeAst.getValue();
|
||||
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto afterAst = reader::analyze(*ctx, ast);
|
||||
|
||||
if (afterAst) {
|
||||
|
@ -106,7 +108,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
auto ctx = makeSereneContext();
|
||||
applyPassManagerCLOptions(ctx->pm);
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto afterAst = reader::analyze(*ctx, ast);
|
||||
|
||||
if (afterAst) {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "serene/namespace.h"
|
||||
#include "serene/passes/slir_lowering.h"
|
||||
#include "serene/slir/dialect.h"
|
||||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <memory>
|
||||
#include <mlir/IR/MLIRContext.h>
|
||||
|
|
|
@ -27,11 +27,13 @@
|
|||
|
||||
#include "mlir/Support/LogicalResult.h"
|
||||
#include "serene/llvm/patches.h"
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
|
||||
namespace serene {
|
||||
|
||||
template <typename K, typename V> class Environment {
|
||||
template <typename K, typename V>
|
||||
class Environment {
|
||||
Environment<K, V> *parent;
|
||||
llvm::DenseMap<K, V> pairs;
|
||||
|
||||
|
|
|
@ -31,46 +31,46 @@ namespace serene {
|
|||
|
||||
/// A collection of common error codes in Serene
|
||||
enum class errc {
|
||||
argument_list_too_long = int(std::errc::argument_list_too_long),
|
||||
argument_out_of_domain = int(std::errc::argument_out_of_domain),
|
||||
bad_address = int(std::errc::bad_address),
|
||||
bad_file_descriptor = int(std::errc::bad_file_descriptor),
|
||||
broken_pipe = int(std::errc::broken_pipe),
|
||||
argument_list_too_long = int(std::errc::argument_list_too_long),
|
||||
argument_out_of_domain = int(std::errc::argument_out_of_domain),
|
||||
bad_address = int(std::errc::bad_address),
|
||||
bad_file_descriptor = int(std::errc::bad_file_descriptor),
|
||||
broken_pipe = int(std::errc::broken_pipe),
|
||||
device_or_resource_busy = int(std::errc::device_or_resource_busy),
|
||||
directory_not_empty = int(std::errc::directory_not_empty),
|
||||
directory_not_empty = int(std::errc::directory_not_empty),
|
||||
executable_format_error = int(std::errc::executable_format_error),
|
||||
file_exists = int(std::errc::file_exists),
|
||||
file_too_large = int(std::errc::file_too_large),
|
||||
filename_too_long = int(std::errc::filename_too_long),
|
||||
function_not_supported = int(std::errc::function_not_supported),
|
||||
illegal_byte_sequence = int(std::errc::illegal_byte_sequence),
|
||||
file_exists = int(std::errc::file_exists),
|
||||
file_too_large = int(std::errc::file_too_large),
|
||||
filename_too_long = int(std::errc::filename_too_long),
|
||||
function_not_supported = int(std::errc::function_not_supported),
|
||||
illegal_byte_sequence = int(std::errc::illegal_byte_sequence),
|
||||
inappropriate_io_control_operation =
|
||||
int(std::errc::inappropriate_io_control_operation),
|
||||
interrupted = int(std::errc::interrupted),
|
||||
invalid_argument = int(std::errc::invalid_argument),
|
||||
invalid_seek = int(std::errc::invalid_seek),
|
||||
io_error = int(std::errc::io_error),
|
||||
is_a_directory = int(std::errc::is_a_directory),
|
||||
no_child_process = int(std::errc::no_child_process),
|
||||
no_lock_available = int(std::errc::no_lock_available),
|
||||
no_space_on_device = int(std::errc::no_space_on_device),
|
||||
no_such_device_or_address = int(std::errc::no_such_device_or_address),
|
||||
no_such_device = int(std::errc::no_such_device),
|
||||
no_such_file_or_directory = int(std::errc::no_such_file_or_directory),
|
||||
no_such_process = int(std::errc::no_such_process),
|
||||
not_a_directory = int(std::errc::not_a_directory),
|
||||
not_enough_memory = int(std::errc::not_enough_memory),
|
||||
not_supported = int(std::errc::not_supported),
|
||||
operation_not_permitted = int(std::errc::operation_not_permitted),
|
||||
permission_denied = int(std::errc::permission_denied),
|
||||
read_only_file_system = int(std::errc::read_only_file_system),
|
||||
interrupted = int(std::errc::interrupted),
|
||||
invalid_argument = int(std::errc::invalid_argument),
|
||||
invalid_seek = int(std::errc::invalid_seek),
|
||||
io_error = int(std::errc::io_error),
|
||||
is_a_directory = int(std::errc::is_a_directory),
|
||||
no_child_process = int(std::errc::no_child_process),
|
||||
no_lock_available = int(std::errc::no_lock_available),
|
||||
no_space_on_device = int(std::errc::no_space_on_device),
|
||||
no_such_device_or_address = int(std::errc::no_such_device_or_address),
|
||||
no_such_device = int(std::errc::no_such_device),
|
||||
no_such_file_or_directory = int(std::errc::no_such_file_or_directory),
|
||||
no_such_process = int(std::errc::no_such_process),
|
||||
not_a_directory = int(std::errc::not_a_directory),
|
||||
not_enough_memory = int(std::errc::not_enough_memory),
|
||||
not_supported = int(std::errc::not_supported),
|
||||
operation_not_permitted = int(std::errc::operation_not_permitted),
|
||||
permission_denied = int(std::errc::permission_denied),
|
||||
read_only_file_system = int(std::errc::read_only_file_system),
|
||||
resource_deadlock_would_occur = int(std::errc::resource_deadlock_would_occur),
|
||||
resource_unavailable_try_again =
|
||||
int(std::errc::resource_unavailable_try_again),
|
||||
result_out_of_range = int(std::errc::result_out_of_range),
|
||||
result_out_of_range = int(std::errc::result_out_of_range),
|
||||
too_many_files_open_in_system = int(std::errc::too_many_files_open_in_system),
|
||||
too_many_files_open = int(std::errc::too_many_files_open),
|
||||
too_many_links = int(std::errc::too_many_links)
|
||||
too_many_files_open = int(std::errc::too_many_files_open),
|
||||
too_many_links = int(std::errc::too_many_links)
|
||||
};
|
||||
|
||||
/// The **official way** to create `std::error_code` in context of Serene.
|
||||
|
|
|
@ -29,8 +29,10 @@
|
|||
#include "serene/errors/error.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
#include "serene/context.h"
|
||||
#include "serene/errors/error.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "serene/exprs/traits.h"
|
||||
#include "serene/reader/location.h"
|
||||
#include "serene/utils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace serene {
|
||||
|
@ -40,7 +41,7 @@ namespace exprs {
|
|||
|
||||
class Expression;
|
||||
|
||||
using Node = std::shared_ptr<Expression>;
|
||||
using Node = std::shared_ptr<Expression>;
|
||||
using ErrorPtr = std::shared_ptr<errors::Error>;
|
||||
|
||||
// tree? Yupe, Errors can be stackable which makes
|
||||
|
@ -48,7 +49,7 @@ using ErrorTree = std::vector<ErrorPtr>;
|
|||
|
||||
using MaybeNode = Result<Node, ErrorTree>;
|
||||
|
||||
using Ast = std::vector<Node>;
|
||||
using Ast = std::vector<Node>;
|
||||
using MaybeAst = Result<Ast, ErrorTree>;
|
||||
|
||||
static auto EmptyNode = MaybeNode::success(nullptr);
|
||||
|
@ -92,7 +93,8 @@ public:
|
|||
/// \param[args] Any argument with any type passed to this function will be
|
||||
/// passed to the constructor of type T.
|
||||
/// \return A unique pointer to an Expression
|
||||
template <typename T, typename... Args> Node make(Args &&...args) {
|
||||
template <typename T, typename... Args>
|
||||
Node make(Args &&...args) {
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
};
|
||||
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
#include "serene/namespace.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include "llvm/ADT/Optional.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/namespace.h"
|
||||
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -31,7 +31,8 @@ namespace llvm {
|
|||
|
||||
// Our specialization of DensMapInfo for string type. This will allow use to use
|
||||
// string
|
||||
template <> struct DenseMapInfo<std::string> {
|
||||
template <>
|
||||
struct DenseMapInfo<std::string> {
|
||||
static inline std::string getEmptyKey() { return ""; }
|
||||
|
||||
static inline std::string getTombstoneKey() {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "serene/slir/generatable.h"
|
||||
#include "serene/traits.h"
|
||||
#include "serene/utils.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <llvm/ADT/SmallString.h>
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
|
@ -40,7 +41,7 @@
|
|||
#include <mlir/Support/LogicalResult.h>
|
||||
#include <string>
|
||||
|
||||
#define NAMESPACE_LOG(...) \
|
||||
#define NAMESPACE_LOG(...) \
|
||||
DEBUG_WITH_TYPE("NAMESPACE", llvm::dbgs() << __VA_ARGS__ << "\n");
|
||||
|
||||
namespace serene {
|
||||
|
@ -49,7 +50,7 @@ class SereneContext;
|
|||
namespace exprs {
|
||||
class Expression;
|
||||
using Node = std::shared_ptr<Expression>;
|
||||
using Ast = std::vector<Node>;
|
||||
using Ast = std::vector<Node>;
|
||||
} // namespace exprs
|
||||
|
||||
/// Serene's namespaces are the unit of compilation. Any code that needs to be
|
||||
|
@ -58,7 +59,7 @@ using Ast = std::vector<Node>;
|
|||
class Namespace : public WithTrait<Namespace, slir::Generatable> {
|
||||
private:
|
||||
SereneContext &ctx;
|
||||
bool initialized = false;
|
||||
bool initialized = false;
|
||||
std::atomic<uint> fn_counter = 0;
|
||||
exprs::Ast tree;
|
||||
mlir::OpBuilder builder;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "serene/slir/dialect.h"
|
||||
|
||||
#include <mlir/Dialect/Affine/IR/AffineOps.h>
|
||||
#include <mlir/Dialect/LLVMIR/LLVMDialect.h>
|
||||
#include <mlir/Dialect/MemRef/IR/MemRef.h>
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "mlir/IR/Location.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -25,13 +25,6 @@
|
|||
#ifndef READER_H
|
||||
#define READER_H
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <vector>
|
||||
|
||||
#include "serene/errors.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
|
@ -39,10 +32,18 @@
|
|||
#include "serene/reader/errors.h"
|
||||
#include "serene/reader/location.h"
|
||||
#include "serene/serene.h"
|
||||
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#define READER_LOG(...) \
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <vector>
|
||||
|
||||
#define READER_LOG(...) \
|
||||
DEBUG_WITH_TYPE("READER", llvm::dbgs() << __VA_ARGS__ << "\n");
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T> serene::reader::LocationRange &where(ILocatable<T> &);
|
||||
template <typename T>
|
||||
serene::reader::LocationRange &where(ILocatable<T> &);
|
||||
} // namespace serene::reader
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "mlir/IR/Identifier.h"
|
||||
#include "serene/reader/location.h"
|
||||
#include "serene/traits.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace serene {
|
||||
|
@ -51,7 +52,8 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
template <typename T> class Generatable : public TraitBase<T, Generatable> {
|
||||
template <typename T>
|
||||
class Generatable : public TraitBase<T, Generatable> {
|
||||
public:
|
||||
Generatable(){};
|
||||
Generatable(const Generatable &) = delete;
|
||||
|
@ -62,9 +64,15 @@ public:
|
|||
void dumpIR() { this->Object().dumpToIR(); };
|
||||
};
|
||||
|
||||
template <typename T> void dumpIR(Generatable<T> &t) { t.dumpIR(); };
|
||||
template <typename T>
|
||||
void dumpIR(Generatable<T> &t) {
|
||||
t.dumpIR();
|
||||
};
|
||||
|
||||
template <typename T> void dumpSLIR(Generatable<T> &t) { t.dumpSLIR(); };
|
||||
template <typename T>
|
||||
void dumpSLIR(Generatable<T> &t) {
|
||||
t.dumpSLIR();
|
||||
};
|
||||
|
||||
} // namespace serene::slir
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/slir/generatable.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -119,7 +119,8 @@ public:
|
|||
std::string toString() const { return this->Object().toString(); }
|
||||
};
|
||||
|
||||
template <typename T> std::string toString(IDebuggable<T> &t) {
|
||||
template <typename T>
|
||||
std::string toString(IDebuggable<T> &t) {
|
||||
return t.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define SERENE_UTILS_H
|
||||
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
// C++17 required. We can't go back to 14 any more :))
|
||||
|
@ -45,7 +46,8 @@ namespace serene {
|
|||
///
|
||||
/// In order check for a value being errorful or successful checkout the `ok`
|
||||
/// method or simply use the value as a conditiona.
|
||||
template <typename T, typename E = llvm::Error> class Result {
|
||||
template <typename T, typename E = llvm::Error>
|
||||
class Result {
|
||||
|
||||
// The actual data container
|
||||
std::variant<T, E> contents;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/context.h"
|
||||
|
||||
#include "serene/namespace.h"
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/errors/error.h"
|
||||
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -23,12 +23,14 @@
|
|||
*/
|
||||
|
||||
#include "serene/exprs/call.h"
|
||||
|
||||
#include "serene/errors/error.h"
|
||||
#include "serene/exprs/def.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "serene/reader/semantics.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
|
|
@ -23,11 +23,13 @@
|
|||
*/
|
||||
|
||||
#include "serene/exprs/def.h"
|
||||
|
||||
#include "serene/errors/error.h"
|
||||
#include "serene/exprs/fn.h"
|
||||
#include "serene/exprs/list.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "serene/exprs/traits.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -23,11 +23,13 @@
|
|||
*/
|
||||
|
||||
#include "serene/exprs/fn.h"
|
||||
|
||||
#include "serene/errors/error.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "serene/reader/semantics.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
||||
|
@ -80,7 +82,7 @@ MaybeNode Fn::make(SereneContext &ctx, List *list) {
|
|||
Ast body;
|
||||
|
||||
if (list->count() > 2) {
|
||||
body = std::vector<Node>(list->begin() + 2, list->end());
|
||||
body = std::vector<Node>(list->begin() + 2, list->end());
|
||||
auto maybeAst = reader::analyze(ctx, body);
|
||||
|
||||
if (!maybeAst) {
|
||||
|
|
|
@ -23,15 +23,18 @@
|
|||
*/
|
||||
|
||||
#include "serene/exprs/list.h"
|
||||
|
||||
#include "serene/errors/error.h"
|
||||
#include "serene/exprs/call.h"
|
||||
#include "serene/exprs/def.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/fn.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/exprs/number.h"
|
||||
|
||||
#include "serene/slir/dialect.h"
|
||||
#include "serene/slir/utils.h"
|
||||
|
||||
|
@ -48,7 +49,7 @@ int Number::toI64() { return std::stoi(this->value); };
|
|||
|
||||
void Number::generateIR(serene::Namespace &ns) {
|
||||
mlir::OpBuilder &builder = ns.getBuilder();
|
||||
mlir::ModuleOp &module = ns.getModule();
|
||||
mlir::ModuleOp &module = ns.getModule();
|
||||
|
||||
auto op = builder.create<serene::slir::ValueOp>(
|
||||
serene::slir::toMLIRLocation(ns, location.start), toI64());
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/exprs/symbol.h"
|
||||
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
||||
namespace serene {
|
||||
|
|
|
@ -23,13 +23,16 @@
|
|||
*/
|
||||
|
||||
#include "serene/namespace.h"
|
||||
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/llvm/IR/Value.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
@ -54,7 +57,7 @@ mlir::LogicalResult Namespace::setTree(exprs::Ast &t) {
|
|||
if (initialized) {
|
||||
return mlir::failure();
|
||||
}
|
||||
this->tree = std::move(t);
|
||||
this->tree = std::move(t);
|
||||
this->initialized = true;
|
||||
return mlir::success();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/passes/slir_lowering.h"
|
||||
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
|
||||
namespace serene::passes {
|
||||
|
@ -30,7 +31,7 @@ namespace serene::passes {
|
|||
mlir::LogicalResult
|
||||
ValueOpLowering::matchAndRewrite(serene::slir::ValueOp op,
|
||||
mlir::PatternRewriter &rewriter) const {
|
||||
auto value = op.value();
|
||||
auto value = op.value();
|
||||
mlir::Location loc = op.getLoc();
|
||||
|
||||
// auto std_const =
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
*/
|
||||
|
||||
#include "serene/reader/location.h"
|
||||
|
||||
#include "mlir/IR/Identifier.h"
|
||||
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
||||
namespace serene {
|
||||
|
@ -31,7 +33,7 @@ namespace reader {
|
|||
|
||||
LocationRange::LocationRange(const LocationRange &loc) {
|
||||
start = loc.start;
|
||||
end = loc.end;
|
||||
end = loc.end;
|
||||
}
|
||||
|
||||
/// Return the string represenation of the location.
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
*/
|
||||
|
||||
#include "serene/reader/reader.h"
|
||||
|
||||
#include "serene/exprs/list.h"
|
||||
#include "serene/exprs/number.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "serene/namespace.h"
|
||||
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "llvm/Support/ErrorOr.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
@ -120,7 +122,7 @@ bool Reader::isValidForIdentifier(char c) {
|
|||
exprs::Node Reader::readNumber(bool neg) {
|
||||
std::string number(neg ? "-" : "");
|
||||
bool floatNum = false;
|
||||
bool empty = false;
|
||||
bool empty = false;
|
||||
|
||||
LocationRange loc;
|
||||
char c = getChar(false);
|
||||
|
@ -141,7 +143,7 @@ exprs::Node Reader::readNumber(bool neg) {
|
|||
floatNum = true;
|
||||
}
|
||||
number += c;
|
||||
c = getChar(false);
|
||||
c = getChar(false);
|
||||
empty = false;
|
||||
}
|
||||
|
||||
|
@ -158,7 +160,7 @@ exprs::Node Reader::readNumber(bool neg) {
|
|||
/// If reads it as number
|
||||
exprs::Node Reader::readSymbol() {
|
||||
bool empty = true;
|
||||
char c = getChar(false);
|
||||
char c = getChar(false);
|
||||
|
||||
READER_LOG("Reading symbol");
|
||||
if (!this->isValidForIdentifier(c)) {
|
||||
|
@ -189,7 +191,7 @@ exprs::Node Reader::readSymbol() {
|
|||
|
||||
while (c != EOF && ((!(isspace(c)) && this->isValidForIdentifier(c)))) {
|
||||
sym += c;
|
||||
c = getChar(false);
|
||||
c = getChar(false);
|
||||
empty = false;
|
||||
}
|
||||
|
||||
|
@ -219,7 +221,7 @@ exprs::Node Reader::readList() {
|
|||
case EOF:
|
||||
throw ReadError(const_cast<char *>("EOF reached before closing of list"));
|
||||
case ')':
|
||||
list_terminated = true;
|
||||
list_terminated = true;
|
||||
list->location.end = current_location;
|
||||
|
||||
break;
|
||||
|
@ -276,7 +278,7 @@ Result<exprs::Ast> Reader::read() {
|
|||
|
||||
/// Reads the input into an AST and prints it out as string again.
|
||||
void Reader::toString() {
|
||||
auto maybeAst = read();
|
||||
auto maybeAst = read();
|
||||
std::string result = "";
|
||||
|
||||
if (!maybeAst) {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/reader/semantics.h"
|
||||
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
|
|
|
@ -23,5 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/serene.h"
|
||||
|
||||
#include "serene/reader/reader.h"
|
||||
|
||||
#include <iostream>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "serene/slir/generatable.h"
|
||||
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include "serene/exprs/traits.h"
|
||||
#include "serene/namespace.h"
|
||||
#include "serene/slir/dialect.h"
|
||||
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/ScopedHashTable.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
@ -42,15 +44,18 @@
|
|||
namespace serene {
|
||||
namespace slir {
|
||||
|
||||
template <typename T> mlir::ModuleOp &Generatable<T>::generate() {
|
||||
template <typename T>
|
||||
mlir::ModuleOp &Generatable<T>::generate() {
|
||||
return this->Object().generate();
|
||||
};
|
||||
|
||||
template <typename T> mlir::LogicalResult Generatable<T>::runPasses() {
|
||||
template <typename T>
|
||||
mlir::LogicalResult Generatable<T>::runPasses() {
|
||||
return this->Object().runPasses();
|
||||
};
|
||||
|
||||
template <typename T> void Generatable<T>::dumpSLIR() {
|
||||
template <typename T>
|
||||
void Generatable<T>::dumpSLIR() {
|
||||
this->Object().dumpSLIR();
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace serene::slir {
|
|||
::mlir::Location toMLIRLocation(serene::Namespace &ns,
|
||||
serene::reader::Location &loc) {
|
||||
mlir::OpBuilder &builder = ns.getBuilder();
|
||||
auto file = ns.filename;
|
||||
auto file = ns.filename;
|
||||
std::string filename{file.getValueOr("REPL")};
|
||||
|
||||
return mlir::FileLineColLoc::get(builder.getIdentifier(filename), loc.line,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "mlir/IR/Value.h"
|
||||
#include "serene/slir/dialect.h"
|
||||
#include "serene/slir/slir.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
namespace serene {
|
||||
|
|
Loading…
Reference in New Issue