summary refs log tree commit diff
path: root/all.h
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2017-05-17 09:40:07 -0400
committerQuentin Carbonneaux <quentin@c9x.me>2017-05-17 10:05:28 -0400
commita3a1451c5fabb5c94f7fbeb13fdc6b1e2c23181f (patch)
tree1fb1ba60e8f3cab09c629ce9dd63e00e01974c39 /all.h
parent2d02070af019e9896ecf2a63bedc098092fd395d (diff)
downloadroux-a3a1451c5fabb5c94f7fbeb13fdc6b1e2c23181f.tar.gz
intern symbol names
Symbols in the source file are still limited in
length because the rest of the code assumes that
strings always fit in NString bytes.

Regardless, there is already a benefit because
comparing/copying symbol names does not require
using strcmp()/strcpy() anymore.
Diffstat (limited to 'all.h')
-rw-r--r--all.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/all.h b/all.h
index 1e9476d..b9ac9b2 100644
--- a/all.h
+++ b/all.h
@@ -275,7 +275,7 @@ struct Alias {
 	#define astack(t) ((t) & 1)
 	} type;
 	Ref base;
-	char label[NString];
+	uint32_t label;
 	int64_t offset;
 	Alias *slot;
 };
@@ -312,7 +312,7 @@ struct Con {
 		CBits,
 		CAddr,
 	} type;
-	char label[NString];
+	uint32_t label;
 	union {
 		int64_t i;
 		double d;
@@ -411,19 +411,22 @@ typedef enum {
 
 extern Typ *typ;
 extern Ins insb[NIns], *curi;
+uint32_t hash(char *);
 void die_(char *, char *, ...) __attribute__((noreturn));
 void *emalloc(size_t);
 void *alloc(size_t);
 void freeall(void);
+void *vnew(ulong, size_t, Pool);
+void vfree(void *);
+void vgrow(void *, ulong);
+uint32_t intern(char *);
+char *str(uint32_t);
 int argcls(Ins *, int);
 int iscmp(int, int *, int *);
 void emit(int, int, Ref, Ref, Ref);
 void emiti(Ins);
 void idup(Ins **, Ins *, ulong);
 Ins *icpy(Ins *, Ins *, ulong);
-void *vnew(ulong, size_t, Pool);
-void vfree(void *);
-void vgrow(void *, ulong);
 int cmpop(int);
 int cmpneg(int);
 int clsmerge(short *, short);