Remove type prefix declarations

This commit is contained in:
Ginger Bill
2017-06-28 23:23:10 +01:00
parent 0622509807
commit 4f28e9e1fb
17 changed files with 233 additions and 256 deletions
+99 -103
View File
@@ -25,91 +25,89 @@ import (
// IMPORTANT NOTE(bill): Do not change the order of any of this data // IMPORTANT NOTE(bill): Do not change the order of any of this data
// The compiler relies upon this _exact_ order // The compiler relies upon this _exact_ order
type ( TypeInfoEnumValue :: raw_union {
TypeInfoEnumValue raw_union { f: f64,
f: f64, i: i128,
i: i128, }
} // NOTE(bill): This must match the compiler's
// NOTE(bill): This must match the compiler's CallingConvention :: enum {
CallingConvention enum { Invalid = 0,
Invalid = 0, Odin = 1,
Odin = 1, Contextless = 2,
Contextless = 2, C = 3,
C = 3, Std = 4,
Std = 4, Fast = 5,
Fast = 5, }
}
TypeInfoRecord struct #ordered { TypeInfoRecord :: struct #ordered {
types: []^TypeInfo, types: []^TypeInfo,
names: []string, names: []string,
offsets: []int, // offsets may not be used in tuples offsets: []int, // offsets may not be used in tuples
usings: []bool, // usings may not be used in tuples usings: []bool, // usings may not be used in tuples
packed: bool, packed: bool,
ordered: bool, ordered: bool,
custom_align: bool, custom_align: bool,
} }
TypeInfo union { TypeInfo :: union {
size: int, size: int,
align: int, align: int,
Named{name: string, base: ^TypeInfo}, Named{name: string, base: ^TypeInfo},
Integer{signed: bool}, Integer{signed: bool},
Rune{}, Rune{},
Float{}, Float{},
Complex{}, Complex{},
String{}, String{},
Boolean{}, Boolean{},
Any{}, Any{},
Pointer{ Pointer{
elem: ^TypeInfo, // nil -> rawptr elem: ^TypeInfo, // nil -> rawptr
},
Atomic{elem: ^TypeInfo},
Procedure{
params: ^TypeInfo, // TypeInfo.Tuple
results: ^TypeInfo, // TypeInfo.Tuple
variadic: bool,
convention: CallingConvention,
},
Array{
elem: ^TypeInfo,
elem_size: int,
count: int,
},
DynamicArray{elem: ^TypeInfo, elem_size: int},
Slice {elem: ^TypeInfo, elem_size: int},
Vector {elem: ^TypeInfo, elem_size, count: int},
Tuple {using record: TypeInfoRecord}, // Only really used for procedures
Struct {using record: TypeInfoRecord},
RawUnion {using record: TypeInfoRecord},
Union{
common_fields: struct {
types: []^TypeInfo,
names: []string,
offsets: []int, // offsets may not be used in tuples
}, },
Atomic{elem: ^TypeInfo}, variant_names: []string,
Procedure{ variant_types: []^TypeInfo,
params: ^TypeInfo, // TypeInfo.Tuple },
results: ^TypeInfo, // TypeInfo.Tuple Enum{
variadic: bool, base: ^TypeInfo,
convention: CallingConvention, names: []string,
}, values: []TypeInfoEnumValue,
Array{ },
elem: ^TypeInfo, Map{
elem_size: int, key: ^TypeInfo,
count: int, value: ^TypeInfo,
}, generated_struct: ^TypeInfo,
DynamicArray{elem: ^TypeInfo, elem_size: int}, count: int, // == 0 if dynamic
Slice {elem: ^TypeInfo, elem_size: int}, },
Vector {elem: ^TypeInfo, elem_size, count: int}, BitField{
Tuple {using record: TypeInfoRecord}, // Only really used for procedures names: []string,
Struct {using record: TypeInfoRecord}, bits: []i32,
RawUnion {using record: TypeInfoRecord}, offsets: []i32,
Union{ },
common_fields: struct { }
types: []^TypeInfo,
names: []string,
offsets: []int, // offsets may not be used in tuples
},
variant_names: []string,
variant_types: []^TypeInfo,
},
Enum{
base: ^TypeInfo,
names: []string,
values: []TypeInfoEnumValue,
},
Map{
key: ^TypeInfo,
value: ^TypeInfo,
generated_struct: ^TypeInfo,
count: int, // == 0 if dynamic
},
BitField{
names: []string,
bits: []i32,
offsets: []i32,
},
}
)
// NOTE(bill): only the ones that are needed (not all types) // NOTE(bill): only the ones that are needed (not all types)
// This will be set by the compiler // This will be set by the compiler
@@ -154,37 +152,35 @@ foreign __llvm_core {
} }
// IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it) // IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)
type ( AllocatorMode :: enum u8 {
AllocatorMode enum u8 { Alloc,
Alloc, Free,
Free, FreeAll,
FreeAll, Resize,
Resize, }
} AllocatorProc :: proc(allocator_data: rawptr, mode: AllocatorMode,
AllocatorProc proc(allocator_data: rawptr, mode: AllocatorMode, size, alignment: int,
size, alignment: int, old_memory: rawptr, old_size: int, flags: u64 = 0) -> rawptr;
old_memory: rawptr, old_size: int, flags: u64 = 0) -> rawptr; Allocator :: struct #ordered {
Allocator struct #ordered { procedure: AllocatorProc,
procedure: AllocatorProc, data: rawptr,
data: rawptr, }
}
Context struct #ordered { Context :: struct #ordered {
thread_id: int, thread_id: int,
allocator: Allocator, allocator: Allocator,
user_data: rawptr, user_data: rawptr,
user_index: int, user_index: int,
} }
)
// #thread_local var __context: Context; // #thread_local var __context: Context;
type SourceCodeLocation struct { SourceCodeLocation :: struct {
fully_pathed_filename: string, fully_pathed_filename: string,
line, column: i64, line, column: i64,
procedure: string, procedure: string,
+2 -2
View File
@@ -6,12 +6,12 @@ proc __multi3(a, b: u128) -> u128 #cc_c #link_name "__multi3" {
when ODIN_ENDIAN == "bit" { when ODIN_ENDIAN == "bit" {
type TWords raw_union { TWords :: raw_union {
all: u128, all: u128,
using _: struct {lo, hi: u64}, using _: struct {lo, hi: u64},
}; };
} else { } else {
type TWords raw_union { TWords :: raw_union {
all: u128, all: u128,
using _: struct {hi, lo: u64}, using _: struct {hi, lo: u64},
}; };
+1 -1
View File
@@ -2,7 +2,7 @@
// Multiple precision decimal numbers // Multiple precision decimal numbers
// NOTE: This is only for floating point printing and nothing else // NOTE: This is only for floating point printing and nothing else
type Decimal struct { Decimal :: struct {
digits: [384]u8, // big-endian digits digits: [384]u8, // big-endian digits
count: int, count: int,
decimal_point: int, decimal_point: int,
+2 -2
View File
@@ -9,12 +9,12 @@ import (
_BUFFER_SIZE :: 1<<12; _BUFFER_SIZE :: 1<<12;
type StringBuffer union { StringBuffer :: union {
Static {buf: []u8}, Static {buf: []u8},
Dynamic{buf: [dynamic]u8}, Dynamic{buf: [dynamic]u8},
} }
type FmtInfo struct { FmtInfo :: struct {
minus: bool, minus: bool,
plus: bool, plus: bool,
space: bool, space: bool,
+8 -10
View File
@@ -16,18 +16,16 @@ EPSILON :: 1.19209290e-7;
τ :: TAU; τ :: TAU;
π :: PI; π :: PI;
type ( Vec2 :: [vector 2]f32;
Vec2 [vector 2]f32; Vec3 :: [vector 3]f32;
Vec3 [vector 3]f32; Vec4 :: [vector 4]f32;
Vec4 [vector 4]f32;
// Column major // Column major
Mat2 [2][2]f32; Mat2 :: [2][2]f32;
Mat3 [3][3]f32; Mat3 :: [3][3]f32;
Mat4 [4][4]f32; Mat4 :: [4][4]f32;
Complex complex64; Complex :: complex64;
)
foreign __llvm_core { foreign __llvm_core {
proc sqrt(x: f32) -> f32 #link_name "llvm.sqrt.f32"; proc sqrt(x: f32) -> f32 #link_name "llvm.sqrt.f32";
+13 -13
View File
@@ -52,7 +52,7 @@ proc align_forward(ptr: rawptr, align: int) -> rawptr {
type AllocationHeader struct { AllocationHeader :: struct {
size: int, size: int,
} }
@@ -80,19 +80,19 @@ proc allocation_header(data: rawptr) -> ^AllocationHeader {
// Custom allocators // Custom allocators
type (
Arena struct {
backing: Allocator,
offset: int,
memory: []u8,
temp_count: int,
}
ArenaTempMemory struct { Arena :: struct {
arena: ^Arena, backing: Allocator,
original_count: int, offset: int,
} memory: []u8,
) temp_count: int,
}
ArenaTempMemory :: struct {
arena: ^Arena,
original_count: int,
}
+5 -7
View File
@@ -4,11 +4,9 @@ foreign_system_library (
) )
import "strings.odin"; import "strings.odin";
type ( Handle :: i32;
Handle i32; FileTime :: u64;
FileTime u64; Errno :: i32;
Errno i32;
)
O_RDONLY :: 0x00000; O_RDONLY :: 0x00000;
@@ -42,7 +40,7 @@ RTLD_GLOBAL :: 0x100;
// "Argv" arguments converted to Odin strings // "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments(); args := _alloc_command_line_arguments();
type _FileTime struct #ordered { _FileTime :: struct #ordered {
seconds: i64, seconds: i64,
nanoseconds: i32, nanoseconds: i32,
reserved: i32, reserved: i32,
@@ -52,7 +50,7 @@ type _FileTime 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 // 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. // Validity is not guaranteed.
type Stat struct #ordered { Stat :: struct #ordered {
device_id: u64, // ID of device containing file device_id: u64, // ID of device containing file
serial: u64, // File serial number serial: u64, // File serial number
nlink: u32, // Number of hard links nlink: u32, // Number of hard links
+4 -5
View File
@@ -1,9 +1,8 @@
import win32 "sys/windows.odin"; import win32 "sys/windows.odin";
type ( Handle :: int;
Handle int; FileTime :: u64;
FileTime u64;
)
INVALID_HANDLE: Handle : -1; INVALID_HANDLE: Handle : -1;
@@ -22,7 +21,7 @@ O_SYNC :: 0x01000;
O_ASYNC :: 0x02000; O_ASYNC :: 0x02000;
O_CLOEXEC :: 0x80000; O_CLOEXEC :: 0x80000;
type Errno int; Errno :: int;
ERROR_NONE: Errno : 0; ERROR_NONE: Errno : 0;
ERROR_FILE_NOT_FOUND: Errno : 2; ERROR_FILE_NOT_FOUND: Errno : 2;
+6 -9
View File
@@ -5,13 +5,10 @@ foreign_system_library (
import "strings.odin"; import "strings.odin";
type ( Handle :: i32;
Handle i32; FileTime :: u64;
FileTime u64; Errno :: int;
Errno int; AddressSize :: int;
AddressSize int;
)
O_RDONLY :: 0x00000; O_RDONLY :: 0x00000;
@@ -50,12 +47,12 @@ RTLD_FIRST :: 0x100;
args: [dynamic]string; args: [dynamic]string;
type _FileTime struct #ordered { _FileTime :: struct #ordered {
seconds: i64, seconds: i64,
nanoseconds: i64 nanoseconds: i64
} }
type Stat struct #ordered { Stat :: struct #ordered {
device_id : i32, // ID of device containing file device_id : i32, // ID of device containing file
mode : u16, // Mode of the file mode : u16, // Mode of the file
nlink : u16, // Number of hard links nlink : u16, // Number of hard links
+24 -25
View File
@@ -1,29 +1,28 @@
type ( Any :: struct #ordered {
Any struct #ordered { data: rawptr,
data: rawptr, type_info: ^TypeInfo,
type_info: ^TypeInfo, };
};
String struct #ordered { String :: struct #ordered {
data: ^u8, data: ^u8,
len: int, len: int,
}; };
Slice struct #ordered { Slice :: struct #ordered {
data: rawptr, data: rawptr,
len: int, len: int,
cap: int, cap: int,
}; };
DynamicArray struct #ordered { DynamicArray :: struct #ordered {
data: rawptr, data: rawptr,
len: int, len: int,
cap: int, cap: int,
allocator: Allocator, allocator: Allocator,
}; };
DynamicMap :: struct #ordered {
hashes: [dynamic]int,
entries: DynamicArray,
};
DynamicMap struct #ordered {
hashes: [dynamic]int,
entries: DynamicArray,
};
)
+1 -1
View File
@@ -1,6 +1,6 @@
import . "decimal.odin"; import . "decimal.odin";
type IntFlag enum { IntFlag :: enum {
Prefix = 1<<0, Prefix = 1<<0,
Plus = 1<<1, Plus = 1<<1,
Space = 1<<2, Space = 1<<2,
+2 -2
View File
@@ -3,11 +3,11 @@ import (
"os.odin"; "os.odin";
) )
type Semaphore struct { Semaphore :: struct {
// _handle: win32.Handle, // _handle: win32.Handle,
} }
type Mutex struct { Mutex :: struct {
_semaphore: Semaphore, _semaphore: Semaphore,
_counter: i32, _counter: i32,
_owner: i32, _owner: i32,
+2 -2
View File
@@ -3,11 +3,11 @@ import (
"atomics.odin"; "atomics.odin";
) )
type Semaphore struct { Semaphore :: struct {
_handle: win32.Handle, _handle: win32.Handle,
} }
type Mutex struct { Mutex :: struct {
_semaphore: Semaphore, _semaphore: Semaphore,
_counter: i32, _counter: i32,
_owner: i32, _owner: i32,
+42 -46
View File
@@ -10,56 +10,52 @@ CONTEXT_FORWARD_COMPATIBLE_BIT_ARB :: 0x0002;
CONTEXT_CORE_PROFILE_BIT_ARB :: 0x00000001; CONTEXT_CORE_PROFILE_BIT_ARB :: 0x00000001;
CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002; CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002;
type ( Hglrc :: Handle;
Hglrc Handle; ColorRef :: u32;
ColorRef u32;
LayerPlaneDescriptor struct { LayerPlaneDescriptor :: struct {
size: u16, size: u16,
version: u16, version: u16,
flags: u32, flags: u32,
pixel_type: u8, pixel_type: u8,
color_bits: u8, color_bits: u8,
red_bits: u8, red_bits: u8,
red_shift: u8, red_shift: u8,
green_bits: u8, green_bits: u8,
green_shift: u8, green_shift: u8,
blue_bits: u8, blue_bits: u8,
blue_shift: u8, blue_shift: u8,
alpha_bits: u8, alpha_bits: u8,
alpha_shift: u8, alpha_shift: u8,
accum_bits: u8, accum_bits: u8,
accum_red_bits: u8, accum_red_bits: u8,
accum_green_bits: u8, accum_green_bits: u8,
accum_blue_bits: u8, accum_blue_bits: u8,
accum_alpha_bits: u8, accum_alpha_bits: u8,
depth_bits: u8, depth_bits: u8,
stencil_bits: u8, stencil_bits: u8,
aux_buffers: u8, aux_buffers: u8,
layer_type: u8, layer_type: u8,
reserved: u8, reserved: u8,
transparent: ColorRef, transparent: ColorRef,
} }
PointFloat struct { PointFloat :: struct {
x, y: f32, x, y: f32,
} }
Glyph_MetricsFloat struct { Glyph_MetricsFloat :: struct {
black_box_x: f32, black_box_x: f32,
black_box_y: f32, black_box_y: f32,
glyph_origin: PointFloat, glyph_origin: PointFloat,
cell_inc_x: f32, cell_inc_x: f32,
cell_inc_y: f32, cell_inc_y: f32,
} }
)
type ( CreateContextAttribsARBType :: proc(hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc;
CreateContextAttribsARBType proc(hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc; ChoosePixelFormatARBType :: proc(hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool #cc_c;
ChoosePixelFormatARBType proc(hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool #cc_c; SwapIntervalEXTType :: proc(interval: i32) -> bool #cc_c;
SwapIntervalEXTType proc(interval: i32) -> bool #cc_c; GetExtensionsStringARBType :: proc(Hdc) -> ^u8 #cc_c;
GetExtensionsStringARBType proc(Hdc) -> ^u8 #cc_c;
)
// Procedures // Procedures
create_context_attribs_arb: CreateContextAttribsARBType; create_context_attribs_arb: CreateContextAttribsARBType;
+18 -20
View File
@@ -6,25 +6,23 @@ foreign_system_library (
"shell32.lib" when ODIN_OS == "windows"; "shell32.lib" when ODIN_OS == "windows";
) )
type ( Handle :: rawptr;
Handle rawptr; Hwnd :: Handle;
Hwnd Handle; Hdc :: Handle;
Hdc Handle; Hinstance :: Handle;
Hinstance Handle; Hicon :: Handle;
Hicon Handle; Hcursor :: Handle;
Hcursor Handle; Hmenu :: Handle;
Hmenu Handle; Hbrush :: Handle;
Hbrush Handle; Hgdiobj :: Handle;
Hgdiobj Handle; Hmodule :: Handle;
Hmodule Handle; Hmonitor :: Handle;
Hmonitor Handle; Wparam :: uint;
Wparam uint; Lparam :: int;
Lparam int; Lresult :: int;
Lresult int; WndProc :: proc(Hwnd, u32, Wparam, Lparam) -> Lresult #cc_c;
WndProc proc(Hwnd, u32, Wparam, Lparam) -> Lresult #cc_c;
)
type Bool i32; Bool :: i32;
FALSE: Bool : 0; FALSE: Bool : 0;
TRUE: Bool : 1; TRUE: Bool : 1;
@@ -147,7 +145,7 @@ PixelFormatDescriptor :: struct #ordered {
type Proc proc() #cc_c; Proc :: proc() #cc_c;
MAPVK_VK_TO_VSC :: 0; MAPVK_VK_TO_VSC :: 0;
MAPVK_VSC_TO_VK :: 1; MAPVK_VSC_TO_VK :: 1;
@@ -268,7 +266,7 @@ PFD_DEPTH_DONTCARE :: 0x20000000;
PFD_DOUBLEBUFFER_DONTCARE :: 0x40000000; PFD_DOUBLEBUFFER_DONTCARE :: 0x40000000;
PFD_STEREO_DONTCARE :: 0x80000000; PFD_STEREO_DONTCARE :: 0x80000000;
type GET_FILEEX_INFO_LEVELS i32; GET_FILEEX_INFO_LEVELS :: i32;
GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0; GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0;
GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1; GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1;
+1 -1
View File
@@ -194,7 +194,7 @@ void check_const_decl(Checker *c, Entity *e, AstNode *type_expr, AstNode *init,
if (init != NULL) { if (init != NULL) {
check_expr_or_type(c, &operand, init); check_expr_or_type(c, &operand, init);
} }
#if 0 #if 1
if (operand.mode == Addressing_Type) { if (operand.mode == Addressing_Type) {
e->kind = Entity_TypeName; e->kind = Entity_TypeName;
+3 -7
View File
@@ -3033,10 +3033,12 @@ void parse_foreign_block_decl(AstFile *f, Array<AstNode *> *decls) {
case AstNode_BadDecl: case AstNode_BadDecl:
return; return;
case AstNode_ValueDecl:
case AstNode_ProcDecl: case AstNode_ProcDecl:
array_add(decls, decl); array_add(decls, decl);
return; return;
case AstNode_GenDecl: case AstNode_GenDecl:
switch (decl->GenDecl.token.kind) { switch (decl->GenDecl.token.kind) {
case Token_var: case Token_var:
@@ -3170,12 +3172,6 @@ AstNode *parse_value_decl(AstFile *f, Array<AstNode *> names, CommentGroup docs)
AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) { AstNode *parse_simple_stmt(AstFile *f, StmtAllowFlag flags) {
Token token = f->curr_token; Token token = f->curr_token;
switch (f->curr_token.kind) {
case Token_var:
case Token_const:
return parse_decl(f);
}
CommentGroup docs = f->lead_comment; CommentGroup docs = f->lead_comment;
Array<AstNode *> lhs = parse_lhs_expr_list(f); Array<AstNode *> lhs = parse_lhs_expr_list(f);
@@ -4333,7 +4329,7 @@ AstNode *parse_stmt(AstFile *f) {
// case Token_var: // case Token_var:
// case Token_const: // case Token_const:
case Token_proc: case Token_proc:
case Token_type: // case Token_type:
case Token_import: case Token_import:
case Token_import_load: case Token_import_load:
case Token_foreign: case Token_foreign: