mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Added simple assignment, read more
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
This commit is contained in:
28
.notes/read-opcode-layout.txt
Normal file
28
.notes/read-opcode-layout.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user