mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-24 04:41:25 +00:00
Constant folding for strings
This commit is contained in:
parent
41a76ab91d
commit
ff37abb0c7
1 changed files with 7 additions and 3 deletions
10
fold.c
10
fold.c
|
@ -1373,11 +1373,15 @@ static GMQCC_INLINE ast_expression *fold_op_cmp(fold_t *fold, ast_value *a, ast_
|
|||
float la = fold_immvalue_float(a);
|
||||
float lb = fold_immvalue_float(b);
|
||||
fold_check_inexact_float(fold, a, b);
|
||||
return (ast_expression*)fold->imm_float[!(ne ? la == lb : la != lb)];
|
||||
} if (isvector(a) && isvector(b)) {
|
||||
return (ast_expression*)fold->imm_float[ne ? la != lb : la == lb];
|
||||
} else if (isvector(a) && isvector(b)) {
|
||||
vec3_t la = fold_immvalue_vector(a);
|
||||
vec3_t lb = fold_immvalue_vector(b);
|
||||
return (ast_expression*)fold->imm_float[!(ne ? vec3_cmp(la, lb) : !vec3_cmp(la, lb))];
|
||||
bool compare = vec3_cmp(la, lb);
|
||||
return (ast_expression*)fold->imm_float[ne ? !compare : compare];
|
||||
} else if (isstring(a) && isstring(b)) {
|
||||
bool compare = !strcmp(fold_immvalue_string(a), fold_immvalue_string(b));
|
||||
return (ast_expression*)fold->imm_float[ne ? !compare : compare];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue