Renemed all variables to fit into a namespace

Basically, all Toy varaibles, functions, etc. are prepended with "Toy_",
and macros are prepended with "TOY_". This is to reduce namespace
pollution, which was an issue pointed out to be - blame @GyroVorbis.

I've also bumped the minor version number - theoretically I should bump
the major number, but I'm not quite ready for 1.0 yet.
This commit is contained in:
2023-01-25 12:52:07 +00:00
parent 047ccc5f16
commit 2e2bee4fa3
55 changed files with 4837 additions and 4707 deletions

View File

@@ -1,87 +1,87 @@
#pragma once
typedef enum Opcode {
OP_EOF,
typedef enum Toy_Opcode {
TOY_OP_EOF,
//basic statements
OP_ASSERT,
OP_PRINT,
TOY_OP_ASSERT,
TOY_OP_PRINT,
//data
OP_LITERAL,
OP_LITERAL_LONG, //for more than 256 literals in a chunk
OP_LITERAL_RAW, //forcibly get the raw value of the literal
TOY_OP_LITERAL,
TOY_OP_LITERAL_LONG, //for more than 256 literals in a chunk
TOY_OP_LITERAL_RAW, //forcibly get the raw value of the literal
//arithmetic operators
OP_NEGATE,
OP_ADDITION,
OP_SUBTRACTION,
OP_MULTIPLICATION,
OP_DIVISION,
OP_MODULO,
OP_GROUPING_BEGIN,
OP_GROUPING_END,
TOY_OP_NEGATE,
TOY_OP_ADDITION,
TOY_OP_SUBTRACTION,
TOY_OP_MULTIPLICATION,
TOY_OP_DIVISION,
TOY_OP_MODULO,
TOY_OP_GROUPING_BEGIN,
TOY_OP_GROUPING_END,
//variable stuff
OP_SCOPE_BEGIN,
OP_SCOPE_END,
TOY_OP_SCOPE_BEGIN,
TOY_OP_SCOPE_END,
OP_TYPE_DECL, //declare a type to be used (as a literal)
OP_TYPE_DECL_LONG, //declare a type to be used (as a long literal)
TOY_OP_TYPE_DECL, //declare a type to be used (as a literal)
TOY_OP_TYPE_DECL_LONG, //declare a type to be used (as a long literal)
OP_VAR_DECL, //declare a variable to be used (as a literal)
OP_VAR_DECL_LONG, //declare a variable to be used (as a long literal)
TOY_OP_VAR_DECL, //declare a variable to be used (as a literal)
TOY_OP_VAR_DECL_LONG, //declare a variable to be used (as a long literal)
OP_FN_DECL, //declare a function to be used (as a literal)
OP_FN_DECL_LONG, //declare a function to be used (as a long literal)
TOY_OP_FN_DECL, //declare a function to be used (as a literal)
TOY_OP_FN_DECL_LONG, //declare a function to be used (as a long literal)
OP_VAR_ASSIGN, //assign to a literal
OP_VAR_ADDITION_ASSIGN,
OP_VAR_SUBTRACTION_ASSIGN,
OP_VAR_MULTIPLICATION_ASSIGN,
OP_VAR_DIVISION_ASSIGN,
OP_VAR_MODULO_ASSIGN,
TOY_OP_VAR_ASSIGN, //assign to a literal
TOY_OP_VAR_ADDITION_ASSIGN,
TOY_OP_VAR_SUBTRACTION_ASSIGN,
TOY_OP_VAR_MULTIPLICATION_ASSIGN,
TOY_OP_VAR_DIVISION_ASSIGN,
TOY_OP_VAR_MODULO_ASSIGN,
OP_TYPE_CAST, //temporarily change a type of an atomic value
OP_TYPE_OF, //get the type of a variable
TOY_OP_TYPE_CAST, //temporarily change a type of an atomic value
TOY_OP_TYPE_OF, //get the type of a variable
OP_IMPORT,
OP_EXPORT_removed,
TOY_OP_IMPORT,
TOY_OP_EXPORT_removed,
//for indexing
OP_INDEX,
OP_INDEX_ASSIGN,
OP_INDEX_ASSIGN_INTERMEDIATE,
OP_DOT,
TOY_OP_INDEX,
TOY_OP_INDEX_ASSIGN,
TOY_OP_INDEX_ASSIGN_INTERMEDIATE,
TOY_OP_DOT,
//comparison of values
OP_COMPARE_EQUAL,
OP_COMPARE_NOT_EQUAL,
OP_COMPARE_LESS,
OP_COMPARE_LESS_EQUAL,
OP_COMPARE_GREATER,
OP_COMPARE_GREATER_EQUAL,
OP_INVERT, //for booleans
TOY_OP_COMPARE_EQUAL,
TOY_OP_COMPARE_NOT_EQUAL,
TOY_OP_COMPARE_LESS,
TOY_OP_COMPARE_LESS_EQUAL,
TOY_OP_COMPARE_GREATER,
TOY_OP_COMPARE_GREATER_EQUAL,
TOY_OP_INVERT, //for booleans
//logical operators
OP_AND,
OP_OR,
TOY_OP_AND,
TOY_OP_OR,
//jumps, and conditional jumps (absolute)
OP_JUMP,
OP_IF_FALSE_JUMP,
OP_FN_CALL,
OP_FN_RETURN,
TOY_OP_JUMP,
TOY_OP_IF_FALSE_JUMP,
TOY_OP_FN_CALL,
TOY_OP_FN_RETURN,
//pop the stack at the end of a complex statement
OP_POP_STACK,
TOY_OP_POP_STACK,
//ternary shorthand
OP_TERNARY,
TOY_OP_TERNARY,
//meta
OP_FN_END, //different from SECTION_END
OP_SECTION_END = 255,
TOY_OP_FN_END, //different from SECTION_END
TOY_OP_SECTION_END = 255,
//TODO: add more
} Opcode;
} Toy_Opcode;