Fixing bugs, constraining syntax

This commit is contained in:
Krzosa Karol
2022-09-27 11:30:16 +02:00
parent b743ceb2f4
commit 60f794580c
10 changed files with 56 additions and 23 deletions

View File

@@ -21,11 +21,6 @@ main :: (): int
string_val: String = "String type"
cstring_val: *char = "CString type"
Assert(s64val == 0 && s32val == 0 && s16val == 0 && s8val == 0 && intval == 0 && u64val == 0 && u32val == 0 && u16val == 0 && u8val == 0 && f64val == 0 && f32val == 0)
// @todo: Fix error here !!
// Assert(string_val[0] == 'S) //'
Assert(cstring_val[0] == 'C')
// This is how we can assign variables
// There is no need for prefixes, compiler figures
// out the format by itself
@@ -58,9 +53,35 @@ main :: (): int
// To do this we need a cast
combining_types := this_is_s64_by_default->F64 + this_is_f64_by_default
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')
Assert(signed_variable == 10 && unsigned_variable == 10)
Assert(INT_VALUE == 10)
Assert(FLOAT_VALUE == 124.125)
Assert(this_is_f64_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)
Assert(data1.d == 2)
Assert(data2.a == 4)
Assert(data2.b == 2)
Assert(data2.c == 0)
Assert(data2.d == 0)
Data :: struct
a: S64
b: S32
c: S32
d: S32

View File

@@ -6,7 +6,7 @@ main :: (): int
// about this type. For example this information allows us to walk
// the type tree, pretty print all values in that type, along with their sizes.
// Other use cases allow us to do a type safe printf
type_info: *Type_Info = get_type_info(some_type)
type_info: *Type_Info = GetTypeInfo(some_type)
// It can be null, requiring the type information would be a bit unwise
// this is a lot of data
@@ -45,11 +45,11 @@ main :: (): int
Assert(value_to_be_wrapped == 20)
letter := get_first_letter_of_type(value_to_be_wrapped)
letter := GetFirstLetterOfType(value_to_be_wrapped)
Assert(letter == 'I')
get_first_letter_of_type :: (a: Any): U8
type_info := get_type_info(a.type)
GetFirstLetterOfType :: (a: Any): U8
type_info := GetTypeInfo(a.type)
if !type_info
return '-'