Fixing divd constant.

This commit is contained in:
Ben Vanik
2015-05-12 23:38:02 -07:00
parent 4327724f77
commit 4248268b4f
9 changed files with 235 additions and 65 deletions

View File

@@ -304,20 +304,36 @@ void Value::Mul(Value* other) {
}
}
void Value::Div(Value* other) {
void Value::Div(Value* other, bool is_unsigned) {
assert_true(type == other->type);
switch (type) {
case INT8_TYPE:
constant.i8 /= uint8_t(other->constant.i8);
if (is_unsigned) {
constant.i8 /= uint8_t(other->constant.i8);
} else {
constant.i8 /= other->constant.i8;
}
break;
case INT16_TYPE:
constant.i16 /= uint16_t(other->constant.i16);
if (is_unsigned) {
constant.i16 /= uint16_t(other->constant.i16);
} else {
constant.i16 /= other->constant.i16;
}
break;
case INT32_TYPE:
constant.i32 /= uint32_t(other->constant.i32);
if (is_unsigned) {
constant.i32 /= uint32_t(other->constant.i32);
} else {
constant.i32 /= other->constant.i32;
}
break;
case INT64_TYPE:
constant.i64 /= uint64_t(other->constant.i64);
if (is_unsigned) {
constant.i64 /= uint64_t(other->constant.i64);
} else {
constant.i64 /= other->constant.i64;
}
break;
case FLOAT32_TYPE:
constant.f32 /= other->constant.f32;