Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DanielGavin/ols
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGavin committed Sep 22, 2024
2 parents 0d1d4d8 + e23ddd2 commit 23bd4b3
Show file tree
Hide file tree
Showing 10 changed files with 339 additions and 167 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
mkdir dist
mv ols dist/ols-arm64-darwin
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: dist-arm64-darwin
path: ./dist
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
mkdir dist
mv ols dist/ols-x86_64-darwin
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: dist-x86_64-darwin
path: ./dist
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
mkdir dist
mv ols dist/ols-x86_64-unknown-linux-gnu
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: dist-x86_64-unknown-linux-gnu
path: ./dist
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
cd dist
ren ols.exe ols-x86_64-pc-windows-msvc.exe
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: dist-x86_64-pc-windows-msvc
path: ./dist
Expand All @@ -144,19 +144,19 @@ jobs:
- run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- run: 'echo "HEAD_SHA: $HEAD_SHA"'

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4.1.7
with:
name: dist-x86_64-unknown-linux-gnu
path: dist
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4.1.7
with:
name: dist-x86_64-pc-windows-msvc
path: dist
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4.1.7
with:
name: dist-x86_64-darwin
path: dist
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4.1.7
with:
name: dist-arm64-darwin
path: dist
Expand Down
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,38 @@ lspconfig.ols.setup({})
### Emacs

```elisp
;; With odin-mode (https://github.com/mattt-b/odin-mode) and lsp-mode already added to your init.el of course!.
(setq-default lsp-auto-guess-root t) ;; if you work with Projectile/project.el this will help find the ols.json file.
(defvar lsp-language-id-configuration '((odin-mode . "odin")))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "/path/to/ols/executable")
:major-modes '(odin-mode)
:server-id 'ols
:multi-root t)) ;; This is just so lsp-mode sends the "workspaceFolders" param to the server.
;; Enable odin-mode and configure OLS as the language server
(use-package! odin-mode
:mode ("\\.odin\\'" . odin-mode)
:hook (odin-mode . lsp))
;; Set up OLS as the language server for Odin, ensuring lsp-mode is loaded first
(with-eval-after-load 'lsp-mode
(setq-default lsp-auto-guess-root t) ;; Helps find the ols.json file with Projectile or project.el
(setq lsp-language-id-configuration (cons '(odin-mode . "odin") lsp-language-id-configuration))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "/path/to/ols/executable") ;; Adjust the path here
:major-modes '(odin-mode)
:server-id 'ols
:multi-root t))) ;; Ensures lsp-mode sends "workspaceFolders" to the server
(add-hook 'odin-mode-hook #'lsp)
```

### Helix
Guide for installing helix with ols:
https://github.com/joaocarvalhoopen/Helix_editor_for_the_Odin_programming_Language

Helix supports Odin and OLS by default. One can enable it through their languages.toml. Example config:
```toml
# Optional. The default configration requires OLS in PATH env. variable. If not,
# you can set path to the executable like so:
# [language-server.ols]
# command = "path/to/executable"

[[language]]
name = "odin"
```

### Micro

