X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=parser.c;h=f589d63629361ddc6b48edd09d20299bb93227ef;hp=e2bb6eeee6c6286ff984113ba90d1b48ffad67d0;hb=b3e87c328009c3c5b1b700d600733906d7792f59;hpb=fed0f8b6b42f11740d673131edecdff1764053a9 diff --git a/parser.c b/parser.c index e2bb6ee..f589d63 100644 --- a/parser.c +++ b/parser.c @@ -671,8 +671,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) return false; } } - if (!ast_block_set_type(blocks[0], exprs[1])) - return false; + ast_block_set_type(blocks[0], exprs[1]); vec_push(sy->out, syblock(ctx, blocks[0])); return true; @@ -1086,23 +1085,21 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) else if (ConstF(0) > ConstF(1)) out = (ast_expression*)parser_const_float_1(parser); } else { + ast_binary *eq = ast_binary_new(ctx, INSTR_EQ_F, exprs[0], exprs[1]); + + eq->refs = false; /* references nothing */ + /* if (lt) { */ out = (ast_expression*)ast_ternary_new(ctx, (ast_expression*)ast_binary_new(ctx, INSTR_LT, exprs[0], exprs[1]), - /* out = -1 */ (ast_expression*)parser_const_float_neg1(parser), - /* } else { */ /* if (eq) { */ - (ast_expression*)ast_ternary_new(ctx, - (ast_expression*)ast_binary_new(ctx, INSTR_EQ_F, exprs[0], exprs[1]), - + (ast_expression*)ast_ternary_new(ctx, (ast_expression*)eq, /* out = 0 */ (ast_expression*)parser_const_float_0(parser), - /* } else { */ - /* out = 1 */ (ast_expression*)parser_const_float_1(parser) /* } */ @@ -1942,12 +1939,8 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma } } if (o == operator_count) { - /* no operator found... must be the end of the statement */ compile_error(parser_ctx(parser), "unknown operator: %s", parser_tokval(parser)); goto onerr; - - /*Are there any expressions which actually end with an operator?*/ - /*break;*/ } /* found an operator */ op = &operators[o]; @@ -3899,11 +3892,12 @@ static bool parse_function_body(parser_t *parser, ast_value *var) ast_expression *functype = fld_think->expression.next; thinkfunc = ast_value_new(parser_ctx(parser), parser_tokval(parser), functype->expression.vtype); - if (!thinkfunc || !ast_type_adopt(thinkfunc, functype)) { + if (!thinkfunc) { /* || !ast_type_adopt(thinkfunc, functype)*/ ast_unref(framenum); parseerror(parser, "failed to create implicit prototype for `%s`", parser_tokval(parser)); return false; } + ast_type_adopt(thinkfunc, functype); if (!parser_next(parser)) { ast_unref(framenum);