mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-25 22:41:34 +00:00
Merge branch 'master' into windows-llvm-11.1.0
This commit is contained in:
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@@ -1,3 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: odin-lang
|
||||
patreon: gingerbill
|
||||
|
||||
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -38,6 +38,9 @@ jobs:
|
||||
cd tests/vendor
|
||||
make
|
||||
timeout-minutes: 10
|
||||
- name: Odin check examples/all for Linux i386
|
||||
run: ./odin check examples/all -vet -strict-style -target:linux_i386
|
||||
timeout-minutes: 10
|
||||
- name: Odin check examples/all for OpenBSD amd64
|
||||
run: ./odin check examples/all -vet -strict-style -target:openbsd_amd64
|
||||
timeout-minutes: 10
|
||||
@@ -81,6 +84,9 @@ jobs:
|
||||
cd tests/vendor
|
||||
make
|
||||
timeout-minutes: 10
|
||||
- name: Odin check examples/all for Darwin arm64
|
||||
run: ./odin check examples/all -vet -strict-style -target:darwin_arm64
|
||||
timeout-minutes: 10
|
||||
build_windows:
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
@@ -141,3 +147,9 @@ jobs:
|
||||
cd tests\core\math\big
|
||||
call build.bat
|
||||
timeout-minutes: 10
|
||||
- name: Odin check examples/all for Windows 32bits
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
||||
odin check examples/all -strict-style -target:windows_i386
|
||||
timeout-minutes: 10
|
||||
|
||||
@@ -139,7 +139,13 @@ Context_Memory_Input :: struct #packed {
|
||||
size_packed: i64,
|
||||
size_unpacked: i64,
|
||||
}
|
||||
#assert(size_of(Context_Memory_Input) == 64)
|
||||
when size_of(rawptr) == 8 {
|
||||
#assert(size_of(Context_Memory_Input) == 64)
|
||||
} else {
|
||||
// e.g. `-target:windows_i386`
|
||||
#assert(size_of(Context_Memory_Input) == 52)
|
||||
}
|
||||
|
||||
|
||||
Context_Stream_Input :: struct #packed {
|
||||
input_data: []u8,
|
||||
@@ -473,4 +479,4 @@ discard_to_next_byte_lsb_from_stream :: proc(z: ^Context_Stream_Input) {
|
||||
consume_bits_lsb(z, discard)
|
||||
}
|
||||
|
||||
discard_to_next_byte_lsb :: proc{discard_to_next_byte_lsb_from_memory, discard_to_next_byte_lsb_from_stream};
|
||||
discard_to_next_byte_lsb :: proc{discard_to_next_byte_lsb_from_memory, discard_to_next_byte_lsb_from_stream}
|
||||
|
||||
@@ -100,7 +100,7 @@ E_GZIP :: compress.GZIP_Error
|
||||
E_ZLIB :: compress.ZLIB_Error
|
||||
E_Deflate :: compress.Deflate_Error
|
||||
|
||||
GZIP_MAX_PAYLOAD_SIZE :: int(max(u32le))
|
||||
GZIP_MAX_PAYLOAD_SIZE :: i64(max(u32le))
|
||||
|
||||
load :: proc{load_from_slice, load_from_file, load_from_context}
|
||||
|
||||
@@ -136,7 +136,7 @@ load_from_context :: proc(z: ^$C, buf: ^bytes.Buffer, known_gzip_size := -1, exp
|
||||
|
||||
z.output = buf
|
||||
|
||||
if expected_output_size > GZIP_MAX_PAYLOAD_SIZE {
|
||||
if i64(expected_output_size) > i64(GZIP_MAX_PAYLOAD_SIZE) {
|
||||
return E_GZIP.Payload_Size_Exceeds_Max_Payload
|
||||
}
|
||||
|
||||
|
||||
@@ -677,4 +677,4 @@ inflate_from_byte_array_raw :: proc(input: []u8, buf: ^bytes.Buffer, raw := fals
|
||||
return inflate_raw(z=&ctx, expected_output_size=expected_output_size)
|
||||
}
|
||||
|
||||
inflate :: proc{inflate_from_context, inflate_from_byte_array};
|
||||
inflate :: proc{inflate_from_context, inflate_from_byte_array}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dynamic_bit_array
|
||||
|
||||
import "core:intrinsics"
|
||||
import "core:mem"
|
||||
|
||||
/*
|
||||
Note that these constants are dependent on the backing being a u64.
|
||||
@@ -15,15 +16,16 @@ INDEX_MASK :: 63
|
||||
NUM_BITS :: 64
|
||||
|
||||
Bit_Array :: struct {
|
||||
bits: [dynamic]u64,
|
||||
bias: int,
|
||||
max_index: int,
|
||||
bits: [dynamic]u64,
|
||||
bias: int,
|
||||
max_index: int,
|
||||
free_pointer: bool,
|
||||
}
|
||||
|
||||
Bit_Array_Iterator :: struct {
|
||||
array: ^Bit_Array,
|
||||
array: ^Bit_Array,
|
||||
word_idx: int,
|
||||
bit_idx: uint,
|
||||
bit_idx: uint,
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -186,7 +188,7 @@ set :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator
|
||||
/*
|
||||
A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative).
|
||||
*/
|
||||
create :: proc(max_index: int, min_index := 0, allocator := context.allocator) -> (res: Bit_Array, ok: bool) #optional_ok {
|
||||
create :: proc(max_index: int, min_index := 0, allocator := context.allocator) -> (res: ^Bit_Array, ok: bool) #optional_ok {
|
||||
context.allocator = allocator
|
||||
size_in_bits := max_index - min_index
|
||||
|
||||
@@ -194,11 +196,11 @@ create :: proc(max_index: int, min_index := 0, allocator := context.allocator) -
|
||||
|
||||
legs := size_in_bits >> INDEX_SHIFT
|
||||
|
||||
res = Bit_Array{
|
||||
bias = min_index,
|
||||
max_index = max_index,
|
||||
}
|
||||
return res, resize_if_needed(&res, legs)
|
||||
res = new(Bit_Array)
|
||||
res.bias = min_index
|
||||
res.max_index = max_index
|
||||
res.free_pointer = true
|
||||
return res, resize_if_needed(res, legs)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -206,7 +208,7 @@ create :: proc(max_index: int, min_index := 0, allocator := context.allocator) -
|
||||
*/
|
||||
clear :: proc(ba: ^Bit_Array) {
|
||||
if ba == nil { return }
|
||||
ba.bits = {}
|
||||
mem.zero_slice(ba.bits[:])
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -215,6 +217,9 @@ clear :: proc(ba: ^Bit_Array) {
|
||||
destroy :: proc(ba: ^Bit_Array) {
|
||||
if ba == nil { return }
|
||||
delete(ba.bits)
|
||||
if ba.free_pointer { // Only free if this Bit_Array was created using `create`, not when on the stack.
|
||||
free(ba)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,6 +21,7 @@ package dynamic_bit_array
|
||||
// returns `false`, `false`, because this Bit Array wasn't created to allow negative indices.
|
||||
was_set, was_retrieved := get(&bits, -1)
|
||||
fmt.println(was_set, was_retrieved)
|
||||
destroy(&bits)
|
||||
}
|
||||
|
||||
-- A Bit Array can optionally allow for negative indices, if the mininum value was given during creation:
|
||||
@@ -40,13 +41,13 @@ package dynamic_bit_array
|
||||
using bit_array
|
||||
|
||||
bits := create(int(max(Foo)), int(min(Foo)))
|
||||
defer destroy(&bits)
|
||||
defer destroy(bits)
|
||||
|
||||
fmt.printf("Set(Bar): %v\n", set(&bits, Foo.Bar))
|
||||
fmt.printf("Get(Bar): %v, %v\n", get(&bits, Foo.Bar))
|
||||
fmt.printf("Set(Negative_Test): %v\n", set(&bits, Foo.Negative_Test))
|
||||
fmt.printf("Get(Leaves): %v, %v\n", get(&bits, Foo.Leaves))
|
||||
fmt.printf("Get(Negative_Test): %v, %v\n", get(&bits, Foo.Negative_Test))
|
||||
fmt.printf("Set(Bar): %v\n", set(bits, Foo.Bar))
|
||||
fmt.printf("Get(Bar): %v, %v\n", get(bits, Foo.Bar))
|
||||
fmt.printf("Set(Negative_Test): %v\n", set(bits, Foo.Negative_Test))
|
||||
fmt.printf("Get(Leaves): %v, %v\n", get(bits, Foo.Leaves))
|
||||
fmt.printf("Get(Negative_Test): %v, %v\n", get(bits, Foo.Negative_Test))
|
||||
fmt.printf("Freed.\n")
|
||||
}
|
||||
*/
|
||||
@@ -1,6 +1,6 @@
|
||||
package crypto
|
||||
|
||||
when ODIN_OS != .Linux && ODIN_OS != .OpenBSD {
|
||||
when ODIN_OS != .Linux && ODIN_OS != .OpenBSD && ODIN_OS != .Windows {
|
||||
_rand_bytes :: proc (dst: []byte) {
|
||||
unimplemented("crypto: rand_bytes not supported on this OS")
|
||||
}
|
||||
|
||||
23
core/crypto/rand_windows.odin
Normal file
23
core/crypto/rand_windows.odin
Normal file
@@ -0,0 +1,23 @@
|
||||
package crypto
|
||||
|
||||
import win32 "core:sys/windows"
|
||||
import "core:os"
|
||||
import "core:fmt"
|
||||
|
||||
_rand_bytes :: proc(dst: []byte) {
|
||||
ret := (os.Errno)(win32.BCryptGenRandom(nil, raw_data(dst), u32(len(dst)), win32.BCRYPT_USE_SYSTEM_PREFERRED_RNG))
|
||||
if ret != os.ERROR_NONE {
|
||||
switch ret {
|
||||
case os.ERROR_INVALID_HANDLE:
|
||||
// The handle to the first parameter is invalid.
|
||||
// This should not happen here, since we explicitly pass nil to it
|
||||
panic("crypto: BCryptGenRandom Invalid handle for hAlgorithm")
|
||||
case os.ERROR_INVALID_PARAMETER:
|
||||
// One of the parameters was invalid
|
||||
panic("crypto: BCryptGenRandom Invalid parameter")
|
||||
case:
|
||||
// Unknown error
|
||||
panic(fmt.tprintf("crypto: BCryptGenRandom failed: %d\n", ret))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -605,7 +605,7 @@ fmt_bad_verb :: proc(using fi: ^Info, verb: rune) {
|
||||
fmt_bool :: proc(using fi: ^Info, b: bool, verb: rune) {
|
||||
switch verb {
|
||||
case 't', 'v':
|
||||
io.write_string(writer, b ? "true" : "false", &fi.n)
|
||||
fmt_string(fi, b ? "true" : "false", 's')
|
||||
case:
|
||||
fmt_bad_verb(fi, verb)
|
||||
}
|
||||
@@ -943,11 +943,27 @@ fmt_float :: proc(fi: ^Info, v: f64, bit_size: int, verb: rune) {
|
||||
fmt_string :: proc(fi: ^Info, s: string, verb: rune) {
|
||||
switch verb {
|
||||
case 's', 'v':
|
||||
io.write_string(fi.writer, s, &fi.n)
|
||||
if fi.width_set && len(s) < fi.width {
|
||||
for _ in 0..<fi.width - len(s) {
|
||||
io.write_byte(fi.writer, ' ', &fi.n)
|
||||
if fi.width_set {
|
||||
if fi.width > len(s) {
|
||||
if fi.minus {
|
||||
io.write_string(fi.writer, s, &fi.n)
|
||||
}
|
||||
|
||||
for _ in 0..<fi.width - len(s) {
|
||||
io.write_byte(fi.writer, ' ', &fi.n)
|
||||
}
|
||||
|
||||
if !fi.minus {
|
||||
io.write_string(fi.writer, s, &fi.n)
|
||||
}
|
||||
}
|
||||
else {
|
||||
io.write_string(fi.writer, s[:fi.width], &fi.n)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
io.write_string(fi.writer, s, &fi.n)
|
||||
}
|
||||
|
||||
case 'q': // quoted string
|
||||
@@ -1058,7 +1074,7 @@ fmt_enum :: proc(fi: ^Info, v: any, verb: rune) {
|
||||
fmt_arg(fi, any{v.data, runtime.type_info_base(e.base).id}, verb)
|
||||
case 's', 'v':
|
||||
if str, ok := enum_value_to_string(v); ok {
|
||||
io.write_string(fi.writer, str, &fi.n)
|
||||
fmt_string(fi, str, 's')
|
||||
} else {
|
||||
io.write_string(fi.writer, "%!(BAD ENUM VALUE=", &fi.n)
|
||||
fmt_arg(fi, any{v.data, runtime.type_info_base(e.base).id}, 'i')
|
||||
|
||||
@@ -41,6 +41,8 @@ mem_copy_non_overlapping :: proc(dst, src: rawptr, len: int) ---
|
||||
mem_zero :: proc(ptr: rawptr, len: int) ---
|
||||
mem_zero_volatile :: proc(ptr: rawptr, len: int) ---
|
||||
|
||||
unaligned_load :: proc(src: ^$T) -> T ---
|
||||
unaligned_store :: proc(dst: ^$T, val: T) -> T ---
|
||||
|
||||
fixed_point_mul :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) ---
|
||||
fixed_point_div :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) ---
|
||||
|
||||
@@ -34,7 +34,7 @@ Node :: struct {
|
||||
pos: tokenizer.Pos,
|
||||
end: tokenizer.Pos,
|
||||
state_flags: Node_State_Flags,
|
||||
derived: any,
|
||||
derived: Any_Node,
|
||||
}
|
||||
|
||||
Comment_Group :: struct {
|
||||
@@ -88,9 +88,11 @@ File :: struct {
|
||||
|
||||
Expr :: struct {
|
||||
using expr_base: Node,
|
||||
derived_expr: Any_Expr,
|
||||
}
|
||||
Stmt :: struct {
|
||||
using stmt_base: Node,
|
||||
derived_stmt: Any_Stmt,
|
||||
}
|
||||
Decl :: struct {
|
||||
using decl_base: Stmt,
|
||||
@@ -541,7 +543,7 @@ unparen_expr :: proc(expr: ^Expr) -> (val: ^Expr) {
|
||||
return
|
||||
}
|
||||
for {
|
||||
e, ok := val.derived.(Paren_Expr)
|
||||
e, ok := val.derived.(^Paren_Expr)
|
||||
if !ok || e.expr == nil {
|
||||
break
|
||||
}
|
||||
@@ -758,4 +760,173 @@ Matrix_Type :: struct {
|
||||
row_count: ^Expr,
|
||||
column_count: ^Expr,
|
||||
elem: ^Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Any_Node :: union {
|
||||
^Package,
|
||||
^File,
|
||||
^Comment_Group,
|
||||
|
||||
^Bad_Expr,
|
||||
^Ident,
|
||||
^Implicit,
|
||||
^Undef,
|
||||
^Basic_Lit,
|
||||
^Basic_Directive,
|
||||
^Ellipsis,
|
||||
^Proc_Lit,
|
||||
^Comp_Lit,
|
||||
^Tag_Expr,
|
||||
^Unary_Expr,
|
||||
^Binary_Expr,
|
||||
^Paren_Expr,
|
||||
^Selector_Expr,
|
||||
^Implicit_Selector_Expr,
|
||||
^Selector_Call_Expr,
|
||||
^Index_Expr,
|
||||
^Deref_Expr,
|
||||
^Slice_Expr,
|
||||
^Matrix_Index_Expr,
|
||||
^Call_Expr,
|
||||
^Field_Value,
|
||||
^Ternary_If_Expr,
|
||||
^Ternary_When_Expr,
|
||||
^Or_Else_Expr,
|
||||
^Or_Return_Expr,
|
||||
^Type_Assertion,
|
||||
^Type_Cast,
|
||||
^Auto_Cast,
|
||||
^Inline_Asm_Expr,
|
||||
|
||||
^Proc_Group,
|
||||
|
||||
^Typeid_Type,
|
||||
^Helper_Type,
|
||||
^Distinct_Type,
|
||||
^Poly_Type,
|
||||
^Proc_Type,
|
||||
^Pointer_Type,
|
||||
^Multi_Pointer_Type,
|
||||
^Array_Type,
|
||||
^Dynamic_Array_Type,
|
||||
^Struct_Type,
|
||||
^Union_Type,
|
||||
^Enum_Type,
|
||||
^Bit_Set_Type,
|
||||
^Map_Type,
|
||||
^Relative_Type,
|
||||
^Matrix_Type,
|
||||
|
||||
^Bad_Stmt,
|
||||
^Empty_Stmt,
|
||||
^Expr_Stmt,
|
||||
^Tag_Stmt,
|
||||
^Assign_Stmt,
|
||||
^Block_Stmt,
|
||||
^If_Stmt,
|
||||
^When_Stmt,
|
||||
^Return_Stmt,
|
||||
^Defer_Stmt,
|
||||
^For_Stmt,
|
||||
^Range_Stmt,
|
||||
^Inline_Range_Stmt,
|
||||
^Case_Clause,
|
||||
^Switch_Stmt,
|
||||
^Type_Switch_Stmt,
|
||||
^Branch_Stmt,
|
||||
^Using_Stmt,
|
||||
|
||||
^Bad_Decl,
|
||||
^Value_Decl,
|
||||
^Package_Decl,
|
||||
^Import_Decl,
|
||||
^Foreign_Block_Decl,
|
||||
^Foreign_Import_Decl,
|
||||
|
||||
^Attribute,
|
||||
^Field,
|
||||
^Field_List,
|
||||
}
|
||||
|
||||
|
||||
Any_Expr :: union {
|
||||
^Bad_Expr,
|
||||
^Ident,
|
||||
^Implicit,
|
||||
^Undef,
|
||||
^Basic_Lit,
|
||||
^Basic_Directive,
|
||||
^Ellipsis,
|
||||
^Proc_Lit,
|
||||
^Comp_Lit,
|
||||
^Tag_Expr,
|
||||
^Unary_Expr,
|
||||
^Binary_Expr,
|
||||
^Paren_Expr,
|
||||
^Selector_Expr,
|
||||
^Implicit_Selector_Expr,
|
||||
^Selector_Call_Expr,
|
||||
^Index_Expr,
|
||||
^Deref_Expr,
|
||||
^Slice_Expr,
|
||||
^Matrix_Index_Expr,
|
||||
^Call_Expr,
|
||||
^Field_Value,
|
||||
^Ternary_If_Expr,
|
||||
^Ternary_When_Expr,
|
||||
^Or_Else_Expr,
|
||||
^Or_Return_Expr,
|
||||
^Type_Assertion,
|
||||
^Type_Cast,
|
||||
^Auto_Cast,
|
||||
^Inline_Asm_Expr,
|
||||
|
||||
^Proc_Group,
|
||||
|
||||
^Typeid_Type,
|
||||
^Helper_Type,
|
||||
^Distinct_Type,
|
||||
^Poly_Type,
|
||||
^Proc_Type,
|
||||
^Pointer_Type,
|
||||
^Multi_Pointer_Type,
|
||||
^Array_Type,
|
||||
^Dynamic_Array_Type,
|
||||
^Struct_Type,
|
||||
^Union_Type,
|
||||
^Enum_Type,
|
||||
^Bit_Set_Type,
|
||||
^Map_Type,
|
||||
^Relative_Type,
|
||||
^Matrix_Type,
|
||||
}
|
||||
|
||||
|
||||
Any_Stmt :: union {
|
||||
^Bad_Stmt,
|
||||
^Empty_Stmt,
|
||||
^Expr_Stmt,
|
||||
^Tag_Stmt,
|
||||
^Assign_Stmt,
|
||||
^Block_Stmt,
|
||||
^If_Stmt,
|
||||
^When_Stmt,
|
||||
^Return_Stmt,
|
||||
^Defer_Stmt,
|
||||
^For_Stmt,
|
||||
^Range_Stmt,
|
||||
^Inline_Range_Stmt,
|
||||
^Case_Clause,
|
||||
^Switch_Stmt,
|
||||
^Type_Switch_Stmt,
|
||||
^Branch_Stmt,
|
||||
^Using_Stmt,
|
||||
|
||||
^Bad_Decl,
|
||||
^Value_Decl,
|
||||
^Package_Decl,
|
||||
^Import_Decl,
|
||||
^Foreign_Block_Decl,
|
||||
^Foreign_Import_Decl,
|
||||
}
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
package odin_ast
|
||||
|
||||
import "core:intrinsics"
|
||||
import "core:mem"
|
||||
import "core:fmt"
|
||||
import "core:reflect"
|
||||
import "core:odin/tokenizer"
|
||||
_ :: intrinsics
|
||||
|
||||
new :: proc($T: typeid, pos, end: tokenizer.Pos) -> ^T {
|
||||
n, _ := mem.new(T)
|
||||
n.pos = pos
|
||||
n.end = end
|
||||
n.derived = n^
|
||||
n.derived = n
|
||||
base: ^Node = n // dummy check
|
||||
_ = base // "Use" type to make -vet happy
|
||||
when intrinsics.type_has_field(T, "derived_expr") {
|
||||
n.derived_expr = n
|
||||
}
|
||||
when intrinsics.type_has_field(T, "derived_stmt") {
|
||||
n.derived_stmt = n
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -59,232 +68,257 @@ clone_node :: proc(node: ^Node) -> ^Node {
|
||||
return nil
|
||||
}
|
||||
|
||||
size := size_of(Node)
|
||||
size := size_of(Node)
|
||||
align := align_of(Node)
|
||||
ti := type_info_of(node.derived.id)
|
||||
ti := reflect.union_variant_type_info(node.derived)
|
||||
if ti != nil {
|
||||
size = ti.size
|
||||
align = ti.align
|
||||
elem := ti.variant.(reflect.Type_Info_Pointer).elem
|
||||
size = elem.size
|
||||
align = elem.align
|
||||
}
|
||||
|
||||
switch in node.derived {
|
||||
case Package, File:
|
||||
#partial switch in node.derived {
|
||||
case ^Package, ^File:
|
||||
panic("Cannot clone this node type")
|
||||
}
|
||||
|
||||
res := cast(^Node)mem.alloc(size, align)
|
||||
src: rawptr = node
|
||||
if node.derived != nil {
|
||||
src = node.derived.data
|
||||
src = (^rawptr)(&node.derived)^
|
||||
}
|
||||
mem.copy(res, src, size)
|
||||
res.derived.data = rawptr(res)
|
||||
res.derived.id = node.derived.id
|
||||
res_ptr_any: any
|
||||
res_ptr_any.data = &res
|
||||
res_ptr_any.id = ti.id
|
||||
|
||||
switch r in &res.derived {
|
||||
case Bad_Expr:
|
||||
case Ident:
|
||||
case Implicit:
|
||||
case Undef:
|
||||
case Basic_Lit:
|
||||
reflect.set_union_value(res.derived, res_ptr_any)
|
||||
|
||||
case Ellipsis:
|
||||
res_ptr := reflect.deref(res_ptr_any)
|
||||
|
||||
if de := reflect.struct_field_value_by_name(res_ptr, "derived_expr", true); de != nil {
|
||||
reflect.set_union_value(de, res_ptr_any)
|
||||
}
|
||||
if ds := reflect.struct_field_value_by_name(res_ptr, "derived_stmt", true); ds != nil {
|
||||
reflect.set_union_value(ds, res_ptr_any)
|
||||
}
|
||||
|
||||
if res.derived != nil do switch r in res.derived {
|
||||
case ^Package, ^File:
|
||||
case ^Bad_Expr:
|
||||
case ^Ident:
|
||||
case ^Implicit:
|
||||
case ^Undef:
|
||||
case ^Basic_Lit:
|
||||
case ^Basic_Directive:
|
||||
case ^Comment_Group:
|
||||
|
||||
case ^Ellipsis:
|
||||
r.expr = clone(r.expr)
|
||||
case Proc_Lit:
|
||||
case ^Proc_Lit:
|
||||
r.type = auto_cast clone(r.type)
|
||||
r.body = clone(r.body)
|
||||
case Comp_Lit:
|
||||
case ^Comp_Lit:
|
||||
r.type = clone(r.type)
|
||||
r.elems = clone(r.elems)
|
||||
|
||||
case Tag_Expr:
|
||||
case ^Tag_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
case Unary_Expr:
|
||||
case ^Unary_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
case Binary_Expr:
|
||||
case ^Binary_Expr:
|
||||
r.left = clone(r.left)
|
||||
r.right = clone(r.right)
|
||||
case Paren_Expr:
|
||||
case ^Paren_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
case Selector_Expr:
|
||||
case ^Selector_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
r.field = auto_cast clone(r.field)
|
||||
case Implicit_Selector_Expr:
|
||||
case ^Implicit_Selector_Expr:
|
||||
r.field = auto_cast clone(r.field)
|
||||
case Selector_Call_Expr:
|
||||
case ^Selector_Call_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
r.call = auto_cast clone(r.call)
|
||||
case Index_Expr:
|
||||
case ^Index_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
r.index = clone(r.index)
|
||||
case Matrix_Index_Expr:
|
||||
case ^Matrix_Index_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
r.row_index = clone(r.row_index)
|
||||
r.column_index = clone(r.column_index)
|
||||
case Deref_Expr:
|
||||
case ^Deref_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
case Slice_Expr:
|
||||
case ^Slice_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
r.low = clone(r.low)
|
||||
r.high = clone(r.high)
|
||||
case Call_Expr:
|
||||
case ^Call_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
r.args = clone(r.args)
|
||||
case Field_Value:
|
||||
case ^Field_Value:
|
||||
r.field = clone(r.field)
|
||||
r.value = clone(r.value)
|
||||
case Ternary_If_Expr:
|
||||
case ^Ternary_If_Expr:
|
||||
r.x = clone(r.x)
|
||||
r.cond = clone(r.cond)
|
||||
r.y = clone(r.y)
|
||||
case Ternary_When_Expr:
|
||||
case ^Ternary_When_Expr:
|
||||
r.x = clone(r.x)
|
||||
r.cond = clone(r.cond)
|
||||
r.y = clone(r.y)
|
||||
case Or_Else_Expr:
|
||||
case ^Or_Else_Expr:
|
||||
r.x = clone(r.x)
|
||||
r.y = clone(r.y)
|
||||
case Or_Return_Expr:
|
||||
case ^Or_Return_Expr:
|
||||
r.expr = clone(r.expr)
|
||||
case Type_Assertion:
|
||||
case ^Type_Assertion:
|
||||
r.expr = clone(r.expr)
|
||||
r.type = clone(r.type)
|
||||
case Type_Cast:
|
||||
case ^Type_Cast:
|
||||
r.type = clone(r.type)
|
||||
r.expr = clone(r.expr)
|
||||
case Auto_Cast:
|
||||
case ^Auto_Cast:
|
||||
r.expr = clone(r.expr)
|
||||
case Inline_Asm_Expr:
|
||||
case ^Inline_Asm_Expr:
|
||||
r.param_types = clone(r.param_types)
|
||||
r.return_type = clone(r.return_type)
|
||||
r.constraints_string = clone(r.constraints_string)
|
||||
r.asm_string = clone(r.asm_string)
|
||||
|
||||
case Bad_Stmt:
|
||||
case ^Bad_Stmt:
|
||||
// empty
|
||||
case Empty_Stmt:
|
||||
case ^Empty_Stmt:
|
||||
// empty
|
||||
case Expr_Stmt:
|
||||
case ^Expr_Stmt:
|
||||
r.expr = clone(r.expr)
|
||||
case Tag_Stmt:
|
||||
case ^Tag_Stmt:
|
||||
r.stmt = clone(r.stmt)
|
||||
|
||||
case Assign_Stmt:
|
||||
case ^Assign_Stmt:
|
||||
r.lhs = clone(r.lhs)
|
||||
r.rhs = clone(r.rhs)
|
||||
case Block_Stmt:
|
||||
case ^Block_Stmt:
|
||||
r.label = clone(r.label)
|
||||
r.stmts = clone(r.stmts)
|
||||
case If_Stmt:
|
||||
case ^If_Stmt:
|
||||
r.label = clone(r.label)
|
||||
r.init = clone(r.init)
|
||||
r.cond = clone(r.cond)
|
||||
r.body = clone(r.body)
|
||||
r.else_stmt = clone(r.else_stmt)
|
||||
case When_Stmt:
|
||||
case ^When_Stmt:
|
||||
r.cond = clone(r.cond)
|
||||
r.body = clone(r.body)
|
||||
r.else_stmt = clone(r.else_stmt)
|
||||
case Return_Stmt:
|
||||
case ^Return_Stmt:
|
||||
r.results = clone(r.results)
|
||||
case Defer_Stmt:
|
||||
case ^Defer_Stmt:
|
||||
r.stmt = clone(r.stmt)
|
||||
case For_Stmt:
|
||||
case ^For_Stmt:
|
||||
r.label = clone(r.label)
|
||||
r.init = clone(r.init)
|
||||
r.cond = clone(r.cond)
|
||||
r.post = clone(r.post)
|
||||
r.body = clone(r.body)
|
||||
case Range_Stmt:
|
||||
case ^Range_Stmt:
|
||||
r.label = clone(r.label)
|
||||
r.vals = clone(r.vals)
|
||||
r.expr = clone(r.expr)
|
||||
r.body = clone(r.body)
|
||||
case Case_Clause:
|
||||
case ^Inline_Range_Stmt:
|
||||
r.label = clone(r.label)
|
||||
r.val0 = clone(r.val0)
|
||||
r.val1 = clone(r.val1)
|
||||
r.expr = clone(r.expr)
|
||||
r.body = clone(r.body)
|
||||
case ^Case_Clause:
|
||||
r.list = clone(r.list)
|
||||
r.body = clone(r.body)
|
||||
case Switch_Stmt:
|
||||
case ^Switch_Stmt:
|
||||
r.label = clone(r.label)
|
||||
r.init = clone(r.init)
|
||||
r.cond = clone(r.cond)
|
||||
r.body = clone(r.body)
|
||||
case Type_Switch_Stmt:
|
||||
case ^Type_Switch_Stmt:
|
||||
r.label = clone(r.label)
|
||||
r.tag = clone(r.tag)
|
||||
r.expr = clone(r.expr)
|
||||
r.body = clone(r.body)
|
||||
case Branch_Stmt:
|
||||
case ^Branch_Stmt:
|
||||
r.label = auto_cast clone(r.label)
|
||||
case Using_Stmt:
|
||||
case ^Using_Stmt:
|
||||
r.list = clone(r.list)
|
||||
case Bad_Decl:
|
||||
case Value_Decl:
|
||||
case ^Bad_Decl:
|
||||
case ^Value_Decl:
|
||||
r.attributes = clone(r.attributes)
|
||||
r.names = clone(r.names)
|
||||
r.type = clone(r.type)
|
||||
r.values = clone(r.values)
|
||||
case Package_Decl:
|
||||
case Import_Decl:
|
||||
case Foreign_Block_Decl:
|
||||
case ^Package_Decl:
|
||||
case ^Import_Decl:
|
||||
case ^Foreign_Block_Decl:
|
||||
r.attributes = clone(r.attributes)
|
||||
r.foreign_library = clone(r.foreign_library)
|
||||
r.body = clone(r.body)
|
||||
case Foreign_Import_Decl:
|
||||
case ^Foreign_Import_Decl:
|
||||
r.name = auto_cast clone(r.name)
|
||||
case Proc_Group:
|
||||
case ^Proc_Group:
|
||||
r.args = clone(r.args)
|
||||
case Attribute:
|
||||
case ^Attribute:
|
||||
r.elems = clone(r.elems)
|
||||
case Field:
|
||||
case ^Field:
|
||||
r.names = clone(r.names)
|
||||
r.type = clone(r.type)
|
||||
r.default_value = clone(r.default_value)
|
||||
case Field_List:
|
||||
case ^Field_List:
|
||||
r.list = clone(r.list)
|
||||
case Typeid_Type:
|
||||
case ^Typeid_Type:
|
||||
r.specialization = clone(r.specialization)
|
||||
case Helper_Type:
|
||||
case ^Helper_Type:
|
||||
r.type = clone(r.type)
|
||||
case Distinct_Type:
|
||||
case ^Distinct_Type:
|
||||
r.type = clone(r.type)
|
||||
case Poly_Type:
|
||||
case ^Poly_Type:
|
||||
r.type = auto_cast clone(r.type)
|
||||
r.specialization = clone(r.specialization)
|
||||
case Proc_Type:
|
||||
case ^Proc_Type:
|
||||
r.params = auto_cast clone(r.params)
|
||||
r.results = auto_cast clone(r.results)
|
||||
case Pointer_Type:
|
||||
case ^Pointer_Type:
|
||||
r.elem = clone(r.elem)
|
||||
case Multi_Pointer_Type:
|
||||
case ^Multi_Pointer_Type:
|
||||
r.elem = clone(r.elem)
|
||||
case Array_Type:
|
||||
case ^Array_Type:
|
||||
r.len = clone(r.len)
|
||||
r.elem = clone(r.elem)
|
||||
case Dynamic_Array_Type:
|
||||
case ^Dynamic_Array_Type:
|
||||
r.elem = clone(r.elem)
|
||||
case Struct_Type:
|
||||
case ^Struct_Type:
|
||||
r.poly_params = auto_cast clone(r.poly_params)
|
||||
r.align = clone(r.align)
|
||||
r.fields = auto_cast clone(r.fields)
|
||||
case Union_Type:
|
||||
case ^Union_Type:
|
||||
r.poly_params = auto_cast clone(r.poly_params)
|
||||
r.align = clone(r.align)
|
||||
r.variants = clone(r.variants)
|
||||
case Enum_Type:
|
||||
case ^Enum_Type:
|
||||
r.base_type = clone(r.base_type)
|
||||
r.fields = clone(r.fields)
|
||||
case Bit_Set_Type:
|
||||
case ^Bit_Set_Type:
|
||||
r.elem = clone(r.elem)
|
||||
r.underlying = clone(r.underlying)
|
||||
case Map_Type:
|
||||
case ^Map_Type:
|
||||
r.key = clone(r.key)
|
||||
r.value = clone(r.value)
|
||||
case Matrix_Type:
|
||||
case ^Matrix_Type:
|
||||
r.row_count = clone(r.row_count)
|
||||
r.column_count = clone(r.column_count)
|
||||
r.elem = clone(r.elem)
|
||||
case ^Relative_Type:
|
||||
r.tag = clone(r.tag)
|
||||
r.type = clone(r.type)
|
||||
case:
|
||||
fmt.panicf("Unhandled node kind: %T", r)
|
||||
fmt.panicf("Unhandled node kind: %v", r)
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
@@ -59,64 +59,64 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
}
|
||||
|
||||
switch n in &node.derived {
|
||||
case File:
|
||||
case ^File:
|
||||
if n.docs != nil {
|
||||
walk(v, n.docs)
|
||||
}
|
||||
walk_stmt_list(v, n.decls[:])
|
||||
case Package:
|
||||
case ^Package:
|
||||
for _, f in n.files {
|
||||
walk(v, f)
|
||||
}
|
||||
|
||||
case Comment_Group:
|
||||
case ^Comment_Group:
|
||||
// empty
|
||||
case Bad_Expr:
|
||||
case Ident:
|
||||
case Implicit:
|
||||
case Undef:
|
||||
case Basic_Lit:
|
||||
case Basic_Directive:
|
||||
case Ellipsis:
|
||||
case ^Bad_Expr:
|
||||
case ^Ident:
|
||||
case ^Implicit:
|
||||
case ^Undef:
|
||||
case ^Basic_Lit:
|
||||
case ^Basic_Directive:
|
||||
case ^Ellipsis:
|
||||
if n.expr != nil {
|
||||
walk(v, n.expr)
|
||||
}
|
||||
case Proc_Lit:
|
||||
case ^Proc_Lit:
|
||||
walk(v, n.type)
|
||||
walk(v, n.body)
|
||||
walk_expr_list(v, n.where_clauses)
|
||||
case Comp_Lit:
|
||||
case ^Comp_Lit:
|
||||
if n.type != nil {
|
||||
walk(v, n.type)
|
||||
}
|
||||
walk_expr_list(v, n.elems)
|
||||
case Tag_Expr:
|
||||
case ^Tag_Expr:
|
||||
walk(v, n.expr)
|
||||
case Unary_Expr:
|
||||
case ^Unary_Expr:
|
||||
walk(v, n.expr)
|
||||
case Binary_Expr:
|
||||
case ^Binary_Expr:
|
||||
walk(v, n.left)
|
||||
walk(v, n.right)
|
||||
case Paren_Expr:
|
||||
case ^Paren_Expr:
|
||||
walk(v, n.expr)
|
||||
case Selector_Expr:
|
||||
case ^Selector_Expr:
|
||||
walk(v, n.expr)
|
||||
walk(v, n.field)
|
||||
case Implicit_Selector_Expr:
|
||||
case ^Implicit_Selector_Expr:
|
||||
walk(v, n.field)
|
||||
case Selector_Call_Expr:
|
||||
case ^Selector_Call_Expr:
|
||||
walk(v, n.expr)
|
||||
walk(v, n.call)
|
||||
case Index_Expr:
|
||||
case ^Index_Expr:
|
||||
walk(v, n.expr)
|
||||
walk(v, n.index)
|
||||
case Matrix_Index_Expr:
|
||||
case ^Matrix_Index_Expr:
|
||||
walk(v, n.expr)
|
||||
walk(v, n.row_index)
|
||||
walk(v, n.column_index)
|
||||
case Deref_Expr:
|
||||
case ^Deref_Expr:
|
||||
walk(v, n.expr)
|
||||
case Slice_Expr:
|
||||
case ^Slice_Expr:
|
||||
walk(v, n.expr)
|
||||
if n.low != nil {
|
||||
walk(v, n.low)
|
||||
@@ -124,57 +124,57 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
if n.high != nil {
|
||||
walk(v, n.high)
|
||||
}
|
||||
case Call_Expr:
|
||||
case ^Call_Expr:
|
||||
walk(v, n.expr)
|
||||
walk_expr_list(v, n.args)
|
||||
case Field_Value:
|
||||
case ^Field_Value:
|
||||
walk(v, n.field)
|
||||
walk(v, n.value)
|
||||
case Ternary_If_Expr:
|
||||
case ^Ternary_If_Expr:
|
||||
walk(v, n.x)
|
||||
walk(v, n.cond)
|
||||
walk(v, n.y)
|
||||
case Ternary_When_Expr:
|
||||
case ^Ternary_When_Expr:
|
||||
walk(v, n.x)
|
||||
walk(v, n.cond)
|
||||
walk(v, n.y)
|
||||
case Or_Else_Expr:
|
||||
case ^Or_Else_Expr:
|
||||
walk(v, n.x)
|
||||
walk(v, n.y)
|
||||
case Or_Return_Expr:
|
||||
case ^Or_Return_Expr:
|
||||
walk(v, n.expr)
|
||||
case Type_Assertion:
|
||||
case ^Type_Assertion:
|
||||
walk(v, n.expr)
|
||||
if n.type != nil {
|
||||
walk(v, n.type)
|
||||
}
|
||||
case Type_Cast:
|
||||
case ^Type_Cast:
|
||||
walk(v, n.type)
|
||||
walk(v, n.expr)
|
||||
case Auto_Cast:
|
||||
case ^Auto_Cast:
|
||||
walk(v, n.expr)
|
||||
case Inline_Asm_Expr:
|
||||
case ^Inline_Asm_Expr:
|
||||
walk_expr_list(v, n.param_types)
|
||||
walk(v, n.return_type)
|
||||
walk(v, n.constraints_string)
|
||||
walk(v, n.asm_string)
|
||||
|
||||
|
||||
case Bad_Stmt:
|
||||
case Empty_Stmt:
|
||||
case Expr_Stmt:
|
||||
case ^Bad_Stmt:
|
||||
case ^Empty_Stmt:
|
||||
case ^Expr_Stmt:
|
||||
walk(v, n.expr)
|
||||
case Tag_Stmt:
|
||||
case ^Tag_Stmt:
|
||||
walk(v, n.stmt)
|
||||
case Assign_Stmt:
|
||||
case ^Assign_Stmt:
|
||||
walk_expr_list(v, n.lhs)
|
||||
walk_expr_list(v, n.rhs)
|
||||
case Block_Stmt:
|
||||
case ^Block_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
walk_stmt_list(v, n.stmts)
|
||||
case If_Stmt:
|
||||
case ^If_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
@@ -186,17 +186,17 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
if n.else_stmt != nil {
|
||||
walk(v, n.else_stmt)
|
||||
}
|
||||
case When_Stmt:
|
||||
case ^When_Stmt:
|
||||
walk(v, n.cond)
|
||||
walk(v, n.body)
|
||||
if n.else_stmt != nil {
|
||||
walk(v, n.else_stmt)
|
||||
}
|
||||
case Return_Stmt:
|
||||
case ^Return_Stmt:
|
||||
walk_expr_list(v, n.results)
|
||||
case Defer_Stmt:
|
||||
case ^Defer_Stmt:
|
||||
walk(v, n.stmt)
|
||||
case For_Stmt:
|
||||
case ^For_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
@@ -210,7 +210,7 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
walk(v, n.post)
|
||||
}
|
||||
walk(v, n.body)
|
||||
case Range_Stmt:
|
||||
case ^Range_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
@@ -221,7 +221,7 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
}
|
||||
walk(v, n.expr)
|
||||
walk(v, n.body)
|
||||
case Inline_Range_Stmt:
|
||||
case ^Inline_Range_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
@@ -233,10 +233,10 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
}
|
||||
walk(v, n.expr)
|
||||
walk(v, n.body)
|
||||
case Case_Clause:
|
||||
case ^Case_Clause:
|
||||
walk_expr_list(v, n.list)
|
||||
walk_stmt_list(v, n.body)
|
||||
case Switch_Stmt:
|
||||
case ^Switch_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
@@ -247,7 +247,7 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
walk(v, n.cond)
|
||||
}
|
||||
walk(v, n.body)
|
||||
case Type_Switch_Stmt:
|
||||
case ^Type_Switch_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
@@ -258,16 +258,16 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
walk(v, n.expr)
|
||||
}
|
||||
walk(v, n.body)
|
||||
case Branch_Stmt:
|
||||
case ^Branch_Stmt:
|
||||
if n.label != nil {
|
||||
walk(v, n.label)
|
||||
}
|
||||
case Using_Stmt:
|
||||
case ^Using_Stmt:
|
||||
walk_expr_list(v, n.list)
|
||||
|
||||
|
||||
case Bad_Decl:
|
||||
case Value_Decl:
|
||||
case ^Bad_Decl:
|
||||
case ^Value_Decl:
|
||||
if n.docs != nil {
|
||||
walk(v, n.docs)
|
||||
}
|
||||
@@ -280,21 +280,21 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
if n.comment != nil {
|
||||
walk(v, n.comment)
|
||||
}
|
||||
case Package_Decl:
|
||||
case ^Package_Decl:
|
||||
if n.docs != nil {
|
||||
walk(v, n.docs)
|
||||
}
|
||||
if n.comment != nil {
|
||||
walk(v, n.comment)
|
||||
}
|
||||
case Import_Decl:
|
||||
case ^Import_Decl:
|
||||
if n.docs != nil {
|
||||
walk(v, n.docs)
|
||||
}
|
||||
if n.comment != nil {
|
||||
walk(v, n.comment)
|
||||
}
|
||||
case Foreign_Block_Decl:
|
||||
case ^Foreign_Block_Decl:
|
||||
if n.docs != nil {
|
||||
walk(v, n.docs)
|
||||
}
|
||||
@@ -303,7 +303,7 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
walk(v, n.foreign_library)
|
||||
}
|
||||
walk(v, n.body)
|
||||
case Foreign_Import_Decl:
|
||||
case ^Foreign_Import_Decl:
|
||||
if n.docs != nil {
|
||||
walk(v, n.docs)
|
||||
}
|
||||
@@ -313,11 +313,11 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
walk(v, n.comment)
|
||||
}
|
||||
|
||||
case Proc_Group:
|
||||
case ^Proc_Group:
|
||||
walk_expr_list(v, n.args)
|
||||
case Attribute:
|
||||
case ^Attribute:
|
||||
walk_expr_list(v, n.elems)
|
||||
case Field:
|
||||
case ^Field:
|
||||
if n.docs != nil {
|
||||
walk(v, n.docs)
|
||||
}
|
||||
@@ -331,31 +331,31 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
if n.comment != nil {
|
||||
walk(v, n.comment)
|
||||
}
|
||||
case Field_List:
|
||||
case ^Field_List:
|
||||
for x in n.list {
|
||||
walk(v, x)
|
||||
}
|
||||
case Typeid_Type:
|
||||
case ^Typeid_Type:
|
||||
if n.specialization != nil {
|
||||
walk(v, n.specialization)
|
||||
}
|
||||
case Helper_Type:
|
||||
case ^Helper_Type:
|
||||
walk(v, n.type)
|
||||
case Distinct_Type:
|
||||
case ^Distinct_Type:
|
||||
walk(v, n.type)
|
||||
case Poly_Type:
|
||||
case ^Poly_Type:
|
||||
walk(v, n.type)
|
||||
if n.specialization != nil {
|
||||
walk(v, n.specialization)
|
||||
}
|
||||
case Proc_Type:
|
||||
case ^Proc_Type:
|
||||
walk(v, n.params)
|
||||
walk(v, n.results)
|
||||
case Pointer_Type:
|
||||
case ^Pointer_Type:
|
||||
walk(v, n.elem)
|
||||
case Multi_Pointer_Type:
|
||||
case ^Multi_Pointer_Type:
|
||||
walk(v, n.elem)
|
||||
case Array_Type:
|
||||
case ^Array_Type:
|
||||
if n.tag != nil {
|
||||
walk(v, n.tag)
|
||||
}
|
||||
@@ -363,12 +363,12 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
walk(v, n.len)
|
||||
}
|
||||
walk(v, n.elem)
|
||||
case Dynamic_Array_Type:
|
||||
case ^Dynamic_Array_Type:
|
||||
if n.tag != nil {
|
||||
walk(v, n.tag)
|
||||
}
|
||||
walk(v, n.elem)
|
||||
case Struct_Type:
|
||||
case ^Struct_Type:
|
||||
if n.poly_params != nil {
|
||||
walk(v, n.poly_params)
|
||||
}
|
||||
@@ -377,7 +377,7 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
}
|
||||
walk_expr_list(v, n.where_clauses)
|
||||
walk(v, n.fields)
|
||||
case Union_Type:
|
||||
case ^Union_Type:
|
||||
if n.poly_params != nil {
|
||||
walk(v, n.poly_params)
|
||||
}
|
||||
@@ -386,23 +386,23 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
}
|
||||
walk_expr_list(v, n.where_clauses)
|
||||
walk_expr_list(v, n.variants)
|
||||
case Enum_Type:
|
||||
case ^Enum_Type:
|
||||
if n.base_type != nil {
|
||||
walk(v, n.base_type)
|
||||
}
|
||||
walk_expr_list(v, n.fields)
|
||||
case Bit_Set_Type:
|
||||
case ^Bit_Set_Type:
|
||||
walk(v, n.elem)
|
||||
if n.underlying != nil {
|
||||
walk(v, n.underlying)
|
||||
}
|
||||
case Map_Type:
|
||||
case ^Map_Type:
|
||||
walk(v, n.key)
|
||||
walk(v, n.value)
|
||||
case Relative_Type:
|
||||
case ^Relative_Type:
|
||||
walk(v, n.tag)
|
||||
walk(v, n.type)
|
||||
case Matrix_Type:
|
||||
case ^Matrix_Type:
|
||||
walk(v, n.row_count)
|
||||
walk(v, n.column_count)
|
||||
walk(v, n.elem)
|
||||
|
||||
@@ -195,10 +195,10 @@ parse_file :: proc(p: ^Parser, file: ^ast.File) -> bool {
|
||||
for p.curr_tok.kind != .EOF {
|
||||
stmt := parse_stmt(p)
|
||||
if stmt != nil {
|
||||
if _, ok := stmt.derived.(ast.Empty_Stmt); !ok {
|
||||
if _, ok := stmt.derived.(^ast.Empty_Stmt); !ok {
|
||||
append(&p.file.decls, stmt)
|
||||
if es, es_ok := stmt.derived.(ast.Expr_Stmt); es_ok && es.expr != nil {
|
||||
if _, pl_ok := es.expr.derived.(ast.Proc_Lit); pl_ok {
|
||||
if es, es_ok := stmt.derived.(^ast.Expr_Stmt); es_ok && es.expr != nil {
|
||||
if _, pl_ok := es.expr.derived.(^ast.Proc_Lit); pl_ok {
|
||||
error(p, stmt.pos, "procedure literal evaluated but not used")
|
||||
}
|
||||
}
|
||||
@@ -459,7 +459,7 @@ is_blank_ident_token :: proc(tok: tokenizer.Token) -> bool {
|
||||
return false
|
||||
}
|
||||
is_blank_ident_node :: proc(node: ^ast.Node) -> bool {
|
||||
if ident, ok := node.derived.(ast.Ident); ok {
|
||||
if ident, ok := node.derived.(^ast.Ident); ok {
|
||||
return is_blank_ident(ident.name)
|
||||
}
|
||||
return true
|
||||
@@ -502,34 +502,34 @@ is_semicolon_optional_for_node :: proc(p: ^Parser, node: ^ast.Node) -> bool {
|
||||
return true
|
||||
}
|
||||
|
||||
switch n in node.derived {
|
||||
case ast.Empty_Stmt, ast.Block_Stmt:
|
||||
#partial switch n in node.derived {
|
||||
case ^ast.Empty_Stmt, ^ast.Block_Stmt:
|
||||
return true
|
||||
|
||||
case ast.If_Stmt, ast.When_Stmt,
|
||||
ast.For_Stmt, ast.Range_Stmt, ast.Inline_Range_Stmt,
|
||||
ast.Switch_Stmt, ast.Type_Switch_Stmt:
|
||||
case ^ast.If_Stmt, ^ast.When_Stmt,
|
||||
^ast.For_Stmt, ^ast.Range_Stmt, ^ast.Inline_Range_Stmt,
|
||||
^ast.Switch_Stmt, ^ast.Type_Switch_Stmt:
|
||||
return true
|
||||
|
||||
case ast.Helper_Type:
|
||||
case ^ast.Helper_Type:
|
||||
return is_semicolon_optional_for_node(p, n.type)
|
||||
case ast.Distinct_Type:
|
||||
case ^ast.Distinct_Type:
|
||||
return is_semicolon_optional_for_node(p, n.type)
|
||||
case ast.Pointer_Type:
|
||||
case ^ast.Pointer_Type:
|
||||
return is_semicolon_optional_for_node(p, n.elem)
|
||||
case ast.Struct_Type, ast.Union_Type, ast.Enum_Type:
|
||||
case ^ast.Struct_Type, ^ast.Union_Type, ^ast.Enum_Type:
|
||||
// Require semicolon within a procedure body
|
||||
return p.curr_proc == nil
|
||||
case ast.Proc_Lit:
|
||||
case ^ast.Proc_Lit:
|
||||
return true
|
||||
|
||||
case ast.Package_Decl, ast.Import_Decl, ast.Foreign_Import_Decl:
|
||||
case ^ast.Package_Decl, ^ast.Import_Decl, ^ast.Foreign_Import_Decl:
|
||||
return true
|
||||
|
||||
case ast.Foreign_Block_Decl:
|
||||
case ^ast.Foreign_Block_Decl:
|
||||
return is_semicolon_optional_for_node(p, n.body)
|
||||
|
||||
case ast.Value_Decl:
|
||||
case ^ast.Value_Decl:
|
||||
if n.is_mutable {
|
||||
return false
|
||||
}
|
||||
@@ -641,10 +641,10 @@ parse_stmt_list :: proc(p: ^Parser) -> []^ast.Stmt {
|
||||
p.curr_tok.kind != .EOF {
|
||||
stmt := parse_stmt(p)
|
||||
if stmt != nil {
|
||||
if _, ok := stmt.derived.(ast.Empty_Stmt); !ok {
|
||||
if _, ok := stmt.derived.(^ast.Empty_Stmt); !ok {
|
||||
append(&list, stmt)
|
||||
if es, es_ok := stmt.derived.(ast.Expr_Stmt); es_ok && es.expr != nil {
|
||||
if _, pl_ok := es.expr.derived.(ast.Proc_Lit); pl_ok {
|
||||
if es, es_ok := stmt.derived.(^ast.Expr_Stmt); es_ok && es.expr != nil {
|
||||
if _, pl_ok := es.expr.derived.(^ast.Proc_Lit); pl_ok {
|
||||
error(p, stmt.pos, "procedure literal evaluated but not used")
|
||||
}
|
||||
}
|
||||
@@ -722,7 +722,7 @@ convert_stmt_to_expr :: proc(p: ^Parser, stmt: ^ast.Stmt, kind: string) -> ^ast.
|
||||
if stmt == nil {
|
||||
return nil
|
||||
}
|
||||
if es, ok := stmt.derived.(ast.Expr_Stmt); ok {
|
||||
if es, ok := stmt.derived.(^ast.Expr_Stmt); ok {
|
||||
return es.expr
|
||||
}
|
||||
error(p, stmt.pos, "expected %s, found a simple statement", kind)
|
||||
@@ -864,7 +864,7 @@ parse_for_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
|
||||
if p.curr_tok.kind != .Semicolon {
|
||||
cond = parse_simple_stmt(p, {Stmt_Allow_Flag.In})
|
||||
if as, ok := cond.derived.(ast.Assign_Stmt); ok && as.op.kind == .In {
|
||||
if as, ok := cond.derived.(^ast.Assign_Stmt); ok && as.op.kind == .In {
|
||||
is_range = true
|
||||
}
|
||||
}
|
||||
@@ -906,7 +906,7 @@ parse_for_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
|
||||
|
||||
if is_range {
|
||||
assign_stmt := cond.derived.(ast.Assign_Stmt)
|
||||
assign_stmt := cond.derived.(^ast.Assign_Stmt)
|
||||
vals := assign_stmt.lhs[:]
|
||||
|
||||
rhs: ^ast.Expr
|
||||
@@ -987,7 +987,7 @@ parse_switch_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
tag = as
|
||||
} else {
|
||||
tag = parse_simple_stmt(p, {Stmt_Allow_Flag.In})
|
||||
if as, ok := tag.derived.(ast.Assign_Stmt); ok && as.op.kind == .In {
|
||||
if as, ok := tag.derived.(^ast.Assign_Stmt); ok && as.op.kind == .In {
|
||||
is_type_switch = true
|
||||
} else if parse_control_statement_semicolon_separator(p) {
|
||||
init = tag
|
||||
@@ -1074,14 +1074,14 @@ parse_attribute :: proc(p: ^Parser, tok: tokenizer.Token, open_kind, close_kind:
|
||||
skip_possible_newline(p)
|
||||
|
||||
decl := parse_stmt(p)
|
||||
switch d in &decl.derived {
|
||||
case ast.Value_Decl:
|
||||
#partial switch d in decl.derived_stmt {
|
||||
case ^ast.Value_Decl:
|
||||
if d.docs == nil { d.docs = docs }
|
||||
append(&d.attributes, attribute)
|
||||
case ast.Foreign_Block_Decl:
|
||||
case ^ast.Foreign_Block_Decl:
|
||||
if d.docs == nil { d.docs = docs }
|
||||
append(&d.attributes, attribute)
|
||||
case ast.Foreign_Import_Decl:
|
||||
case ^ast.Foreign_Import_Decl:
|
||||
if d.docs == nil { d.docs = docs }
|
||||
append(&d.attributes, attribute)
|
||||
case:
|
||||
@@ -1095,11 +1095,11 @@ parse_attribute :: proc(p: ^Parser, tok: tokenizer.Token, open_kind, close_kind:
|
||||
|
||||
parse_foreign_block_decl :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
decl := parse_stmt(p)
|
||||
switch in decl.derived {
|
||||
case ast.Empty_Stmt, ast.Bad_Stmt, ast.Bad_Decl:
|
||||
#partial switch in decl.derived_stmt {
|
||||
case ^ast.Empty_Stmt, ^ast.Bad_Stmt, ^ast.Bad_Decl:
|
||||
// Ignore
|
||||
return nil
|
||||
case ast.When_Stmt, ast.Value_Decl:
|
||||
case ^ast.When_Stmt, ^ast.Value_Decl:
|
||||
return decl
|
||||
}
|
||||
|
||||
@@ -1303,13 +1303,13 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
case .Defer:
|
||||
tok := advance_token(p)
|
||||
stmt := parse_stmt(p)
|
||||
switch s in stmt.derived {
|
||||
case ast.Empty_Stmt:
|
||||
#partial switch s in stmt.derived_stmt {
|
||||
case ^ast.Empty_Stmt:
|
||||
error(p, s.pos, "empty statement after defer (e.g. ';')")
|
||||
case ast.Defer_Stmt:
|
||||
case ^ast.Defer_Stmt:
|
||||
error(p, s.pos, "you cannot defer a defer statement")
|
||||
stmt = s.stmt
|
||||
case ast.Return_Stmt:
|
||||
case ^ast.Return_Stmt:
|
||||
error(p, s.pos, "you cannot defer a return statement")
|
||||
}
|
||||
ds := ast.new(ast.Defer_Stmt, tok.pos, stmt.end)
|
||||
@@ -1381,8 +1381,8 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
expect_token_after(p, .Colon, "identifier list")
|
||||
decl := parse_value_decl(p, list, docs)
|
||||
if decl != nil {
|
||||
switch d in &decl.derived {
|
||||
case ast.Value_Decl:
|
||||
#partial switch d in decl.derived_stmt {
|
||||
case ^ast.Value_Decl:
|
||||
d.is_using = true
|
||||
return decl
|
||||
}
|
||||
@@ -1413,9 +1413,9 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
return stmt
|
||||
case "partial":
|
||||
stmt := parse_stmt(p)
|
||||
switch s in &stmt.derived {
|
||||
case ast.Switch_Stmt: s.partial = true
|
||||
case ast.Type_Switch_Stmt: s.partial = true
|
||||
#partial switch s in stmt.derived_stmt {
|
||||
case ^ast.Switch_Stmt: s.partial = true
|
||||
case ^ast.Type_Switch_Stmt: s.partial = true
|
||||
case: error(p, stmt.pos, "#partial can only be applied to a switch statement")
|
||||
}
|
||||
return stmt
|
||||
@@ -1560,11 +1560,11 @@ parse_body :: proc(p: ^Parser) -> ^ast.Block_Stmt {
|
||||
}
|
||||
|
||||
convert_stmt_to_body :: proc(p: ^Parser, stmt: ^ast.Stmt) -> ^ast.Stmt {
|
||||
switch s in stmt.derived {
|
||||
case ast.Block_Stmt:
|
||||
#partial switch s in stmt.derived_stmt {
|
||||
case ^ast.Block_Stmt:
|
||||
error(p, stmt.pos, "expected a normal statement rather than a block statement")
|
||||
return stmt
|
||||
case ast.Empty_Stmt:
|
||||
case ^ast.Empty_Stmt:
|
||||
error(p, stmt.pos, "expected a non-empty statement")
|
||||
}
|
||||
|
||||
@@ -1641,10 +1641,10 @@ convert_to_ident_list :: proc(p: ^Parser, list: []Expr_And_Flags, ignore_flags,
|
||||
|
||||
id: ^ast.Expr = ident.expr
|
||||
|
||||
switch n in ident.expr.derived {
|
||||
case ast.Ident:
|
||||
case ast.Bad_Expr:
|
||||
case ast.Poly_Type:
|
||||
#partial switch n in ident.expr.derived_expr {
|
||||
case ^ast.Ident:
|
||||
case ^ast.Bad_Expr:
|
||||
case ^ast.Poly_Type:
|
||||
if allow_poly_names {
|
||||
if n.specialization == nil {
|
||||
break
|
||||
@@ -1806,21 +1806,21 @@ check_procedure_name_list :: proc(p: ^Parser, names: []^ast.Expr) -> bool {
|
||||
return false
|
||||
}
|
||||
|
||||
_, first_is_polymorphic := names[0].derived.(ast.Poly_Type)
|
||||
_, first_is_polymorphic := names[0].derived.(^ast.Poly_Type)
|
||||
any_polymorphic_names := first_is_polymorphic
|
||||
|
||||
for i := 1; i < len(names); i += 1 {
|
||||
name := names[i]
|
||||
|
||||
if first_is_polymorphic {
|
||||
if _, ok := name.derived.(ast.Poly_Type); ok {
|
||||
if _, ok := name.derived.(^ast.Poly_Type); ok {
|
||||
any_polymorphic_names = true
|
||||
} else {
|
||||
error(p, name.pos, "mixture of polymorphic and non-polymorphic identifiers")
|
||||
return any_polymorphic_names
|
||||
}
|
||||
} else {
|
||||
if _, ok := name.derived.(ast.Poly_Type); ok {
|
||||
if _, ok := name.derived.(^ast.Poly_Type); ok {
|
||||
any_polymorphic_names = true
|
||||
error(p, name.pos, "mixture of polymorphic and non-polymorphic identifiers")
|
||||
return any_polymorphic_names
|
||||
@@ -1885,7 +1885,7 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
|
||||
if type == nil {
|
||||
return false
|
||||
}
|
||||
_, ok := type.derived.(ast.Ellipsis)
|
||||
_, ok := type.derived.(^ast.Ellipsis)
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -1903,7 +1903,7 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
|
||||
type = parse_var_type(p, allowed_flags)
|
||||
tt := ast.unparen_expr(type)
|
||||
if is_signature && !any_polymorphic_names {
|
||||
if ti, ok := tt.derived.(ast.Typeid_Type); ok && ti.specialization != nil {
|
||||
if ti, ok := tt.derived.(^ast.Typeid_Type); ok && ti.specialization != nil {
|
||||
error(p, tt.pos, "specialization of typeid is not allowed without polymorphic names")
|
||||
}
|
||||
}
|
||||
@@ -1979,7 +1979,7 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
|
||||
p.curr_tok.kind != .EOF {
|
||||
prefix_flags := parse_field_prefixes(p)
|
||||
param := parse_var_type(p, allowed_flags & {.Typeid_Token, .Ellipsis})
|
||||
if _, ok := param.derived.(ast.Ellipsis); ok {
|
||||
if _, ok := param.derived.(^ast.Ellipsis); ok {
|
||||
if seen_ellipsis {
|
||||
error(p, param.pos, "extra variadic parameter after ellipsis")
|
||||
}
|
||||
@@ -2006,8 +2006,8 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
|
||||
|
||||
names := make([]^ast.Expr, 1)
|
||||
names[0] = ast.new(ast.Ident, tok.pos, end_pos(tok))
|
||||
switch ident in &names[0].derived {
|
||||
case ast.Ident:
|
||||
#partial switch ident in names[0].derived_expr {
|
||||
case ^ast.Ident:
|
||||
ident.name = tok.text
|
||||
case:
|
||||
unreachable()
|
||||
@@ -2137,12 +2137,12 @@ parse_proc_type :: proc(p: ^Parser, tok: tokenizer.Token) -> ^ast.Proc_Type {
|
||||
|
||||
loop: for param in params.list {
|
||||
if param.type != nil {
|
||||
if _, ok := param.type.derived.(ast.Poly_Type); ok {
|
||||
if _, ok := param.type.derived.(^ast.Poly_Type); ok {
|
||||
is_generic = true
|
||||
break loop
|
||||
}
|
||||
for name in param.names {
|
||||
if _, ok := name.derived.(ast.Poly_Type); ok {
|
||||
if _, ok := name.derived.(^ast.Poly_Type); ok {
|
||||
is_generic = true
|
||||
break loop
|
||||
}
|
||||
@@ -2179,13 +2179,13 @@ parse_inlining_operand :: proc(p: ^Parser, lhs: bool, tok: tokenizer.Token) -> ^
|
||||
}
|
||||
}
|
||||
|
||||
switch e in &ast.unparen_expr(expr).derived {
|
||||
case ast.Proc_Lit:
|
||||
#partial switch e in ast.unparen_expr(expr).derived_expr {
|
||||
case ^ast.Proc_Lit:
|
||||
if e.inlining != .None && e.inlining != pi {
|
||||
error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure literal")
|
||||
}
|
||||
e.inlining = pi
|
||||
case ast.Call_Expr:
|
||||
case ^ast.Call_Expr:
|
||||
if e.inlining != .None && e.inlining != pi {
|
||||
error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure call")
|
||||
}
|
||||
@@ -2276,9 +2276,9 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
bd.name = name.text
|
||||
original_type := parse_type(p)
|
||||
type := ast.unparen_expr(original_type)
|
||||
switch t in &type.derived {
|
||||
case ast.Array_Type: t.tag = bd
|
||||
case ast.Dynamic_Array_Type: t.tag = bd
|
||||
#partial switch t in type.derived_expr {
|
||||
case ^ast.Array_Type: t.tag = bd
|
||||
case ^ast.Dynamic_Array_Type: t.tag = bd
|
||||
case:
|
||||
error(p, original_type.pos, "expected an array type after #%s", name.text)
|
||||
}
|
||||
@@ -2290,10 +2290,10 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
tag.name = name.text
|
||||
original_expr := parse_expr(p, lhs)
|
||||
expr := ast.unparen_expr(original_expr)
|
||||
switch t in &expr.derived {
|
||||
case ast.Comp_Lit:
|
||||
#partial switch t in expr.derived_expr {
|
||||
case ^ast.Comp_Lit:
|
||||
t.tag = tag
|
||||
case ast.Array_Type:
|
||||
case ^ast.Array_Type:
|
||||
t.tag = tag
|
||||
error(p, tok.pos, "#%s has been replaced with #sparse for non-contiguous enumerated array types", name.text)
|
||||
case:
|
||||
@@ -2308,8 +2308,8 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
tag.name = name.text
|
||||
original_type := parse_type(p)
|
||||
type := ast.unparen_expr(original_type)
|
||||
switch t in &type.derived {
|
||||
case ast.Array_Type:
|
||||
#partial switch t in type.derived_expr {
|
||||
case ^ast.Array_Type:
|
||||
t.tag = tag
|
||||
case:
|
||||
error(p, tok.pos, "expected an enumerated array type after #%s", name.text)
|
||||
@@ -2689,7 +2689,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
variants: [dynamic]^ast.Expr
|
||||
for p.curr_tok.kind != .Close_Brace && p.curr_tok.kind != .EOF {
|
||||
type := parse_type(p)
|
||||
if _, ok := type.derived.(ast.Bad_Expr); !ok {
|
||||
if _, ok := type.derived.(^ast.Bad_Expr); !ok {
|
||||
append(&variants, type)
|
||||
}
|
||||
if !allow_token(p, .Comma) {
|
||||
@@ -2864,19 +2864,19 @@ is_literal_type :: proc(expr: ^ast.Expr) -> bool {
|
||||
if val == nil {
|
||||
return false
|
||||
}
|
||||
switch _ in val.derived {
|
||||
case ast.Bad_Expr,
|
||||
ast.Ident,
|
||||
ast.Selector_Expr,
|
||||
ast.Array_Type,
|
||||
ast.Struct_Type,
|
||||
ast.Union_Type,
|
||||
ast.Enum_Type,
|
||||
ast.Dynamic_Array_Type,
|
||||
ast.Map_Type,
|
||||
ast.Bit_Set_Type,
|
||||
ast.Matrix_Type,
|
||||
ast.Call_Expr:
|
||||
#partial switch _ in val.derived_expr {
|
||||
case ^ast.Bad_Expr,
|
||||
^ast.Ident,
|
||||
^ast.Selector_Expr,
|
||||
^ast.Array_Type,
|
||||
^ast.Struct_Type,
|
||||
^ast.Union_Type,
|
||||
^ast.Enum_Type,
|
||||
^ast.Dynamic_Array_Type,
|
||||
^ast.Map_Type,
|
||||
^ast.Bit_Set_Type,
|
||||
^ast.Matrix_Type,
|
||||
^ast.Call_Expr:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -2998,7 +2998,7 @@ parse_call_expr :: proc(p: ^Parser, operand: ^ast.Expr) -> ^ast.Expr {
|
||||
ce.close = close.pos
|
||||
|
||||
o := ast.unparen_expr(operand)
|
||||
if se, ok := o.derived.(ast.Selector_Expr); ok && se.op.kind == .Arrow_Right {
|
||||
if se, ok := o.derived.(^ast.Selector_Expr); ok && se.op.kind == .Arrow_Right {
|
||||
sce := ast.new(ast.Selector_Call_Expr, ce.pos, ce.end)
|
||||
sce.expr = o
|
||||
sce.call = ce
|
||||
@@ -3428,13 +3428,13 @@ parse_simple_stmt :: proc(p: ^Parser, flags: Stmt_Allow_Flags) -> ^ast.Stmt {
|
||||
stmt := parse_stmt(p)
|
||||
|
||||
if stmt != nil {
|
||||
switch n in &stmt.derived {
|
||||
case ast.Block_Stmt: n.label = label
|
||||
case ast.If_Stmt: n.label = label
|
||||
case ast.For_Stmt: n.label = label
|
||||
case ast.Switch_Stmt: n.label = label
|
||||
case ast.Type_Switch_Stmt: n.label = label
|
||||
case ast.Range_Stmt: n.label = label
|
||||
#partial switch n in stmt.derived_stmt {
|
||||
case ^ast.Block_Stmt: n.label = label
|
||||
case ^ast.If_Stmt: n.label = label
|
||||
case ^ast.For_Stmt: n.label = label
|
||||
case ^ast.Switch_Stmt: n.label = label
|
||||
case ^ast.Type_Switch_Stmt: n.label = label
|
||||
case ^ast.Range_Stmt: n.label = label
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -342,16 +342,16 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) {
|
||||
return
|
||||
}
|
||||
|
||||
switch v in &decl.derived {
|
||||
case Expr_Stmt:
|
||||
#partial switch v in decl.derived_stmt {
|
||||
case ^Expr_Stmt:
|
||||
move_line(p, decl.pos)
|
||||
visit_expr(p, v.expr)
|
||||
if p.config.semicolons {
|
||||
push_generic_token(p, .Semicolon, 0)
|
||||
}
|
||||
case When_Stmt:
|
||||
case ^When_Stmt:
|
||||
visit_stmt(p, cast(^Stmt)decl)
|
||||
case Foreign_Import_Decl:
|
||||
case ^Foreign_Import_Decl:
|
||||
if len(v.attributes) > 0 {
|
||||
sort.sort(sort_attribute(&v.attributes))
|
||||
move_line(p, v.attributes[0].pos)
|
||||
@@ -370,7 +370,7 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) {
|
||||
for path in v.fullpaths {
|
||||
push_ident_token(p, path, 0)
|
||||
}
|
||||
case Foreign_Block_Decl:
|
||||
case ^Foreign_Block_Decl:
|
||||
if len(v.attributes) > 0 {
|
||||
sort.sort(sort_attribute(&v.attributes))
|
||||
move_line(p, v.attributes[0].pos)
|
||||
@@ -383,7 +383,7 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) {
|
||||
|
||||
visit_expr(p, v.foreign_library)
|
||||
visit_stmt(p, v.body)
|
||||
case Import_Decl:
|
||||
case ^Import_Decl:
|
||||
move_line(p, decl.pos)
|
||||
|
||||
if v.name.text != "" {
|
||||
@@ -395,7 +395,7 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) {
|
||||
push_ident_token(p, v.fullpath, 1)
|
||||
}
|
||||
|
||||
case Value_Decl:
|
||||
case ^Value_Decl:
|
||||
if len(v.attributes) > 0 {
|
||||
sort.sort(sort_attribute(&v.attributes))
|
||||
move_line(p, v.attributes[0].pos)
|
||||
@@ -446,10 +446,10 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) {
|
||||
add_semicolon := true
|
||||
|
||||
for value in v.values {
|
||||
switch a in value.derived {
|
||||
case Union_Type, Enum_Type, Struct_Type:
|
||||
#partial switch a in value.derived {
|
||||
case ^Union_Type, ^Enum_Type, ^Struct_Type:
|
||||
add_semicolon = false || called_in_stmt
|
||||
case Proc_Lit:
|
||||
case ^Proc_Lit:
|
||||
add_semicolon = false
|
||||
}
|
||||
}
|
||||
@@ -516,23 +516,34 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
return
|
||||
}
|
||||
|
||||
switch v in stmt.derived {
|
||||
case Import_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
case Value_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
case Foreign_Import_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
case Foreign_Block_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
}
|
||||
|
||||
switch v in stmt.derived {
|
||||
case Using_Stmt:
|
||||
switch v in stmt.derived_stmt {
|
||||
case ^Bad_Stmt:
|
||||
case ^Bad_Decl:
|
||||
case ^Package_Decl:
|
||||
|
||||
case ^Empty_Stmt:
|
||||
push_generic_token(p, .Semicolon, 0)
|
||||
case ^Tag_Stmt:
|
||||
push_generic_token(p, .Hash, 1)
|
||||
push_generic_token(p, v.op.kind, 1, v.op.text)
|
||||
visit_stmt(p, v.stmt)
|
||||
|
||||
|
||||
case ^Import_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
case ^Value_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
case ^Foreign_Import_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
case ^Foreign_Block_Decl:
|
||||
visit_decl(p, cast(^Decl)stmt, true)
|
||||
return
|
||||
|
||||
case ^Using_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
push_generic_token(p, .Using, 1)
|
||||
@@ -542,7 +553,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
if p.config.semicolons {
|
||||
push_generic_token(p, .Semicolon, 0)
|
||||
}
|
||||
case Block_Stmt:
|
||||
case ^Block_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
if v.pos.line == v.end.line {
|
||||
@@ -572,7 +583,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
visit_end_brace(p, v.end)
|
||||
}
|
||||
}
|
||||
case If_Stmt:
|
||||
case ^If_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
if v.label != nil {
|
||||
@@ -595,7 +606,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
|
||||
uses_do := false
|
||||
|
||||
if check_stmt, ok := v.body.derived.(Block_Stmt); ok && check_stmt.uses_do {
|
||||
if check_stmt, ok := v.body.derived.(^Block_Stmt); ok && check_stmt.uses_do {
|
||||
uses_do = true
|
||||
}
|
||||
|
||||
@@ -626,7 +637,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
|
||||
visit_stmt(p, v.else_stmt)
|
||||
}
|
||||
case Switch_Stmt:
|
||||
case ^Switch_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
if v.label != nil {
|
||||
@@ -654,7 +665,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
|
||||
visit_expr(p, v.cond)
|
||||
visit_stmt(p, v.body)
|
||||
case Case_Clause:
|
||||
case ^Case_Clause:
|
||||
move_line(p, v.pos)
|
||||
|
||||
if !p.config.indent_cases {
|
||||
@@ -678,7 +689,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
if !p.config.indent_cases {
|
||||
indent(p)
|
||||
}
|
||||
case Type_Switch_Stmt:
|
||||
case ^Type_Switch_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
hint_current_line(p, {.Switch_Stmt})
|
||||
@@ -696,7 +707,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
|
||||
visit_stmt(p, v.tag)
|
||||
visit_stmt(p, v.body)
|
||||
case Assign_Stmt:
|
||||
case ^Assign_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
hint_current_line(p, {.Assign})
|
||||
@@ -710,13 +721,13 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
if block_stmt && p.config.semicolons {
|
||||
push_generic_token(p, .Semicolon, 0)
|
||||
}
|
||||
case Expr_Stmt:
|
||||
case ^Expr_Stmt:
|
||||
move_line(p, v.pos)
|
||||
visit_expr(p, v.expr)
|
||||
if block_stmt && p.config.semicolons {
|
||||
push_generic_token(p, .Semicolon, 0)
|
||||
}
|
||||
case For_Stmt:
|
||||
case ^For_Stmt:
|
||||
// this should be simplified
|
||||
move_line(p, v.pos)
|
||||
|
||||
@@ -753,7 +764,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
|
||||
visit_stmt(p, v.body)
|
||||
|
||||
case Inline_Range_Stmt:
|
||||
case ^Inline_Range_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
if v.label != nil {
|
||||
@@ -779,7 +790,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
visit_expr(p, v.expr)
|
||||
visit_stmt(p, v.body)
|
||||
|
||||
case Range_Stmt:
|
||||
case ^Range_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
if v.label != nil {
|
||||
@@ -805,7 +816,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
visit_expr(p, v.expr)
|
||||
|
||||
visit_stmt(p, v.body)
|
||||
case Return_Stmt:
|
||||
case ^Return_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
push_generic_token(p, .Return, 1)
|
||||
@@ -817,7 +828,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
if block_stmt && p.config.semicolons {
|
||||
push_generic_token(p, .Semicolon, 0)
|
||||
}
|
||||
case Defer_Stmt:
|
||||
case ^Defer_Stmt:
|
||||
move_line(p, v.pos)
|
||||
push_generic_token(p, .Defer, 0)
|
||||
|
||||
@@ -826,7 +837,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
if p.config.semicolons {
|
||||
push_generic_token(p, .Semicolon, 0)
|
||||
}
|
||||
case When_Stmt:
|
||||
case ^When_Stmt:
|
||||
move_line(p, v.pos)
|
||||
push_generic_token(p, .When, 1)
|
||||
visit_expr(p, v.cond)
|
||||
@@ -846,7 +857,7 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
visit_stmt(p, v.else_stmt)
|
||||
}
|
||||
|
||||
case Branch_Stmt:
|
||||
case ^Branch_Stmt:
|
||||
move_line(p, v.pos)
|
||||
|
||||
push_generic_token(p, v.tok.kind, 0)
|
||||
@@ -918,8 +929,15 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
|
||||
set_source_position(p, expr.pos)
|
||||
|
||||
switch v in expr.derived {
|
||||
case Inline_Asm_Expr:
|
||||
switch v in expr.derived_expr {
|
||||
case ^Bad_Expr:
|
||||
|
||||
case ^Tag_Expr:
|
||||
push_generic_token(p, .Hash, 1)
|
||||
push_generic_token(p, v.op.kind, 1, v.op.text)
|
||||
visit_expr(p, v.expr)
|
||||
|
||||
case ^Inline_Asm_Expr:
|
||||
push_generic_token(p, v.tok.kind, 1, v.tok.text)
|
||||
|
||||
push_generic_token(p, .Open_Paren, 1)
|
||||
@@ -936,42 +954,42 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
push_generic_token(p, .Comma, 0)
|
||||
visit_expr(p, v.constraints_string)
|
||||
push_generic_token(p, .Close_Brace, 0)
|
||||
case Undef:
|
||||
case ^Undef:
|
||||
push_generic_token(p, .Undef, 1)
|
||||
case Auto_Cast:
|
||||
case ^Auto_Cast:
|
||||
push_generic_token(p, v.op.kind, 1)
|
||||
visit_expr(p, v.expr)
|
||||
case Ternary_If_Expr:
|
||||
case ^Ternary_If_Expr:
|
||||
visit_expr(p, v.x)
|
||||
push_generic_token(p, v.op1.kind, 1)
|
||||
visit_expr(p, v.cond)
|
||||
push_generic_token(p, v.op2.kind, 1)
|
||||
visit_expr(p, v.y)
|
||||
case Ternary_When_Expr:
|
||||
case ^Ternary_When_Expr:
|
||||
visit_expr(p, v.x)
|
||||
push_generic_token(p, v.op1.kind, 1)
|
||||
visit_expr(p, v.cond)
|
||||
push_generic_token(p, v.op2.kind, 1)
|
||||
visit_expr(p, v.y)
|
||||
case Or_Else_Expr:
|
||||
case ^Or_Else_Expr:
|
||||
visit_expr(p, v.x)
|
||||
push_generic_token(p, v.token.kind, 1)
|
||||
visit_expr(p, v.y)
|
||||
case Or_Return_Expr:
|
||||
case ^Or_Return_Expr:
|
||||
visit_expr(p, v.expr)
|
||||
push_generic_token(p, v.token.kind, 1)
|
||||
case Selector_Call_Expr:
|
||||
case ^Selector_Call_Expr:
|
||||
visit_expr(p, v.call.expr)
|
||||
push_generic_token(p, .Open_Paren, 1)
|
||||
visit_exprs(p, v.call.args, {.Add_Comma})
|
||||
push_generic_token(p, .Close_Paren, 0)
|
||||
case Ellipsis:
|
||||
case ^Ellipsis:
|
||||
push_generic_token(p, .Ellipsis, 1)
|
||||
visit_expr(p, v.expr)
|
||||
case Relative_Type:
|
||||
case ^Relative_Type:
|
||||
visit_expr(p, v.tag)
|
||||
visit_expr(p, v.type)
|
||||
case Slice_Expr:
|
||||
case ^Slice_Expr:
|
||||
visit_expr(p, v.expr)
|
||||
push_generic_token(p, .Open_Bracket, 0)
|
||||
visit_expr(p, v.low)
|
||||
@@ -981,37 +999,37 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
visit_expr(p, v.high)
|
||||
}
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
case Ident:
|
||||
case ^Ident:
|
||||
if .Enforce_Poly_Names in options {
|
||||
push_generic_token(p, .Dollar, 1)
|
||||
push_ident_token(p, v.name, 0)
|
||||
} else {
|
||||
push_ident_token(p, v.name, 1)
|
||||
}
|
||||
case Deref_Expr:
|
||||
case ^Deref_Expr:
|
||||
visit_expr(p, v.expr)
|
||||
push_generic_token(p, v.op.kind, 0)
|
||||
case Type_Cast:
|
||||
case ^Type_Cast:
|
||||
push_generic_token(p, v.tok.kind, 1)
|
||||
push_generic_token(p, .Open_Paren, 0)
|
||||
visit_expr(p, v.type)
|
||||
push_generic_token(p, .Close_Paren, 0)
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.expr)
|
||||
case Basic_Directive:
|
||||
case ^Basic_Directive:
|
||||
push_generic_token(p, v.tok.kind, 1)
|
||||
push_ident_token(p, v.name, 0)
|
||||
case Distinct_Type:
|
||||
case ^Distinct_Type:
|
||||
push_generic_token(p, .Distinct, 1)
|
||||
visit_expr(p, v.type)
|
||||
case Dynamic_Array_Type:
|
||||
case ^Dynamic_Array_Type:
|
||||
visit_expr(p, v.tag)
|
||||
push_generic_token(p, .Open_Bracket, 1)
|
||||
push_generic_token(p, .Dynamic, 0)
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.elem)
|
||||
case Bit_Set_Type:
|
||||
case ^Bit_Set_Type:
|
||||
push_generic_token(p, .Bit_Set, 1)
|
||||
push_generic_token(p, .Open_Bracket, 0)
|
||||
|
||||
@@ -1023,7 +1041,7 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
}
|
||||
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
case Union_Type:
|
||||
case ^Union_Type:
|
||||
push_generic_token(p, .Union, 1)
|
||||
|
||||
push_poly_params(p, v.poly_params)
|
||||
@@ -1045,7 +1063,7 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
visit_exprs(p, v.variants, {.Add_Comma, .Trailing})
|
||||
visit_end_brace(p, v.end)
|
||||
}
|
||||
case Enum_Type:
|
||||
case ^Enum_Type:
|
||||
push_generic_token(p, .Enum, 1)
|
||||
|
||||
hint_current_line(p, {.Enum})
|
||||
@@ -1068,7 +1086,7 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
}
|
||||
|
||||
set_source_position(p, v.end)
|
||||
case Struct_Type:
|
||||
case ^Struct_Type:
|
||||
push_generic_token(p, .Struct, 1)
|
||||
|
||||
hint_current_line(p, {.Struct})
|
||||
@@ -1103,7 +1121,7 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
}
|
||||
|
||||
set_source_position(p, v.end)
|
||||
case Proc_Lit:
|
||||
case ^Proc_Lit:
|
||||
switch v.inlining {
|
||||
case .None:
|
||||
case .Inline:
|
||||
@@ -1112,7 +1130,7 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
push_ident_token(p, "#force_no_inline", 0)
|
||||
}
|
||||
|
||||
visit_proc_type(p, v.type^, true)
|
||||
visit_proc_type(p, v.type, true)
|
||||
|
||||
push_where_clauses(p, v.where_clauses)
|
||||
|
||||
@@ -1122,16 +1140,16 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
} else {
|
||||
push_generic_token(p, .Undef, 1)
|
||||
}
|
||||
case Proc_Type:
|
||||
case ^Proc_Type:
|
||||
visit_proc_type(p, v)
|
||||
case Basic_Lit:
|
||||
case ^Basic_Lit:
|
||||
push_generic_token(p, v.tok.kind, 1, v.tok.text)
|
||||
case Binary_Expr:
|
||||
case ^Binary_Expr:
|
||||
visit_binary_expr(p, v)
|
||||
case Implicit_Selector_Expr:
|
||||
case ^Implicit_Selector_Expr:
|
||||
push_generic_token(p, .Period, 1)
|
||||
push_ident_token(p, v.field.name, 0)
|
||||
case Call_Expr:
|
||||
case ^Call_Expr:
|
||||
visit_expr(p, v.expr)
|
||||
|
||||
push_format_token(p,
|
||||
@@ -1146,27 +1164,34 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
|
||||
visit_call_exprs(p, v.args, v.ellipsis.kind == .Ellipsis)
|
||||
push_generic_token(p, .Close_Paren, 0)
|
||||
case Typeid_Type:
|
||||
case ^Typeid_Type:
|
||||
push_generic_token(p, .Typeid, 1)
|
||||
|
||||
if v.specialization != nil {
|
||||
push_generic_token(p, .Quo, 0)
|
||||
visit_expr(p, v.specialization)
|
||||
}
|
||||
case Selector_Expr:
|
||||
case ^Selector_Expr:
|
||||
visit_expr(p, v.expr)
|
||||
push_generic_token(p, v.op.kind, 0)
|
||||
visit_expr(p, v.field)
|
||||
case Paren_Expr:
|
||||
case ^Paren_Expr:
|
||||
push_generic_token(p, .Open_Paren, 1)
|
||||
visit_expr(p, v.expr)
|
||||
push_generic_token(p, .Close_Paren, 0)
|
||||
case Index_Expr:
|
||||
case ^Index_Expr:
|
||||
visit_expr(p, v.expr)
|
||||
push_generic_token(p, .Open_Bracket, 0)
|
||||
visit_expr(p, v.index)
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
case Proc_Group:
|
||||
case ^Matrix_Index_Expr:
|
||||
visit_expr(p, v.expr)
|
||||
push_generic_token(p, .Open_Bracket, 0)
|
||||
visit_expr(p, v.row_index)
|
||||
push_generic_token(p, .Comma, 0)
|
||||
visit_expr(p, v.column_index)
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
case ^Proc_Group:
|
||||
push_generic_token(p, v.tok.kind, 1)
|
||||
|
||||
if len(v.args) != 0 && v.pos.line != v.args[len(v.args) - 1].pos.line {
|
||||
@@ -1181,7 +1206,7 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
push_generic_token(p, .Close_Brace, 0)
|
||||
}
|
||||
|
||||
case Comp_Lit:
|
||||
case ^Comp_Lit:
|
||||
if v.type != nil {
|
||||
visit_expr(p, v.type)
|
||||
}
|
||||
@@ -1198,18 +1223,18 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
push_generic_token(p, .Close_Brace, 0)
|
||||
}
|
||||
|
||||
case Unary_Expr:
|
||||
case ^Unary_Expr:
|
||||
push_generic_token(p, v.op.kind, 1)
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.expr)
|
||||
case Field_Value:
|
||||
case ^Field_Value:
|
||||
visit_expr(p, v.field)
|
||||
push_generic_token(p, .Eq, 1)
|
||||
visit_expr(p, v.value)
|
||||
case Type_Assertion:
|
||||
case ^Type_Assertion:
|
||||
visit_expr(p, v.expr)
|
||||
|
||||
if unary, ok := v.type.derived.(Unary_Expr); ok && unary.op.text == "?" {
|
||||
if unary, ok := v.type.derived.(^Unary_Expr); ok && unary.op.text == "?" {
|
||||
push_generic_token(p, .Period, 0)
|
||||
visit_expr(p, v.type)
|
||||
} else {
|
||||
@@ -1219,13 +1244,13 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
push_generic_token(p, .Close_Paren, 0)
|
||||
}
|
||||
|
||||
case Pointer_Type:
|
||||
case ^Pointer_Type:
|
||||
push_generic_token(p, .Pointer, 1)
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.elem)
|
||||
case Implicit:
|
||||
case ^Implicit:
|
||||
push_generic_token(p, v.tok.kind, 1)
|
||||
case Poly_Type:
|
||||
case ^Poly_Type:
|
||||
push_generic_token(p, .Dollar, 1)
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.type)
|
||||
@@ -1235,22 +1260,35 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, options := List_Options{}) {
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.specialization)
|
||||
}
|
||||
case Array_Type:
|
||||
case ^Array_Type:
|
||||
visit_expr(p, v.tag)
|
||||
push_generic_token(p, .Open_Bracket, 1)
|
||||
visit_expr(p, v.len)
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.elem)
|
||||
case Map_Type:
|
||||
case ^Map_Type:
|
||||
push_generic_token(p, .Map, 1)
|
||||
push_generic_token(p, .Open_Bracket, 0)
|
||||
visit_expr(p, v.key)
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
merge_next_token(p)
|
||||
visit_expr(p, v.value)
|
||||
case Helper_Type:
|
||||
case ^Helper_Type:
|
||||
visit_expr(p, v.type)
|
||||
case ^Multi_Pointer_Type:
|
||||
push_generic_token(p, .Open_Bracket, 1)
|
||||
push_generic_token(p, .Pointer, 0)
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
visit_expr(p, v.elem)
|
||||
case ^Matrix_Type:
|
||||
push_generic_token(p, .Matrix, 1)
|
||||
push_generic_token(p, .Open_Bracket, 0)
|
||||
visit_expr(p, v.row_count)
|
||||
push_generic_token(p, .Comma, 0)
|
||||
visit_expr(p, v.column_count)
|
||||
push_generic_token(p, .Close_Bracket, 0)
|
||||
visit_expr(p, v.elem)
|
||||
case:
|
||||
panic(fmt.aprint(expr.derived))
|
||||
}
|
||||
@@ -1348,7 +1386,7 @@ visit_field_list :: proc(p: ^Printer, list: ^ast.Field_List, options := List_Opt
|
||||
}
|
||||
}
|
||||
|
||||
visit_proc_type :: proc(p: ^Printer, proc_type: ast.Proc_Type, is_proc_lit := false) {
|
||||
visit_proc_type :: proc(p: ^Printer, proc_type: ^ast.Proc_Type, is_proc_lit := false) {
|
||||
if is_proc_lit {
|
||||
push_format_token(p, Format_Token {
|
||||
kind = .Proc,
|
||||
@@ -1392,7 +1430,7 @@ visit_proc_type :: proc(p: ^Printer, proc_type: ast.Proc_Type, is_proc_lit := fa
|
||||
} else if len(proc_type.results.list) == 1 {
|
||||
|
||||
for name in proc_type.results.list[0].names {
|
||||
if ident, ok := name.derived.(ast.Ident); ok {
|
||||
if ident, ok := name.derived.(^ast.Ident); ok {
|
||||
if ident.name != "_" {
|
||||
use_parens = true
|
||||
}
|
||||
@@ -1410,19 +1448,19 @@ visit_proc_type :: proc(p: ^Printer, proc_type: ast.Proc_Type, is_proc_lit := fa
|
||||
}
|
||||
}
|
||||
|
||||
visit_binary_expr :: proc(p: ^Printer, binary: ast.Binary_Expr) {
|
||||
visit_binary_expr :: proc(p: ^Printer, binary: ^ast.Binary_Expr) {
|
||||
move_line(p, binary.left.pos)
|
||||
|
||||
if v, ok := binary.left.derived.(ast.Binary_Expr); ok {
|
||||
if v, ok := binary.left.derived.(^ast.Binary_Expr); ok {
|
||||
visit_binary_expr(p, v)
|
||||
} else {
|
||||
visit_expr(p, binary.left)
|
||||
}
|
||||
|
||||
either_implicit_selector := false
|
||||
if _, ok := binary.left.derived.(ast.Implicit_Selector_Expr); ok {
|
||||
if _, ok := binary.left.derived.(^ast.Implicit_Selector_Expr); ok {
|
||||
either_implicit_selector = true
|
||||
} else if _, ok := binary.right.derived.(ast.Implicit_Selector_Expr); ok {
|
||||
} else if _, ok := binary.right.derived.(^ast.Implicit_Selector_Expr); ok {
|
||||
either_implicit_selector = true
|
||||
}
|
||||
|
||||
@@ -1439,7 +1477,7 @@ visit_binary_expr :: proc(p: ^Printer, binary: ast.Binary_Expr) {
|
||||
move_line(p, binary.right.pos)
|
||||
|
||||
|
||||
if v, ok := binary.right.derived.(ast.Binary_Expr); ok {
|
||||
if v, ok := binary.right.derived.(^ast.Binary_Expr); ok {
|
||||
visit_binary_expr(p, v)
|
||||
} else {
|
||||
visit_expr(p, binary.right)
|
||||
@@ -1499,7 +1537,7 @@ visit_signature_list :: proc(p: ^Printer, list: ^ast.Field_List, remove_blank :=
|
||||
named := false
|
||||
|
||||
for name in field.names {
|
||||
if ident, ok := name.derived.(ast.Ident); ok {
|
||||
if ident, ok := name.derived.(^ast.Ident); ok {
|
||||
//for some reason the parser uses _ to mean empty
|
||||
if ident.name != "_" || !remove_blank {
|
||||
named = true
|
||||
|
||||
@@ -132,26 +132,11 @@ cleanpath_strip_prefix :: proc(buf: []u16) -> []u16 {
|
||||
|
||||
@(private)
|
||||
cleanpath_from_handle :: proc(fd: Handle) -> (string, Errno) {
|
||||
if fd == 0 {
|
||||
return "", ERROR_INVALID_HANDLE
|
||||
buf, err := cleanpath_from_handle_u16(fd)
|
||||
if err != 0 {
|
||||
return "", err
|
||||
}
|
||||
h := win32.HANDLE(fd)
|
||||
|
||||
MAX_PATH := win32.DWORD(260) + 1
|
||||
buf: []u16
|
||||
for {
|
||||
buf = make([]u16, MAX_PATH, context.temp_allocator)
|
||||
err := win32.GetFinalPathNameByHandleW(h, raw_data(buf), MAX_PATH, 0)
|
||||
switch Errno(err) {
|
||||
case ERROR_PATH_NOT_FOUND, ERROR_INVALID_PARAMETER:
|
||||
return "", Errno(err)
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
MAX_PATH = MAX_PATH*2 + 1
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
return cleanpath_from_buf(buf), ERROR_NONE
|
||||
return win32.utf16_to_utf8(buf, context.allocator), err
|
||||
}
|
||||
@(private)
|
||||
cleanpath_from_handle_u16 :: proc(fd: Handle) -> ([]u16, Errno) {
|
||||
@@ -160,21 +145,13 @@ cleanpath_from_handle_u16 :: proc(fd: Handle) -> ([]u16, Errno) {
|
||||
}
|
||||
h := win32.HANDLE(fd)
|
||||
|
||||
MAX_PATH := win32.DWORD(260) + 1
|
||||
buf: []u16
|
||||
for {
|
||||
buf = make([]u16, MAX_PATH, context.temp_allocator)
|
||||
err := win32.GetFinalPathNameByHandleW(h, raw_data(buf), MAX_PATH, 0)
|
||||
switch Errno(err) {
|
||||
case ERROR_PATH_NOT_FOUND, ERROR_INVALID_PARAMETER:
|
||||
return nil, Errno(err)
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
MAX_PATH = MAX_PATH*2 + 1
|
||||
continue
|
||||
}
|
||||
break
|
||||
n := win32.GetFinalPathNameByHandleW(h, nil, 0, 0)
|
||||
if n == 0 {
|
||||
return nil, Errno(win32.GetLastError())
|
||||
}
|
||||
return cleanpath_strip_prefix(buf), ERROR_NONE
|
||||
buf := make([]u16, max(n, win32.DWORD(260))+1, context.temp_allocator)
|
||||
buf_len := win32.GetFinalPathNameByHandleW(h, raw_data(buf), n, 0)
|
||||
return buf[:buf_len], ERROR_NONE
|
||||
}
|
||||
@(private)
|
||||
cleanpath_from_buf :: proc(buf: []u16) -> string {
|
||||
|
||||
@@ -365,6 +365,19 @@ index :: proc(val: any, i: int, loc := #caller_location) -> any {
|
||||
return nil
|
||||
}
|
||||
|
||||
deref :: proc(val: any) -> any {
|
||||
if val != nil {
|
||||
ti := type_info_base(type_info_of(val.id))
|
||||
if info, ok := ti.variant.(Type_Info_Pointer); ok {
|
||||
return any{
|
||||
(^rawptr)(val.data)^,
|
||||
info.elem.id,
|
||||
}
|
||||
}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Struct_Tag represents the type of the string of a struct field
|
||||
@@ -680,7 +693,6 @@ union_variant_typeid :: proc(a: any) -> typeid {
|
||||
return nil
|
||||
}
|
||||
panic("expected a union to reflect.union_variant_typeid")
|
||||
|
||||
}
|
||||
|
||||
get_union_variant_raw_tag :: proc(a: any) -> i64 {
|
||||
|
||||
@@ -304,7 +304,7 @@ filter :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator) -
|
||||
return r[:]
|
||||
}
|
||||
|
||||
scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U)->V, allocator := context.allocator) -> []V {
|
||||
scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U) -> V, allocator := context.allocator) -> []V {
|
||||
if len(s) == 0 { return {} }
|
||||
|
||||
res := make([]V, len(s), allocator)
|
||||
@@ -344,15 +344,106 @@ max :: proc(s: $S/[]$T) -> (res: T, ok: bool) where intrinsics.type_is_ordered(T
|
||||
return
|
||||
}
|
||||
|
||||
min_max :: proc(s: $S/[]$T) -> (min, max: T, ok: bool) where intrinsics.type_is_ordered(T) {
|
||||
if len(s) != 0 {
|
||||
min, max = s[0], s[0]
|
||||
ok = true
|
||||
for v in s[1:] {
|
||||
min = builtin.min(min, v)
|
||||
max = builtin.max(max, v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
dot_product :: proc(a, b: $S/[]$T) -> T
|
||||
any_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable(T) {
|
||||
for v in s {
|
||||
if v == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
none_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable(T) {
|
||||
for v in s {
|
||||
if v == value {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
all_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable(T) {
|
||||
if len(s) == 0 {
|
||||
return false
|
||||
}
|
||||
for v in s {
|
||||
if v != value {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
any_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool {
|
||||
for v in s {
|
||||
if f(v) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
none_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool {
|
||||
for v in s {
|
||||
if f(v) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
all_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool {
|
||||
if len(s) == 0 {
|
||||
return false
|
||||
}
|
||||
for v in s {
|
||||
if !f(v) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
count :: proc(s: $S/[]$T, value: T) -> (n: int) where intrinsics.type_is_comparable(T) {
|
||||
for v in s {
|
||||
if v == value {
|
||||
n += 1
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
count_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> (n: int) {
|
||||
for v in s {
|
||||
if f(v) {
|
||||
n += 1
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
dot_product :: proc(a, b: $S/[]$T) -> (r: T, ok: bool)
|
||||
where intrinsics.type_is_numeric(T) {
|
||||
if len(a) != len(b) {
|
||||
panic("slice.dot_product: slices of unequal length")
|
||||
return
|
||||
}
|
||||
r: T
|
||||
#no_bounds_check for _, i in a {
|
||||
r += a[i] * b[i]
|
||||
}
|
||||
return r
|
||||
return r, true
|
||||
}
|
||||
|
||||
@@ -895,6 +895,7 @@ unquote_string :: proc(lit: string, allocator := context.allocator) -> (res: str
|
||||
if s == `""` {
|
||||
return "", false, true
|
||||
}
|
||||
s = s[1:len(s)-1]
|
||||
|
||||
if contains_rune(s, '\n') >= 0 {
|
||||
return s, false, false
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
//+build windows
|
||||
package all
|
||||
|
||||
import botan "vendor:botan"
|
||||
@@ -16,24 +15,12 @@ import IMG "vendor:sdl2/image"
|
||||
import MIX "vendor:sdl2/mixer"
|
||||
import TTF "vendor:sdl2/ttf"
|
||||
|
||||
import stb_easy_font "vendor:stb/easy_font"
|
||||
import stbi "vendor:stb/image"
|
||||
import stbrp "vendor:stb/rect_pack"
|
||||
import stbtt "vendor:stb/truetype"
|
||||
import stb_vorbis "vendor:stb/vorbis"
|
||||
|
||||
import vk "vendor:vulkan"
|
||||
|
||||
import D3D11 "vendor:directx/d3d11"
|
||||
import D3D12 "vendor:directx/d3d12"
|
||||
import DXGI "vendor:directx/dxgi"
|
||||
|
||||
// note these are technicaly darwin only but they are added to aid with documentation generation
|
||||
import NS "vendor:darwin/Foundation"
|
||||
import MTL "vendor:darwin/Metal"
|
||||
import CA "vendor:darwin/QuartzCore"
|
||||
|
||||
|
||||
_ :: botan
|
||||
_ :: ENet
|
||||
_ :: gl
|
||||
@@ -47,15 +34,7 @@ _ :: SDLNet
|
||||
_ :: IMG
|
||||
_ :: MIX
|
||||
_ :: TTF
|
||||
_ :: stb_easy_font
|
||||
_ :: stbi
|
||||
_ :: stbrp
|
||||
_ :: stbtt
|
||||
_ :: stb_vorbis
|
||||
_ :: vk
|
||||
_ :: D3D11
|
||||
_ :: D3D12
|
||||
_ :: DXGI
|
||||
_ :: NS
|
||||
_ :: MTL
|
||||
_ :: CA
|
||||
_ :: CA
|
||||
|
||||
10
examples/all/all_vendor_directx.odin
Normal file
10
examples/all/all_vendor_directx.odin
Normal file
@@ -0,0 +1,10 @@
|
||||
//+build windows
|
||||
package all
|
||||
|
||||
import D3D11 "vendor:directx/d3d11"
|
||||
import D3D12 "vendor:directx/d3d12"
|
||||
import DXGI "vendor:directx/dxgi"
|
||||
|
||||
_ :: D3D11
|
||||
_ :: D3D12
|
||||
_ :: DXGI
|
||||
15
examples/all/all_vendor_stl.odin
Normal file
15
examples/all/all_vendor_stl.odin
Normal file
@@ -0,0 +1,15 @@
|
||||
//+build windows, linux
|
||||
package all
|
||||
|
||||
import stb_easy_font "vendor:stb/easy_font"
|
||||
import stbi "vendor:stb/image"
|
||||
import stbrp "vendor:stb/rect_pack"
|
||||
import stbtt "vendor:stb/truetype"
|
||||
import stb_vorbis "vendor:stb/vorbis"
|
||||
|
||||
_ :: stb_easy_font
|
||||
_ :: stbi
|
||||
_ :: stbrp
|
||||
_ :: stbtt
|
||||
_ :: stb_vorbis
|
||||
|
||||
@@ -280,7 +280,7 @@ bool global_ignore_warnings(void) {
|
||||
}
|
||||
|
||||
|
||||
gb_global TargetMetrics target_windows_386 = {
|
||||
gb_global TargetMetrics target_windows_i386 = {
|
||||
TargetOs_windows,
|
||||
TargetArch_i386,
|
||||
4,
|
||||
@@ -296,7 +296,7 @@ gb_global TargetMetrics target_windows_amd64 = {
|
||||
str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_linux_386 = {
|
||||
gb_global TargetMetrics target_linux_i386 = {
|
||||
TargetOs_linux,
|
||||
TargetArch_i386,
|
||||
4,
|
||||
@@ -339,7 +339,7 @@ gb_global TargetMetrics target_darwin_arm64 = {
|
||||
str_lit("e-m:o-i64:64-i128:128-n32:64-S128"), // TODO(bill): Is this correct?
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_freebsd_386 = {
|
||||
gb_global TargetMetrics target_freebsd_i386 = {
|
||||
TargetOs_freebsd,
|
||||
TargetArch_i386,
|
||||
4,
|
||||
@@ -421,12 +421,12 @@ gb_global NamedTargetMetrics named_targets[] = {
|
||||
{ str_lit("darwin_amd64"), &target_darwin_amd64 },
|
||||
{ str_lit("darwin_arm64"), &target_darwin_arm64 },
|
||||
{ str_lit("essence_amd64"), &target_essence_amd64 },
|
||||
{ str_lit("linux_386"), &target_linux_386 },
|
||||
{ str_lit("linux_i386"), &target_linux_i386 },
|
||||
{ str_lit("linux_amd64"), &target_linux_amd64 },
|
||||
{ str_lit("linux_arm64"), &target_linux_arm64 },
|
||||
{ str_lit("windows_386"), &target_windows_386 },
|
||||
{ str_lit("windows_i386"), &target_windows_i386 },
|
||||
{ str_lit("windows_amd64"), &target_windows_amd64 },
|
||||
{ str_lit("freebsd_386"), &target_freebsd_386 },
|
||||
{ str_lit("freebsd_i386"), &target_freebsd_i386 },
|
||||
{ str_lit("freebsd_amd64"), &target_freebsd_amd64 },
|
||||
{ str_lit("openbsd_amd64"), &target_openbsd_amd64 },
|
||||
{ str_lit("freestanding_wasm32"), &target_freestanding_wasm32 },
|
||||
@@ -971,13 +971,13 @@ void init_build_context(TargetMetrics *cross_target) {
|
||||
#endif
|
||||
#else
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
metrics = &target_windows_386;
|
||||
metrics = &target_windows_i386;
|
||||
#elif defined(GB_SYSTEM_OSX)
|
||||
#error "Build Error: Unsupported architecture"
|
||||
#elif defined(GB_SYSTEM_FREEBSD)
|
||||
metrics = &target_freebsd_386;
|
||||
metrics = &target_freebsd_i386;
|
||||
#else
|
||||
metrics = &target_linux_386;
|
||||
metrics = &target_linux_i386;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -952,7 +952,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
|
||||
mode = Addressing_Constant;
|
||||
value = exact_value_i64(at->EnumeratedArray.count);
|
||||
type = t_untyped_integer;
|
||||
} else if (is_type_slice(op_type) && id == BuiltinProc_len) {
|
||||
} else if ((is_type_slice(op_type) || is_type_relative_slice(op_type)) && id == BuiltinProc_len) {
|
||||
mode = Addressing_Value;
|
||||
} else if (is_type_dynamic_array(op_type)) {
|
||||
mode = Addressing_Value;
|
||||
|
||||
@@ -1042,7 +1042,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
|
||||
return lb_string_len(p, v);
|
||||
} else if (is_type_array(t)) {
|
||||
GB_PANIC("Array lengths are constant");
|
||||
} else if (is_type_slice(t)) {
|
||||
} else if (is_type_slice(t) || is_type_relative_slice(t)) {
|
||||
return lb_slice_len(p, v);
|
||||
} else if (is_type_dynamic_array(t)) {
|
||||
return lb_dynamic_array_len(p, v);
|
||||
@@ -1068,7 +1068,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
|
||||
GB_PANIC("Unreachable");
|
||||
} else if (is_type_array(t)) {
|
||||
GB_PANIC("Array lengths are constant");
|
||||
} else if (is_type_slice(t)) {
|
||||
} else if (is_type_slice(t) || is_type_relative_slice(t)) {
|
||||
return lb_slice_len(p, v);
|
||||
} else if (is_type_dynamic_array(t)) {
|
||||
return lb_dynamic_array_cap(p, v);
|
||||
|
||||
@@ -1373,7 +1373,7 @@ lbValue lb_slice_elem(lbProcedure *p, lbValue slice) {
|
||||
return lb_emit_struct_ev(p, slice, 0);
|
||||
}
|
||||
lbValue lb_slice_len(lbProcedure *p, lbValue slice) {
|
||||
GB_ASSERT(is_type_slice(slice.type));
|
||||
GB_ASSERT(is_type_slice(slice.type) || is_type_relative_slice(slice.type));
|
||||
return lb_emit_struct_ev(p, slice, 1);
|
||||
}
|
||||
lbValue lb_dynamic_array_elem(lbProcedure *p, lbValue da) {
|
||||
|
||||
61
src/main.cpp
61
src/main.cpp
@@ -406,8 +406,8 @@ i32 linker_stage(lbGenerator *gen) {
|
||||
// available at runtime wherever the executable is run, so we make require those to be
|
||||
// local to the executable (unless the system collection is used, in which case we search
|
||||
// the system library paths for the library file).
|
||||
if (string_ends_with(lib, str_lit(".a"))) {
|
||||
// static libs, absolute full path relative to the file in which the lib was imported from
|
||||
if (string_ends_with(lib, str_lit(".a")) || string_ends_with(lib, str_lit(".o"))) {
|
||||
// static libs and object files, absolute full path relative to the file in which the lib was imported from
|
||||
lib_str = gb_string_append_fmt(lib_str, " -l:\"%.*s\" ", LIT(lib));
|
||||
} else if (string_ends_with(lib, str_lit(".so"))) {
|
||||
// dynamic lib, relative path to executable
|
||||
@@ -475,34 +475,39 @@ i32 linker_stage(lbGenerator *gen) {
|
||||
}
|
||||
}
|
||||
|
||||
result = system_exec_command_line_app("ld-link",
|
||||
"clang -Wno-unused-command-line-argument %s -o \"%.*s%.*s\" %s "
|
||||
" %s "
|
||||
" %.*s "
|
||||
" %.*s "
|
||||
" %s "
|
||||
#if defined(GB_SYSTEM_OSX)
|
||||
// This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit.
|
||||
// NOTE: If you change this (although this minimum is as low as you can go with Odin working)
|
||||
// make sure to also change the 'mtriple' param passed to 'opt'
|
||||
#if defined(GB_CPU_ARM)
|
||||
" -mmacosx-version-min=12.0.0 "
|
||||
#else
|
||||
" -mmacosx-version-min=10.8.0 "
|
||||
#endif
|
||||
// This points the linker to where the entry point is
|
||||
" -e _main "
|
||||
#endif
|
||||
, object_files, LIT(output_base), LIT(output_ext),
|
||||
#if defined(GB_SYSTEM_OSX)
|
||||
"-lSystem -lm -Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib",
|
||||
gbString platform_lib_str = gb_string_make(heap_allocator(), "");
|
||||
defer (gb_string_free(platform_lib_str));
|
||||
#if defined(GB_SYSTEM_OSX)
|
||||
platform_lib_str = gb_string_appendc(platform_lib_str, "-lSystem -lm -Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib");
|
||||
#else
|
||||
platform_lib_str = gb_string_appendc(platform_lib_str, "-lc -lm");
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_OSX)
|
||||
// This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit.
|
||||
// NOTE: If you change this (although this minimum is as low as you can go with Odin working)
|
||||
// make sure to also change the 'mtriple' param passed to 'opt'
|
||||
#if defined(GB_CPU_ARM)
|
||||
link_settings = gb_string_appendc(link_settings, " -mmacosx-version-min=12.0.0 ");
|
||||
#else
|
||||
"-lc -lm",
|
||||
link_settings = gb_string_appendc(link_settings, " -mmacosx-version-min=10.8.0 ");
|
||||
#endif
|
||||
lib_str,
|
||||
LIT(build_context.link_flags),
|
||||
LIT(build_context.extra_linker_flags),
|
||||
link_settings);
|
||||
// This points the linker to where the entry point is
|
||||
link_settings = gb_string_appendc(link_settings, " -e _main ");
|
||||
#endif
|
||||
|
||||
gbString link_command_line = gb_string_make(heap_allocator(), "clang -Wno-unused-command-line-argument ");
|
||||
defer (gb_string_free(link_command_line));
|
||||
|
||||
link_command_line = gb_string_appendc(link_command_line, object_files);
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " -o \"%.*s%.*s\" ", LIT(output_base), LIT(output_ext));
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " %s ", platform_lib_str);
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " %s ", lib_str);
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " %.*s ", LIT(build_context.link_flags));
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " %.*s ", LIT(build_context.extra_linker_flags));
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " %s ", link_settings);
|
||||
|
||||
result = system_exec_command_line_app("ld-link", link_command_line);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
|
||||
@@ -1538,7 +1538,7 @@ void fix_advance_to_next_stmt(AstFile *f) {
|
||||
Token expect_closing(AstFile *f, TokenKind kind, String context) {
|
||||
if (f->curr_token.kind != kind &&
|
||||
f->curr_token.kind == Token_Semicolon &&
|
||||
f->curr_token.string == "\n") {
|
||||
(f->curr_token.string == "\n" || f->curr_token.kind == Token_EOF)) {
|
||||
Token tok = f->prev_token;
|
||||
tok.pos.column += cast(i32)tok.string.len;
|
||||
syntax_error(tok, "Missing ',' before newline in %.*s", LIT(context));
|
||||
@@ -1560,6 +1560,7 @@ void assign_removal_flag_to_semicolon(AstFile *f) {
|
||||
switch (curr_token->kind) {
|
||||
case Token_CloseBrace:
|
||||
case Token_CloseParen:
|
||||
case Token_EOF:
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ main :: proc() {
|
||||
gzip_test(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
|
||||
@@ -37,6 +37,7 @@ import "core:crypto/jh"
|
||||
import "core:crypto/groestl"
|
||||
import "core:crypto/haval"
|
||||
import "core:crypto/siphash"
|
||||
import "core:os"
|
||||
|
||||
TEST_count := 0
|
||||
TEST_fail := 0
|
||||
@@ -127,6 +128,9 @@ main :: proc() {
|
||||
bench_modern(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
TestHash :: struct {
|
||||
|
||||
@@ -3,6 +3,7 @@ package test_core_json
|
||||
import "core:encoding/json"
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
|
||||
TEST_count := 0
|
||||
TEST_fail := 0
|
||||
@@ -34,6 +35,9 @@ main :: proc() {
|
||||
marshal_json(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
|
||||
@@ -5,6 +5,7 @@ import "core:hash"
|
||||
import "core:time"
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
|
||||
TEST_count := 0
|
||||
TEST_fail := 0
|
||||
@@ -35,6 +36,9 @@ main :: proc() {
|
||||
test_xxhash_vectors(&t)
|
||||
test_crc64_vectors(&t)
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -57,6 +57,9 @@ main :: proc() {
|
||||
png_test(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
PNG_Test :: struct {
|
||||
|
||||
@@ -3,6 +3,7 @@ package test_core_math_noise
|
||||
import "core:testing"
|
||||
import "core:math/noise"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
|
||||
TEST_count := 0
|
||||
TEST_fail := 0
|
||||
@@ -35,6 +36,9 @@ main :: proc() {
|
||||
t := testing.T{}
|
||||
noise_test(&t)
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Test_Vector :: struct {
|
||||
|
||||
@@ -2,7 +2,7 @@ package test_core_odin_parser
|
||||
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
|
||||
import "core:os"
|
||||
import "core:odin/parser"
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ main :: proc() {
|
||||
test_parse_demo(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package test_core_image
|
||||
import "core:strings"
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
|
||||
TEST_count := 0
|
||||
TEST_fail := 0
|
||||
@@ -35,6 +36,9 @@ main :: proc() {
|
||||
test_index_any_larger_string_found(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
|
||||
4
tests/vendor/botan/test_vendor_botan.odin
vendored
4
tests/vendor/botan/test_vendor_botan.odin
vendored
@@ -14,6 +14,7 @@ package test_vendor_botan
|
||||
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
|
||||
import "vendor:botan/md4"
|
||||
import "vendor:botan/md5"
|
||||
@@ -86,6 +87,9 @@ main :: proc() {
|
||||
test_siphash_2_4(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
TestHash :: struct {
|
||||
|
||||
4
tests/vendor/glfw/test_vendor_glfw.odin
vendored
4
tests/vendor/glfw/test_vendor_glfw.odin
vendored
@@ -3,6 +3,7 @@ package test_vendor_glfw
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "vendor:glfw"
|
||||
import "core:os"
|
||||
|
||||
GLFW_MAJOR :: 3
|
||||
GLFW_MINOR :: 3
|
||||
@@ -36,6 +37,9 @@ main :: proc() {
|
||||
test_glfw(&t)
|
||||
|
||||
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
|
||||
6
vendor/ENet/unix.odin
vendored
6
vendor/ENet/unix.odin
vendored
@@ -1,4 +1,4 @@
|
||||
//+build linux, darwin, freebsd
|
||||
//+build linux, darwin, freebsd, openbsd
|
||||
package ENet
|
||||
|
||||
// When we implement the appropriate bindings for Unix, the section separated
|
||||
@@ -14,7 +14,7 @@ import "core:c"
|
||||
|
||||
@(private="file") FD_ZERO :: #force_inline proc(s: ^fd_set) {
|
||||
for i := size_of(fd_set) / size_of(c.long); i != 0; i -= 1 {
|
||||
s.fds_bits[i] = 0;
|
||||
s.fds_bits[i] = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,4 +56,4 @@ SOCKETSET_REMOVE :: #force_inline proc(sockset: ^SocketSet, socket: Socket) {
|
||||
|
||||
SOCKSET_CHECK :: #force_inline proc(sockset: ^SocketSet, socket: Socket) -> bool {
|
||||
return FD_ISSET(i32(socket), cast(^fd_set)sockset)
|
||||
}
|
||||
}
|
||||
|
||||
6
vendor/botan/bindings/botan.odin
vendored
6
vendor/botan/bindings/botan.odin
vendored
@@ -142,11 +142,7 @@ fpe_t :: ^fpe_struct
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import botan_lib "botan.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import botan_lib "system:botan-2"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import botan_lib "system:botan-2"
|
||||
} else when ODIN_OS == .OpenBSD {
|
||||
} else {
|
||||
foreign import botan_lib "system:botan-2"
|
||||
}
|
||||
|
||||
|
||||
7
vendor/glfw/bindings/bindings.odin
vendored
7
vendor/glfw/bindings/bindings.odin
vendored
@@ -3,8 +3,6 @@ package glfw_bindings
|
||||
import "core:c"
|
||||
import vk "vendor:vulkan"
|
||||
|
||||
when ODIN_OS == .Linux { foreign import glfw "system:glfw" } // TODO: Add the billion-or-so static libs to link to in linux
|
||||
when ODIN_OS == .Darwin { foreign import glfw "system:glfw" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import glfw {
|
||||
"../lib/glfw3_mt.lib",
|
||||
@@ -12,6 +10,11 @@ when ODIN_OS == .Windows {
|
||||
"system:gdi32.lib",
|
||||
"system:shell32.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
// TODO: Add the billion-or-so static libs to link to in linux
|
||||
foreign import glfw "system:glfw"
|
||||
} else {
|
||||
foreign import glfw "system:glfw"
|
||||
}
|
||||
|
||||
#assert(size_of(c.int) == size_of(b32))
|
||||
|
||||
9
vendor/miniaudio/common.odin
vendored
9
vendor/miniaudio/common.odin
vendored
@@ -2,8 +2,13 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
handle :: distinct rawptr
|
||||
|
||||
|
||||
10
vendor/miniaudio/data_conversion.odin
vendored
10
vendor/miniaudio/data_conversion.odin
vendored
@@ -2,9 +2,13 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
*************************************************************************************************************************************************************
|
||||
|
||||
13
vendor/miniaudio/decoding.odin
vendored
13
vendor/miniaudio/decoding.odin
vendored
@@ -2,10 +2,13 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
@@ -164,4 +167,4 @@ foreign lib {
|
||||
decode_from_vfs :: proc(pVFS: ^vfs, pFilePath: cstring, pConfig: ^decoder_config, pFrameCountOut: ^u64, ppPCMFramesOut: ^rawptr) -> result ---
|
||||
decode_file :: proc(pFilePath: cstring, pConfig: ^decoder_config, pFrameCountOut: ^u64, ppPCMFramesOut: ^rawptr) -> result ---
|
||||
decode_memory :: proc(pData: rawptr, dataSize: c.size_t, pConfig: ^decoder_config, pFrameCountOut: ^u64, ppPCMFramesOut: ^rawptr) -> result ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/miniaudio/device_io_procs.odin
vendored
9
vendor/miniaudio/device_io_procs.odin
vendored
@@ -1,7 +1,12 @@
|
||||
package miniaudio
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
import "core:c"
|
||||
|
||||
|
||||
8
vendor/miniaudio/device_io_types.odin
vendored
8
vendor/miniaudio/device_io_types.odin
vendored
@@ -6,7 +6,7 @@ SUPPORT_WASAPI :: ODIN_OS == .Windows
|
||||
SUPPORT_DSOUND :: ODIN_OS == .Windows
|
||||
SUPPORT_WINMM :: ODIN_OS == .Windows
|
||||
SUPPORT_COREAUDIO :: ODIN_OS == .Darwin
|
||||
SUPPORT_SNDIO :: false // ODIN_OS == .OpenBSD
|
||||
SUPPORT_SNDIO :: ODIN_OS == .OpenBSD
|
||||
SUPPORT_AUDIO4 :: false // ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD
|
||||
SUPPORT_OSS :: ODIN_OS == .FreeBSD
|
||||
SUPPORT_PULSEAUDIO :: ODIN_OS == .Linux
|
||||
@@ -739,8 +739,8 @@ context_type :: struct {
|
||||
pa_stream_writable_size: proc "system" (),
|
||||
pa_stream_readable_size: proc "system" (),
|
||||
|
||||
/*pa_mainloop**/ pMainLoop: ptr,
|
||||
/*pa_context**/ pPulseContext: ptr,
|
||||
/*pa_mainloop**/ pMainLoop: rawptr,
|
||||
/*pa_context**/ pPulseContext: rawptr,
|
||||
} when SUPPORT_PULSEAUDIO else struct {}),
|
||||
|
||||
jack: (struct {
|
||||
@@ -791,7 +791,7 @@ context_type :: struct {
|
||||
AudioUnitInitialize: proc "system" (),
|
||||
AudioUnitRender: proc "system" (),
|
||||
|
||||
/*AudioComponent*/ component: ptr,
|
||||
/*AudioComponent*/ component: rawptr,
|
||||
noAudioSessionDeactivate: b32, /* For tracking whether or not the iOS audio session should be explicitly deactivated. Set from the config in ma_context_init__coreaudio(). */
|
||||
} when SUPPORT_COREAUDIO else struct {}),
|
||||
|
||||
|
||||
11
vendor/miniaudio/encoding.odin
vendored
11
vendor/miniaudio/encoding.odin
vendored
@@ -2,8 +2,13 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
@@ -49,4 +54,4 @@ foreign lib {
|
||||
encoder_init_file_w :: proc(pFilePath: [^]c.wchar_t, pConfig: ^encoder_config, pEncoder: ^encoder) -> result ---
|
||||
encoder_uninit :: proc(pEncoder: ^encoder) ---
|
||||
encoder_write_pcm_frames :: proc(pEncoder: ^encoder, FramesIn: rawptr, frameCount: u64) -> u64 ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/miniaudio/filtering.odin
vendored
9
vendor/miniaudio/filtering.odin
vendored
@@ -1,7 +1,12 @@
|
||||
package miniaudio
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
/**************************************************************************************************************************************************************
|
||||
|
||||
|
||||
11
vendor/miniaudio/generation.odin
vendored
11
vendor/miniaudio/generation.odin
vendored
@@ -2,8 +2,13 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
waveform_type :: enum c.int {
|
||||
sine,
|
||||
@@ -82,4 +87,4 @@ foreign lib {
|
||||
noise_set_amplitude :: proc(pNoise: ^noise, amplitude: f64) -> result ---
|
||||
noise_set_seed :: proc(pNoise: ^noise, seed: i32) -> result ---
|
||||
noise_set_type :: proc(pNoise: ^noise, type: noise_type) -> result ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/miniaudio/logging.odin
vendored
11
vendor/miniaudio/logging.odin
vendored
@@ -2,8 +2,13 @@ package miniaudio
|
||||
|
||||
import c "core:c/libc"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
MAX_LOG_CALLBACKS :: 4
|
||||
|
||||
@@ -32,4 +37,4 @@ foreign lib {
|
||||
log_post :: proc(pLog: ^log, level: u32, pMessage: cstring) -> result ---
|
||||
log_postv :: proc(pLog: ^log, level: u32, pFormat: cstring, args: c.va_list) -> result ---
|
||||
log_postf :: proc(pLog: ^log, level: u32, pFormat: cstring, #c_vararg args: ..any) -> result ---
|
||||
}
|
||||
}
|
||||
|
||||
6
vendor/miniaudio/src/Makefile
vendored
6
vendor/miniaudio/src/Makefile
vendored
@@ -1,6 +1,6 @@
|
||||
all:
|
||||
mkdir -p ../lib
|
||||
gcc -c -O2 -Os -fPIC miniaudio.c
|
||||
ar rcs ../lib/miniaudio.a miniaudio.o
|
||||
#gcc -fPIC -shared -Wl,-soname=miniaudio.so -o ../lib/miniaudio.so miniaudio.o
|
||||
$(CC) -c -O2 -Os -fPIC miniaudio.c
|
||||
$(AR) rcs ../lib/miniaudio.a miniaudio.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=miniaudio.so -o ../lib/miniaudio.so miniaudio.o
|
||||
rm *.o
|
||||
|
||||
11
vendor/miniaudio/utilities.odin
vendored
11
vendor/miniaudio/utilities.odin
vendored
@@ -1,7 +1,12 @@
|
||||
package miniaudio
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
@(default_calling_convention="c", link_prefix="ma_")
|
||||
foreign lib {
|
||||
@@ -228,4 +233,4 @@ foreign lib {
|
||||
audio_buffer_get_cursor_in_pcm_frames :: proc(pAudioBuffer: ^audio_buffer, pCursor: ^u64) -> result ---
|
||||
audio_buffer_get_length_in_pcm_frames :: proc(pAudioBuffer: ^audio_buffer, pLength: ^u64) -> result ---
|
||||
audio_buffer_get_available_frames :: proc(pAudioBuffer: ^audio_buffer, pAvailableFrames: ^u64) -> result ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/miniaudio/vfs.odin
vendored
9
vendor/miniaudio/vfs.odin
vendored
@@ -2,8 +2,13 @@ package miniaudio
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "lib/miniaudio.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "lib/miniaudio.a" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "lib/miniaudio.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "lib/miniaudio.a"
|
||||
} else {
|
||||
foreign import lib "system:miniaudio"
|
||||
}
|
||||
|
||||
/************************************************************************************************************************************************************
|
||||
|
||||
|
||||
4
vendor/portmidi/portmidi.odin
vendored
4
vendor/portmidi/portmidi.odin
vendored
@@ -9,6 +9,8 @@ when ODIN_OS == .Windows {
|
||||
"system:Winmm.lib",
|
||||
"system:Advapi32.lib",
|
||||
}
|
||||
} else {
|
||||
foreign import lib "system:portmidi"
|
||||
}
|
||||
|
||||
#assert(size_of(b32) == size_of(c.int))
|
||||
@@ -519,4 +521,4 @@ foreign lib {
|
||||
WriteSysEx() writes a timestamped system-exclusive midi message.
|
||||
*/
|
||||
WriteSysEx :: proc(stream: Stream, whence: Timestamp, msg: cstring) -> Error ---
|
||||
}
|
||||
}
|
||||
|
||||
8
vendor/portmidi/util.odin
vendored
8
vendor/portmidi/util.odin
vendored
@@ -7,7 +7,11 @@ package portmidi
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "portmidi_s.lib" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "portmidi_s.lib"
|
||||
} else {
|
||||
foreign import lib "system:portmidi"
|
||||
}
|
||||
|
||||
|
||||
Queue :: distinct rawptr
|
||||
@@ -118,4 +122,4 @@ foreign lib {
|
||||
state, returns .NoError if successfully set overflow state.
|
||||
*/
|
||||
SetOverflow :: proc(queue: Queue) -> Error ---
|
||||
}
|
||||
}
|
||||
|
||||
12
vendor/raylib/raylib.odin
vendored
12
vendor/raylib/raylib.odin
vendored
@@ -99,15 +99,17 @@ when ODIN_OS == .Windows {
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
}
|
||||
}
|
||||
when ODIN_OS == .Linux {
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib {
|
||||
"linux/libraylib.a",
|
||||
"system:dl",
|
||||
"system:pthread",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib "macos/libraylib.a"
|
||||
} else {
|
||||
foreign import lib "system:raylib"
|
||||
}
|
||||
when ODIN_OS == .Darwin { foreign import lib "macos/libraylib.a" }
|
||||
|
||||
VERSION :: "4.0"
|
||||
|
||||
@@ -1150,9 +1152,9 @@ foreign lib {
|
||||
DrawRectangleGradientH :: proc(posX, posY, width, height: c.int, color1: Color, color2: Color) --- // Draw a horizontal-gradient-filled rectangle
|
||||
DrawRectangleGradientEx :: proc(rec: Rectangle, col1, col2, col3, col4: Color) --- // Draw a gradient-filled rectangle with custom vertex colors
|
||||
DrawRectangleLines :: proc(posX, posY, width, height: c.int, color: Color) --- // Draw rectangle outline
|
||||
DrawRectangleLinesEx :: proc(rec: Rectangle, lineThick: c.int, color: Color) --- // Draw rectangle outline with extended parameters
|
||||
DrawRectangleLinesEx :: proc(rec: Rectangle, lineThick: f32, color: Color) --- // Draw rectangle outline with extended parameters
|
||||
DrawRectangleRounded :: proc(rec: Rectangle, roundness: f32, segments: c.int, color: Color) --- // Draw rectangle with rounded edges
|
||||
DrawRectangleRoundedLines :: proc(rec: Rectangle, roundness: f32, segments: c.int, lineThick: c.int, color: Color) --- // Draw rectangle with rounded edges outline
|
||||
DrawRectangleRoundedLines :: proc(rec: Rectangle, roundness: f32, segments: c.int, lineThick: f32, color: Color) --- // Draw rectangle with rounded edges outline
|
||||
DrawTriangle :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw a color-filled triangle (vertex in counter-clockwise order!)
|
||||
DrawTriangleLines :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw triangle outline (vertex in counter-clockwise order!)
|
||||
DrawTriangleFan :: proc(points: [^]Vector2, pointsCount: c.int, color: Color) --- // Draw a triangle fan defined by points (first vertex is the center)
|
||||
|
||||
10
vendor/raylib/rlgl.odin
vendored
10
vendor/raylib/rlgl.odin
vendored
@@ -10,9 +10,13 @@ when ODIN_OS == .Windows {
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib "linux/libraylib.a"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib "macos/libraylib.a"
|
||||
} else {
|
||||
foreign import lib "system:raylib"
|
||||
}
|
||||
when ODIN_OS == .Linux { foreign import lib "linux/libraylib.a" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "macos/libraylib.a" }
|
||||
|
||||
GRAPHICS_API_OPENGL_11 :: false
|
||||
GRAPHICS_API_OPENGL_21 :: true
|
||||
@@ -378,4 +382,4 @@ foreign lib {
|
||||
// Quick and dirty cube/quad buffers load->draw->unload
|
||||
rlLoadDrawCube :: proc() --- // Load and draw a cube
|
||||
rlLoadDrawQuad :: proc() --- // Load and draw a quad
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/image/sdl_image.odin
vendored
11
vendor/sdl2/image/sdl_image.odin
vendored
@@ -3,10 +3,11 @@ package sdl2_image
|
||||
import "core:c"
|
||||
import SDL ".."
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2_image.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2_image" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2_image" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2_image" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2_image.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2_image"
|
||||
}
|
||||
|
||||
bool :: SDL.bool
|
||||
|
||||
@@ -119,4 +120,4 @@ foreign lib {
|
||||
|
||||
/* Individual loading functions */
|
||||
LoadGIFAnimation_RW :: proc(src: ^SDL.RWops) -> ^Animation ---
|
||||
}
|
||||
}
|
||||
|
||||
10
vendor/sdl2/mixer/sdl_mixer.odin
vendored
10
vendor/sdl2/mixer/sdl_mixer.odin
vendored
@@ -3,11 +3,11 @@ package sdl2_mixer
|
||||
import "core:c"
|
||||
import SDL ".."
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2_mixer.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2_mixer" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2_mixer" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2_mixer" }
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2_mixer.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2_mixer"
|
||||
}
|
||||
|
||||
MAJOR_VERSION :: 2
|
||||
MINOR_VERSION :: 0
|
||||
|
||||
11
vendor/sdl2/net/sdl_net.odin
vendored
11
vendor/sdl2/net/sdl_net.odin
vendored
@@ -3,10 +3,11 @@ package sdl2_net
|
||||
import "core:c"
|
||||
import SDL ".."
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2_net.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2_net" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2_net" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2_net" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2_net.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2_net"
|
||||
}
|
||||
|
||||
bool :: SDL.bool
|
||||
|
||||
@@ -188,4 +189,4 @@ Read16 :: #force_inline proc "c" (areap: rawptr) -> u16 {
|
||||
Read32 :: #force_inline proc "c" (areap: rawptr) -> u32 {
|
||||
area := (^[4]u8)(areap)
|
||||
return u32(area[0])<<24 | u32(area[1])<<16 | u32(area[2])<<8 | u32(area[3])
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl2.odin
vendored
11
vendor/sdl2/sdl2.odin
vendored
@@ -25,10 +25,11 @@ package sdl2
|
||||
import "core:c"
|
||||
import "core:intrinsics"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
version :: struct {
|
||||
major: u8, /**< major version */
|
||||
@@ -314,4 +315,4 @@ foreign lib {
|
||||
IsShapedWindow :: proc(window: ^Window) -> bool ---
|
||||
SetWindowShape :: proc(window: ^Window, shape: ^Surface, shape_mode: ^WindowShapeMode) -> c.int ---
|
||||
GetShapedWindowMode :: proc(window: ^Window, shape_mode: ^WindowShapeMode) -> c.int ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/sdl2/sdl_audio.odin
vendored
9
vendor/sdl2/sdl_audio.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Audio format flags.
|
||||
|
||||
11
vendor/sdl2/sdl_blendmode.odin
vendored
11
vendor/sdl2/sdl_blendmode.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
|
||||
@@ -62,4 +63,4 @@ BlendFactor :: enum c.int {
|
||||
foreign lib {
|
||||
ComposeCustomBlendMode :: proc(srcColorFactor, dstColorFactor: BlendFactor, colorOperation: BlendOperation,
|
||||
srcAlphaFactor, dstAlphaFactor: BlendFactor, alphaOperation: BlendOperation) -> BlendMode ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_cpuinfo.odin
vendored
11
vendor/sdl2/sdl_cpuinfo.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
/* This is a guess for the cacheline size used for padding.
|
||||
* Most x86 processors have a 64 byte cache line.
|
||||
@@ -41,4 +42,4 @@ foreign lib {
|
||||
SIMDAlloc :: proc(len: c.size_t) -> rawptr ---
|
||||
SIMDRealloc :: proc(mem: rawptr, len: c.size_t) -> rawptr ---
|
||||
SIMDFree :: proc(ptr: rawptr) ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_events.odin
vendored
11
vendor/sdl2/sdl_events.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
RELEASED :: 0
|
||||
PRESSED :: 1
|
||||
@@ -498,4 +499,4 @@ foreign lib {
|
||||
FilterEvents :: proc(filter: EventFilter, userdata: rawptr) ---
|
||||
EventState :: proc(type: EventType, state: c.int) -> u8 ---
|
||||
RegisterEvents :: proc(numevents: c.int) -> u32 ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/sdl2/sdl_gamecontroller.odin
vendored
9
vendor/sdl2/sdl_gamecontroller.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
GameController :: struct {}
|
||||
|
||||
|
||||
11
vendor/sdl2/sdl_gesture_haptic.odin
vendored
11
vendor/sdl2/sdl_gesture_haptic.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
// Gesture
|
||||
|
||||
@@ -259,4 +260,4 @@ foreign lib {
|
||||
HapticRumbleInit :: proc(haptic: ^Haptic) -> c.int ---
|
||||
HapticRumblePlay :: proc(haptic: ^Haptic, strength: f32, length: u32) -> c.int ---
|
||||
HapticRumbleStop :: proc(haptic: ^Haptic) -> c.int ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_hints.odin
vendored
11
vendor/sdl2/sdl_hints.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
HINT_ACCELEROMETER_AS_JOYSTICK :: "SDL_ACCELEROMETER_AS_JOYSTICK"
|
||||
HINT_ALLOW_ALT_TAB_WHILE_GRABBED :: "SDL_ALLOW_ALT_TAB_WHILE_GRABBED"
|
||||
@@ -146,4 +147,4 @@ foreign lib {
|
||||
AddHintCallback :: proc(name: cstring, callback: HintCallback, userdata: rawptr) ---
|
||||
DelHintCallback :: proc(name: cstring, callback: HintCallback, userdata: rawptr) ---
|
||||
ClearHints :: proc() ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_joystick.odin
vendored
11
vendor/sdl2/sdl_joystick.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
Joystick :: struct {}
|
||||
|
||||
@@ -106,4 +107,4 @@ foreign lib {
|
||||
JoystickSendEffect :: proc(joystick: ^Joystick, data: rawptr, size: c.int) -> c.int ---
|
||||
JoystickClose :: proc(joystick: ^Joystick) ---
|
||||
JoystickCurrentPowerLevel :: proc(joystick: ^Joystick) -> JoystickPowerLevel ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/sdl2/sdl_keyboard.odin
vendored
9
vendor/sdl2/sdl_keyboard.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
Keysym :: struct {
|
||||
scancode: Scancode, /**< SDL physical key code - see ::SDL_Scancode for details */
|
||||
|
||||
2
vendor/sdl2/sdl_keycode.odin
vendored
2
vendor/sdl2/sdl_keycode.odin
vendored
@@ -327,4 +327,4 @@ KMOD_RESERVED :: Keymod{.RESERVED}
|
||||
KMOD_CTRL :: Keymod{.LCTRL, .RCTRL}
|
||||
KMOD_SHIFT :: Keymod{.LSHIFT, .RSHIFT}
|
||||
KMOD_ALT :: Keymod{.LALT, .RALT}
|
||||
KMOD_GUI :: Keymod{.LGUI, .RGUI};
|
||||
KMOD_GUI :: Keymod{.LGUI, .RGUI}
|
||||
|
||||
11
vendor/sdl2/sdl_log.odin
vendored
11
vendor/sdl2/sdl_log.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
MAX_LOG_MESSAGE :: 4096
|
||||
|
||||
@@ -74,4 +75,4 @@ foreign lib {
|
||||
// LogMessageV :: proc(category: c.int, priority: LogPriority, fmt: cstring, ap: va_list) ---
|
||||
LogGetOutputFunction :: proc(callback: ^LogOutputFunction, userdata: ^rawptr) ---
|
||||
LogSetOutputFunction :: proc(callback: LogOutputFunction, userdata: rawptr) ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/sdl2/sdl_messagebox.odin
vendored
9
vendor/sdl2/sdl_messagebox.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
MessageBoxFlag :: enum u32 {
|
||||
_ = 0,
|
||||
|
||||
11
vendor/sdl2/sdl_metal.odin
vendored
11
vendor/sdl2/sdl_metal.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
MetalView :: distinct rawptr
|
||||
|
||||
@@ -15,4 +16,4 @@ foreign lib {
|
||||
Metal_DestroyView :: proc(view: MetalView) ---
|
||||
Metal_GetLayer :: proc(view: MetalView) -> rawptr ---
|
||||
Metal_GetDrawableSize :: proc(window: ^Window, w, h: ^c.int) ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_mouse.odin
vendored
11
vendor/sdl2/sdl_mouse.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
Cursor :: struct {}
|
||||
|
||||
@@ -61,4 +62,4 @@ foreign lib {
|
||||
GetDefaultCursor :: proc() -> ^Cursor ---
|
||||
FreeCursor :: proc(cursor: ^Cursor) ---
|
||||
ShowCursor :: proc(toggle: c.int) -> c.int ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_mutex.odin
vendored
11
vendor/sdl2/sdl_mutex.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
MUTEX_TIMEDOUT :: 1
|
||||
MUTEX_MAXWAIT :: ~u32(0)
|
||||
@@ -41,4 +42,4 @@ foreign lib {
|
||||
CondBroadcast :: proc(cv: ^cond) -> c.int ---
|
||||
CondWait :: proc(cv: ^cond, m: ^mutex) -> c.int ---
|
||||
CondWaitTimeout :: proc(cv: ^cond, m: ^mutex, ms: u32) -> c.int ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_pixels.odin
vendored
11
vendor/sdl2/sdl_pixels.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
ALPHA_OPAQUE :: 255
|
||||
ALPHA_TRANSPARENT :: 0
|
||||
@@ -234,4 +235,4 @@ foreign lib {
|
||||
GetRGB :: proc(pixel: u32, format: ^PixelFormat, r, g, b: ^u8) ---
|
||||
GetRGBA :: proc(pixel: u32, format: ^PixelFormat, r, g, b, a: ^u8) ---
|
||||
CalculateGammaRamp :: proc(gamma: f32, ramp: ^[256]u16) ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_rect.odin
vendored
11
vendor/sdl2/sdl_rect.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
Point :: struct {
|
||||
x: c.int,
|
||||
@@ -47,4 +48,4 @@ foreign lib {
|
||||
UnionRect :: proc(A, B: ^Rect, result: ^Rect) ---
|
||||
EnclosePoints :: proc(points: [^]Point, count: c.int, clip: ^Rect, result: ^Rect) -> bool ---
|
||||
IntersectRectAndLine :: proc(rect: ^Rect, X1, Y1, X2, Y2: ^c.int) -> bool ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_render.odin
vendored
11
vendor/sdl2/sdl_render.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
RendererFlag :: enum u32 {
|
||||
SOFTWARE = 0, /**< The renderer is a software fallback */
|
||||
@@ -140,4 +141,4 @@ foreign lib {
|
||||
GL_UnbindTexture :: proc(texture: ^Texture) -> c.int ---
|
||||
RenderGetMetalLayer :: proc(renderer: ^Renderer) -> rawptr ---
|
||||
RenderGetMetalCommandEncoder :: proc(renderer: ^Renderer) -> rawptr ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_rwops.odin
vendored
11
vendor/sdl2/sdl_rwops.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
/* RWops Types */
|
||||
RWOPS_UNKNOWN :: 0 /**< Unknown stream type */
|
||||
@@ -105,4 +106,4 @@ foreign lib {
|
||||
WriteBE32 :: proc(dst: ^RWops, value: ^u32) -> c.size_t ---
|
||||
WriteLE64 :: proc(dst: ^RWops, value: ^u64) -> c.size_t ---
|
||||
WriteBE64 :: proc(dst: ^RWops, value: ^u64) -> c.size_t ---
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/sdl2/sdl_scancode.odin
vendored
2
vendor/sdl2/sdl_scancode.odin
vendored
@@ -539,4 +539,4 @@ SCANCODE_APP1 :: Scancode.APP1
|
||||
SCANCODE_APP2 :: Scancode.APP2
|
||||
|
||||
SCANCODE_AUDIOREWIND :: Scancode.AUDIOREWIND
|
||||
SCANCODE_AUDIOFASTFORWARD :: Scancode.AUDIOFASTFORWARD;
|
||||
SCANCODE_AUDIOFASTFORWARD :: Scancode.AUDIOFASTFORWARD
|
||||
|
||||
11
vendor/sdl2/sdl_stdinc.odin
vendored
11
vendor/sdl2/sdl_stdinc.odin
vendored
@@ -5,10 +5,11 @@ import "core:intrinsics"
|
||||
import "core:runtime"
|
||||
_, _ :: intrinsics, runtime
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
bool :: distinct b32
|
||||
#assert(size_of(bool) == size_of(c.int))
|
||||
@@ -160,4 +161,4 @@ iconv_utf8_ucs2 :: proc "c" (s: string) -> [^]u16 {
|
||||
iconv_utf8_utf32 :: iconv_utf8_ucs4
|
||||
iconv_utf8_ucs4 :: proc "c" (s: string) -> [^]rune {
|
||||
return cast([^]rune)iconv_string("UCS-4-INTERNAL", "UTF-8", cstring(raw_data(s)), len(s)+1)
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_surface.odin
vendored
11
vendor/sdl2/sdl_surface.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
SWSURFACE :: 0 /**< Just here for compatibility */
|
||||
PREALLOC :: 0x00000001 /**< Surface uses preallocated memory */
|
||||
@@ -108,4 +109,4 @@ foreign lib {
|
||||
SetYUVConversionMode :: proc(mode: YUV_CONVERSION_MODE) ---
|
||||
GetYUVConversionMode :: proc() -> YUV_CONVERSION_MODE ---
|
||||
GetYUVConversionModeForResolution :: proc(width, height: c.int) -> YUV_CONVERSION_MODE ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_system.odin
vendored
11
vendor/sdl2/sdl_system.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
// General
|
||||
@(default_calling_convention="c", link_prefix="SDL_")
|
||||
@@ -122,4 +123,4 @@ foreign lib {
|
||||
AndroidGetExternalStoragePath :: proc() -> cstring ---
|
||||
AndroidRequestPermission :: proc(permission: cstring) -> bool ---
|
||||
AndroidShowToast :: proc(message: cstring, duration, gravity, xoffset, yoffset: c.int) -> c.int ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_syswm.odin
vendored
11
vendor/sdl2/sdl_syswm.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
SYSWM_TYPE :: enum c.int {
|
||||
UNKNOWN,
|
||||
@@ -105,4 +106,4 @@ SysWMinfo :: struct {
|
||||
@(default_calling_convention="c", link_prefix="SDL_")
|
||||
foreign lib {
|
||||
GetWindowWMInfo :: proc(window: ^Window, info: ^SysWMinfo) -> bool ---
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/sdl2/sdl_thread.odin
vendored
9
vendor/sdl2/sdl_thread.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
Thread :: struct {}
|
||||
|
||||
|
||||
11
vendor/sdl2/sdl_timer.odin
vendored
11
vendor/sdl2/sdl_timer.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
TimerCallback :: proc "c" (interval: u32, param: rawptr) -> u32
|
||||
TimerID :: distinct c.int
|
||||
@@ -22,4 +23,4 @@ foreign lib {
|
||||
Delay :: proc(ms: u32) ---
|
||||
AddTimer :: proc(interval: u32, callback: TimerCallback, param: rawptr) -> TimerID ---
|
||||
RemoveTimer :: proc(id: TimerID) -> bool ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_touch.odin
vendored
11
vendor/sdl2/sdl_touch.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
TouchID :: distinct i64
|
||||
FingerID :: distinct i64
|
||||
@@ -34,4 +35,4 @@ foreign lib {
|
||||
GetTouchDeviceType :: proc(touchID: TouchID) -> TouchDeviceType ---
|
||||
GetNumTouchFingers :: proc(touchID: TouchID) -> c.int ---
|
||||
GetTouchFinger :: proc(touchID: TouchID, index: c.int) -> ^Finger ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_video.odin
vendored
11
vendor/sdl2/sdl_video.odin
vendored
@@ -2,10 +2,11 @@ package sdl2
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
DisplayMode :: struct {
|
||||
format: u32, /**< pixel format */
|
||||
@@ -310,4 +311,4 @@ foreign lib {
|
||||
// Used by vendor:OpenGL
|
||||
gl_set_proc_address :: proc(p: rawptr, name: cstring) {
|
||||
(^rawptr)(p)^ = GL_GetProcAddress(name)
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/sdl_vulkan.odin
vendored
11
vendor/sdl2/sdl_vulkan.odin
vendored
@@ -3,10 +3,11 @@ package sdl2
|
||||
import "core:c"
|
||||
import vk "vendor:vulkan"
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2"
|
||||
}
|
||||
|
||||
VkInstance :: vk.Instance
|
||||
VkSurfaceKHR :: vk.SurfaceKHR
|
||||
@@ -22,4 +23,4 @@ foreign lib {
|
||||
Vulkan_GetInstanceExtensions :: proc(window: ^Window, pCount: ^c.uint, pNames: [^]cstring) -> bool ---
|
||||
Vulkan_CreateSurface :: proc(window: ^Window, instance: VkInstance, surface: ^VkSurfaceKHR) -> bool ---
|
||||
Vulkan_GetDrawableSize :: proc(window: ^Window, w, h: ^c.int) ---
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/sdl2/ttf/sdl_ttf.odin
vendored
11
vendor/sdl2/ttf/sdl_ttf.odin
vendored
@@ -3,10 +3,11 @@ package sdl2_ttf
|
||||
import "core:c"
|
||||
import SDL ".."
|
||||
|
||||
when ODIN_OS == .Windows { foreign import lib "SDL2_ttf.lib" }
|
||||
when ODIN_OS == .Linux { foreign import lib "system:SDL2_ttf" }
|
||||
when ODIN_OS == .Darwin { foreign import lib "system:SDL2_ttf" }
|
||||
when ODIN_OS == .FreeBSD { foreign import lib "system:SDL2_ttf" }
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL2_ttf.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL2_ttf"
|
||||
}
|
||||
|
||||
bool :: SDL.bool
|
||||
|
||||
@@ -163,4 +164,4 @@ foreign lib {
|
||||
|
||||
SetFontSDF :: proc(font: ^Font, on_off: bool) -> c.int ---
|
||||
GetFontSDF :: proc(font: ^Font) -> bool ---
|
||||
}
|
||||
}
|
||||
|
||||
26
vendor/stb/src/Makefile
vendored
26
vendor/stb/src/Makefile
vendored
@@ -1,16 +1,16 @@
|
||||
all:
|
||||
mkdir -p ../lib
|
||||
gcc -c -O2 -Os -fPIC stb_image.c stb_image_write.c stb_image_resize.c stb_truetype.c stb_rect_pack.c stb_vorbis.c
|
||||
ar rcs ../lib/stb_image.a stb_image.o
|
||||
ar rcs ../lib/stb_image_write.a stb_image_write.o
|
||||
ar rcs ../lib/stb_image_resize.a stb_image_resize.o
|
||||
ar rcs ../lib/stb_truetype.a stb_truetype.o
|
||||
ar rcs ../lib/stb_rect_pack.a stb_rect_pack.o
|
||||
#ar rcs ../lib/stb_vorbis_pack.a stb_vorbis_pack.o
|
||||
#gcc -fPIC -shared -Wl,-soname=stb_image.so -o ../lib/stb_image.so stb_image.o
|
||||
#gcc -fPIC -shared -Wl,-soname=stb_image_write.so -o ../lib/stb_image_write.so stb_image_write.o
|
||||
#gcc -fPIC -shared -Wl,-soname=stb_image_resize.so -o ../lib/stb_image_resize.so stb_image_resize.o
|
||||
#gcc -fPIC -shared -Wl,-soname=stb_truetype.so -o ../lib/stb_truetype.so stb_image_truetype.o
|
||||
#gcc -fPIC -shared -Wl,-soname=stb_rect_pack.so -o ../lib/stb_rect_pack.so stb_rect_packl.o
|
||||
#gcc -fPIC -shared -Wl,-soname=stb_vorbis.so -o ../lib/stb_vorbis.so stb_vorbisl.o
|
||||
$(CC) -c -O2 -Os -fPIC stb_image.c stb_image_write.c stb_image_resize.c stb_truetype.c stb_rect_pack.c stb_vorbis.c
|
||||
$(AR) rcs ../lib/stb_image.a stb_image.o
|
||||
$(AR) rcs ../lib/stb_image_write.a stb_image_write.o
|
||||
$(AR) rcs ../lib/stb_image_resize.a stb_image_resize.o
|
||||
$(AR) rcs ../lib/stb_truetype.a stb_truetype.o
|
||||
$(AR) rcs ../lib/stb_rect_pack.a stb_rect_pack.o
|
||||
#$(AR) rcs ../lib/stb_vorbis_pack.a stb_vorbis_pack.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_image.so -o ../lib/stb_image.so stb_image.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_image_write.so -o ../lib/stb_image_write.so stb_image_write.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_image_resize.so -o ../lib/stb_image_resize.so stb_image_resize.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_truetype.so -o ../lib/stb_truetype.so stb_image_truetype.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_rect_pack.so -o ../lib/stb_rect_pack.so stb_rect_packl.o
|
||||
#$(CC) -fPIC -shared -Wl,-soname=stb_vorbis.so -o ../lib/stb_vorbis.so stb_vorbisl.o
|
||||
rm *.o
|
||||
|
||||
139
vendor/vulkan/_gen/create_vulkan_odin_wrapper.py
vendored
139
vendor/vulkan/_gen/create_vulkan_odin_wrapper.py
vendored
@@ -444,7 +444,7 @@ procedure_map = {}
|
||||
def parse_procedures(f):
|
||||
data = re.findall(r"typedef (\w+\*?) \(\w+ \*(\w+)\)\((.+?)\);", src, re.S)
|
||||
|
||||
ff = []
|
||||
group_ff = {"Loader":[], "Misc":[], "Instance":[], "Device":[]}
|
||||
|
||||
for rt, name, fields in data:
|
||||
proc_name = no_vk(name)
|
||||
@@ -464,18 +464,32 @@ def parse_procedures(f):
|
||||
ts += " -> {}".format(rt_str)
|
||||
|
||||
procedure_map[proc_name] = ts
|
||||
ff.append( (proc_name, ts) )
|
||||
|
||||
max_len = max(len(n) for n, t in ff)
|
||||
fields_types_name = [do_type(t) for t in re.findall(r"(?:\s*|)(.+?)\s*\w+(?:,|$)", fields)]
|
||||
table_name = fields_types_name[0]
|
||||
nn = (proc_name, ts)
|
||||
if table_name in ('Device', 'Queue', 'CommandBuffer') and proc_name != 'GetDeviceProcAddr':
|
||||
group_ff["Device"].append(nn)
|
||||
elif table_name in ('Instance', 'PhysicalDevice') or proc_name == 'GetDeviceProcAddr':
|
||||
group_ff["Instance"].append(nn)
|
||||
elif table_name in ('rawptr', '', 'DebugReportFlagsEXT') or proc_name == 'GetInstanceProcAddr':
|
||||
group_ff["Misc"].append(nn)
|
||||
else:
|
||||
group_ff["Loader"].append(nn)
|
||||
|
||||
|
||||
f.write("import \"core:c\"\n\n")
|
||||
f.write("// Procedure Types\n\n");
|
||||
for n, t in ff:
|
||||
f.write("{} :: #type {}\n".format(n.ljust(max_len), t.replace('"c"', '"system"')))
|
||||
for group_name, ff in group_ff.items():
|
||||
ff.sort()
|
||||
f.write("// {} Procedure Types\n".format(group_name))
|
||||
max_len = max(len(n) for n, t in ff)
|
||||
for n, t in ff:
|
||||
f.write("{} :: #type {}\n".format(n.ljust(max_len), t.replace('"c"', '"system"')))
|
||||
f.write("\n")
|
||||
|
||||
def group_functions(f):
|
||||
data = re.findall(r"typedef (\w+\*?) \(\w+ \*(\w+)\)\((.+?)\);", src, re.S)
|
||||
group_map = {"Instance":[], "Device":[], "Loader":[]}
|
||||
group_map = {"Loader":[], "Instance":[], "Device":[]}
|
||||
|
||||
for rt, vkname, fields in data:
|
||||
fields_types_name = [do_type(t) for t in re.findall(r"(?:\s*|)(.+?)\s*\w+(?:,|$)", fields)]
|
||||
@@ -493,6 +507,8 @@ def group_functions(f):
|
||||
pass
|
||||
else:
|
||||
group_map["Loader"].append(nn)
|
||||
for _, group in group_map.items():
|
||||
group.sort()
|
||||
|
||||
for group_name, group_lines in group_map.items():
|
||||
f.write("// {} Procedures\n".format(group_name))
|
||||
@@ -502,7 +518,7 @@ def group_functions(f):
|
||||
f.write('{}: {}\n'.format(remove_prefix(name, "Proc"), name.rjust(max_len)))
|
||||
f.write("\n")
|
||||
|
||||
f.write("load_proc_addresses :: proc(set_proc_address: SetProcAddressType) {\n")
|
||||
f.write("load_proc_addresses_custom :: proc(set_proc_address: SetProcAddressType) {\n")
|
||||
for group_name, group_lines in group_map.items():
|
||||
f.write("\t// {} Procedures\n".format(group_name))
|
||||
max_len = max(len(name) for name, _ in group_lines)
|
||||
@@ -514,7 +530,77 @@ def group_functions(f):
|
||||
remove_prefix(vk_name, 'Proc'),
|
||||
))
|
||||
f.write("\n")
|
||||
f.write("}\n")
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("// Device Procedure VTable\n")
|
||||
f.write("Device_VTable :: struct {\n")
|
||||
max_len = max(len(name) for name, _ in group_map["Device"])
|
||||
for name, vk_name in group_map["Device"]:
|
||||
f.write('\t{}: {},\n'.format(remove_prefix(name, "Proc"), name.rjust(max_len)))
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("load_proc_addresses_device_vtable :: proc(device: Device, vtable: ^Device_VTable) {\n")
|
||||
for name, vk_name in group_map["Device"]:
|
||||
k = max_len - len(name)
|
||||
f.write('\tvtable.{}{} = auto_cast GetDeviceProcAddr(device, "vk{}")\n'.format(
|
||||
remove_prefix(name, 'Proc'),
|
||||
"".ljust(k),
|
||||
remove_prefix(vk_name, 'Proc'),
|
||||
))
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("load_proc_addresses_device :: proc(device: Device) {\n")
|
||||
max_len = max(len(name) for name, _ in group_map["Device"])
|
||||
for name, vk_name in group_map["Device"]:
|
||||
k = max_len - len(name)
|
||||
f.write('\t{}{} = auto_cast GetDeviceProcAddr(device, "vk{}")\n'.format(
|
||||
remove_prefix(name, 'Proc'),
|
||||
"".ljust(k),
|
||||
remove_prefix(vk_name, 'Proc'),
|
||||
))
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("load_proc_addresses_instance :: proc(instance: Instance) {\n")
|
||||
max_len = max(len(name) for name, _ in group_map["Instance"])
|
||||
for name, vk_name in group_map["Instance"]:
|
||||
k = max_len - len(name)
|
||||
f.write('\t{}{} = auto_cast GetInstanceProcAddr(instance, "vk{}")\n'.format(
|
||||
remove_prefix(name, 'Proc'),
|
||||
"".ljust(k),
|
||||
remove_prefix(vk_name, 'Proc'),
|
||||
))
|
||||
f.write("\n\t// Device Procedures (may call into dispatch)\n")
|
||||
max_len = max(len(name) for name, _ in group_map["Device"])
|
||||
for name, vk_name in group_map["Device"]:
|
||||
k = max_len - len(name)
|
||||
f.write('\t{}{} = auto_cast GetInstanceProcAddr(instance, "vk{}")\n'.format(
|
||||
remove_prefix(name, 'Proc'),
|
||||
"".ljust(k),
|
||||
remove_prefix(vk_name, 'Proc'),
|
||||
))
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("load_proc_addresses_global :: proc(vk_get_instance_proc_addr: rawptr) {\n")
|
||||
f.write("\tGetInstanceProcAddr = auto_cast vk_get_instance_proc_addr\n\n")
|
||||
max_len = max(len(name) for name, _ in group_map["Loader"])
|
||||
for name, vk_name in group_map["Loader"]:
|
||||
k = max_len - len(name)
|
||||
f.write('\t{}{} = auto_cast GetInstanceProcAddr(nil, "vk{}")\n'.format(
|
||||
remove_prefix(name, 'Proc'),
|
||||
"".ljust(k),
|
||||
remove_prefix(vk_name, 'Proc'),
|
||||
))
|
||||
f.write("}\n\n")
|
||||
|
||||
f.write("""
|
||||
load_proc_addresses :: proc{
|
||||
\tload_proc_addresses_global,
|
||||
\tload_proc_addresses_instance,
|
||||
\tload_proc_addresses_device,
|
||||
\tload_proc_addresses_device_vtable,
|
||||
\tload_proc_addresses_custom,
|
||||
}\n
|
||||
"""[1::])
|
||||
|
||||
|
||||
|
||||
@@ -581,14 +667,14 @@ MAX_GLOBAL_PRIORITY_SIZE_EXT :: 16
|
||||
parse_handles_def(f)
|
||||
f.write("\n\n")
|
||||
parse_flags_def(f)
|
||||
with open("../enums.odin", 'w', encoding='utf-8') as f:
|
||||
f.write(BASE)
|
||||
f.write("\n")
|
||||
parse_enums(f)
|
||||
f.write("\n\n")
|
||||
with open("../structs.odin", 'w', encoding='utf-8') as f:
|
||||
f.write(BASE)
|
||||
f.write("""
|
||||
with open("../enums.odin", 'w', encoding='utf-8') as f:
|
||||
f.write(BASE)
|
||||
f.write("\n")
|
||||
parse_enums(f)
|
||||
f.write("\n\n")
|
||||
with open("../structs.odin", 'w', encoding='utf-8') as f:
|
||||
f.write(BASE)
|
||||
f.write("""
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
@@ -622,13 +708,12 @@ CAMetalLayer :: struct {}
|
||||
|
||||
/********************************/
|
||||
""")
|
||||
f.write("\n")
|
||||
parse_structs(f)
|
||||
f.write("\n\n")
|
||||
with open("../procedures.odin", 'w', encoding='utf-8') as f:
|
||||
f.write(BASE)
|
||||
f.write("\n")
|
||||
parse_procedures(f)
|
||||
f.write("\n")
|
||||
group_functions(f)
|
||||
f.write("\n\n")
|
||||
f.write("\n")
|
||||
parse_structs(f)
|
||||
f.write("\n\n")
|
||||
with open("../procedures.odin", 'w', encoding='utf-8') as f:
|
||||
f.write(BASE)
|
||||
f.write("\n")
|
||||
parse_procedures(f)
|
||||
f.write("\n")
|
||||
group_functions(f)
|
||||
|
||||
4383
vendor/vulkan/procedures.odin
vendored
4383
vendor/vulkan/procedures.odin
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user