Fixed C-API function name, resolved #87, thanks @hiperiondev

This commit is contained in:
2023-07-26 00:22:45 +10:00
parent 24ce965e76
commit ba98624e82
8 changed files with 16 additions and 16 deletions

View File

@@ -27,7 +27,7 @@ int Toy_hookAbout(Toy_Interpreter* interpreter, Toy_Literal identifier, Toy_Lite
//store as an aliased dictionary //store as an aliased dictionary
if (!TOY_IS_NULL(alias)) { if (!TOY_IS_NULL(alias)) {
//make sure the name isn't taken //make sure the name isn't taken
if (Toy_isDelcaredScopeVariable(interpreter->scope, alias)) { if (Toy_isDeclaredScopeVariable(interpreter->scope, alias)) {
interpreter->errorOutput("Can't override an existing variable\n"); interpreter->errorOutput("Can't override an existing variable\n");
Toy_freeLiteral(alias); Toy_freeLiteral(alias);
@@ -83,11 +83,11 @@ int Toy_hookAbout(Toy_Interpreter* interpreter, Toy_Literal identifier, Toy_Lite
//store globally //store globally
else { else {
//make sure the names aren't taken //make sure the names aren't taken
if (Toy_isDelcaredScopeVariable(interpreter->scope, majorKeyLiteral) || if (Toy_isDeclaredScopeVariable(interpreter->scope, majorKeyLiteral) ||
Toy_isDelcaredScopeVariable(interpreter->scope, minorKeyLiteral) || Toy_isDeclaredScopeVariable(interpreter->scope, minorKeyLiteral) ||
Toy_isDelcaredScopeVariable(interpreter->scope, patchKeyLiteral) || Toy_isDeclaredScopeVariable(interpreter->scope, patchKeyLiteral) ||
Toy_isDelcaredScopeVariable(interpreter->scope, buildKeyLiteral) || Toy_isDeclaredScopeVariable(interpreter->scope, buildKeyLiteral) ||
Toy_isDelcaredScopeVariable(interpreter->scope, authorKeyLiteral)) { Toy_isDeclaredScopeVariable(interpreter->scope, authorKeyLiteral)) {
interpreter->errorOutput("Can't override an existing variable\n"); interpreter->errorOutput("Can't override an existing variable\n");
Toy_freeLiteral(alias); Toy_freeLiteral(alias);

View File

@@ -133,7 +133,7 @@ int Toy_hookRandom(Toy_Interpreter* interpreter, Toy_Literal identifier, Toy_Lit
//store the library in an aliased dictionary //store the library in an aliased dictionary
if (!TOY_IS_NULL(alias)) { if (!TOY_IS_NULL(alias)) {
//make sure the name isn't taken //make sure the name isn't taken
if (Toy_isDelcaredScopeVariable(interpreter->scope, alias)) { if (Toy_isDeclaredScopeVariable(interpreter->scope, alias)) {
interpreter->errorOutput("Can't override an existing variable\n"); interpreter->errorOutput("Can't override an existing variable\n");
Toy_freeLiteral(alias); Toy_freeLiteral(alias);
return -1; return -1;

View File

@@ -462,7 +462,7 @@ int Toy_hookRunner(Toy_Interpreter* interpreter, Toy_Literal identifier, Toy_Lit
//store the library in an aliased dictionary //store the library in an aliased dictionary
if (!TOY_IS_NULL(alias)) { if (!TOY_IS_NULL(alias)) {
//make sure the name isn't taken //make sure the name isn't taken
if (Toy_isDelcaredScopeVariable(interpreter->scope, alias)) { if (Toy_isDeclaredScopeVariable(interpreter->scope, alias)) {
interpreter->errorOutput("Can't override an existing variable\n"); interpreter->errorOutput("Can't override an existing variable\n");
Toy_freeLiteral(alias); Toy_freeLiteral(alias);
return -1; return -1;

View File

@@ -2024,7 +2024,7 @@ int Toy_hookStandard(Toy_Interpreter* interpreter, Toy_Literal identifier, Toy_L
//store the library in an aliased dictionary //store the library in an aliased dictionary
if (!TOY_IS_NULL(alias)) { if (!TOY_IS_NULL(alias)) {
//make sure the name isn't taken //make sure the name isn't taken
if (Toy_isDelcaredScopeVariable(interpreter->scope, alias)) { if (Toy_isDeclaredScopeVariable(interpreter->scope, alias)) {
interpreter->errorOutput("Can't override an existing variable\n"); interpreter->errorOutput("Can't override an existing variable\n");
Toy_freeLiteral(alias); Toy_freeLiteral(alias);
return -1; return -1;

View File

@@ -54,7 +54,7 @@ The current minor version of Toy. This value is embedded into the bytecode, and
This value MUST fit into an unsigned char. This value MUST fit into an unsigned char.
!*/ !*/
#define TOY_VERSION_MINOR 1 #define TOY_VERSION_MINOR 2
/*! /*!
### TOY_VERSION_PATCH ### TOY_VERSION_PATCH
@@ -64,7 +64,7 @@ The current patch version of Toy. This value is embedded into the bytecode.
This value MUST fit into an unsigned char. This value MUST fit into an unsigned char.
!*/ !*/
#define TOY_VERSION_PATCH 7 #define TOY_VERSION_PATCH 0
/*! /*!
### TOY_VERSION_BUILD ### TOY_VERSION_BUILD

View File

@@ -699,7 +699,7 @@ static bool execVarAssign(Toy_Interpreter* interpreter) {
return false; return false;
} }
if (!Toy_isDelcaredScopeVariable(interpreter->scope, lhs)) { if (!Toy_isDeclaredScopeVariable(interpreter->scope, lhs)) {
interpreter->errorOutput("Undeclared variable \""); interpreter->errorOutput("Undeclared variable \"");
Toy_printLiteralCustom(lhs, interpreter->errorOutput); Toy_printLiteralCustom(lhs, interpreter->errorOutput);
interpreter->errorOutput("\"\n"); interpreter->errorOutput("\"\n");
@@ -1467,7 +1467,7 @@ bool Toy_callFn(Toy_Interpreter* interpreter, const char* name, Toy_LiteralArray
Toy_Literal key = TOY_TO_IDENTIFIER_LITERAL(Toy_createRefStringLength(name, strlen(name))); Toy_Literal key = TOY_TO_IDENTIFIER_LITERAL(Toy_createRefStringLength(name, strlen(name)));
Toy_Literal val = TOY_TO_NULL_LITERAL; Toy_Literal val = TOY_TO_NULL_LITERAL;
if (!Toy_isDelcaredScopeVariable(interpreter->scope, key)) { if (!Toy_isDeclaredScopeVariable(interpreter->scope, key)) {
interpreter->errorOutput("No function with that name\n"); interpreter->errorOutput("No function with that name\n");
return false; return false;
} }

View File

@@ -256,7 +256,7 @@ bool Toy_declareScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal typ
return true; return true;
} }
bool Toy_isDelcaredScopeVariable(Toy_Scope* scope, Toy_Literal key) { bool Toy_isDeclaredScopeVariable(Toy_Scope* scope, Toy_Literal key) {
while (scope != NULL) { while (scope != NULL) {
if (Toy_existsLiteralDictionary(&scope->variables, key)) { if (Toy_existsLiteralDictionary(&scope->variables, key)) {
return true; return true;

View File

@@ -58,11 +58,11 @@ This function returns true on success, otherwise it returns failure (such as if
TOY_API bool Toy_declareScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal type); TOY_API bool Toy_declareScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal type);
/*! /*!
### bool Toy_isDelcaredScopeVariable(Toy_Scope* scope, Toy_Literal key) ### bool Toy_isDeclaredScopeVariable(Toy_Scope* scope, Toy_Literal key)
This function checks to see if a given variable with the name `key` has been previously declared. This function checks to see if a given variable with the name `key` has been previously declared.
!*/ !*/
TOY_API bool Toy_isDelcaredScopeVariable(Toy_Scope* scope, Toy_Literal key); TOY_API bool Toy_isDeclaredScopeVariable(Toy_Scope* scope, Toy_Literal key);
/*! /*!
### bool Toy_setScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal value, bool constCheck) ### bool Toy_setScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal value, bool constCheck)