mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 11:20:08 +00:00
Merge branch 'odin-lang:master' into haiku
This commit is contained in:
@@ -63,11 +63,13 @@ jobs:
|
|||||||
cp -r core dist
|
cp -r core dist
|
||||||
cp -r vendor dist
|
cp -r vendor dist
|
||||||
cp -r examples dist
|
cp -r examples dist
|
||||||
|
# Zipping so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
|
||||||
|
zip -r dist.zip dist
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: ubuntu_artifacts
|
name: ubuntu_artifacts
|
||||||
path: dist
|
path: dist.zip
|
||||||
build_macos:
|
build_macos:
|
||||||
name: MacOS Build
|
name: MacOS Build
|
||||||
if: github.repository == 'odin-lang/Odin'
|
if: github.repository == 'odin-lang/Odin'
|
||||||
@@ -76,15 +78,13 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Download LLVM and setup PATH
|
- name: Download LLVM and setup PATH
|
||||||
run: |
|
run: |
|
||||||
brew install llvm@13
|
brew install llvm@13 dylibbundler
|
||||||
echo "/usr/local/opt/llvm@13/bin" >> $GITHUB_PATH
|
echo "/usr/local/opt/llvm@13/bin" >> $GITHUB_PATH
|
||||||
TMP_PATH=$(xcrun --show-sdk-path)/user/include
|
TMP_PATH=$(xcrun --show-sdk-path)/user/include
|
||||||
echo "CPATH=$TMP_PATH" >> $GITHUB_ENV
|
echo "CPATH=$TMP_PATH" >> $GITHUB_ENV
|
||||||
- name: build odin
|
- name: build odin
|
||||||
run: make nightly
|
run: make nightly
|
||||||
- name: Odin run
|
- name: Bundle
|
||||||
run: ./odin run examples/demo
|
|
||||||
- name: Copy artifacts
|
|
||||||
run: |
|
run: |
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cp odin dist
|
cp odin dist
|
||||||
@@ -94,11 +94,16 @@ jobs:
|
|||||||
cp -r core dist
|
cp -r core dist
|
||||||
cp -r vendor dist
|
cp -r vendor dist
|
||||||
cp -r examples dist
|
cp -r examples dist
|
||||||
|
dylibbundler -b -x dist/odin -d dist/libs -od -p @executable_path/libs
|
||||||
|
# Zipping so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
|
||||||
|
zip -r dist.zip dist
|
||||||
|
- name: Odin run
|
||||||
|
run: ./dist/odin run examples/demo
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: macos_artifacts
|
name: macos_artifacts
|
||||||
path: dist
|
path: dist.zip
|
||||||
build_macos_arm:
|
build_macos_arm:
|
||||||
name: MacOS ARM Build
|
name: MacOS ARM Build
|
||||||
if: github.repository == 'odin-lang/Odin'
|
if: github.repository == 'odin-lang/Odin'
|
||||||
@@ -107,15 +112,13 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Download LLVM and setup PATH
|
- name: Download LLVM and setup PATH
|
||||||
run: |
|
run: |
|
||||||
brew install llvm@13
|
brew install llvm@13 dylibbundler
|
||||||
echo "/opt/homebrew/opt/llvm@13/bin" >> $GITHUB_PATH
|
echo "/opt/homebrew/opt/llvm@13/bin" >> $GITHUB_PATH
|
||||||
TMP_PATH=$(xcrun --show-sdk-path)/user/include
|
TMP_PATH=$(xcrun --show-sdk-path)/user/include
|
||||||
echo "CPATH=$TMP_PATH" >> $GITHUB_ENV
|
echo "CPATH=$TMP_PATH" >> $GITHUB_ENV
|
||||||
- name: build odin
|
- name: build odin
|
||||||
run: make nightly
|
run: make nightly
|
||||||
- name: Odin run
|
- name: Bundle
|
||||||
run: ./odin run examples/demo
|
|
||||||
- name: Copy artifacts
|
|
||||||
run: |
|
run: |
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cp odin dist
|
cp odin dist
|
||||||
@@ -125,11 +128,16 @@ jobs:
|
|||||||
cp -r core dist
|
cp -r core dist
|
||||||
cp -r vendor dist
|
cp -r vendor dist
|
||||||
cp -r examples dist
|
cp -r examples dist
|
||||||
|
dylibbundler -b -x dist/odin -d dist/libs -od -p @executable_path/libs
|
||||||
|
# Zipping so executable permissions are retained, see https://github.com/actions/upload-artifact/issues/38
|
||||||
|
zip -r dist.zip dist
|
||||||
|
- name: Odin run
|
||||||
|
run: ./dist/odin run examples/demo
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: macos_arm_artifacts
|
name: macos_arm_artifacts
|
||||||
path: dist
|
path: dist.zip
|
||||||
upload_b2:
|
upload_b2:
|
||||||
runs-on: [ubuntu-latest]
|
runs-on: [ubuntu-latest]
|
||||||
needs: [build_windows, build_macos, build_macos_arm, build_ubuntu]
|
needs: [build_windows, build_macos, build_macos_arm, build_ubuntu]
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ Typeid_Kind :: enum u8 {
|
|||||||
|
|
||||||
// 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
|
||||||
type_table: []Type_Info
|
type_table: []^Type_Info
|
||||||
|
|
||||||
args__: []cstring
|
args__: []cstring
|
||||||
|
|
||||||
@@ -609,7 +609,7 @@ __type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info #no_bounds_check
|
|||||||
if n < 0 || n >= len(type_table) {
|
if n < 0 || n >= len(type_table) {
|
||||||
n = 0
|
n = 0
|
||||||
}
|
}
|
||||||
return &type_table[n]
|
return type_table[n]
|
||||||
}
|
}
|
||||||
|
|
||||||
when !ODIN_NO_RTTI {
|
when !ODIN_NO_RTTI {
|
||||||
|
|||||||
+2
-5
@@ -1,7 +1,6 @@
|
|||||||
package os
|
package os
|
||||||
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
import "core:mem"
|
|
||||||
import "core:strconv"
|
import "core:strconv"
|
||||||
import "core:unicode/utf8"
|
import "core:unicode/utf8"
|
||||||
|
|
||||||
@@ -160,13 +159,11 @@ write_entire_file :: proc(name: string, data: []byte, truncate := true) -> (succ
|
|||||||
}
|
}
|
||||||
|
|
||||||
write_ptr :: proc(fd: Handle, data: rawptr, len: int) -> (int, Errno) {
|
write_ptr :: proc(fd: Handle, data: rawptr, len: int) -> (int, Errno) {
|
||||||
s := transmute([]byte)mem.Raw_Slice{data, len}
|
return write(fd, ([^]byte)(data)[:len])
|
||||||
return write(fd, s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
read_ptr :: proc(fd: Handle, data: rawptr, len: int) -> (int, Errno) {
|
read_ptr :: proc(fd: Handle, data: rawptr, len: int) -> (int, Errno) {
|
||||||
s := transmute([]byte)mem.Raw_Slice{data, len}
|
return read(fd, ([^]byte)(data)[:len])
|
||||||
return read(fd, s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
heap_allocator_proc :: runtime.heap_allocator_proc
|
heap_allocator_proc :: runtime.heap_allocator_proc
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package os2
|
package os2
|
||||||
|
|
||||||
import "core:mem"
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
import "core:strconv"
|
import "core:strconv"
|
||||||
import "core:unicode/utf8"
|
import "core:unicode/utf8"
|
||||||
@@ -64,13 +63,11 @@ write_encoded_rune :: proc(f: ^File, r: rune) -> (n: int, err: Error) {
|
|||||||
|
|
||||||
|
|
||||||
write_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) {
|
write_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) {
|
||||||
s := transmute([]byte)mem.Raw_Slice{data, len}
|
return write(f, ([^]byte)(data)[:len])
|
||||||
return write(f, s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
read_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) {
|
read_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) {
|
||||||
s := transmute([]byte)mem.Raw_Slice{data, len}
|
return read(f, ([^]byte)(data)[:len])
|
||||||
return read(f, s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-54
@@ -1053,41 +1053,6 @@ struct lbGlobalVariable {
|
|||||||
bool is_initialized;
|
bool is_initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
gb_internal lbProcedure *lb_create_startup_type_info(lbModule *m) {
|
|
||||||
if (build_context.no_rtti) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_CDecl);
|
|
||||||
|
|
||||||
lbProcedure *p = lb_create_dummy_procedure(m, str_lit(LB_STARTUP_TYPE_INFO_PROC_NAME), proc_type);
|
|
||||||
p->is_startup = true;
|
|
||||||
LLVMSetLinkage(p->value, LLVMInternalLinkage);
|
|
||||||
|
|
||||||
lb_add_attribute_to_proc(m, p->value, "nounwind");
|
|
||||||
// lb_add_attribute_to_proc(p->module, p->value, "mustprogress");
|
|
||||||
// lb_add_attribute_to_proc(p->module, p->value, "nofree");
|
|
||||||
// lb_add_attribute_to_proc(p->module, p->value, "norecurse");
|
|
||||||
// lb_add_attribute_to_proc(p->module, p->value, "nosync");
|
|
||||||
// lb_add_attribute_to_proc(p->module, p->value, "willreturn");
|
|
||||||
if (!LB_USE_GIANT_PACKED_STRUCT) {
|
|
||||||
lb_add_attribute_to_proc(m, p->value, "optnone");
|
|
||||||
lb_add_attribute_to_proc(m, p->value, "noinline");
|
|
||||||
}
|
|
||||||
|
|
||||||
lb_begin_procedure_body(p);
|
|
||||||
|
|
||||||
lb_setup_type_info_data(p);
|
|
||||||
|
|
||||||
lb_end_procedure_body(p);
|
|
||||||
|
|
||||||
if (!m->debug_builder && LLVMVerifyFunction(p->value, LLVMReturnStatusAction)) {
|
|
||||||
gb_printf_err("LLVM CODE GEN FAILED FOR PROCEDURE: %s\n", "main");
|
|
||||||
LLVMDumpValue(p->value);
|
|
||||||
gb_printf_err("\n\n\n\n");
|
|
||||||
LLVMVerifyFunction(p->value, LLVMAbortProcessAction);
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
gb_internal lbProcedure *lb_create_objc_names(lbModule *main_module) {
|
gb_internal lbProcedure *lb_create_objc_names(lbModule *main_module) {
|
||||||
if (build_context.metrics.os != TargetOs_darwin) {
|
if (build_context.metrics.os != TargetOs_darwin) {
|
||||||
@@ -1129,7 +1094,7 @@ gb_internal void lb_finalize_objc_names(lbProcedure *p) {
|
|||||||
lb_end_procedure_body(p);
|
lb_end_procedure_body(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *startup_type_info, lbProcedure *objc_names, Array<lbGlobalVariable> &global_variables) { // Startup Runtime
|
gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *objc_names, Array<lbGlobalVariable> &global_variables) { // Startup Runtime
|
||||||
Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_Odin);
|
Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_Odin);
|
||||||
|
|
||||||
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_STARTUP_RUNTIME_PROC_NAME), proc_type);
|
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_STARTUP_RUNTIME_PROC_NAME), proc_type);
|
||||||
@@ -1139,9 +1104,7 @@ gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProc
|
|||||||
|
|
||||||
lb_begin_procedure_body(p);
|
lb_begin_procedure_body(p);
|
||||||
|
|
||||||
if (startup_type_info) {
|
lb_setup_type_info_data(main_module);
|
||||||
LLVMBuildCall2(p->builder, lb_type_internal_for_procedures_raw(main_module, startup_type_info->type), startup_type_info->value, nullptr, 0, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objc_names) {
|
if (objc_names) {
|
||||||
LLVMBuildCall2(p->builder, lb_type_internal_for_procedures_raw(main_module, objc_names->type), objc_names->value, nullptr, 0, "");
|
LLVMBuildCall2(p->builder, lb_type_internal_for_procedures_raw(main_module, objc_names->type), objc_names->value, nullptr, 0, "");
|
||||||
@@ -1201,7 +1164,7 @@ gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProc
|
|||||||
lbValue data = lb_emit_struct_ep(p, var.var, 0);
|
lbValue data = lb_emit_struct_ep(p, var.var, 0);
|
||||||
lbValue ti = lb_emit_struct_ep(p, var.var, 1);
|
lbValue ti = lb_emit_struct_ep(p, var.var, 1);
|
||||||
lb_emit_store(p, data, lb_emit_conv(p, gp, t_rawptr));
|
lb_emit_store(p, data, lb_emit_conv(p, gp, t_rawptr));
|
||||||
lb_emit_store(p, ti, lb_type_info(main_module, var_type));
|
lb_emit_store(p, ti, lb_type_info(p, var_type));
|
||||||
} else {
|
} else {
|
||||||
LLVMTypeRef vt = llvm_addr_type(p->module, var.var);
|
LLVMTypeRef vt = llvm_addr_type(p->module, var.var);
|
||||||
lbValue src0 = lb_emit_conv(p, var.init, t);
|
lbValue src0 = lb_emit_conv(p, var.init, t);
|
||||||
@@ -1426,7 +1389,6 @@ gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m == &m->gen->default_module) {
|
if (m == &m->gen->default_module) {
|
||||||
lb_llvm_function_pass_per_function_internal(m, m->gen->startup_type_info);
|
|
||||||
lb_llvm_function_pass_per_function_internal(m, m->gen->startup_runtime);
|
lb_llvm_function_pass_per_function_internal(m, m->gen->startup_runtime);
|
||||||
lb_llvm_function_pass_per_function_internal(m, m->gen->cleanup_runtime);
|
lb_llvm_function_pass_per_function_internal(m, m->gen->cleanup_runtime);
|
||||||
lb_llvm_function_pass_per_function_internal(m, m->gen->objc_names);
|
lb_llvm_function_pass_per_function_internal(m, m->gen->objc_names);
|
||||||
@@ -2691,17 +2653,19 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
|
|
||||||
{ // Add type info data
|
{ // Add type info data
|
||||||
isize max_type_info_count = info->minimum_dependency_type_info_set.count+1;
|
isize max_type_info_count = info->minimum_dependency_type_info_set.count+1;
|
||||||
Type *t = alloc_type_array(t_type_info, max_type_info_count);
|
Type *t = alloc_type_array(t_type_info_ptr, max_type_info_count);
|
||||||
|
|
||||||
// IMPORTANT NOTE(bill): As LLVM does not have a union type, an array of unions cannot be initialized
|
// IMPORTANT NOTE(bill): As LLVM does not have a union type, an array of unions cannot be initialized
|
||||||
// at compile time without cheating in some way. This means to emulate an array of unions is to use
|
// at compile time without cheating in some way. This means to emulate an array of unions is to use
|
||||||
// a giant packed struct of "corrected" data types.
|
// a giant packed struct of "corrected" data types.
|
||||||
|
|
||||||
LLVMTypeRef internal_llvm_type = lb_setup_type_info_data_internal_type(m, max_type_info_count);
|
LLVMTypeRef internal_llvm_type = lb_type(m, t);
|
||||||
|
|
||||||
LLVMValueRef g = LLVMAddGlobal(m->mod, internal_llvm_type, LB_TYPE_INFO_DATA_NAME);
|
LLVMValueRef g = LLVMAddGlobal(m->mod, internal_llvm_type, LB_TYPE_INFO_DATA_NAME);
|
||||||
LLVMSetInitializer(g, LLVMConstNull(internal_llvm_type));
|
LLVMSetInitializer(g, LLVMConstNull(internal_llvm_type));
|
||||||
LLVMSetLinkage(g, USE_SEPARATE_MODULES ? LLVMExternalLinkage : LLVMInternalLinkage);
|
LLVMSetLinkage(g, USE_SEPARATE_MODULES ? LLVMExternalLinkage : LLVMInternalLinkage);
|
||||||
|
LLVMSetUnnamedAddress(g, LLVMGlobalUnnamedAddr);
|
||||||
|
LLVMSetGlobalConstant(g, /*true*/false);
|
||||||
|
|
||||||
lbValue value = {};
|
lbValue value = {};
|
||||||
value.value = g;
|
value.value = g;
|
||||||
@@ -2710,11 +2674,6 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
lb_global_type_info_data_entity = alloc_entity_variable(nullptr, make_token_ident(LB_TYPE_INFO_DATA_NAME), t, EntityState_Resolved);
|
lb_global_type_info_data_entity = alloc_entity_variable(nullptr, make_token_ident(LB_TYPE_INFO_DATA_NAME), t, EntityState_Resolved);
|
||||||
lb_add_entity(m, lb_global_type_info_data_entity, value);
|
lb_add_entity(m, lb_global_type_info_data_entity, value);
|
||||||
|
|
||||||
if (LB_USE_GIANT_PACKED_STRUCT) {
|
|
||||||
LLVMSetLinkage(g, LLVMPrivateLinkage);
|
|
||||||
LLVMSetUnnamedAddress(g, LLVMGlobalUnnamedAddr);
|
|
||||||
LLVMSetGlobalConstant(g, /*true*/false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{ // Type info member buffer
|
{ // Type info member buffer
|
||||||
// NOTE(bill): Removes need for heap allocation by making it global memory
|
// NOTE(bill): Removes need for heap allocation by making it global memory
|
||||||
@@ -2750,9 +2709,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
|
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
|
||||||
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
|
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
|
||||||
LLVMSetLinkage(g, LLVMInternalLinkage);
|
LLVMSetLinkage(g, LLVMInternalLinkage);
|
||||||
if (LB_USE_GIANT_PACKED_STRUCT) {
|
lb_make_global_private_const(g);
|
||||||
lb_make_global_private_const(g);
|
|
||||||
}
|
|
||||||
return lb_addr({g, alloc_type_pointer(t)});
|
return lb_addr({g, alloc_type_pointer(t)});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2921,12 +2878,11 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_SECTION("LLVM Runtime Type Information Creation");
|
TIME_SECTION("LLVM Runtime Objective-C Names Creation");
|
||||||
gen->startup_type_info = lb_create_startup_type_info(default_module);
|
|
||||||
gen->objc_names = lb_create_objc_names(default_module);
|
gen->objc_names = lb_create_objc_names(default_module);
|
||||||
|
|
||||||
TIME_SECTION("LLVM Runtime Startup Creation (Global Variables & @(init))");
|
TIME_SECTION("LLVM Runtime Startup Creation (Global Variables & @(init))");
|
||||||
gen->startup_runtime = lb_create_startup_runtime(default_module, gen->startup_type_info, gen->objc_names, global_variables);
|
gen->startup_runtime = lb_create_startup_runtime(default_module, gen->objc_names, global_variables);
|
||||||
|
|
||||||
TIME_SECTION("LLVM Runtime Cleanup Creation & @(fini)");
|
TIME_SECTION("LLVM Runtime Cleanup Creation & @(fini)");
|
||||||
gen->cleanup_runtime = lb_create_cleanup_runtime(default_module);
|
gen->cleanup_runtime = lb_create_cleanup_runtime(default_module);
|
||||||
|
|||||||
@@ -225,7 +225,6 @@ struct lbGenerator : LinkerData {
|
|||||||
std::atomic<u32> global_array_index;
|
std::atomic<u32> global_array_index;
|
||||||
std::atomic<u32> global_generated_index;
|
std::atomic<u32> global_generated_index;
|
||||||
|
|
||||||
lbProcedure *startup_type_info;
|
|
||||||
lbProcedure *startup_runtime;
|
lbProcedure *startup_runtime;
|
||||||
lbProcedure *cleanup_runtime;
|
lbProcedure *cleanup_runtime;
|
||||||
lbProcedure *objc_names;
|
lbProcedure *objc_names;
|
||||||
@@ -486,7 +485,7 @@ gb_internal lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValu
|
|||||||
|
|
||||||
gb_internal void lb_fill_slice(lbProcedure *p, lbAddr const &slice, lbValue base_elem, lbValue len);
|
gb_internal void lb_fill_slice(lbProcedure *p, lbAddr const &slice, lbValue base_elem, lbValue len);
|
||||||
|
|
||||||
gb_internal lbValue lb_type_info(lbModule *m, Type *type);
|
gb_internal lbValue lb_type_info(lbProcedure *p, Type *type);
|
||||||
|
|
||||||
gb_internal lbValue lb_find_or_add_entity_string(lbModule *m, String const &str);
|
gb_internal lbValue lb_find_or_add_entity_string(lbModule *m, String const &str);
|
||||||
gb_internal lbValue lb_generate_anonymous_proc_lit(lbModule *m, String const &prefix_name, Ast *expr, lbProcedure *parent = nullptr);
|
gb_internal lbValue lb_generate_anonymous_proc_lit(lbModule *m, String const &prefix_name, Ast *expr, lbProcedure *parent = nullptr);
|
||||||
@@ -587,7 +586,6 @@ gb_internal LLVMTypeRef llvm_array_type(LLVMTypeRef ElementType, uint64_t Elemen
|
|||||||
|
|
||||||
#define LB_STARTUP_RUNTIME_PROC_NAME "__$startup_runtime"
|
#define LB_STARTUP_RUNTIME_PROC_NAME "__$startup_runtime"
|
||||||
#define LB_CLEANUP_RUNTIME_PROC_NAME "__$cleanup_runtime"
|
#define LB_CLEANUP_RUNTIME_PROC_NAME "__$cleanup_runtime"
|
||||||
#define LB_STARTUP_TYPE_INFO_PROC_NAME "__$startup_type_info"
|
|
||||||
#define LB_TYPE_INFO_DATA_NAME "__$type_info_data"
|
#define LB_TYPE_INFO_DATA_NAME "__$type_info_data"
|
||||||
#define LB_TYPE_INFO_TYPES_NAME "__$type_info_types_data"
|
#define LB_TYPE_INFO_TYPES_NAME "__$type_info_types_data"
|
||||||
#define LB_TYPE_INFO_NAMES_NAME "__$type_info_names_data"
|
#define LB_TYPE_INFO_NAMES_NAME "__$type_info_names_data"
|
||||||
|
|||||||
@@ -1755,7 +1755,7 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
|
|||||||
TypeAndValue tav = type_and_value_of_expr(arg);
|
TypeAndValue tav = type_and_value_of_expr(arg);
|
||||||
if (tav.mode == Addressing_Type) {
|
if (tav.mode == Addressing_Type) {
|
||||||
Type *t = default_type(type_of_expr(arg));
|
Type *t = default_type(type_of_expr(arg));
|
||||||
return lb_type_info(p->module, t);
|
return lb_type_info(p, t);
|
||||||
}
|
}
|
||||||
GB_ASSERT(is_type_typeid(tav.type));
|
GB_ASSERT(is_type_typeid(tav.type));
|
||||||
|
|
||||||
@@ -3361,9 +3361,9 @@ gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
|
|||||||
for (Ast *var_arg : variadic) {
|
for (Ast *var_arg : variadic) {
|
||||||
lbValue arg = lb_build_expr(p, var_arg);
|
lbValue arg = lb_build_expr(p, var_arg);
|
||||||
if (is_type_any(elem_type)) {
|
if (is_type_any(elem_type)) {
|
||||||
array_add(&args, lb_emit_conv(p, arg, default_type(arg.type)));
|
array_add(&args, lb_emit_conv(p, arg, c_vararg_promote_type(default_type(arg.type))));
|
||||||
} else {
|
} else {
|
||||||
array_add(&args, lb_emit_conv(p, arg, elem_type));
|
array_add(&args, lb_emit_conv(p, arg, c_vararg_promote_type(elem_type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -748,7 +748,7 @@ gb_internal void lb_build_range_enum(lbProcedure *p, Type *enum_type, Type *val_
|
|||||||
i64 enum_count = t->Enum.fields.count;
|
i64 enum_count = t->Enum.fields.count;
|
||||||
lbValue max_count = lb_const_int(m, t_int, enum_count);
|
lbValue max_count = lb_const_int(m, t_int, enum_count);
|
||||||
|
|
||||||
lbValue ti = lb_type_info(m, t);
|
lbValue ti = lb_type_info(p, t);
|
||||||
lbValue variant = lb_emit_struct_ep(p, ti, 4);
|
lbValue variant = lb_emit_struct_ep(p, ti, 4);
|
||||||
lbValue eti_ptr = lb_emit_conv(p, variant, t_type_info_enum_ptr);
|
lbValue eti_ptr = lb_emit_conv(p, variant, t_type_info_enum_ptr);
|
||||||
lbValue values = lb_emit_load(p, lb_emit_struct_ep(p, eti_ptr, 2));
|
lbValue values = lb_emit_load(p, lb_emit_struct_ep(p, eti_ptr, 2));
|
||||||
|
|||||||
+160
-908
File diff suppressed because it is too large
Load Diff
@@ -365,6 +365,9 @@ enum Typeid_Kind : u8 {
|
|||||||
Typeid_Matrix,
|
Typeid_Matrix,
|
||||||
Typeid_SoaPointer,
|
Typeid_SoaPointer,
|
||||||
Typeid_Bit_Field,
|
Typeid_Bit_Field,
|
||||||
|
|
||||||
|
Typeid__COUNT
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// IMPORTANT NOTE(bill): This must match the same as the in core.odin
|
// IMPORTANT NOTE(bill): This must match the same as the in core.odin
|
||||||
@@ -562,6 +565,14 @@ gb_global Type *t_f16 = &basic_types[Basic_f16];
|
|||||||
gb_global Type *t_f32 = &basic_types[Basic_f32];
|
gb_global Type *t_f32 = &basic_types[Basic_f32];
|
||||||
gb_global Type *t_f64 = &basic_types[Basic_f64];
|
gb_global Type *t_f64 = &basic_types[Basic_f64];
|
||||||
|
|
||||||
|
gb_global Type *t_f16be = &basic_types[Basic_f16be];
|
||||||
|
gb_global Type *t_f32be = &basic_types[Basic_f32be];
|
||||||
|
gb_global Type *t_f64be = &basic_types[Basic_f64be];
|
||||||
|
|
||||||
|
gb_global Type *t_f16le = &basic_types[Basic_f16le];
|
||||||
|
gb_global Type *t_f32le = &basic_types[Basic_f32le];
|
||||||
|
gb_global Type *t_f64le = &basic_types[Basic_f64le];
|
||||||
|
|
||||||
gb_global Type *t_complex32 = &basic_types[Basic_complex32];
|
gb_global Type *t_complex32 = &basic_types[Basic_complex32];
|
||||||
gb_global Type *t_complex64 = &basic_types[Basic_complex64];
|
gb_global Type *t_complex64 = &basic_types[Basic_complex64];
|
||||||
gb_global Type *t_complex128 = &basic_types[Basic_complex128];
|
gb_global Type *t_complex128 = &basic_types[Basic_complex128];
|
||||||
@@ -2819,6 +2830,49 @@ gb_internal Type *default_type(Type *type) {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://en.cppreference.com/w/c/language/conversion#Default_argument_promotions
|
||||||
|
gb_internal Type *c_vararg_promote_type(Type *type) {
|
||||||
|
GB_ASSERT(type != nullptr);
|
||||||
|
|
||||||
|
Type *core = core_type(type);
|
||||||
|
|
||||||
|
if (core->kind == Type_BitSet) {
|
||||||
|
core = core_type(bit_set_to_int(core));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (core->kind == Type_Basic) {
|
||||||
|
switch (core->Basic.kind) {
|
||||||
|
case Basic_f32:
|
||||||
|
case Basic_UntypedFloat:
|
||||||
|
return t_f64;
|
||||||
|
case Basic_f32le:
|
||||||
|
return t_f64le;
|
||||||
|
case Basic_f32be:
|
||||||
|
return t_f64be;
|
||||||
|
|
||||||
|
case Basic_UntypedBool:
|
||||||
|
case Basic_bool:
|
||||||
|
case Basic_b8:
|
||||||
|
case Basic_b16:
|
||||||
|
case Basic_i8:
|
||||||
|
case Basic_i16:
|
||||||
|
case Basic_u8:
|
||||||
|
case Basic_u16:
|
||||||
|
return t_i32;
|
||||||
|
|
||||||
|
case Basic_i16le:
|
||||||
|
case Basic_u16le:
|
||||||
|
return t_i32le;
|
||||||
|
|
||||||
|
case Basic_i16be:
|
||||||
|
case Basic_u16be:
|
||||||
|
return t_i32be;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
gb_internal bool union_variant_index_types_equal(Type *v, Type *vt) {
|
gb_internal bool union_variant_index_types_equal(Type *v, Type *vt) {
|
||||||
if (are_types_identical(v, vt)) {
|
if (are_types_identical(v, vt)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Vendored
+61
@@ -0,0 +1,61 @@
|
|||||||
|
//+build linux
|
||||||
|
package egl
|
||||||
|
|
||||||
|
NativeDisplayType :: distinct rawptr
|
||||||
|
NativeWindowType :: distinct rawptr
|
||||||
|
Display :: distinct rawptr
|
||||||
|
Surface :: distinct rawptr
|
||||||
|
Config :: distinct rawptr
|
||||||
|
Context :: distinct rawptr
|
||||||
|
|
||||||
|
NO_DISPLAY :: Display(uintptr(0))
|
||||||
|
NO_CONTEXT :: Context(uintptr(0))
|
||||||
|
NO_SURFACE :: Surface(uintptr(0))
|
||||||
|
|
||||||
|
CONTEXT_OPENGL_CORE_PROFILE_BIT :: 0x00000001
|
||||||
|
WINDOW_BIT :: 0x0004
|
||||||
|
OPENGL_BIT :: 0x0008
|
||||||
|
|
||||||
|
BLUE_SIZE :: 0x3022
|
||||||
|
GREEN_SIZE :: 0x3023
|
||||||
|
RED_SIZE :: 0x3024
|
||||||
|
DEPTH_SIZE :: 0x3025
|
||||||
|
STENCIL_SIZE :: 0x3026
|
||||||
|
|
||||||
|
SURFACE_TYPE :: 0x3033
|
||||||
|
NONE :: 0x3038
|
||||||
|
COLOR_BUFFER_TYPE :: 0x303F
|
||||||
|
RENDERABLE_TYPE :: 0x3040
|
||||||
|
CONFORMANT :: 0x3042
|
||||||
|
|
||||||
|
BACK_BUFFER :: 0x3084
|
||||||
|
RENDER_BUFFER :: 0x3086
|
||||||
|
GL_COLORSPACE_SRGB :: 0x3089
|
||||||
|
GL_COLORSPACE_LINEAR :: 0x308A
|
||||||
|
RGB_BUFFER :: 0x308E
|
||||||
|
GL_COLORSPACE :: 0x309D
|
||||||
|
|
||||||
|
CONTEXT_MAJOR_VERSION :: 0x3098
|
||||||
|
CONTEXT_MINOR_VERSION :: 0x30FB
|
||||||
|
CONTEXT_OPENGL_PROFILE_MASK :: 0x30FD
|
||||||
|
|
||||||
|
OPENGL_API :: 0x30A2
|
||||||
|
|
||||||
|
foreign import egl "system:EGL"
|
||||||
|
@(default_calling_convention="c", link_prefix="egl")
|
||||||
|
foreign egl {
|
||||||
|
GetDisplay :: proc(display: NativeDisplayType) -> Display ---
|
||||||
|
Initialize :: proc(display: Display, major: ^i32, minor: ^i32) -> i32 ---
|
||||||
|
BindAPI :: proc(api: u32) -> i32 ---
|
||||||
|
ChooseConfig :: proc(display: Display, attrib_list: ^i32, configs: ^Context, config_size: i32, num_config: ^i32) -> i32 ---
|
||||||
|
CreateWindowSurface :: proc(display: Display, config: Config, native_window: NativeWindowType, attrib_list: ^i32) -> Surface ---
|
||||||
|
CreateContext :: proc(display: Display, config: Config, share_context: Context, attrib_list: ^i32) -> Context ---
|
||||||
|
MakeCurrent :: proc(display: Display, draw: Surface, read: Surface, ctx: Context) -> i32 ---
|
||||||
|
SwapInterval :: proc(display: Display, interval: i32) -> i32 ---
|
||||||
|
SwapBuffers :: proc(display: Display, surface: Surface) -> i32 ---
|
||||||
|
GetProcAddress :: proc(name: cstring) -> rawptr ---
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_set_proc_address :: proc(p: rawptr, name: cstring) {
|
||||||
|
(^rawptr)(p)^ = GetProcAddress(name)
|
||||||
|
}
|
||||||
Vendored
+3
-2
@@ -149,8 +149,9 @@ WaitEvents :: glfw.WaitEvents
|
|||||||
WaitEventsTimeout :: glfw.WaitEventsTimeout
|
WaitEventsTimeout :: glfw.WaitEventsTimeout
|
||||||
PostEmptyEvent :: glfw.PostEmptyEvent
|
PostEmptyEvent :: glfw.PostEmptyEvent
|
||||||
|
|
||||||
GetInputMode :: glfw.GetInputMode
|
RawMouseMotionSupported :: glfw.RawMouseMotionSupported
|
||||||
SetInputMode :: glfw.SetInputMode
|
GetInputMode :: glfw.GetInputMode
|
||||||
|
SetInputMode :: glfw.SetInputMode
|
||||||
|
|
||||||
GetMouseButton :: glfw.GetMouseButton
|
GetMouseButton :: glfw.GetMouseButton
|
||||||
GetCursorPos :: proc "c" (window: WindowHandle) -> (xpos, ypos: f64) {
|
GetCursorPos :: proc "c" (window: WindowHandle) -> (xpos, ypos: f64) {
|
||||||
|
|||||||
Vendored
+6
-7
@@ -318,11 +318,11 @@ GlyphInfo :: struct {
|
|||||||
// Font type, includes texture and charSet array data
|
// Font type, includes texture and charSet array data
|
||||||
Font :: struct {
|
Font :: struct {
|
||||||
baseSize: c.int, // Base size (default chars height)
|
baseSize: c.int, // Base size (default chars height)
|
||||||
charsCount: c.int, // Number of characters
|
glyphCount: c.int, // Number of characters
|
||||||
charsPadding: c.int, // Padding around the chars
|
glyphPadding: c.int, // Padding around the chars
|
||||||
texture: Texture2D, // Characters texture atlas
|
texture: Texture2D, // Characters texture atlas
|
||||||
recs: [^]Rectangle, // Characters rectangles in texture
|
recs: [^]Rectangle, // Characters rectangles in texture
|
||||||
chars: [^]GlyphInfo, // Characters info data
|
glyphs: [^]GlyphInfo, // Characters info data
|
||||||
}
|
}
|
||||||
|
|
||||||
// Camera type, defines a camera position/orientation in 3d space
|
// Camera type, defines a camera position/orientation in 3d space
|
||||||
@@ -404,7 +404,7 @@ BoneInfo :: struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Model type
|
// Model type
|
||||||
Model :: struct {
|
Model :: struct #align(align_of(uintptr)) {
|
||||||
transform: Matrix, // Local transform matrix
|
transform: Matrix, // Local transform matrix
|
||||||
|
|
||||||
meshCount: c.int, // Number of meshes
|
meshCount: c.int, // Number of meshes
|
||||||
@@ -425,7 +425,7 @@ ModelAnimation :: struct {
|
|||||||
frameCount: c.int, // Number of animation frames
|
frameCount: c.int, // Number of animation frames
|
||||||
bones: [^]BoneInfo, // Bones information (skeleton)
|
bones: [^]BoneInfo, // Bones information (skeleton)
|
||||||
framePoses: [^][^]Transform, // Poses array by frame
|
framePoses: [^][^]Transform, // Poses array by frame
|
||||||
name: [32]u8, // Animation name
|
name: [32]byte, // Animation name
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ray type (useful for raycast)
|
// Ray type (useful for raycast)
|
||||||
@@ -491,7 +491,6 @@ VrDeviceInfo :: struct {
|
|||||||
vResolution: c.int, // Vertical resolution in pixels
|
vResolution: c.int, // Vertical resolution in pixels
|
||||||
hScreenSize: f32, // Horizontal size in meters
|
hScreenSize: f32, // Horizontal size in meters
|
||||||
vScreenSize: f32, // Vertical size in meters
|
vScreenSize: f32, // Vertical size in meters
|
||||||
vScreenCenter: f32, // Screen center in meters
|
|
||||||
eyeToScreenDistance: f32, // Distance between eye and display in meters
|
eyeToScreenDistance: f32, // Distance between eye and display in meters
|
||||||
lensSeparationDistance: f32, // Lens separation distance in meters
|
lensSeparationDistance: f32, // Lens separation distance in meters
|
||||||
interpupillaryDistance: f32, // IPD (distance between pupils) in meters
|
interpupillaryDistance: f32, // IPD (distance between pupils) in meters
|
||||||
@@ -500,7 +499,7 @@ VrDeviceInfo :: struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VR Stereo rendering configuration for simulator
|
// VR Stereo rendering configuration for simulator
|
||||||
VrStereoConfig :: struct {
|
VrStereoConfig :: struct #align(4) {
|
||||||
projection: [2]Matrix, // VR projection matrices (per eye)
|
projection: [2]Matrix, // VR projection matrices (per eye)
|
||||||
viewOffset: [2]Matrix, // VR view offset matrices (per eye)
|
viewOffset: [2]Matrix, // VR view offset matrices (per eye)
|
||||||
leftLensCenter: [2]f32, // VR left lens center
|
leftLensCenter: [2]f32, // VR left lens center
|
||||||
|
|||||||
Reference in New Issue
Block a user