Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 1d7f0ac

Browse files
authored
Merge pull request #204 from lumen/lumen_web
lumen_web
2 parents 570ff8c + f02d22d commit 1d7f0ac

File tree

180 files changed

+6321
-1914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+6321
-1914
lines changed

.circleci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM circleci/rust
1+
FROM circleci/rust:latest-browsers
22

33
RUN rustup default nightly
44

.circleci/config.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
- liblumen_syntax
4444
- lumen
4545
- lumen_runtime
46+
- lumen_web
4647
- target/debug/.fingerprint
4748
- target/debug/build
4849
- target/debug/deps
@@ -92,6 +93,7 @@ jobs:
9293
- liblumen_syntax
9394
- lumen
9495
- lumen_runtime
96+
- lumen_web
9597
- target/debug/.fingerprint
9698
- target/debug/build
9799
- target/debug/deps
@@ -113,6 +115,32 @@ jobs:
113115
command: |
114116
rustfmt --version
115117
cargo fmt -- --check
118+
chrome_examples_spawn_chain_test:
119+
docker:
120+
# `kronicdeth` is temporary until we get a DockerHub organization
121+
- image: kronicdeth/lumen-development
122+
environment:
123+
CARGO_HOME: cargo
124+
steps:
125+
- attach_workspace:
126+
at: .
127+
- run:
128+
name: Run all tests
129+
working_directory: "examples/spawn-chain"
130+
command: wasm-pack test --chrome --headless
131+
firefox_examples_spawn_chain_test:
132+
docker:
133+
# `kronicdeth` is temporary until we get a DockerHub organization
134+
- image: kronicdeth/lumen-development
135+
environment:
136+
CARGO_HOME: cargo
137+
steps:
138+
- attach_workspace:
139+
at: .
140+
- run:
141+
name: Run all tests
142+
working_directory: "examples/spawn-chain"
143+
command: wasm-pack test --firefox --headless
116144
x86_64_examples_spawn_chain_test:
117145
docker:
118146
# `kronicdeth` is temporary until we get a DockerHub organization
@@ -242,6 +270,10 @@ jobs:
242270
- run:
243271
name: Run all tests
244272
working_directory: "liblumen_eir_interpreter"
273+
command: cargo test --locked
274+
- run:
275+
name: Fibonacci
276+
working_directory: "liblumen_eir_interpreter"
245277
command: cargo run -- --ident fib:run/0 fib.erl
246278
x86_64_liblumen_syntax_test:
247279
docker:
@@ -283,6 +315,7 @@ jobs:
283315
name: Run all tests
284316
working_directory: "lumen_runtime"
285317
command: cargo test --locked
318+
286319
workflows:
287320
version: 2
288321
primary:
@@ -331,4 +364,11 @@ workflows:
331364
- x86_64_lumen_runtime_test:
332365
requires:
333366
- x86_64_build
367+
- chrome_examples_spawn_chain_test:
368+
requires:
369+
- wasm32_build
370+
- firefox_examples_spawn_chain_test:
371+
requires:
372+
- wasm32_build
373+
334374

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ members = [
1515
"liblumen_diagnostics",
1616
"liblumen_syntax",
1717
"liblumen_eir_interpreter",
18+
"lumen_web",
1819
]
1920

2021
[profile.release]

examples/spawn-chain/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ console_error_panic_hook = { version = "0.1.1", optional = true }
2020

2121
liblumen_alloc = { path = "../../liblumen_alloc" }
2222
lumen_runtime = { path = "../../lumen_runtime" }
23+
lumen_web = { path = "../../lumen_web" }
2324
num-bigint = "0.2.2"
2425
wasm-bindgen = "0.2"
2526

examples/spawn-chain/src/code.rs renamed to examples/spawn-chain/src/apply_3.rs

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ use std::convert::TryInto;
22
use std::sync::Arc;
33

