From 874e05ec66161caad4beed3ba1951b7cced92833 Mon Sep 17 00:00:00 2001 From: nub31 Date: Tue, 10 Jun 2025 22:09:45 +0200 Subject: [PATCH] cleanup repo --- .clang-format | 3 -- .gitignore | 4 +- a.out | Bin 14792 -> 0 bytes build.sh | 17 +++---- debug.sh | 5 -- example/main.nub | 2 +- run.sh | 4 -- src/runtime/core/{syscall.asm => syscall.s} | 8 ++-- .../tools}/syntax-highlighting/build.sh | 0 .../language-configuration.json | 0 .../tools}/syntax-highlighting/package.json | 0 .../syntaxes/nub.tmLanguage.json | 43 +++++++++++++++++- 12 files changed, 59 insertions(+), 27 deletions(-) delete mode 100644 .clang-format delete mode 100755 a.out delete mode 100755 debug.sh delete mode 100755 run.sh rename src/runtime/core/{syscall.asm => syscall.s} (56%) rename {tools => src/tools}/syntax-highlighting/build.sh (100%) rename {tools => src/tools}/syntax-highlighting/language-configuration.json (100%) rename {tools => src/tools}/syntax-highlighting/package.json (100%) rename {tools => src/tools}/syntax-highlighting/syntaxes/nub.tmLanguage.json (86%) diff --git a/.clang-format b/.clang-format deleted file mode 100644 index f9641b6..0000000 --- a/.clang-format +++ /dev/null @@ -1,3 +0,0 @@ -BasedOnStyle: Chromium -IndentWidth: 4 -ColumnLimit: 120 \ No newline at end of file diff --git a/.gitignore b/.gitignore index acd4af4..c1b9796 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -tools/syntax-highlighting/out \ No newline at end of file +src/tools/syntax-highlighting/out +bin +bin-int diff --git a/a.out b/a.out deleted file mode 100755 index 3da7aa0cfb78ea76af279afd71b9fe11202260bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14792 zcmeHOZ)_Ar6rWyOkSg@3SculJ(fYB=QQD>?RHuc5y-@xrCDs60ws%W=@ox9H-GyRI z&=3iSREZxHjWH&E(JzKCCML#6XyS!$#V>07ViaN(FhC-bko0_ScHZ4}DTJ7q_+ciw zdGGz^y*F=ud)aAoGe?udn_~?Pj9QF6%h38U&IJ_qj2XSclvqD&VVt$GGpf>N za(yIUmJ^U9zv_G%21C=h5LFpkwZ3jX&_ z#eiZ!F`yVw3@8Q^1BwB~fMP%~@IPaq(i_tlt31;Led}rt8rl9TR` zs+s&pw; zZtBE;kiNpsICiJyXghd)jb0~&*K|Xw)X{n6(w8s}DX&6YVsP)C3)7;6seupBbsxA^ zk<*B5tw)X{vR)uY>9^VEKr>2ZqkL`y-5S*Kx1~hXj6WblNE0G)i-jKvZ2WHSmH_HZ7y4(NIk>pcqgLC5Wl?5ln=F^(pjV-Fjh zH-A{#tE7BPN)nBv$aBB)xHThxJim;M&Q#;i$n_mj|09sGVfA} zUz7f!H}vVWYxNJU@6}yqIj& zaU1fdHjPY-7g(;y|jIB zTWTXSw+!zX8XPuvY~H*pIbx0s4h<(whPNqr{T&L^&RD+1oB%7xd$uoBC_J4nFw=H2 z%rwV5&-8q&=(D_)b%aB~a>4lunbl;wY-kvZI6s9;s@;#G{Yik(p>KVA8VuZXD4y>9(0w4f|3fi! z|A*{8P;SBAL-A*0TnwF+0L@Qvbni$wL5JSBcT)UJ3=zg=B#;nRxF2Kf6i@r60T}MB z6wewtSkMrJM)QZ(-Rs{81Gtw`Jnf$yGM?%tNq!{vK|JowWNUJMO~z|-V!T6EU%!MI zzQ-~5kOa7l=Q5twi9Ya_yKDUi0mHoXcMPNVLL5M7n&@ktgsb9`dK z>srKQufiB&wEpV-HmxqGPNnBZ&~Z?(cDdZ@`ab{Qv*} diff --git a/build.sh b/build.sh index 49b69e7..f70f97c 100755 --- a/build.sh +++ b/build.sh @@ -3,12 +3,13 @@ set -e dotnet build src/lang/Nub.Lang.CLI -nub example | qbe > out.s +mkdir -p bin-int bin +rm -rf bin-int/* bin/* -gcc -nostartfiles -no-pie \ - out.s \ - src/runtime/baseline/entry.s \ - src/runtime/baseline/nub_memcpy.s \ - src/runtime/baseline/nub_memset.s \ - src/runtime/baseline/nub_panic.s \ - src/runtime/baseline/nub_strcmp.s \ +nub example | qbe | as -o bin-int/out.o + +find src/runtime -name '*.s' | while read -r file; do + as "$file" -o "bin-int/$(basename "${file}" .s).o" +done + +gcc -nostartfiles -o bin/out bin-int/*.o diff --git a/debug.sh b/debug.sh deleted file mode 100755 index 5b44083..0000000 --- a/debug.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e -./clean.sh -./build.sh -gdb -tui ./out/program diff --git a/example/main.nub b/example/main.nub index a2eac42..942e600 100644 --- a/example/main.nub +++ b/example/main.nub @@ -40,4 +40,4 @@ export func main(args: []^string): i64 { return 0 -} \ No newline at end of file +} diff --git a/run.sh b/run.sh deleted file mode 100755 index 000d377..0000000 --- a/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -e -./build.sh -bash -c './out/program; echo "Process exited with status code $?"' diff --git a/src/runtime/core/syscall.asm b/src/runtime/core/syscall.s similarity index 56% rename from src/runtime/core/syscall.asm rename to src/runtime/core/syscall.s index e4afea3..a4a368b 100644 --- a/src/runtime/core/syscall.asm +++ b/src/runtime/core/syscall.s @@ -3,9 +3,9 @@ .section .text core_syscall: - movq rax, rdi - movq rdi, rsi - movq rsi, rdx - movq r10, rcx + mov rax, rdi + mov rdi, rsi + mov rsi, rdx + mov r10, rcx syscall ret diff --git a/tools/syntax-highlighting/build.sh b/src/tools/syntax-highlighting/build.sh similarity index 100% rename from tools/syntax-highlighting/build.sh rename to src/tools/syntax-highlighting/build.sh diff --git a/tools/syntax-highlighting/language-configuration.json b/src/tools/syntax-highlighting/language-configuration.json similarity index 100% rename from tools/syntax-highlighting/language-configuration.json rename to src/tools/syntax-highlighting/language-configuration.json diff --git a/tools/syntax-highlighting/package.json b/src/tools/syntax-highlighting/package.json similarity index 100% rename from tools/syntax-highlighting/package.json rename to src/tools/syntax-highlighting/package.json diff --git a/tools/syntax-highlighting/syntaxes/nub.tmLanguage.json b/src/tools/syntax-highlighting/syntaxes/nub.tmLanguage.json similarity index 86% rename from tools/syntax-highlighting/syntaxes/nub.tmLanguage.json rename to src/tools/syntax-highlighting/syntaxes/nub.tmLanguage.json index 3d75d00..7c8da71 100644 --- a/tools/syntax-highlighting/syntaxes/nub.tmLanguage.json +++ b/src/tools/syntax-highlighting/syntaxes/nub.tmLanguage.json @@ -74,9 +74,12 @@ }, "types": { "patterns": [ + { + "include": "#function-type" + }, { "name": "storage.type.primitive.nub", - "match": "\\b(i8|i16|i32|i64|u8|u16|u32|u64|f32|f64|bool|void|any)\\b" + "match": "\\b(i8|i16|i32|i64|u8|u16|u32|u64|f32|f64|bool|string|void|any)\\b" }, { "name": "storage.type.array.nub", @@ -88,6 +91,44 @@ } ] }, + "function-type": { + "patterns": [ + { + "begin": "\\b(func)\\s*\\(", + "beginCaptures": { + "1": { + "name": "storage.type.function.nub" + } + }, + "end": "(?<=\\))(?:\\s*:\\s*([^\\s,;{}()]+))?", + "endCaptures": { + "1": { + "name": "storage.type.nub" + } + }, + "patterns": [ + { + "include": "#function-type-parameters" + } + ] + } + ] + }, + "function-type-parameters": { + "patterns": [ + { + "match": "\\.\\.\\.", + "name": "keyword.operator.variadic.nub" + }, + { + "include": "#types" + }, + { + "match": ",", + "name": "punctuation.separator.nub" + } + ] + }, "strings": { "patterns": [ {