codegen: add support for shortening cast

master
Andrew Kelley 2015-12-15 02:58:01 -07:00
parent 1f48b626a1
commit de7c5ea102
1 changed files with 8 additions and 2 deletions

View File

@ -292,10 +292,16 @@ static LLVMValueRef gen_cast_expr(CodeGen *g, AstNode *node) {
if (actual_type->data.integral.is_signed && wanted_type->data.integral.is_signed) {
return LLVMBuildSExt(g->builder, expr_val, wanted_type->type_ref, "");
} else {
zig_panic("TODO gen_cast_expr sign mismatch");
zig_panic("TODO gen_cast_expr widen unsigned");
}
} else {
zig_panic("TODO gen_cast_expr");
assert(actual_type->size_in_bits > wanted_type->size_in_bits);
if (actual_type->data.integral.is_signed && wanted_type->data.integral.is_signed) {
return LLVMBuildTrunc(g->builder, expr_val, wanted_type->type_ref, "");
} else {
zig_panic("TODO gen_cast_expr shorten unsigned");
}
}
case CastOpArrayToString:
{