44
use liblumen_alloc::erts::exception::runtime;
5-
use liblumen_alloc::erts::process::code::stack::frame::Frame;
5+
use liblumen_alloc::erts::process::code::stack::frame::Placement;
66
use liblumen_alloc::erts::process::code::Result;
77
use liblumen_alloc::erts::process::ProcessControlBlock;
88
use liblumen_alloc::erts::term::{Atom, Term, TypedTerm};
9-
use liblumen_alloc::erts::ModuleFunctionArity;
109

1110
use crate::elixir;
1211

13-
pub fn apply(arc_process: &Arc<ProcessControlBlock>) -> Result {
12+
pub fn code(arc_process: &Arc<ProcessControlBlock>) -> Result {
1413
let module_term = arc_process.stack_pop().unwrap();
1514
let function_term = arc_process.stack_pop().unwrap();
1615

@@ -43,40 +42,57 @@ pub fn apply(arc_process: &Arc<ProcessControlBlock>) -> Result {
4342

4443
match module.name() {
4544
"Elixir.Chain" => match function.name() {
46-
"counter" => match arity {
45+
"console" => match arity {
4746
1 => {
48-
let module_function_arity = Arc::new(ModuleFunctionArity {
49-
module,
50-
function,
51-
arity,
52-
});
47+
elixir::chain::console_1::place_frame_with_arguments(
48+
arc_process,
49+
Placement::Replace,
50+
argument_vec[0],
51+
)?;
5352

54-
// Elixir.Chain.counter is a user function and not a BIF, so it is a `Code` and
55-
// run in a frame instead of directly
56-
let chain_counter_frame =
57-
Frame::new(module_function_arity, elixir::chain::counter_0_code);
58-
arc_process.stack_push(argument_vec[0])?;
59-
arc_process.replace_frame(chain_counter_frame);
53+
// don't count finding the function as a reduction if it is found, only on
54+
// exception in `undef`, so that each path is at least one reduction.
55+
ProcessControlBlock::call_code(arc_process)
56+
}
57+
_ => undef(arc_process, module_term, function_term, argument_list),
58+
},
59+
"counter" => match arity {
60+
2 => {
61+
elixir::chain::counter_2::place_frame_with_arguments(
62+
arc_process,
63+
Placement::Replace,
64+
argument_vec[0],
65+
argument_vec[1],
66+
)?;
67+
68+
// don't count finding the function as a reduction if it is found, only on
69+
// exception in `undef`, so that each path is at least one reduction.
70+
ProcessControlBlock::call_code(arc_process)
71+
}
72+
_ => undef(arc_process, module_term, function_term, argument_list),
73+
},
74+
"create_processes" => match arity {
75+
2 => {
76+
elixir::chain::create_processes_2::place_frame_with_arguments(
77+
arc_process,
78+
Placement::Replace,
79+
argument_vec[0],
80+
argument_vec[1],
81+
)?;
6082

6183
// don't count finding the function as a reduction if it is found, only on
6284
// exception in `undef`, so that each path is at least one reduction.
6385
ProcessControlBlock::call_code(arc_process)
6486
}
6587
_ => undef(arc_process, module_term, function_term, argument_list),
6688
},
67-
"run" => match arity {
89+
"dom" => match arity {
6890
1 => {
69-
let module_function_arity = Arc::new(ModuleFunctionArity {
70-
module,
71-
function,
72-
arity,
73-
});
74-
// Elixir.Chain.run is a user function and not a BIF, so it is a `Code` and
75-
// run in a frame instead of directly
76-
let chain_run_frame =
77-
Frame::new(module_function_arity, elixir::chain::run_0_code);
78-
arc_process.stack_push(argument_vec[0])?;
79-
arc_process.replace_frame(chain_run_frame);
91+
elixir::chain::dom_1::place_frame_with_arguments(
92+
arc_process,
93+
Placement::Replace,
94+
argument_vec[0],
95+
)?;
8096

8197
// don't count finding the function as a reduction if it is found, only on
8298
// exception in `undef`, so that each path is at least one reduction.

0 commit comments

Comments
 (0)