nomen-lang 0.0.19 → 0.2.0

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.
Files changed (62) hide show
  1. package/NOMEN_AGENTS.md +57 -12
  2. package/core/System/Array.nm +11 -11
  3. package/core/System/Buffer.nm +2 -2
  4. package/core/System/Channel.nm +146 -12
  5. package/core/System/ClassBuffer.nm +2 -2
  6. package/core/System/Console.nm +28 -17
  7. package/core/System/Controls/Button.nm +96 -8
  8. package/core/System/Controls/CheckBox.nm +117 -12
  9. package/core/System/Controls/Container.nm +114 -8
  10. package/core/System/Controls/Text.nm +98 -8
  11. package/core/System/Controls/TextBox.nm +120 -10
  12. package/core/System/Controls/Window.nm +231 -23
  13. package/core/System/Graph.nm +1 -1
  14. package/core/System/Init.nm +4 -8
  15. package/core/System/LinkedList.nm +1 -1
  16. package/core/System/List.nm +3 -3
  17. package/core/System/Map.nm +5 -5
  18. package/core/System/Math.nm +10 -32
  19. package/core/System/Result.nm +1 -1
  20. package/core/System/Set.nm +4 -4
  21. package/core/System/Stream/Directory.nm +189 -63
  22. package/core/System/Stream/DirectoryError.nm +21 -0
  23. package/core/System/Stream/File.nm +339 -141
  24. package/core/System/Stream/FileError.nm +21 -0
  25. package/core/System/Stream/Http.nm +109 -44
  26. package/core/System/Stream/HttpError.nm +20 -0
  27. package/core/System/String.nm +83 -69
  28. package/core/System/StringBuilder.nm +11 -13
  29. package/core/System/Task.nm +46 -12
  30. package/core/System/Test.nm +1 -1
  31. package/core/System/Text/Json.nm +5 -3
  32. package/core/System/Text/JsonTree.nm +23 -14
  33. package/core/System/Text/Regex.nm +124 -64
  34. package/core/System/Tree.nm +1 -1
  35. package/core/System/bool.nm +4 -9
  36. package/core/System/char.nm +3 -9
  37. package/core/System/float.nm +2 -1
  38. package/core/System/float32.nm +44 -0
  39. package/core/System/float64.nm +44 -0
  40. package/core/System/int.nm +3 -9
  41. package/core/System/int16.nm +47 -0
  42. package/core/System/int32.nm +47 -0
  43. package/core/System/int64.nm +3 -9
  44. package/core/System/int8.nm +3 -9
  45. package/core/System/ufloat.nm +44 -0
  46. package/core/System/ufloat32.nm +44 -0
  47. package/core/System/ufloat64.nm +44 -0
  48. package/core/System/uint.nm +3 -9
  49. package/core/System/uint16.nm +47 -0
  50. package/core/System/uint32.nm +47 -0
  51. package/core/System/uint64.nm +3 -9
  52. package/core/System/uint8.nm +3 -9
  53. package/core/docs/System/Channel.md +2 -0
  54. package/core/docs/System/Result.md +5 -1
  55. package/core/docs/System/Task.md +1 -1
  56. package/dist/index.mjs +38794 -21299
  57. package/package.json +38 -34
  58. package/src/args.ts +11 -0
  59. package/src/index.ts +21 -3
  60. package/src/init.ts +1 -1
  61. package/src/test.ts +48 -4
  62. package/src/types/Config.ts +2 -0
