mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix immutable rules; add some general documentation
immutable is still a little weird and not completely what you'd expect. Maybe just not having it is better.
This commit is contained in:
+3
-9
@@ -2,16 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
{
|
|
||||||
|
|
||||||
x := [...]int{1, 2, 3, 4};
|
|
||||||
immutable y := ^x;
|
|
||||||
fmt.println(y^[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
/*
|
/*
|
||||||
Version 0.1.0
|
Version 0.1.1
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
* Dynamic Arrays `[...]Type`
|
* Dynamic Arrays `[...]Type`
|
||||||
@@ -24,10 +17,11 @@ main :: proc() {
|
|||||||
* Entities prefixes with an underscore do not get exported on imports
|
* Entities prefixes with an underscore do not get exported on imports
|
||||||
* Overloaded `free` for pointers, slices, strings, dynamic arrays, and dynamic maps
|
* Overloaded `free` for pointers, slices, strings, dynamic arrays, and dynamic maps
|
||||||
* enum types have an implict `names` field, a []string of all the names in that enum
|
* enum types have an implict `names` field, a []string of all the names in that enum
|
||||||
|
* immutable variables are "completely immutable"
|
||||||
|
* `slice_to_bytes` - convert any slice to a slice of bytes
|
||||||
|
|
||||||
Removed:
|
Removed:
|
||||||
* Maybe/option types
|
* Maybe/option types
|
||||||
* immutable variables
|
|
||||||
* Remove `type` keyword and other "reserved" keywords
|
* Remove `type` keyword and other "reserved" keywords
|
||||||
* `compile_assert` and `assert`return the value of the condition for semantic reasons
|
* `compile_assert` and `assert`return the value of the condition for semantic reasons
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
crc32 :: proc(data: []byte) -> u32 {
|
crc32 :: proc(data: []byte) -> u32 {
|
||||||
result := ~cast(u32)0;
|
result := ~cast(u32)0;
|
||||||
for b in data {
|
for b in data {
|
||||||
result = result>>8 ~ __CRC32_TABLE[(result ~ cast(u32)b) & 0xff];
|
result = result>>8 ~ _crc32_table[(result ~ cast(u32)b) & 0xff];
|
||||||
}
|
}
|
||||||
return ~result;
|
return ~result;
|
||||||
}
|
}
|
||||||
crc64 :: proc(data: []byte) -> u64 {
|
crc64 :: proc(data: []byte) -> u64 {
|
||||||
result := ~cast(u64)0;
|
result := ~cast(u64)0;
|
||||||
for b in data {
|
for b in data {
|
||||||
result = result>>8 ~ __CRC64_TABLE[(result ~ cast(u64)b) & 0xff];
|
result = result>>8 ~ _crc64_table[(result ~ cast(u64)b) & 0xff];
|
||||||
}
|
}
|
||||||
return ~result;
|
return ~result;
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ murmur64 :: proc(data: []byte) -> u64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
__CRC32_TABLE := [256]u32{
|
immutable _crc32_table := [256]u32{
|
||||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
||||||
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||||
@@ -268,7 +268,7 @@ __CRC32_TABLE := [256]u32{
|
|||||||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
|
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
|
||||||
};
|
};
|
||||||
__CRC64_TABLE := [256]u64{
|
immutable _crc64_table := [256]u64{
|
||||||
0x0000000000000000, 0x42f0e1eba9ea3693, 0x85e1c3d753d46d26, 0xc711223cfa3e5bb5,
|
0x0000000000000000, 0x42f0e1eba9ea3693, 0x85e1c3d753d46d26, 0xc711223cfa3e5bb5,
|
||||||
0x493366450e42ecdf, 0x0bc387aea7a8da4c, 0xccd2a5925d9681f9, 0x8e224479f47cb76a,
|
0x493366450e42ecdf, 0x0bc387aea7a8da4c, 0xccd2a5925d9681f9, 0x8e224479f47cb76a,
|
||||||
0x9266cc8a1c85d9be, 0xd0962d61b56fef2d, 0x17870f5d4f51b498, 0x5577eeb6e6bb820b,
|
0x9266cc8a1c85d9be, 0xd0962d61b56fef2d, 0x17870f5d4f51b498, 0x5577eeb6e6bb820b,
|
||||||
|
|||||||
+87
-87
@@ -20,13 +20,13 @@ Viewport :: proc(x, y, width, height: i32) #foreign lib "gl
|
|||||||
Ortho :: proc(left, right, bottom, top, near, far: f64) #foreign lib "glOrtho";
|
Ortho :: proc(left, right, bottom, top, near, far: f64) #foreign lib "glOrtho";
|
||||||
Color3f :: proc(r, g, b: f32) #foreign lib "glColor3f";
|
Color3f :: proc(r, g, b: f32) #foreign lib "glColor3f";
|
||||||
Vertex3f :: proc(x, y, z: f32) #foreign lib "glVertex3f";
|
Vertex3f :: proc(x, y, z: f32) #foreign lib "glVertex3f";
|
||||||
|
GetError :: proc() -> i32 #foreign lib "glGetError";
|
||||||
|
GetString :: proc(name: i32) -> ^byte #foreign lib "glGetString";
|
||||||
|
GetIntegerv :: proc(name: i32, v: ^i32) #foreign lib "glGetIntegerv";
|
||||||
|
TexCoord2f :: proc(x, y: f32) #foreign lib "glTexCoord2f";
|
||||||
TexImage2D :: proc(target, level, internal_format,
|
TexImage2D :: proc(target, level, internal_format,
|
||||||
width, height, border,
|
width, height, border,
|
||||||
format, _type: i32, pixels: rawptr) #foreign lib "glTexImage2D";
|
format, type: i32, pixels: rawptr) #foreign lib "glTexImage2D";
|
||||||
|
|
||||||
GetError :: proc() -> i32 #foreign lib "glGetError";
|
|
||||||
GetString :: proc(name: i32) -> ^byte #foreign lib "glGetString";
|
|
||||||
GetIntegerv :: proc(name: i32, v: ^i32) #foreign lib "glGetIntegerv";
|
|
||||||
|
|
||||||
|
|
||||||
string_data :: proc(s: string) -> ^u8 #inline { return ^s[0]; }
|
string_data :: proc(s: string) -> ^u8 #inline { return ^s[0]; }
|
||||||
@@ -42,114 +42,114 @@ GetProcAddress :: proc(name: string) -> proc() #cc_c {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenBuffers: proc(count: i32, buffers: ^u32) #cc_c;
|
GenBuffers: proc(count: i32, buffers: ^u32) #cc_c;
|
||||||
GenVertexArrays: proc(count: i32, buffers: ^u32) #cc_c;
|
GenVertexArrays: proc(count: i32, buffers: ^u32) #cc_c;
|
||||||
GenSamplers: proc(count: i32, buffers: ^u32) #cc_c;
|
GenSamplers: proc(count: i32, buffers: ^u32) #cc_c;
|
||||||
BindBuffer: proc(target: i32, buffer: u32) #cc_c;
|
BindBuffer: proc(target: i32, buffer: u32) #cc_c;
|
||||||
BindVertexArray: proc(buffer: u32) #cc_c;
|
BindVertexArray: proc(buffer: u32) #cc_c;
|
||||||
BindSampler: proc(position: i32, sampler: u32) #cc_c;
|
BindSampler: proc(position: i32, sampler: u32) #cc_c;
|
||||||
BufferData: proc(target: i32, size: int, data: rawptr, usage: i32) #cc_c;
|
BufferData: proc(target: i32, size: int, data: rawptr, usage: i32) #cc_c;
|
||||||
BufferSubData: proc(target: i32, offset, size: int, data: rawptr) #cc_c;
|
BufferSubData: proc(target: i32, offset, size: int, data: rawptr) #cc_c;
|
||||||
|
|
||||||
DrawArrays: proc(mode, first: i32, count: u32) #cc_c;
|
DrawArrays: proc(mode, first: i32, count: u32) #cc_c;
|
||||||
DrawElements: proc(mode: i32, count: u32, type_: i32, indices: rawptr) #cc_c;
|
DrawElements: proc(mode: i32, count: u32, type_: i32, indices: rawptr) #cc_c;
|
||||||
|
|
||||||
MapBuffer: proc(target, access: i32) -> rawptr #cc_c;
|
MapBuffer: proc(target, access: i32) -> rawptr #cc_c;
|
||||||
UnmapBuffer: proc(target: i32) #cc_c;
|
UnmapBuffer: proc(target: i32) #cc_c;
|
||||||
|
|
||||||
VertexAttribPointer: proc(index: u32, size, type_: i32, normalized: i32, stride: u32, pointer: rawptr) #cc_c;
|
VertexAttribPointer: proc(index: u32, size, type_: i32, normalized: i32, stride: u32, pointer: rawptr) #cc_c;
|
||||||
EnableVertexAttribArray: proc(index: u32) #cc_c;
|
EnableVertexAttribArray: proc(index: u32) #cc_c;
|
||||||
|
|
||||||
CreateShader: proc(shader_type: i32) -> u32 #cc_c;
|
CreateShader: proc(shader_type: i32) -> u32 #cc_c;
|
||||||
ShaderSource: proc(shader: u32, count: u32, str: ^^byte, length: ^i32) #cc_c;
|
ShaderSource: proc(shader: u32, count: u32, str: ^^byte, length: ^i32) #cc_c;
|
||||||
CompileShader: proc(shader: u32) #cc_c;
|
CompileShader: proc(shader: u32) #cc_c;
|
||||||
CreateProgram: proc() -> u32 #cc_c;
|
CreateProgram: proc() -> u32 #cc_c;
|
||||||
AttachShader: proc(program, shader: u32) #cc_c;
|
AttachShader: proc(program, shader: u32) #cc_c;
|
||||||
DetachShader: proc(program, shader: u32) #cc_c;
|
DetachShader: proc(program, shader: u32) #cc_c;
|
||||||
DeleteShader: proc(shader: u32) #cc_c;
|
DeleteShader: proc(shader: u32) #cc_c;
|
||||||
LinkProgram: proc(program: u32) #cc_c;
|
LinkProgram: proc(program: u32) #cc_c;
|
||||||
UseProgram: proc(program: u32) #cc_c;
|
UseProgram: proc(program: u32) #cc_c;
|
||||||
DeleteProgram: proc(program: u32) #cc_c;
|
DeleteProgram: proc(program: u32) #cc_c;
|
||||||
|
|
||||||
|
|
||||||
GetShaderiv: proc(shader: u32, pname: i32, params: ^i32) #cc_c;
|
GetShaderiv: proc(shader: u32, pname: i32, params: ^i32) #cc_c;
|
||||||
GetProgramiv: proc(program: u32, pname: i32, params: ^i32) #cc_c;
|
GetProgramiv: proc(program: u32, pname: i32, params: ^i32) #cc_c;
|
||||||
GetShaderInfoLog: proc(shader: u32, max_length: u32, length: ^u32, info_long: ^byte) #cc_c;
|
GetShaderInfoLog: proc(shader: u32, max_length: u32, length: ^u32, info_long: ^byte) #cc_c;
|
||||||
GetProgramInfoLog: proc(program: u32, max_length: u32, length: ^u32, info_long: ^byte) #cc_c;
|
GetProgramInfoLog: proc(program: u32, max_length: u32, length: ^u32, info_long: ^byte) #cc_c;
|
||||||
|
|
||||||
ActiveTexture: proc(texture: i32) #cc_c;
|
ActiveTexture: proc(texture: i32) #cc_c;
|
||||||
GenerateMipmap: proc(target: i32) #cc_c;
|
GenerateMipmap: proc(target: i32) #cc_c;
|
||||||
|
|
||||||
SamplerParameteri: proc(sampler: u32, pname: i32, param: i32) #cc_c;
|
SamplerParameteri: proc(sampler: u32, pname: i32, param: i32) #cc_c;
|
||||||
SamplerParameterf: proc(sampler: u32, pname: i32, param: f32) #cc_c;
|
SamplerParameterf: proc(sampler: u32, pname: i32, param: f32) #cc_c;
|
||||||
SamplerParameteriv: proc(sampler: u32, pname: i32, params: ^i32) #cc_c;
|
SamplerParameteriv: proc(sampler: u32, pname: i32, params: ^i32) #cc_c;
|
||||||
SamplerParameterfv: proc(sampler: u32, pname: i32, params: ^f32) #cc_c;
|
SamplerParameterfv: proc(sampler: u32, pname: i32, params: ^f32) #cc_c;
|
||||||
SamplerParameterIiv: proc(sampler: u32, pname: i32, params: ^i32) #cc_c;
|
SamplerParameterIiv: proc(sampler: u32, pname: i32, params: ^i32) #cc_c;
|
||||||
SamplerParameterIuiv: proc(sampler: u32, pname: i32, params: ^u32) #cc_c;
|
SamplerParameterIuiv: proc(sampler: u32, pname: i32, params: ^u32) #cc_c;
|
||||||
|
|
||||||
|
|
||||||
Uniform1i: proc(loc: i32, v0: i32) #cc_c;
|
Uniform1i: proc(loc: i32, v0: i32) #cc_c;
|
||||||
Uniform2i: proc(loc: i32, v0, v1: i32) #cc_c;
|
Uniform2i: proc(loc: i32, v0, v1: i32) #cc_c;
|
||||||
Uniform3i: proc(loc: i32, v0, v1, v2: i32) #cc_c;
|
Uniform3i: proc(loc: i32, v0, v1, v2: i32) #cc_c;
|
||||||
Uniform4i: proc(loc: i32, v0, v1, v2, v3: i32) #cc_c;
|
Uniform4i: proc(loc: i32, v0, v1, v2, v3: i32) #cc_c;
|
||||||
Uniform1f: proc(loc: i32, v0: f32) #cc_c;
|
Uniform1f: proc(loc: i32, v0: f32) #cc_c;
|
||||||
Uniform2f: proc(loc: i32, v0, v1: f32) #cc_c;
|
Uniform2f: proc(loc: i32, v0, v1: f32) #cc_c;
|
||||||
Uniform3f: proc(loc: i32, v0, v1, v2: f32) #cc_c;
|
Uniform3f: proc(loc: i32, v0, v1, v2: f32) #cc_c;
|
||||||
Uniform4f: proc(loc: i32, v0, v1, v2, v3: f32) #cc_c;
|
Uniform4f: proc(loc: i32, v0, v1, v2, v3: f32) #cc_c;
|
||||||
UniformMatrix4fv: proc(loc: i32, count: u32, transpose: i32, value: ^f32) #cc_c;
|
UniformMatrix4fv: proc(loc: i32, count: u32, transpose: i32, value: ^f32) #cc_c;
|
||||||
|
|
||||||
GetUniformLocation: proc(program: u32, name: ^byte) -> i32 #cc_c;
|
GetUniformLocation: proc(program: u32, name: ^byte) -> i32 #cc_c;
|
||||||
|
|
||||||
init :: proc() {
|
init :: proc() {
|
||||||
set_proc_address :: proc(p: rawptr, name: string) #inline { (cast(^(proc() #cc_c))p)^ = GetProcAddress(name); }
|
set_proc_address :: proc(p: rawptr, name: string) #inline { (cast(^(proc() #cc_c))p)^ = GetProcAddress(name); }
|
||||||
|
|
||||||
set_proc_address(^GenBuffers, "glGenBuffers\x00");
|
set_proc_address(^GenBuffers, "glGenBuffers\x00");
|
||||||
set_proc_address(^GenVertexArrays, "glGenVertexArrays\x00");
|
set_proc_address(^GenVertexArrays, "glGenVertexArrays\x00");
|
||||||
set_proc_address(^GenSamplers, "glGenSamplers\x00");
|
set_proc_address(^GenSamplers, "glGenSamplers\x00");
|
||||||
set_proc_address(^BindBuffer, "glBindBuffer\x00");
|
set_proc_address(^BindBuffer, "glBindBuffer\x00");
|
||||||
set_proc_address(^BindSampler, "glBindSampler\x00");
|
set_proc_address(^BindSampler, "glBindSampler\x00");
|
||||||
set_proc_address(^BindVertexArray, "glBindVertexArray\x00");
|
set_proc_address(^BindVertexArray, "glBindVertexArray\x00");
|
||||||
set_proc_address(^BufferData, "glBufferData\x00");
|
set_proc_address(^BufferData, "glBufferData\x00");
|
||||||
set_proc_address(^BufferSubData, "glBufferSubData\x00");
|
set_proc_address(^BufferSubData, "glBufferSubData\x00");
|
||||||
|
|
||||||
set_proc_address(^DrawArrays, "glDrawArrays\x00");
|
set_proc_address(^DrawArrays, "glDrawArrays\x00");
|
||||||
set_proc_address(^DrawElements, "glDrawElements\x00");
|
set_proc_address(^DrawElements, "glDrawElements\x00");
|
||||||
|
|
||||||
set_proc_address(^MapBuffer, "glMapBuffer\x00");
|
set_proc_address(^MapBuffer, "glMapBuffer\x00");
|
||||||
set_proc_address(^UnmapBuffer, "glUnmapBuffer\x00");
|
set_proc_address(^UnmapBuffer, "glUnmapBuffer\x00");
|
||||||
|
|
||||||
set_proc_address(^VertexAttribPointer, "glVertexAttribPointer\x00");
|
set_proc_address(^VertexAttribPointer, "glVertexAttribPointer\x00");
|
||||||
set_proc_address(^EnableVertexAttribArray, "glEnableVertexAttribArray\x00");
|
set_proc_address(^EnableVertexAttribArray, "glEnableVertexAttribArray\x00");
|
||||||
|
|
||||||
set_proc_address(^CreateShader, "glCreateShader\x00");
|
set_proc_address(^CreateShader, "glCreateShader\x00");
|
||||||
set_proc_address(^ShaderSource, "glShaderSource\x00");
|
set_proc_address(^ShaderSource, "glShaderSource\x00");
|
||||||
set_proc_address(^CompileShader, "glCompileShader\x00");
|
set_proc_address(^CompileShader, "glCompileShader\x00");
|
||||||
set_proc_address(^CreateProgram, "glCreateProgram\x00");
|
set_proc_address(^CreateProgram, "glCreateProgram\x00");
|
||||||
set_proc_address(^AttachShader, "glAttachShader\x00");
|
set_proc_address(^AttachShader, "glAttachShader\x00");
|
||||||
set_proc_address(^DetachShader, "glDetachShader\x00");
|
set_proc_address(^DetachShader, "glDetachShader\x00");
|
||||||
set_proc_address(^DeleteShader, "glDeleteShader\x00");
|
set_proc_address(^DeleteShader, "glDeleteShader\x00");
|
||||||
set_proc_address(^LinkProgram, "glLinkProgram\x00");
|
set_proc_address(^LinkProgram, "glLinkProgram\x00");
|
||||||
set_proc_address(^UseProgram, "glUseProgram\x00");
|
set_proc_address(^UseProgram, "glUseProgram\x00");
|
||||||
set_proc_address(^DeleteProgram, "glDeleteProgram\x00");
|
set_proc_address(^DeleteProgram, "glDeleteProgram\x00");
|
||||||
|
|
||||||
set_proc_address(^GetShaderiv, "glGetShaderiv\x00");
|
set_proc_address(^GetShaderiv, "glGetShaderiv\x00");
|
||||||
set_proc_address(^GetProgramiv, "glGetProgramiv\x00");
|
set_proc_address(^GetProgramiv, "glGetProgramiv\x00");
|
||||||
set_proc_address(^GetShaderInfoLog, "glGetShaderInfoLog\x00");
|
set_proc_address(^GetShaderInfoLog, "glGetShaderInfoLog\x00");
|
||||||
set_proc_address(^GetProgramInfoLog, "glGetProgramInfoLog\x00");
|
set_proc_address(^GetProgramInfoLog, "glGetProgramInfoLog\x00");
|
||||||
|
|
||||||
set_proc_address(^ActiveTexture, "glActiveTexture\x00");
|
set_proc_address(^ActiveTexture, "glActiveTexture\x00");
|
||||||
set_proc_address(^GenerateMipmap, "glGenerateMipmap\x00");
|
set_proc_address(^GenerateMipmap, "glGenerateMipmap\x00");
|
||||||
|
|
||||||
set_proc_address(^Uniform1i, "glUniform1i\x00");
|
set_proc_address(^Uniform1i, "glUniform1i\x00");
|
||||||
set_proc_address(^UniformMatrix4fv, "glUniformMatrix4fv\x00");
|
set_proc_address(^UniformMatrix4fv, "glUniformMatrix4fv\x00");
|
||||||
|
|
||||||
set_proc_address(^GetUniformLocation, "glGetUniformLocation\x00");
|
set_proc_address(^GetUniformLocation, "glGetUniformLocation\x00");
|
||||||
|
|
||||||
set_proc_address(^SamplerParameteri, "glSamplerParameteri\x00");
|
set_proc_address(^SamplerParameteri, "glSamplerParameteri\x00");
|
||||||
set_proc_address(^SamplerParameterf, "glSamplerParameterf\x00");
|
set_proc_address(^SamplerParameterf, "glSamplerParameterf\x00");
|
||||||
set_proc_address(^SamplerParameteriv, "glSamplerParameteriv\x00");
|
set_proc_address(^SamplerParameteriv, "glSamplerParameteriv\x00");
|
||||||
set_proc_address(^SamplerParameterfv, "glSamplerParameterfv\x00");
|
set_proc_address(^SamplerParameterfv, "glSamplerParameterfv\x00");
|
||||||
set_proc_address(^SamplerParameterIiv, "glSamplerParameterIiv\x00");
|
set_proc_address(^SamplerParameterIiv, "glSamplerParameterIiv\x00");
|
||||||
set_proc_address(^SamplerParameterIuiv, "glSamplerParameterIuiv\x00");
|
set_proc_address(^SamplerParameterIuiv, "glSamplerParameterIuiv\x00");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,14 @@ WS_CAPTION :: 0x00C00000;
|
|||||||
WS_VISIBLE :: 0x10000000;
|
WS_VISIBLE :: 0x10000000;
|
||||||
WS_OVERLAPPEDWINDOW :: WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
|
WS_OVERLAPPEDWINDOW :: WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
|
||||||
|
|
||||||
WM_DESTROY :: 0x0002;
|
WM_DESTROY :: 0x0002;
|
||||||
WM_CLOSE :: 0x0010;
|
WM_SIZE :: 0x0005;
|
||||||
WM_QUIT :: 0x0012;
|
WM_CLOSE :: 0x0010;
|
||||||
WM_KEYDOWN :: 0x0100;
|
WM_ACTIVATEAPP :: 0x001C;
|
||||||
WM_KEYUP :: 0x0101;
|
WM_QUIT :: 0x0012;
|
||||||
|
WM_KEYDOWN :: 0x0100;
|
||||||
|
WM_KEYUP :: 0x0101;
|
||||||
|
WM_SIZING :: 0x0214;
|
||||||
|
|
||||||
PM_REMOVE :: 1;
|
PM_REMOVE :: 1;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ HICB :: 0b1011_1111;
|
|||||||
|
|
||||||
Accept_Range :: struct { lo, hi: u8 }
|
Accept_Range :: struct { lo, hi: u8 }
|
||||||
|
|
||||||
accept_ranges := [5]Accept_Range{
|
immutable accept_ranges := [5]Accept_Range{
|
||||||
{0x80, 0xbf},
|
{0x80, 0xbf},
|
||||||
{0xa0, 0xbf},
|
{0xa0, 0xbf},
|
||||||
{0x80, 0x9f},
|
{0x80, 0x9f},
|
||||||
@@ -38,7 +38,7 @@ accept_ranges := [5]Accept_Range{
|
|||||||
{0x80, 0x8f},
|
{0x80, 0x8f},
|
||||||
};
|
};
|
||||||
|
|
||||||
accept_sizes := [256]byte{
|
immutable accept_sizes := [256]byte{
|
||||||
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x00-0x0f
|
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x00-0x0f
|
||||||
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x10-0x1f
|
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x10-0x1f
|
||||||
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x20-0x2f
|
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 0x20-0x2f
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
// This stores the information for the specify architecture of this build
|
||||||
typedef struct BuildContext {
|
typedef struct BuildContext {
|
||||||
|
// Constants
|
||||||
String ODIN_OS; // target operating system
|
String ODIN_OS; // target operating system
|
||||||
String ODIN_ARCH; // target architecture
|
String ODIN_ARCH; // target architecture
|
||||||
String ODIN_ENDIAN; // target endian
|
String ODIN_ENDIAN; // target endian
|
||||||
@@ -6,8 +8,10 @@ typedef struct BuildContext {
|
|||||||
String ODIN_VERSION; // compiler version
|
String ODIN_VERSION; // compiler version
|
||||||
String ODIN_ROOT; // Odin ROOT
|
String ODIN_ROOT; // Odin ROOT
|
||||||
|
|
||||||
i64 word_size;
|
// In bytes
|
||||||
i64 max_align;
|
i64 word_size; // Size of a pointer, must be >= 4
|
||||||
|
i64 max_align; // max alignment, must be >= 1 (and typically >= word_size)
|
||||||
|
|
||||||
String llc_flags;
|
String llc_flags;
|
||||||
String link_flags;
|
String link_flags;
|
||||||
bool is_dll;
|
bool is_dll;
|
||||||
|
|||||||
+8
-3
@@ -4103,7 +4103,8 @@ void check_set_mode_with_indirection(Operand *o, bool indirection) {
|
|||||||
if (o->mode != Addressing_Immutable) {
|
if (o->mode != Addressing_Immutable) {
|
||||||
if (indirection) {
|
if (indirection) {
|
||||||
o->mode = Addressing_Variable;
|
o->mode = Addressing_Variable;
|
||||||
} else if (o->mode != Addressing_Variable) {
|
} else if (o->mode != Addressing_Variable &&
|
||||||
|
o->mode != Addressing_Constant) {
|
||||||
o->mode = Addressing_Value;
|
o->mode = Addressing_Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4139,7 +4140,9 @@ bool check_set_index_data(Operand *o, Type *type, bool indirection, i64 *max_cou
|
|||||||
|
|
||||||
case Type_Slice:
|
case Type_Slice:
|
||||||
o->type = t->Slice.elem;
|
o->type = t->Slice.elem;
|
||||||
o->mode = Addressing_Variable;
|
if (o->mode != Addressing_Immutable) {
|
||||||
|
o->mode = Addressing_Variable;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Type_DynamicArray:
|
case Type_DynamicArray:
|
||||||
@@ -5132,7 +5135,9 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
o->mode = Addressing_Value;
|
if (o->mode != Addressing_Immutable) {
|
||||||
|
o->mode = Addressing_Value;
|
||||||
|
}
|
||||||
|
|
||||||
i64 indices[2] = {0};
|
i64 indices[2] = {0};
|
||||||
AstNode *nodes[2] = {se->low, se->high};
|
AstNode *nodes[2] = {se->low, se->high};
|
||||||
|
|||||||
+38
-30
@@ -6,22 +6,6 @@ typedef enum ExprKind {
|
|||||||
Expr_Stmt,
|
Expr_Stmt,
|
||||||
} ExprKind;
|
} ExprKind;
|
||||||
|
|
||||||
typedef enum AddressingMode {
|
|
||||||
Addressing_Invalid,
|
|
||||||
|
|
||||||
Addressing_NoValue,
|
|
||||||
Addressing_Value,
|
|
||||||
Addressing_Variable,
|
|
||||||
Addressing_Immutable,
|
|
||||||
Addressing_Constant,
|
|
||||||
Addressing_Type,
|
|
||||||
Addressing_Builtin,
|
|
||||||
Addressing_Overload,
|
|
||||||
Addressing_MapIndex,
|
|
||||||
|
|
||||||
Addressing_Count,
|
|
||||||
} AddressingMode;
|
|
||||||
|
|
||||||
// Statements and Declarations
|
// Statements and Declarations
|
||||||
typedef enum StmtFlag {
|
typedef enum StmtFlag {
|
||||||
Stmt_BreakAllowed = 1<<0,
|
Stmt_BreakAllowed = 1<<0,
|
||||||
@@ -124,11 +108,26 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = {
|
|||||||
|
|
||||||
#include "types.c"
|
#include "types.c"
|
||||||
|
|
||||||
#define MAP_TYPE Entity *
|
typedef enum AddressingMode {
|
||||||
#define MAP_PROC map_entity_
|
Addressing_Invalid, // invalid addressing mode
|
||||||
#define MAP_NAME MapEntity
|
Addressing_NoValue, // no value (void in C)
|
||||||
#include "map.c"
|
Addressing_Value, // computed value (rvalue)
|
||||||
|
Addressing_Immutable, // immutable computed value (const rvalue)
|
||||||
|
Addressing_Variable, // addressable variable (lvalue)
|
||||||
|
Addressing_Constant, // constant & type will be a of Type_Basic (stripping Type_Named)
|
||||||
|
Addressing_Type, // type
|
||||||
|
Addressing_Builtin, // built in procedure
|
||||||
|
Addressing_Overload, // overloaded procedure
|
||||||
|
Addressing_MapIndex, // map index expression
|
||||||
|
// lhs: acts like a Variable
|
||||||
|
// ths: acts like a value with an optional boolean part (for existence check)
|
||||||
|
} AddressingMode;
|
||||||
|
|
||||||
|
// Operand is used as an intermediate value whilst checking
|
||||||
|
// Operands store an addressing mode, the expression being evaluated,
|
||||||
|
// its type and node, and other specific information for certain
|
||||||
|
// addressing modes
|
||||||
|
// Its zero-value is a valid "invalid operand"
|
||||||
typedef struct Operand {
|
typedef struct Operand {
|
||||||
AddressingMode mode;
|
AddressingMode mode;
|
||||||
Type * type;
|
Type * type;
|
||||||
@@ -161,7 +160,7 @@ bool is_operand_nil(Operand o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DeclInfo is used to store information of certain declarations to allow for "any order" usage
|
||||||
typedef struct DeclInfo {
|
typedef struct DeclInfo {
|
||||||
Scope *scope;
|
Scope *scope;
|
||||||
|
|
||||||
@@ -175,6 +174,17 @@ typedef struct DeclInfo {
|
|||||||
MapBool deps; // Key: Entity *
|
MapBool deps; // Key: Entity *
|
||||||
} DeclInfo;
|
} DeclInfo;
|
||||||
|
|
||||||
|
// ProcedureInfo stores the information needed for checking a procedure
|
||||||
|
typedef struct ProcedureInfo {
|
||||||
|
AstFile * file;
|
||||||
|
Token token;
|
||||||
|
DeclInfo *decl;
|
||||||
|
Type * type; // Type_Procedure
|
||||||
|
AstNode * body; // AstNode_BlockStmt
|
||||||
|
u32 tags;
|
||||||
|
} ProcedureInfo;
|
||||||
|
|
||||||
|
// ExprInfo stores information used for "untyped" expressions
|
||||||
typedef struct ExprInfo {
|
typedef struct ExprInfo {
|
||||||
bool is_lhs; // Debug info
|
bool is_lhs; // Debug info
|
||||||
AddressingMode mode;
|
AddressingMode mode;
|
||||||
@@ -187,14 +197,12 @@ ExprInfo make_expr_info(bool is_lhs, AddressingMode mode, Type *type, ExactValue
|
|||||||
return ei;
|
return ei;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct ProcedureInfo {
|
|
||||||
AstFile * file;
|
|
||||||
Token token;
|
#define MAP_TYPE Entity *
|
||||||
DeclInfo *decl;
|
#define MAP_PROC map_entity_
|
||||||
Type * type; // Type_Procedure
|
#define MAP_NAME MapEntity
|
||||||
AstNode * body; // AstNode_BlockStmt
|
#include "map.c"
|
||||||
u32 tags;
|
|
||||||
} ProcedureInfo;
|
|
||||||
|
|
||||||
typedef struct Scope {
|
typedef struct Scope {
|
||||||
Scope * parent;
|
Scope * parent;
|
||||||
@@ -258,7 +266,7 @@ typedef struct CheckerContext {
|
|||||||
Type * type_hint;
|
Type * type_hint;
|
||||||
} CheckerContext;
|
} CheckerContext;
|
||||||
|
|
||||||
// NOTE(bill): Symbol tables
|
// CheckerInfo stores all the symbol information for a type-checked program
|
||||||
typedef struct CheckerInfo {
|
typedef struct CheckerInfo {
|
||||||
MapTypeAndValue types; // Key: AstNode * | Expression -> Type (and value)
|
MapTypeAndValue types; // Key: AstNode * | Expression -> Type (and value)
|
||||||
MapEntity definitions; // Key: AstNode * | Identifier -> Entity
|
MapEntity definitions; // Key: AstNode * | Identifier -> Entity
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ i16 f32_to_f16(f32 value) {
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef Array(i32) Array_i32;
|
||||||
|
typedef Array(isize) Array_isize;
|
||||||
|
|
||||||
|
|
||||||
#define MAP_TYPE String
|
#define MAP_TYPE String
|
||||||
#define MAP_PROC map_string_
|
#define MAP_PROC map_string_
|
||||||
|
|||||||
+6
-3
@@ -40,12 +40,15 @@ typedef enum EntityFlag {
|
|||||||
EntityFlag_TypeField = 1<<8,
|
EntityFlag_TypeField = 1<<8,
|
||||||
} EntityFlag;
|
} EntityFlag;
|
||||||
|
|
||||||
|
// Zero value means the overloading process is not yet done
|
||||||
typedef enum OverloadKind {
|
typedef enum OverloadKind {
|
||||||
Overload_No = -1,
|
Overload_Unknown,
|
||||||
Overload_Unknown = 0,
|
Overload_No,
|
||||||
Overload_Yes = +1,
|
Overload_Yes,
|
||||||
} OverloadKind;
|
} OverloadKind;
|
||||||
|
|
||||||
|
|
||||||
|
// An Entity is a named "thing" in the language
|
||||||
typedef struct Entity Entity;
|
typedef struct Entity Entity;
|
||||||
struct Entity {
|
struct Entity {
|
||||||
EntityKind kind;
|
EntityKind kind;
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
#define MAP_NAME MapString
|
#define MAP_NAME MapString
|
||||||
#include "map.c"
|
#include "map.c"
|
||||||
*/
|
*/
|
||||||
|
// A `Map` is an unordered hash table which can allow for a key to point to multiple values
|
||||||
|
// with the use of the `multi_*` procedures.
|
||||||
|
// TODO(bill): I should probably allow the `multi_*` stuff to be #ifdefed out
|
||||||
|
|
||||||
#ifndef MAP_UTIL_STUFF
|
#ifndef MAP_UTIL_STUFF
|
||||||
#define MAP_UTIL_STUFF
|
#define MAP_UTIL_STUFF
|
||||||
|
|||||||
+3
-1
@@ -111,7 +111,9 @@ AstNodeArray make_ast_node_array(AstFile *f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE(bill): This massive define is so it is possible to create a discriminated union (and extra debug info)
|
||||||
|
// for the AstNode. I personally prefer discriminated unions over subtype polymorphism as I can preallocate
|
||||||
|
// all the nodes and even memcpy in a different kind of node
|
||||||
#define AST_NODE_KINDS \
|
#define AST_NODE_KINDS \
|
||||||
AST_NODE_KIND(Ident, "identifier", Token) \
|
AST_NODE_KIND(Ident, "identifier", Token) \
|
||||||
AST_NODE_KIND(Implicit, "implicit", Token) \
|
AST_NODE_KIND(Implicit, "implicit", Token) \
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ typedef struct String {
|
|||||||
#define str_lit(c_str) (String){cast(u8 *)c_str, gb_size_of(c_str)-1}
|
#define str_lit(c_str) (String){cast(u8 *)c_str, gb_size_of(c_str)-1}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE(bill): String16 is only used for Windows due to its file directories
|
||||||
typedef struct String16 {
|
typedef struct String16 {
|
||||||
wchar_t *text;
|
wchar_t *text;
|
||||||
isize len;
|
isize len;
|
||||||
|
|||||||
+9
-8
@@ -178,8 +178,9 @@ typedef struct Type {
|
|||||||
bool failure;
|
bool failure;
|
||||||
} Type;
|
} Type;
|
||||||
|
|
||||||
typedef Array(i32) Array_i32;
|
|
||||||
|
|
||||||
|
// TODO(bill): Should I add extra information here specifying the kind of selection?
|
||||||
|
// e.g. field, constant, vector field, type field, etc.
|
||||||
typedef struct Selection {
|
typedef struct Selection {
|
||||||
Entity * entity;
|
Entity * entity;
|
||||||
Array_i32 index;
|
Array_i32 index;
|
||||||
@@ -195,6 +196,7 @@ Selection make_selection(Entity *entity, Array_i32 index, bool indirect) {
|
|||||||
void selection_add_index(Selection *s, isize index) {
|
void selection_add_index(Selection *s, isize index) {
|
||||||
// IMPORTANT NOTE(bill): this requires a stretchy buffer/dynamic array so it requires some form
|
// IMPORTANT NOTE(bill): this requires a stretchy buffer/dynamic array so it requires some form
|
||||||
// of heap allocation
|
// of heap allocation
|
||||||
|
// TODO(bill): Find a way to use a backing buffer for initial use as the general case is probably .count<3
|
||||||
if (s->index.e == NULL) {
|
if (s->index.e == NULL) {
|
||||||
array_init(&s->index, heap_allocator());
|
array_init(&s->index, heap_allocator());
|
||||||
}
|
}
|
||||||
@@ -277,6 +279,7 @@ gb_global Type *t_byte_slice = NULL;
|
|||||||
gb_global Type *t_string_slice = NULL;
|
gb_global Type *t_string_slice = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
// Type generated for the "preload" file
|
||||||
gb_global Type *t_type_info = NULL;
|
gb_global Type *t_type_info = NULL;
|
||||||
gb_global Type *t_type_info_record = NULL;
|
gb_global Type *t_type_info_record = NULL;
|
||||||
gb_global Type *t_type_info_enum_value = NULL;
|
gb_global Type *t_type_info_enum_value = NULL;
|
||||||
@@ -303,7 +306,6 @@ gb_global Type *t_type_info_raw_union = NULL;
|
|||||||
gb_global Type *t_type_info_enum = NULL;
|
gb_global Type *t_type_info_enum = NULL;
|
||||||
gb_global Type *t_type_info_map = NULL;
|
gb_global Type *t_type_info_map = NULL;
|
||||||
|
|
||||||
|
|
||||||
gb_global Type *t_type_info_named_ptr = NULL;
|
gb_global Type *t_type_info_named_ptr = NULL;
|
||||||
gb_global Type *t_type_info_integer_ptr = NULL;
|
gb_global Type *t_type_info_integer_ptr = NULL;
|
||||||
gb_global Type *t_type_info_float_ptr = NULL;
|
gb_global Type *t_type_info_float_ptr = NULL;
|
||||||
@@ -323,8 +325,6 @@ gb_global Type *t_type_info_raw_union_ptr = NULL;
|
|||||||
gb_global Type *t_type_info_enum_ptr = NULL;
|
gb_global Type *t_type_info_enum_ptr = NULL;
|
||||||
gb_global Type *t_type_info_map_ptr = NULL;
|
gb_global Type *t_type_info_map_ptr = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gb_global Type *t_allocator = NULL;
|
gb_global Type *t_allocator = NULL;
|
||||||
gb_global Type *t_allocator_ptr = NULL;
|
gb_global Type *t_allocator_ptr = NULL;
|
||||||
gb_global Type *t_context = NULL;
|
gb_global Type *t_context = NULL;
|
||||||
@@ -337,14 +337,15 @@ gb_global Type *t_map_header = NULL;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
i64 type_size_of (gbAllocator allocator, Type *t);
|
|
||||||
i64 type_align_of (gbAllocator allocator, Type *t);
|
|
||||||
i64 type_offset_of(gbAllocator allocator, Type *t, i32 index);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i64 type_size_of (gbAllocator allocator, Type *t);
|
||||||
|
i64 type_align_of (gbAllocator allocator, Type *t);
|
||||||
|
i64 type_offset_of (gbAllocator allocator, Type *t, i32 index);
|
||||||
gbString type_to_string(Type *type);
|
gbString type_to_string(Type *type);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Type *base_type(Type *t) {
|
Type *base_type(Type *t) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (t == NULL) {
|
if (t == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user