X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=ast.cpp;h=1ac0a4418fe73032a086427dee3f225a51790275;hp=b507a6b45bfa56b932ca7699f2cb0689697e2f4d;hb=97a74eb677071f3a73a07f940cc5c6ea1c9b2e4b;hpb=3a7848d67c76cba48dfea49b56354e18c254600e diff --git a/ast.cpp b/ast.cpp index b507a6b..1ac0a44 100644 --- a/ast.cpp +++ b/ast.cpp @@ -1510,9 +1510,9 @@ bool ast_function::generateFunction(ir_builder *ir) /* fill the parameter list */ for (auto &it : m_function_type->m_type_params) { if (it->m_vtype == TYPE_FIELD) - vec_push(irf->m_params, it->m_next->m_vtype); + irf->m_params.push_back(it->m_next->m_vtype); else - vec_push(irf->m_params, it->m_vtype); + irf->m_params.push_back(it->m_vtype); if (!m_builtin) { if (!it->generateLocal(m_ir_func, true)) return false; @@ -1582,7 +1582,7 @@ bool ast_function::generateFunction(ir_builder *ir) { return ir_block_create_return(m_curblock, m_context, nullptr); } - else if (vec_size(m_curblock->m_entries) || m_curblock == irf->m_first) + else if (m_curblock->m_entries.size() || m_curblock == irf->m_first) { if (m_return_value) { if (!m_return_value->codegen(this, false, &dummy)) @@ -1804,7 +1804,7 @@ bool ast_binary::codegen(ast_function *func, bool lvalue, ir_value **out) return false; } /* use the likely flag */ - vec_last(func->m_curblock->m_instr)->m_likely = true; + func->m_curblock->m_instr.back()->m_likely = true; /* enter the right-expression's block */ func->m_curblock = other; @@ -1932,6 +1932,7 @@ bool ast_binstore::codegen(ast_function *func, bool lvalue, ir_value **out) if (!idx->codegen(func, false, &iridx)) return false; } + if (!m_dest->codegen(func, false, &leftr)) return false; @@ -2153,19 +2154,28 @@ bool ast_member::codegen(ast_function *func, bool lvalue, ir_value **out) else m_outr = *out; return (*out != nullptr); - } else { - if (!m_owner->codegen(func, false, &vec)) - return false; } + // Vector member access + if (!m_owner->codegen(func, lvalue, &vec)) + return false; + if (vec->m_vtype != TYPE_VECTOR && !(vec->m_vtype == TYPE_FIELD && m_owner->m_next->m_vtype == TYPE_VECTOR)) { + compile_error(m_context, "vector member produced neither vector nor field"); return false; } *out = vec->vectorMember(m_field); - m_outl = *out; + if (!*out) { + compile_error(m_context, "internal error: failed to create vector member access"); + return false; + } + if (lvalue) + m_outl = *out; + else + m_outr = *out; return (*out != nullptr); }