mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
I was coding earlier this week, but my brain was so foggy I ended up not knowing what I was doing. After a few days break, I've cleaned up the mess, which took hours. Changes: * Variables can be assigned * Added new value types as placeholders * Added 'compare' and 'assign' to the AST * Added duplicate opcode * Added functions to copy and free values * Max name length is 255 chars * Compound assigns are squeezed into one word To be completed: * Tests for this commit's changes * Compound assignments * Variable access
29 lines
644 B
Plaintext
29 lines
644 B
Plaintext
TOY_OPCODE_DECLARE:
|
|
{Declare, type, length, 0} ; {emitString()}
|
|
|
|
# write value
|
|
TOY_OPCODE_READ:
|
|
null -> {Read, type, 0, 0}
|
|
bool -> {Read, type, value, 0}
|
|
int -> {Read, type, 0, 0} ; {value}
|
|
float -> {Read, type, 0, 0} ; {value}
|
|
string -> {Read, type, leaf, 0} ; {emitString()}
|
|
|
|
# write assignment
|
|
TOY_AST_FLAG_ASSIGN:
|
|
{Read, type(string), name, length} ;
|
|
{emitString()} ;
|
|
{writeCode()} ;
|
|
{Assign, 0, 0, 0} ;
|
|
|
|
TOY_AST_FLAG_ADD_ASSIGN:
|
|
{Read, type(string), name, length} ;
|
|
{emitString()} ;
|
|
{Duplicate, 0, 0, 0} ;
|
|
{writeCode()} ;
|
|
{Assign, 0, 0, 0}
|
|
{Add, Assign, 0, 0} ;
|
|
|
|
//subtract, multiply, divide, modulo all mimic add
|
|
|