@@ -6,7 +6,7 @@ pub class Window: Control {
6
6
 
7
7
  pub func #init = (self, string title, int width, int height) {
8
8
  ```
9
- #arch: c, aarch64_use_c
9
+ #arch: c
10
10
  #platform: macos
11
11
  // Set up NSApplication first
12
12
  id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
@@ -35,7 +35,46 @@ pub class Window: Control {
35
35
  self->handle = (uint64_t)win;
36
36
  ```
37
37
  ```
38
- #arch: c, aarch64_use_c
38
+ #arch: aarch64_use_c
39
+ #platform: macos
40
+ // Set up NSApplication first
41
+ id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
42
+ ((void(*)(id, SEL, long))objc_msgSend)(app, sel_registerName("setActivationPolicy:"), 0);
43
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(app, sel_registerName("activateIgnoringOtherApps:"), 1);
44
+ // Create window
45
+ unsigned long style = 1 | 2 | 4 | 8;
46
+ id win = ((id(*)(id, SEL, double, double, double, double, unsigned long, unsigned long, BOOL))objc_msgSend)(
47
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSWindow"), sel_registerName("alloc")),
48
+ sel_registerName("initWithContentRect:styleMask:backing:defer:"),
49
+ 0.0, 0.0, (double)width, (double)height,
50
+ style, 2, 0);
51
+ ((id(*)(id, SEL, id))objc_msgSend)(
52
+ win, sel_registerName("setTitle:"),
53
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
54
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
55
+ ((void(*)(id, SEL, double, double))objc_msgSend)(
56
+ win, sel_registerName("setFrameTopLeftPoint:"), 100.0, 100.0);
57
+ ((void(*)(id, SEL, id))objc_msgSend)(win, sel_registerName("makeKeyAndOrderFront:"), (id)0);
58
+ // The content view must resize with the window and autoresize its
59
+ // subviews so each control's autoresizingMask takes effect during a
60
+ // live resize (AppKit's blocking drag loop bypasses our event loop).
61
+ id cv = ((id(*)(id, SEL))objc_msgSend)(win, sel_registerName("contentView"));
62
+ ((void(*)(id, SEL, unsigned long))objc_msgSend)(cv, sel_registerName("setAutoresizingMask:"), 18UL);
63
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(cv, sel_registerName("setAutoresizesSubviews:"), 1);
64
+ self->handle = (uint64_t)win;
65
+ ```
66
+ ```
67
+ #arch: c
68
+ #platform: ios
69
+ id win = ((id(*)(id, SEL))objc_msgSend)(
70
+ ((id(*)(id, SEL))objc_msgSend)(objc_getClass("UIWindow"), sel_registerName("alloc")),
71
+ sel_registerName("initWithFrame:"),
72
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, (double)width, (double)height));
73
+ ((void(*)(id, SEL))objc_msgSend)(win, sel_registerName("makeKeyAndVisible"));
74
+ self->handle = (uint64_t)win;
75
+ ```
76
+ ```
77
+ #arch: aarch64_use_c
39
78
  #platform: ios
40
79
  id win = ((id(*)(id, SEL))objc_msgSend)(
41
80
  ((id(*)(id, SEL))objc_msgSend)(objc_getClass("UIWindow"), sel_registerName("alloc")),
@@ -48,12 +87,22 @@ pub class Window: Control {
48
87
 
49
88
  pub func show = (self) {
50
89
  ```
51
- #arch: c, aarch64_use_c
90
+ #arch: c
91
+ #platform: macos
92
+ ((void(*)(id, SEL, id))objc_msgSend)((id)self->handle, sel_registerName("makeKeyAndOrderFront:"), 0);
93
+ ```
94
+ ```
95
+ #arch: aarch64_use_c
52
96
  #platform: macos
53
97
  ((void(*)(id, SEL, id))objc_msgSend)((id)self->handle, sel_registerName("makeKeyAndOrderFront:"), 0);
54
98
  ```
55
99
  ```
56
- #arch: c, aarch64_use_c
100
+ #arch: c
101
+ #platform: ios
102
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("makeKeyAndVisible"));
103
+ ```
104
+ ```
105
+ #arch: aarch64_use_c
57
106
  #platform: ios
58
107
  ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("makeKeyAndVisible"));
