diff options
| -rw-r--r-- | src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc | 45 | ||||
| -rw-r--r-- | test/test_samples/ostream_test.ncpp | 7 |
2 files changed, 10 insertions, 42 deletions
diff --git a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc index 0959103..f774541 100644 --- a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc +++ b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc @@ -706,45 +706,16 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile( subText = subText.erase(subText.find(";")); size_t indxReg = 0UL; - if (subText.ends_with(");")) { - // Check for namespace resolution - if (subText.find("::") != CompilerKit::STLString::npos) { - auto colonPos = subText.find("::"); - auto nsName = subText.substr(0, colonPos); - auto funcPart = subText.substr(colonPos + 2); - - // Trim - while (!nsName.empty() && (nsName.front() == ' ' || nsName.front() == '\t')) { - nsName.erase(0, 1); - } - while (!nsName.empty() && (nsName.back() == ' ' || nsName.back() == '\t')) { - nsName.pop_back(); - } - - // Extract function name - auto funcName = funcPart; - if (funcName.find("(") != CompilerKit::STLString::npos) { - funcName = funcName.substr(0, funcName.find("(")); - } + if (subText.find("(") != CompilerKit::STLString::npos) + subText.erase(subText.find("(")); - // Trim - while (!funcName.empty() && (funcName.front() == ' ' || funcName.front() == '\t')) { - funcName.erase(0, 1); - } + auto ref = nectar_get_variable_ref(subText); - while (!funcName.empty() && (funcName.back() == ' ' || funcName.back() == '\t')) { - funcName.pop_back(); - } - - // Generate mangled name - nectar_push_scope(ScopeKind::kScopeNamespace, nsName); - auto mangled = nectar_mangle_name(funcName); - nectar_pop_scope(); - - kOrigin += 3UL; - break; - } - } + if (ref.empty() == false) + syntax_tree.fUserValue += "mov rax, " + ref + "\n"; + + if (subText.starts_with("'") || isnumber(subText[0])) + syntax_tree.fUserValue += "mov rax, " + subText + "\n"; syntax_tree.fUserValue += nectar_generate_epilogue() + "ret\n"; kOrigin += 2UL; diff --git a/test/test_samples/ostream_test.ncpp b/test/test_samples/ostream_test.ncpp index 130e2d3..69cb70e 100644 --- a/test/test_samples/ostream_test.ncpp +++ b/test/test_samples/ostream_test.ncpp @@ -24,13 +24,10 @@ struct iostream let main() { - let six_seven = 100; - let eight_nine = 1; + let six_seven = 67; let io = iostream{}; - - io.write(eight_nine); six_seven = io.read(); - return 0; + return six_seven; } |
