commit: 45ec205ca40056411a2939456fefa67953db9e63
parent 66d79e14a5a977b31045dbde6a5828d2873f9c9b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Oct 2022 01:25:16 +0200
Add support for Parrot bytecode (aka PBC)
Diffstat:
7 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/.reuse/dep5 b/.reuse/dep5
@@ -3,6 +3,6 @@ Upstream-Name: deblob
Upstream-Contact: deblob Authors <https://hacktivis.me/projects/deblob>
Source: https://hacktivis.me/projects/deblob
-Files: test/fixtures/pyc/*.pyc test/fixtures/hello.luac* test/fixtures/hello.class test/fixtures/hello.nqp.moarvm
+Files: test/fixtures/pyc/*.pyc test/fixtures/hello.luac* test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc
Copyright: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob>
License: BSD-3-Clause
diff --git a/Makefile b/Makefile
@@ -15,9 +15,10 @@ MANDOC ?= mandoc
REUSE ?= reuse
JAVAC ?= javac
NQP ?= nqp
+PARROT ?= parrot
EXE = deblob
-TEST_BLOBS = test/fixtures/hello test/fixtures/hello.a test/fixtures/hello.o test/fixtures/hello.exe test/fixtures/hello.luac53 test/fixtures/hello.luac54 test/fixtures/hello.wasm test/fixtures/hello.class test/fixtures/hello.nqp.moarvm
+TEST_BLOBS = test/fixtures/hello test/fixtures/hello.a test/fixtures/hello.o test/fixtures/hello.exe test/fixtures/hello.luac53 test/fixtures/hello.luac54 test/fixtures/hello.wasm test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc
all: $(EXE)
@@ -55,6 +56,9 @@ test/fixtures/hello.class: test/fixtures/hello.java
test/fixtures/hello.nqp.moarvm: test/fixtures/hello.nqp
$(NQP) --target mbc --output=$@ test/fixtures/hello.nqp
+test/fixtures/hello.pir.pbc: test/fixtures/hello.pir
+ $(PARROT) -o $@ test/fixtures/hello.pir
+
.PHONY: test
test: all $(TEST_BLOBS)
rm -fr test/check_dir-fixtures
diff --git a/README.md b/README.md
@@ -27,6 +27,7 @@ Dependencies:
- wasm assembler, default one is `wat2wasm` from [wabt](https://github.com/WebAssembly/wabt)
- Java Development Kit, defaults to `javac`. Any version should work, including early bootstrap with jamvm 1.5+
- [NQP](https://github.com/Raku/nqp) aka Not Quite Perl
+- [Parrot](http://www.parrot.org/)
Rebuilding:
```
diff --git a/deblob.1 b/deblob.1
@@ -62,6 +62,8 @@ WASM (Web Assembly)
Apple Preferred Executable Format
.It
MoarVM bytecode
+.It
+Parrot bytecode
.El
.Sh EXAMPLES
The following code block shows how it can be used in Gentoo's
diff --git a/main.ha b/main.ha
@@ -33,6 +33,8 @@ const magic: [_][]u8 = [
[0x6F, 0x0D, '\r', '\n'], // (3439i litte-endian) Python 3.10
// MoarVM bytecode https://github.com/MoarVM/MoarVM/blob/master/docs/bytecode.markdown
['M', 'O', 'A', 'R', 'V', 'M', '\r', '\n'],
+ // Parrot Bytecode https://github.com/parrot/parrot/blob/master/docs/parrotbyte.pod
+ [0xFE, 'P', 'B', 'C', '\r', '\n', 0x1A, '\n'],
];
const dos_magic: []u8 = ['M', 'Z'];
const pe_magic: []u8 = ['P', 'E', 0x00, 0x00];
@@ -77,6 +79,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = {
("test/fixtures/hello.py", false),
("test/fixtures/hello.java", false),
("test/fixtures/hello.nqp", false),
+ ("test/fixtures/hello.pir", false),
("test/fixtures/hello", true),
("test/fixtures/hello.luac53", true),
("test/fixtures/hello.luac54", true),
@@ -90,6 +93,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = {
//("test/fixtures/option.rom", true),
("test/fixtures/qemu_vga.ndrv", true),
("test/fixtures/hello.nqp.moarvm", true),
+ ("test/fixtures/hello.pir.pbc", true),
("test/fixtures/empty", false),
];
@@ -191,7 +195,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = {
case let e: fs::error =>
fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_before) == 29);
+ assert(len(files_before) == 31);
const ret = check_dir(dirname);
assert(ret is void);
@@ -202,7 +206,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = {
case let e: fs::error =>
fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_after) == 17);
+ assert(len(files_after) == 18);
};
export fn main() void = {
diff --git a/test/fixtures/hello.pir b/test/fixtures/hello.pir
@@ -0,0 +1,5 @@
+# SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob>
+# SPDX-License-Identifier: BSD-3-Clause
+.sub main
+ say "Hello, World!"
+.end
diff --git a/test/fixtures/hello.pir.pbc b/test/fixtures/hello.pir.pbc
Binary files differ.