torva 0.3.0__tar.gz
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.
- torva-0.3.0/.github/workflows/ci.yml +55 -0
- torva-0.3.0/.github/workflows/release.yml +60 -0
- torva-0.3.0/.gitignore +24 -0
- torva-0.3.0/.python-version +1 -0
- torva-0.3.0/.vscode/extensions.json +6 -0
- torva-0.3.0/.vscode/settings.json +26 -0
- torva-0.3.0/Cargo.lock +218 -0
- torva-0.3.0/Cargo.toml +26 -0
- torva-0.3.0/LICENSE +21 -0
- torva-0.3.0/PKG-INFO +109 -0
- torva-0.3.0/README.md +97 -0
- torva-0.3.0/docs/editors.md +113 -0
- torva-0.3.0/docs/language.md +259 -0
- torva-0.3.0/docs/python.md +260 -0
- torva-0.3.0/docs/rust.md +139 -0
- torva-0.3.0/docs/sandboxing.md +69 -0
- torva-0.3.0/examples/collatz.tv +34 -0
- torva-0.3.0/examples/exports.py +71 -0
- torva-0.3.0/examples/host.py +31 -0
- torva-0.3.0/examples/host.rs +42 -0
- torva-0.3.0/examples/host.tv +9 -0
- torva-0.3.0/examples/pfib.tv +15 -0
- torva-0.3.0/pyproject.toml +42 -0
- torva-0.3.0/src/binary.rs +418 -0
- torva-0.3.0/src/compiler/codegen.rs +2308 -0
- torva-0.3.0/src/compiler/cst.rs +98 -0
- torva-0.3.0/src/compiler/format.rs +173 -0
- torva-0.3.0/src/compiler/mod.rs +1268 -0
- torva-0.3.0/src/compiler/strings.rs +187 -0
- torva-0.3.0/src/compiler/syntax.rs +2010 -0
- torva-0.3.0/src/fiber.rs +141 -0
- torva-0.3.0/src/heap.rs +369 -0
- torva-0.3.0/src/interp.rs +1091 -0
- torva-0.3.0/src/lib.rs +49 -0
- torva-0.3.0/src/limits.rs +429 -0
- torva-0.3.0/src/program.rs +872 -0
- torva-0.3.0/src/python.rs +1856 -0
- torva-0.3.0/src/scheduler.rs +798 -0
- torva-0.3.0/src/text.rs +731 -0
- torva-0.3.0/src/value.rs +429 -0
- torva-0.3.0/src/verify.rs +473 -0
- torva-0.3.0/src/vm.rs +340 -0
- torva-0.3.0/tests/compile.rs +393 -0
- torva-0.3.0/tests/embed.rs +495 -0
- torva-0.3.0/tests/heap.rs +415 -0
- torva-0.3.0/tests/limits.rs +398 -0
- torva-0.3.0/tests/syntax.rs +218 -0
- torva-0.3.0/tests/test_compiler.py +2912 -0
- torva-0.3.0/tests/test_torva.py +580 -0
- torva-0.3.0/torva.pyi +372 -0
- torva-0.3.0/uv.lock +153 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
rust:
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
21
|
+
with:
|
|
22
|
+
components: clippy, rustfmt
|
|
23
|
+
- run: cargo fmt --check
|
|
24
|
+
- run: cargo clippy --all-targets -- -D warnings
|
|
25
|
+
- run: cargo clippy --all-targets --features checked -- -D warnings
|
|
26
|
+
- run: cargo clippy --lib --features python -- -D warnings
|
|
27
|
+
- run: cargo test
|
|
28
|
+
- run: cargo test --features checked
|
|
29
|
+
|
|
30
|
+
python:
|
|
31
|
+
strategy:
|
|
32
|
+
fail-fast: false
|
|
33
|
+
matrix:
|
|
34
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
35
|
+
python: ["3.13", "3.14", "3.15"]
|
|
36
|
+
runs-on: ${{ matrix.os }}
|
|
37
|
+
env:
|
|
38
|
+
UV_PYTHON: ${{ matrix.python }}
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
42
|
+
- uses: astral-sh/setup-uv@v6
|
|
43
|
+
- run: uv sync
|
|
44
|
+
- run: uv run pytest
|
|
45
|
+
|
|
46
|
+
lint:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v4
|
|
50
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
51
|
+
- uses: astral-sh/setup-uv@v6
|
|
52
|
+
- run: uv sync
|
|
53
|
+
- run: uv run ruff check
|
|
54
|
+
- run: uv run ruff format --check
|
|
55
|
+
- run: uv run pyrefly check
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
wheels:
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
include:
|
|
15
|
+
- { os: ubuntu-latest, target: x86_64 }
|
|
16
|
+
- { os: ubuntu-24.04-arm, target: aarch64 }
|
|
17
|
+
- { os: macos-latest, target: aarch64 }
|
|
18
|
+
- { os: macos-latest, target: x86_64 }
|
|
19
|
+
- { os: windows-latest, target: x64 }
|
|
20
|
+
runs-on: ${{ matrix.os }}
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
- uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.13"
|
|
26
|
+
- uses: PyO3/maturin-action@v1
|
|
27
|
+
with:
|
|
28
|
+
target: ${{ matrix.target }}
|
|
29
|
+
args: --release --out dist
|
|
30
|
+
manylinux: auto
|
|
31
|
+
- uses: actions/upload-artifact@v4
|
|
32
|
+
with:
|
|
33
|
+
name: wheel-${{ matrix.os }}-${{ matrix.target }}
|
|
34
|
+
path: dist
|
|
35
|
+
|
|
36
|
+
sdist:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: PyO3/maturin-action@v1
|
|
41
|
+
with:
|
|
42
|
+
command: sdist
|
|
43
|
+
args: --out dist
|
|
44
|
+
- uses: actions/upload-artifact@v4
|
|
45
|
+
with:
|
|
46
|
+
name: sdist
|
|
47
|
+
path: dist
|
|
48
|
+
|
|
49
|
+
publish:
|
|
50
|
+
needs: [wheels, sdist]
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
environment: pypi
|
|
53
|
+
permissions:
|
|
54
|
+
id-token: write
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/download-artifact@v4
|
|
57
|
+
with:
|
|
58
|
+
path: dist
|
|
59
|
+
merge-multiple: true
|
|
60
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
torva-0.3.0/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Rust build output
|
|
13
|
+
target/
|
|
14
|
+
|
|
15
|
+
# Compiled extension modules
|
|
16
|
+
*.so
|
|
17
|
+
*.pyd
|
|
18
|
+
|
|
19
|
+
# Test cache
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
|
|
22
|
+
# Compiled programs
|
|
23
|
+
*.tva
|
|
24
|
+
*.tvb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.15
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"[python]": {
|
|
3
|
+
"editor.formatOnSave": true,
|
|
4
|
+
"editor.codeActionsOnSave": {
|
|
5
|
+
"source.fixAll": "explicit",
|
|
6
|
+
"source.organizeImports": "explicit"
|
|
7
|
+
},
|
|
8
|
+
"editor.defaultFormatter": "charliermarsh.ruff"
|
|
9
|
+
},
|
|
10
|
+
"[rust]": {
|
|
11
|
+
"editor.formatOnSave": true,
|
|
12
|
+
"editor.codeActionsOnSave": {
|
|
13
|
+
"source.organizeImports": "explicit"
|
|
14
|
+
},
|
|
15
|
+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
|
|
16
|
+
},
|
|
17
|
+
"rust-analyzer.check.command": "clippy",
|
|
18
|
+
"rust-analyzer.cargo.features": ["python"],
|
|
19
|
+
"python.testing.pytestArgs": [
|
|
20
|
+
"tests"
|
|
21
|
+
],
|
|
22
|
+
"python.testing.unittestEnabled": false,
|
|
23
|
+
"python.testing.pytestEnabled": true,
|
|
24
|
+
"python.terminal.activateEnvironment": false,
|
|
25
|
+
"python-envs.terminal.autoActivationType": "off"
|
|
26
|
+
}
|
torva-0.3.0/Cargo.lock
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "countme"
|
|
7
|
+
version = "3.0.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "crossbeam-deque"
|
|
13
|
+
version = "0.8.8"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"crossbeam-epoch",
|
|
18
|
+
"crossbeam-utils",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[[package]]
|
|
22
|
+
name = "crossbeam-epoch"
|
|
23
|
+
version = "0.9.21"
|
|
24
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
25
|
+
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"crossbeam-utils",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[[package]]
|
|
31
|
+
name = "crossbeam-utils"
|
|
32
|
+
version = "0.8.23"
|
|
33
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
34
|
+
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "equivalent"
|
|
38
|
+
version = "1.0.3"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
|
41
|
+
|
|
42
|
+
[[package]]
|
|
43
|
+
name = "hashbrown"
|
|
44
|
+
version = "0.14.5"
|
|
45
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
46
|
+
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
|
47
|
+
|
|
48
|
+
[[package]]
|
|
49
|
+
name = "hashbrown"
|
|
50
|
+
version = "0.17.2"
|
|
51
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
52
|
+
checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
|
|
53
|
+
|
|
54
|
+
[[package]]
|
|
55
|
+
name = "heck"
|
|
56
|
+
version = "0.5.0"
|
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
58
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "indexmap"
|
|
62
|
+
version = "2.14.2"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
|
65
|
+
dependencies = [
|
|
66
|
+
"equivalent",
|
|
67
|
+
"hashbrown 0.17.2",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[[package]]
|
|
71
|
+
name = "libc"
|
|
72
|
+
version = "0.2.191"
|
|
73
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "once_cell"
|
|
78
|
+
version = "1.21.4"
|
|
79
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
81
|
+
|
|
82
|
+
[[package]]
|
|
83
|
+
name = "portable-atomic"
|
|
84
|
+
version = "1.15.0"
|
|
85
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
86
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
87
|
+
|
|
88
|
+
[[package]]
|
|
89
|
+
name = "proc-macro2"
|
|
90
|
+
version = "1.0.107"
|
|
91
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
92
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
93
|
+
dependencies = [
|
|
94
|
+
"unicode-ident",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[[package]]
|
|
98
|
+
name = "pyo3"
|
|
99
|
+
version = "0.30.1"
|
|
100
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
101
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
102
|
+
dependencies = [
|
|
103
|
+
"libc",
|
|
104
|
+
"once_cell",
|
|
105
|
+
"portable-atomic",
|
|
106
|
+
"pyo3-build-config",
|
|
107
|
+
"pyo3-ffi",
|
|
108
|
+
"pyo3-macros",
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[[package]]
|
|
112
|
+
name = "pyo3-build-config"
|
|
113
|
+
version = "0.30.1"
|
|
114
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
115
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
116
|
+
dependencies = [
|
|
117
|
+
"target-lexicon",
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
[[package]]
|
|
121
|
+
name = "pyo3-ffi"
|
|
122
|
+
version = "0.30.1"
|
|
123
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
124
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
125
|
+
dependencies = [
|
|
126
|
+
"libc",
|
|
127
|
+
"pyo3-build-config",
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
[[package]]
|
|
131
|
+
name = "pyo3-macros"
|
|
132
|
+
version = "0.30.1"
|
|
133
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
135
|
+
dependencies = [
|
|
136
|
+
"proc-macro2",
|
|
137
|
+
"pyo3-macros-backend",
|
|
138
|
+
"quote",
|
|
139
|
+
"syn",
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
[[package]]
|
|
143
|
+
name = "pyo3-macros-backend"
|
|
144
|
+
version = "0.30.1"
|
|
145
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
146
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
147
|
+
dependencies = [
|
|
148
|
+
"heck",
|
|
149
|
+
"proc-macro2",
|
|
150
|
+
"quote",
|
|
151
|
+
"syn",
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
[[package]]
|
|
155
|
+
name = "quote"
|
|
156
|
+
version = "1.0.47"
|
|
157
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
158
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
159
|
+
dependencies = [
|
|
160
|
+
"proc-macro2",
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
[[package]]
|
|
164
|
+
name = "rowan"
|
|
165
|
+
version = "0.16.1"
|
|
166
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
167
|
+
checksum = "417a3a9f582e349834051b8a10c8d71ca88da4211e4093528e36b9845f6b5f21"
|
|
168
|
+
dependencies = [
|
|
169
|
+
"countme",
|
|
170
|
+
"hashbrown 0.14.5",
|
|
171
|
+
"rustc-hash",
|
|
172
|
+
"text-size",
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
[[package]]
|
|
176
|
+
name = "rustc-hash"
|
|
177
|
+
version = "1.1.0"
|
|
178
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
179
|
+
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
180
|
+
|
|
181
|
+
[[package]]
|
|
182
|
+
name = "syn"
|
|
183
|
+
version = "3.0.10"
|
|
184
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
185
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
186
|
+
dependencies = [
|
|
187
|
+
"proc-macro2",
|
|
188
|
+
"quote",
|
|
189
|
+
"unicode-ident",
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
[[package]]
|
|
193
|
+
name = "target-lexicon"
|
|
194
|
+
version = "0.13.6"
|
|
195
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
196
|
+
checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
|
|
197
|
+
|
|
198
|
+
[[package]]
|
|
199
|
+
name = "text-size"
|
|
200
|
+
version = "1.1.1"
|
|
201
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
202
|
+
checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
|
|
203
|
+
|
|
204
|
+
[[package]]
|
|
205
|
+
name = "torva"
|
|
206
|
+
version = "0.3.0"
|
|
207
|
+
dependencies = [
|
|
208
|
+
"crossbeam-deque",
|
|
209
|
+
"indexmap",
|
|
210
|
+
"pyo3",
|
|
211
|
+
"rowan",
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
[[package]]
|
|
215
|
+
name = "unicode-ident"
|
|
216
|
+
version = "1.0.27"
|
|
217
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
218
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
torva-0.3.0/Cargo.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "torva"
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
description = "A lightweight virtual machine that runs programs as fibers across all CPU cores"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
repository = "https://github.com/travispaxton/torva"
|
|
9
|
+
|
|
10
|
+
[lib]
|
|
11
|
+
name = "torva"
|
|
12
|
+
crate-type = ["cdylib", "rlib"]
|
|
13
|
+
|
|
14
|
+
[dependencies]
|
|
15
|
+
crossbeam-deque = "0.8.8"
|
|
16
|
+
indexmap = "2.14.2"
|
|
17
|
+
pyo3 = { version = "0.30.1", features = ["abi3-py313"], optional = true }
|
|
18
|
+
rowan = "0.16"
|
|
19
|
+
|
|
20
|
+
[features]
|
|
21
|
+
# The Python extension module; maturin enables it.
|
|
22
|
+
python = ["dep:pyo3"]
|
|
23
|
+
# The interpreter bounds-checks instruction and register indexes even though
|
|
24
|
+
# loading proved them in range, turning a loader bug into a panic, which fails
|
|
25
|
+
# the fiber with an InternalError, instead of undefined behavior.
|
|
26
|
+
checked = []
|
torva-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Travis Paxton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
torva-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: torva
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
License-File: LICENSE
|
|
5
|
+
Summary: A lightweight virtual machine that runs programs as fibers across all CPU cores
|
|
6
|
+
Author-email: travispaxton <2214573+travispaxton@users.noreply.github.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Requires-Python: >=3.13
|
|
9
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
10
|
+
Project-URL: Repository, https://github.com/travispaxton/torva
|
|
11
|
+
|
|
12
|
+
# torva
|
|
13
|
+
|
|
14
|
+
A lightweight virtual machine that runs programs as fibers across all CPU
|
|
15
|
+
cores, for running code you didn't write inside a Python or Rust service.
|
|
16
|
+
|
|
17
|
+
- **Parallel.** Programs start tasks that run on every core. Fibers are
|
|
18
|
+
preempted, so one busy fiber can't starve the others, and the VM never
|
|
19
|
+
holds Python's GIL.
|
|
20
|
+
- **Sandboxed.** A program reaches the outside world only through the
|
|
21
|
+
functions you give it, with the types you declare. Limits cap the fuel,
|
|
22
|
+
time, memory, tasks and cores each call may use.
|
|
23
|
+
- **Typed.** Programs are written in a small, statically typed language. The
|
|
24
|
+
compiler is built in, and every module is verified when it loads.
|
|
25
|
+
- **Embeddable.** Give programs functions from Python, sync or `async`, or
|
|
26
|
+
from Rust. Your records become the program's types.
|
|
27
|
+
- **Editor-ready.** Completion, errors as you type, hover, go-to-definition
|
|
28
|
+
and formatting for the language, from the same compiler.
|
|
29
|
+
|
|
30
|
+
```go
|
|
31
|
+
from host import log(message: str), fetch_price(item: str) -> float
|
|
32
|
+
from torva import task
|
|
33
|
+
|
|
34
|
+
fn total(a: str, b: str) -> float {
|
|
35
|
+
log("pricing " + a + " and " + b)
|
|
36
|
+
x = task.start(fetch_price, a)
|
|
37
|
+
y = task.start(fetch_price, b)
|
|
38
|
+
return x.wait() + y.wait()
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import asyncio
|
|
44
|
+
import torva
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def log(message: str) -> None:
|
|
48
|
+
print(f"[torva] {message}")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async def fetch_price(item: str) -> float:
|
|
52
|
+
await asyncio.sleep(0.1)
|
|
53
|
+
return {"apple": 0.5, "bread": 2.25}.get(item, 1.0)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
async def main() -> None:
|
|
57
|
+
program = torva.compile(open("examples/host.tv").read())
|
|
58
|
+
vm = torva.VirtualMachine(functions={"log": log, "fetch_price": fetch_price})
|
|
59
|
+
print(await vm.run(program, "total", "apple", "bread")) # 2.75
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
asyncio.run(main())
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The two prices are fetched at once, each in its own task.
|
|
66
|
+
|
|
67
|
+
## Install
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
pip install torva # CPython 3.13 or newer
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
For Rust, add it from git:
|
|
74
|
+
|
|
75
|
+
```toml
|
|
76
|
+
[dependencies]
|
|
77
|
+
torva = { git = "https://github.com/travispaxton/torva" }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Documentation
|
|
81
|
+
|
|
82
|
+
- [The language](https://github.com/travispaxton/torva/blob/main/docs/language.md): types, functions, records, errors,
|
|
83
|
+
tasks and the built-ins.
|
|
84
|
+
- [Python](https://github.com/travispaxton/torva/blob/main/docs/python.md): running programs, host functions, records from
|
|
85
|
+
the host, generic host functions and checking host calls.
|
|
86
|
+
- [Rust](https://github.com/travispaxton/torva/blob/main/docs/rust.md): the VM builder, host functions, compiling with
|
|
87
|
+
signatures, and the module formats.
|
|
88
|
+
- [Editors](https://github.com/travispaxton/torva/blob/main/docs/editors.md): completion, analysis, string languages and
|
|
89
|
+
formatting.
|
|
90
|
+
- [Sandboxing](https://github.com/travispaxton/torva/blob/main/docs/sandboxing.md): limits, failures and fuzzing.
|
|
91
|
+
|
|
92
|
+
[examples/](https://github.com/travispaxton/torva/tree/main/examples) has programs and hosts to run:
|
|
93
|
+
`uv run examples/host.py` or `cargo run --example host`.
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
uv sync # builds the VM and installs it into .venv
|
|
99
|
+
uv run pytest # Python tests
|
|
100
|
+
cargo test # Rust tests
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Run `cargo test --all-features` with Python installed to test the Rust build
|
|
104
|
+
with both the Python bindings and the `checked` feature enabled.
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
[MIT](https://github.com/travispaxton/torva/blob/main/LICENSE)
|
|
109
|
+
|
torva-0.3.0/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# torva
|
|
2
|
+
|
|
3
|
+
A lightweight virtual machine that runs programs as fibers across all CPU
|
|
4
|
+
cores, for running code you didn't write inside a Python or Rust service.
|
|
5
|
+
|
|
6
|
+
- **Parallel.** Programs start tasks that run on every core. Fibers are
|
|
7
|
+
preempted, so one busy fiber can't starve the others, and the VM never
|
|
8
|
+
holds Python's GIL.
|
|
9
|
+
- **Sandboxed.** A program reaches the outside world only through the
|
|
10
|
+
functions you give it, with the types you declare. Limits cap the fuel,
|
|
11
|
+
time, memory, tasks and cores each call may use.
|
|
12
|
+
- **Typed.** Programs are written in a small, statically typed language. The
|
|
13
|
+
compiler is built in, and every module is verified when it loads.
|
|
14
|
+
- **Embeddable.** Give programs functions from Python, sync or `async`, or
|
|
15
|
+
from Rust. Your records become the program's types.
|
|
16
|
+
- **Editor-ready.** Completion, errors as you type, hover, go-to-definition
|
|
17
|
+
and formatting for the language, from the same compiler.
|
|
18
|
+
|
|
19
|
+
```go
|
|
20
|
+
from host import log(message: str), fetch_price(item: str) -> float
|
|
21
|
+
from torva import task
|
|
22
|
+
|
|
23
|
+
fn total(a: str, b: str) -> float {
|
|
24
|
+
log("pricing " + a + " and " + b)
|
|
25
|
+
x = task.start(fetch_price, a)
|
|
26
|
+
y = task.start(fetch_price, b)
|
|
27
|
+
return x.wait() + y.wait()
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import asyncio
|
|
33
|
+
import torva
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def log(message: str) -> None:
|
|
37
|
+
print(f"[torva] {message}")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
async def fetch_price(item: str) -> float:
|
|
41
|
+
await asyncio.sleep(0.1)
|
|
42
|
+
return {"apple": 0.5, "bread": 2.25}.get(item, 1.0)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async def main() -> None:
|
|
46
|
+
program = torva.compile(open("examples/host.tv").read())
|
|
47
|
+
vm = torva.VirtualMachine(functions={"log": log, "fetch_price": fetch_price})
|
|
48
|
+
print(await vm.run(program, "total", "apple", "bread")) # 2.75
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
asyncio.run(main())
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The two prices are fetched at once, each in its own task.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
pip install torva # CPython 3.13 or newer
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For Rust, add it from git:
|
|
63
|
+
|
|
64
|
+
```toml
|
|
65
|
+
[dependencies]
|
|
66
|
+
torva = { git = "https://github.com/travispaxton/torva" }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Documentation
|
|
70
|
+
|
|
71
|
+
- [The language](https://github.com/travispaxton/torva/blob/main/docs/language.md): types, functions, records, errors,
|
|
72
|
+
tasks and the built-ins.
|
|
73
|
+
- [Python](https://github.com/travispaxton/torva/blob/main/docs/python.md): running programs, host functions, records from
|
|
74
|
+
the host, generic host functions and checking host calls.
|
|
75
|
+
- [Rust](https://github.com/travispaxton/torva/blob/main/docs/rust.md): the VM builder, host functions, compiling with
|
|
76
|
+
signatures, and the module formats.
|
|
77
|
+
- [Editors](https://github.com/travispaxton/torva/blob/main/docs/editors.md): completion, analysis, string languages and
|
|
78
|
+
formatting.
|
|
79
|
+
- [Sandboxing](https://github.com/travispaxton/torva/blob/main/docs/sandboxing.md): limits, failures and fuzzing.
|
|
80
|
+
|
|
81
|
+
[examples/](https://github.com/travispaxton/torva/tree/main/examples) has programs and hosts to run:
|
|
82
|
+
`uv run examples/host.py` or `cargo run --example host`.
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
uv sync # builds the VM and installs it into .venv
|
|
88
|
+
uv run pytest # Python tests
|
|
89
|
+
cargo test # Rust tests
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Run `cargo test --all-features` with Python installed to test the Rust build
|
|
93
|
+
with both the Python bindings and the `checked` feature enabled.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
[MIT](https://github.com/travispaxton/torva/blob/main/LICENSE)
|