diff --git a/.notes/disassembly.txt b/.notes/disassembly.txt deleted file mode 100644 index 57b2c2d..0000000 --- a/.notes/disassembly.txt +++ /dev/null @@ -1,33 +0,0 @@ - -//source - -while (true) { - print "1"; - break; - print "2"; -} - -print "3"; - -//asm - -0 TOY_OPCODE_READ [TOY_VALUE_BOOLEAN, true, -] -4 TOY_OPCODE_JUMP [TOY_OP_PARAM_JUMP_RELATIVE, TOY_OP_PARAM_JUMP_IF_FALSE, -] -8 52 (jumps to end '64' after this JUMP instruction) -12 TOY_OPCODE_SCOPE_PUSH -16 TOY_OPCODE_READ [TOY_VALUE_STRING, TOY_STRING_LEAF, 0] -20 0 (string "1") -24 TOY_OPCODE_PRINT -28 TOY_OPCODE_ESCAPE -32 0? (addr) -36 0? (diff) -40 TOY_OPCODE_READ [TOY_VALUE_STRING, TOY_STRING_LEAF, 0] -44 4 (string "2") -48 TOY_OPCODE_PRINT -52 TOY_OPCODE_SCOPE_POP -56 TOY_OPCODE_JUMP [TOY_OP_PARAM_JUMP_RELATIVE, TOY_OP_PARAM_JUMP_ALWAYS, -] -60 -64 (jumps to start '0' after this JUMP instruction) -64 TOY_OPCODE_READ [TOY_VALUE_STRING, TOY_STRING_LEAF, 0] -68 8 (string "3") -72 TOY_OPCODE_PRINT -76 TOY_OPCODE_RETURN diff --git a/.notes/misc.txt b/.notes/misc.txt deleted file mode 100644 index 2185392..0000000 --- a/.notes/misc.txt +++ /dev/null @@ -1,3 +0,0 @@ -type coercion -permanent strings? -concat & free? (strings) diff --git a/.notes/read-opcode-layout.txt b/.notes/read-opcode-layout.txt deleted file mode 100644 index 0ccc1fa..0000000 --- a/.notes/read-opcode-layout.txt +++ /dev/null @@ -1,28 +0,0 @@ -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 - diff --git a/repl/main.c b/repl/main.c index 91d4587..5d3da08 100644 --- a/repl/main.c +++ b/repl/main.c @@ -10,9 +10,6 @@ #include //utilities -#define APPEND(dest, src) \ - strncpy((dest) + (strlen(dest)), (src), strlen((src)) + 1); - #if defined(_WIN32) || defined(_WIN64) #define FLIPSLASH(str) for (int i = 0; str != NULL && str[i]; i++) str[i] = str[i] == '/' ? '\\' : str[i]; #else @@ -60,30 +57,6 @@ unsigned char* readFile(char* path, int* size) { return buffer; } -int getFilePath(char* dest, const char* src) { - char* p = NULL; - - //find the last slash, regardless of platform - p = strrchr(src, '\\'); - if (p == NULL) { - p = strrchr(src, '/'); - } - if (p == NULL) { - int len = strlen(src); - strncpy(dest, src, len); - return len; - } - - //determine length of the path - int len = p - src + 1; - - //copy to the dest - strncpy(dest, src, len); - dest[len] = '\0'; - - return len; -} - int getFileName(char* dest, const char* src) { char* p = NULL; @@ -489,7 +462,7 @@ int main(int argc, const char* argv[]) { Toy_runVM(&vm); //print the debug info - if (cmd.verboseDebugPrint) { + if (cmd.verboseDebugPrint) { //URGENT: 'verbose' option is mainly for the WIP elements, like decompiler debugStackPrint(vm.stack); debugScopePrint(vm.scope, 0); } diff --git a/source/toy_print.h b/source/toy_print.h index bfa9af4..b358011 100644 --- a/source/toy_print.h +++ b/source/toy_print.h @@ -16,5 +16,3 @@ TOY_API void Toy_setAssertFailureCallback(Toy_callbackType cb); TOY_API void Toy_resetPrintCallback(void); TOY_API void Toy_resetErrorCallback(void); TOY_API void Toy_resetAssertFailureCallback(void); - -//TODO: rename print.h to debug? \ No newline at end of file diff --git a/source/toy_value.h b/source/toy_value.h index 45bac77..58d4d15 100644 --- a/source/toy_value.h +++ b/source/toy_value.h @@ -92,5 +92,5 @@ TOY_API int Toy_compareValues(Toy_Value left, Toy_Value right); //convert the value to a string - values that *are* strings are simply copied TOY_API union Toy_String_t* Toy_stringifyValue(struct Toy_Bucket** bucketHandle, Toy_Value value); -//for debugging +//for error messages TOY_API const char* Toy_private_getValueTypeAsCString(Toy_ValueType type);