diff --git a/Repl.vcxproj b/Repl.vcxproj index 381b18b..cd79381 100644 --- a/Repl.vcxproj +++ b/Repl.vcxproj @@ -110,11 +110,11 @@ C:\Users\kayne\Desktop\Toy\source;%(AdditionalIncludeDirectories) + stdc17 - @@ -122,7 +122,6 @@ - diff --git a/Toy.vcxproj b/Toy.vcxproj index 8381fbe..7f0fe47 100644 --- a/Toy.vcxproj +++ b/Toy.vcxproj @@ -105,6 +105,7 @@ TOY_EXPORT;%(PreprocessorDefinitions) + stdc17 diff --git a/source/toy_common.h b/source/toy_common.h index 5e6d915..0953a4d 100644 --- a/source/toy_common.h +++ b/source/toy_common.h @@ -6,7 +6,7 @@ #define TOY_VERSION_MAJOR 0 #define TOY_VERSION_MINOR 9 -#define TOY_VERSION_PATCH 0 +#define TOY_VERSION_PATCH 1 #define TOY_VERSION_BUILD __DATE__ " " __TIME__ //platform/compiler-specific instructions diff --git a/source/toy_interpreter.c b/source/toy_interpreter.c index 760c005..a4eb387 100644 --- a/source/toy_interpreter.c +++ b/source/toy_interpreter.c @@ -37,8 +37,7 @@ bool Toy_injectNativeFn(Toy_Interpreter* interpreter, const char* name, Toy_Nati return false; } - int identifierLength = strlen(name); - Toy_Literal identifier = TOY_TO_IDENTIFIER_LITERAL(Toy_createRefStringLength(name, identifierLength)); + Toy_Literal identifier = TOY_TO_IDENTIFIER_LITERAL(Toy_createRefString(name)); //make sure the name isn't taken if (Toy_existsLiteralDictionary(&interpreter->scope->variables, identifier)) { diff --git a/source/toy_literal.c b/source/toy_literal.c index 35be37b..37293ff 100644 --- a/source/toy_literal.c +++ b/source/toy_literal.c @@ -417,7 +417,7 @@ int Toy_hashLiteral(Toy_Literal lit) { return -1; default: - //should never bee seen + //should never be seen fprintf(stderr, TOY_CC_ERROR "[internal] Unrecognized literal type in hash: %d\n" TOY_CC_RESET, lit.type); return 0; } diff --git a/source/toy_literal.h b/source/toy_literal.h index f13d043..a4fb6dc 100644 --- a/source/toy_literal.h +++ b/source/toy_literal.h @@ -118,12 +118,12 @@ typedef struct Toy_Literal { #define TOY_TO_STRING_LITERAL(value) Toy_private_toStringLiteral(value) #define TOY_TO_ARRAY_LITERAL(value) ((Toy_Literal){{ .array = value }, TOY_LITERAL_ARRAY, 0}) #define TOY_TO_DICTIONARY_LITERAL(value) ((Toy_Literal){{ .dictionary = value }, TOY_LITERAL_DICTIONARY, 0}) -#define TOY_TO_FUNCTION_LITERAL(value, l) ((Toy_Literal){{ .function.inner.bytecode = value, .function.scope = NULL }, TOY_LITERAL_FUNCTION, l}) -#define TOY_TO_FUNCTION_NATIVE_LITERAL(value) ((Toy_Literal){{ .function.inner.native = value, .function.scope = NULL }, TOY_LITERAL_FUNCTION_NATIVE, 0}) -#define TOY_TO_FUNCTION_HOOK_LITERAL(value) ((Toy_Literal){{ .function.inner.hook = value, .function.scope = NULL }, TOY_LITERAL_FUNCTION_HOOK, 0}) +#define TOY_TO_FUNCTION_LITERAL(value, l) ((Toy_Literal){{ .function = { .inner = { .bytecode = value }, .scope = NULL }}, TOY_LITERAL_FUNCTION, l}) +#define TOY_TO_FUNCTION_NATIVE_LITERAL(value) ((Toy_Literal){{ .function = { .inner = { .native = value }, .scope = NULL }}, TOY_LITERAL_FUNCTION_NATIVE, 0}) +#define TOY_TO_FUNCTION_HOOK_LITERAL(value) ((Toy_Literal){{ .function = { .inner = { .hook = value }, .scope = NULL }}, TOY_LITERAL_FUNCTION_HOOK, 0}) #define TOY_TO_IDENTIFIER_LITERAL(value) Toy_private_toIdentifierLiteral(value) -#define TOY_TO_TYPE_LITERAL(value, c) ((Toy_Literal){{ .type.typeOf = value, .type.constant = c, .type.subtypes = NULL, .type.capacity = 0, .type.count = 0 }, TOY_LITERAL_TYPE, 0}) -#define TOY_TO_OPAQUE_LITERAL(value, t) ((Toy_Literal){{ .opaque.ptr = value, .opaque.tag = t }, TOY_LITERAL_OPAQUE, 0}) +#define TOY_TO_TYPE_LITERAL(value, c) ((Toy_Literal){{ .type = { .typeOf = value, .constant = c, .subtypes = NULL, .capacity = 0, .count = 0 }}, TOY_LITERAL_TYPE, 0}) +#define TOY_TO_OPAQUE_LITERAL(value, t) ((Toy_Literal){{ .opaque = { .ptr = value, .tag = t }}, TOY_LITERAL_OPAQUE, 0}) //BUGFIX: For blank indexing #define TOY_IS_INDEX_BLANK(value) ((value).type == TOY_LITERAL_INDEX_BLANK)