WIP: symbol def
authorLukas Krickl <lukas@krickl.dev>
Sat, 2 Dec 2023 11:17:51 +0000 (12:17 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 2 Dec 2023 11:17:51 +0000 (12:17 +0100)
include/ulas.h
src/ulas.c

index 6ca65e500d480a0b78d6bb7321bbf1d349a16064..dcd60bf4be355c73633424b0fd9bf39c28cfc240 100644 (file)
@@ -418,7 +418,8 @@ struct ulas_sym *ulas_symbolresolve(const char *name, int *rc);
 // the function to auto-detect the scope
 // if a label starts with @ the current scope is used, otherwise 0 is used
 // if the symbol already exists -1 is returned
-int ulas_symbolset(int scope, struct ulas_sym symbol);
+int ulas_symbolset(const char *name, int scope, struct ulas_tok tok,
+                   int constant);
 
 // tokenisze according to pre-defined rules
 // returns the amount of bytes of line that were
index ad101e6b418a5670fd4da7b0c8d7819fc5a9f539..466409f70ed9631ac1a6f7e750c2b0576960d9f0 100644 (file)
@@ -223,10 +223,10 @@ struct ulas_sym *ulas_symbolresolve(const char *name, int *rc) {
   return NULL;
 }
 
-int ulas_symbolset(int scope, struct ulas_sym symbol) {
+int ulas_symbolset(const char *name, int scope, struct ulas_tok tok,
+                   int constant) {
   int rc = 0;
   int resolve_rc = 0;
-  const char *name = symbol.name;
   struct ulas_sym *exisitng = ulas_symbolresolve(name, &resolve_rc);
   // define new
   if (!exisitng) {
@@ -1164,6 +1164,7 @@ struct ulas_sym *ulas_symbufget(struct ulas_symbuf *sb, int i) {
 void ulas_symbufclear(struct ulas_symbuf *sb) {
   for (long i = 0; i < sb->len; i++) {
     struct ulas_sym *s = &sb->buf[i];
+    free(s->name);
     ulas_tokfree(&s->tok);
   }
   sb->len = 0;