Skip to content

Commit b67dad0

Browse files
committed
Patch CFA>
1 parent e5a5036 commit b67dad0

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

build.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ pub fn build(b: *std.Build) !void {
6767
std.fs.path.basename(sub_path),
6868
);
6969
emcc_step.dependOn(&file.step);
70+
if (comptime std.mem.eql(u8, sub_path, "jonesforth/jonesforth.f")) {
71+
const patch = b.addSystemCommand(&.{
72+
"patch",
73+
b.getInstallPath(file.dir, file.dest_rel_path),
74+
});
75+
patch.addFileArg(b.path("src/jonesforth.f.patch"));
76+
emcc_step.dependOn(&patch.step);
77+
}
7078
}
7179
b.getInstallStep().dependOn(emcc_step);
7280

src/jonesforth.f.patch

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
995,996c995,996
2+
< 2DUP SWAP ( cfa curr curr cfa )
3+
< < IF ( current dictionary entry < cfa? )
4+
---
5+
> 2DUP >CFA ( cfa curr curr cfa )
6+
> = IF ( current dictionary entry < cfa? )

src/zorth.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ test forth {
11611161
.{ preamble ++ "SEE >DFA ", fmt.comptimePrint(": >DFA >CFA {d}+ EXIT ;\n", .{@sizeOf(usize)}) },
11621162
.{ preamble ++ "SEE HIDE ", ": HIDE WORD FIND HIDDEN ;\n" },
11631163
.{ preamble ++ "SEE QUIT ", fmt.comptimePrint(": QUIT R0 RSP! INTERPRET BRANCH ( -{d} ) ;\n", .{2 * @sizeOf(usize)}) },
1164+
.{ preamble ++ "SEE / ", ": / /MOD SWAP DROP ;\n" },
11641165
.{
11651166
preamble ++
11661167
\\: FOO THROW ;

0 commit comments

Comments
 (0)