summaryrefslogtreecommitdiff
path: root/com.h
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-24 20:20:06 +0100
committerubq323 <ubq323@ubq323.website>2024-06-24 20:20:06 +0100
commite9b99a90510309ac4f5d91d4a5138e7a84904057 (patch)
tree9d633feb897bcbbd43da6419882df600f9de5595 /com.h
parentbc47478d855b08023409dbfc8550958991265c14 (diff)
add local variables and (let) form
Diffstat (limited to 'com.h')
-rw-r--r--com.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/com.h b/com.h
index 26b7494..c623d49 100644
--- a/com.h
+++ b/com.h
@@ -7,10 +7,24 @@ typedef struct _compiler Compiler;
#include "chunk.h"
+typedef struct {
+ char *name;
+ uint8_t slot;
+} Local;
+
+#define MAX_LOCALS 256
+typedef struct _scope Scope;
+struct _scope {
+ Scope *outer;
+ uint8_t nlocals;
+ Local locals[MAX_LOCALS];
+};
+
struct _compiler {
State *S;
Chunk *ch;
int stack_cur;
+ Scope *scope;
};
Compiler compiler_new(Compiler *outer, Chunk *ch);