aboutsummaryrefslogtreecommitdiffstats
path: root/clox/src/compiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'clox/src/compiler.c')
-rw-r--r--clox/src/compiler.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/clox/src/compiler.c b/clox/src/compiler.c
index 578af94..75df7aa 100644
--- a/clox/src/compiler.c
+++ b/clox/src/compiler.c
@@ -5,6 +5,10 @@
#include "compiler.h"
#include "scanner.h"
+#ifdef DEBUG_PRINT_CODE
+#include "debug.h"
+#endif
+
typedef struct {
Token current;
Token previous;
@@ -109,7 +113,14 @@ static void emitConstant(Value value) {
emitBytes(OP_CONSTANT, makeConstant(value));
}
-static void endCompiler() { emitReturn(); }
+static void endCompiler() {
+ emitReturn();
+#ifdef DEBUG_PRINT_CODE
+ if (!parser.hadError) {
+ disassembleChunk(currentChunk(), "code");
+ }
+#endif
+}
static void expression();
static ParseRule *getRule(TokenType type);