summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
index 63deddc..f395f6c 100644
--- a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
+++ b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
@@ -22,6 +22,7 @@
#include <CompilerKit/PEF.h>
#include <CompilerKit/UUID.h>
#include <CompilerKit/Utilities/Compiler.h>
+#include "CompilerKit/Detail/Config.h"
/* NeKernel NECTAR Compiler Driver. */
/* This is part of the CompilerKit. */
@@ -363,10 +364,14 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
auto tmp = left.substr(0, left.find(op.first));
- kStdOut << tmp << "\n";
+ while (right.find(" ") != CompilerKit::STLString::npos)
+ tmp.erase(tmp.find(" "), 1);
+
+ while (right.find(" ") != CompilerKit::STLString::npos)
+ right.erase(right.find(" "), 1);
if (auto var = nectar_find_variable(tmp); var) {
- syntax_tree.fUserValue += "mov rdi, qword " + var->fRegister + "\n";
+ syntax_tree.fUserValue += "mov rdi, qword [rbp+" + std::to_string(-var->fStackOffset) + "]\n";
delete var;
} else {
if (!isnumber(tmp[0])) {
@@ -376,10 +381,8 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
syntax_tree.fUserValue += "mov rdi, " + tmp + "\n";
}
- kStdOut << right << "\n";
-
if (auto var = nectar_find_variable(right); var) {
- syntax_tree.fUserValue += "mov rsi, qword " + var->fRegister + "\n";
+ syntax_tree.fUserValue += "mov rsi, qword [rbp+" + std::to_string(-var->fStackOffset) + "]\n";
delete var;
}
@@ -544,11 +547,6 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
// Pop function scope
nectar_pop_scope();
- // Clear function-local state
- if (kFunctionEmbedLevel < 1) {
- kContext.fVariables.clear();
- }
-
break;
}
case CompilerKit::KeywordKind::kKeywordKindDelete: {
@@ -1677,7 +1675,7 @@ NECTAR_MODULE(CompilerNectarAMD64) {
CompilerKit::STLString err = "Unknown option: ";
err += argv[index];
- CompilerKit::Detail::print_error(err, "necdrv");
+ CompilerKit::Detail::print_error(err, "NectarDriver");
continue;
}