]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
cache the IMMEDIATE string in the builder directly
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 24 Aug 2012 17:52:06 +0000 (19:52 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 24 Aug 2012 17:52:06 +0000 (19:52 +0200)
ir.c
ir.h

diff --git a/ir.c b/ir.c
index 7af697961edc9902d79b1d95243244e6111fee7d..133aca5d66e179a60501fee268faa17365898fd1 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -168,6 +168,7 @@ ir_builder* ir_builder_new(const char *modulename)
     MEM_VECTOR_INIT(self, fields);
     MEM_VECTOR_INIT(self, filenames);
     MEM_VECTOR_INIT(self, filestrings);
+    self->str_immediate = 0;
     self->name = NULL;
     if (!ir_builder_set_name(self, modulename)) {
         mem_d(self);
@@ -2679,7 +2680,18 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
 
     def.type   = global->vtype;
     def.offset = code_globals_elements;
-    def.name   = global->code.name       = code_genstring(global->name);
+
+    if (global->name) {
+        if (global->name[0] == '#') {
+            if (!self->str_immediate)
+                self->str_immediate = code_genstring("IMMEDIATE");
+            def.name = global->code.name = self->str_immediate;
+        }
+        else
+            def.name = global->code.name = code_genstring(global->name);
+    }
+    else
+        def.name   = 0;
 
     switch (global->vtype)
     {
diff --git a/ir.h b/ir.h
index 825f6a7123db4893b40f23aacc0532e9feb2eef1..1059c6ed9c1753f5d15f7613b4f4fc6030ae47f4 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -308,6 +308,8 @@ typedef struct ir_builder_s
 
     MEM_VECTOR_MAKE(const char*, filenames);
     MEM_VECTOR_MAKE(qcint,       filestrings);
+    /* we cache the #IMMEDIATE string here */
+    qcint str_immediate;
 } ir_builder;
 
 ir_builder* ir_builder_new(const char *modulename);