{"id":13599923,"url":"https://github.com/maekawatoshiki/rapidus","last_synced_at":"2025-04-05T08:06:03.473Z","repository":{"id":44566800,"uuid":"138584142","full_name":"maekawatoshiki/rapidus","owner":"maekawatoshiki","description":"ECMAScript implementation in Rust","archived":false,"fork":false,"pushed_at":"2023-09-02T14:56:12.000Z","size":2000,"stargazers_count":536,"open_issues_count":3,"forks_count":21,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-03-29T07:04:39.088Z","etag":null,"topics":["javascript","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maekawatoshiki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-25T11:12:14.000Z","updated_at":"2025-02-22T08:22:43.000Z","dependencies_parsed_at":"2024-06-09T20:34:23.348Z","dependency_job_id":"c7686590-0db4-42e5-ae35-f954f03e4dde","html_url":"https://github.com/maekawatoshiki/rapidus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maekawatoshiki%2Frapidus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maekawatoshiki%2Frapidus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maekawatoshiki%2Frapidus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maekawatoshiki%2Frapidus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maekawatoshiki","download_url":"https://codeload.github.com/maekawatoshiki/rapidus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305933,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","rust"],"created_at":"2024-08-01T17:01:18.929Z","updated_at":"2025-04-05T08:06:03.456Z","avatar_url":"https://github.com/maekawatoshiki.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Rapidus\n\n[![Build](https://github.com/maekawatoshiki/rapidus/actions/workflows/rust.yml/badge.svg)](https://github.com/maekawatoshiki/rapidus/actions/workflows/rust.yml)\n[![codecov](https://codecov.io/gh/maekawatoshiki/rapidus/branch/main/graph/badge.svg)](https://codecov.io/gh/maekawatoshiki/rapidus/branch/main)\n[![](http://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nJavaScript engine implemented in Rust, now aiming at ES5.\n\nBig thanks to [boa](https://github.com/boa-dev/boa).\n\n# Rapidus on WASM\n\nOn [this page](https://maekawatoshiki.github.io/rapidus), you can try rapidus compiled into WASM on your browser. How amazing, isn't it?\n\n*The compiled rapidus on the above page is some commits behind this branch.*\n\n# Features \n\n- Small\n- Partly support for Tracing-JIT compiling\n- REPL \n\n# Building from Source\n\n## Building on Linux\n\n1. Install Rust\n\n  Run the command below and follow the onscreen instructions. \n\n```sh\ncurl https://sh.rustup.rs -sSf | sh\n```\n\n2. Use Rust Nightly\n\n```sh\nrustup override set nightly\n```\n\n3. Install dependencies\n  - LLVM 6.0\n  - (Other packages as necessary...)\n\n```sh\n# e.g. Ubuntu or Debian\napt-get install llvm-6.0\n```\n\n4. Test \n\n```sh\ncargo test\n```\n\n- If the compilation failed because of LLVM-related errors, the following command may help.\n\n```sh\nln -sf /usr/bin/llvm-config-6.0 /usr/bin/llvm-config\n```\n\n5. Build\n\n```sh\ncargo run --release\n```\n\n6. Run\n\n```sh\ncargo run --release examples/XXX.js\n```\n\n7. multilined-aware REPL\n\n```sh\n$ cargo run\n\u003e function fact(n) {\n... if (n \u003c 2) {     \u003c- recognize multilined input\n... return n\n... } else {\n... return n * fact(n-1)\n... }\n... }                \u003c- recognize the end of input\nundefined\n\u003e fact(10)\n3628800\n```\n\n8. Debug mode (tracing bytecode execution)\n   \n   use --trace option.\n\n```sh\n$ cargo run -- --trace\n\u003e function fibo(x) { if (x\u003c2) return 1; return fibo(x-1)+fibo(x-2)}\n00020m 00000 Return                    \u003cempty\u003e\nundefined\n\u003e fibo(3)\n00009m 00000 PushInt8 3                \u003cempty\u003e\n00015m 00002 GetValue 'fibo'           3.0\n00066m 00007 Call 1                    Function\n--\u003e call function\n  module_id:0 func_id:0\n00007m 00000 GetValue 'x'              \u003cempty\u003e\n00001m 00005 PushInt8 2                3.0\n00013m 00007 Lt                        2.0\n\n...\n\n00001m 00007 Lt                        2.0\n00000m 00008 JmpIfFalse 00016          true\n00000m 00013 PushInt8 1                \u003cempty\u003e\n00167m 00015 Return                    1.0\n\u003c-- return value(1.0)\n  module_id:0 func_id:2\n00001m 00052 Add                       1.0\n00044m 00053 Return                    3.0\n\u003c-- return value(3.0)\n  module_id:0 func_id:0\n00000m 00012 Return                    3.0\n3\n\u003e \n   |     |     |                        | \n   |     |     |                        \\- value at the top of exec stack\n   |     |     \\-------------------------- instruction\n   |     \\-------------------------------- program counter\n   \\-------------------------------------- execution time per inst. (in microsecs)\n```\n\n## Building on other platforms\n\nI don't know.\n\n- ~~tips: If you are using macOS, you cannot use llvm installed with ``brew``. You should use macports or docker instead.~~ Now it works!\n\n## Use DLLs written in Rust\n\n**THIS FEATURE IS EXPERIMENTAL**\n\n\n\n1. Make a cargo project in the directory rapidus' directory is located\n\n```sh\n$ cargo new hello --lib\n$ ls\nrapidus hello\n```\n\n2. Edit ``Cargo.toml``\n\n```sh\n$ cd hello\n$ \u003cYOUR EDITOR\u003e Cargo.toml\n```\n\n```toml\n# Add the followings to Cargo.toml\n\n[dependencies]\nrapidus = { path = \"../rapidus\" }\n# other dependencies if you want...\n\n[lib]\nname = \"hello\"\ncrate_type = [\"cdylib\"] # try 'dylib' if it doesn't work.\n```\n\n3. Edit ``src/lib.rs``\n\n```sh\n$ \u003cYOUR EDITOR\u003e src/lib.rs\n```\n\n```rust\n// src/lib.rs\n\n#[macro_use]\nextern crate rapidus;\nuse rapidus::{\n   gc,\n   vm::{callobj::CallObject, error::RuntimeError, value::*, vm::VM},\n};\n\n#[no_mangle]\nfn initialize(vm: \u0026mut VM, _: \u0026Vec\u003cValue\u003e, _: CallObjectRef) -\u003e Result\u003c(), RuntimeError\u003e {\n    // make_object!() is useful\n    let module_exports = make_object!(\n        greet:   Value::default_builtin_function(greet),\n        message: Value::String(\"hello\".to_string())\n    );\n\n    vm.set_return_value(module_exports); // We have to return module.exports\n\n    Ok(())\n}\n\n#[no_mangle]\nfn greet(vm: \u0026mut VM, _: \u0026Vec\u003cValue\u003e, _: CallObjectRef) -\u003e Result\u003c(), RuntimeError\u003e {\n    println!(\"Hello World from Rust DLL!\");\n\n    vm.set_return_value(Value::Undefined); // Remember to return a value you want\n\n    Ok(())\n}\n```\n\n4. Let's build\n\n```sh\n$ cargo build # --release as necessary\n```\n\n5. Copy the generated DLL to rapidus' directory\n\n```sh\n$ cp ./target/debug/libhello.(so|dll|dylib) ../rapidus\n$ cd ../rapidus\n$ ls\nlibhello.(so|dll|dylib) etc...\n```\n\n6. You're ready to use it from rapidus. Let's try from REPL.\n\n```sh\n$ cargo run\n\u003e var mod = require('hello')\n\u003e mod.greet()\nHello World from Rust DLL!\n\u003e mod.message\n'hello'\n```\n\n7. Now everything can be possible from Rust!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaekawatoshiki%2Frapidus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaekawatoshiki%2Frapidus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaekawatoshiki%2Frapidus/lists"}