include fixes

This commit is contained in:
2024-01-03 13:55:46 +01:00
parent 0213684b3b
commit 8af15331d2
10 changed files with 15 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.27)
cmake_minimum_required(VERSION 3.20)
project(psil)
if (SANITIZE STREQUAL "YES")
@@ -18,7 +18,7 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_link_options(-O3)
endif ()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(src)

View File

@@ -1,4 +1,4 @@
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(vm)

View File

@@ -1,4 +1,4 @@
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(vm src/VM.cpp src/Cell.cpp

View File

@@ -11,6 +11,8 @@
#include <sstream>
#include <string>
#include <utility>
#include <atomic>
enum class CellType {
NUMATOM,
STRATOM,

View File

@@ -7,6 +7,7 @@
#include "Handle.h"
class Compiler {
public:
static Handle compile(Handle src, Handle fake_env = nullptr, Handle suffix = nullptr);

View File

@@ -29,10 +29,6 @@ public:
return dynamic_cast<NumAtomCell &>(*_target)._val == dynamic_cast<NumAtomCell &>(*rhs._target)._val;
} else if (_target->_type == CellType::STRATOM) {
return dynamic_cast<StrAtomCell &>(*_target)._val == dynamic_cast<StrAtomCell &>(*rhs._target)._val;
} else if (_target->_type == CellType::CONS) {
// This is questionable
return dynamic_cast<ConsCell &>(*_target)._car == dynamic_cast<ConsCell &>(*rhs._target)._car &&
dynamic_cast<ConsCell &>(*_target)._cdr == dynamic_cast<ConsCell &>(*rhs._target)._cdr;
}
}
return false;

View File

@@ -14,6 +14,7 @@
#include <queue>
#include <set>
#include <thread>
#include <functional>
#include "Cell.h"
#include "Handle.h"

View File

@@ -5,13 +5,14 @@
#include "Compiler.h"
#include <string>
#include <functional>
Handle Compiler::compile(Handle src, Handle fake_env, Handle suffix) {
Handle out;
std::function<Handle(Handle)> compileArgsRaw = [&](Handle args) {
Handle out;
while (args != nullptr) {
while (!args.null()) {
out.splice(compile(args.car(), fake_env));
args = args.cdr();
}
@@ -21,7 +22,7 @@ Handle Compiler::compile(Handle src, Handle fake_env, Handle suffix) {
std::function<Handle(Handle, Handle)> compileArgsList = [&](Handle args, Handle env) {
Handle out;
out.append(Handle("NIL"));
while (args != nullptr) {
while (!args.null()) {
out.splice(compile(args.car(), env));
out.append(Handle("CONS"));
args = args.cdr();
@@ -74,7 +75,7 @@ Handle Compiler::compile(Handle src, Handle fake_env, Handle suffix) {
Handle body = cdr.cdr().car();
while (definitions != nullptr) {
while (!definitions.null()) {
argBody.emplace_back(definitions.car().car(), definitions.car().cdr().car());
argNames.append(definitions.car().car());
argBodies.append(definitions.car().cdr().car());
@@ -116,11 +117,11 @@ Handle Compiler::findIndex(Handle symbol, Handle env) {
Handle curFrame = env;
while (curFrame != nullptr) {
while (!curFrame.null()) {
int64_t arg = 1;
Handle curArg = curFrame.car();
while (curArg != nullptr) {
while (!curArg.null()) {
if (curArg.car() == symbol) return Handle::cons(frame, arg);
curArg = curArg.cdr();
arg++;

View File

@@ -4,7 +4,6 @@
#include "Parser.h"
#include <format>
#include <ranges>
#include <stack>

View File

@@ -1,4 +1,4 @@
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)