diff options
| author | gingerBill <bill@gingerbill.org> | 2018-09-02 15:56:36 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-09-02 15:56:36 +0100 |
| commit | 220485a2d2cd180e7ff2a15bab66c867c06b05d7 (patch) | |
| tree | 4b3df1aae33e7b2af9375b1f8e11d8c2b2b88a15 /core/runtime | |
| parent | eb274cf31600814b2f808c80d43376b0e9e959f1 (diff) | |
`typeid` as keyword (ready to implement polymorphic name parameters)
Diffstat (limited to 'core/runtime')
| -rw-r--r-- | core/runtime/core.odin | 25 | ||||
| -rw-r--r-- | core/runtime/internal.odin | 4 |
2 files changed, 21 insertions, 8 deletions
diff --git a/core/runtime/core.odin b/core/runtime/core.odin index 7d1f8a9f6..fb428d8fe 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -268,10 +268,6 @@ type_info_base_without_enum :: proc "contextless" (info: ^Type_Info) -> ^Type_In return base; } -__typeid_of :: proc "contextless" (ti: ^Type_Info) -> typeid { - if ti == nil do return nil; - return ti.id; -} __type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info { data := transmute(Typeid_Bit_Field)id; n := int(data.index); @@ -284,11 +280,11 @@ __type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info { typeid_base :: proc "contextless" (id: typeid) -> typeid { ti := type_info_of(id); ti = type_info_base(ti); - return typeid_of(ti); + return ti.id; } typeid_base_without_enum :: proc "contextless" (id: typeid) -> typeid { ti := type_info_base_without_enum(type_info_of(id)); - return typeid_of(ti); + return ti.id; } @@ -365,6 +361,23 @@ pop :: proc "contextless" (array: ^$T/[dynamic]$E) -> E { return res; } +@(builtin) +unordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) { + runtime.bounds_check_error_loc(loc, index, len(array)); + n := len(array)-1; + if index != n { + array[index] = array[n]; + } + pop(array); +} + +@(builtin) +ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) { + runtime.bounds_check_error_loc(loc, index, len(array)); + copy(array[index:], array[index+1:]); + pop(array); +} + @(builtin) clear :: proc[clear_dynamic_array, clear_map]; diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index 141058647..5b1c6b434 100644 --- a/core/runtime/internal.odin +++ b/core/runtime/internal.odin @@ -63,7 +63,7 @@ __print_type :: proc(fd: os.Handle, ti: ^Type_Info) { case Type_Info_Named: os.write_string(fd, info.name); case Type_Info_Integer: - a := any{typeid = typeid_of(ti)}; + a := any{id = ti.id}; switch _ in a { case int: os.write_string(fd, "int"); case uint: os.write_string(fd, "uint"); @@ -83,7 +83,7 @@ __print_type :: proc(fd: os.Handle, ti: ^Type_Info) { case Type_Info_String: os.write_string(fd, "string"); case Type_Info_Boolean: - a := any{typeid = typeid_of(ti)}; + a := any{id = ti.id}; switch _ in a { case bool: os.write_string(fd, "bool"); case: |