Missed the globals

This commit is contained in:
2023-01-25 13:15:16 +00:00
parent 2e2bee4fa3
commit 5183037a99
4 changed files with 24 additions and 24 deletions

View File

@@ -249,7 +249,7 @@ static Toy_Literal modulo(Toy_Interpreter* interpreter, Toy_Literal lhs, Toy_Lit
return TOY_TO_NULL_LITERAL; return TOY_TO_NULL_LITERAL;
} }
int _index(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) { int Toy_private_index(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//_index(compound, first, second, third, assignValue, op) //_index(compound, first, second, third, assignValue, op)
Toy_Literal op = Toy_popLiteralArray(arguments); Toy_Literal op = Toy_popLiteralArray(arguments);
Toy_Literal assign = Toy_popLiteralArray(arguments); Toy_Literal assign = Toy_popLiteralArray(arguments);
@@ -934,7 +934,7 @@ int _index(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
return 1; return 1;
} }
int _set(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) { int Toy_private_set(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//if wrong number of arguments, fail //if wrong number of arguments, fail
if (arguments->count != 3) { if (arguments->count != 3) {
interpreter->errorOutput("Incorrect number of arguments to _set\n"); interpreter->errorOutput("Incorrect number of arguments to _set\n");
@@ -1052,7 +1052,7 @@ int _set(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
return 0; return 0;
} }
int _get(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) { int Toy_private_get(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//if wrong number of arguments, fail //if wrong number of arguments, fail
if (arguments->count != 2) { if (arguments->count != 2) {
interpreter->errorOutput("Incorrect number of arguments to _get"); interpreter->errorOutput("Incorrect number of arguments to _get");
@@ -1123,7 +1123,7 @@ int _get(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
} }
} }
int _push(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) { int Toy_private_push(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//if wrong number of arguments, fail //if wrong number of arguments, fail
if (arguments->count != 2) { if (arguments->count != 2) {
interpreter->errorOutput("Incorrect number of arguments to _push\n"); interpreter->errorOutput("Incorrect number of arguments to _push\n");
@@ -1186,7 +1186,7 @@ int _push(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
} }
} }
int _pop(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) { int Toy_private_pop(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//if wrong number of arguments, fail //if wrong number of arguments, fail
if (arguments->count != 1) { if (arguments->count != 1) {
interpreter->errorOutput("Incorrect number of arguments to _pop\n"); interpreter->errorOutput("Incorrect number of arguments to _pop\n");
@@ -1229,7 +1229,7 @@ int _pop(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
} }
} }
int _length(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) { int Toy_private_length(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//if wrong number of arguments, fail //if wrong number of arguments, fail
if (arguments->count != 1) { if (arguments->count != 1) {
interpreter->errorOutput("Incorrect number of arguments to _length\n"); interpreter->errorOutput("Incorrect number of arguments to _length\n");
@@ -1280,7 +1280,7 @@ int _length(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
return 1; return 1;
} }
int _clear(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) { int Toy_private_clear(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments) {
//if wrong number of arguments, fail //if wrong number of arguments, fail
if (arguments->count != 1) { if (arguments->count != 1) {
interpreter->errorOutput("Incorrect number of arguments to _clear\n"); interpreter->errorOutput("Incorrect number of arguments to _clear\n");

View File

@@ -3,12 +3,12 @@
#include "toy_interpreter.h" #include "toy_interpreter.h"
//the _index function is a historical oddity - it's used whenever a compound is indexed //the _index function is a historical oddity - it's used whenever a compound is indexed
int _index(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments); int Toy_private_index(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments);
//globally available native functions //globally available native functions
int _set(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments); int Toy_private_set(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments);
int _get(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments); int Toy_private_get(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments);
int _push(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments); int Toy_private_push(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments);
int _pop(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments); int Toy_private_pop(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments);
int _length(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments); int Toy_private_length(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments);
int _clear(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments); int Toy_private_clear(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments);

View File

@@ -1574,7 +1574,7 @@ static bool execIndex(Toy_Interpreter* interpreter, bool assignIntermediate) {
} }
//call the _index function //call the _index function
if (_index(interpreter, &arguments) < 0) { if (Toy_private_index(interpreter, &arguments) < 0) {
interpreter->errorOutput("Something went wrong while indexing: "); interpreter->errorOutput("Something went wrong while indexing: ");
Toy_printLiteralCustom(idn, interpreter->errorOutput); Toy_printLiteralCustom(idn, interpreter->errorOutput);
interpreter->errorOutput("\n"); interpreter->errorOutput("\n");
@@ -1693,7 +1693,7 @@ static bool execIndexAssign(Toy_Interpreter* interpreter) {
Toy_pushLiteralArray(&arguments, op); //it expects an assignment "opcode" Toy_pushLiteralArray(&arguments, op); //it expects an assignment "opcode"
//call the _index function //call the _index function
if (_index(interpreter, &arguments) < 0) { if (Toy_private_index(interpreter, &arguments) < 0) {
//clean up //clean up
Toy_freeLiteral(assign); Toy_freeLiteral(assign);
Toy_freeLiteral(third); Toy_freeLiteral(third);
@@ -1741,7 +1741,7 @@ static bool execIndexAssign(Toy_Interpreter* interpreter) {
Toy_pushLiteralArray(&arguments, result); Toy_pushLiteralArray(&arguments, result);
Toy_pushLiteralArray(&arguments, op); Toy_pushLiteralArray(&arguments, op);
if (_index(interpreter, &arguments) < 0) { if (Toy_private_index(interpreter, &arguments) < 0) {
interpreter->errorOutput("Something went wrong while indexing: "); interpreter->errorOutput("Something went wrong while indexing: ");
Toy_printLiteralCustom(idn, interpreter->errorOutput); Toy_printLiteralCustom(idn, interpreter->errorOutput);
interpreter->errorOutput("\n"); interpreter->errorOutput("\n");
@@ -2434,12 +2434,12 @@ void Toy_resetInterpreter(Toy_Interpreter* interpreter) {
interpreter->scope = Toy_pushScope(NULL); interpreter->scope = Toy_pushScope(NULL);
//globally available functions //globally available functions
Toy_injectNativeFn(interpreter, "_set", _set); Toy_injectNativeFn(interpreter, "_set", Toy_private_set);
Toy_injectNativeFn(interpreter, "_get", _get); Toy_injectNativeFn(interpreter, "_get", Toy_private_get);
Toy_injectNativeFn(interpreter, "_push", _push); Toy_injectNativeFn(interpreter, "_push", Toy_private_push);
Toy_injectNativeFn(interpreter, "_pop", _pop); Toy_injectNativeFn(interpreter, "_pop", Toy_private_pop);
Toy_injectNativeFn(interpreter, "_length", _length); Toy_injectNativeFn(interpreter, "_length", Toy_private_length);
Toy_injectNativeFn(interpreter, "_clear", _clear); Toy_injectNativeFn(interpreter, "_clear", Toy_private_clear);
} }
void Toy_freeInterpreter(Toy_Interpreter* interpreter) { void Toy_freeInterpreter(Toy_Interpreter* interpreter) {

View File

@@ -112,7 +112,7 @@ typedef struct {
PrecedenceRule precedence; PrecedenceRule precedence;
} ParseRule; } ParseRule;
ParseRule parseRules[]; static ParseRule parseRules[];
//forward declarations //forward declarations
static void declaration(Toy_Parser* parser, Toy_ASTNode** nodeHandle); static void declaration(Toy_Parser* parser, Toy_ASTNode** nodeHandle);