diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-03-29 18:30:04 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-03-29 18:30:04 +0200 |
commit | 6154309f0cd3ed5071996951465808f2503e2eb1 (patch) | |
tree | b1666eea410e859f814ae47ca47b8b2d7d333c50 /cpp.cpp | |
parent | b0cac4997b5767526b29187fecf2a87aa1b0ebef (diff) |
mcc produces first dummy executable
Diffstat (limited to 'cpp.cpp')
-rw-r--r-- | cpp.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
@@ -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<uint8_t> 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<uint8_t> CPP::getData() +{ + return {}; // TODO } |