mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-28 18:57:48 +01:00
include fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.27)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(psil)
|
project(psil)
|
||||||
|
|
||||||
if (SANITIZE STREQUAL "YES")
|
if (SANITIZE STREQUAL "YES")
|
||||||
@@ -18,7 +18,7 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
add_link_options(-O3)
|
add_link_options(-O3)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_subdirectory(vm)
|
add_subdirectory(vm)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_library(vm src/VM.cpp src/Cell.cpp
|
add_library(vm src/VM.cpp src/Cell.cpp
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
enum class CellType {
|
enum class CellType {
|
||||||
NUMATOM,
|
NUMATOM,
|
||||||
STRATOM,
|
STRATOM,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Handle.h"
|
#include "Handle.h"
|
||||||
|
|
||||||
class Compiler {
|
class Compiler {
|
||||||
public:
|
public:
|
||||||
static Handle compile(Handle src, Handle fake_env = nullptr, Handle suffix = nullptr);
|
static Handle compile(Handle src, Handle fake_env = nullptr, Handle suffix = nullptr);
|
||||||
|
|||||||
@@ -29,10 +29,6 @@ public:
|
|||||||
return dynamic_cast<NumAtomCell &>(*_target)._val == dynamic_cast<NumAtomCell &>(*rhs._target)._val;
|
return dynamic_cast<NumAtomCell &>(*_target)._val == dynamic_cast<NumAtomCell &>(*rhs._target)._val;
|
||||||
} else if (_target->_type == CellType::STRATOM) {
|
} else if (_target->_type == CellType::STRATOM) {
|
||||||
return dynamic_cast<StrAtomCell &>(*_target)._val == dynamic_cast<StrAtomCell &>(*rhs._target)._val;
|
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;
|
return false;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
#include "Handle.h"
|
#include "Handle.h"
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
Handle Compiler::compile(Handle src, Handle fake_env, Handle suffix) {
|
Handle Compiler::compile(Handle src, Handle fake_env, Handle suffix) {
|
||||||
Handle out;
|
Handle out;
|
||||||
|
|
||||||
std::function<Handle(Handle)> compileArgsRaw = [&](Handle args) {
|
std::function<Handle(Handle)> compileArgsRaw = [&](Handle args) {
|
||||||
Handle out;
|
Handle out;
|
||||||
while (args != nullptr) {
|
while (!args.null()) {
|
||||||
out.splice(compile(args.car(), fake_env));
|
out.splice(compile(args.car(), fake_env));
|
||||||
args = args.cdr();
|
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) {
|
std::function<Handle(Handle, Handle)> compileArgsList = [&](Handle args, Handle env) {
|
||||||
Handle out;
|
Handle out;
|
||||||
out.append(Handle("NIL"));
|
out.append(Handle("NIL"));
|
||||||
while (args != nullptr) {
|
while (!args.null()) {
|
||||||
out.splice(compile(args.car(), env));
|
out.splice(compile(args.car(), env));
|
||||||
out.append(Handle("CONS"));
|
out.append(Handle("CONS"));
|
||||||
args = args.cdr();
|
args = args.cdr();
|
||||||
@@ -74,7 +75,7 @@ Handle Compiler::compile(Handle src, Handle fake_env, Handle suffix) {
|
|||||||
|
|
||||||
Handle body = cdr.cdr().car();
|
Handle body = cdr.cdr().car();
|
||||||
|
|
||||||
while (definitions != nullptr) {
|
while (!definitions.null()) {
|
||||||
argBody.emplace_back(definitions.car().car(), definitions.car().cdr().car());
|
argBody.emplace_back(definitions.car().car(), definitions.car().cdr().car());
|
||||||
argNames.append(definitions.car().car());
|
argNames.append(definitions.car().car());
|
||||||
argBodies.append(definitions.car().cdr().car());
|
argBodies.append(definitions.car().cdr().car());
|
||||||
@@ -116,11 +117,11 @@ Handle Compiler::findIndex(Handle symbol, Handle env) {
|
|||||||
|
|
||||||
Handle curFrame = env;
|
Handle curFrame = env;
|
||||||
|
|
||||||
while (curFrame != nullptr) {
|
while (!curFrame.null()) {
|
||||||
int64_t arg = 1;
|
int64_t arg = 1;
|
||||||
Handle curArg = curFrame.car();
|
Handle curArg = curFrame.car();
|
||||||
|
|
||||||
while (curArg != nullptr) {
|
while (!curArg.null()) {
|
||||||
if (curArg.car() == symbol) return Handle::cons(frame, arg);
|
if (curArg.car() == symbol) return Handle::cons(frame, arg);
|
||||||
curArg = curArg.cdr();
|
curArg = curArg.cdr();
|
||||||
arg++;
|
arg++;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
|
|
||||||
#include <format>
|
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|||||||
Reference in New Issue
Block a user