Chapter 17.7
This commit is contained in:
parent
964859a8a1
commit
3a02da2161
2 changed files with 13 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define DEBUG_PRINT_CODE
|
||||
#define DEBUG_TRACE_EXECUTION
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue