nomen-lang 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOMEN_AGENTS.md +235 -0
- package/core/System/Ansi.nm +150 -0
- package/core/System/Array.nm +358 -0
- package/core/System/BigInt.nm +887 -0
- package/core/System/Buffer.nm +526 -0
- package/core/System/Channel.nm +198 -0
- package/core/System/ClassBuffer.nm +229 -0
- package/core/System/Console.nm +211 -0
- package/core/System/Controls/Button.nm +138 -0
- package/core/System/Controls/CheckBox.nm +158 -0
- package/core/System/Controls/Container.nm +1562 -0
- package/core/System/Controls/Control.nm +28 -0
- package/core/System/Controls/Geometry.nm +101 -0
- package/core/System/Controls/Layout.nm +228 -0
- package/core/System/Controls/LayoutParams.nm +50 -0
- package/core/System/Controls/Text.nm +129 -0
- package/core/System/Controls/TextBox.nm +157 -0
- package/core/System/Controls/Window.nm +280 -0
- package/core/System/Disposable.nm +8 -0
- package/core/System/Enumerable.nm +10 -0
- package/core/System/Equatable.nm +10 -0
- package/core/System/Graph.nm +68 -0
- package/core/System/Hashable.nm +13 -0
- package/core/System/Init.nm +21 -0
- package/core/System/LinkedList.nm +64 -0
- package/core/System/List.nm +44 -0
- package/core/System/Map.nm +153 -0
- package/core/System/Math.nm +54 -0
- package/core/System/Mutex.nm +78 -0
- package/core/System/Nursery.nm +27 -0
- package/core/System/Sendable.nm +9 -0
- package/core/System/Set.nm +97 -0
- package/core/System/Stream/Directory.nm +176 -0
- package/core/System/Stream/File.nm +432 -0
- package/core/System/Stream/Http.nm +453 -0
- package/core/System/String.nm +154 -0
- package/core/System/StringBuilder.nm +249 -0
- package/core/System/Stringable.nm +8 -0
- package/core/System/Task.nm +263 -0
- package/core/System/Test.nm +241 -0
- package/core/System/Text/Json.nm +377 -0
- package/core/System/Text/JsonTree.nm +187 -0
- package/core/System/Text/Regex.nm +655 -0
- package/core/System/Time.nm +112 -0
- package/core/System/Tree.nm +70 -0
- package/core/System/Viewable.nm +27 -0
- package/core/System/bool.nm +66 -0
- package/core/System/char.nm +42 -0
- package/core/System/float.nm +43 -0
- package/core/System/int.nm +54 -0
- package/core/System/int64.nm +42 -0
- package/core/System/int8.nm +42 -0
- package/core/System/uint.nm +42 -0
- package/core/System/uint64.nm +42 -0
- package/core/System/uint8.nm +42 -0
- package/core/docs/System/Ansi.md +40 -0
- package/core/docs/System/Array.md +16 -0
- package/core/docs/System/BigInt.md +30 -0
- package/core/docs/System/Buffer.md +31 -0
- package/core/docs/System/Channel.md +10 -0
- package/core/docs/System/ClassBuffer.md +15 -0
- package/core/docs/System/Console.md +13 -0
- package/core/docs/System/Controls/Button.md +12 -0
- package/core/docs/System/Controls/CheckBox.md +15 -0
- package/core/docs/System/Controls/Container.md +82 -0
- package/core/docs/System/Controls/Control.md +5 -0
- package/core/docs/System/Controls/Geometry.md +26 -0
- package/core/docs/System/Controls/Layout.md +37 -0
- package/core/docs/System/Controls/LayoutParams.md +13 -0
- package/core/docs/System/Controls/Text.md +12 -0
- package/core/docs/System/Controls/TextBox.md +13 -0
- package/core/docs/System/Controls/Window.md +20 -0
- package/core/docs/System/Disposable.md +5 -0
- package/core/docs/System/Enumerable.md +5 -0
- package/core/docs/System/Graph.md +17 -0
- package/core/docs/System/Init.md +9 -0
- package/core/docs/System/LinkedList.md +16 -0
- package/core/docs/System/List.md +13 -0
- package/core/docs/System/Map.md +14 -0
- package/core/docs/System/Math.md +11 -0
- package/core/docs/System/Mutex.md +10 -0
- package/core/docs/System/Nursery.md +5 -0
- package/core/docs/System/Sendable.md +5 -0
- package/core/docs/System/Set.md +14 -0
- package/core/docs/System/Stream/Directory.md +12 -0
- package/core/docs/System/Stream/File.md +21 -0
- package/core/docs/System/String.md +14 -0
- package/core/docs/System/StringBuilder.md +12 -0
- package/core/docs/System/Stringable.md +5 -0
- package/core/docs/System/Task.md +15 -0
- package/core/docs/System/Text/Json.md +12 -0
- package/core/docs/System/Text/JsonTree.md +21 -0
- package/core/docs/System/Text/Regex.md +12 -0
- package/core/docs/System/Time.md +11 -0
- package/core/docs/System/Tree.md +18 -0
- package/core/docs/System/Viewable.md +5 -0
- package/core/docs/System/bool.md +9 -0
- package/core/docs/System/char.md +9 -0
- package/core/docs/System/float.md +9 -0
- package/core/docs/System/int.md +10 -0
- package/core/docs/System/int64.md +9 -0
- package/core/docs/System/int8.md +9 -0
- package/core/docs/System/uint.md +9 -0
- package/core/docs/System/uint64.md +9 -0
- package/core/docs/System/uint8.md +9 -0
- package/core/package.jsonc +4 -0
- package/dist/index.mjs +417 -5490
- package/package.json +33 -30
- package/src/args.ts +171 -0
- package/src/index.ts +53 -104
- package/src/init.ts +128 -0
- package/src/test.ts +6 -2
- package/test/fixtures/build/calc.test +0 -0
- package/test/fixtures/build/calc.test.c +0 -969
- package/test/fixtures/build/main.h +0 -170
- package/test/fixtures/calc.test.nm +0 -32
- package/tsconfig.json +0 -21
- package/vite.config.ts +0 -7
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mathematical helper functions
|
|
3
|
+
**/
|
|
4
|
+
pub struct Math {
|
|
5
|
+
pub func power = (int base, int exp, out int) {
|
|
6
|
+
```
|
|
7
|
+
#arch: c
|
|
8
|
+
int result = 1;
|
|
9
|
+
for (int i = 0; i < exp; i++) {
|
|
10
|
+
result *= base;
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
```
|
|
14
|
+
```
|
|
15
|
+
#arch: aarch64
|
|
16
|
+
mov x2, #1
|
|
17
|
+
mov x3, #0
|
|
18
|
+
b .Lchk_Math_power
|
|
19
|
+
.Lloop_Math_power:
|
|
20
|
+
mul x2, x2, x0
|
|
21
|
+
add x3, x3, #1
|
|
22
|
+
.Lchk_Math_power:
|
|
23
|
+
cmp x3, x1
|
|
24
|
+
blt .Lloop_Math_power
|
|
25
|
+
mov x0, x2
|
|
26
|
+
```
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
inline func sqrt = (float x, out float) {
|
|
30
|
+
```
|
|
31
|
+
#arch: c
|
|
32
|
+
return sqrt(x);
|
|
33
|
+
```
|
|
34
|
+
```
|
|
35
|
+
#arch: aarch64
|
|
36
|
+
fmov d0, x0
|
|
37
|
+
fsqrt d0, d0
|
|
38
|
+
fmov x0, d0
|
|
39
|
+
```
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
pub func log = (float x, out float) {
|
|
43
|
+
```
|
|
44
|
+
#arch: c
|
|
45
|
+
return log(x);
|
|
46
|
+
```
|
|
47
|
+
```
|
|
48
|
+
#arch: aarch64
|
|
49
|
+
fmov d0, x0
|
|
50
|
+
bl _log
|
|
51
|
+
fmov x0, d0
|
|
52
|
+
```
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Mutex — pthread-backed lock for shared mutable state.
|
|
2
|
+
//
|
|
3
|
+
// Default stance in Nomen is "no shared mutable state" — communicate by moving
|
|
4
|
+
// Sendable values (or via Channel<T>). Mutex exists for when you genuinely
|
|
5
|
+
// need shared mutability. See ASYNC.md.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A pthread-backed mutual-exclusion lock for protecting shared mutable state
|
|
9
|
+
**/
|
|
10
|
+
pub class Mutex: Sendable {
|
|
11
|
+
pub var uint64 handle = 0
|
|
12
|
+
|
|
13
|
+
pub func #init = (self) {
|
|
14
|
+
```
|
|
15
|
+
#arch: c
|
|
16
|
+
#scope: file
|
|
17
|
+
#include <pthread.h>
|
|
18
|
+
```
|
|
19
|
+
```
|
|
20
|
+
#arch: c
|
|
21
|
+
self->handle = (unsigned long long)malloc(sizeof(pthread_mutex_t));
|
|
22
|
+
pthread_mutex_init((pthread_mutex_t *)self->handle, NULL);
|
|
23
|
+
```
|
|
24
|
+
```
|
|
25
|
+
#arch: aarch64
|
|
26
|
+
mov x0, #64
|
|
27
|
+
bl _malloc
|
|
28
|
+
str x0, [x19, #8]
|
|
29
|
+
mov x1, #0
|
|
30
|
+
bl _pthread_mutex_init
|
|
31
|
+
```
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pub func lock = (self) {
|
|
35
|
+
```
|
|
36
|
+
#arch: c
|
|
37
|
+
pthread_mutex_lock((pthread_mutex_t *)self->handle);
|
|
38
|
+
```
|
|
39
|
+
```
|
|
40
|
+
#arch: aarch64
|
|
41
|
+
ldr x0, [x19, #8]
|
|
42
|
+
bl _pthread_mutex_lock
|
|
43
|
+
```
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
pub func unlock = (self) {
|
|
47
|
+
```
|
|
48
|
+
#arch: c
|
|
49
|
+
pthread_mutex_unlock((pthread_mutex_t *)self->handle);
|
|
50
|
+
```
|
|
51
|
+
```
|
|
52
|
+
#arch: aarch64
|
|
53
|
+
ldr x0, [x19, #8]
|
|
54
|
+
bl _pthread_mutex_unlock
|
|
55
|
+
```
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pub func #destroy = () {
|
|
59
|
+
```
|
|
60
|
+
#arch: c
|
|
61
|
+
if (self->handle) {
|
|
62
|
+
pthread_mutex_destroy((pthread_mutex_t *)self->handle);
|
|
63
|
+
free((void *)self->handle);
|
|
64
|
+
self->handle = 0;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
```
|
|
68
|
+
#arch: aarch64
|
|
69
|
+
ldr x0, [x19, #8]
|
|
70
|
+
cbz x0, .Lmutex_destroy_end
|
|
71
|
+
bl _pthread_mutex_destroy
|
|
72
|
+
ldr x0, [x19, #8]
|
|
73
|
+
bl _free
|
|
74
|
+
str xzr, [x19, #8]
|
|
75
|
+
.Lmutex_destroy_end:
|
|
76
|
+
```
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Nursery — the capability passed to a function that needs to spawn into its
|
|
2
|
+
// caller's nursery (the Trio escape hatch). See ASYNC.md, "Escape hatch:
|
|
3
|
+
// passing the nursery".
|
|
4
|
+
//
|
|
5
|
+
// An `async` block names its nursery (`async pool { }`), binding a Nursery
|
|
6
|
+
// variable in scope. That variable is passed to helper functions with `ref`
|
|
7
|
+
// and is the receiver of `pool.spawn(fn(args))`. The Nursery wraps the
|
|
8
|
+
// per-invocation tracking state of the `async { }` block — a pointer to the
|
|
9
|
+
// futures array and a pointer to the count slot, both on the async block's
|
|
10
|
+
// stack frame — so it is only valid for the lifetime of its enclosing block
|
|
11
|
+
// (which is exactly the structured-concurrency invariant: the block cannot
|
|
12
|
+
// exit until every spawned task, including those spawned through a passed
|
|
13
|
+
// Nursery, has finished).
|
|
14
|
+
//
|
|
15
|
+
// Config rides on the declaration: `async pool = Nursery(timeout: 2000) { }`.
|
|
16
|
+
//
|
|
17
|
+
// `name.spawn(fn(args))` is special-cased by the compiler (it needs the spawn
|
|
18
|
+
// trampoline machinery), so it is NOT a regular method declared here. The two
|
|
19
|
+
// fields are the full runtime contract.
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The capability for spawning into a caller's `async` block; owns and tracks its tasks
|
|
23
|
+
**/
|
|
24
|
+
pub struct Nursery: Sendable {
|
|
25
|
+
pub var uint64 futures_ptr = 0
|
|
26
|
+
pub var uint64 count_ptr = 0
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Marker trait for types whose values are safe to move across task boundaries.
|
|
2
|
+
// See ASYNC.md for the design. Auto-derivable in a follow-up; for now, structs
|
|
3
|
+
// opt in explicitly with `: Sendable`.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A marker trait for values that are safe to move across task boundaries
|
|
7
|
+
**/
|
|
8
|
+
pub trait Sendable {
|
|
9
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An ordered set of unique values (`add`/`has`/`get`/`remove`)
|
|
3
|
+
**/
|
|
4
|
+
pub struct Set<T> {
|
|
5
|
+
var length = 0
|
|
6
|
+
var Buffer<T> slots = Buffer<T>()
|
|
7
|
+
var used = Buffer<int>()
|
|
8
|
+
|
|
9
|
+
pub func add = (ref self, mov T value) {
|
|
10
|
+
var int cap = self.slots.cap
|
|
11
|
+
if cap == 0 {
|
|
12
|
+
cap = self.slots.alloc_int(8)
|
|
13
|
+
self.used.alloc(8)
|
|
14
|
+
}
|
|
15
|
+
if self.length * 4 >= cap * 3 {
|
|
16
|
+
self.rehash(cap * 2)
|
|
17
|
+
cap = self.slots.cap
|
|
18
|
+
}
|
|
19
|
+
var int idx = self.find_slot(value, cap)
|
|
20
|
+
if self.used.load(idx) == 0 {
|
|
21
|
+
self.used.store(idx, 1)
|
|
22
|
+
self.slots.store_int(idx, value)
|
|
23
|
+
self.length += 1
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
pub func has = (self, T value, out bool) {
|
|
28
|
+
var int cap = self.slots.cap
|
|
29
|
+
if cap == 0 {
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
32
|
+
var int idx = self.find_slot(value, cap)
|
|
33
|
+
return self.used.load(idx) != 0
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pub func get = (self, T key, out T) {
|
|
37
|
+
var int cap = self.slots.cap
|
|
38
|
+
if cap == 0 {
|
|
39
|
+
return 0
|
|
40
|
+
}
|
|
41
|
+
var int idx = self.find_slot(key, cap)
|
|
42
|
+
if self.used.load(idx) == 0 {
|
|
43
|
+
return 0
|
|
44
|
+
}
|
|
45
|
+
return self.slots.load_int(idx)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
pub func remove = (ref self, T value) {
|
|
49
|
+
var int cap = self.slots.cap
|
|
50
|
+
if cap == 0 {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
var int idx = self.find_slot(value, cap)
|
|
54
|
+
if self.used.load(idx) == 0 {
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
self.used.store(idx, 0)
|
|
58
|
+
self.slots.store_int(idx, 0)
|
|
59
|
+
self.length = self.length - 1
|
|
60
|
+
self.rehash(cap)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func find_slot = (self, T value, int cap, out int: out >= 0 && out < cap) {
|
|
64
|
+
var int v = value
|
|
65
|
+
var int idx = v % cap
|
|
66
|
+
if idx < 0 {
|
|
67
|
+
idx = idx + cap
|
|
68
|
+
}
|
|
69
|
+
while self.used.load(idx) != 0 {
|
|
70
|
+
if self.slots.load_int(idx) == v {
|
|
71
|
+
return idx
|
|
72
|
+
}
|
|
73
|
+
idx += 1
|
|
74
|
+
if idx >= cap {
|
|
75
|
+
idx = 0
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return idx
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
func rehash = (ref self, int new_cap) {
|
|
82
|
+
var Buffer<T> old_slots = mov self.slots swap Buffer<T>()
|
|
83
|
+
var Buffer<int> old_used = mov self.used swap Buffer<int>()
|
|
84
|
+
var int old_cap = old_slots.cap
|
|
85
|
+
|
|
86
|
+
self.slots.alloc_int(new_cap)
|
|
87
|
+
self.used.alloc(new_cap)
|
|
88
|
+
self.length = 0
|
|
89
|
+
|
|
90
|
+
var i = 0
|
|
91
|
+
while i < old_cap; i += 1 {
|
|
92
|
+
if old_used.load(i) != 0 {
|
|
93
|
+
self.add(old_slots.load_int(i))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for working with filesystem directories.
|
|
3
|
+
*
|
|
4
|
+
* `Directory` is a namespace of static helpers — no instance is constructed.
|
|
5
|
+
*
|
|
6
|
+
* Directory.create("scratch")
|
|
7
|
+
* const string names = Directory.list("scratch")
|
|
8
|
+
* const bool has = Directory.exists("scratch")
|
|
9
|
+
* Directory.remove("scratch")
|
|
10
|
+
**/
|
|
11
|
+
pub struct Directory {
|
|
12
|
+
// (static) Create a directory at `path`.
|
|
13
|
+
pub func create = (string path) {
|
|
14
|
+
```
|
|
15
|
+
#arch: c
|
|
16
|
+
mkdir(path, 0777);
|
|
17
|
+
```
|
|
18
|
+
```
|
|
19
|
+
#arch: aarch64
|
|
20
|
+
mov x1, #0x1FF
|
|
21
|
+
bl _mkdir
|
|
22
|
+
```
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// (static) Remove the (empty) directory at `path`.
|
|
26
|
+
pub func remove = (string path) {
|
|
27
|
+
```
|
|
28
|
+
#arch: c
|
|
29
|
+
rmdir(path);
|
|
30
|
+
```
|
|
31
|
+
```
|
|
32
|
+
#arch: aarch64
|
|
33
|
+
bl _rmdir
|
|
34
|
+
```
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// (static) Whether a directory exists at `path`.
|
|
38
|
+
pub func exists = (string path, out bool) {
|
|
39
|
+
```
|
|
40
|
+
#arch: c
|
|
41
|
+
struct stat st;
|
|
42
|
+
return stat(path, &st) == 0 ? 1 : 0;
|
|
43
|
+
```
|
|
44
|
+
```
|
|
45
|
+
#arch: aarch64
|
|
46
|
+
sub sp, sp, #160
|
|
47
|
+
mov x1, sp
|
|
48
|
+
bl _stat
|
|
49
|
+
cmp x0, #0
|
|
50
|
+
cset x0, eq
|
|
51
|
+
add sp, sp, #160
|
|
52
|
+
b .return_Directory_exists
|
|
53
|
+
```
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Returns the directory's entry names as a single newline-separated
|
|
58
|
+
// string. The `.` and `..` entries are skipped. Returns an empty string
|
|
59
|
+
// if the path cannot be opened.
|
|
60
|
+
//
|
|
61
|
+
// On macOS/iOS the entry length is read from `dirent.d_namlen`, so this
|
|
62
|
+
// is currently macOS-specific aarch64 asm (the C backend is portable).
|
|
63
|
+
pub func list = (string path, out string) {
|
|
64
|
+
```
|
|
65
|
+
#arch: c
|
|
66
|
+
#scope: file
|
|
67
|
+
#include <dirent.h>
|
|
68
|
+
```
|
|
69
|
+
```
|
|
70
|
+
#arch: c
|
|
71
|
+
DIR *d = opendir(path);
|
|
72
|
+
if (!d) return strdup("");
|
|
73
|
+
int cap = 4096;
|
|
74
|
+
int len = 0;
|
|
75
|
+
char *buf = (char*)malloc(cap);
|
|
76
|
+
struct dirent *e;
|
|
77
|
+
while ((e = readdir(d)) != NULL) {
|
|
78
|
+
if (e->d_name[0] == '.' && e->d_name[1] == 0) continue;
|
|
79
|
+
if (e->d_name[0] == '.' && e->d_name[1] == '.' && e->d_name[2] == 0) continue;
|
|
80
|
+
int nl = (int)strlen(e->d_name);
|
|
81
|
+
if (len + nl + 2 > cap) {
|
|
82
|
+
while (len + nl + 2 > cap) cap *= 2;
|
|
83
|
+
buf = (char*)realloc(buf, cap);
|
|
84
|
+
}
|
|
85
|
+
memcpy(buf + len, e->d_name, nl);
|
|
86
|
+
len += nl;
|
|
87
|
+
buf[len++] = '\n';
|
|
88
|
+
}
|
|
89
|
+
buf[len] = 0;
|
|
90
|
+
closedir(d);
|
|
91
|
+
return buf;
|
|
92
|
+
```
|
|
93
|
+
```
|
|
94
|
+
#arch: aarch64
|
|
95
|
+
sub sp, sp, #64
|
|
96
|
+
str x0, [sp, #0]
|
|
97
|
+
bl _opendir
|
|
98
|
+
str x0, [sp, #8]
|
|
99
|
+
cbz x0, .Ldir_list_empty
|
|
100
|
+
mov x0, #4096
|
|
101
|
+
bl _malloc
|
|
102
|
+
str x0, [sp, #16]
|
|
103
|
+
str xzr, [sp, #24]
|
|
104
|
+
mov x0, #4096
|
|
105
|
+
str x0, [sp, #32]
|
|
106
|
+
.Ldir_list_loop:
|
|
107
|
+
ldr x0, [sp, #8]
|
|
108
|
+
bl _readdir
|
|
109
|
+
str x0, [sp, #40]
|
|
110
|
+
cbz x0, .Ldir_list_done
|
|
111
|
+
ldrb w1, [x0, #21]
|
|
112
|
+
cmp w1, #46
|
|
113
|
+
bne .Ldir_list_keep
|
|
114
|
+
ldrb w1, [x0, #22]
|
|
115
|
+
cbz w1, .Ldir_list_loop
|
|
116
|
+
cmp w1, #46
|
|
117
|
+
bne .Ldir_list_keep
|
|
118
|
+
ldrb w1, [x0, #23]
|
|
119
|
+
cbz w1, .Ldir_list_loop
|
|
120
|
+
.Ldir_list_keep:
|
|
121
|
+
ldr x0, [sp, #40]
|
|
122
|
+
ldrh w0, [x0, #18]
|
|
123
|
+
str x0, [sp, #48]
|
|
124
|
+
.Ldir_list_grow:
|
|
125
|
+
ldr x1, [sp, #24]
|
|
126
|
+
ldr x2, [sp, #48]
|
|
127
|
+
add x1, x1, x2
|
|
128
|
+
add x1, x1, #2
|
|
129
|
+
ldr x2, [sp, #32]
|
|
130
|
+
cmp x1, x2
|
|
131
|
+
ble .Ldir_list_grow_ok
|
|
132
|
+
lsl x2, x2, #1
|
|
133
|
+
str x2, [sp, #32]
|
|
134
|
+
ldr x0, [sp, #16]
|
|
135
|
+
bl _realloc
|
|
136
|
+
str x0, [sp, #16]
|
|
137
|
+
b .Ldir_list_grow
|
|
138
|
+
.Ldir_list_grow_ok:
|
|
139
|
+
ldr x0, [sp, #16]
|
|
140
|
+
ldr x1, [sp, #24]
|
|
141
|
+
add x0, x0, x1
|
|
142
|
+
ldr x1, [sp, #40]
|
|
143
|
+
add x1, x1, #21
|
|
144
|
+
ldr x2, [sp, #48]
|
|
145
|
+
bl _memcpy
|
|
146
|
+
ldr x0, [sp, #48]
|
|
147
|
+
ldr x1, [sp, #24]
|
|
148
|
+
add x1, x1, x0
|
|
149
|
+
str x1, [sp, #24]
|
|
150
|
+
ldr x0, [sp, #16]
|
|
151
|
+
ldr x1, [sp, #24]
|
|
152
|
+
mov w2, #10
|
|
153
|
+
strb w2, [x0, x1]
|
|
154
|
+
add x1, x1, #1
|
|
155
|
+
str x1, [sp, #24]
|
|
156
|
+
b .Ldir_list_loop
|
|
157
|
+
.Ldir_list_done:
|
|
158
|
+
ldr x0, [sp, #16]
|
|
159
|
+
ldr x1, [sp, #24]
|
|
160
|
+
strb wzr, [x0, x1]
|
|
161
|
+
ldr x0, [sp, #8]
|
|
162
|
+
bl _closedir
|
|
163
|
+
ldr x0, [sp, #16]
|
|
164
|
+
add sp, sp, #64
|
|
165
|
+
b .return_Directory_list
|
|
166
|
+
.Ldir_list_empty:
|
|
167
|
+
adr x0, .Ldir_list_empty_str
|
|
168
|
+
bl _strdup
|
|
169
|
+
add sp, sp, #64
|
|
170
|
+
b .return_Directory_list
|
|
171
|
+
.Ldir_list_empty_str: .asciz ""
|
|
172
|
+
.p2align 2
|
|
173
|
+
```
|
|
174
|
+
return ""
|
|
175
|
+
}
|
|
176
|
+
}
|