-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
5b17c5e
commit 3148a56
Showing
17 changed files
with
654 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.