From 9c766ec61e94a1787d691d01edaa67e920e19813 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 28 Aug 2022 01:35:00 +0100 Subject: [PATCH] Working on memory issues --- docs/TODO.txt | 2 ++ source/interpreter.c | 2 ++ source/parser.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/TODO.txt b/docs/TODO.txt index 7e9fe34..1a309b4 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -26,6 +26,7 @@ DONE: assert needs to kill the whole script, not just functions DONE: native functions DONE: global functions _get, _set, _push, _pop, _length, clear available + TODO: slice and dot notation around the _index function TODO: ternary operator TODO: Nullish types @@ -37,5 +38,6 @@ TODO: standard library TODO: external runner library TODO: document how it all works TODO: third output stream, for parser/compiler/interpreter errors +TODO: better and more consistent error messages NOPE: functions return a set number of values \ No newline at end of file diff --git a/source/interpreter.c b/source/interpreter.c index f7c4ecd..4daeaec 100644 --- a/source/interpreter.c +++ b/source/interpreter.c @@ -42,6 +42,8 @@ bool injectNativeFn(Interpreter* interpreter, char* name, NativeFn func) { setLiteralDictionary(&interpreter->scope->variables, identifier, fn); setLiteralDictionary(&interpreter->scope->types, identifier, type); + freeLiteral(identifier); + return true; } diff --git a/source/parser.c b/source/parser.c index bc3a431..ada6e56 100644 --- a/source/parser.c +++ b/source/parser.c @@ -1377,7 +1377,7 @@ static void varDecl(Parser* parser, Node** nodeHandle) { static void fnDecl(Parser* parser, Node** nodeHandle) { //read the identifier - consume(parser, TOKEN_IDENTIFIER, "Expected identifier after var keyword"); + consume(parser, TOKEN_IDENTIFIER, "Expected identifier after fn keyword"); Token identifierToken = parser->previous; int length = identifierToken.length;