+ case opid2('*','='):
+ case opid2('/','='):
+ if (exprs[1]->expression.vtype != TYPE_FLOAT ||
+ !(exprs[0]->expression.vtype == TYPE_FLOAT ||
+ exprs[0]->expression.vtype == TYPE_VECTOR))
+ {
+ ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+ ast_type_to_string(exprs[1], ty2, sizeof(ty2));
+ parseerror(parser, "invalid types used in expression: %s and %s",
+ ty1, ty2);
+ return false;
+ }
+ if (ast_istype(exprs[0], ast_value) && asvalue[0]->cvq == CV_CONST) {
+ parseerror(parser, "assignment to constant `%s`", asvalue[0]->name);
+ }
+ if (ast_istype(exprs[0], ast_entfield))
+ assignop = type_storep_instr[exprs[0]->expression.vtype];
+ else
+ assignop = type_store_instr[exprs[0]->expression.vtype];
+ switch (exprs[0]->expression.vtype) {
+ case TYPE_FLOAT:
+ out = (ast_expression*)ast_binstore_new(ctx, assignop,
+ (op->id == opid2('*','=') ? INSTR_MUL_F : INSTR_DIV_F),
+ exprs[0], exprs[1]);
+ break;
+ case TYPE_VECTOR:
+ if (op->id == opid2('*','=')) {
+ out = (ast_expression*)ast_binstore_new(ctx, assignop, INSTR_MUL_VF,
+ exprs[0], exprs[1]);
+ } else {
+ /* there's no DIV_VF */
+ out = (ast_expression*)ast_binary_new(ctx, INSTR_DIV_F,
+ (ast_expression*)parser_const_float_1(parser),
+ exprs[1]);
+ if (!out)
+ return false;
+ out = (ast_expression*)ast_binstore_new(ctx, assignop, INSTR_MUL_VF,
+ exprs[0], out);
+ }
+ break;
+ default:
+ parseerror(parser, "invalid types used in expression: cannot add or subtract type %s and %s",
+ type_name[exprs[0]->expression.vtype],
+ type_name[exprs[1]->expression.vtype]);
+ return false;
+ };
+ break;
+ case opid2('&','='):
+ case opid2('|','='):
+ if (NotSameType(TYPE_FLOAT)) {
+ ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+ ast_type_to_string(exprs[1], ty2, sizeof(ty2));
+ parseerror(parser, "invalid types used in expression: %s and %s",
+ ty1, ty2);
+ return false;
+ }
+ if (ast_istype(exprs[0], ast_value) && asvalue[0]->cvq == CV_CONST) {
+ parseerror(parser, "assignment to constant `%s`", asvalue[0]->name);
+ }
+ if (ast_istype(exprs[0], ast_entfield))
+ assignop = type_storep_instr[exprs[0]->expression.vtype];
+ else
+ assignop = type_store_instr[exprs[0]->expression.vtype];
+ out = (ast_expression*)ast_binstore_new(ctx, assignop,
+ (op->id == opid2('&','=') ? INSTR_BITAND : INSTR_BITOR),
+ exprs[0], exprs[1]);
+ break;
+ case opid3('&','~','='):
+ /* This is like: a &= ~(b);
+ * But QC has no bitwise-not, so we implement it as
+ * a -= a & (b);
+ */
+ if (NotSameType(TYPE_FLOAT)) {
+ ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+ ast_type_to_string(exprs[1], ty2, sizeof(ty2));
+ parseerror(parser, "invalid types used in expression: %s and %s",
+ ty1, ty2);
+ return false;
+ }
+ if (ast_istype(exprs[0], ast_entfield))
+ assignop = type_storep_instr[exprs[0]->expression.vtype];
+ else
+ assignop = type_store_instr[exprs[0]->expression.vtype];
+ out = (ast_expression*)ast_binary_new(ctx, INSTR_BITAND, exprs[0], exprs[1]);
+ if (!out)
+ return false;
+ if (ast_istype(exprs[0], ast_value) && asvalue[0]->cvq == CV_CONST) {
+ parseerror(parser, "assignment to constant `%s`", asvalue[0]->name);
+ }
+ asbinstore = ast_binstore_new(ctx, assignop, INSTR_SUB_F, exprs[0], out);
+ asbinstore->keep_dest = true;
+ out = (ast_expression*)asbinstore;
+ break;