]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
added __STD_VERSION_[MINOR/MAJOR]__, and vec_upload
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index bf08a5d426a8d874128905d1f9120056d8bccf7a..dbb1d97a46ae58e8d881a3ec40a351aaa395ba49 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -193,6 +193,11 @@ uint16_t type_not_instr[TYPE_COUNT] = {
     AINSTR_END, /* array  */
 };
 
+/* protos */
+static void ir_gen_extparam(ir_builder *ir);
+
+/* error functions */
+
 static void irerror(lex_ctx ctx, const char *msg, ...)
 {
     va_list ap;
@@ -2671,10 +2676,8 @@ tailcall:
                 ir_value *param = instr->params[p];
                 ir_value *targetparam;
 
-                if (p-8 >= vec_size(ir->extparams)) {
-                    irerror(instr->context, "Not enough extparam-globals have been created");
-                    return false;
-                }
+                if (p-8 >= vec_size(ir->extparams))
+                    ir_gen_extparam(ir);
 
                 targetparam = ir->extparams[p-8];
 
@@ -2846,7 +2849,10 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
     if (vec_size(irfun->locals)) {
         ir_value *last = vec_last(irfun->locals);
         local_var_end = last->code.globaladdr;
-        local_var_end += type_sizeof[last->vtype];
+        if (last->vtype == TYPE_FIELD && last->fieldtype == TYPE_VECTOR)
+            local_var_end += type_sizeof[TYPE_VECTOR];
+        else
+            local_var_end += type_sizeof[last->vtype];
     }
     for (i = 0; i < vec_size(irfun->values); ++i)
     {
@@ -2862,7 +2868,7 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
     fun.locals = vec_size(code_globals) - fun.firstlocal;
 
     if (irfun->builtin)
-        fun.entry = irfun->builtin;
+        fun.entry = irfun->builtin+1;
     else {
         irfun->code_function_def = vec_size(code_functions);
         fun.entry = vec_size(code_statements);