Install the [LSP plugin](https://github.com/AndCake/micro-plugin-lsp)
Expand Down
43 changes: 42 additions & 1 deletion builtin/builtin.odin
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Odin_Arch_Type :: enum int {
}

@builtin
ODIN_ARCH: Odin_Arch_Type
ODIN_ARCH: Odin_Arch_Type

Odin_Build_Mode_Type :: enum int {
Executable,
Expand All @@ -88,6 +88,14 @@ Odin_Build_Mode_Type :: enum int {
@builtin
ODIN_BUILD_MODE: Odin_Build_Mode_Type

Odin_Error_Pos_Style_Type :: enum int {
Default = 0,
Unix = 1,
}

@builtin
ODIN_ERROR_POS_STYLE: Odin_Error_Pos_Style_Type

Odin_Endian_Type :: enum int {
Unknown,
Little,
Expand Down Expand Up @@ -127,3 +135,36 @@ ODIN_OPTIMIZATION_MODE: Odin_Optimization_Mode

@builtin
ODIN_DEBUG: bool

@builtin
ODIN_WINDOWS_SUBSYSTEM: string

@builtin
ODIN_VENDOR: string

@builtin
ODIN_VERSION: string

@builtin
ODIN_ROOT: string

@builtin
ODIN_DISABLE_ASSERT: bool

@builtin
ODIN_DEFAULT_TO_NIL_ALLOCATOR: bool

@builtin
ODIN_DEFAULT_TO_PANIC_ALLOCATOR: bool

@builtin
ODIN_NO_CRT: bool

@builtin
ODIN_NO_ENTRY_POINT: bool

@builtin
ODIN_NO_RTTI: bool

@builtin
ODIN_COMPILE_TIMESTAMP: int
74 changes: 66 additions & 8 deletions builtin/intrinsics.odin
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package ols_builtin
// Package-Related
is_package_imported :: proc(package_name: string) -> bool ---

// Matrix Related Procedures
transpose :: proc(m: $T/matrix[$R, $C]$E) -> matrix[C, R]E ---
outer_product :: proc(a: $A/[$X]$E, b: $B/[$Y]E) -> matrix[X, Y]E ---
hadamard_product :: proc(a, b: $T/matrix[$R, $C]$E) -> T ---
matrix_flatten :: proc(m: $T/matrix[$R, $C]$E) -> [R*C]E ---

// Types
soa_struct :: proc($N: int, $T: typeid) -> type / #soa[N]T

Expand Down Expand Up @@ -34,6 +40,9 @@ overflow_add :: proc(lhs, rhs: $T) -> (T, bool) #optional_ok ---
overflow_sub :: proc(lhs, rhs: $T) -> (T, bool) #optional_ok ---
overflow_mul :: proc(lhs, rhs: $T) -> (T, bool) #optional_ok ---

saturating_add :: proc(lhs, rhs: $T) -> T ---
saturating_sub :: proc(lhs, rhs: $T) -> T ---

sqrt :: proc(x: $T) -> T ---

fused_mul_add :: proc(a, b, c: $T) -> T ---
Expand Down Expand Up @@ -71,7 +80,8 @@ expect :: proc(val, expected_val: T) -> T ---

// Linux and Darwin Only
syscall :: proc(id: uintptr, args: ..uintptr) -> uintptr ---

// FreeBSD, NetBSD, et cetera
syscall_bsd :: proc(id: uintptr, args: ..uintptr) -> (uintptr, bool) ---

// Atomics
Atomic_Memory_Order :: enum {
Expand Down Expand Up @@ -219,8 +229,21 @@ type_is_matrix :: proc($T: typeid) -> bool ---

type_has_nil :: proc($T: typeid) -> bool ---

type_is_matrix_row_major :: proc($T: typeid) -> bool ---
type_is_matrix_column_major :: proc($T: typeid) -> bool ---

type_is_specialization_of :: proc($T, $S: typeid) -> bool ---

type_is_variant_of :: proc($U, $V: typeid) -> bool ---
type_union_tag_type :: proc($T: typeid) -> typeid ---
type_union_tag_offset :: proc($T: typeid) -> uintptr ---
type_union_base_tag_value :: proc($T: typeid) -> int ---
type_union_variant_count :: proc($T: typeid) -> int ---
type_variant_type_of :: proc($T: typeid, $index: int) -> typeid ---
type_variant_index_of :: proc($U, $V: typeid) -> int ---

type_bit_set_elem_type :: proc($T: typeid) -> typeid ---
type_bit_set_underlying_type :: proc($T: typeid) -> typeid ---

type_has_field :: proc($T: typeid, $name: string) -> bool ---
type_field_type :: proc($T: typeid, $name: string) -> typeid ---
Expand All @@ -232,6 +255,7 @@ type_proc_parameter_type :: proc($T: typeid, index: int) -> typeid ---
type_proc_return_type :: proc($T: typeid, index: int) -> typeid ---

type_struct_field_count :: proc($T: typeid) -> int ---
type_struct_has_implicit_padding :: proc($T: typeid) -> bool ---

type_polymorphic_record_parameter_count :: proc($T: typeid) -> typeid ---
type_polymorphic_record_parameter_value :: proc(
Expand All @@ -257,14 +281,27 @@ type_hasher_proc :: proc(
hasher: proc "contextless" (data: rawptr, seed: uintptr) -> uintptr
) ---

type_map_info :: proc($T: typeid/map[$K]$V) -> ^runtime.Map_Info ---
type_map_cell_info :: proc($T: typeid) -> ^runtime.Map_Cell_Info ---

type_convert_variants_to_pointers :: proc($T: typeid) -> typeid ---
type_merge :: proc($U, $V: typeid) -> typeid ---

type_has_shared_fields :: proc($U, $V: typeid) -> bool ---

constant_utf16_cstring :: proc($literal: string) -> [^]u16 ---

constant_log2 :: proc($v: $T) -> T ---

// SIMD related
simd_add :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_sub :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_mul :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_div :: proc(a, b: #simd[N]T) -> #simd[N]T ---

simd_saturating_add :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_saturating_sub :: proc(a, b: #simd[N]T) -> #simd[N]T ---

// Keeps Odin's Behaviour
// (x << y) if y <= mask else 0
simd_shl :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T ---
Expand All @@ -284,10 +321,10 @@ simd_shr_masked :: proc(
simd_add_sat :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_sub_sat :: proc(a, b: #simd[N]T) -> #simd[N]T ---

simd_and :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_or :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_xor :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_and_not :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_bit_and :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_bit_or :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_bit_xor :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_bit_and_not :: proc(a, b: #simd[N]T) -> #simd[N]T ---

simd_neg :: proc(a: #simd[N]T) -> #simd[N]T ---

Expand Down Expand Up @@ -320,6 +357,18 @@ simd_reduce_and :: proc(a: #simd[N]T) -> T ---
simd_reduce_or :: proc(a: #simd[N]T) -> T ---
simd_reduce_xor :: proc(a: #simd[N]T) -> T ---

simd_reduce_any :: proc(a: #simd[N]T) -> T ---
simd_reduce_all :: proc(a: #simd[N]T) -> T ---

simd_gather :: proc(ptr: #simd[N]rawptr, val: #simd[N]T, mask: #simd[N]U) -> #simd[N]T ---
simd_scatter :: proc(ptr: #simd[N]rawptr, val: #simd[N]T, mask: #simd[N]U) ---

simd_masked_load :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) -> #simd[N]T ---
simd_masked_store :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) ---

simd_masked_expand_load :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) -> #simd[N]T ---
simd_masked_compress_store :: proc(ptr: rawptr, val: #simd[N]T, mask: #simd[N]U) ---

simd_shuffle :: proc(
a, b: #simd[N]T,
indices: ..int,
Expand All @@ -339,11 +388,20 @@ simd_nearest :: proc(a: #simd[N]any_float) -> #simd[N]any_float ---
simd_to_bits :: proc(v: #simd[N]T) -> #simd[N]Integer ---

// equivalent a swizzle with descending indices, e.g. reserve(a, 3, 2, 1, 0)
simd_reverse :: proc(a: #simd[N]T) -> #simd[N]T ---
simd_lanes_reverse :: proc(a: #simd[N]T) -> #simd[N]T ---

simd_lanes_rotate_left :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
simd_lanes_rotate_right :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---

simd_rotate_left :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
simd_rotate_right :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T ---
// Checks if the current target supports the given target features.
//
// Takes a constant comma-seperated string (eg: "sha512,sse4.1"), or a procedure type which has either
// `@(require_target_feature)` or `@(enable_target_feature)` as its input and returns a boolean indicating
// if all listed features are supported.
has_target_feature :: proc($test: $T) -> bool ---

// Returns the value of the procedure where `x` must be a call expression
procedure_of :: proc(x: $T) -> T ---

// WASM targets only
wasm_memory_grow :: proc(index, delta: uintptr) -> int ---
Expand Down
Loading

0 comments on commit 23bd4b3

Please sign in to comment.