Chapter 17.7

This commit is contained in:
Tom Willemse 2021-08-17 20:47:18 -07:00
parent 964859a8a1
commit 3a02da2161
Signed by: ryuslash
GPG key ID: 7D5C407B435025C1
2 changed files with 13 additions and 1 deletions

View file

@ -5,6 +5,7 @@
#include <stddef.h>
#include <stdint.h>
#define DEBUG_PRINT_CODE
#define DEBUG_TRACE_EXECUTION
#endif

View file

@ -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);