summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-02-10 14:57:41 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-02-10 14:57:41 +0100
commit3a65785e51c1986072478f2d4e69ba2e4eb791c9 (patch)
tree196ad054735e425b360da6afe9ddb02d028d300b
parent9bb4bd31d8dc8347285a523ce2bff8bf8dbad370 (diff)
chore: codebase improvements and tweaks.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--include/CompilerKit/Utilities/Compiler.h4
-rw-r--r--src/CompilerKit/ck-osx-san.json2
-rw-r--r--src/CompilerKit/ck-osx.json2
-rw-r--r--src/CompilerKit/ck-posix.json2
-rw-r--r--src/CompilerKit/src/Assemblers/Assembler+ARM64.cc12
-rw-r--r--src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc46
-rw-r--r--src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc2
-rw-r--r--src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cc2
-rw-r--r--src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc9
9 files changed, 41 insertions, 40 deletions
diff --git a/include/CompilerKit/Utilities/Compiler.h b/include/CompilerKit/Utilities/Compiler.h
index cd28567..ca577db 100644
--- a/include/CompilerKit/Utilities/Compiler.h
+++ b/include/CompilerKit/Utilities/Compiler.h
@@ -65,7 +65,7 @@ inline void print_warning(STLString reason, STLString file) noexcept {
/// @internal
/// @brief Handler for SIGSEGV signal.
inline void drvi_crash_handler(std::int32_t id) {
- CompilerKit::STLString verbose_header = "COMPILERKIT CRASH REPORT - ";
+ CompilerKit::STLString verbose_header = "NECTAR CRASH REPORT - ";
verbose_header += kDistVersion;
verbose_header += " - ";
verbose_header += CompilerKit::current_date();
@@ -91,7 +91,7 @@ inline void drvi_crash_handler(std::int32_t id) {
switch (id) {
default: {
- kStdOut << "SIGNAL: Signal (" << id << ")." << kBlank << std::endl;
+ kStdOut << "SIGNAL: (" << id << ")." << kBlank << std::endl;
break;
}
}
diff --git a/src/CompilerKit/ck-osx-san.json b/src/CompilerKit/ck-osx-san.json
index b477c42..e133ebf 100644
--- a/src/CompilerKit/ck-osx-san.json
+++ b/src/CompilerKit/ck-osx-san.json
@@ -27,5 +27,5 @@
"CK_USE_STRUCTS=1",
"kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
],
- "description": "CompilerKit for OSX, with Asan/Ubsan."
+ "description": "CompilerKit for OSX, with Asan/Ubsan. CK is the framework behind Nectar."
}
diff --git a/src/CompilerKit/ck-osx.json b/src/CompilerKit/ck-osx.json
index 88e6a5b..a4f711d 100644
--- a/src/CompilerKit/ck-osx.json
+++ b/src/CompilerKit/ck-osx.json
@@ -23,5 +23,5 @@
"CK_USE_MACHO_LINKER=1",
"kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
],
- "description": "CompilerKit for OSX."
+ "description": "CompilerKit for OSX. CK is the framework behind Nectar."
}
diff --git a/src/CompilerKit/ck-posix.json b/src/CompilerKit/ck-posix.json
index c8c561d..264a4a6 100644
--- a/src/CompilerKit/ck-posix.json
+++ b/src/CompilerKit/ck-posix.json
@@ -21,6 +21,6 @@
"CK_USE_STRUCTS=1",
"kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
],
- "description": "CompilerKit for POSIX."
+ "description": "CompilerKit for POSIX. CK is the framework behind Nectar."
}
diff --git a/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc b/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc
index fa41e6d..bf567b7 100644
--- a/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc
+++ b/src/CompilerKit/src/Assemblers/Assembler+ARM64.cc
@@ -72,13 +72,13 @@ NECTAR_MODULE(AssemblerMainARM64) {
for (size_t i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "-v") == 0) {
- kStdOut << "AssemblerPower: AARCH64 Assembler Driver.\nAssemblerPower: " << kDistVersion
- << "\nAssemblerPower: "
+ kStdOut << "ACORN: AARCH64 Assembler Driver.\nACORN: " << kDistVersion
+ << "\nACORN: "
"Copyright (c) "
"Amlal El Mahrouss\n";
return 0;
} else if (strcmp(argv[i], "-help") == 0) {
- kStdOut << "AssemblerPower: AARCH64 Assembler Driver.\nAssemblerPower: Copyright (c) 2024 "
+ kStdOut << "ACORN: AARCH64 Assembler Driver.\nACORN: Copyright (c) 2024 "
"Amlal El Mahrouss\n";
kStdOut << "-version,--v: print program version.\n";
kStdOut << "-fverbose: print verbose output.\n";
@@ -93,12 +93,12 @@ NECTAR_MODULE(AssemblerMainARM64) {
continue;
}
- kStdOut << "AssemblerPower: ignore " << argv[i] << "\n";
+ kStdOut << "ACORN: ignore " << argv[i] << "\n";
continue;
}
if (!std::filesystem::exists(argv[i])) {
- kStdOut << "AssemblerPower: can't open: " << argv[i] << std::endl;
+ kStdOut << "ACORN: can't open: " << argv[i] << std::endl;
goto asm_fail_exit;
}
@@ -117,7 +117,7 @@ NECTAR_MODULE(AssemblerMainARM64) {
if (file_ptr_out.bad()) {
if (kVerbose) {
- kStdOut << "AssemblerPower: error: " << strerror(errno) << "\n";
+ kStdOut << "ACORN: error: " << strerror(errno) << "\n";
}
}
diff --git a/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc b/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc
index cbf3425..438bea0 100644
--- a/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc
+++ b/src/CompilerKit/src/Assemblers/Assembler+PowerPC.cc
@@ -72,13 +72,13 @@ NECTAR_MODULE(AssemblerMainPower64) {
for (size_t i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "-v") == 0) {
- kStdOut << "AssemblerPower: POWER64 Assembler Driver.\nAssemblerPower: " << kDistVersion
- << "\nAssemblerPower: "
+ kStdOut << "POWER: POWER64 Assembler Driver.\nPOWER: " << kDistVersion
+ << "\nPOWER: "
"Copyright (c) "
"Amlal El Mahrouss\n";
return 0;
} else if (strcmp(argv[i], "-h") == 0) {
- kStdOut << "AssemblerPower: POWER64 Assembler Driver.\nAssemblerPower: Copyright (c) 2024 "
+ kStdOut << "POWER: POWER64 Assembler Driver.\nPOWER: Copyright (c) 2024 "
"Amlal El Mahrouss\n";
kStdOut << "-version,-v: print program version.\n";
kStdOut << "-fverbose: print verbose output.\n";
@@ -93,12 +93,12 @@ NECTAR_MODULE(AssemblerMainPower64) {
continue;
}
- kStdOut << "AssemblerPower: ignore " << argv[i] << "\n";
+ kStdOut << "POWER: ignore " << argv[i] << "\n";
continue;
}
if (!std::filesystem::exists(argv[i])) {
- kStdOut << "AssemblerPower: can't open: " << argv[i] << std::endl;
+ kStdOut << "POWER: can't open: " << argv[i] << std::endl;
goto asm_fail_exit;
}
@@ -117,7 +117,7 @@ NECTAR_MODULE(AssemblerMainPower64) {
if (file_ptr_out.bad()) {
if (kVerbose) {
- kStdOut << "AssemblerPower: error: " << strerror(errno) << "\n";
+ kStdOut << "POWER: error: " << strerror(errno) << "\n";
}
}
@@ -163,7 +163,7 @@ NECTAR_MODULE(AssemblerMainPower64) {
if (!kOutputAsBinary) {
if (kVerbose) {
- kStdOut << "AssemblerPower: Writing object file...\n";
+ kStdOut << "POWER: Writing object file...\n";
}
// this is the final step, write everything to the file.
@@ -175,8 +175,8 @@ NECTAR_MODULE(AssemblerMainPower64) {
file_ptr_out << hdr;
if (kRecords.empty()) {
- kStdErr << "AssemblerPower: At least one record is needed to write an object "
- "file.\nAssemblerPower: Make one using `public_segment .code64 foo_bar`.\n";
+ kStdErr << "POWER: At least one record is needed to write an object "
+ "file.\nPOWER: Make one using `public_segment .code64 foo_bar`.\n";
std::filesystem::remove(object_output);
return 1;
@@ -193,7 +193,7 @@ NECTAR_MODULE(AssemblerMainPower64) {
file_ptr_out << record_hdr;
- if (kVerbose) kStdOut << "AssemblerPower: Wrote record " << record_hdr.fName << "...\n";
+ if (kVerbose) kStdOut << "POWER: Wrote record " << record_hdr.fName << "...\n";
}
// increment once again, so that we won't lie about the kUndefinedSymbols.
@@ -202,7 +202,7 @@ NECTAR_MODULE(AssemblerMainPower64) {
for (auto& sym : kUndefinedSymbols) {
CompilerKit::AERecordHeader undefined_sym{0};
- if (kVerbose) kStdOut << "AssemblerPower: Wrote symbol " << sym << " to file...\n";
+ if (kVerbose) kStdOut << "POWER: Wrote symbol " << sym << " to file...\n";
undefined_sym.fKind = kAENullType;
undefined_sym.fSize = sym.size();
@@ -230,7 +230,7 @@ NECTAR_MODULE(AssemblerMainPower64) {
file_ptr_out.seekp(pos_end);
} else {
if (kVerbose) {
- kStdOut << "AssemblerPower: Write raw binary...\n";
+ kStdOut << "POWER: Write raw binary...\n";
}
}
@@ -239,19 +239,19 @@ NECTAR_MODULE(AssemblerMainPower64) {
file_ptr_out.write(reinterpret_cast<const char*>(&byte), sizeof(byte));
}
- if (kVerbose) kStdOut << "AssemblerPower: Wrote file with program in it.\n";
+ if (kVerbose) kStdOut << "POWER: Wrote file with program in it.\n";
file_ptr_out.flush();
file_ptr_out.close();
- if (kVerbose) kStdOut << "AssemblerPower: Exit succeeded.\n";
+ if (kVerbose) kStdOut << "POWER: Exit succeeded.\n";
return 0;
}
asm_fail_exit:
- if (kVerbose) kStdOut << "AssemblerPower: Exit failed.\n";
+ if (kVerbose) kStdOut << "POWER: Exit failed.\n";
return NECTAR_EXEC_ERROR;
}
@@ -323,7 +323,7 @@ static bool asm_read_attributes(std::string line) {
return true;
}
- // public_segment is a special keyword used by AssemblerPower to tell the AE output stage to
+ // public_segment is a special keyword used by POWER to tell the AE output stage to
// mark this section as a header. it currently supports .code64, .data64.,
// .zero64
else if (CompilerKit::ast_find_needle(line, "public_segment")) {
@@ -529,7 +529,7 @@ bool CompilerKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
}
if (kVerbose) {
- kStdOut << "AssemblerPower: found a base 16 number here: " << jump_label.substr(pos)
+ kStdOut << "POWER: found a base 16 number here: " << jump_label.substr(pos)
<< "\n";
}
@@ -546,7 +546,7 @@ bool CompilerKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
if (kVerbose) {
- kStdOut << "AssemblerPower: found a base 2 number here: " << jump_label.substr(pos) << "\n";
+ kStdOut << "POWER: found a base 2 number here: " << jump_label.substr(pos) << "\n";
}
for (char& i : num.number) {
@@ -566,7 +566,7 @@ bool CompilerKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
if (kVerbose) {
- kStdOut << "AssemblerPower: found a base 8 number here: " << jump_label.substr(pos) << "\n";
+ kStdOut << "POWER: found a base 8 number here: " << jump_label.substr(pos) << "\n";
}
for (char& i : num.number) {
@@ -594,7 +594,7 @@ bool CompilerKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
}
if (kVerbose) {
- kStdOut << "AssemblerPower: found a base 10 number here: " << jump_label.substr(pos) << "\n";
+ kStdOut << "POWER: found a base 10 number here: " << jump_label.substr(pos) << "\n";
}
return true;
@@ -808,8 +808,8 @@ bool CompilerKit::EncoderPowerPC::WriteLine(std::string line, std::string file)
}
if (kVerbose) {
- kStdOut << "AssemblerPower: Found register: " << register_syntax << "\n";
- kStdOut << "AssemblerPower: Amount of registers in instruction: "
+ kStdOut << "POWER: Found register: " << register_syntax << "\n";
+ kStdOut << "POWER: Amount of registers in instruction: "
<< found_some_count << "\n";
}
@@ -875,7 +875,7 @@ bool CompilerKit::EncoderPowerPC::WriteLine(std::string line, std::string file)
// remember! register to register!
if (found_some_count == 1) {
CompilerKit::Detail::print_error(
- "Unrecognized register found.\ntip: each AssemblerPower register "
+ "Unrecognized register found.\ntip: each POWER register "
"starts with 'r'.\nline: " +
line,
file);
diff --git a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
index 62022ba..5b246f2 100644
--- a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
+++ b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
@@ -1029,7 +1029,7 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
for (const auto& keyword : kKeywords) {
if (keyword.fKeywordName == subText)
- CompilerKit::Detail::print_error("A Nectar keyword cannot be called.", file);
+ CompilerKit::Detail::print_error("A nectar keyword cannot be used there.", file);
}
kExternalSymbols.insert(subText);
diff --git a/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cc b/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cc
index c3bbd9e..42baa58 100644
--- a/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cc
+++ b/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cc
@@ -545,7 +545,7 @@ NECTAR_MODULE(DynamicLinker64MachO) {
}
// Write LC_LOAD_DYLINKER command
- const Char* dyldPath = "/usr/lib/dyld";
+ constexpr Char* dyldPath = "/usr/lib/dyld";
std::vector<Char> dylinkerCmd(dylinkerCmdSize, 0);
dylinker_command* dylinker = reinterpret_cast<dylinker_command*>(dylinkerCmd.data());
dylinker->cmd = LC_LOAD_DYLINKER;
diff --git a/src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc b/src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc
index 78bb548..5cbbba6 100644
--- a/src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc
+++ b/src/CompilerKit/src/Linkers/DynamicLinker64+PEF.cc
@@ -29,6 +29,7 @@
#define kLinkerAbiContainer "__PEFContainer:ABI:"
#define kLinkerGuidContainer "__PEFContainer:GUID:"
+#define kEndContainer "__PEFContainer:END:"
#define kLinkerSplash() kStdOut << kLinkerVersionStr << kStdEndl
@@ -280,7 +281,7 @@ NECTAR_MODULE(DynamicLinker64PEF) {
size_t org = kLinkerDefaultOrigin;
for (size_t ae_record_index = 0; ae_record_index < cnt; ++ae_record_index) {
- CompilerKit::PEFCommandHeader command_header{0};
+ CompilerKit::PEFCommandHeader command_header{{}};
std::size_t offset_of_obj = ae_records[ae_record_index].fOffset;
std::memcpy(command_header.Name, ae_records[ae_record_index].fName, kPefNameLen);
@@ -447,7 +448,7 @@ NECTAR_MODULE(DynamicLinker64PEF) {
time_t timestamp = time(nullptr);
- CompilerKit::STLString timeStampStr = "Container:BuildEpoch:";
+ CompilerKit::STLString timeStampStr = "__PEFContainer:BuildEpoch:";
timeStampStr += std::to_string(timestamp);
strncpy(date_cmd_hdr.Name, timeStampStr.c_str(), timeStampStr.size());
@@ -491,7 +492,7 @@ NECTAR_MODULE(DynamicLinker64PEF) {
command_headers.push_back(std::move(abi_cmd_hdr));
- CompilerKit::PEFCommandHeader stack_cmd_hdr{0};
+ CompilerKit::PEFCommandHeader stack_cmd_hdr{{}};
stack_cmd_hdr.Cpu = kArch;
stack_cmd_hdr.Flags = 0;
@@ -541,7 +542,7 @@ NECTAR_MODULE(DynamicLinker64PEF) {
end_exec_hdr.Flags = CompilerKit::kPefLinkerID;
end_exec_hdr.Kind = CompilerKit::kPefZero;
- std::memcpy(end_exec_hdr.Name, "Container:Exec:END", strlen("Container:Exec:END"));
+ std::memcpy(end_exec_hdr.Name, kEndContainer, strlen(kEndContainer));
end_exec_hdr.VirtualSize = strlen(end_exec_hdr.Name);