forked from Rust-related/RustPython
Compare commits
38 Commits
framestack
...
wasm-outpu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6435ab3ad4 | ||
|
|
d2565cd1b0 | ||
|
|
f8f9fa7fd0 | ||
|
|
b5c1990267 | ||
|
|
351a61f2b3 | ||
|
|
34a60ce6a2 | ||
|
|
41d5dc52eb | ||
|
|
71ea9b8f16 | ||
|
|
fa89e8803c | ||
|
|
30bb111b1a | ||
|
|
8d78c67d0b | ||
|
|
5734fc29ca | ||
|
|
03911d98d7 | ||
|
|
2c55c4793e | ||
|
|
8eacbcbc06 | ||
|
|
f227ce0498 | ||
|
|
eb51007993 | ||
|
|
1b4b157a2d | ||
|
|
68892fb4e2 | ||
|
|
04548db1e0 | ||
|
|
ee2fb20f96 | ||
|
|
de61b1c685 | ||
|
|
51271e5000 | ||
|
|
a8fb2f3754 | ||
|
|
023e6119c4 | ||
|
|
083eb977ad | ||
|
|
c1ab263258 | ||
|
|
be462afaa4 | ||
|
|
a17fb3f4d0 | ||
|
|
cd3429ce4d | ||
|
|
0da1f73777 | ||
|
|
d972b07195 | ||
|
|
f9860d083e | ||
|
|
15c6328ecd | ||
|
|
05d2faa227 | ||
|
|
bbdef3d8c8 | ||
|
|
1a0677ab44 | ||
|
|
2939e53717 |
43
.travis.yml
43
.travis.yml
@@ -61,6 +61,49 @@ matrix:
|
||||
- cargo fmt --all -- --check
|
||||
env:
|
||||
- REGULAR_TEST=false
|
||||
- name: publish documentation
|
||||
language: rust
|
||||
rust: stable
|
||||
cache: cargo
|
||||
script:
|
||||
- cargo doc --no-deps --all
|
||||
if: branch = release
|
||||
env:
|
||||
- REGULAR_TEST=false
|
||||
- PUBLISH_DOC=true
|
||||
- name: WASM online demo
|
||||
language: rust
|
||||
rust: nightly
|
||||
cache: cargo
|
||||
script:
|
||||
- cd wasm
|
||||
- bash release.sh
|
||||
if: branch = release
|
||||
env:
|
||||
- REGULAR_TEST=false
|
||||
- PUBLISH_DEMO=true
|
||||
allow_failures:
|
||||
- rust: nightly
|
||||
env: REGULAR_TEST=true
|
||||
|
||||
deploy:
|
||||
- provider: pages
|
||||
repo: RustPython/website
|
||||
target-branch: master
|
||||
local-dir: target/doc
|
||||
skip-cleanup: true
|
||||
github-token: $WEBSITE_GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
|
||||
keep-history: true
|
||||
on:
|
||||
branch: release
|
||||
condition: $PUBLISH_DOC = true
|
||||
- provider: pages
|
||||
repo: RustPython/demo
|
||||
target-branch: master
|
||||
local-dir: wasm/app/dist
|
||||
skip-cleanup: true
|
||||
github-token: $WEBSITE_GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
|
||||
keep-history: true
|
||||
on:
|
||||
branch: release
|
||||
condition: $PUBLISH_DEMO = true
|
||||
|
||||
48
Cargo.lock
generated
48
Cargo.lock
generated
@@ -155,6 +155,14 @@ dependencies = [
|
||||
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.3"
|
||||
@@ -522,6 +530,31 @@ dependencies = [
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.40"
|
||||
@@ -630,11 +663,13 @@ dependencies = [
|
||||
"num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustpython_parser 0.0.1",
|
||||
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"statrs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -704,6 +739,14 @@ name = "siphasher"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "statrs"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "string_cache"
|
||||
version = "0.7.3"
|
||||
@@ -921,6 +964,7 @@ dependencies = [
|
||||
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
|
||||
"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18"
|
||||
"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
|
||||
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
|
||||
"checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603"
|
||||
@@ -966,6 +1010,9 @@ dependencies = [
|
||||
"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
|
||||
"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035"
|
||||
"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"
|
||||
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
|
||||
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
|
||||
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
|
||||
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
|
||||
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
|
||||
"checksum redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "214a97e49be64fd2c86f568dd0cb2c757d2cc53de95b273b6ad0a1c908482f26"
|
||||
@@ -983,6 +1030,7 @@ dependencies = [
|
||||
"checksum serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae"
|
||||
"checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0"
|
||||
"checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537"
|
||||
"checksum statrs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "10102ac8d55e35db2b3fafc26f81ba8647da2e15879ab686a67e6d19af2685e8"
|
||||
"checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
|
||||
"checksum string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35293b05cf1494e8ddd042a7df6756bf18d07f42d234f32e71dce8a7aabb0191"
|
||||
"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
|
||||
|
||||
26
README.md
26
README.md
@@ -32,18 +32,24 @@ Or use the interactive shell:
|
||||
|
||||
Currently the project is in an early phase, and so is the documentation.
|
||||
|
||||
You can generate documentation by running:
|
||||
You can read the [online documentation](https://rustpython.github.io/website/rustpython/index.html) for the latest code on master.
|
||||
|
||||
You can also generate documentation locally by running:
|
||||
|
||||
```shell
|
||||
$ cargo doc
|
||||
$ cargo doc # Including documentation for all dependencies
|
||||
$ cargo doc --no-deps --all # Excluding all dependencies
|
||||
```
|
||||
|
||||
Documentation HTML files can then be found in the `target/doc` directory.
|
||||
|
||||
# Code organization
|
||||
|
||||
- `parser`: python lexing, parsing and ast
|
||||
- `vm`: python virtual machine
|
||||
- `parser/src`: python lexing, parsing and ast
|
||||
- `vm/src`: python virtual machine
|
||||
- `builtins.rs`: Builtin functions
|
||||
- `compile.rs`: the python compiler from ast to bytecode
|
||||
- `obj`: python builtin types
|
||||
- `src`: using the other subcrates to bring rustpython to life.
|
||||
- `docs`: documentation (work in progress)
|
||||
- `py_code_object`: CPython bytecode to rustpython bytecode convertor (work in progress)
|
||||
@@ -53,12 +59,15 @@ Documentation HTML files can then be found in the `target/doc` directory.
|
||||
# Contributing
|
||||
|
||||
To start contributing, there are a lot of things that need to be done.
|
||||
|
||||
Most tasks are listed in the [issue tracker](https://github.com/RustPython/RustPython/issues).
|
||||
Check issues labeled with `good first issue` if you wish to start coding.
|
||||
|
||||
Another approach is to checkout the sourcecode: builtin functions and object methods are often the simplest
|
||||
and easiest way to contribute.
|
||||
|
||||
You can also simply run
|
||||
`cargo run tests/snippets/todo.py` to assist in finding any
|
||||
`cargo run tests/snippets/whats_left_to_implement.py` to assist in finding any
|
||||
unimplemented method.
|
||||
|
||||
# Testing
|
||||
@@ -102,8 +111,8 @@ At this stage RustPython only has preliminary support for web assembly. The inst
|
||||
|
||||
## Setup
|
||||
|
||||
To get started, install [wasm-bingden](https://rustwasm.github.io/wasm-bindgen/whirlwind-tour/basic-usage.html)
|
||||
and [wasm-webpack](https://rustwasm.github.io/wasm-pack/installer/). You will also need to have `npm` installed.
|
||||
To get started, install [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/whirlwind-tour/basic-usage.html)
|
||||
and [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/). You will also need to have `npm` installed.
|
||||
|
||||
<!-- Using `rustup` add the compile target `wasm32-unknown-emscripten`. To do so you will need to have [rustup](https://rustup.rs/) installed.
|
||||
|
||||
@@ -149,12 +158,13 @@ Finally, run:
|
||||
|
||||
```
|
||||
npm install
|
||||
npm link rustpython_wasm
|
||||
```
|
||||
|
||||
and you will be able to run the files with:
|
||||
|
||||
```
|
||||
webpack-dev-server
|
||||
node_modules/.bin/webpack-dev-server
|
||||
```
|
||||
|
||||
Open a browser console and see the output of rustpython_wasm. To verify this, modify the line in `app/index.js`
|
||||
|
||||
@@ -8,6 +8,7 @@ bitflags = "1.0.4"
|
||||
num-complex = "0.2"
|
||||
num-bigint = "0.2.1"
|
||||
num-traits = "0.2"
|
||||
rand = "0.5"
|
||||
log = "0.3"
|
||||
rustpython_parser = {path = "../parser"}
|
||||
serde = "1.0.66"
|
||||
@@ -15,3 +16,4 @@ serde_derive = "1.0.66"
|
||||
serde_json = "1.0.26"
|
||||
byteorder = "1.2.6"
|
||||
regex = "1"
|
||||
statrs = "0.10.0"
|
||||
|
||||
@@ -850,14 +850,9 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
|
||||
},
|
||||
ctx.type_type(),
|
||||
);
|
||||
let obj = PyObject::new(
|
||||
PyObjectKind::Module {
|
||||
name: "__builtins__".to_string(),
|
||||
dict: scope,
|
||||
},
|
||||
ctx.type_type(),
|
||||
);
|
||||
obj
|
||||
let mod_name = "__builtins__".to_string();
|
||||
let py_mod = ctx.new_module(&mod_name, scope);
|
||||
py_mod
|
||||
}
|
||||
|
||||
pub fn builtin_build_class_(vm: &mut VirtualMachine, mut args: PyFuncArgs) -> PyResult {
|
||||
|
||||
@@ -15,6 +15,7 @@ extern crate num_complex;
|
||||
extern crate num_traits;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate statrs;
|
||||
|
||||
extern crate rustpython_parser;
|
||||
|
||||
|
||||
@@ -42,8 +42,15 @@ pub fn get_value(obj: &PyObjectRef) -> f64 {
|
||||
pub fn make_float(vm: &mut VirtualMachine, obj: &PyObjectRef) -> Result<f64, PyObjectRef> {
|
||||
if objtype::isinstance(obj, &vm.ctx.float_type()) {
|
||||
Ok(get_value(obj))
|
||||
} else if objtype::isinstance(obj, &vm.ctx.int_type()) {
|
||||
Ok(objint::get_value(obj).to_f64().unwrap())
|
||||
} else if let Ok(method) = vm.get_method(obj.clone(), "__float__") {
|
||||
let res = vm.invoke(
|
||||
method,
|
||||
PyFuncArgs {
|
||||
args: vec![],
|
||||
kwargs: vec![],
|
||||
},
|
||||
)?;
|
||||
Ok(get_value(&res))
|
||||
} else {
|
||||
Err(vm.new_type_error(format!("Cannot cast {:?} to float", obj)))
|
||||
}
|
||||
|
||||
@@ -201,6 +201,12 @@ fn int_add(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
}
|
||||
}
|
||||
|
||||
fn int_float(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(i, Some(vm.ctx.int_type()))]);
|
||||
let i = get_value(i);
|
||||
Ok(vm.ctx.new_float(i.to_f64().unwrap()))
|
||||
}
|
||||
|
||||
fn int_floordiv(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(
|
||||
vm,
|
||||
@@ -391,6 +397,7 @@ pub fn init(context: &PyContext) {
|
||||
int_type.set_attr("__add__", context.new_rustfunc(int_add));
|
||||
int_type.set_attr("__and__", context.new_rustfunc(int_and));
|
||||
int_type.set_attr("__divmod__", context.new_rustfunc(int_divmod));
|
||||
int_type.set_attr("__float__", context.new_rustfunc(int_float));
|
||||
int_type.set_attr("__floordiv__", context.new_rustfunc(int_floordiv));
|
||||
int_type.set_attr("__hash__", context.new_rustfunc(int_hash));
|
||||
int_type.set_attr("__new__", context.new_rustfunc(int_new));
|
||||
|
||||
@@ -125,6 +125,23 @@ fn list_clear(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
Ok(vm.get_none())
|
||||
}
|
||||
|
||||
fn list_count(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(
|
||||
vm,
|
||||
args,
|
||||
required = [(zelf, Some(vm.ctx.list_type())), (value, None)]
|
||||
);
|
||||
let elements = get_elements(zelf);
|
||||
let mut count: usize = 0;
|
||||
for element in elements.iter() {
|
||||
let is_eq = vm._eq(element, value.clone())?;
|
||||
if objbool::boolval(vm, is_eq)? {
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
Ok(vm.context().new_int(count.to_bigint().unwrap()))
|
||||
}
|
||||
|
||||
pub fn list_extend(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(
|
||||
vm,
|
||||
@@ -152,6 +169,14 @@ fn list_reverse(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
Ok(vm.get_none())
|
||||
}
|
||||
|
||||
fn list_sort(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(list, Some(vm.ctx.list_type()))]);
|
||||
let mut _elements = get_mut_elements(list);
|
||||
unimplemented!("TODO: figure out how to invoke `sort_by` on a Vec");
|
||||
// elements.sort_by();
|
||||
// Ok(vm.get_none())
|
||||
}
|
||||
|
||||
fn list_contains(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
trace!("list.contains called with: {:?}", args);
|
||||
arg_check!(
|
||||
@@ -221,6 +246,8 @@ pub fn init(context: &PyContext) {
|
||||
list_type.set_attr("__repr__", context.new_rustfunc(list_repr));
|
||||
list_type.set_attr("append", context.new_rustfunc(list_append));
|
||||
list_type.set_attr("clear", context.new_rustfunc(list_clear));
|
||||
list_type.set_attr("count", context.new_rustfunc(list_count));
|
||||
list_type.set_attr("extend", context.new_rustfunc(list_extend));
|
||||
list_type.set_attr("reverse", context.new_rustfunc(list_reverse));
|
||||
list_type.set_attr("sort", context.new_rustfunc(list_sort));
|
||||
}
|
||||
|
||||
@@ -11,6 +11,23 @@ use super::objtype;
|
||||
use num_bigint::ToBigInt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
fn tuple_count(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(
|
||||
vm,
|
||||
args,
|
||||
required = [(zelf, Some(vm.ctx.tuple_type())), (value, None)]
|
||||
);
|
||||
let elements = get_elements(zelf);
|
||||
let mut count: usize = 0;
|
||||
for element in elements.iter() {
|
||||
let is_eq = vm._eq(element, value.clone())?;
|
||||
if objbool::boolval(vm, is_eq)? {
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
Ok(vm.context().new_int(count.to_bigint().unwrap()))
|
||||
}
|
||||
|
||||
fn tuple_eq(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(
|
||||
vm,
|
||||
@@ -142,4 +159,5 @@ pub fn init(context: &PyContext) {
|
||||
tuple_type.set_attr("__len__", context.new_rustfunc(tuple_len));
|
||||
tuple_type.set_attr("__new__", context.new_rustfunc(tuple_new));
|
||||
tuple_type.set_attr("__repr__", context.new_rustfunc(tuple_repr));
|
||||
tuple_type.set_attr("count", context.new_rustfunc(tuple_count));
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ pub fn get_type_name(typ: &PyObjectRef) -> String {
|
||||
{
|
||||
name.clone()
|
||||
} else {
|
||||
panic!("Cannot get type_name of non-type type");
|
||||
panic!("Cannot get type_name of non-type type {:?}", typ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -642,6 +642,7 @@ impl AttributeProtocol for PyObjectRef {
|
||||
|
||||
fn set_attr(&self, attr_name: &str, value: PyObjectRef) {
|
||||
match self.borrow().kind {
|
||||
PyObjectKind::Module { name: _, ref dict } => dict.set_item(attr_name, value),
|
||||
PyObjectKind::Instance { ref dict } => dict.set_item(attr_name, value),
|
||||
PyObjectKind::Class {
|
||||
name: _,
|
||||
|
||||
@@ -8,6 +8,8 @@ use super::super::pyobject::{
|
||||
DictProtocol, PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeProtocol,
|
||||
};
|
||||
use super::super::VirtualMachine;
|
||||
use statrs::function::erf::{erf, erfc};
|
||||
use statrs::function::gamma::{gamma, ln_gamma};
|
||||
use std;
|
||||
|
||||
// Helper macro:
|
||||
@@ -156,8 +158,7 @@ fn math_erf(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
if x.is_nan() {
|
||||
Ok(vm.ctx.new_float(x))
|
||||
} else {
|
||||
// TODO: implement algorithm
|
||||
unimplemented!("TODO");
|
||||
Ok(vm.ctx.new_float(erf(x)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +169,7 @@ fn math_erfc(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
if x.is_nan() {
|
||||
Ok(vm.ctx.new_float(x))
|
||||
} else {
|
||||
// TODO: implement algorithm
|
||||
unimplemented!("TODO");
|
||||
Ok(vm.ctx.new_float(erfc(x)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,8 +178,7 @@ fn math_gamma(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
let x = objfloat::get_value(value);
|
||||
|
||||
if x.is_finite() {
|
||||
// TODO: implement algorithm
|
||||
unimplemented!("TODO");
|
||||
Ok(vm.ctx.new_float(gamma(x)))
|
||||
} else {
|
||||
if x.is_nan() || x.is_sign_positive() {
|
||||
Ok(vm.ctx.new_float(x))
|
||||
@@ -194,8 +193,7 @@ fn math_lgamma(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
let x = objfloat::get_value(value);
|
||||
|
||||
if x.is_finite() {
|
||||
// TODO: implement algorithm
|
||||
unimplemented!("TODO");
|
||||
Ok(vm.ctx.new_float(ln_gamma(x)))
|
||||
} else {
|
||||
if x.is_nan() {
|
||||
Ok(vm.ctx.new_float(x))
|
||||
|
||||
@@ -4,6 +4,7 @@ mod json;
|
||||
mod keyword;
|
||||
mod math;
|
||||
mod pystruct;
|
||||
mod random;
|
||||
mod re;
|
||||
mod time_module;
|
||||
mod tokenize;
|
||||
@@ -23,6 +24,7 @@ pub fn get_module_inits() -> HashMap<String, StdlibInitFunc> {
|
||||
modules.insert("keyword".to_string(), keyword::mk_module as StdlibInitFunc);
|
||||
modules.insert("math".to_string(), math::mk_module as StdlibInitFunc);
|
||||
modules.insert("re".to_string(), re::mk_module as StdlibInitFunc);
|
||||
modules.insert("random".to_string(), random::mk_module as StdlibInitFunc);
|
||||
modules.insert("struct".to_string(), pystruct::mk_module as StdlibInitFunc);
|
||||
modules.insert("time".to_string(), time_module::mk_module as StdlibInitFunc);
|
||||
modules.insert(
|
||||
|
||||
62
vm/src/stdlib/random.rs
Normal file
62
vm/src/stdlib/random.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
//! Random module.
|
||||
|
||||
extern crate rand;
|
||||
|
||||
use super::super::obj::{objfloat, objtype};
|
||||
use super::super::pyobject::{
|
||||
DictProtocol, PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeProtocol,
|
||||
};
|
||||
use super::super::VirtualMachine;
|
||||
use stdlib::random::rand::distributions::{Distribution, Normal};
|
||||
|
||||
pub fn mk_module(ctx: &PyContext) -> PyObjectRef {
|
||||
let py_mod = ctx.new_module(&"random".to_string(), ctx.new_scope(None));
|
||||
py_mod.set_item("gauss", ctx.new_rustfunc(random_gauss));
|
||||
py_mod.set_item("normalvariate", ctx.new_rustfunc(random_normalvariate));
|
||||
py_mod.set_item("random", ctx.new_rustfunc(random_random));
|
||||
// py_mod.set_item("weibull", ctx.new_rustfunc(random_weibullvariate));
|
||||
// TODO: implement more random functions.
|
||||
py_mod
|
||||
}
|
||||
|
||||
fn random_gauss(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
// TODO: is this the same?
|
||||
random_normalvariate(vm, args)
|
||||
}
|
||||
|
||||
fn random_normalvariate(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(
|
||||
vm,
|
||||
args,
|
||||
required = [
|
||||
(mu, Some(vm.ctx.float_type())),
|
||||
(sigma, Some(vm.ctx.float_type()))
|
||||
]
|
||||
);
|
||||
let mu = objfloat::get_value(mu);
|
||||
let sigma = objfloat::get_value(sigma);
|
||||
let normal = Normal::new(mu, sigma);
|
||||
let value = normal.sample(&mut rand::thread_rng());
|
||||
let py_value = vm.ctx.new_float(value);
|
||||
Ok(py_value)
|
||||
}
|
||||
|
||||
fn random_random(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args);
|
||||
let value = rand::random::<f64>();
|
||||
let py_value = vm.ctx.new_float(value);
|
||||
Ok(py_value)
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: enable this function:
|
||||
fn random_weibullvariate(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(alpha, Some(vm.ctx.float_type())), (beta, Some(vm.ctx.float_type()))]);
|
||||
let alpha = objfloat::get_value(alpha);
|
||||
let beta = objfloat::get_value(beta);
|
||||
let weibull = Weibull::new(alpha, beta);
|
||||
let value = weibull.sample(&mut rand::thread_rng());
|
||||
let py_value = vm.ctx.new_float(value);
|
||||
Ok(py_value)
|
||||
}
|
||||
*/
|
||||
101
vm/src/vm.rs
101
vm/src/vm.rs
@@ -31,7 +31,7 @@ use super::sysmodule;
|
||||
/// Top level container of a python virtual machine. In theory you could
|
||||
/// create more instances of this struct and have them operate fully isolated.
|
||||
pub struct VirtualMachine {
|
||||
builtins: PyObjectRef,
|
||||
pub builtins: PyObjectRef,
|
||||
pub sys_module: PyObjectRef,
|
||||
pub stdlib_inits: HashMap<String, stdlib::StdlibInitFunc>,
|
||||
pub ctx: PyContext,
|
||||
@@ -42,10 +42,15 @@ impl VirtualMachine {
|
||||
/// Create a new `VirtualMachine` structure.
|
||||
pub fn new() -> VirtualMachine {
|
||||
let ctx = PyContext::new();
|
||||
|
||||
// Hard-core modules:
|
||||
let builtins = builtins::make_module(&ctx);
|
||||
let sysmod = sysmodule::mk_module(&ctx);
|
||||
|
||||
// Add builtins as builtins module:
|
||||
// sysmod.get_attr("modules").unwrap().set_item("builtins", builtins.clone());
|
||||
let modules = sysmod.get_attr("modules").unwrap();
|
||||
modules.set_item("builtins", builtins.clone());
|
||||
|
||||
let stdlib_inits = stdlib::get_module_inits();
|
||||
VirtualMachine {
|
||||
builtins: builtins,
|
||||
@@ -455,9 +460,31 @@ impl VirtualMachine {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _sub(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
// 1. Try __sub__, next __rsub__, next, give up
|
||||
if let Ok(method) = self.get_method(a.clone(), "__sub__") {
|
||||
/// Calls default method, reverse method or exception
|
||||
///
|
||||
/// * `a` - First argument.
|
||||
/// * `b` - Second argument.
|
||||
/// * `d` - Default method to try and call (such as `__and__`).
|
||||
/// * `r` - Reverse method to try and call (such as `__rand__`), in case first one fails.
|
||||
/// * `op` - Operator for the exception text, for example `&`.
|
||||
///
|
||||
/// Given the above example, it will
|
||||
/// 1. Try to call `__and__` with `a` and `b`
|
||||
/// 2. If above fails try to call `__rand__` with `a` and `b`
|
||||
/// 3. If above fails throw an exception:
|
||||
/// `TypeError: Unsupported operand types for '&': 'float' and 'int'`
|
||||
/// if `a` is of type float and `b` of type int
|
||||
///
|
||||
pub fn call_or_unsupported(
|
||||
&mut self,
|
||||
a: PyObjectRef,
|
||||
b: PyObjectRef,
|
||||
d: &str,
|
||||
r: &str,
|
||||
op: &str,
|
||||
) -> PyResult {
|
||||
// Try to call the first method
|
||||
if let Ok(method) = self.get_method(a.clone(), d) {
|
||||
match self.invoke(
|
||||
method,
|
||||
PyFuncArgs {
|
||||
@@ -474,8 +501,8 @@ impl VirtualMachine {
|
||||
}
|
||||
}
|
||||
|
||||
// 2. try __rsub__
|
||||
if let Ok(method) = self.get_method(b.clone(), "__rsub__") {
|
||||
// 2. Try to call reverse method
|
||||
if let Ok(method) = self.get_method(b.clone(), r) {
|
||||
match self.invoke(
|
||||
method,
|
||||
PyFuncArgs {
|
||||
@@ -492,16 +519,21 @@ impl VirtualMachine {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. It all failed :(
|
||||
// Cannot sub a and b
|
||||
// 3. Both failed, throw an exception
|
||||
// TODO: Move this chunk somewhere else, it should be
|
||||
// called in other methods as well (for example objint.rs)
|
||||
let a_type_name = objtype::get_type_name(&a.typ());
|
||||
let b_type_name = objtype::get_type_name(&b.typ());
|
||||
Err(self.new_type_error(format!(
|
||||
"Unsupported operand types for '-': '{}' and '{}'",
|
||||
a_type_name, b_type_name
|
||||
"Unsupported operand types for '{}': '{}' and '{}'",
|
||||
op, a_type_name, b_type_name
|
||||
)))
|
||||
}
|
||||
|
||||
pub fn _sub(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_or_unsupported(a, b, "__sub__", "__rsub__", "-")
|
||||
}
|
||||
|
||||
pub fn _add(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__add__", vec![b])
|
||||
}
|
||||
@@ -527,54 +559,11 @@ impl VirtualMachine {
|
||||
}
|
||||
|
||||
pub fn _or(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
self.call_method(&a, "__or__", vec![b])
|
||||
self.call_or_unsupported(a, b, "__or__", "__ror__", "|")
|
||||
}
|
||||
|
||||
pub fn _and(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
// 1. Try __and__, next __rand__, next, give up
|
||||
if let Ok(method) = self.get_method(a.clone(), "__and__") {
|
||||
match self.invoke(
|
||||
method,
|
||||
PyFuncArgs {
|
||||
args: vec![b.clone()],
|
||||
kwargs: vec![],
|
||||
},
|
||||
) {
|
||||
Ok(value) => return Ok(value),
|
||||
Err(err) => {
|
||||
if !objtype::isinstance(&err, &self.ctx.exceptions.not_implemented_error) {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. try __rand__
|
||||
if let Ok(method) = self.get_method(b.clone(), "__rand__") {
|
||||
match self.invoke(
|
||||
method,
|
||||
PyFuncArgs {
|
||||
args: vec![a.clone()],
|
||||
kwargs: vec![],
|
||||
},
|
||||
) {
|
||||
Ok(value) => return Ok(value),
|
||||
Err(err) => {
|
||||
if !objtype::isinstance(&err, &self.ctx.exceptions.not_implemented_error) {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. It all failed :(
|
||||
// Cannot and a and b
|
||||
let a_type_name = objtype::get_type_name(&a.typ());
|
||||
let b_type_name = objtype::get_type_name(&b.typ());
|
||||
Err(self.new_type_error(format!(
|
||||
"Unsupported operand types for '&': '{}' and '{}'",
|
||||
a_type_name, b_type_name
|
||||
)))
|
||||
self.call_or_unsupported(a, b, "__and__", "__rand__", "&")
|
||||
}
|
||||
|
||||
pub fn _eq(&mut self, a: &PyObjectRef, b: PyObjectRef) -> PyResult {
|
||||
|
||||
347
wasm/Cargo.lock
generated
347
wasm/Cargo.lock
generated
@@ -29,6 +29,37 @@ dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace-sys"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.4.0"
|
||||
@@ -66,6 +97,11 @@ name = "byteorder"
|
||||
version = "1.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.6"
|
||||
@@ -114,6 +150,38 @@ name = "ena"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "failure"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "failure_derive"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
@@ -146,6 +214,22 @@ dependencies = [
|
||||
"typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.7.8"
|
||||
@@ -159,6 +243,14 @@ name = "itoa"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
@@ -266,6 +358,44 @@ dependencies = [
|
||||
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "4.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ordermap"
|
||||
version = "0.3.5"
|
||||
@@ -310,6 +440,11 @@ dependencies = [
|
||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.6.8"
|
||||
@@ -343,6 +478,19 @@ name = "rand_core"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "redox_termios"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.2.11"
|
||||
@@ -388,6 +536,11 @@ dependencies = [
|
||||
"ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rustpython_parser"
|
||||
version = "0.0.1"
|
||||
@@ -395,7 +548,9 @@ dependencies = [
|
||||
"lalrpop 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lalrpop-util 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -405,19 +560,27 @@ dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustpython_parser 0.0.1",
|
||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"statrs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustpython_wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustpython_parser 0.0.1",
|
||||
"rustpython_vm 0.1.0",
|
||||
"wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"web-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -466,6 +629,19 @@ name = "siphasher"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "sourcefile"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "statrs"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "string_cache"
|
||||
version = "0.7.3"
|
||||
@@ -512,6 +688,17 @@ dependencies = [
|
||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "term"
|
||||
version = "0.4.6"
|
||||
@@ -521,6 +708,24 @@ dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "0.3.6"
|
||||
@@ -539,6 +744,11 @@ name = "ucd-util"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.1.0"
|
||||
@@ -567,6 +777,89 @@ name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"wasm-bindgen-macro 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-shared 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-macro-support 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-backend 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-shared 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-webidl"
|
||||
version = "0.2.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-backend 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"js-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-webidl 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "weedle"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
@@ -591,22 +884,43 @@ name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wincolor"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a"
|
||||
"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
|
||||
"checksum ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b385d69402821a1c254533a011a312531cbcc0e3e24f19bbb4747a5a2daf37e2"
|
||||
"checksum atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0fd4c0631f06448cc45a6bbb3b710ebb7ff8ccb96a0800c994afe23a70d5df2"
|
||||
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
|
||||
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
|
||||
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
|
||||
"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
|
||||
"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
|
||||
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
||||
"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
|
||||
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
|
||||
"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781"
|
||||
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
|
||||
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
|
||||
@@ -614,13 +928,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d8acd393692c503b168471874953a2531df0e9ab77d0b6bbc582395743300a4a"
|
||||
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
|
||||
"checksum ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe5a5078ac8c506d3e4430763b1ba9b609b1286913e7d08e581d1c2de9b7e5"
|
||||
"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e"
|
||||
"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7"
|
||||
"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596"
|
||||
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
|
||||
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
|
||||
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
||||
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
|
||||
"checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82"
|
||||
"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114"
|
||||
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
|
||||
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
|
||||
"checksum js-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58cfec35fd4a94f3cf357d5cb7da71c71cd52720c2f2a7320090a8db5f06f655"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lalrpop 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba451f7bd819b7afc99d4cf4bdcd5a4861e64955ba9680ac70df3a50625ad6cf"
|
||||
"checksum lalrpop-snap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "60013fd6be14317d43f47658b1440956a9ca48a9ed0257e0e0a59aac13e43a1f"
|
||||
@@ -631,43 +951,68 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
|
||||
"checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b"
|
||||
"checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4"
|
||||
"checksum nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a"
|
||||
"checksum num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "10b8423ea72ec64751198856a853e07b37087cfc9b53a87ecb19bff67b6d1320"
|
||||
"checksum num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "107b9be86cd2481930688277b675b0114578227f034674726605b8a482d8baf8"
|
||||
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
|
||||
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
||||
"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
|
||||
"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
|
||||
"checksum phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "03dc191feb9b08b0dc1330d6549b795b9d81aec19efe6b4a45aec8d4caee0c4b"
|
||||
"checksum phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b539898d22d4273ded07f64a05737649dc69095d92cb87c7097ec68e3f150b93"
|
||||
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||
"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee"
|
||||
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
|
||||
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
|
||||
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
|
||||
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
|
||||
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
|
||||
"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d"
|
||||
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
|
||||
"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
|
||||
"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341"
|
||||
"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
|
||||
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
|
||||
"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d"
|
||||
"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
|
||||
"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7"
|
||||
"checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef"
|
||||
"checksum serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "225de307c6302bec3898c51ca302fc94a7a1697ef0845fcee6448f33c032249c"
|
||||
"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce"
|
||||
"checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0"
|
||||
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
|
||||
"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3"
|
||||
"checksum statrs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "10102ac8d55e35db2b3fafc26f81ba8647da2e15879ab686a67e6d19af2685e8"
|
||||
"checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
|
||||
"checksum string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da"
|
||||
"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
|
||||
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
|
||||
"checksum syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4439ee8325b4e4b57e59309c3724c9a4478eaeb4eb094b6f3fac180a3b2876"
|
||||
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
|
||||
"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
|
||||
"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
|
||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
||||
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
|
||||
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
|
||||
"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
|
||||
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||
"checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4"
|
||||
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum wasm-bindgen 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "91f95b8f30407b9ca0c2de157281d3828bbed1fc1f55bea6eb54f40c52ec75ec"
|
||||
"checksum wasm-bindgen-backend 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "ab7c242ebcb45bae45340986c48d1853eb2c1c52ff551f7724951b62a2c51429"
|
||||
"checksum wasm-bindgen-macro 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "6e353f83716dec9a3597b5719ef88cb6c9e461ec16528f38aa023d3224b4e569"
|
||||
"checksum wasm-bindgen-macro-support 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "3cc90b65fe69c3dd5a09684517dc79f42b847baa2d479c234d125e0a629d9b0a"
|
||||
"checksum wasm-bindgen-shared 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "a71a37df4f5845025f96f279d20bbe5b19cbcb77f5410a3a90c6c544d889a162"
|
||||
"checksum wasm-bindgen-webidl 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b064b8b2336b5a6bf5f31bc95fc1310842395df29877d910cb6f8f791070f319"
|
||||
"checksum web-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d7c588c2e5a091bc4532c5a87032955f9133b644e868b54d08ead0185dcc5b9"
|
||||
"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
|
||||
|
||||
@@ -15,6 +15,10 @@ rustpython_vm = {path = "../vm"}
|
||||
cfg-if = "0.1.2"
|
||||
wasm-bindgen = "0.2"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3"
|
||||
features = [ "console" ]
|
||||
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
|
||||
4
wasm/app/html-console.js
Normal file
4
wasm/app/html-console.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export function htmlPrint(text) {
|
||||
const htmlConsole = document.getElementById('console');
|
||||
htmlConsole.value += text;
|
||||
}
|
||||
@@ -3,8 +3,31 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RustPython Starter Application</title>
|
||||
<style type="text/css" media="screen">
|
||||
#code {
|
||||
height: 70vh;
|
||||
width: 95vw;
|
||||
}
|
||||
|
||||
#run-btn {
|
||||
width: 10em;
|
||||
height: 5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>RustPython Demo</h1>
|
||||
<p>Please input your python code below and click <kbd>Run</kbd>:</p>
|
||||
<textarea id="code">x = 1
|
||||
y = 2
|
||||
print('Hello! x + y equals to ' + str(x+y))
|
||||
</textarea>
|
||||
<button id="run-btn">Run</button>
|
||||
<h2>Open the browser console (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> or <kbd>F12</kbd>) to see the output</h2>
|
||||
<script src="./bootstrap.js"></script>
|
||||
<textarea id="console">
|
||||
</textarea>
|
||||
|
||||
<a href="https://github.com/RustPython/RustPython"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png" alt="Fork me on GitHub"></a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
import * as rp from "rustpython_wasm";
|
||||
|
||||
rp.run_code("print('Hello Python!')\n");
|
||||
function runCodeFromTextarea(_) {
|
||||
// Clean the console
|
||||
document.getElementById('console').value = '';
|
||||
|
||||
const code = document.getElementById('code').value;
|
||||
if (!code.endsWith('\n')) { // HACK: if the code doesn't end with newline it crashes.
|
||||
rp.run_code(code + '\n');
|
||||
return;
|
||||
}
|
||||
rp.run_code(code);
|
||||
}
|
||||
document.getElementById('run-btn').addEventListener('click', runCodeFromTextarea);
|
||||
|
||||
runCodeFromTextarea(); // Run once for demo
|
||||
|
||||
9
wasm/build.sh
Normal file
9
wasm/build.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
# The second cp is due to https://github.com/rustwasm/wasm-pack/issues/240
|
||||
wasm-pack build --debug && \
|
||||
cp app/html-console.js pkg \
|
||||
cd pkg && \
|
||||
npm link && \
|
||||
cd ../app && \
|
||||
npm install && \
|
||||
npm link rustpython_wasm && \
|
||||
node_modules/.bin/webpack-dev-server
|
||||
8
wasm/release.sh
Normal file
8
wasm/release.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
wasm-pack build && \
|
||||
cd pkg && \
|
||||
npm link && \
|
||||
cd ../app && \
|
||||
npm install && \
|
||||
npm link rustpython_wasm && \
|
||||
webpack --mode production && \
|
||||
echo "Output saved to app/dist"
|
||||
@@ -1,28 +1,34 @@
|
||||
mod wasm_builtins;
|
||||
|
||||
extern crate rustpython_vm;
|
||||
extern crate wasm_bindgen;
|
||||
use rustpython_vm::compile;
|
||||
use rustpython_vm::VirtualMachine;
|
||||
use wasm_bindgen::prelude::*;
|
||||
extern crate web_sys;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
// Use `js_namespace` here to bind `console.log(..)` instead of just
|
||||
// `log(..)`
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
fn log(s: &str);
|
||||
}
|
||||
use rustpython_vm::VirtualMachine;
|
||||
use rustpython_vm::compile;
|
||||
use rustpython_vm::pyobject::AttributeProtocol;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::console;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run_code(source: &str) -> () {
|
||||
//add hash in here
|
||||
log("Running RustPython");
|
||||
log(&source.to_string());
|
||||
console::log_1(&"Running RustPython".into());
|
||||
console::log_1(&"Running code:".into());
|
||||
console::log_1(&source.to_string().into());
|
||||
console::log_1(&"----- console -----".into());
|
||||
|
||||
let mut vm = VirtualMachine::new();
|
||||
// We are monkey-patching the builtin print to use console.log
|
||||
// TODO: moneky-patch sys.stdout instead, after print actually uses sys.stdout
|
||||
vm.builtins.set_attr("print", vm.context().new_rustfunc(wasm_builtins::builtin_print));
|
||||
|
||||
let code_obj = compile::compile(&mut vm, &source.to_string(), compile::Mode::Exec, None);
|
||||
|
||||
let builtins = vm.get_builtin_scope();
|
||||
let vars = vm.context().new_scope(Some(builtins));
|
||||
match vm.run_code_obj(code_obj.unwrap(), vars) {
|
||||
Ok(_value) => log("Execution successful"),
|
||||
Err(_) => log("Execution failed"),
|
||||
Ok(_value) => console::log_1(&"Execution successful".into()),
|
||||
Err(_) => console::log_1(&"Execution failed".into()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
extern crate rustpython_parser;
|
||||
extern crate rustpython_vm;
|
||||
|
||||
use rustpython_vm::compile;
|
||||
use rustpython_vm::pyobject::PyResult;
|
||||
use rustpython_vm::VirtualMachine;
|
||||
|
||||
fn main() {
|
||||
let mut vm = VirtualMachine::new();
|
||||
let program = "print('Hello RustPython!')";
|
||||
run_command(&mut vm, program.to_string());
|
||||
}
|
||||
|
||||
fn _run_string(vm: &mut VirtualMachine, source: &str, source_path: Option<String>) -> PyResult {
|
||||
let code_obj = compile::compile(vm, &source.to_string(), compile::Mode::Exec, source_path)?;
|
||||
let builtins = vm.get_builtin_scope();
|
||||
let vars = vm.context().new_scope(Some(builtins)); // Keep track of local variables
|
||||
vm.run_code_obj(code_obj, vars)
|
||||
}
|
||||
|
||||
fn run_command(vm: &mut VirtualMachine, mut source: String) -> PyResult {
|
||||
// This works around https://github.com/RustPython/RustPython/issues/17
|
||||
source.push_str("\n");
|
||||
_run_string(vm, &source, None)
|
||||
}
|
||||
35
wasm/src/wasm_builtins.rs
Normal file
35
wasm/src/wasm_builtins.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
//! Builtin function specific to WASM build.
|
||||
//!
|
||||
//! This is required because some feature like I/O works differently in the browser comparing to
|
||||
//! desktop.
|
||||
//! Implements functions listed here: https://docs.python.org/3/library/builtins.html
|
||||
//!
|
||||
extern crate wasm_bindgen;
|
||||
extern crate web_sys;
|
||||
|
||||
use rustpython_vm::obj::objstr;
|
||||
use rustpython_vm::VirtualMachine;
|
||||
use rustpython_vm::pyobject::{ PyFuncArgs, PyResult };
|
||||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::console;
|
||||
|
||||
#[wasm_bindgen(module = "./html-console")]
|
||||
extern "C" {
|
||||
fn htmlPrint(text: String);
|
||||
}
|
||||
|
||||
pub fn builtin_print(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
let mut first = true;
|
||||
for a in args.args {
|
||||
if first {
|
||||
first = false;
|
||||
} else {
|
||||
htmlPrint(" ".into())
|
||||
//console::log_1(&" ".into())
|
||||
}
|
||||
let v = vm.to_str(&a)?;
|
||||
let s = objstr::get_value(&v);
|
||||
htmlPrint(format!("{}\n", s).into())
|
||||
}
|
||||
Ok(vm.get_none())
|
||||
}
|
||||
Reference in New Issue
Block a user