59
108
  ```
@@ -61,24 +110,43 @@ pub class Window: Control {
61
110
 
62
111
  pub func set_title = (self, string title) {
63
112
  ```
64
- #arch: c, aarch64_use_c
113
+ #arch: c
65
114
  #platform: macos
66
115
  ((id(*)(id, SEL, id))objc_msgSend)(
67
116
  (id)self->handle, sel_registerName("setTitle:"),
68
117
  ((id(*)(id, SEL, const char*))objc_msgSend)(
69
118
  (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
70
119
  ```
120
+ ```
121
+ #arch: aarch64_use_c
122
+ #platform: macos
123
+ ((id(*)(id, SEL, id))objc_msgSend)(
124
+ (id)self->handle, sel_registerName("setTitle:"),
125
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
126
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
127
+ ```
71
128
  }
72
129
 
73
130
  pub func run = () {
74
131
  ```
75
- #arch: c, aarch64_use_c
132
+ #arch: c
133
+ #platform: macos
134
+ ((void(*)(id, SEL))objc_msgSend)(
135
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication")), sel_registerName("run"));
136
+ ```
137
+ ```
138
+ #arch: aarch64_use_c
76
139
  #platform: macos
77
140
  ((void(*)(id, SEL))objc_msgSend)(
78
141
  ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication")), sel_registerName("run"));
79
142
  ```
80
143
  ```
81
- #arch: c, aarch64_use_c
144
+ #arch: c
145
+ #platform: ios
146
+ UIApplicationMain(0, 0, 0, 0);
147
+ ```
148
+ ```
149
+ #arch: aarch64_use_c
82
150
  #platform: ios
83
151
  UIApplicationMain(0, 0, 0, 0);
84
152
  ```
@@ -90,7 +158,32 @@ pub class Window: Control {
90
158
  // Also runs the run loop briefly to process Apple Events (e.g. dock Quit).
91
159
  pub func process_events = (out int) {
92
160
  ```
93
- #arch: c, aarch64_use_c
161
+ #arch: c
162
+ #platform: macos
163
+ id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
164
+ id distant_past = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSDate"), sel_registerName("distantPast"));
165
+ id default_mode = ((id(*)(id, SEL, const char*))objc_msgSend)(
166
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), "kCFRunLoopDefaultMode");
167
+ int had_click = 0;
168
+ while (1) {
169
+ id event = ((id(*)(id, SEL, unsigned long long, id, id, BOOL))objc_msgSend)(
170
+ app, sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:"),
171
+ 0xFFFFFFFFFFFFFFFFULL, // NSEventMaskAny
172
+ distant_past, // untilDate — returns immediately if no events
173
+ default_mode, // inMode
174
+ 1); // dequeue
175
+ if (!event) break;
176
+ ((void(*)(id, SEL, id))objc_msgSend)(app, sel_registerName("sendEvent:"), event);
177
+ long type = ((long(*)(id, SEL))objc_msgSend)(event, sel_registerName("type"));
178
+ if (type == 1) had_click = 1; // NSLeftMouseDown = 1
179
+ }
180
+ // Process run loop sources (Apple Events, timers) so that dock Quit
181
+ // and other system interactions work without NSApplication.run().
182
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, 1);
183
+ return had_click;
184
+ ```
185
+ ```
186
+ #arch: aarch64_use_c
94
187
  #platform: macos
95
188
  id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
96
189
  id distant_past = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSDate"), sel_registerName("distantPast"));
@@ -115,7 +208,12 @@ pub class Window: Control {
115
208
  return had_click;
116
209
  ```
117
210
  ```
118
- #arch: c, aarch64_use_c
211
+ #arch: c
212
+ #platform: ios
213
+ return 0;
214
+ ```
215
+ ```
216
+ #arch: aarch64_use_c
119
217
  #platform: ios
120
218
  return 0;
121
219
  ```
@@ -125,13 +223,25 @@ pub class Window: Control {
125
223
  // manual event loop when the user closes the window.
126
224
  pub func is_visible = (self, out bool) {
127
225
  ```
128
- #arch: c, aarch64_use_c
226
+ #arch: c
227
+ #platform: macos
228
+ BOOL vis = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isVisible"));
229
+ return vis;
230
+ ```
231
+ ```
232
+ #arch: aarch64_use_c
129
233
  #platform: macos
130
234
  BOOL vis = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isVisible"));
131
235
  return vis;
132
236
  ```
133
237
  ```
134
- #arch: c, aarch64_use_c
238
+ #arch: c
239
+ #platform: ios
240
+ BOOL vis = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isKeyWindow"));
241
+ return vis;
242
+ ```
243
+ ```
244
+ #arch: aarch64_use_c
135
245
  #platform: ios
136
246
  BOOL vis = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isKeyWindow"));
137
247
  return vis;
@@ -142,7 +252,7 @@ pub class Window: Control {
142
252
  // recent mouse-down. Call after process_events returned 1.
143
253
  pub func click_x = (self, out int) {
144
254
  ```
145
- #arch: c, aarch64_use_c
255
+ #arch: c
146
256
  #platform: macos
147
257
  id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
148
258
  id event = ((id(*)(id, SEL))objc_msgSend)(app, sel_registerName("currentEvent"));
@@ -154,7 +264,24 @@ pub class Window: Control {
154
264
  return (int)loc.x;
155
265
  ```
156
266
  ```
157
- #arch: c, aarch64_use_c
267
+ #arch: aarch64_use_c
268
+ #platform: macos
269
+ id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
270
+ id event = ((id(*)(id, SEL))objc_msgSend)(app, sel_registerName("currentEvent"));
271
+ if (!event) return -1;
272
+ long type = ((long(*)(id, SEL))objc_msgSend)(event, sel_registerName("type"));
273
+ if (type != 1) return -1; // NSLeftMouseDown = 1
274
+ // locationInWindow is a CGPoint inside the event; read it via struct-return
275
+ CGPoint loc = ((CGPoint(*)(id, SEL))objc_msgSend)(event, sel_registerName("locationInWindow"));
276
+ return (int)loc.x;
277
+ ```
278
+ ```
279
+ #arch: c
280
+ #platform: ios
281
+ return -1;
282
+ ```
283
+ ```
284
+ #arch: aarch64_use_c
158
285
  #platform: ios
159
286
  return -1;
160
287
  ```
@@ -164,7 +291,21 @@ pub class Window: Control {
164
291
  // recent mouse-down, in the window's content view.
165
292
  pub func click_y = (self, out int) {
166
293
  ```
167
- #arch: c, aarch64_use_c
294
+ #arch: c
295
+ #platform: macos
296
+ id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
297
+ id event = ((id(*)(id, SEL))objc_msgSend)(app, sel_registerName("currentEvent"));
298
+ if (!event) return -1;
299
+ long type = ((long(*)(id, SEL))objc_msgSend)(event, sel_registerName("type"));
300
+ if (type != 1) return -1; // NSLeftMouseDown = 1
301
+ CGPoint loc = ((CGPoint(*)(id, SEL))objc_msgSend)(event, sel_registerName("locationInWindow"));
302
+ id cv = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("contentView"));
303
+ CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(cv, sel_registerName("frame"));
304
+ // NSWindow coords are bottom-left origin; flip to top-left for layout math
305
+ return (int)(frame.size.height - loc.y);
306
+ ```
307
+ ```
308
+ #arch: aarch64_use_c
168
309
  #platform: macos
169
310
  id app = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
170
311
  id event = ((id(*)(id, SEL))objc_msgSend)(app, sel_registerName("currentEvent"));
@@ -178,7 +319,12 @@ pub class Window: Control {
178
319
  return (int)(frame.size.height - loc.y);
179
320
  ```
180
321
  ```
181
- #arch: c, aarch64_use_c
322
+ #arch: c
323
+ #platform: ios
324
+ return -1;
325
+ ```
326
+ ```
327
+ #arch: aarch64_use_c
182
328
  #platform: ios
183
329
  return -1;
184
330
  ```
@@ -187,14 +333,30 @@ pub class Window: Control {
187
333
  // Returns the width of the window's content view.
188
334
  pub func content_width = (self, out int) {
189
335
  ```
190
- #arch: c, aarch64_use_c
336
+ #arch: c
191
337
  #platform: macos
192
338
  id cv = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("contentView"));
193
339
  CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(cv, sel_registerName("frame"));
194
340
  return (int)frame.size.width;
195
341
  ```
196
342
  ```
197
- #arch: c, aarch64_use_c
343
+ #arch: aarch64_use_c
344
+ #platform: macos
345
+ id cv = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("contentView"));
346
+ CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(cv, sel_registerName("frame"));
347
+ return (int)frame.size.width;
348
+ ```
349
+ ```
350
+ #arch: c
351
+ #platform: ios
352
+ id cv = ((id(*)(id, SEL))objc_msgSend)(
353
+ ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("rootViewController")),
354
+ sel_registerName("view"));
355
+ CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(cv, sel_registerName("frame"));
356
+ return (int)frame.size.width;
357
+ ```
358
+ ```
359
+ #arch: aarch64_use_c
198
360
  #platform: ios
199
361
  id cv = ((id(*)(id, SEL))objc_msgSend)(
200
362
  ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("rootViewController")),
@@ -207,14 +369,30 @@ pub class Window: Control {
207
369
  // Returns the height of the window's content view (for coordinate flipping).
208
370
  pub func content_height = (self, out int) {
209
371
  ```
210
- #arch: c, aarch64_use_c
372
+ #arch: c
373
+ #platform: macos
374
+ id cv = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("contentView"));
375
+ CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(cv, sel_registerName("frame"));
376
+ return (int)frame.size.height;
377
+ ```
378
+ ```
379
+ #arch: aarch64_use_c
211
380
  #platform: macos
212
381
  id cv = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("contentView"));
213
382
  CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(cv, sel_registerName("frame"));
214
383
  return (int)frame.size.height;
215
384
  ```
216
385
  ```
217
- #arch: c, aarch64_use_c
386
+ #arch: c
387
+ #platform: ios
388
+ id cv = ((id(*)(id, SEL))objc_msgSend)(
389
+ ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("rootViewController")),
390
+ sel_registerName("view"));
391
+ CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(cv, sel_registerName("frame"));
392
+ return (int)frame.size.height;
393
+ ```
394
+ ```
395
+ #arch: aarch64_use_c
218
396
  #platform: ios
219
397
  id cv = ((id(*)(id, SEL))objc_msgSend)(
220
398
  ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("rootViewController")),
@@ -244,14 +422,28 @@ pub class Window: Control {
244
422
 
245
423
  pub func set_frame = (ref self, int x, int y, int width, int height) {
246
424
  ```
247
- #arch: c, aarch64_use_c
425
+ #arch: c
248
426
  #platform: macos
249
427
  ((void(*)(id, SEL, CGRect))objc_msgSend)(
250
428
  (id)self->handle, sel_registerName("setFrame:"),
251
429
  ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
252
430
  ```
253
431
  ```
254
- #arch: c, aarch64_use_c
432
+ #arch: aarch64_use_c
433
+ #platform: macos
434
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
435
+ (id)self->handle, sel_registerName("setFrame:"),
436
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
437
+ ```
438
+ ```
439
+ #arch: c
440
+ #platform: ios
441
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
442
+ (id)self->handle, sel_registerName("setFrame:"),
443
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
444
+ ```
445
+ ```
446
+ #arch: aarch64_use_c
255
447
  #platform: ios
256
448
  ((void(*)(id, SEL, CGRect))objc_msgSend)(
257
449
  (id)self->handle, sel_registerName("setFrame:"),
@@ -261,7 +453,15 @@ pub class Window: Control {
261
453
 
262
454
  func #destroy = () {
263
455
  ```
264
- #arch: c, aarch64_use_c
456
+ #arch: c
457
+ #platform: macos
458
+ if (self->handle) {
459
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
460
+ self->handle = 0;
461
+ }
462
+ ```
463
+ ```
464
+ #arch: aarch64_use_c
265
465
  #platform: macos
266
466
  if (self->handle) {
267
467
  ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
@@ -269,7 +469,15 @@ pub class Window: Control {
269
469
  }
270
470
  ```
271
471
  ```
272
- #arch: c, aarch64_use_c
472
+ #arch: c
473
+ #platform: ios
474
+ if (self->handle) {
475
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
476
+ self->handle = 0;
477
+ }
478
+ ```
479
+ ```
480
+ #arch: aarch64_use_c
273
481
  #platform: ios
274
482
  if (self->handle) {
275
483
  ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
@@ -14,7 +14,7 @@ pub struct Graph<T>: Enumerable {
14
14
  var node_count = 0
15
15
  var edge_count = 0
16
16
 
17
- pub func add_node = (ref self, mov T value) {
17
+ pub func add_node = (ref self, move T value) {
18
18
  var int idx = self.node_count
19
19
  self.values.grow_T(idx + 1)
20
20
  self.values.store_T(idx, value)
@@ -8,16 +8,12 @@ pub struct Init {
8
8
  var bool is_tty
9
9
  }
10
10
 
11
+ // FFI: the C library's decimal-string parser (stdlib.h).
12
+ extern func atoi = (string s, out int)
13
+
11
14
  /**
12
15
  * Parses a decimal string into an int
13
16
  **/
14
17
  pub func parse_int = (string s, out int) {
15
- ```
16
- #arch: c
17
- return atoi(s);
18
- ```
19
- ```
20
- #arch: aarch64
21
- bl _atoi
22
- ```
18
+ return atoi(s)
23
19
  }
@@ -13,7 +13,7 @@ pub struct LinkedList<T>: Enumerable {
13
13
  var int head = -1
14
14
  var count = 0
15
15
 
16
- pub func add = (ref self, mov T value) {
16
+ pub func add = (ref self, move T value) {
17
17
  var int idx = self.count
18
18
  self.values.grow_T(idx + 1)
19
19
  self.values.store_T(idx, value)
@@ -5,7 +5,7 @@ pub struct List<T>: Viewable {
5
5
  var length = 0
6
6
  var Buffer<T> items = Buffer<T>()
7
7
 
8
- pub func push = (ref self, mov T value) {
8
+ pub func push = (ref self, move T value) {
9
9
  if self.length >= self.items.cap {
10
10
  var new_cap = 4
11
11
  var int old_cap = self.items.cap
@@ -18,7 +18,7 @@ pub struct List<T>: Viewable {
18
18
  self.length += 1
19
19
  }
20
20
 
21
- pub func pop = (ref self, mov out T) {
21
+ pub func pop = (ref self, move out T) {
22
22
  if self.length <= 0 {
23
23
  return self.items.move_T(0)
24
24
  }
@@ -57,7 +57,7 @@ pub struct List<T>: Viewable {
57
57
  return self.items.slice(start, end)
58
58
  }
59
59
 
60
- pub func set = (ref self, int i: i >= 0 && i < self.length, mov T value) {
60
+ pub func set = (ref self, int i: i >= 0 && i < self.length, move T value) {
61
61
  self.items.replace_T(i, value)
62
62
  }
63
63
 
@@ -24,7 +24,7 @@ pub struct Map<TK: Hashable + Equatable, TV> {
24
24
  }
25
25
  }
26
26
 
27
- pub func set = (ref self, mov TK key, mov TV value) {
27
+ pub func set = (ref self, move TK key, move TV value) {
28
28
  var int cap = self.keys.cap
29
29
  if cap == 0 {
30
30
  cap = self.keys.alloc_T(8)
@@ -166,9 +166,9 @@ pub struct Map<TK: Hashable + Equatable, TV> {
166
166
  }
167
167
 
168
168
  func rehash = (ref self, int new_cap) {
169
- var Buffer<TK> old_keys = mov self.keys swap Buffer<TK>()
170
- var Buffer<TV> old_values = mov self.values swap Buffer<TV>()
171
- var Buffer<int> old_used = mov self.used swap Buffer<int>()
169
+ var Buffer<TK> old_keys = move self.keys swap Buffer<TK>()
170
+ var Buffer<TV> old_values = move self.values swap Buffer<TV>()
171
+ var Buffer<int> old_used = move self.used swap Buffer<int>()
172
172
  var int old_cap = old_keys.cap
173
173
 
174
174
  self.keys.alloc_T(new_cap)
@@ -190,7 +190,7 @@ pub struct Map<TK: Hashable + Equatable, TV> {
190
190
  // move_T results.
191
191
  var TK k = old_keys.move_T(i)
192
192
  var TV v = old_values.move_T(i)
193
- self.set(mov k, mov v)
193
+ self.set(move k, move v)
194
194
  }
195
195
  }
196
196
  }
@@ -3,29 +3,17 @@
3
3
  **/
4
4
  pub struct Math {
5
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;
6
+ var result = 1
7
+ var i = 0
8
+ while i < exp; i += 1 {
9
+ result = result * base
11
10
  }
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
- ```
11
+ return result
27
12
  }
28
13
 
14
+ // Square root — stays an inline raw body for speed (see CORE_RAW.md):
15
+ // the single-fsqrt splice keeps `advance`'s inner loop call-free so it
16
+ // holds the SLP vector shapes; a real call scalarizes the loop.
29
17
  inline func sqrt = (float x, out float) {
30
18
  ```
31
19
  #arch: c
@@ -39,16 +27,6 @@ pub struct Math {
39
27
  ```
40
28
  }
41
29
 
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
- }
30
+ // libm natural logarithm — extern.
31
+ extern func log = (float x, out float)
54
32
  }
@@ -1,4 +1,4 @@
1
- pub enum Result<T, E> {
1
+ pub must_use enum Result<T, E> {
2
2
  case ok(T value)
3
3
  case error(E error)
4
4
  }
@@ -12,7 +12,7 @@ pub struct Set<T: Hashable + Equatable> {
12
12
  var Buffer<T> slots = Buffer<T>()
13
13
  var used = Buffer<int>()
14
14
 
15
- pub func add = (ref self, mov T value) {
15
+ pub func add = (ref self, move T value) {
16
16
  var int cap = self.slots.cap
17
17
  if cap == 0 {
18
18
  cap = self.slots.alloc_T(8)
@@ -148,8 +148,8 @@ pub struct Set<T: Hashable + Equatable> {
148
148
  }
149
149
 
150
150
  func rehash = (ref self, int new_cap) {
151
- var Buffer<T> old_slots = mov self.slots swap Buffer<T>()
152
- var Buffer<int> old_used = mov self.used swap Buffer<int>()
151
+ var Buffer<T> old_slots = move self.slots swap Buffer<T>()
152
+ var Buffer<int> old_used = move self.used swap Buffer<int>()
153
153
  var int old_cap = old_slots.cap
154
154
 
155
155
  self.slots.alloc_T(new_cap)
@@ -168,7 +168,7 @@ pub struct Set<T: Hashable + Equatable> {
168
168
  // once the new buffer has made its own copy — passing it inline
169
169
  // would orphan the move_T result.
170
170
  var T v = old_slots.move_T(i)
171
- self.add(mov v)
171
+ self.add(move v)
172
172
  }
173
173
  }
174
174
  }