From fc6b2c27fc81c2a86792aa3e5bd5ad5d9acd7c51 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 29 Nov 2021 18:15:18 -0600 Subject: [PATCH] removed type-value interchange --- core/io/binary.onyx | 6 +++--- docs/watchout | 8 +------- src/parser.c | 11 ----------- tests/new_struct_behaviour.onyx | 2 +- tests/operator_overload.onyx | 2 +- tests/poly_structs_with_values.onyx | 2 +- tests/struct_robustness.onyx | 5 ++--- 7 files changed, 9 insertions(+), 27 deletions(-) diff --git a/core/io/binary.onyx b/core/io/binary.onyx index f65c726e..c709a314 100644 --- a/core/io/binary.onyx +++ b/core/io/binary.onyx @@ -17,14 +17,14 @@ binary_write_byte :: (use bw: ^BinaryWriter, byte: u8) { } binary_write :: (use bw: ^BinaryWriter, $T: type_expr, v: ^T) { - stream_write(stream, <[] u8>.{ ~~ v, sizeof T }); + stream_write(stream, .{ ~~ v, sizeof T }); } binary_write_slice :: (use bw: ^BinaryWriter, sl: [] $T, output_size := false) { assert(false, "binary_write_slice is not working at the moment"); if output_size do binary_write(bw, i32, sl.count); - bytes := <[] u8>.{ + bytes := ([] u8).{ data = cast(^u8) ^sl.data[0], count = sizeof T * sl.count, }; @@ -72,5 +72,5 @@ binary_read_slice :: (use br: ^BinaryReader, sl := memory.make_slice(u8, size * sizeof T, allocator = allocator); _, bytes_read := stream_read(stream, sl); - return <[] T>.{ data = cast(^T) sl.data, count = size }; + return .{ data = cast(^T) sl.data, count = size }; } diff --git a/docs/watchout b/docs/watchout index 19c79e76..cec05161 100644 --- a/docs/watchout +++ b/docs/watchout @@ -15,10 +15,4 @@ Some tags to watch out for in the code with features that may be removed in the The implementation of `null_proc` is rather simple, but feels a little verbose an targential compared to everything else being done - in the compiler. - - :TypeValueInterchange - Angle brackets are being used to specify types in value expressions - and vice versa. This is just a temporary hack. The long term goal - is that type expressions are automatically detected in value - expressions. \ No newline at end of file + in the compiler. \ No newline at end of file diff --git a/src/parser.c b/src/parser.c index 4304880f..b3e770dd 100644 --- a/src/parser.c +++ b/src/parser.c @@ -516,17 +516,6 @@ static AstTyped* parse_factor(OnyxParser* parser) { break; } - // :TypeValueInterchange - case '<': { - AstTypeAlias* alias = make_node(AstTypeAlias, Ast_Kind_Type_Alias); - alias->token = expect_token(parser, '<'); - alias->to = parse_type(parser); - expect_token(parser, '>'); - - retval = (AstTyped *) alias; - break; - } - case '[': { AstType *type = parse_type(parser); retval = (AstTyped *) type; diff --git a/tests/new_struct_behaviour.onyx b/tests/new_struct_behaviour.onyx index c3094a2b..600169ee 100644 --- a/tests/new_struct_behaviour.onyx +++ b/tests/new_struct_behaviour.onyx @@ -57,7 +57,7 @@ main :: (args: [] cstr) { foo := Foo.{}; println(foo->get_member2_plus_three()); - ps := .{ 1234 }; + ps := PolyStruct(i32).{ 1234 }; println(ps.works(ps.member)); plus_one : (i32) -> i32 = PolyStruct.member_function; diff --git a/tests/operator_overload.onyx b/tests/operator_overload.onyx index 0fa1aaf0..c929cabe 100644 --- a/tests/operator_overload.onyx +++ b/tests/operator_overload.onyx @@ -59,7 +59,7 @@ join :: (a: Vec($T, $N), b: Vec(T, $M)) -> Vec(T, #value N + M) { } make_vec :: (data: [$N] $T) -> Vec(T, N) { - return .{ data }; + return .{ data }; } main :: (args: [] cstr) { diff --git a/tests/poly_structs_with_values.onyx b/tests/poly_structs_with_values.onyx index 3fd00534..2cdcac92 100644 --- a/tests/poly_structs_with_values.onyx +++ b/tests/poly_structs_with_values.onyx @@ -24,7 +24,7 @@ main :: (args: [] cstr) { str_member : str = default; } - swd := .{ x = 1234 }; + swd := SimpleWithDefault(i32, "Hello World!").{ x = 1234 }; println(swd.x); println(swd.str_member); poly_match(swd); diff --git a/tests/struct_robustness.onyx b/tests/struct_robustness.onyx index 09648d30..43165758 100644 --- a/tests/struct_robustness.onyx +++ b/tests/struct_robustness.onyx @@ -118,8 +118,7 @@ main :: (args: [] cstr) { printf("PolyStruct({}, {})\n", ps1.t_data, ps1.r_data); - // Currently, this is how you have to do this. - ps2 := .{ 1234, 5678 }; + ps2 := PolyStruct(f32, i32).{ 1234, 5678 }; printf("PolyStruct({}, {})\n", ps2.t_data, ps2.r_data); } @@ -131,7 +130,7 @@ main :: (args: [] cstr) { r_data : R = 5678; } - PolyStructTyped :: ; + PolyStructTyped :: PolyStruct(i32, f32); ps := PolyStructTyped.{}; printf("PolyStruct({}, {})\n", ps.t_data, ps.r_data); -- 2.25.1