nomen-lang 0.10.0 → 0.12.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.
- package/NOMEN_AGENTS.md +7 -6
- package/core/System/Controls/App.nm +8 -0
- package/core/System/Controls/Container.nm +148 -44
- package/core/System/Controls/Window.nm +363 -51
- package/core/System/Format.nm +751 -0
- package/core/assets/nomen.png +0 -0
- package/dist/index.mjs +3425 -416
- package/package.json +1 -1
- package/src/args.ts +1 -1
- package/src/docs.ts +10 -1
- package/src/index.ts +15 -1
- package/src/types/Config.ts +1 -1
package/package.json
CHANGED
package/src/args.ts
CHANGED
|
@@ -174,7 +174,7 @@ export function print_help(): void {
|
|
|
174
174
|
" --config, -c <path> Path to a config file",
|
|
175
175
|
" --watch, -w Watch for file changes",
|
|
176
176
|
" --filter, -f <regex> Only run test files whose path matches this regex",
|
|
177
|
-
" --arch, -a <arch> Target architecture: aarch64 | c (default: aarch64)",
|
|
177
|
+
" --arch, -a <arch> Target architecture: aarch64 | c | js (default: aarch64)",
|
|
178
178
|
" --platform, -p <name> Target platform: macos, ios, linux, android, windows, web",
|
|
179
179
|
" --lib, -l <path> Path to System library directory (containing package.jsonc)",
|
|
180
180
|
" --audit Audit the generated program for memory issues",
|
package/src/docs.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type BaseNode from "../../src/nodes/BaseNode.ts";
|
|
|
6
6
|
import type BitsetNode from "../../src/nodes/BitsetNode.ts";
|
|
7
7
|
import type EnumNode from "../../src/nodes/EnumNode.ts";
|
|
8
8
|
import type FunctionNode from "../../src/nodes/FunctionNode.ts";
|
|
9
|
+
import type ParameterNode from "../../src/nodes/ParameterNode.ts";
|
|
9
10
|
import type StructNode from "../../src/nodes/StructNode.ts";
|
|
10
11
|
import type TraitNode from "../../src/nodes/TraitNode.ts";
|
|
11
12
|
import type Type from "../../src/nodes/Type.ts";
|
|
@@ -231,12 +232,20 @@ function heading_of(item: DocItem): string {
|
|
|
231
232
|
function signature_of(fn: FunctionNode): string {
|
|
232
233
|
const params = fn.params
|
|
233
234
|
.filter((p) => !p.is_self_param)
|
|
234
|
-
.map((p) => `${render_type(p.type)}${p.name ? " " + p.name : ""}`);
|
|
235
|
+
.map((p) => `${render_type(p.type)}${p.name ? " " + p.name : ""}${field_set_of(p)}`);
|
|
235
236
|
let sig = `${fn.name}(${params.join(", ")})`;
|
|
236
237
|
if (fn.return_type?.name) sig += ` -> ${render_type(fn.return_type)}`;
|
|
237
238
|
return sig;
|
|
238
239
|
}
|
|
239
240
|
|
|
241
|
+
/** The declared field set suffix (FIELD_EFFECTS.md): `{}` for "displaces
|
|
242
|
+
* nothing", `{ a, b }` for a named set, nothing for a wildcard. */
|
|
243
|
+
function field_set_of(param: ParameterNode): string {
|
|
244
|
+
if (param.field_set === undefined) return "";
|
|
245
|
+
if (param.field_set.length === 0) return " {}";
|
|
246
|
+
return ` { ${param.field_set.join(", ")} }`;
|
|
247
|
+
}
|
|
248
|
+
|
|
240
249
|
function members_of(node: BaseNode): FunctionNode[] {
|
|
241
250
|
if (node.node_type === "struct" || node.node_type === "trait") {
|
|
242
251
|
const n = node as unknown as { functions: FunctionNode[] };
|
package/src/index.ts
CHANGED
|
@@ -165,7 +165,7 @@ try {
|
|
|
165
165
|
config = JSON.parse(fs.readFileSync(args.config, "utf-8"));
|
|
166
166
|
}
|
|
167
167
|
// Overwrite with args
|
|
168
|
-
if (args.arch) config.arch = args.arch as "aarch64" | "c";
|
|
168
|
+
if (args.arch) config.arch = args.arch as "aarch64" | "c" | "js";
|
|
169
169
|
if (args.platform) config.platform = args.platform;
|
|
170
170
|
if (args.lib) config.lib = args.lib;
|
|
171
171
|
if (args.audit) config.audit = args.audit;
|
|
@@ -382,6 +382,20 @@ function processFile(filename: string, config: Config, mode: Mode, program_args:
|
|
|
382
382
|
// Output lives in the project's `build/` — `build/test` for *.test.nm —
|
|
383
383
|
// unless an explicit --out names the linked binary.
|
|
384
384
|
const buildDir = build_dir_for(resolved, filename.endsWith(".test.nm"));
|
|
385
|
+
|
|
386
|
+
// The JS backend emits a self-contained ESM module; `run` executes it with
|
|
387
|
+
// Node instead of compiling and linking a native binary.
|
|
388
|
+
if (arch === "js") {
|
|
389
|
+
if (!fs.existsSync(buildDir)) fs.mkdirSync(buildDir, { recursive: true });
|
|
390
|
+
const jsfile = path.join(buildDir, basename + ".mjs");
|
|
391
|
+
fs.writeFileSync(jsfile, result.code);
|
|
392
|
+
console.log(`Created ${jsfile} in ${(performance.now() - startTime).toFixed(2)}ms`);
|
|
393
|
+
if (mode === "run") {
|
|
394
|
+
execFileSync(process.env.NODE ?? "node", [jsfile, ...program_args], { stdio: "inherit" });
|
|
395
|
+
console.log(`Completed in ${(performance.now() - startTime).toFixed(2)}ms`);
|
|
396
|
+
}
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
385
399
|
if (!fs.existsSync(buildDir)) {
|
|
386
400
|
fs.mkdirSync(buildDir, { recursive: true });
|
|
387
401
|
}
|
package/src/types/Config.ts
CHANGED