Add TypeOf operator

This commit is contained in:
Krzosa Karol
2022-10-11 11:13:07 +02:00
parent 4004b8b8d3
commit e37bf8b1bc
8 changed files with 61 additions and 38 deletions

View File

@@ -53,6 +53,24 @@ main :: (): int
// To do this we need a cast
combining_types := this_is_s64_by_default->F32 + this_is_f32_by_default
// Compound statements
// Struct is at the bottom of the file!
data1 := Data{
a = 1,
d = 2
}
data2: Data = {
a = 4,
b = 2,
}
size0 := SizeOf(Data)
size1 := SizeOf(data1)
align0 := AlignOf(Data)
align1 := AlignOf(data1)
type0 := TypeOf(Data)
type1 := TypeOf(data1)
Assert(s64val == 0 && s32val == 0 && s16val == 0 && s8val == 0 && intval == 0 && u64val == 0 && u32val == 0 && u16val == 0 && u8val == 0 && f64val == 0 && f32val == 0)
Assert(string_val[0] == 'S')
Assert(cstring_val[0] == 'C')
@@ -62,15 +80,6 @@ main :: (): int
Assert(this_is_f32_by_default == 15.1255)
Assert(combining_types == 15.1255 + 20)
// Compound statements
data1 := Data{
a = 1,
d = 2
}
data2: Data = {
a = 4,
b = 2,
}
Assert(data1.a == 1)
Assert(data1.b == 0)
Assert(data1.c == 0)
@@ -80,6 +89,11 @@ main :: (): int
Assert(data2.c == 0)
Assert(data2.d == 0)
Assert(size0 == size1)
Assert(align0 == align1)
Assert(type0 == type1)
Assert(TypeOf(data2) == Data)
return 0
Data :: struct