diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-08 16:56:35 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-08 16:56:35 +0100 |
| commit | f8f2153b6b859dee35192f237d292e75c0a4cd76 (patch) | |
| tree | dc6653957315777d50200cddabcdd7a8661a3ab0 | |
| parent | dd72dcbd5d07a9b4a2f735765233e2cc5faa7849 (diff) | |
chore: Starting writing Nectar implementation, specs in progress.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc | 11 | ||||
| -rw-r--r-- | test/test_samples/ostream.ncpp | 9 | ||||
| -rw-r--r-- | test/test_samples/sample.asm | 7 | ||||
| -rw-r--r-- | test/test_samples/sample.cc | 24 | ||||
| -rw-r--r-- | test/test_samples/sample.ncpp | 11 |
5 files changed, 25 insertions, 37 deletions
diff --git a/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc b/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc index 35d6407..18f0931 100644 --- a/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc +++ b/src/CompilerKit/src/Compilers/CPlusPlusCompiler+AMD64.cc @@ -251,7 +251,7 @@ static std::size_t kNamespaceEmbedLevel{}; /// detail namespaces const char* CompilerFrontendCPlusPlusAMD64::Language() { - return "Nectar C++"; + return "Nectar"; } static std::uintptr_t kOrigin = kPefBaseOrigin; @@ -756,7 +756,7 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile( for (auto pairRight : kRegisterMap) { ++indexRight; - if (pairRight != varName) { + if (pairRight.ends_with(varName)) { syntax_tree.fUserValue += instr + kRegisterList[kRegisterMap.size()] + ", " + valueOfVar + "\n"; kOrigin += 1UL; @@ -1452,7 +1452,7 @@ class AssemblyCPlusPlusInterfaceAMD64 final CK_ASSEMBLY_INTERFACE { ///////////////////////////////////////////////////////////////////////////////////////// -#define kExtListCxx {".cpp", ".cc", ".cc", ".c++", ".cp", ".ipp", ".i++"} +#define kExtListCxx {".ncpp"} NECTAR_MODULE(CompilerCPlusPlusAMD64) { bool skip = false; @@ -1461,14 +1461,13 @@ NECTAR_MODULE(CompilerCPlusPlusAMD64) { kKeywords.emplace_back("else", CompilerKit::KeywordKind::kKeywordKindElse); kKeywords.emplace_back("else if", CompilerKit::KeywordKind::kKeywordKindElseIf); - kKeywords.emplace_back("class", CompilerKit::KeywordKind::kKeywordKindClass); kKeywords.emplace_back("struct", CompilerKit::KeywordKind::kKeywordKindClass); - kKeywords.emplace_back("namespace", CompilerKit::KeywordKind::kKeywordKindNamespace); kKeywords.emplace_back("typedef", CompilerKit::KeywordKind::kKeywordKindTypedef); kKeywords.emplace_back("using", CompilerKit::KeywordKind::kKeywordKindTypedef); + kKeywords.emplace_back("alias", CompilerKit::KeywordKind::kKeywordKindTypedef); kKeywords.emplace_back("{", CompilerKit::KeywordKind::kKeywordKindBodyStart); kKeywords.emplace_back("}", CompilerKit::KeywordKind::kKeywordKindBodyEnd); - kKeywords.emplace_back("auto", CompilerKit::KeywordKind::kKeywordKindType); + kKeywords.emplace_back("let", CompilerKit::KeywordKind::kKeywordKindType); kKeywords.emplace_back("int", CompilerKit::KeywordKind::kKeywordKindType); kKeywords.emplace_back("bool", CompilerKit::KeywordKind::kKeywordKindType); kKeywords.emplace_back("unsigned", CompilerKit::KeywordKind::kKeywordKindType); diff --git a/test/test_samples/ostream.ncpp b/test/test_samples/ostream.ncpp new file mode 100644 index 0000000..8f0248f --- /dev/null +++ b/test/test_samples/ostream.ncpp @@ -0,0 +1,9 @@ +#import <stdio.h> + +struct ostream +{ + void write(int& val) + { + printf("%i", val); + } +}; diff --git a/test/test_samples/sample.asm b/test/test_samples/sample.asm deleted file mode 100644 index 72b1a46..0000000 --- a/test/test_samples/sample.asm +++ /dev/null @@ -1,7 +0,0 @@ -%bits 64 -%org 0x40000000 - -public_segment .code64 __ImageStart - mov rax, 5 - ret - diff --git a/test/test_samples/sample.cc b/test/test_samples/sample.cc deleted file mode 100644 index 038f487..0000000 --- a/test/test_samples/sample.cc +++ /dev/null @@ -1,24 +0,0 @@ -class ostream -{ - ostream() - { - return void; - } - - ~ostream() - { - return void; - } - - ostream& write(const char* buf, const long sz) - { - return *this; - } -}; - -int main() -{ - ostream* f = new ostream(); - f->write("foo", 3); - return 0; -} diff --git a/test/test_samples/sample.ncpp b/test/test_samples/sample.ncpp new file mode 100644 index 0000000..241f69e --- /dev/null +++ b/test/test_samples/sample.ncpp @@ -0,0 +1,11 @@ +#import "ostream.ncpp" + +int main(void) +{ + ostream s; + let six_seven = 67; + + s.write(six_seven); + + return 0; +} |
