diff options
| author | hachem <im@hachem.wtf> | 2026-09-09 05:43:06 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-09 05:43:06 +0200 |
| commit | bf3bd19f79936fa519a5285701763da58935592a (patch) | |
| tree | 9f854e50405a6fabd28d783232360c2c0b26e2f9 /src/ast.h | |
| parent | 8b76d35b0a045e0a3277be422513b938ef33dcce (diff) | |
refactor: split code gen into arch seam
Diffstat (limited to 'src/ast.h')
| -rw-r--r-- | src/ast.h | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -118,6 +118,7 @@ enum StatementKind STATEMENT_WHILE, STATEMENT_CALL, STATEMENT_STACK, + STATEMENT_INSTRUCTION, }; struct AssignStatement @@ -175,6 +176,17 @@ struct StackStatement struct Expr* size; }; +// a bare instruction: a mnemonic and its operands emitted verbatim, the escape +// hatch for anything outside the assignment / control-flow model (int, hlt, +// lgdt, in/out, ...) +struct InstructionStatement +{ + struct Token mnemonic; + struct Expr** operands; + size_t operand_count; + size_t operand_capacity; +}; + struct Statement { enum StatementKind kind; @@ -187,6 +199,7 @@ struct Statement struct WhileStatement loop; struct CallStatement call; struct StackStatement stack; + struct InstructionStatement instruction; }; }; @@ -202,12 +215,22 @@ struct ProcDecl size_t body_capacity; }; +enum OutputFormat +{ + OUTPUT_ELF, + OUTPUT_BIN, +}; + struct Config { uint32_t bits; bool has_entry; struct Token entry; bool logical_registers; + enum OutputFormat format; + bool has_org; + struct Token org; + bool boot; }; struct Program |
