diff --git a/Airport.vcxproj b/Airport.vcxproj
index f0e97e6..217581b 100644
--- a/Airport.vcxproj
+++ b/Airport.vcxproj
@@ -113,26 +113,32 @@
SDL2main.lib;SDL2.lib;SDL2_image.lib;Toy.lib;Box.lib;%(AdditionalDependencies)
- C:\Users\kayne\Documents\SDL2_image-2.6.2\lib\x64;C:\Users\kayne\Documents\SDL2-2.26.2\lib\x64;$(SolutionDir)out\$(Configuration);%(AdditionalLibraryDirectories)
+ $(SDL2Dir)\lib\x64;$(SDL2ImageDir)\lib\x64;$(SolutionDir)out\$(Configuration);%(AdditionalLibraryDirectories)
- C:\Users\kayne\Documents\SDL2-2.26.2\include;C:\Users\kayne\Documents\SDL2_image-2.6.2\include;%(SolutionDir)Toy\source;%(SolutionDir)box;%(AdditionalIncludeDirectories)
+ $(SDL2Dir)\include;$(SDL2ImageDir)\include;%(SolutionDir)Toy\source;$(SolutionDir)box;%(AdditionalIncludeDirectories)
stdc17
+
+ xcopy "$(SolutionDir)Toy\repl\lib*.*" "$(SolutionDir)box" /Y /I /E
+
stdc17
- C:\Users\kayne\Documents\SDL2-2.26.2\include;C:\Users\kayne\Documents\SDL2_image-2.6.2\include;%(SolutionDir)Toy\source;%(SolutionDir)box;%(AdditionalIncludeDirectories)
+ $(SDL2Dir)\include;$(SDL2ImageDir)\include;%(SolutionDir)Toy\source;$(SolutionDir)box;%(AdditionalIncludeDirectories)
- C:\Users\kayne\Documents\SDL2_image-2.6.2\lib\x64;C:\Users\kayne\Documents\SDL2-2.26.2\lib\x64;$(SolutionDir)out\$(Configuration);%(AdditionalLibraryDirectories)
+ $(SDL2Dir)\lib\x64;$(SDL2ImageDir)\lib\x64;$(SolutionDir)out\$(Configuration);%(AdditionalLibraryDirectories)
SDL2main.lib;SDL2.lib;SDL2_image.lib;Toy.lib;Box.lib;%(AdditionalDependencies)
+
+ xcopy "$(SolutionDir)Toy\repl\lib*.*" "$(SolutionDir)box" /Y /I /E
+
diff --git a/Box.vcxproj b/Box.vcxproj
index 3a73267..d740cd7 100644
--- a/Box.vcxproj
+++ b/Box.vcxproj
@@ -110,10 +110,10 @@
stdc17
BOX_EXPORT;%(PreprocessorDefinitions)
- C:\Users\kayne\Documents\SDL2-2.26.2\include;C:\Users\kayne\Documents\SDL2_image-2.6.2\include;%(SolutionDir)Toy\source;%(AdditionalIncludeDirectories)
+ $(SDL2Dir)\include;$(SDL2ImageDir)\include;%(SolutionDir)Toy\source;%(AdditionalIncludeDirectories)
- C:\Users\kayne\Documents\SDL2_image-2.6.2\lib\x64;C:\Users\kayne\Documents\SDL2-2.26.2\lib\x64;$(SolutionDir)out\$(Configuration)\;%(AdditionalLibraryDirectories)
+ $(SDL2Dir)\lib\x64;$(SDL2ImageDir)\lib\x64;$(SolutionDir)out\$(Configuration)\;%(AdditionalLibraryDirectories)
SDL2.lib;SDL2_image.lib;Toy.lib;%(AdditionalDependencies)
@@ -121,10 +121,10 @@
stdc17
BOX_EXPORT;%(PreprocessorDefinitions)
- C:\Users\kayne\Documents\SDL2-2.26.2\include;C:\Users\kayne\Documents\SDL2_image-2.6.2\include;%(SolutionDir)Toy\source;%(AdditionalIncludeDirectories)
+ $(SDL2Dir)\include;$(SDL2ImageDir)\include;%(SolutionDir)Toy\source;%(AdditionalIncludeDirectories)
- C:\Users\kayne\Documents\SDL2_image-2.6.2\lib\x64;C:\Users\kayne\Documents\SDL2-2.26.2\lib\x64;$(SolutionDir)out\$(Configuration)\;%(AdditionalLibraryDirectories)
+ $(SDL2Dir)\lib\x64;$(SDL2ImageDir)\lib\x64;$(SolutionDir)out\$(Configuration)\;%(AdditionalLibraryDirectories)
SDL2.lib;SDL2_image.lib;Toy.lib;%(AdditionalDependencies)
diff --git a/Toy b/Toy
index 2adb9d9..cdca6fa 160000
--- a/Toy
+++ b/Toy
@@ -1 +1 @@
-Subproject commit 2adb9d915858409f3ca7206666dc135527c49d1b
+Subproject commit cdca6fa45cb59a9d27e35fc423063cabd7fb2f76
diff --git a/assets/scripts/entity.toy b/assets/scripts/entity.toy
index 82a13d8..b50f98d 100644
--- a/assets/scripts/entity.toy
+++ b/assets/scripts/entity.toy
@@ -1,7 +1,7 @@
import node;
//constants
-var SPEED: int const = 10;
+var SPEED: int const = 5;
//variables
var parent: opaque = null;
diff --git a/box/box_engine.c b/box/box_engine.c
index a9c81d6..1948b74 100644
--- a/box/box_engine.c
+++ b/box/box_engine.c
@@ -338,7 +338,7 @@ void Box_execEngine() {
//set up time
engine.realTime = clock();
engine.simTime = engine.realTime;
- clock_t delta = (double) CLOCKS_PER_SEC / 60.0;
+ clock_t delta = (double) CLOCKS_PER_SEC / 240.0;
while (engine.running) {
execEvents();
@@ -346,19 +346,13 @@ void Box_execEngine() {
//calc the time passed
engine.realTime = clock();
- //if not enough time has passed
- if (engine.simTime < engine.realTime) {
- //while not enough time has passed
- while(engine.simTime < engine.realTime) {
- //simulate the world
- execStep();
+ //while not enough time has passed
+ while(engine.simTime < engine.realTime) {
+ //simulate the world
+ execStep();
- //calc the time simulation
- engine.simTime += delta;
- }
- }
- else {
- sleep(0.01); //let the machine sleep, 10ms
+ //calc the time simulation
+ engine.simTime += delta;
}
//render the world
diff --git a/box/box_engine_node.c b/box/box_engine_node.c
index 862e85f..e341aca 100644
--- a/box/box_engine_node.c
+++ b/box/box_engine_node.c
@@ -29,7 +29,7 @@ void Box_initEngineNode(Box_EngineNode* node, Toy_Interpreter* interpreter, cons
}
//if this variable is a function (this outmodes import and export)
- Toy_private_entry* entry = &variablesPtr->entries[i];
+ Toy_private_dictionary_entry* entry = &variablesPtr->entries[i];
if (TOY_IS_FUNCTION(entry->value)) {
//save a copy
Toy_setLiteralDictionary(node->functions, entry->key, entry->value);
diff --git a/box/lib_runner.c b/box/lib_runner.c
index 04fbc57..4b8ef80 100644
--- a/box/lib_runner.c
+++ b/box/lib_runner.c
@@ -7,6 +7,7 @@
#include
#include
+#include
typedef struct Toy_Runner {
Toy_Interpreter interpreter;
@@ -32,6 +33,11 @@ static int nativeLoadScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argu
Toy_freeLiteral(drivePathLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(drivePathLiteral)) {
+ Toy_freeLiteral(drivePathLiteral);
+ return -1;
+ }
+
Toy_Literal filePathLiteral = Toy_getFilePathLiteral(interpreter, &drivePathLiteral);
if (TOY_IS_NULL(filePathLiteral)) {
@@ -48,7 +54,7 @@ static int nativeLoadScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argu
//load and compile the bytecode
size_t fileSize = 0;
- const char* source = Toy_readFile(filePath, &fileSize);
+ const char* source = (const char*)Toy_readFile(filePath, &fileSize);
if (!source) {
interpreter->errorOutput("Failed to load source file\n");
@@ -102,6 +108,11 @@ static int nativeLoadScriptBytecode(Toy_Interpreter* interpreter, Toy_LiteralArr
Toy_freeLiteral(drivePathLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(drivePathLiteral)) {
+ Toy_freeLiteral(drivePathLiteral);
+ return -1;
+ }
+
Toy_RefString* drivePath = Toy_copyRefString(TOY_AS_STRING(drivePathLiteral));
//get the drive and path as a string (can't trust that pesky strtok - custom split) TODO: move this to refstring library
@@ -212,6 +223,11 @@ static int nativeRunScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argum
Toy_freeLiteral(runnerIdn);
}
+ if (TOY_IS_IDENTIFIER(runnerLiteral)) {
+ Toy_freeLiteral(runnerLiteral);
+ return -1;
+ }
+
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
interpreter->errorOutput("Unrecognized opaque literal in runScript\n");
return -1;
@@ -259,6 +275,12 @@ static int nativeGetScriptVar(Toy_Interpreter* interpreter, Toy_LiteralArray* ar
Toy_freeLiteral(runnerIdn);
}
+ if (TOY_IS_IDENTIFIER(varName) || TOY_IS_IDENTIFIER(runnerLiteral)) {
+ Toy_freeLiteral(varName);
+ Toy_freeLiteral(runnerLiteral);
+ return -1;
+ }
+
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
interpreter->errorOutput("Unrecognized opaque literal in getScriptVar\n");
return -1;
@@ -331,6 +353,12 @@ static int nativeCallScriptFn(Toy_Interpreter* interpreter, Toy_LiteralArray* ar
Toy_freeLiteral(runnerIdn);
}
+ if (TOY_IS_IDENTIFIER(varName) || TOY_IS_IDENTIFIER(runnerLiteral)) {
+ Toy_freeLiteral(varName);
+ Toy_freeLiteral(runnerLiteral);
+ return -1;
+ }
+
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
interpreter->errorOutput("Unrecognized opaque literal in callScriptFn\n");
return -1;
@@ -400,6 +428,11 @@ static int nativeResetScript(Toy_Interpreter* interpreter, Toy_LiteralArray* arg
Toy_freeLiteral(runnerIdn);
}
+ if (TOY_IS_IDENTIFIER(runnerLiteral)) {
+ Toy_freeLiteral(runnerLiteral);
+ return -1;
+ }
+
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
interpreter->errorOutput("Unrecognized opaque literal in resetScript\n");
return -1;
@@ -436,6 +469,11 @@ static int nativeFreeScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argu
Toy_freeLiteral(runnerIdn);
}
+ if (TOY_IS_IDENTIFIER(runnerLiteral)) {
+ Toy_freeLiteral(runnerLiteral);
+ return -1;
+ }
+
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
interpreter->errorOutput("Unrecognized opaque literal in freeScript\n");
return -1;
@@ -470,6 +508,11 @@ static int nativeCheckScriptDirty(Toy_Interpreter* interpreter, Toy_LiteralArray
Toy_freeLiteral(runnerIdn);
}
+ if (TOY_IS_IDENTIFIER(runnerLiteral)) {
+ Toy_freeLiteral(runnerLiteral);
+ return -1;
+ }
+
if (TOY_GET_OPAQUE_TAG(runnerLiteral) != TOY_OPAQUE_TAG_RUNNER) {
interpreter->errorOutput("Unrecognized opaque literal in checkScriptDirty\n");
return -1;
diff --git a/box/lib_standard.c b/box/lib_standard.c
index 57fdbb3..d7d5a8c 100644
--- a/box/lib_standard.c
+++ b/box/lib_standard.c
@@ -2,9 +2,10 @@
#include "toy_memory.h"
-#include
#include
+#include
#include
+#include
static int nativeClock(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//no arguments
@@ -53,6 +54,12 @@ static int nativeConcat(Toy_Interpreter* interpreter, Toy_LiteralArray* argument
Toy_freeLiteral(otherLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(otherLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(otherLiteral);
+ return -1;
+ }
+
//for each self type
if (TOY_IS_ARRAY(selfLiteral)) {
if (!TOY_IS_ARRAY(otherLiteral)) {
@@ -163,6 +170,12 @@ static int nativeContainsKey(Toy_Interpreter* interpreter, Toy_LiteralArray* arg
Toy_freeLiteral(keyLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(keyLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(keyLiteral);
+ return -1;
+ }
+
//check type
if (!(/* TOY_IS_ARRAY(selfLiteral) || */ TOY_IS_DICTIONARY(selfLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to containsKey\n");
@@ -208,6 +221,12 @@ static int nativeContainsValue(Toy_Interpreter* interpreter, Toy_LiteralArray* a
Toy_freeLiteral(valueLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(valueLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(valueLiteral);
+ return -1;
+ }
+
//check type
if (!( TOY_IS_ARRAY(selfLiteral) || TOY_IS_DICTIONARY(selfLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to containsValue\n");
@@ -278,6 +297,12 @@ static int nativeEvery(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments
Toy_freeLiteral(fnLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(fnLiteral);
+ return -1;
+ }
+
//check type
if (!( TOY_IS_ARRAY(selfLiteral) || TOY_IS_DICTIONARY(selfLiteral) ) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to every\n");
@@ -394,6 +419,12 @@ static int nativeFilter(Toy_Interpreter* interpreter, Toy_LiteralArray* argument
Toy_freeLiteral(fnLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(fnLiteral);
+ return -1;
+ }
+
//check type
if (!( TOY_IS_ARRAY(selfLiteral) || TOY_IS_DICTIONARY(selfLiteral) ) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to filter\n");
@@ -508,6 +539,12 @@ static int nativeForEach(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
Toy_freeLiteral(fnLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(fnLiteral);
+ return -1;
+ }
+
//check type
if (!( TOY_IS_ARRAY(selfLiteral) || TOY_IS_DICTIONARY(selfLiteral) ) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to forEach\n");
@@ -580,6 +617,11 @@ static int nativeGetKeys(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
Toy_freeLiteral(selfLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ return -1;
+ }
+
//check type
if (!TOY_IS_DICTIONARY(selfLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to getKeys\n");
@@ -625,6 +667,11 @@ static int nativeGetValues(Toy_Interpreter* interpreter, Toy_LiteralArray* argum
Toy_freeLiteral(selfLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ return -1;
+ }
+
//check type
if (!TOY_IS_DICTIONARY(selfLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to getValues\n");
@@ -677,6 +724,12 @@ static int nativeIndexOf(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
Toy_freeLiteral(valueLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(valueLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(valueLiteral);
+ return -1;
+ }
+
//check type
if (!TOY_IS_ARRAY(selfLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to indexOf\n");
@@ -724,6 +777,12 @@ static int nativeMap(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
Toy_freeLiteral(fnLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(fnLiteral);
+ return -1;
+ }
+
//check type
if (!( TOY_IS_ARRAY(selfLiteral) || TOY_IS_DICTIONARY(selfLiteral) ) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to map\n");
@@ -833,6 +892,13 @@ static int nativeReduce(Toy_Interpreter* interpreter, Toy_LiteralArray* argument
Toy_freeLiteral(fnLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(defaultLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(defaultLiteral);
+ Toy_freeLiteral(fnLiteral);
+ return -1;
+ }
+
//check type
if (!( TOY_IS_ARRAY(selfLiteral) || TOY_IS_DICTIONARY(selfLiteral) ) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to reduce\n");
@@ -928,6 +994,12 @@ static int nativeSome(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
Toy_freeLiteral(fnLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(fnLiteral);
+ return -1;
+ }
+
//check type
if (!( TOY_IS_ARRAY(selfLiteral) || TOY_IS_DICTIONARY(selfLiteral) ) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to some\n");
@@ -1092,6 +1164,12 @@ static int nativeSort(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
Toy_freeLiteral(fnLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(fnLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(fnLiteral);
+ return -1;
+ }
+
//check type
if (!TOY_IS_ARRAY(selfLiteral) || !( TOY_IS_FUNCTION(fnLiteral) || TOY_IS_FUNCTION_NATIVE(fnLiteral) )) {
interpreter->errorOutput("Incorrect argument type passed to sort\n");
@@ -1128,6 +1206,11 @@ static int nativeToLower(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
Toy_freeLiteral(selfLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ return -1;
+ }
+
if (!TOY_IS_STRING(selfLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to toLower\n");
Toy_freeLiteral(selfLiteral);
@@ -1189,6 +1272,11 @@ static int nativeToString(Toy_Interpreter* interpreter, Toy_LiteralArray* argume
Toy_freeLiteral(selfLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ return -1;
+ }
+
//BUGFIX: probably an undefined variable
if (TOY_IS_IDENTIFIER(selfLiteral)) {
Toy_freeLiteral(selfLiteral);
@@ -1228,6 +1316,11 @@ static int nativeToUpper(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
Toy_freeLiteral(selfLiteralIdn);
}
+ if (TOY_IS_IDENTIFIER(selfLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ return -1;
+ }
+
if (!TOY_IS_STRING(selfLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to toUpper\n");
Toy_freeLiteral(selfLiteral);
@@ -1288,7 +1381,13 @@ static int nativeTrim(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
Toy_freeLiteral(selfLiteralIdn);
}
- if (!TOY_IS_STRING(selfLiteral)) {
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(trimCharsLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(trimCharsLiteral);
+ return -1;
+ }
+
+ if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to trim\n");
Toy_freeLiteral(trimCharsLiteral);
Toy_freeLiteral(selfLiteral);
@@ -1399,7 +1498,13 @@ static int nativeTrimBegin(Toy_Interpreter* interpreter, Toy_LiteralArray* argum
Toy_freeLiteral(selfLiteralIdn);
}
- if (!TOY_IS_STRING(selfLiteral)) {
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(trimCharsLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(trimCharsLiteral);
+ return -1;
+ }
+
+ if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to trimBegin\n");
Toy_freeLiteral(trimCharsLiteral);
Toy_freeLiteral(selfLiteral);
@@ -1487,7 +1592,13 @@ static int nativeTrimEnd(Toy_Interpreter* interpreter, Toy_LiteralArray* argumen
Toy_freeLiteral(selfLiteralIdn);
}
- if (!TOY_IS_STRING(selfLiteral)) {
+ if (TOY_IS_IDENTIFIER(selfLiteral) || TOY_IS_IDENTIFIER(trimCharsLiteral)) {
+ Toy_freeLiteral(selfLiteral);
+ Toy_freeLiteral(trimCharsLiteral);
+ return -1;
+ }
+
+ if (!TOY_IS_STRING(selfLiteral) || !TOY_IS_STRING(trimCharsLiteral)) {
interpreter->errorOutput("Incorrect argument type passed to trimEnd\n");
Toy_freeLiteral(trimCharsLiteral);
Toy_freeLiteral(selfLiteral);