added default_of and made zero_of more clear
This commit is contained in:
parent
765a1ff4a2
commit
5884bcf577
2 changed files with 11 additions and 5 deletions
11
base.jai
11
base.jai
|
|
@ -12,6 +12,17 @@ align_of :: ($T: Type) -> uint #expand {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default_of :: ($T: Type) -> T #expand {
|
||||||
|
default: T;
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
zero_of :: ($T: Type) -> T #expand {
|
||||||
|
zero: T = ---;
|
||||||
|
memset(*zero, 0, size_of(T));
|
||||||
|
return zero;
|
||||||
|
}
|
||||||
|
|
||||||
bitcast :: ($T: Type, expr: Code) -> T #expand {
|
bitcast :: ($T: Type, expr: Code) -> T #expand {
|
||||||
value := expr;
|
value := expr;
|
||||||
return (*value).(*T).*;
|
return (*value).(*T).*;
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,6 @@ c_call :: (block: Code) #expand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zero_value :: ($T: Type) -> T #expand {
|
|
||||||
zero: T;
|
|
||||||
return zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
check_type_tag :: ($$T: Type, tag: Type_Info_Tag) -> bool, *Type_Info {
|
check_type_tag :: ($$T: Type, tag: Type_Info_Tag) -> bool, *Type_Info {
|
||||||
#if is_constant(T) {
|
#if is_constant(T) {
|
||||||
info :: type_info(T);
|
info :: type_info(T);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue