aboutsummaryrefslogtreecommitdiffstats
path: root/clox/src/compiler.c
diff options
context:
space:
mode:
authorGravatar Tom Willemse2022-06-04 22:00:27 -0700
committerGravatar Tom Willemse2022-06-04 22:00:27 -0700
commit14b3866ac09c80b8f34d79227d743eabb2da0f2a (patch)
tree62eb3137f016ceaec9d0c88e527a663372927d59 /clox/src/compiler.c
parent57ed9226c06b5fbe016e62857fe9662c51da3dfd (diff)
downloadcrafting-interpreters-14b3866ac09c80b8f34d79227d743eabb2da0f2a.tar.gz
crafting-interpreters-14b3866ac09c80b8f34d79227d743eabb2da0f2a.zip
Chapter 26.1, 26.2, 26.3, and 26.4
Diffstat (limited to 'clox/src/compiler.c')
-rw-r--r--clox/src/compiler.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/clox/src/compiler.c b/clox/src/compiler.c
index 75ed697..f31d015 100644
--- a/clox/src/compiler.c
+++ b/clox/src/compiler.c
@@ -4,6 +4,7 @@
#include "common.h"
#include "compiler.h"
+#include "memory.h"
#include "scanner.h"
#ifdef DEBUG_PRINT_CODE
@@ -827,3 +828,11 @@ ObjFunction *compile(const char *source) {
ObjFunction *function = endCompiler();
return parser.hadError ? NULL : function;
}
+
+void markCompilerRoots() {
+ Compiler *compiler = current;
+ while (compiler != NULL) {
+ markObject((Obj *)compiler->function);
+ compiler = compiler->enclosing;
+ }
+}