mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Added tables to integration tests, tweaked a lot of comments
This commit is contained in:
@@ -85,7 +85,7 @@ Toy_Bytecode Toy_compileBytecode(Toy_Ast* ast) {
|
||||
|
||||
//build
|
||||
writeBytecodeHeader(&bc);
|
||||
writeBytecodeBody(&bc, ast); //TODO: implement module packing
|
||||
writeBytecodeBody(&bc, ast); //TODO: implement module packing (multiple modules in one package)
|
||||
|
||||
return bc;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef enum Toy_OpcodeType {
|
||||
TOY_OPCODE_PRINT,
|
||||
TOY_OPCODE_CONCAT,
|
||||
TOY_OPCODE_INDEX,
|
||||
//TODO: clear the program stack - much needed
|
||||
//URGENT: clear the program stack - much needed
|
||||
|
||||
//meta instructions
|
||||
TOY_OPCODE_PASS,
|
||||
|
||||
@@ -651,11 +651,6 @@ static Toy_AstFlag aggregate(Toy_Bucket** bucketHandle, Toy_Parser* parser, Toy_
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: allow trailing commas
|
||||
// static Toy_AstFlag noop(Toy_Bucket** bucketHandle, Toy_Parser* parser, Toy_Ast** rootHandle) {
|
||||
// return return TOY_AST_FLAG_NONE;
|
||||
// }
|
||||
|
||||
static ParsingTuple* getParsingRule(Toy_TokenType type) {
|
||||
return &parsingRulesetTable[type];
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ static unsigned int writeInstructionIfThenElse(Toy_Routine** rt, Toy_AstIfThenEl
|
||||
}
|
||||
|
||||
static unsigned int writeInstructionWhileThen(Toy_Routine** rt, Toy_AstWhileThen ast) {
|
||||
//TODO: begin
|
||||
//begin
|
||||
unsigned int beginAddr = CURRENT_ADDRESS(rt, code);
|
||||
|
||||
//cond-branch
|
||||
@@ -830,7 +830,7 @@ static void* writeRoutine(Toy_Routine* rt, Toy_Ast* ast) {
|
||||
count += rt->dataCount;
|
||||
}
|
||||
|
||||
//TODO: subs region
|
||||
//TODO: subroutine region
|
||||
|
||||
//finally, record the total size within the header, and return the result
|
||||
*((int*)buffer) = count;
|
||||
|
||||
@@ -126,8 +126,6 @@ void Toy_declareScope(Toy_Scope* scope, Toy_String* key, Toy_Value value) {
|
||||
Toy_insertTable(&scope->table, TOY_VALUE_FROM_STRING(Toy_copyString(key)), value);
|
||||
}
|
||||
|
||||
|
||||
//TODO: check for clearign old values
|
||||
void Toy_assignScope(Toy_Scope* scope, Toy_String* key, Toy_Value value) {
|
||||
if (key->info.type != TOY_STRING_NAME) {
|
||||
fprintf(stderr, TOY_CC_ERROR "ERROR: Toy_Scope only allows name strings as keys\n" TOY_CC_RESET);
|
||||
|
||||
@@ -189,7 +189,7 @@ Toy_String* Toy_concatStrings(Toy_Bucket** bucketHandle, Toy_String* left, Toy_S
|
||||
}
|
||||
|
||||
void Toy_freeString(Toy_String* str) {
|
||||
decrementRefCount(str); //TODO: tool for checking the bucket is empty, and freeing it
|
||||
decrementRefCount(str); //TODO: tool for checking the bucket is empty, and freeing it?
|
||||
}
|
||||
|
||||
unsigned int Toy_getStringLength(Toy_String* str) {
|
||||
|
||||
@@ -26,7 +26,7 @@ TOY_API Toy_Value Toy_lookupTable(Toy_Table** tableHandle, Toy_Value key);
|
||||
TOY_API void Toy_removeTable(Toy_Table** tableHandle, Toy_Value key);
|
||||
|
||||
//NOTE: exposed to skip unnecessary allocations within Toy_Scope
|
||||
TOY_API Toy_Table* Toy_private_adjustTableCapacity(Toy_Table* oldTable, unsigned int newCapacity); //TODO: make it public
|
||||
TOY_API Toy_Table* Toy_private_adjustTableCapacity(Toy_Table* oldTable, unsigned int newCapacity); //TODO: make it public?
|
||||
TOY_API Toy_TableEntry* Toy_private_lookupTableEntryPtr(Toy_Table** tableHandle, Toy_Value key); //TODO: make it public?
|
||||
|
||||
//some useful sizes, could be swapped out as needed
|
||||
|
||||
@@ -412,7 +412,7 @@ int Toy_compareValues(Toy_Value left, Toy_Value right) {
|
||||
Toy_String* Toy_stringifyValue(Toy_Bucket** bucketHandle, Toy_Value value) {
|
||||
value = Toy_unwrapValue(value);
|
||||
|
||||
//TODO: could have "constant" strings that can be referenced, instead of null, true, false, etc.
|
||||
//TODO: could have "constant" strings that can be referenced, instead of null, true, false, etc. - new string type of 'permanent'
|
||||
|
||||
switch(value.type) {
|
||||
case TOY_VALUE_NULL:
|
||||
|
||||
@@ -37,7 +37,6 @@ typedef struct Toy_Value { //32 | 64 BITNESS
|
||||
struct Toy_Array* array; //4 | 8
|
||||
struct Toy_Table* table; //4 | 8
|
||||
//TODO: more types go here
|
||||
//TODO: consider 'stack' as a possible addition
|
||||
|
||||
} as; //4 | 8
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ static void processRead(Toy_VM* vm) {
|
||||
unsigned int count = (unsigned int)READ_INT(vm);
|
||||
unsigned int capacity = count > TOY_ARRAY_INITIAL_CAPACITY ? count : TOY_ARRAY_INITIAL_CAPACITY;
|
||||
|
||||
//neat trick to find the next power of two, inclusive (restriction of the array system) TODO: move this into a function
|
||||
//neat trick to find the next power of two, inclusive (restriction of the array system)
|
||||
capacity--;
|
||||
capacity |= capacity >> 1;
|
||||
capacity |= capacity >> 2;
|
||||
@@ -128,7 +128,7 @@ static void processRead(Toy_VM* vm) {
|
||||
unsigned int capacity = count / 2;
|
||||
capacity = capacity > TOY_TABLE_INITIAL_CAPACITY ? capacity : TOY_TABLE_INITIAL_CAPACITY;
|
||||
|
||||
//neat trick to find the next power of two, inclusive (restriction of the table system) TODO: move this into a function
|
||||
//neat trick to find the next power of two, inclusive (restriction of the table system)
|
||||
capacity--;
|
||||
capacity |= capacity >> 1;
|
||||
capacity |= capacity >> 2;
|
||||
@@ -317,7 +317,6 @@ static void processAccess(Toy_VM* vm) {
|
||||
|
||||
//in the event of a certain subset of types, create references instead (these should only exist on the stack)
|
||||
if (TOY_VALUE_IS_REFERENCE(*valuePtr) || TOY_VALUE_IS_ARRAY(*valuePtr) || TOY_VALUE_IS_TABLE(*valuePtr)) {
|
||||
//TODO: more types to be implemented as stack-only references
|
||||
Toy_Value ref = TOY_REFERENCE_FROM_POINTER(valuePtr);
|
||||
Toy_pushStack(&vm->stack, ref);
|
||||
}
|
||||
@@ -635,7 +634,7 @@ static void processIndex(Toy_VM* vm) {
|
||||
}
|
||||
else {
|
||||
Toy_error("Incorrect number of elements found in index");
|
||||
//TODO: clear stack, then leave null?
|
||||
//TODO: clear stack, then leave null
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -728,7 +727,6 @@ static void processIndex(Toy_VM* vm) {
|
||||
|
||||
//in the event of a certain subset of types, create references instead (these should only exist on the stack)
|
||||
if (TOY_VALUE_IS_REFERENCE(array->data[i]) || TOY_VALUE_IS_ARRAY(array->data[i]) || TOY_VALUE_IS_TABLE(array->data[i])) {
|
||||
//TODO: more types to be implemented as stack-only references
|
||||
Toy_Value ref = TOY_REFERENCE_FROM_POINTER(&(array->data[i]));
|
||||
Toy_pushStack(&vm->stack, ref);
|
||||
}
|
||||
@@ -761,7 +759,6 @@ static void processIndex(Toy_VM* vm) {
|
||||
|
||||
//in the event of a certain subset of types, create references instead (these should only exist on the stack)
|
||||
if (TOY_VALUE_IS_REFERENCE(entry->value) || TOY_VALUE_IS_ARRAY(entry->value) || TOY_VALUE_IS_TABLE(entry->value)) {
|
||||
//TODO: more types to be implemented as stack-only references
|
||||
Toy_Value ref = TOY_REFERENCE_FROM_POINTER(&(entry->value));
|
||||
Toy_pushStack(&vm->stack, ref);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef struct Toy_VM {
|
||||
Toy_Bucket* stringBucket; //stores the string literals
|
||||
Toy_Bucket* scopeBucket; //stores the scopes
|
||||
|
||||
//TODO: panic flag
|
||||
//URGENT: panic/failed state flag
|
||||
} Toy_VM;
|
||||
|
||||
TOY_API void Toy_initVM(Toy_VM* vm);
|
||||
|
||||
Reference in New Issue
Block a user