builtin: u8/byte clean up

pull/13758/merge
Alexander Medvednikov 2022-04-14 16:42:29 +03:00
parent 2d6d6c9ac9
commit 0dff050735
4 changed files with 10 additions and 10 deletions

View File

@ -2179,7 +2179,7 @@ pub fn (expr Expr) is_literal() bool {
CastExpr { CastExpr {
return !expr.has_arg && expr.expr.is_literal() return !expr.has_arg && expr.expr.is_literal()
&& (expr.typ.is_ptr() || expr.typ.is_pointer() && (expr.typ.is_ptr() || expr.typ.is_pointer()
|| expr.typ in [i8_type, i16_type, int_type, i64_type, byte_type, u8_type, u16_type, u32_type, u64_type, f32_type, f64_type, char_type, bool_type, rune_type]) || expr.typ in [i8_type, i16_type, int_type, i64_type, byte_type, u16_type, u32_type, u64_type, f32_type, f64_type, char_type, bool_type, rune_type])
} }
SizeOf, IsRefType { SizeOf, IsRefType {
return expr.is_type || expr.expr.is_literal() return expr.is_type || expr.expr.is_literal()

View File

@ -441,7 +441,7 @@ pub const (
int_literal_type_idx = 27 int_literal_type_idx = 27
thread_type_idx = 28 thread_type_idx = 28
error_type_idx = 29 error_type_idx = 29
u8_type_idx = 30 // u8_type_idx = 30
) )
// Note: builtin_type_names must be in the same order as the idx consts above // Note: builtin_type_names must be in the same order as the idx consts above
@ -453,15 +453,15 @@ pub const builtin_type_names_matcher = build_builtin_type_names_matcher()
pub const ( pub const (
integer_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx, integer_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
byte_type_idx, u8_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx, byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx, usize_type_idx,
usize_type_idx, int_literal_type_idx, rune_type_idx] int_literal_type_idx, rune_type_idx]
signed_integer_type_idxs = [char_type_idx, i8_type_idx, i16_type_idx, int_type_idx, signed_integer_type_idxs = [char_type_idx, i8_type_idx, i16_type_idx, int_type_idx,
i64_type_idx, isize_type_idx] i64_type_idx, isize_type_idx]
unsigned_integer_type_idxs = [byte_type_idx, u8_type_idx, u16_type_idx, u32_type_idx, unsigned_integer_type_idxs = [byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx,
u64_type_idx, usize_type_idx] usize_type_idx]
// C will promote any type smaller than int to int in an expression // C will promote any type smaller than int to int in an expression
int_promoted_type_idxs = [char_type_idx, i8_type_idx, i16_type_idx, byte_type_idx, int_promoted_type_idxs = [char_type_idx, i8_type_idx, i16_type_idx, byte_type_idx,
u8_type_idx, u16_type_idx] u16_type_idx]
float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx] float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx]
number_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx, number_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
byte_type_idx, char_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx, byte_type_idx, char_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, isize_type_idx,
@ -483,7 +483,7 @@ pub const (
i64_type = new_type(i64_type_idx) i64_type = new_type(i64_type_idx)
isize_type = new_type(isize_type_idx) isize_type = new_type(isize_type_idx)
byte_type = new_type(byte_type_idx) byte_type = new_type(byte_type_idx)
u8_type = new_type(u8_type_idx) // u8_type = new_type(u8_type_idx)
u16_type = new_type(u16_type_idx) u16_type = new_type(u16_type_idx)
u32_type = new_type(u32_type_idx) u32_type = new_type(u32_type_idx)
u64_type = new_type(u64_type_idx) u64_type = new_type(u64_type_idx)

View File

@ -394,7 +394,7 @@ fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type ast.Type, right
ast.i64_type { 63 } ast.i64_type { 63 }
// //
ast.byte_type { 7 } ast.byte_type { 7 }
ast.u8_type { 7 } // ast.u8_type { 7 }
ast.u16_type { 15 } ast.u16_type { 15 }
ast.u32_type { 31 } ast.u32_type { 31 }
ast.u64_type { 63 } ast.u64_type { 63 }

View File

@ -143,7 +143,7 @@ fn (mut c Checker) eval_comptime_const_expr(expr ast.Expr, nlevel int) ?ast.Comp
ast.i64_type { return 8 } ast.i64_type { return 8 }
// //
ast.byte_type { return 1 } ast.byte_type { return 1 }
ast.u8_type { return 1 } // ast.u8_type { return 1 }
ast.u16_type { return 2 } ast.u16_type { return 2 }
ast.u32_type { return 4 } ast.u32_type { return 4 }
ast.u64_type { return 8 } ast.u64_type { return 8 }