Additions:
* Ability to have tags on `#foreign` block procedures.
- This will enable the creation different binding generators, such jsbindgen.
+* `#distinct` types can now be made over any type.
+ - Used to be only primitives.
* New `logo-new-256.ico` for favicon on website.
Removals:
if (from_->id == to_->id) return 1;
+ if (to->kind == Type_Kind_Distinct) {
+ if (types_are_compatible(to->Distinct.base_type, from)) {
+ return 1;
+ }
+
+ if (from->kind == Type_Kind_Distinct && types_are_compatible(to, from->Distinct.base_type)) {
+ return 1;
+ }
+
+ *err_msg = "Cannot convert from a distinct type to the wrong destination type.";
+ return 0;
+ }
+
+ if (from->kind == Type_Kind_Distinct) {
+ if (types_are_compatible(from->Distinct.base_type, to)) {
+ return 1;
+ }
+
+ if (to->kind == Type_Kind_Distinct && types_are_compatible(from, to->Distinct.base_type)) {
+ return 1;
+ }
+
+ *err_msg = "Cannot convert to a distinct type from the wrong destination type.";
+ return 0;
+ }
+
+
+
if (from->kind == Type_Kind_Enum) from = from->Enum.backing;
if (to->kind == Type_Kind_Enum) to = to->Enum.backing;
}
}
- if (to->kind == Type_Kind_Distinct) {
- if (!types_are_compatible(to->Distinct.base_type, from)) {
- // :BadErrorMessage
- *err_msg = "Cannot convert to a distinct type using the wrong base type.";
- return 0;
- } else {
- return 1;
- }
- }
-
- if (from->kind == Type_Kind_Distinct) {
- if (!types_are_compatible(from->Distinct.base_type, to)) {
- // :BadErrorMessage
- *err_msg = "Cannot convert from a distinct type to the wrong destination type.";
- return 0;
- } else {
- return 1;
- }
- }
-
if (from->kind == Type_Kind_Slice || to->kind == Type_Kind_Slice) {
if ((from->kind != Type_Kind_Slice || to->kind != Type_Kind_Slice)
|| to->Slice.elem->kind != Type_Kind_Pointer || from->Slice.elem->kind != Type_Kind_Pointer
Type *base_type = type_build_from_ast(alloc, distinct->base_type);
if (base_type == NULL) return NULL;
- if (base_type->kind != Type_Kind_Basic && base_type->kind != Type_Kind_Pointer) {
- onyx_report_error(distinct->token->pos, Error_Critical, "Distinct types can only be made out of primitive types. '%s' is not a primitive type.", type_get_name(base_type));
- return NULL;
- }
+ // if (base_type->kind != Type_Kind_Basic && base_type->kind != Type_Kind_Pointer) {
+ // onyx_report_error(distinct->token->pos, Error_Critical, "Distinct types can only be made out of primitive types. '%s' is not a primitive type.", type_get_name(base_type));
+ // return NULL;
+ // }
Type *distinct_type = type_create(Type_Kind_Distinct, alloc, 0);
distinct_type->Distinct.base_type = base_type;
#define WASM_TYPE_VOID 0x00
static b32 onyx_type_is_stored_in_memory(Type *type) {
+ if (type->kind == Type_Kind_Distinct) {
+ type = type->Distinct.base_type;
+ }
+
if (type_struct_is_just_one_basic_value(type)) return 0;
return type->kind == Type_Kind_Struct
return;
}
+ if (type->kind == Type_Kind_Function) assert(5678 && 0);
if (type->kind == Type_Kind_Struct) type = type_struct_is_just_one_basic_value(type);
if (type->kind == Type_Kind_Enum) type = type->Enum.backing;
- if (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type;
- if (type->kind == Type_Kind_Function) assert(5678 && 0);
+
+ while (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type;
assert(type);
if (type->kind == Type_Kind_Struct) type = type_struct_is_just_one_basic_value(type);
if (type->kind == Type_Kind_Enum) type = type->Enum.backing;
- if (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type;
if (type->kind == Type_Kind_Function) assert(1234 && 0);
+ while (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type;
+
assert(type);
i32 load_size = type_size_of(type);