]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.h
cache filenames as such instead of using code_cachedstring
[xonotic/gmqcc.git] / ir.h
diff --git a/ir.h b/ir.h
index dccc970f3a632b0dc3fc1167574905b8e78a3ee7..825f6a7123db4893b40f23aacc0532e9feb2eef1 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -68,6 +68,7 @@ typedef struct ir_value_s {
 
     /* for acessing vectors */
     struct ir_value_s *members[3];
+    struct ir_value_s *memberof;
 
     /* For the temp allocator */
     MEM_VECTOR_MAKE(ir_life_entry_t, life);
@@ -82,7 +83,7 @@ ir_value* ir_value_var(const char *name, int st, int vtype);
  */
 ir_value* ir_value_out(struct ir_function_s *owner, const char *name, int st, int vtype);
 void      ir_value_delete(ir_value*);
-void      ir_value_set_name(ir_value*, const char *name);
+bool      ir_value_set_name(ir_value*, const char *name);
 ir_value* ir_value_vector_member(ir_value*, unsigned int member);
 
 MEM_VECTOR_PROTO_ALL(ir_value, struct ir_instr_s*, reads);
@@ -110,7 +111,7 @@ bool ir_value_lives(ir_value*, size_t);
 bool ir_values_overlap(const ir_value*, const ir_value*);
 
 void ir_value_dump(ir_value*, int (*oprintf)(const char*,...));
-void ir_value_dump_life(ir_value *self, int (*oprintf)(const char*,...));
+void ir_value_dump_life(const ir_value *self, int (*oprintf)(const char*,...));
 
 /* A vector of IR values */
 typedef struct {
@@ -260,6 +261,14 @@ typedef struct ir_function_s
 
     lex_ctx       context;
 
+    /* for prototypes - first we generate all the
+     * globals, and we remember teh function-defs
+     * so we can later fill in the entry pos
+     *
+     * remember the ID:
+     */
+    qcint code_function_def;
+
     /* for temp allocation */
     size_t run_id;
 
@@ -296,6 +305,9 @@ typedef struct ir_builder_s
     MEM_VECTOR_MAKE(ir_function*, functions);
     MEM_VECTOR_MAKE(ir_value*, globals);
     MEM_VECTOR_MAKE(ir_value*, fields);
+
+    MEM_VECTOR_MAKE(const char*, filenames);
+    MEM_VECTOR_MAKE(qcint,       filestrings);
 } ir_builder;
 
 ir_builder* ir_builder_new(const char *modulename);
@@ -304,8 +316,10 @@ void        ir_builder_delete(ir_builder*);
 bool ir_builder_set_name(ir_builder *self, const char *name);
 
 MEM_VECTOR_PROTO(ir_builder, ir_function*, functions);
-MEM_VECTOR_PROTO(ir_builder, ir_value*, globals);
-MEM_VECTOR_PROTO(ir_builder, ir_value*, fields);
+MEM_VECTOR_PROTO(ir_builder, ir_value*,    globals);
+MEM_VECTOR_PROTO(ir_builder, ir_value*,    fields);
+MEM_VECTOR_PROTO(ir_builder, const char*,  filenames);
+MEM_VECTOR_PROTO(ir_builder, qcint,        filestrings);
 
 ir_function* ir_builder_get_function(ir_builder*, const char *fun);
 ir_function* ir_builder_create_function(ir_builder*, const char *name, int outtype);
@@ -321,6 +335,6 @@ void ir_builder_dump(ir_builder*, int (*oprintf)(const char*, ...));
 
 /* This code assumes 32 bit floats while generating binary */
 extern int check_int_and_float_size
-[ (sizeof(int32_t) == sizeof(( (ir_value*)(NULL) )->constval.vvec.x)) ? 1 : -1 ];
+[ (sizeof(int32_t) == sizeof(qcfloat)) ? 1 : -1 ];
 
 #endif