mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-24 20:21:38 +00:00
-fperl-logic, off by default, so casting to boolean now
This commit is contained in:
parent
ebc6954bf5
commit
de5592dfc5
2 changed files with 32 additions and 17 deletions
24
ast.c
24
ast.c
|
@ -1538,17 +1538,21 @@ bool ast_binary_codegen(ast_binary *self, ast_function *func, bool lvalue, ir_va
|
||||||
cgen = self->left->expression.codegen;
|
cgen = self->left->expression.codegen;
|
||||||
if (!(*cgen)((ast_expression*)(self->left), func, false, &left))
|
if (!(*cgen)((ast_expression*)(self->left), func, false, &left))
|
||||||
return false;
|
return false;
|
||||||
|
if (!OPTS_FLAG(PERL_LOGIC)) {
|
||||||
notop = type_not_instr[left->vtype];
|
notop = type_not_instr[left->vtype];
|
||||||
if (notop == AINSTR_END) {
|
if (notop == AINSTR_END) {
|
||||||
asterror(ast_ctx(self), "don't know how to cast to bool...");
|
asterror(ast_ctx(self), "don't know how to cast to bool...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
left = ir_block_create_unary(func->curblock, ast_function_label(func, "sce_not"), notop, left);
|
left = ir_block_create_unary(func->curblock,
|
||||||
|
ast_function_label(func, "sce_not"),
|
||||||
|
notop,
|
||||||
|
left);
|
||||||
|
}
|
||||||
from_left = func->curblock;
|
from_left = func->curblock;
|
||||||
|
|
||||||
other = ir_function_create_block(func->ir_func, ast_function_label(func, "sce_other"));
|
other = ir_function_create_block(func->ir_func, ast_function_label(func, "sce_other"));
|
||||||
if (self->op == INSTR_OR) {
|
if ( !(self->op == INSTR_OR) != !OPTS_FLAG(PERL_LOGIC) ) {
|
||||||
if (!ir_block_create_if(func->curblock, left, other, merge))
|
if (!ir_block_create_if(func->curblock, left, other, merge))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1562,12 +1566,17 @@ bool ast_binary_codegen(ast_binary *self, ast_function *func, bool lvalue, ir_va
|
||||||
cgen = self->right->expression.codegen;
|
cgen = self->right->expression.codegen;
|
||||||
if (!(*cgen)((ast_expression*)(self->right), func, false, &right))
|
if (!(*cgen)((ast_expression*)(self->right), func, false, &right))
|
||||||
return false;
|
return false;
|
||||||
|
if (!OPTS_FLAG(PERL_LOGIC)) {
|
||||||
notop = type_not_instr[right->vtype];
|
notop = type_not_instr[right->vtype];
|
||||||
if (notop == AINSTR_END) {
|
if (notop == AINSTR_END) {
|
||||||
asterror(ast_ctx(self), "don't know how to cast to bool...");
|
asterror(ast_ctx(self), "don't know how to cast to bool...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
right = ir_block_create_unary(func->curblock, ast_function_label(func, "sce_not"), notop, right);
|
right = ir_block_create_unary(func->curblock,
|
||||||
|
ast_function_label(func, "sce_not"),
|
||||||
|
notop,
|
||||||
|
right);
|
||||||
|
}
|
||||||
from_right = func->curblock;
|
from_right = func->curblock;
|
||||||
|
|
||||||
if (!ir_block_create_jump(func->curblock, merge))
|
if (!ir_block_create_jump(func->curblock, merge))
|
||||||
|
@ -1581,12 +1590,17 @@ bool ast_binary_codegen(ast_binary *self, ast_function *func, bool lvalue, ir_va
|
||||||
ir_phi_add(phi, from_left, left);
|
ir_phi_add(phi, from_left, left);
|
||||||
ir_phi_add(phi, from_right, right);
|
ir_phi_add(phi, from_right, right);
|
||||||
*out = ir_phi_value(phi);
|
*out = ir_phi_value(phi);
|
||||||
|
if (!OPTS_FLAG(PERL_LOGIC)) {
|
||||||
notop = type_not_instr[(*out)->vtype];
|
notop = type_not_instr[(*out)->vtype];
|
||||||
if (notop == AINSTR_END) {
|
if (notop == AINSTR_END) {
|
||||||
asterror(ast_ctx(self), "don't know how to cast to bool...");
|
asterror(ast_ctx(self), "don't know how to cast to bool...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*out = ir_block_create_unary(func->curblock, ast_function_label(func, "sce_final_not"), notop, *out);
|
*out = ir_block_create_unary(func->curblock,
|
||||||
|
ast_function_label(func, "sce_final_not"),
|
||||||
|
notop,
|
||||||
|
*out);
|
||||||
|
}
|
||||||
self->expression.outr = *out;
|
self->expression.outr = *out;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
1
opts.def
1
opts.def
|
@ -34,6 +34,7 @@
|
||||||
GMQCC_DEFINE_FLAG(FTEPP)
|
GMQCC_DEFINE_FLAG(FTEPP)
|
||||||
GMQCC_DEFINE_FLAG(RELAXED_SWITCH)
|
GMQCC_DEFINE_FLAG(RELAXED_SWITCH)
|
||||||
GMQCC_DEFINE_FLAG(SHORT_LOGIC)
|
GMQCC_DEFINE_FLAG(SHORT_LOGIC)
|
||||||
|
GMQCC_DEFINE_FLAG(PERL_LOGIC)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* warning flags */
|
/* warning flags */
|
||||||
|
|
Loading…
Reference in a new issue