aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/_preload.odin56
-rw-r--r--core/fmt.odin1
-rw-r--r--core/os_essence.odin2
-rw-r--r--core/os_linux.odin4
-rw-r--r--core/os_x.odin4
-rw-r--r--core/raw.odin10
-rw-r--r--core/sys/windows.odin54
-rw-r--r--core/types.odin1
-rw-r--r--examples/demo.odin2
-rw-r--r--src/check_expr.cpp1
-rw-r--r--src/check_type.cpp14
-rw-r--r--src/checker.cpp5
-rw-r--r--src/ir.cpp11
-rw-r--r--src/parser.cpp311
-rw-r--r--src/types.cpp3
15 files changed, 83 insertions, 396 deletions
diff --git a/core/_preload.odin b/core/_preload.odin
index 1e7c75ab1..a63cfd3b5 100644
--- a/core/_preload.odin
+++ b/core/_preload.odin
@@ -23,12 +23,12 @@ import "core:raw.odin"
// NOTE(bill): This must match the compiler's
Calling_Convention :: enum {
- Invalid = 0,
- Odin = 1,
- Contextless = 2,
- C = 3,
- Std = 4,
- Fast = 5,
+ Invalid = 0,
+ Odin = 1,
+ Contextless = 2,
+ C = 3,
+ Std = 4,
+ Fast = 5,
}
// IMPORTANT NOTE(bill): Do not change the order of any of this data
// The compiler relies upon this _exact_ order
@@ -42,67 +42,66 @@ Type_Info_Enum_Value :: union {
};
// Variant Types
-Type_Info_Named :: struct #ordered {name: string, base: ^Type_Info};
-Type_Info_Integer :: struct #ordered {signed: bool};
+Type_Info_Named :: struct {name: string, base: ^Type_Info};
+Type_Info_Integer :: struct {signed: bool};
Type_Info_Rune :: struct{};
Type_Info_Float :: struct{};
Type_Info_Complex :: struct{};
Type_Info_String :: struct{};
Type_Info_Boolean :: struct{};
Type_Info_Any :: struct{};
-Type_Info_Pointer :: struct #ordered {
+Type_Info_Pointer :: struct {
elem: ^Type_Info // nil -> rawptr
};
-Type_Info_Procedure :: struct #ordered {
+Type_Info_Procedure :: struct {
params: ^Type_Info, // Type_Info_Tuple
results: ^Type_Info, // Type_Info_Tuple
variadic: bool,
convention: Calling_Convention,
};
-Type_Info_Array :: struct #ordered {
+Type_Info_Array :: struct {
elem: ^Type_Info,
elem_size: int,
count: int,
};
-Type_Info_Dynamic_Array :: struct #ordered {elem: ^Type_Info, elem_size: int};
-Type_Info_Slice :: struct #ordered {elem: ^Type_Info, elem_size: int};
-Type_Info_Tuple :: struct #ordered { // Only really used for procedures
+Type_Info_Dynamic_Array :: struct {elem: ^Type_Info, elem_size: int};
+Type_Info_Slice :: struct {elem: ^Type_Info, elem_size: int};
+Type_Info_Tuple :: struct { // Only really used for procedures
types: []^Type_Info,
names: []string,
};
-Type_Info_Struct :: struct #ordered {
+Type_Info_Struct :: struct {
types: []^Type_Info,
names: []string,
offsets: []uintptr, // offsets may not be used in tuples
usings: []bool, // usings may not be used in tuples
is_packed: bool,
- is_ordered: bool,
is_raw_union: bool,
custom_align: bool,
};
-Type_Info_Union :: struct #ordered {
+Type_Info_Union :: struct {
variants: []^Type_Info,
tag_offset: uintptr,
tag_type: ^Type_Info,
};
-Type_Info_Enum :: struct #ordered {
+Type_Info_Enum :: struct {
base: ^Type_Info,
names: []string,
values: []Type_Info_Enum_Value,
};
-Type_Info_Map :: struct #ordered {
+Type_Info_Map :: struct {
key: ^Type_Info,
value: ^Type_Info,
generated_struct: ^Type_Info,
};
-Type_Info_Bit_Field :: struct #ordered {
+Type_Info_Bit_Field :: struct {
names: []string,
bits: []i32,
offsets: []i32,
};
-Type_Info :: struct #ordered {
+Type_Info :: struct {
size: int,
align: int,
@@ -139,7 +138,7 @@ __argv__: ^^byte;
// IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)
-Source_Code_Location :: struct #ordered {
+Source_Code_Location :: struct {
file_path: string,
line, column: int,
procedure: string,
@@ -160,19 +159,20 @@ Allocator_Proc :: #type proc(allocator_data: rawptr, mode: Allocator_Mode,
old_memory: rawptr, old_size: int, flags: u64 = 0, location := #caller_location) -> rawptr;
-Allocator :: struct #ordered {
+Allocator :: struct {
procedure: Allocator_Proc,
data: rawptr,
}
-Context :: struct #ordered {
+Context :: struct {
allocator: Allocator,
thread_id: int,
user_data: any,
user_index: int,
+ parent: ^Context,
derived: any, // May be used for derived data types
}
@@ -180,18 +180,18 @@ DEFAULT_ALIGNMENT :: 2*align_of(rawptr);
__INITIAL_MAP_CAP :: 16;
-__Map_Key :: struct #ordered {
+__Map_Key :: struct {
hash: u128,
str: string,
}
-__Map_Find_Result :: struct #ordered {
+__Map_Find_Result :: struct {
hash_index: int,
entry_prev: int,
entry_index: int,
}
-__Map_Entry_Header :: struct #ordered {
+__Map_Entry_Header :: struct {
key: __Map_Key,
next: int,
/*
@@ -199,7 +199,7 @@ __Map_Entry_Header :: struct #ordered {
*/
}
-__Map_Header :: struct #ordered {
+__Map_Header :: struct {
m: ^raw.Map,
is_key_string: bool,
entry_size: int,
diff --git a/core/fmt.odin b/core/fmt.odin
index 3da0c55eb..93ada4809 100644
--- a/core/fmt.odin
+++ b/core/fmt.odin
@@ -253,7 +253,6 @@ write_type :: proc(buf: ^String_Buffer, ti: ^Type_Info) {
case Type_Info_Struct:
write_string(buf, "struct ");
if info.is_packed do write_string(buf, "#packed ");
- if info.is_ordered do write_string(buf, "#ordered ");
if info.is_raw_union do write_string(buf, "#raw_union ");
if info.custom_align {
write_string(buf, "#align ");
diff --git a/core/os_essence.odin b/core/os_essence.odin
index d35e313e8..f713c7e20 100644
--- a/core/os_essence.odin
+++ b/core/os_essence.odin
@@ -13,7 +13,7 @@ OS_Node_Type :: enum i32 {
Directory = 1,
}
-OS_Node_Information :: struct #ordered {
+OS_Node_Information :: struct {
handle: Handle,
id: [16]byte,
ntype: OS_Node_Type,
diff --git a/core/os_linux.odin b/core/os_linux.odin
index cf457c58f..935a9b5d4 100644
--- a/core/os_linux.odin
+++ b/core/os_linux.odin
@@ -40,7 +40,7 @@ RTLD_GLOBAL :: 0x100;
// "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments();
-_File_Time :: struct #ordered {
+_File_Time :: struct {
seconds: i64,
nanoseconds: i32,
reserved: i32,
@@ -50,7 +50,7 @@ _File_Time :: struct #ordered {
// https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/+/jb-dev/sysroot/usr/include/bits/stat.h
// Validity is not guaranteed.
-Stat :: struct #ordered {
+Stat :: struct {
device_id: u64, // ID of device containing file
serial: u64, // File serial number
nlink: u32, // Number of hard links
diff --git a/core/os_x.odin b/core/os_x.odin
index 4bdb2cd9a..7a831d6ec 100644
--- a/core/os_x.odin
+++ b/core/os_x.odin
@@ -46,12 +46,12 @@ RTLD_FIRST :: 0x100;
// "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments();
-_File_Time :: struct #ordered {
+_File_Time :: struct {
seconds: i64,
nanoseconds: i64,
}
-Stat :: struct #ordered {
+Stat :: struct {
device_id: i32, // ID of device containing file
mode: u16, // Mode of the file
nlink: u16, // Number of hard links
diff --git a/core/raw.odin b/core/raw.odin
index ac5482233..361b053e5 100644
--- a/core/raw.odin
+++ b/core/raw.odin
@@ -1,26 +1,26 @@
-Any :: struct #ordered {
+Any :: struct {
data: rawptr,
type_info: ^Type_Info,
}
-String :: struct #ordered {
+String :: struct {
data: ^byte,
len: int,
}
-Slice :: struct #ordered {
+Slice :: struct {
data: rawptr,
len: int,
}
-Dynamic_Array :: struct #ordered {
+Dynamic_Array :: struct {
data: rawptr,
len: int,
cap: int,
allocator: Allocator,
}
-Map :: struct #ordered {
+Map :: struct {
hashes: [dynamic]int,
entries: Dynamic_Array,
}
diff --git a/core/sys/windows.odin b/core/sys/windows.odin
index 8fdf66734..6bff7c2a6 100644
--- a/core/sys/windows.odin
+++ b/core/sys/windows.odin
@@ -30,11 +30,11 @@ Bool :: i32;
FALSE: Bool : 0;
TRUE: Bool : 1;
-Point :: struct #ordered {
+Point :: struct {
x, y: i32,
}
-Wnd_Class_Ex_A :: struct #ordered {
+Wnd_Class_Ex_A :: struct {
size, style: u32,
wnd_proc: Wnd_Proc,
cls_extra, wnd_extra: i32,
@@ -46,7 +46,7 @@ Wnd_Class_Ex_A :: struct #ordered {
sm: Hicon,
}
-Wnd_Class_Ex_W :: struct #ordered {
+Wnd_Class_Ex_W :: struct {
size, style: u32,
wnd_proc: Wnd_Proc,
cls_extra, wnd_extra: i32,
@@ -59,7 +59,7 @@ Wnd_Class_Ex_W :: struct #ordered {
}
-Msg :: struct #ordered {
+Msg :: struct {
hwnd: Hwnd,
message: u32,
wparam: Wparam,
@@ -68,24 +68,24 @@ Msg :: struct #ordered {
pt: Point,
}
-Rect :: struct #ordered {
+Rect :: struct {
left: i32,
top: i32,
right: i32,
bottom: i32,
}
-Filetime :: struct #ordered {
+Filetime :: struct {
lo, hi: u32,
}
-Systemtime :: struct #ordered {
+Systemtime :: struct {
year, month: u16,
day_of_week, day: u16,
hour, minute, second, millisecond: u16,
}
-By_Handle_File_Information :: struct #ordered {
+By_Handle_File_Information :: struct {
file_attributes: u32,
creation_time,
last_access_time,
@@ -98,7 +98,7 @@ By_Handle_File_Information :: struct #ordered {
file_index_low: u32,
}
-File_Attribute_Data :: struct #ordered {
+File_Attribute_Data :: struct {
file_attributes: u32,
creation_time,
last_access_time,
@@ -107,7 +107,7 @@ File_Attribute_Data :: struct #ordered {
file_size_low: u32,
}
-Find_Data :: struct #ordered{
+Find_Data :: struct{
file_attributes: u32,
creation_time: Filetime,
last_access_time: Filetime,
@@ -120,7 +120,7 @@ Find_Data :: struct #ordered{
alternate_file_name: [14]byte,
}
-Security_Attributes :: struct #ordered {
+Security_Attributes :: struct {
length: u32,
security_descriptor: rawptr,
inherit_handle: Bool,
@@ -128,7 +128,7 @@ Security_Attributes :: struct #ordered {
-Pixel_Format_Descriptor :: struct #ordered {
+Pixel_Format_Descriptor :: struct {
size,
version,
flags: u32,
@@ -159,7 +159,7 @@ Pixel_Format_Descriptor :: struct #ordered {
damage_mask: u32,
}
-Critical_Section :: struct #ordered {
+Critical_Section :: struct {
debug_info: ^Critical_Section_Debug,
lock_count: i32,
@@ -169,7 +169,7 @@ Critical_Section :: struct #ordered {
spin_count: ^u32,
}
-Critical_Section_Debug :: struct #ordered {
+Critical_Section_Debug :: struct {
typ: u16,
creator_back_trace_index: u16,
critical_section: ^Critical_Section,
@@ -181,30 +181,30 @@ Critical_Section_Debug :: struct #ordered {
spare_word: u16,
}
-List_Entry :: struct #ordered {flink, blink: ^List_Entry};
+List_Entry :: struct {flink, blink: ^List_Entry};
-Raw_Input_Device :: struct #ordered {
+Raw_Input_Device :: struct {
usage_page: u16,
usage: u16,
flags: u32,
wnd_target: Hwnd,
}
-Raw_Input_Header :: struct #ordered {
+Raw_Input_Header :: struct {
kind: u32,
size: u32,
device: Handle,
wparam: Wparam,
}
-Raw_HID :: struct #ordered {
+Raw_HID :: struct {
size_hid: u32,
count: u32,
raw_data: [1]byte,
}
-Raw_Keyboard :: struct #ordered {
+Raw_Keyboard :: struct {
make_code: u16,
flags: u16,
reserved: u16,
@@ -213,11 +213,11 @@ Raw_Keyboard :: struct #ordered {
extra_information: u32,
}
-Raw_Mouse :: struct #ordered {
+Raw_Mouse :: struct {
flags: u16,
using data: struct #raw_union {
buttons: u32,
- using _: struct #ordered {
+ using _: struct {
button_flags: u16,
button_data: u16,
},
@@ -228,7 +228,7 @@ Raw_Mouse :: struct #ordered {
extra_information: u32,
}
-Raw_Input :: struct #ordered {
+Raw_Input :: struct {
using header: Raw_Input_Header,
data: struct #raw_union {
mouse: Raw_Mouse,
@@ -724,14 +724,14 @@ FILE_TYPE_CHAR :: 0x0002;
FILE_TYPE_PIPE :: 0x0003;
-Monitor_Info :: struct #ordered {
+Monitor_Info :: struct {
size: u32,
monitor: Rect,
work: Rect,
flags: u32,
}
-Window_Placement :: struct #ordered {
+Window_Placement :: struct {
length: u32,
flags: u32,
show_cmd: u32,
@@ -740,7 +740,7 @@ Window_Placement :: struct #ordered {
normal_pos: Rect,
}
-Bitmap_Info_Header :: struct #ordered {
+Bitmap_Info_Header :: struct {
size: u32,
width, height: i32,
planes, bit_count: i16,
@@ -751,13 +751,13 @@ Bitmap_Info_Header :: struct #ordered {
clr_used: u32,
clr_important: u32,
}
-Bitmap_Info :: struct #ordered {
+Bitmap_Info :: struct {
using header: Bitmap_Info_Header,
colors: [1]Rgb_Quad,
}
-Rgb_Quad :: struct #ordered {blue, green, red, reserved: byte}
+Rgb_Quad :: struct {blue, green, red, reserved: byte}
Key_Code :: enum i32 {
diff --git a/core/types.odin b/core/types.odin
index fefcf00ae..0ba87f14d 100644
--- a/core/types.odin
+++ b/core/types.odin
@@ -97,7 +97,6 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool {
switch {
case len(x.types) != len(y.types),
x.is_packed != y.is_packed,
- x.is_ordered != y.is_ordered,
x.is_raw_union != y.is_raw_union,
x.custom_align != y.custom_align:
return false;
diff --git a/examples/demo.odin b/examples/demo.odin
index bc84503b0..0dec48feb 100644
--- a/examples/demo.odin
+++ b/examples/demo.odin
@@ -14,7 +14,6 @@ import "core:utf8.odin"
when ODIN_OS == "windows" {
import "core:atomics.odin"
- import "core:opengl.odin"
import "core:thread.odin"
import win32 "core:sys/windows.odin"
}
@@ -610,7 +609,6 @@ array_programming :: proc() {
}
}
-
main :: proc() {
when false {
general_stuff();
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 6ac837529..500d8cdad 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -6380,7 +6380,6 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
case_ast_node(st, StructType, node);
str = gb_string_appendc(str, "struct ");
if (st->is_packed) str = gb_string_appendc(str, "#packed ");
- if (st->is_ordered) str = gb_string_appendc(str, "#ordered ");
if (st->is_raw_union) str = gb_string_appendc(str, "#raw_union ");
str = gb_string_append_rune(str, '{');
str = write_struct_fields_to_string(str, st->fields);
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 0bee3171f..6fee664d5 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -216,8 +216,6 @@ Array<Entity *> check_struct_fields(Checker *c, AstNode *node, Array<AstNode *>
// TODO(bill): Cleanup struct field reordering
// TODO(bill): Inline sorting procedure?
-gb_global gbAllocator __checker_allocator = {};
-
GB_COMPARE_PROC(cmp_reorder_struct_fields) {
// Rule:
// 'using' over non-'using'
@@ -232,10 +230,10 @@ GB_COMPARE_PROC(cmp_reorder_struct_fields) {
GB_ASSERT(y->kind == Entity_Variable);
bool xu = (x->flags & EntityFlag_Using) != 0;
bool yu = (y->flags & EntityFlag_Using) != 0;
- i64 xa = type_align_of(__checker_allocator, x->type);
- i64 ya = type_align_of(__checker_allocator, y->type);
- i64 xs = type_size_of(__checker_allocator, x->type);
- i64 ys = type_size_of(__checker_allocator, y->type);
+ i64 xa = type_align_of(heap_allocator(), x->type);
+ i64 ya = type_align_of(heap_allocator(), y->type);
+ i64 xs = type_size_of(heap_allocator(), x->type);
+ i64 ys = type_size_of(heap_allocator(), y->type);
if (xu != yu) {
return xu ? -1 : +1;
@@ -545,7 +543,6 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node, Array<Opera
struct_type->Struct.scope = c->context.scope;
struct_type->Struct.is_packed = st->is_packed;
- struct_type->Struct.is_ordered = st->is_ordered;
struct_type->Struct.polymorphic_params = polymorphic_params;
struct_type->Struct.is_polymorphic = is_polymorphic;
struct_type->Struct.is_poly_specialized = is_poly_specialized;
@@ -590,7 +587,6 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node, Array<Opera
// NOTE(bill): Hacky thing
// TODO(bill): Probably make an inline sorting procedure rather than use global variables
- __checker_allocator = c->allocator;
// NOTE(bill): compound literal order must match source not layout
gb_sort_array(reordered_fields.data, fields.count, cmp_reorder_struct_fields);
@@ -1806,7 +1802,6 @@ void generate_map_entry_type(gbAllocator a, Type *type) {
array_add(&fields, make_entity_field(a, s, make_token_ident(str_lit("value")), type->Map.value, false, 2));
- entry_type->Struct.is_ordered = true;
entry_type->Struct.fields = fields;
entry_type->Struct.fields_in_src_order = fields;
@@ -1844,7 +1839,6 @@ void generate_map_internal_types(gbAllocator a, Type *type) {
array_add(&fields, make_entity_field(a, s, make_token_ident(str_lit("hashes")), hashes_type, false, 0));
array_add(&fields, make_entity_field(a, s, make_token_ident(str_lit("entries")), entries_type, false, 1));
- generated_struct_type->Struct.is_ordered = true;
generated_struct_type->Struct.fields = fields;
generated_struct_type->Struct.fields_in_src_order = fields;
diff --git a/src/checker.cpp b/src/checker.cpp
index 47d550070..62a16cd08 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -1389,7 +1389,7 @@ void add_type_info_type(Checker *c, Type *t) {
}
}
-void check_procedure_later(Checker *c, ProcedureInfo const &info) {
+void check_procedure_later(Checker *c, ProcedureInfo info) {
GB_ASSERT(info.decl != nullptr);
array_add(&c->procs, info);
}
@@ -3064,9 +3064,12 @@ void check_import_entities(Checker *c) {
};
if (path.count == 1) {
+ // TODO(bill): Should this be allowed or disabled?
+ #if 0
ImportPathItem item = path[0];
String filename = fn(item);
error(item.decl, "Self importation of '%.*s'", LIT(filename));
+ #endif
} else if (path.count > 0) {
ImportPathItem item = path[path.count-1];
String filename = fn(item);
diff --git a/src/ir.cpp b/src/ir.cpp
index 3a64585d4..d88eac3f8 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -7245,6 +7245,11 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
irValue *next = ir_add_local_generated(proc, t_context);
ir_emit_store(proc, next, new_context);
+ Selection sel = lookup_field(proc->module->allocator, t_context, str_lit("parent"), false);
+ GB_ASSERT(sel.entity != nullptr);
+ irValue *parent_ptr = ir_emit_deep_field_gep(proc, next, sel);
+ ir_emit_store(proc, parent_ptr, prev);
+
array_add(&proc->context_stack, next);
defer (array_pop(&proc->context_stack));
@@ -8030,13 +8035,11 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
{
irValue *is_packed = ir_const_bool(a, t->Struct.is_packed);
- irValue *is_ordered = ir_const_bool(a, t->Struct.is_ordered);
irValue *is_raw_union = ir_const_bool(a, t->Struct.is_raw_union);
irValue *is_custom_align = ir_const_bool(a, t->Struct.custom_align != 0);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 4), is_packed);
- ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 5), is_ordered);
- ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 6), is_raw_union);
- ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 7), is_custom_align);
+ ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 5), is_raw_union);
+ ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 6), is_custom_align);
}
isize count = t->Struct.fields.count;
diff --git a/src/parser.cpp b/src/parser.cpp
index fb1d3e364..f24569790 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -185,10 +185,6 @@ Array<AstNode *> make_ast_node_array(AstFile *f, isize init_capacity = 8) {
Array<AstNode *> elems; \
Token open, close; \
}) \
- AST_NODE_KIND(Alias, "alias", struct { \
- Token token; \
- AstNode *expr; \
- }) \
AST_NODE_KIND(_ExprBegin, "", i32) \
AST_NODE_KIND(BadExpr, "bad expression", struct { Token begin, end; }) \
AST_NODE_KIND(TagExpr, "tag expression", struct { Token token, name; AstNode *expr; }) \
@@ -461,7 +457,6 @@ AST_NODE_KIND(_TypeBegin, "", i32) \
isize field_count; \
AstNode * polymorphic_params; \
bool is_packed; \
- bool is_ordered; \
bool is_raw_union; \
AstNode * align; \
}) \
@@ -562,7 +557,6 @@ Token ast_node_token(AstNode *node) {
return ast_node_token(node->CompoundLit.type);
}
return node->CompoundLit.open;
- case AstNode_Alias: return node->Alias.token;
case AstNode_TagExpr: return node->TagExpr.token;
case AstNode_RunExpr: return node->RunExpr.token;
@@ -698,9 +692,6 @@ AstNode *clone_ast_node(gbAllocator a, AstNode *node) {
n->CompoundLit.type = clone_ast_node(a, n->CompoundLit.type);
n->CompoundLit.elems = clone_ast_node_array(a, n->CompoundLit.elems);
break;
- case AstNode_Alias:
- n->Alias.expr = clone_ast_node(a, n->Alias.expr);
- break;
case AstNode_BadExpr: break;
case AstNode_TagExpr:
@@ -1177,12 +1168,6 @@ AstNode *ast_compound_lit(AstFile *f, AstNode *type, Array<AstNode *> elems, Tok
result->CompoundLit.close = close;
return result;
}
-AstNode *ast_alias(AstFile *f, Token token, AstNode *expr) {
- AstNode *result = make_ast_node(f, AstNode_Alias);
- result->Alias.token = token;
- result->Alias.expr = expr;
- return result;
-}
AstNode *ast_ternary_expr(AstFile *f, AstNode *cond, AstNode *x, AstNode *y) {
@@ -1499,7 +1484,7 @@ AstNode *ast_dynamic_array_type(AstFile *f, Token token, AstNode *elem) {
}
AstNode *ast_struct_type(AstFile *f, Token token, Array<AstNode *> fields, isize field_count,
- AstNode *polymorphic_params, bool is_packed, bool is_ordered, bool is_raw_union,
+ AstNode *polymorphic_params, bool is_packed, bool is_raw_union,
AstNode *align) {
AstNode *result = make_ast_node(f, AstNode_StructType);
result->StructType.token = token;
@@ -1507,7 +1492,6 @@ AstNode *ast_struct_type(AstFile *f, Token token, Array<AstNode *> fields, isize
result->StructType.field_count = field_count;
result->StructType.polymorphic_params = polymorphic_params;
result->StructType.is_packed = is_packed;
- result->StructType.is_ordered = is_ordered;
result->StructType.is_raw_union = is_raw_union;
result->StructType.align = align;
return result;
@@ -2226,7 +2210,7 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
return ast_helper_type(f, token, parse_type(f));
}
Token name = expect_token(f, Token_Ident);
- if (name.string == "alias") {
+ if (name.string == "type_alias") {
return ast_alias_type(f, token, parse_type(f));
} else if (name.string == "run") {
AstNode *expr = parse_expr(f, false);
@@ -2405,7 +2389,6 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
Token token = expect_token(f, Token_struct);
AstNode *polymorphic_params = nullptr;
bool is_packed = false;
- bool is_ordered = false;
bool is_raw_union = false;
AstNode *align = nullptr;
@@ -2429,11 +2412,6 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
}
is_packed = true;
- } else if (tag.string == "ordered") {
- if (is_ordered) {
- syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
- }
- is_ordered = true;
} else if (tag.string == "align") {
if (align) {
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
@@ -2451,17 +2429,10 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
f->expr_level = prev_level;
- if (is_packed && is_ordered) {
- syntax_error(token, "'#ordered' is not needed with '#packed' which implies ordering");
- }
if (is_raw_union && is_packed) {
is_packed = false;
syntax_error(token, "'#raw_union' cannot also be '#packed'");
}
- if (is_raw_union && is_ordered) {
- is_ordered = false;
- syntax_error(token, "'#raw_union' cannot also be '#ordered'");
- }
Token open = expect_token_after(f, Token_OpenBrace, "struct");
@@ -2475,7 +2446,7 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
decls = fields->FieldList.list;
}
- return ast_struct_type(f, token, decls, name_count, polymorphic_params, is_packed, is_ordered, is_raw_union, align);
+ return ast_struct_type(f, token, decls, name_count, polymorphic_params, is_packed, is_raw_union, align);
} break;
case Token_union: {
@@ -3659,7 +3630,6 @@ AstNode *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, Tok
}
AstNode *parse_type_or_ident(AstFile *f) {
-#if 1
bool prev_allow_type = f->allow_type;
isize prev_expr_level = f->expr_level;
defer (f->allow_type = prev_allow_type);
@@ -3669,281 +3639,6 @@ AstNode *parse_type_or_ident(AstFile *f) {
AstNode *operand = parse_operand(f, true);
AstNode *type = parse_atom_expr(f, operand, true);
return type;
-#else
- switch (f->curr_token.kind) {
- case Token_Dollar: {
- Token token = expect_token(f, Token_Dollar);
- AstNode *type = parse_ident(f);
- return ast_poly_type(f, token, type);
- } break;
-
- case Token_type_of: {
- AstNode *i = ast_implicit(f, expect_token(f, Token_type_of));
- AstNode *type = parse_call_expr(f, i);
- while (f->curr_token.kind == Token_Period) {
- Token token = advance_token(f);
- AstNode *sel = parse_ident(f);
- type = ast_selector_expr(f, token, type, sel);
- }
- return type;
- } break;
-
- case Token_Ident: {
- AstNode *e = parse_ident(f);
- while (f->curr_token.kind == Token_Period) {
- Token token = advance_token(f);
- AstNode *sel = parse_ident(f);
- e = ast_selector_expr(f, token, e, sel);
- }
- // TODO(bill): Merge type_or_ident into the general parsing for expressions
- // if (f->curr_token.kind == Token_OpenParen) {
- // HACK NOTE(bill): For type_of_val(expr) et al.
- // e = parse_call_expr(f, e);
- // }
- return e;
- } break;
-
- case Token_Pointer: {
- Token token = expect_token(f, Token_Pointer);
- AstNode *elem = parse_type(f);
- return ast_pointer_type(f, token, elem);
- } break;
-
- case Token_atomic: {
- Token token = expect_token(f, Token_atomic);
- AstNode *elem = parse_type(f);
- return ast_atomic_type(f, token, elem);
- } break;
-
- case Token_Hash: {
- Token hash_token = expect_token(f, Token_Hash);
- Token type_token = expect_token(f, Token_type);
- AstNode *type = parse_type(f);
- return ast_helper_type(f, hash_token, type);
- }
-
- case Token_OpenBracket: {
- Token token = expect_token(f, Token_OpenBracket);
- AstNode *count_expr = nullptr;
- bool is_vector = false;
-
- if (f->curr_token.kind == Token_Ellipsis) {
- count_expr = ast_unary_expr(f, expect_token(f, Token_Ellipsis), nullptr);
- } else if (allow_token(f, Token_vector)) {
- if (f->curr_token.kind != Token_CloseBracket) {
- f->expr_level++;
- count_expr = parse_expr(f, false);
- f->expr_level--;
- } else {
- syntax_error(f->curr_token, "Vector type missing count");
- }
- is_vector = true;
- } else if (allow_token(f, Token_dynamic)) {
- expect_token(f, Token_CloseBracket);
- return ast_dynamic_array_type(f, token, parse_type(f));
- } else if (f->curr_token.kind != Token_CloseBracket) {
- f->expr_level++;
- count_expr = parse_expr(f, false);
- f->expr_level--;
- }
- expect_token(f, Token_CloseBracket);
- if (is_vector) {
- return ast_vector_type(f, token, count_expr, parse_type(f));
- }
- return ast_array_type(f, token, count_expr, parse_type(f));
- } break;
-
- case Token_map: {
- Token token = expect_token(f, Token_map);
- AstNode *count = nullptr;
- AstNode *key = nullptr;
- AstNode *value = nullptr;
-
- Token open = expect_token_after(f, Token_OpenBracket, "map");
- key = parse_expr(f, true);
- if (allow_token(f, Token_Comma)) {
- count = key;
- key = parse_type(f);
- }
- Token close = expect_token(f, Token_CloseBracket);
- value = parse_type(f);
-
- return ast_map_type(f, token, count, key, value);
- } break;
-
- case Token_struct: {
- Token token = expect_token(f, Token_struct);
- bool is_packed = false;
- bool is_ordered = false;
- AstNode *align = nullptr;
-
- isize prev_level = f->expr_level;
- f->expr_level = -1;
-
- while (allow_token(f, Token_Hash)) {
- Token tag = expect_token_after(f, Token_Ident, "#");
- if (tag.string == "packed") {
- if (is_packed) {
- syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
- }
- is_packed = true;
- } else if (tag.string == "ordered") {
- if (is_ordered) {
- syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
- }
- is_ordered = true;
- } else if (tag.string == "align") {
- if (align) {
- syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
- }
- align = parse_expr(f, true);
- } else {
- syntax_error(tag, "Invalid struct tag '#%.*s'", LIT(tag.string));
- }
- }
-
- f->expr_level = prev_level;
-
- if (is_packed && is_ordered) {
- syntax_error(token, "'#ordered' is not needed with '#packed' which implies ordering");
- }
-
- Token open = expect_token_after(f, Token_OpenBrace, "struct");
-
- isize name_count = 0;
- AstNode *fields = parse_struct_field_list(f, &name_count);
- Token close = expect_token(f, Token_CloseBrace);
-
- Array<AstNode *> decls = {};
- if (fields != nullptr) {
- GB_ASSERT(fields->kind == AstNode_FieldList);
- decls = fields->FieldList.list;
- }
-
- return ast_struct_type(f, token, decls, name_count, is_packed, is_ordered, align);
- } break;
-
- case Token_union: {
- Token token = expect_token(f, Token_union);
- Token open = expect_token_after(f, Token_OpenBrace, "union");
- Array<AstNode *> variants = make_ast_node_array(f);
- isize total_decl_name_count = 0;
-
- CommentGroup docs = f->lead_comment;
- Token start_token = f->curr_token;
-
-
- while (f->curr_token.kind != Token_CloseBrace &&
- f->curr_token.kind != Token_EOF) {
- AstNode *type = parse_type(f);
- if (type->kind != AstNode_BadExpr) {
- array_add(&variants, type);
- }
- if (!allow_token(f, Token_Comma)) {
- break;
- }
- }
-
- Token close = expect_token(f, Token_CloseBrace);
-
- return ast_union_type(f, token, variants);
- } break;
-
- case Token_raw_union: {
- Token token = expect_token(f, Token_raw_union);
- Token open = expect_token_after(f, Token_OpenBrace, "raw_union");
-
- isize decl_count = 0;
- AstNode *fields = parse_struct_field_list(f, &decl_count);
- Token close = expect_token(f, Token_CloseBrace);
-
- Array<AstNode *> decls = {};
- if (fields != nullptr) {
- GB_ASSERT(fields->kind == AstNode_FieldList);
- decls = fields->FieldList.list;
- }
-
- return ast_raw_union_type(f, token, decls, decl_count);
- } break;
-
- case Token_enum: {
- Token token = expect_token(f, Token_enum);
- AstNode *base_type = nullptr;
- if (f->curr_token.kind != Token_OpenBrace) {
- base_type = parse_type(f);
- }
- Token open = expect_token(f, Token_OpenBrace);
-
- Array<AstNode *> values = parse_element_list(f);
- Token close = expect_token(f, Token_CloseBrace);
-
- return ast_enum_type(f, token, base_type, values);
- } break;
-
- case Token_bit_field: {
- Token token = expect_token(f, Token_bit_field);
- Array<AstNode *> fields = make_ast_node_array(f);
- AstNode *align = nullptr;
- Token open, close;
-
- isize prev_level = f->expr_level;
- f->expr_level = -1;
-
- while (allow_token(f, Token_Hash)) {
- Token tag = expect_token_after(f, Token_Ident, "#");
- if (tag.string == "align") {
- if (align) {
- syntax_error(tag, "Duplicate bit_field tag '#%.*s'", LIT(tag.string));
- }
- align = parse_expr(f, true);
- } else {
- syntax_error(tag, "Invalid bit_field tag '#%.*s'", LIT(tag.string));
- }
- }
-
- f->expr_level = prev_level;
-
- open = expect_token_after(f, Token_OpenBrace, "bit_field");
-
- while (f->curr_token.kind != Token_EOF &&
- f->curr_token.kind != Token_CloseBrace) {
- AstNode *name = parse_ident(f);
- Token colon = expect_token(f, Token_Colon);
- AstNode *value = parse_expr(f, true);
-
- AstNode *field = ast_field_value(f, name, value, colon);
- array_add(&fields, field);
-
- if (f->curr_token.kind != Token_Comma) {
- break;
- }
- advance_token(f);
- }
-
- close = expect_token(f, Token_CloseBrace);
-
- return ast_bit_field_type(f, token, fields, align);
- } break;
-
- case Token_proc: {
- Token token = advance_token(f);
- AstNode *pt = parse_proc_type(f, token, nullptr);
- if (pt->ProcType.tags != 0) {
- syntax_error(token, "A procedure type cannot have tags");
- }
- return pt;
- } break;
-
- case Token_OpenParen: {
- Token open = expect_token(f, Token_OpenParen);
- AstNode *type = parse_type(f);
- Token close = expect_token(f, Token_CloseParen);
- return ast_paren_expr(f, type, open, close);
- } break;
- }
-
- return nullptr;
-#endif
}
diff --git a/src/types.cpp b/src/types.cpp
index cbf55ac4b..453f4fd71 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -80,7 +80,6 @@ struct TypeStruct {
bool are_offsets_set;
bool are_offsets_being_processed;
bool is_packed;
- bool is_ordered;
bool is_raw_union;
bool is_polymorphic;
bool is_poly_specialized;
@@ -1177,7 +1176,6 @@ bool are_types_identical(Type *x, Type *y) {
if (x->Struct.is_raw_union == y->Struct.is_raw_union &&
x->Struct.fields.count == y->Struct.fields.count &&
x->Struct.is_packed == y->Struct.is_packed &&
- x->Struct.is_ordered == y->Struct.is_ordered &&
x->Struct.custom_align == y->Struct.custom_align) {
// TODO(bill); Fix the custom alignment rule
for_array(i, x->Struct.fields) {
@@ -2338,7 +2336,6 @@ gbString write_type_to_string(gbString str, Type *type) {
case Type_Struct: {
str = gb_string_appendc(str, "struct");
if (type->Struct.is_packed) str = gb_string_appendc(str, " #packed");
- if (type->Struct.is_ordered) str = gb_string_appendc(str, " #ordered");
if (type->Struct.is_raw_union) str = gb_string_appendc(str, " #raw_union");
str = gb_string_appendc(str, " {");
for_array(i, type->Struct.fields) {