mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Cleaned up some comments
This commit is contained in:
@@ -14,7 +14,7 @@ First, the main development branch of Toy is 'v2', with the branches 'v1' and 'v
|
||||
|
||||
v2 is a ground-up rewrite, with additions, changes and deletions to the language that make sense. If you want to discuss the direction things are going, the [Discussions Tab](https://github.com/Ratstail91/Toy/discussions) is perfect for that.
|
||||
|
||||
The [Issue Tracker](https://github.com/Ratstail91/Toy/issues) is a good place to see what tasks and issues are currently waiting to be addressed. The [toy.h](https://github.com/Ratstail91/Toy/blob/v2/source/toy.h) source file is a quick way to see what building blocks are available in the source code. There are also a number of comments prepended with `TODO:` scattered throughout the source code, as reminders of planned features.
|
||||
The [Issue Tracker](https://github.com/Ratstail91/Toy/issues) is a good place to see what tasks and issues are currently waiting to be addressed. The [toy.h](https://github.com/Ratstail91/Toy/blob/v2/source/toy.h) source file is a quick way to see what building blocks are available in the source code. There are also a number of comments prepended with `TODO` scattered throughout the source code, as reminders of planned features.
|
||||
|
||||
The [test cases](https://github.com/Ratstail91/Toy/tree/v2/tests/cases), which test individual parts of the code in isolation, can be a good way to see how those parts are used. Likewise, the [REPL](https://github.com/Ratstail91/Toy/tree/v2/repl) shows a practical usage of Toy.
|
||||
|
||||
@@ -33,8 +33,6 @@ graph TB
|
||||
Toy_Array
|
||||
```
|
||||
|
||||
*TODO: Toy_Value will eventually depend on other structures, includeing those shown here, once the related features are implemented in v2.*
|
||||
|
||||
In addition, [toy_common.h](https://github.com/Ratstail91/Toy/blob/v2/source/toy_common.h) grants platform portability and version info, while [toy_console_colors.h](https://github.com/Ratstail91/Toy/blob/v2/source/toy_console_colors.h) provides string constants as macros that help with console output (where supported).
|
||||
|
||||
# Coding Habits
|
||||
|
||||
@@ -251,7 +251,7 @@ static void errorAndExitCallback(const char* msg) {
|
||||
}
|
||||
|
||||
//main file
|
||||
int main(int argc, const char* argv[]) { //TODO: this needs an interactive terminal mode
|
||||
int main(int argc, const char* argv[]) {
|
||||
Toy_setPrintCallback(printCallback);
|
||||
Toy_setErrorCallback(errorAndExitCallback);
|
||||
Toy_setAssertFailureCallback(errorAndExitCallback);
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef enum Toy_AstFlag {
|
||||
TOY_AST_FLAG_MULTIPLY,
|
||||
TOY_AST_FLAG_DIVIDE,
|
||||
TOY_AST_FLAG_MODULO,
|
||||
TOY_AST_FLAG_ASSIGN, //TODO: implement the declare statement
|
||||
TOY_AST_FLAG_ASSIGN,
|
||||
TOY_AST_FLAG_ADD_ASSIGN,
|
||||
TOY_AST_FLAG_SUBTRACT_ASSIGN,
|
||||
TOY_AST_FLAG_MULTIPLY_ASSIGN,
|
||||
@@ -99,7 +99,6 @@ typedef struct Toy_AstPass {
|
||||
|
||||
typedef struct Toy_AstError {
|
||||
Toy_AstType type;
|
||||
//TODO: more data regarding the error
|
||||
} Toy_AstError;
|
||||
|
||||
typedef struct Toy_AstEnd {
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef enum Toy_OpcodeType {
|
||||
//various action instructions
|
||||
TOY_OPCODE_PRINT,
|
||||
TOY_OPCODE_CONCAT,
|
||||
//TODO: clear the program stack
|
||||
//TODO: clear the program stack?
|
||||
|
||||
//meta instructions
|
||||
TOY_OPCODE_PASS,
|
||||
|
||||
@@ -92,7 +92,6 @@ static void emitString(Toy_Routine** rt, Toy_String* str) {
|
||||
static void writeRoutineCode(Toy_Routine** rt, Toy_Ast* ast); //forward declare for recursion
|
||||
|
||||
static void writeInstructionValue(Toy_Routine** rt, Toy_AstValue ast) {
|
||||
//TODO: store more complex values in the data code
|
||||
EMIT_BYTE(rt, code, TOY_OPCODE_READ);
|
||||
EMIT_BYTE(rt, code, ast.value.type);
|
||||
|
||||
@@ -369,7 +368,9 @@ static void* writeRoutine(Toy_Routine* rt, Toy_Ast* ast) {
|
||||
emitInt((void**)&buffer, &capacity, &count, 0); //subs
|
||||
}
|
||||
|
||||
//append various parts to the buffer TODO: add the rest
|
||||
//append various parts to the buffer
|
||||
//TODO: param region
|
||||
|
||||
if (rt->codeCount > 0) {
|
||||
expand(&buffer, &capacity, &count, rt->codeCount);
|
||||
memcpy((buffer + count), rt->code, rt->codeCount);
|
||||
@@ -394,6 +395,8 @@ static void* writeRoutine(Toy_Routine* rt, Toy_Ast* ast) {
|
||||
count += rt->dataCount;
|
||||
}
|
||||
|
||||
//TODO: subs region
|
||||
|
||||
//finally, record the total size within the header, and return the result
|
||||
*((int*)buffer) = count;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "toy_bucket.h"
|
||||
#include "toy_value.h"
|
||||
|
||||
//TODO: Remove this
|
||||
#define TOY_STRING_MAX_LENGTH 1000
|
||||
|
||||
//rope pattern
|
||||
|
||||
@@ -25,7 +25,7 @@ bool Toy_private_isTruthy(Toy_Value value) {
|
||||
bool Toy_private_isEqual(Toy_Value left, Toy_Value right) {
|
||||
//temp check
|
||||
if (right.type > TOY_VALUE_STRING) {
|
||||
Toy_error(TOY_CC_ERROR "ERROR: Unknown types in value equality comparison\n" TOY_CC_RESET); //TODO: varargs
|
||||
Toy_error(TOY_CC_ERROR "ERROR: Unknown types in value equality comparison\n" TOY_CC_RESET);
|
||||
}
|
||||
|
||||
switch(left.type) {
|
||||
@@ -64,7 +64,7 @@ bool Toy_private_isEqual(Toy_Value left, Toy_Value right) {
|
||||
case TOY_VALUE_FUNCTION:
|
||||
case TOY_VALUE_OPAQUE:
|
||||
default:
|
||||
Toy_error(TOY_CC_ERROR "ERROR: Unknown types in value equality comparison\n" TOY_CC_RESET); //TODO: varargs
|
||||
Toy_error(TOY_CC_ERROR "ERROR: Unknown types in value equality comparison\n" TOY_CC_RESET);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -111,7 +111,7 @@ unsigned int Toy_hashValue(Toy_Value value) {
|
||||
return str->cachedHash;
|
||||
}
|
||||
else if (str->type == TOY_STRING_NODE) {
|
||||
//TODO: I wonder it it would be possible to discretely swap the composite node string with a new leaf string here? Would that speed up other parts of the code by not having to walk the tree?
|
||||
//TODO: I wonder if it would be possible to discretely swap the composite node string with a new leaf string here? Would that speed up other parts of the code by not having to walk the tree in future?
|
||||
char* buffer = Toy_getStringRawBuffer(str);
|
||||
str->cachedHash = hashCString(buffer);
|
||||
free(buffer);
|
||||
|
||||
@@ -29,8 +29,8 @@ typedef struct Toy_VM {
|
||||
//stack - immediate-level values only
|
||||
Toy_Stack* stack;
|
||||
|
||||
//heap - block-level key/value pairs
|
||||
//TODO: needs string util for identifiers
|
||||
//scope - block-level key/value pairs
|
||||
//TODO: Toy_Scope* scope;
|
||||
|
||||
//easy access to memory
|
||||
Toy_Bucket* stringBucket;
|
||||
|
||||
Reference in New Issue
Block a user