mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
This is an incomplete process. It's supposed to be robust enough to support the types of arrays and dictionaries, but arrays and dictionaries aren't implemented in the literals yet, so that's my next task. I'll come back to variable declarations later.
37 lines
614 B
C
37 lines
614 B
C
#pragma once
|
|
|
|
typedef enum Opcode {
|
|
OP_EOF,
|
|
|
|
//basic statements
|
|
OP_ASSERT,
|
|
OP_PRINT,
|
|
|
|
//data
|
|
OP_LITERAL,
|
|
OP_LITERAL_LONG, //for more than 256 literals in a chunk
|
|
|
|
//arithmetic operators
|
|
OP_NEGATE,
|
|
OP_ADDITION,
|
|
OP_SUBTRACTION,
|
|
OP_MULTIPLICATION,
|
|
OP_DIVISION,
|
|
OP_MODULO,
|
|
OP_GROUPING_BEGIN,
|
|
OP_GROUPING_END,
|
|
|
|
//variable stuff
|
|
OP_SCOPE_BEGIN,
|
|
OP_SCOPE_END,
|
|
|
|
OP_TYPE_DECL, //declare a compound type to be used
|
|
OP_VAR_DECL, //stack: literal name, literal type (referenced by array index)
|
|
OP_VAR_ASSIGN, //stack: literal name, literal value
|
|
|
|
//meta
|
|
OP_SECTION_END,
|
|
//TODO: add more
|
|
} Opcode;
|
|
|