Cleaned up some comments

This commit is contained in:
2024-10-10 09:10:39 +11:00
parent ca4073a5ae
commit e6fa345fe6
8 changed files with 15 additions and 14 deletions

View File

@@ -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. 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. 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 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). 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 # Coding Habits

View File

@@ -251,7 +251,7 @@ static void errorAndExitCallback(const char* msg) {
} }
//main file //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_setPrintCallback(printCallback);
Toy_setErrorCallback(errorAndExitCallback); Toy_setErrorCallback(errorAndExitCallback);
Toy_setAssertFailureCallback(errorAndExitCallback); Toy_setAssertFailureCallback(errorAndExitCallback);

View File

@@ -31,7 +31,7 @@ typedef enum Toy_AstFlag {
TOY_AST_FLAG_MULTIPLY, TOY_AST_FLAG_MULTIPLY,
TOY_AST_FLAG_DIVIDE, TOY_AST_FLAG_DIVIDE,
TOY_AST_FLAG_MODULO, 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_ADD_ASSIGN,
TOY_AST_FLAG_SUBTRACT_ASSIGN, TOY_AST_FLAG_SUBTRACT_ASSIGN,
TOY_AST_FLAG_MULTIPLY_ASSIGN, TOY_AST_FLAG_MULTIPLY_ASSIGN,
@@ -99,7 +99,6 @@ typedef struct Toy_AstPass {
typedef struct Toy_AstError { typedef struct Toy_AstError {
Toy_AstType type; Toy_AstType type;
//TODO: more data regarding the error
} Toy_AstError; } Toy_AstError;
typedef struct Toy_AstEnd { typedef struct Toy_AstEnd {

View File

@@ -36,7 +36,7 @@ typedef enum Toy_OpcodeType {
//various action instructions //various action instructions
TOY_OPCODE_PRINT, TOY_OPCODE_PRINT,
TOY_OPCODE_CONCAT, TOY_OPCODE_CONCAT,
//TODO: clear the program stack //TODO: clear the program stack?
//meta instructions //meta instructions
TOY_OPCODE_PASS, TOY_OPCODE_PASS,

View File

@@ -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 writeRoutineCode(Toy_Routine** rt, Toy_Ast* ast); //forward declare for recursion
static void writeInstructionValue(Toy_Routine** rt, Toy_AstValue ast) { 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, TOY_OPCODE_READ);
EMIT_BYTE(rt, code, ast.value.type); 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 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) { if (rt->codeCount > 0) {
expand(&buffer, &capacity, &count, rt->codeCount); expand(&buffer, &capacity, &count, rt->codeCount);
memcpy((buffer + count), rt->code, 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; count += rt->dataCount;
} }
//TODO: subs region
//finally, record the total size within the header, and return the result //finally, record the total size within the header, and return the result
*((int*)buffer) = count; *((int*)buffer) = count;

View File

@@ -5,6 +5,7 @@
#include "toy_bucket.h" #include "toy_bucket.h"
#include "toy_value.h" #include "toy_value.h"
//TODO: Remove this
#define TOY_STRING_MAX_LENGTH 1000 #define TOY_STRING_MAX_LENGTH 1000
//rope pattern //rope pattern

View File

@@ -25,7 +25,7 @@ bool Toy_private_isTruthy(Toy_Value value) {
bool Toy_private_isEqual(Toy_Value left, Toy_Value right) { bool Toy_private_isEqual(Toy_Value left, Toy_Value right) {
//temp check //temp check
if (right.type > TOY_VALUE_STRING) { 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) { switch(left.type) {
@@ -64,7 +64,7 @@ bool Toy_private_isEqual(Toy_Value left, Toy_Value right) {
case TOY_VALUE_FUNCTION: case TOY_VALUE_FUNCTION:
case TOY_VALUE_OPAQUE: case TOY_VALUE_OPAQUE:
default: 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; return 0;
@@ -111,7 +111,7 @@ unsigned int Toy_hashValue(Toy_Value value) {
return str->cachedHash; return str->cachedHash;
} }
else if (str->type == TOY_STRING_NODE) { 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); char* buffer = Toy_getStringRawBuffer(str);
str->cachedHash = hashCString(buffer); str->cachedHash = hashCString(buffer);
free(buffer); free(buffer);

View File

@@ -29,8 +29,8 @@ typedef struct Toy_VM {
//stack - immediate-level values only //stack - immediate-level values only
Toy_Stack* stack; Toy_Stack* stack;
//heap - block-level key/value pairs //scope - block-level key/value pairs
//TODO: needs string util for identifiers //TODO: Toy_Scope* scope;
//easy access to memory //easy access to memory
Toy_Bucket* stringBucket; Toy_Bucket* stringBucket;