Merging master to handle vector members, fields, and members of vector fields
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 12 Aug 2012 08:08:41 +0000 (10:08 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 12 Aug 2012 08:08:41 +0000 (10:08 +0200)
1  2 
ast.c
gmqcc.h
ir.c
ir.h

diff --cc ast.c
index 5f947b0e02903709cde800090c03f877a1b31048,e6d28a61d19a4dcc32672c794a52f62657a4e49c..117f845ae0bc816b40a99f5a3ab0a9741ace5ac6
--- 1/ast.c
--- 2/ast.c
+++ b/ast.c
@@@ -628,11 -637,21 +649,23 @@@ bool ast_global_codegen(ast_value *self
          return true;
      }
  
+     if (self->expression.vtype == TYPE_FIELD) {
+         v = ir_builder_create_field(ir, self->name, self->expression.next->expression.vtype);
+         if (!v)
+             return false;
+         if (self->isconst) {
+             printf("TODO: constant field pointers with value\n");
+             goto error;
+         }
+         self->ir_v = v;
+         return true;
+     }
      v = ir_builder_create_global(ir, self->name, self->expression.vtype);
 -    if (!v)
 +    if (!v) {
 +        printf("ir_builder_create_global failed\n");
          return false;
 +    }
  
      if (self->isconst) {
          switch (self->expression.vtype)
diff --cc gmqcc.h
Simple merge
diff --cc ir.c
index f34cc911a3242b7100e7f1153203367ae1003392,e01da4d4e102c8c6e9d93e5be5f97ed3d047b876..78c97c7058e6230e397c4ec8a9da343555a0589c
--- 1/ir.c
--- 2/ir.c
+++ b/ir.c
@@@ -676,24 -664,15 +694,33 @@@ bool ir_value_set_vector(ir_value *self
      return true;
  }
  
 +bool ir_value_set_quaternion(ir_value *self, quaternion v)
 +{
 +    if (self->vtype != TYPE_QUATERNION)
 +        return false;
 +    memcpy(&self->constval.vquat, v, sizeof(self->constval.vquat));
 +    self->isconst = true;
 +    return true;
 +}
 +
 +bool ir_value_set_matrix(ir_value *self, matrix v)
 +{
 +    if (self->vtype != TYPE_MATRIX)
 +        return false;
 +    memcpy(&self->constval.vmat, v, sizeof(self->constval.vmat));
 +    self->isconst = true;
 +    return true;
 +}
 +
+ bool ir_value_set_field(ir_value *self, ir_value *fld)
+ {
+     if (self->vtype != TYPE_FIELD)
+         return false;
+     self->constval.vpointer = fld;
+     self->isconst = true;
+     return true;
+ }
  bool ir_value_set_string(ir_value *self, const char *str)
  {
      if (self->vtype != TYPE_STRING)
diff --cc ir.h
index a4dddcb937ea5a151f993e599f98b9a0f5b5881b,dccc970f3a632b0dc3fc1167574905b8e78a3ee7..66336d6ae5a6b64a5a8e9a2ff64c2e54c48d22ed
--- 1/ir.h
--- 2/ir.h
+++ b/ir.h
@@@ -97,10 -95,9 +97,11 @@@ bool GMQCC_WARN ir_value_set_int(ir_val
  #endif
  bool GMQCC_WARN ir_value_set_string(ir_value*, const char *s);
  bool GMQCC_WARN ir_value_set_vector(ir_value*, vector v);
+ bool GMQCC_WARN ir_value_set_field(ir_value*, ir_value *fld);
  /*bool   ir_value_set_pointer_v(ir_value*, ir_value* p); */
  /*bool   ir_value_set_pointer_i(ir_value*, int i);       */
 +bool GMQCC_WARN ir_value_set_quaternion(ir_value*, quaternion v);
 +bool GMQCC_WARN ir_value_set_matrix(ir_value*, matrix v);
  
  MEM_VECTOR_PROTO(ir_value, ir_life_entry_t, life);
  /* merge an instruction into the life-range */