WIP: symbol definition
authorLukas Krickl <lukas@krickl.dev>
Sat, 2 Dec 2023 10:52:30 +0000 (11:52 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 2 Dec 2023 10:52:30 +0000 (11:52 +0100)
include/ulas.h
src/ulas.c

index 83d90288c93e50898d142e85de1134dce3238289..6ca65e500d480a0b78d6bb7321bbf1d349a16064 100644 (file)
@@ -414,9 +414,11 @@ char *ulas_strndup(const char *src, unsigned long n);
 struct ulas_sym *ulas_symbolresolve(const char *name, int *rc);
 
 // define a new symbol
-// scope 0 indicates global scope
+// scope 0 indicates global scope. a scope of -1 instructs
+// 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(const char *name, int scope, struct ulas_tok token);
+int ulas_symbolset(int scope, struct ulas_sym symbol);
 
 // tokenisze according to pre-defined rules
 // returns the amount of bytes of line that were
index c2d79cfacc436a69d35c18590d150fa5b6780dc8..ad101e6b418a5670fd4da7b0c8d7819fc5a9f539 100644 (file)
@@ -223,9 +223,10 @@ struct ulas_sym *ulas_symbolresolve(const char *name, int *rc) {
   return NULL;
 }
 
-int ulas_symbolset(const char *name, int scope, struct ulas_tok token) {
+int ulas_symbolset(int scope, struct ulas_sym symbol) {
   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) {
@@ -2059,7 +2060,7 @@ int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) {
         ulas_asmlst(start, outbuf, towrite);
         return 0;
       }
-      // ulas_symbolset(ulas.tok.buf, ulas.scope, 
+      // ulas_symbolset(ulas.tok.buf, -1,
       line = prev;
     } else {
       // start over for the next step...