From 6154309f0cd3ed5071996951465808f2503e2eb1 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 29 Mar 2020 18:30:04 +0200 Subject: mcc produces first dummy executable --- cpp.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'cpp.cpp') diff --git a/cpp.cpp b/cpp.cpp index 67c76ef..73f11e1 100644 --- a/cpp.cpp +++ b/cpp.cpp @@ -243,18 +243,39 @@ void CPP::link() // phases of translation, according to standard void CPP::translate(const std::string& code) { -#if 0 // fix signatures! source_charset_map(); + backslash_escape(); - preprocessing_tokenize(code); + + auto pp_tokens = preprocessing_tokenize(code); + preprocess(); + execution_charset_map(); + concatenate_strings(); - tokens_from_pptokens(); - analysis(); - translate(); + + auto tokens = tokens_from_pptokens(pp_tokens); + auto nodes = analysis(tokens); + translate(); + instantiate(); + link(); -#endif +} + +std::vector CPP::getCode() +{ + // TODO + return { + 0x48, 0xc7, 0xc0, 0x3c, 0x00, 0x00, 0x00, // mov $0x3c,%rax # syscall 60 + 0x48, 0x31, 0xff, // xor %rdi,%rdi # exit code 0 + 0x0f, 0x05, // syscall + }; +} + +std::vector CPP::getData() +{ + return {}; // TODO } -- cgit v1.2.3