v4 mkf18a: import nucleus NAME -- hash 0, the effect from the nucleus (task 4, part 1)
mkf18a takes nucleus=SYSDIR, assembles the nucleus as the ROM does and looks NAME up by its dictionary name; a word in line there, or one with no fixed effect, is refused (plan section 12, rulings 3 and 4). test_mkf18a: 5 new checks failed first, 93 pass at both widths. Its build now has the host node's size, as the tool's has: the nucleus did not fit a mesh node's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -61,6 +61,7 @@ static int save(const char *path, const unsigned char *a, size_t len)
|
||||
}
|
||||
|
||||
/* the build of `dir`, with MAP, ROM and the trains given; NULL, err set, if it is refused */
|
||||
static const char *nucleus; /* `import nucleus` builds against it when set */
|
||||
static unsigned char *build(const char *dir, const f18a_train *trains, unsigned ntrains, size_t *len)
|
||||
{
|
||||
f18a_args a;
|
||||
@@ -71,6 +72,7 @@ static unsigned char *build(const char *dir, const f18a_train *trains, unsigned
|
||||
a.trains = trains;
|
||||
a.ntrains = ntrains;
|
||||
a.tool_root = V4_ROOT;
|
||||
a.nucleus = nucleus;
|
||||
err[0] = 0;
|
||||
if (!f18a_build(&a, &out, len, err, sizeof err)) return NULL;
|
||||
return out;
|
||||
@@ -323,6 +325,34 @@ int main(void)
|
||||
free(c);
|
||||
}
|
||||
|
||||
/* imports from the nucleus (section 12, rulings 3 and 4): hash 0, the effect derived from the nucleus
|
||||
* as the tool assembles it, by its dictionary name */
|
||||
put(SCRATCH "/n1", "00.f18", "import nucleus ABS\n: DIST inv 1 + + ABS ;\n");
|
||||
CHECK(refused(SCRATCH "/n1", NULL, 0, "nucleus"), "an import from the nucleus, with no nucleus given");
|
||||
nucleus = V4_SYS_DIR;
|
||||
{
|
||||
size_t ln;
|
||||
unsigned char *c = build(SCRATCH "/n1", NULL, 0, &ln);
|
||||
v4_f18a_layout lc;
|
||||
CHECK(c != NULL, "an import from the nucleus builds: %s", err);
|
||||
if (c) {
|
||||
CHECK(v4_f18a_check(c, ln, V4_CELL_BITS, &lc, &why) && lc.i == 1, "valid, with one import");
|
||||
CHECK(U(c, lc.imports) == 0 && U(c, lc.imports + 1) == 0, "the nucleus's hash: 0");
|
||||
CHECK(pool_is(c, &lc, U(c, lc.imports + 2), "ABS"), "the import's name, ABS");
|
||||
CHECK(U(c, lc.imports + 3) == (1u | (1u << 16)) && U(c, lc.imports + 4) == 0, "ABS's effect from the nucleus: 1 -> 1");
|
||||
x = export_of(c, &lc, "DIST");
|
||||
CHECK(x && U(c, x + 3) == (2u | (1u << 16)), "DIST, calling it, 2 -> 1");
|
||||
free(c);
|
||||
}
|
||||
}
|
||||
put(SCRATCH "/n2", "00.f18", "import nucleus NOPE\n: W NOPE ;\n");
|
||||
CHECK(refused(SCRATCH "/n2", NULL, 0, "NOPE"), "a name the nucleus does not have");
|
||||
put(SCRATCH "/n3", "00.f18", "import nucleus SCR\n: W SCR ;\n");
|
||||
CHECK(refused(SCRATCH "/n3", NULL, 0, "in line"), "a word in line in the nucleus, which cannot be called");
|
||||
put(SCRATCH "/n4", "00.f18", "import nucleus UM*\n: W UM* ;\n");
|
||||
CHECK(refused(SCRATCH "/n4", NULL, 0, "no fixed effect"), "a nucleus word with no fixed effect");
|
||||
nucleus = NULL;
|
||||
|
||||
free(a);
|
||||
done:
|
||||
free(lib);
|
||||
|
||||
Reference in New Issue
Block a user