]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.cpp
search for funciton param first before function locals, this fixes #163
[xonotic/gmqcc.git] / parser.cpp
index ddde65469ec77e7cb596e58451dc88096c5ad8f1..7e552325d544caf5ebb5a955bbf933d80f8f0926 100644 (file)
@@ -135,17 +135,22 @@ static ast_expression* parser_find_local(parser_t *parser, const char *name, siz
 {
     size_t          i, hash;
     ast_expression *e;
+    ast_expression *p;
 
     hash = util_hthash(parser->htglobals, name);
 
     *isparam = false;
+    p = parser_find_param(parser, name);
+    if (p) {
+        *isparam = true;
+        return p;
+    }
     for (i = parser->variables.size(); i > upto;) {
         --i;
         if ( (e = (ast_expression*)util_htgeth(parser->variables[i], name, hash)) )
             return e;
     }
-    *isparam = true;
-    return parser_find_param(parser, name);
+    return NULL;
 }
 
 static ast_expression* parser_find_local(parser_t *parser, const std::string &name, size_t upto, bool *isparam) {
@@ -296,7 +301,11 @@ static bool rotate_entfield_array_index_nodes(ast_expression **out)
 static int store_op_for(ast_expression* expr)
 {
     if (OPTS_FLAG(ADJUST_VECTOR_FIELDS) && expr->m_vtype == TYPE_FIELD && expr->m_next->m_vtype == TYPE_VECTOR) {
-        return type_storep_instr[TYPE_VECTOR];
+        if (ast_istype(expr, ast_entfield)) {
+            return type_storep_instr[TYPE_VECTOR];
+        } else {
+            return type_store_instr[TYPE_VECTOR];
+        }
     }
 
     if (ast_istype(expr, ast_member) && ast_istype(((ast_member*)expr)->m_owner, ast_entfield)) {