diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/CompilerKit/AST.h | 1 | ||||
| -rw-r--r-- | include/CompilerKit/CodeGenerator.h | 3 | ||||
| -rw-r--r-- | include/CompilerKit/Detail/Config.h | 2 | ||||
| -rw-r--r-- | include/CompilerKit/Utils/Assembler.h (renamed from include/CompilerKit/Utilities/Assembler.h) | 2 | ||||
| -rw-r--r-- | include/CompilerKit/Utils/Compiler.h (renamed from include/CompilerKit/Utilities/Compiler.h) | 0 | ||||
| -rw-r--r-- | include/CompilerKit/Utils/DLL.h (renamed from include/CompilerKit/Utilities/DLL.h) | 0 | ||||
| -rw-r--r-- | include/CoreRuntime/README.md (renamed from include/CoreRuntimeKit/README.md) | 0 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/abi/abi.hpp (renamed from include/CoreRuntimeKit/C++/abi/abi.hpp) | 4 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/abi/new.hpp (renamed from include/CoreRuntimeKit/C++/abi/new.hpp) | 2 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/core/base_alloc.hpp (renamed from include/CoreRuntimeKit/C++/core/base_alloc.hpp) | 2 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/core/base_exception.hpp (renamed from include/CoreRuntimeKit/C++/core/base_exception.hpp) | 6 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/core/base_math.hpp (renamed from include/CoreRuntimeKit/C++/core/base_math.hpp) | 2 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/core/base_process.hpp (renamed from include/CoreRuntimeKit/C++/core/base_process.hpp) | 2 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/defines.hpp (renamed from include/CoreRuntimeKit/C++/defines.hpp) | 0 | ||||
| -rw-r--r-- | include/CoreRuntime/cplusplus/utility.hpp (renamed from include/CoreRuntimeKit/C++/utility.hpp) | 0 | ||||
| -rw-r--r-- | include/CoreRuntime/nec/exports.hpp (renamed from include/CoreRuntimeKit/Nectar/exports.hpp) | 4 | ||||
| -rw-r--r-- | include/CoreRuntimeKit/C++/filesystem/filesystem.hpp | 18 | ||||
| -rw-r--r-- | include/CoreRuntimeKit/Nectar/.keep | 0 | ||||
| -rw-r--r-- | include/DebuggerKit/Common.inl | 12 | ||||
| -rw-r--r-- | include/DebuggerKit/IDebugger.h (renamed from include/DebuggerKit/DebuggerContract.h) | 25 | ||||
| -rw-r--r-- | include/DebuggerKit/Mach.h (renamed from include/DebuggerKit/MachContract.h) | 34 | ||||
| -rw-r--r-- | include/DebuggerKit/NeSystem.h (renamed from include/DebuggerKit/NeKernelContract.h) | 18 | ||||
| -rw-r--r-- | include/DebuggerKit/POSIX.h | 115 | ||||
| -rw-r--r-- | include/GenericsLibrary/algorithm.nhh | 17 | ||||
| -rw-r--r-- | include/GenericsLibrary/fstream.nhh | 20 | ||||
| -rw-r--r-- | include/GenericsLibrary/io.nhh | 6 | ||||
| -rw-r--r-- | include/GenericsLibrary/iterator.nhh | 32 | ||||
| -rw-r--r-- | include/GenericsLibrary/math.nhh | 6 | ||||
| -rw-r--r-- | include/GenericsLibrary/pstd.nhh | 8 | ||||
| -rw-r--r-- | include/GenericsLibrary/start.nhh (renamed from include/GenericsLibrary/nrt.nc) | 6 | ||||
| -rw-r--r-- | include/GenericsLibrary/std.nhh | 18 |
31 files changed, 225 insertions, 140 deletions
diff --git a/include/CompilerKit/AST.h b/include/CompilerKit/AST.h index c1313ce..27f57be 100644 --- a/include/CompilerKit/AST.h +++ b/include/CompilerKit/AST.h @@ -46,6 +46,7 @@ enum struct KeywordKind { kKeywordKindIf, kKeywordKindVariableAssign, kKeywordKindVariableDec, + kKeywordKindVariableEquals, kKeywordKindVariableInc, kKeywordKindTypedef, kKeywordKindEndLine, // Optional in Nectar. diff --git a/include/CompilerKit/CodeGenerator.h b/include/CompilerKit/CodeGenerator.h index 69af3ba..ac42879 100644 --- a/include/CompilerKit/CodeGenerator.h +++ b/include/CompilerKit/CodeGenerator.h @@ -18,9 +18,6 @@ #define CK_ASSEMBLY_INTERFACE : public ::CompilerKit::IAssembly #define CK_ENCODER : public ::CompilerKit::IAssemblyEncoder -/// @brief This function is for internal uses only, do not call it without a wrapper! -CK_IMPORT_C bool NectarCheckFrontend(CompilerKit::STLString& input); - namespace CompilerKit { class AssemblyFactory; class IAssembly; diff --git a/include/CompilerKit/Detail/Config.h b/include/CompilerKit/Detail/Config.h index 651904e..3693754 100644 --- a/include/CompilerKit/Detail/Config.h +++ b/include/CompilerKit/Detail/Config.h @@ -16,6 +16,7 @@ #include <ocl/tproc.hpp> namespace CompilerKit { + inline static constexpr int kBaseYear = 1900; using STLString = std::string; using RopeString = ocl::tproc::crope; @@ -63,6 +64,7 @@ inline bool install_signal(Int32 signal, void (*handler)(int)) noexcept { return true; } + } // namespace CompilerKit #endif // __COMPILERKIT_CONFIG_H__ diff --git a/include/CompilerKit/Utilities/Assembler.h b/include/CompilerKit/Utils/Assembler.h index 8e5821a..6beff60 100644 --- a/include/CompilerKit/Utilities/Assembler.h +++ b/include/CompilerKit/Utils/Assembler.h @@ -8,7 +8,7 @@ #include <CompilerKit/AST.h> #include <CompilerKit/CodeGenerator.h> -#include <CompilerKit/Utilities/Compiler.h> +#include <CompilerKit/Utils/Compiler.h> namespace CompilerKit { /// @brief Get Number from lineBuffer. diff --git a/include/CompilerKit/Utilities/Compiler.h b/include/CompilerKit/Utils/Compiler.h index 094647b..094647b 100644 --- a/include/CompilerKit/Utilities/Compiler.h +++ b/include/CompilerKit/Utils/Compiler.h diff --git a/include/CompilerKit/Utilities/DLL.h b/include/CompilerKit/Utils/DLL.h index 6d12538..6d12538 100644 --- a/include/CompilerKit/Utilities/DLL.h +++ b/include/CompilerKit/Utils/DLL.h diff --git a/include/CoreRuntimeKit/README.md b/include/CoreRuntime/README.md index 84d50bb..84d50bb 100644 --- a/include/CoreRuntimeKit/README.md +++ b/include/CoreRuntime/README.md diff --git a/include/CoreRuntimeKit/C++/abi/abi.hpp b/include/CoreRuntime/cplusplus/abi/abi.hpp index c0a2680..fe60401 100644 --- a/include/CoreRuntimeKit/C++/abi/abi.hpp +++ b/include/CoreRuntime/cplusplus/abi/abi.hpp @@ -5,8 +5,8 @@ #pragma once -#include <base_process> -#include <defines> +#include <CoreRuntime/cplusplus/core/base_process.hpp> +#include <CoreRuntime/cplusplus/defines.hpp> __init_decl() diff --git a/include/CoreRuntimeKit/C++/abi/new.hpp b/include/CoreRuntime/cplusplus/abi/new.hpp index 9e86e22..6592567 100644 --- a/include/CoreRuntimeKit/C++/abi/new.hpp +++ b/include/CoreRuntime/cplusplus/abi/new.hpp @@ -5,7 +5,7 @@ #pragma once -#include <defines> +#include <CoreRuntime/cplusplus/defines.hpp> namespace std { diff --git a/include/CoreRuntimeKit/C++/core/base_alloc.hpp b/include/CoreRuntime/cplusplus/core/base_alloc.hpp index 4d715f7..3b79706 100644 --- a/include/CoreRuntimeKit/C++/core/base_alloc.hpp +++ b/include/CoreRuntime/cplusplus/core/base_alloc.hpp @@ -5,7 +5,7 @@ #pragma once -#include <defines> +#include <CoreRuntime/cplusplus/defines.hpp> namespace std::base_alloc { diff --git a/include/CoreRuntimeKit/C++/core/base_exception.hpp b/include/CoreRuntime/cplusplus/core/base_exception.hpp index c103da5..7316dfa 100644 --- a/include/CoreRuntimeKit/C++/core/base_exception.hpp +++ b/include/CoreRuntime/cplusplus/core/base_exception.hpp @@ -5,9 +5,9 @@ #pragma once -#include <abi> -#include <base_process> -#include <defines> +#include <CoreRuntime/cplusplus/abi/abi.hpp> +#include <CoreRuntime/cplusplus/core/base_process.hpp> +#include <CoreRuntime/cplusplus/defines.hpp> #include <iostream> /// @author Amlal El Mahrouss (amlal@nekernel.org) diff --git a/include/CoreRuntimeKit/C++/core/base_math.hpp b/include/CoreRuntime/cplusplus/core/base_math.hpp index 6691c27..103a1eb 100644 --- a/include/CoreRuntimeKit/C++/core/base_math.hpp +++ b/include/CoreRuntime/cplusplus/core/base_math.hpp @@ -5,7 +5,7 @@ #pragma once -#include <defines> +#include <CoreRuntime/cplusplus/defines.hpp> #ifndef NAN #define NAN (__builtin_nanf("")) diff --git a/include/CoreRuntimeKit/C++/core/base_process.hpp b/include/CoreRuntime/cplusplus/core/base_process.hpp index 84354a9..7673577 100644 --- a/include/CoreRuntimeKit/C++/core/base_process.hpp +++ b/include/CoreRuntime/cplusplus/core/base_process.hpp @@ -5,7 +5,7 @@ #pragma once -#include <defines> +#include <CoreRuntime/cplusplus/defines.hpp> __init_decl() diff --git a/include/CoreRuntimeKit/C++/defines.hpp b/include/CoreRuntime/cplusplus/defines.hpp index 3cd1ee1..3cd1ee1 100644 --- a/include/CoreRuntimeKit/C++/defines.hpp +++ b/include/CoreRuntime/cplusplus/defines.hpp diff --git a/include/CoreRuntimeKit/C++/utility.hpp b/include/CoreRuntime/cplusplus/utility.hpp index a427c44..a427c44 100644 --- a/include/CoreRuntimeKit/C++/utility.hpp +++ b/include/CoreRuntime/cplusplus/utility.hpp diff --git a/include/CoreRuntimeKit/Nectar/exports.hpp b/include/CoreRuntime/nec/exports.hpp index 72638af..3fea960 100644 --- a/include/CoreRuntimeKit/Nectar/exports.hpp +++ b/include/CoreRuntime/nec/exports.hpp @@ -6,8 +6,8 @@ #pragma once -#include <CoreRuntimeKit/C++/abi/abi.hpp> -#include <CoreRuntimeKit/C++/abi/new.hpp> +#include <CoreRuntime/C++/abi/abi.hpp> +#include <CoreRuntime/C++/abi/new.hpp> /// @brief The Nectar FFI. namespace nectar_lang { diff --git a/include/CoreRuntimeKit/C++/filesystem/filesystem.hpp b/include/CoreRuntimeKit/C++/filesystem/filesystem.hpp deleted file mode 100644 index 917dd0f..0000000 --- a/include/CoreRuntimeKit/C++/filesystem/filesystem.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/ne-foss-org/nectar - -#ifndef __NECTAR_FS_H__ -#define __NECTAR_FS_H__ - -#include <defines> - -namespace std { -class path; -class filesystem_error; -class directory_entry; -class directory_iterator; -} // namespace std - -#endif // __NECTAR_FS_H__ diff --git a/include/CoreRuntimeKit/Nectar/.keep b/include/CoreRuntimeKit/Nectar/.keep deleted file mode 100644 index e69de29..0000000 --- a/include/CoreRuntimeKit/Nectar/.keep +++ /dev/null diff --git a/include/DebuggerKit/Common.inl b/include/DebuggerKit/Common.inl index b54c410..a9e5d35 100644 --- a/include/DebuggerKit/Common.inl +++ b/include/DebuggerKit/Common.inl @@ -13,9 +13,17 @@ inline bool kKeepRunning = false; #ifdef DK_NEKERNEL_DEBUGGER -inline DebuggerKit::NeKernel::NeKernelContract kKernelDebugger; +inline DebuggerKit::NeKernel::NeSystemDebugger kKernelDebugger; #else -inline DebuggerKit::POSIX::POSIXMachContract kUserDebugger; +#ifdef DK_MACH_DEBUGGER + +inline DebuggerKit::POSIX::MachDebugger kUserDebugger; + +#else + +inline DebuggerKit::POSIX::POSIXDebugger kUserDebugger; + +#endif #endif static DebuggerKit::ProcessID kPID = 0L; diff --git a/include/DebuggerKit/DebuggerContract.h b/include/DebuggerKit/IDebugger.h index adaeb6e..0ada42c 100644 --- a/include/DebuggerKit/DebuggerContract.h +++ b/include/DebuggerKit/IDebugger.h @@ -10,30 +10,31 @@ #include <DebuggerKit/Detail/Config.h> #include <unordered_map> -#define DK_DEBUGGER_CONTRACT : public ::DebuggerKit::IDebuggerContract +#define DK_DEBUGGER_CONTRACT : public ::DebuggerKit::IDebugger namespace DebuggerKit { -class IDebuggerContract; +class IDebugger; /// =========================================================== /// /// \brief Debugger contract class in C++, as per the design states. /// \author Amlal El Mahrouss /// =========================================================== /// -class IDebuggerContract { +class IDebugger { public: - explicit IDebuggerContract() = default; - virtual ~IDebuggerContract() = default; + explicit IDebugger() = default; + virtual ~IDebugger() = default; public: - IDebuggerContract& operator=(const IDebuggerContract&) = default; - IDebuggerContract(const IDebuggerContract&) = default; + IDebugger& operator=(const IDebugger&) = default; + IDebugger(const IDebugger&) = default; public: - virtual bool Attach(std::string path, std::string argv, ProcessID& pid) noexcept = 0; - virtual bool BreakAt(std::string symbol) noexcept = 0; - virtual bool Break() noexcept = 0; - virtual bool Continue() noexcept = 0; - virtual bool Detach() noexcept = 0; + virtual bool Attach(const CompilerKit::STLString& path, const CompilerKit::STLString& argv, + ProcessID& pid) noexcept = 0; + virtual bool BreakAt(const CompilerKit::STLString& symbol) noexcept = 0; + virtual bool Break() noexcept = 0; + virtual bool Continue() noexcept = 0; + virtual bool Detach() noexcept = 0; using BreakpointMap = std::unordered_map<uintptr_t, uintptr_t>; diff --git a/include/DebuggerKit/MachContract.h b/include/DebuggerKit/Mach.h index bd62007..05dc37f 100644 --- a/include/DebuggerKit/MachContract.h +++ b/include/DebuggerKit/Mach.h @@ -3,26 +3,24 @@ // file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0) // Official repository: https://github.com/ne-foss-org/nectar -#ifndef NECTAR_DEBUGGERKIT_POSIXMACHCONTRACT_H -#define NECTAR_DEBUGGERKIT_POSIXMACHCONTRACT_H +#ifndef NECTAR_DEBUGGERKIT_MACHCONTRACT_H +#define NECTAR_DEBUGGERKIT_MACHCONTRACT_H #ifdef DK_MACH_DEBUGGER -/// @file POSIXMachContract.h +/// @file MachDebugger.h /// @brief POSIX Mach debugger. -#include <DebuggerKit/DebuggerContract.h> +#include <DebuggerKit/IDebugger.h> #include <filesystem> #include <vector> -#ifdef __APPLE__ CK_IMPORT_C kern_return_t mach_vm_write(vm_map_t target_task, mach_vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt); CK_IMPORT_C kern_return_t mach_vm_protect(vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection); -#endif #define PTRACE_ATTACH PT_ATTACHEXC #define PTRACE_DETACH PT_DETACH @@ -32,20 +30,20 @@ CK_IMPORT_C kern_return_t mach_vm_protect(vm_map_t target_task, mach_vm_address_ namespace DebuggerKit::POSIX { /// =========================================================== /// -/// \brief POSIXMachContract engine class in C++ +/// \brief MachDebugger engine class in C++ /// \author Amlal El Mahrouss /// =========================================================== /// -class POSIXMachContract final DK_DEBUGGER_CONTRACT { +class MachDebugger DK_DEBUGGER_CONTRACT { public: - explicit POSIXMachContract() = default; - ~POSIXMachContract() override = default; + explicit MachDebugger() = default; + ~MachDebugger() override = default; public: - POSIXMachContract& operator=(const POSIXMachContract&) = default; - POSIXMachContract(const POSIXMachContract&) = default; + MachDebugger& operator=(const MachDebugger&) = default; + MachDebugger(const MachDebugger&) = default; public: - bool Attach(CompilerKit::STLString path, CompilerKit::STLString argv, + bool Attach(const CompilerKit::STLString& path, const CompilerKit::STLString& argv, ProcessID& pid) noexcept override { pid = fork(); @@ -74,7 +72,7 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT { return true; } - void SetPath(CompilerKit::STLString path) noexcept { + void SetPath(const CompilerKit::STLString& path) noexcept { if (path.empty()) { return; } @@ -82,7 +80,7 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT { m_path = path; } - bool BreakAt(CompilerKit::STLString symbol) noexcept override { + bool BreakAt(const CompilerKit::STLString& symbol) noexcept override { if (!m_path.empty() && std::filesystem::exists(m_path) && std::filesystem::is_regular_file(m_path)) { auto handle = dlopen(m_path.c_str(), RTLD_LAZY); @@ -97,10 +95,10 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT { return false; } -#ifdef __APPLE__ task_read_t task; task_for_pid(mach_task_self(), mPid, &task); +#ifdef __x86_64__ uint32_t brk_inst = 0xD43E0000; mach_vm_protect(task, (mach_vm_address_t) addr, sizeof(uint32_t), false, @@ -115,7 +113,6 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT { return false; } -#ifdef __APPLE__ bool Break() noexcept override { task_read_t task; task_for_pid(mach_task_self(), mPid, &task); @@ -144,7 +141,6 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT { return kr = KERN_SUCCESS; } -#endif private: ProcessID mPid{0}; @@ -154,4 +150,4 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT { #endif // DK_MACH_DEBUGGER -#endif // NECTAR_DEBUGGERKIT_POSIXMACHCONTRACT_H +#endif // NECTAR_DEBUGGERKIT_MACHCONTRACT_H diff --git a/include/DebuggerKit/NeKernelContract.h b/include/DebuggerKit/NeSystem.h index 470da46..a0f3c39 100644 --- a/include/DebuggerKit/NeKernelContract.h +++ b/include/DebuggerKit/NeSystem.h @@ -13,28 +13,28 @@ #ifdef DK_NEKERNEL_DEBUGGER #include <CompilerKit/Detail/Config.h> -#include <DebuggerKit/DebuggerContract.h> +#include <DebuggerKit/IDebugger.h> namespace DebuggerKit::NeKernel { -class NeKernelContract; +class NeSystemDebugger; /// =========================================================== /// /// \brief NeKernel Debugger Contract /// \author Amlal El Mahrouss /// =========================================================== /// -class NeKernelContract final DK_DEBUGGER_CONTRACT { +class NeSystemDebugger DK_DEBUGGER_CONTRACT { public: - NeKernelContract(); - virtual ~NeKernelContract() override; + NeSystemDebugger(); + virtual ~NeSystemDebugger() override; public: - NeKernelContract& operator=(const NeKernelContract&) = default; - NeKernelContract(const NeKernelContract&) = default; + NeSystemDebugger& operator=(const NeSystemDebugger&) = default; + NeSystemDebugger(const NeSystemDebugger&) = default; public: - bool Attach(CompilerKit::STLString path, CompilerKit::STLString arg_v, + bool Attach(const CompilerKit::STLString& path, const CompilerKit::STLString& arg_v, ProcessID& pid) noexcept override; - bool BreakAt(CompilerKit::STLString symbol) noexcept override; + bool BreakAt(const CompilerKit::STLString& symbol) noexcept override; bool Break() noexcept override; bool Continue() noexcept override; bool Detach() noexcept override; diff --git a/include/DebuggerKit/POSIX.h b/include/DebuggerKit/POSIX.h new file mode 100644 index 0000000..47f6abb --- /dev/null +++ b/include/DebuggerKit/POSIX.h @@ -0,0 +1,115 @@ +// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (See accompanying +// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0) +// Official repository: https://github.com/ne-foss-org/nectar + +#ifndef NECTAR_DEBUGGERKIT_MACHCONTRACT_H +#define NECTAR_DEBUGGERKIT_MACHCONTRACT_H + +#ifdef DK_MACH_DEBUGGER + +/// @file POSIXDebugger.h +/// @brief POSIX Mach debugger. + +#include <DebuggerKit/IDebugger.h> +#include <sys/ptrace.h> +#include <filesystem> +#include <vector> + +#define PTRACE_ATTACH PT_ATTACH +#define PTRACE_DETACH PT_DETACH +#define PTRACE_POKETEXT PT_WRITE_I +#define PTRACE_CONT PT_CONTINUE +#define PTRACE_PEEKTEXT PT_READ_I + +namespace DebuggerKit::POSIX { +/// =========================================================== /// +/// \brief POSIXDebugger engine class in C++ +/// \author Amlal El Mahrouss +/// =========================================================== /// +class POSIXDebugger DK_DEBUGGER_CONTRACT { + public: + explicit POSIXDebugger() = default; + ~POSIXDebugger() override = default; + + public: + POSIXDebugger& operator=(const POSIXDebugger&) = default; + POSIXDebugger(const POSIXDebugger&) = default; + + public: + bool Attach(const CompilerKit::STLString& path, const CompilerKit::STLString& argv, + ProcessID& pid) noexcept override { + pid = fork(); + + if (pid == 0) { + if (argv.empty()) { + ptrace(PT_TRACE_ME, 0, nullptr, 0); + kill(getpid(), SIGSTOP); + } + + std::vector<char*> argv_arr; + + argv_arr.push_back(const_cast<char*>(path.c_str())); + argv_arr.push_back(const_cast<char*>(argv.c_str())); + argv_arr.push_back(nullptr); + + execv(path.c_str(), argv_arr.data()); + + _exit(1); + } + + m_path = path; + mPid = pid; + + pid = this->mPid; + + return true; + } + + void SetPath(const CompilerKit::STLString& path) noexcept { + if (path.empty()) { + return; + } + + m_path = path; + } + + bool BreakAt(const CompilerKit::STLString& symbol) noexcept override { + if (!m_path.empty() && std::filesystem::exists(m_path) && + std::filesystem::is_regular_file(m_path)) { + auto handle = dlopen(m_path.c_str(), RTLD_LAZY); + + if (handle == nullptr) { + return false; + } + + auto addr = dlsym(handle, symbol.c_str()); + + if (addr == nullptr) { + return false; + } + + return true; + } + + return false; + } + + bool Break() noexcept override { return false; } + + bool Continue() noexcept override { return false; } + + bool Detach() noexcept override { + this->Continue(); + return false; + } + + private: + ProcessID mPid{0}; + CompilerKit::STLString m_path; +}; +} // namespace DebuggerKit::POSIX + +#endif // DK_MACH_DEBUGGER + +#endif // NECTAR_DEBUGGERKIT_MACHCONTRACT_H diff --git a/include/GenericsLibrary/algorithm.nhh b/include/GenericsLibrary/algorithm.nhh index 5d1bc32..e339ba1 100644 --- a/include/GenericsLibrary/algorithm.nhh +++ b/include/GenericsLibrary/algorithm.nhh @@ -9,9 +9,9 @@ //@ Free algorithm functions for GenericsLibrary. -let for_each(let iterator_instance, let action) +let for_each(let it, let action) { - for (let i := iterator_instance.begin(); i != iterator_instance.end(); i += 1) + for (let i := it.begin(); i !== it.end(); i += 1) { action(i); } @@ -19,9 +19,9 @@ let for_each(let iterator_instance, let action) return; } -let find(let iterator_instance, let predicate) +let find(let it, let predicate) { - for (let i := iterator_instance.begin(); i != iterator_instance.end(); i += 1) + for (let i := it.begin(); i !== it.end(); i += 1) { if (predicate(i)) { @@ -29,15 +29,18 @@ let find(let iterator_instance, let predicate) } } - return -1; + return 1; } let remove(let it, let pred) { - for (let i = it.begin(); i != i != it.end(); ++i) + for (let i = it.begin(); i !== it.end(); ++i) { if (pred(i)) - return 0; + { + i = 0; + return 0; + } } return 1; diff --git a/include/GenericsLibrary/fstream.nhh b/include/GenericsLibrary/fstream.nhh index 4808dd8..441b686 100644 --- a/include/GenericsLibrary/fstream.nhh +++ b/include/GenericsLibrary/fstream.nhh @@ -22,27 +22,15 @@ trait fstream_traits //@ Implementation of fstream traits. impl fstream : trait fstream_traits { - let init() + let write(let self, let data, let size) { - return; - } - - let dispose() - { - return; - } - - let write(let data, let size) - { - let written := __traits_write(fd_, data, size); - + let written := __traits_write(self.fd_, data, size); return written; } - let read(let region, let size) + let read(let self, let data, let size) { - let readen := __traits_read(fd_, region, size); - + let readen := __traits_read(self.fd_, data, size); return readen; } }; diff --git a/include/GenericsLibrary/io.nhh b/include/GenericsLibrary/io.nhh index 25bc561..b946db2 100644 --- a/include/GenericsLibrary/io.nhh +++ b/include/GenericsLibrary/io.nhh @@ -7,14 +7,14 @@ #ifndef NECTAR_GL_IO_NHH #define NECTAR_GL_IO_NHH -import ncl_printf; +import core_print_format_ln; const writefn(let fmt, let args) { - if (fmt := 0) + if (fmt === 0) return; - ncl_printf(fmt, {args}); + core_print_format_ln(fmt, {args}); } #endif diff --git a/include/GenericsLibrary/iterator.nhh b/include/GenericsLibrary/iterator.nhh index e509bc2..f2d46e0 100644 --- a/include/GenericsLibrary/iterator.nhh +++ b/include/GenericsLibrary/iterator.nhh @@ -24,38 +24,26 @@ trait iterator_traits impl iterator : trait iterator_traits { - let init() + let begin(let self) { - return 0; - } - - let dispose() - { - return 0; - } - - let begin() - { - must_pass(_begin != _end); + must_pass(self._begin !== self._end); - let end := _begin; - return end; + let begin := self._begin; + return begin; } - let end() + let end(let self) { - must_pass(_begin != _end); + must_pass(_begin !== _end); - let end :=_begin; - end += _end; - + let end := self._end; return end; } - let size() + let size(let self) { - must_pass(_size > 0); - return _size; + must_pass(self._size > 0); + return self._size; } }; diff --git a/include/GenericsLibrary/math.nhh b/include/GenericsLibrary/math.nhh index a93020e..76813b9 100644 --- a/include/GenericsLibrary/math.nhh +++ b/include/GenericsLibrary/math.nhh @@ -4,8 +4,8 @@ // file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0) // Official repository: https://github.com/ne-foss-org/nectar -#ifndef NECTAR_GL_FUNCTIONS_NHH -#define NECTAR_GL_FUNCTIONS_NHH +#ifndef NECTAR_GL_MATHS_NHH +#define NECTAR_GL_MATHS_NHH //@ Free math functions for GenericsLibrary. @@ -82,4 +82,4 @@ let sign(let value) } } -#endif //@ NECTAR_GL_FUNCTIONS_NHH
\ No newline at end of file +#endif //@ NECTAR_GL_MATHS_NHH
\ No newline at end of file diff --git a/include/GenericsLibrary/pstd.nhh b/include/GenericsLibrary/pstd.nhh index b8ac7ce..68154bd 100644 --- a/include/GenericsLibrary/pstd.nhh +++ b/include/GenericsLibrary/pstd.nhh @@ -17,16 +17,16 @@ extern __nrt_pthread_kill; //@ Parallel free let pfree_bytes(let ptr) { - if (ptr := 0) return 0; + if (ptr === 0) return 0; return __nrt_pfree(ptr); } //@ Parallel alloc (bytes) let palloc_bytes(let type, let sz, let align := 0) { - if (0 := align) return 0; - if (0 := type) return 0; - if (0 := sz) return 0; + if (0 !== align) return 0; + if (0 !== type) return 0; + if (0 !== sz) return 0; return __nrt_palloc(type, sz, align); } diff --git a/include/GenericsLibrary/nrt.nc b/include/GenericsLibrary/start.nhh index 6a39808..c678e7f 100644 --- a/include/GenericsLibrary/nrt.nc +++ b/include/GenericsLibrary/start.nhh @@ -4,12 +4,16 @@ // file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0) // Official repository: https://github.com/ne-foss-org/nectar +#pragma once + extern main; +import argc; +import argv; //@ The main entrypoint is an external symbol defined by the user program. //@ You may also define it as a library and then write your own main wrapper over it. let _start() { - return main(); + return main(argc, argv); } diff --git a/include/GenericsLibrary/std.nhh b/include/GenericsLibrary/std.nhh index 0727269..850ed4b 100644 --- a/include/GenericsLibrary/std.nhh +++ b/include/GenericsLibrary/std.nhh @@ -6,25 +6,25 @@ #pragma once -#define PALLOC_INVALID 0 - extern __nrt_alloc; extern __nrt_free; -//@ Parallel free +/// Installs an error canary to catch any exceptions coming from C++ or Nectar. +#define try if (__nsan_install_error_canary() :== 0): + +//@ Standard free let free_bytes(let ptr) { - if (ptr := 0) return 0; + if (ptr === 0) return 0; return __nrt_free(ptr); } -//@ Parallel alloc (bytes) +//@ Standard alloc (bytes) let alloc_bytes(let type, let sz, let align := 0) { - if (0 := align) return 0; - if (0 := type) return 0; - if (0 := sz) return 0; + if (0 !== align) return 0; + if (0 !== type) return 0; + if (0 !== sz) return 0; return __nrt_alloc(type, sz, align); } - |
