尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
Run programs on many languages in sandbox . Optimized to use in V4 JS engine from Qt or in browser playground
翻譯準備中
正在載入完整 README。
檢視完整 README ↗v4script lets a Qt application run programs written in fifteen languages - from QBasic and Turbo Pascal classics to Go, C++, Java, C# and WebAssembly - inside the JavaScript engine that every Qt Qml installation already has. No compilers, no external processes, no native interpreters: one static library, a few lines of C++, and your users can script your application in the language they like.
v4script::Runtime runtime;
runtime.setOutput([](v4script::Stream, const QString& text) { std::cout << text.toStdString(); });
runtime.run("basic", "FOR i = 1 TO 3: PRINT i * i;: NEXT"); // 1 4 9
runtime.run("pascal", "WriteLn('Pi = ', Pi:0:5);"); // Pi = 3.14159
runtime.run("go", "fmt.Println(strings.Repeat(\"Go\", 3))"); // GoGoGo
QJSEngine as JavaScript, shares its global object and can call
JavaScript - and the other way round.QObject and its
methods become a Go package, a C or C++ header, a Java or C# class, a
Pascal unit, Prolog predicates and Scheme procedures - with names and types in
the conventions of each language.PRINT USING and RND, C has its own
memory with real pointers, the C++ library gives the numbers of
libstdc++'s <random> and the order of its hash tables, C# formats
numbers and orders dictionaries as .NET does, WebAssembly passes the
specification tests.SCREEN 13 and Pascal Graph draw on a
canvas - into a QImage or a Qt Quick Canvas.| Language | Version | What runs | Implementation |
|---|---|---|---|
| Python | 3 | Python 3 (the subset of Skulpt) | Skulpt ae5f462 |
| Lua | 5.3 | Lua 5.3 | fengari 0.1.5 |
| Prolog | ISO | ISO Prolog | Tau Prolog 0.3.4 |
| Perl | 5 | Perl 5 (the subset of Perlito5) | Perlito5 9.028 |
| PHP | 7 | PHP 7 (the subset of Uniter) | Uniter (phpruntime 9.3.0) |
| Go | 1.22 | Go with goroutines, channels, generics and a subset of the standard library | v4script 0.1.4 |
| C | C17 | C17 with its own linear memory and a subset of the C library | v4script 0.1.4 |
| C++ | C++17 | C++17 over the memory of C: classes, templates, exceptions, lambdas and an STL that behaves as libstdc++ | v4script 0.1.4 |
| Java | 21 | Java 21 with records, pattern matching, threads, streams and a JDK subset | v4script 0.1.4 |
| C# | 12 | C# 12 with generics, LINQ, records, patterns, async/await, threads and a .NET 8 subset | v4script 0.1.4 |
| Forth | 2012 | Forth 2012, compatible with gforth | v4script 0.1.4 |
| BASIC | QBasic 4.5 | QBasic / QuickBASIC 4.5 with graphics | v4script 0.1.4 |
| Pascal | FPC 3.2.2 | Free Pascal 3.2.2 (objfpc): classes, exceptions, SysUtils, Math, StrUtils, Classes, Crt, Graph | v4script 0.1.4 |
| WebAssembly | 2.0 | the WAT text format, .wast scripts, WASI | v4script 0.1.4 |
| Scheme | R7RS | R7RS-small, SRFI 1, 13, 18, 69, full continuations | v4script 0.1.4 |
Languages marked v4script are translated into JavaScript by v4script's
own translator; the others run in third-party interpreters written in
JavaScript. Versions are available to the application too:
v4script::languages() and v4script::version().
The translator grows one language at a time, in this order: Kotlin, Rust, Swift, Dart, Scala, F#, Haskell, Erlang, Fortran, COBOL, Nim, Zig, x86 assemblers (NASM, FASM, TASM) and ASMX, Verilog, MASM, Ada, Common Lisp, the NES (ca65) and Z80 (sjasmplus) assemblers, CoffeeScript, the .NET IL assembler. See TODO for the plan and the known gaps.
The playground runs all fifteen
languages in the browser with the same scripts: pick an example - BASIC
games and graphics, Pascal Graph, goroutines in Go, records in Java,
LINQ in C#,
call/cc in Scheme - or write your own program; it stays in your browser.
How it works and how it differs from the Qt engine:
playground.
node tools/build-site.mjsv4run command-line runnerAll documentation: docs/.
cmake -S . -B build -DCMAKE_PREFIX_PATH=<path to Qt>/<kit>
cmake --build build --parallel
ctest --test-dir build --output-on-failure
Requires Qt 6.4 or later (developed with 6.4.1), CMake 3.19 and a C++17
compiler. To use it in your project, add it as a subdirectory and link
V4Script::V4Script - see embedding.
以上為 README 的開頭部分。其餘內容請閱讀原文。 檢視完整 README ↗