Browse Source

Remove `struct #ordered`

gingerBill 7 years ago
parent
commit
30530d058c
15 changed files with 83 additions and 396 deletions
  1. 28 28
      core/_preload.odin
  2. 0 1
      core/fmt.odin
  3. 1 1
      core/os_essence.odin
  4. 2 2
      core/os_linux.odin
  5. 2 2
      core/os_x.odin
  6. 5 5
      core/raw.odin
  7. 27 27
      core/sys/windows.odin
  8. 0 1
      core/types.odin
  9. 0 2
      examples/demo.odin
  10. 0 1
      src/check_expr.cpp
  11. 4 10
      src/check_type.cpp
  12. 4 1
      src/checker.cpp
  13. 7 4
      src/ir.cpp
  14. 3 308
      src/parser.cpp
  15. 0 3
      src/types.cpp

+ 28 - 28
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,

+ 0 - 1
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 ");

+ 1 - 1
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,

+ 2 - 2
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

+ 2 - 2
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

+ 5 - 5
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,
 }

+ 27 - 27
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 {

+ 0 - 1
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;

+ 0 - 2
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();

+ 0 - 1
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);

+ 4 - 10
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;
 

+ 4 - 1
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);

+ 7 - 4
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;

+ 3 - 308
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
 }
 
 

+ 0 - 3
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) {