return out;
}
+static GMQCC_INLINE vec3_t vec3_or(vec3_t a, vec3_t b) {
+ vec3_t out;
+ out.x = (qcfloat_t)(((qcint_t)a.x) | ((qcint_t)b.x));
+ out.y = (qcfloat_t)(((qcint_t)a.y) | ((qcint_t)b.y));
+ out.z = (qcfloat_t)(((qcint_t)a.z) | ((qcint_t)b.z));
+ return out;
+}
+
+static GMQCC_INLINE vec3_t vec3_orvf(vec3_t a, qcfloat_t b) {
+ vec3_t out;
+ out.x = (qcfloat_t)(((qcint_t)a.x) | ((qcint_t)b));
+ out.y = (qcfloat_t)(((qcint_t)a.y) | ((qcint_t)b));
+ out.z = (qcfloat_t)(((qcint_t)a.z) | ((qcint_t)b));
+ return out;
+}
+
+static GMQCC_INLINE vec3_t vec3_and(vec3_t a, vec3_t b) {
+ vec3_t out;
+ out.x = (qcfloat_t)(((qcint_t)a.x) & ((qcint_t)b.x));
+ out.y = (qcfloat_t)(((qcint_t)a.y) & ((qcint_t)b.y));
+ out.z = (qcfloat_t)(((qcint_t)a.z) & ((qcint_t)b.z));
+ return out;
+}
+
+static GMQCC_INLINE vec3_t vec3_andvf(vec3_t a, qcfloat_t b) {
+ vec3_t out;
+ out.x = (qcfloat_t)(((qcint_t)a.x) & ((qcint_t)b));
+ out.y = (qcfloat_t)(((qcint_t)a.y) & ((qcint_t)b));
+ out.z = (qcfloat_t)(((qcint_t)a.z) & ((qcint_t)b));
+ return out;
+}
+
static GMQCC_INLINE vec3_t vec3_xor(vec3_t a, vec3_t b) {
vec3_t out;
out.x = (qcfloat_t)(((qcint_t)a.x) ^ ((qcint_t)b.x));
return out;
}
+static GMQCC_INLINE vec3_t vec3_not(vec3_t a) {
+ vec3_t out;
+ out.x = (qcfloat_t)(~((qcint_t)a.x));
+ out.y = (qcfloat_t)(~((qcint_t)a.y));
+ out.z = (qcfloat_t)(~((qcint_t)a.z));
+ return out;
+}
+
static GMQCC_INLINE qcfloat_t vec3_mulvv(vec3_t a, vec3_t b) {
return (a.x * b.x + a.y * b.y + a.z * b.z);
}
(void)fold_constgen_float (fold, -1.0f);
(void)fold_constgen_vector(fold, vec3_create(0.0f, 0.0f, 0.0f));
+ (void)fold_constgen_vector(fold, vec3_create(-1.0f, -1.0f, -1.0f));
return fold;
}
}
static GMQCC_INLINE ast_expression *fold_op_bor(fold_t *fold, ast_value *a, ast_value *b) {
- if (fold_can_2(a, b))
- return fold_constgen_float(fold, (qcfloat_t)(((qcint_t)fold_immvalue_float(a)) | ((qcint_t)fold_immvalue_float(b))));
+ if (isfloat(a)) {
+ if (fold_can_2(a, b))
+ return fold_constgen_float(fold, (qcfloat_t)(((qcint_t)fold_immvalue_float(a)) | ((qcint_t)fold_immvalue_float(b))));
+ } else {
+ if (isvector(b)) {
+ if (fold_can_2(a, b))
+ return fold_constgen_vector(fold, vec3_or(fold_immvalue_vector(a), fold_immvalue_vector(b)));
+ } else {
+ if (fold_can_2(a, b))
+ return fold_constgen_vector(fold, vec3_orvf(fold_immvalue_vector(a), fold_immvalue_float(b)));
+ }
+ }
return NULL;
}
static GMQCC_INLINE ast_expression *fold_op_band(fold_t *fold, ast_value *a, ast_value *b) {
- if (fold_can_2(a, b))
- return fold_constgen_float(fold, (qcfloat_t)(((qcint_t)fold_immvalue_float(a)) & ((qcint_t)fold_immvalue_float(b))));
+ if (isfloat(a)) {
+ if (fold_can_2(a, b))
+ return fold_constgen_float(fold, (qcfloat_t)(((qcint_t)fold_immvalue_float(a)) & ((qcint_t)fold_immvalue_float(b))));
+ } else {
+ if (isvector(b)) {
+ if (fold_can_2(a, b))
+ return fold_constgen_vector(fold, vec3_and(fold_immvalue_vector(a), fold_immvalue_vector(b)));
+ } else {
+ if (fold_can_2(a, b))
+ return fold_constgen_vector(fold, vec3_andvf(fold_immvalue_vector(a), fold_immvalue_float(b)));
+ }
+ }
return NULL;
}
}
static GMQCC_INLINE ast_expression *fold_op_bnot(fold_t *fold, ast_value *a) {
- if (fold_can_1(a))
- return fold_constgen_float(fold, ~((qcint_t)fold_immvalue_float(a)));
+ if (isfloat(a)) {
+ if (fold_can_1(a))
+ return fold_constgen_float(fold, ~((qcint_t)fold_immvalue_float(a)));
+ } else {
+ if (isvector(a)) {
+ if (fold_can_1(a))
+ return fold_constgen_vector(fold, vec3_not(fold_immvalue_vector(a)));
+ }
+ }
return NULL;
}