alloc_slice :: proc (sl: ^[] $T, count: i32) {
sl.data = calloc(sizeof T * count);
sl.count = count;
+}
+
+make_slice :: proc ($T: type_expr, count: i32) -> [] T {
+ return <[] T>.{
+ data = calloc(sizeof T * count),
+ count = count
+ };
}
\ No newline at end of file
proc (b: f32) -> f64 { return ~~(b + 6); }));
- arr1 : [..] f32;
- arr2 : [..] i32;
- array.init(^arr1);
- array.init(^arr2);
+ arr1 := array.make(f32);
+ arr2 := array.make(i32);
defer array.free(^arr1);
defer array.free(^arr2);
}
}
- InternalStruct :: struct ($SOMETHING) {
+ InternalStruct :: struct (SOMETHING: type_expr) {
foo : SOMETHING;
}
}
expect_token(parser, '=');
AstType* poly_type = parse_type(parser);
- PolySolutionKind sln_kind = PSK_Type;
- if (!node_is_type((AstNode *) poly_type)) sln_kind = PSK_Value;
-
bh_arr_push(solid->known_polyvars, ((AstPolySolution) {
- .kind = sln_kind,
+ .kind = PSK_Undefined,
.poly_sym = poly_var,
.ast_type = poly_type,
.type = NULL
}
bh_arr_each(AstPolySolution, sln, solid->known_polyvars) {
- sln->ast_type = symres_type(sln->ast_type);
- sln->type = type_build_from_ast(semstate.node_allocator, sln->ast_type);
+ // HACK: This assumes that 'ast_type' and 'value' are at the same offset.
+ symres_expression(&sln->value);
+ if (onyx_has_errors()) return;
+
+ if (node_is_type(sln->value)) {
+ sln->type = type_build_from_ast(semstate.node_allocator, sln->ast_type);
+ sln->kind = PSK_Type;
+ } else {
+ sln->kind = PSK_Value;
+ }
+
if (onyx_has_errors()) return;
}