Skip to content

Commit

Permalink
Moved to a workspace architecture (#247)
Browse files Browse the repository at this point in the history
* Moved to a workspace architecture
  • Loading branch information
Razican authored Feb 14, 2020
1 parent cb850fc commit 5f6e4c2
Show file tree
Hide file tree
Showing 51 changed files with 541 additions and 452 deletions.
708 changes: 397 additions & 311 deletions Cargo.lock

Large diffs are not rendered by default.

89 changes: 28 additions & 61 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,61 +1,28 @@
[package]
name = "Boa"
version = "0.5.1"
authors = ["Jason Williams <jase.williams@gmail.com>"]
description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language."
homepage = "https://github.com/jasonwilliams/boa"
repository = "https://github.com/jasonwilliams/boa"
keywords = ["javascript", "compiler", "lexer", "parser", "js"]
license = "Unlicense/MIT"
exclude = [".vscode/*", "Dockerfile", "Makefile", ".editorConfig"]
edition = "2018"
default-run = "boa"

[features]
default = ["wasm-bindgen"]

[dependencies]
gc = "^0.3.3"
gc_derive = "^0.3.2"
serde_json = "^1.0.40"
rand = "^0.7.0"
regex = "^1.3.0"
structopt = "0.3.2"

# Optional Dependencies
wasm-bindgen = { version = "^0.2.50", optional = true }

[dev-dependencies]
criterion = "^0.3.0"

[lib]
crate-type = ["cdylib", "lib"]
name = "boa"
path = "src/lib/lib.rs"
bench = false

[[bench]]
name = "string"
harness = false

[[bench]]
name = "fib"
harness = false

[[bench]]
name = "exec"
harness = false

[[bench]]
name = "parser"
harness = false

[[bin]]
name = "boa"
path = "src/bin/bin.rs"
bench = false

[[bin]]
name = "boashell"
path = "src/bin/shell.rs"
bench = false
[workspace]
members = [
"boa",
"boa_cli",
]

# The release profile, used for `cargo build`.
[profile.dev]
incremental = true
opt-level = 0
debug = true
rpath = false
lto = false
debug-assertions = true
overflow-checks = true
panic = 'unwind'

# The release profile, used for `cargo build --release`.
[profile.release]
incremental = false
opt-level = 3
debug = false
rpath = false
codegen-units = 1
lto = true
debug-assertions = false
overflow-checks = false
panic = 'unwind'
48 changes: 48 additions & 0 deletions boa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[package]
name = "Boa"
version = "0.5.1"
authors = ["Jason Williams <jase.williams@gmail.com>"]
description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language."
repository = "https://github.com/jasonwilliams/boa"
keywords = ["javascript", "compiler", "lexer", "parser", "js"]
categories = ["parser-implementations", "wasm"]
license = "Unlicense/MIT"
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"]
edition = "2018"

[features]
default = ["wasm-bindgen"]

[dependencies]
gc = "0.3.3"
gc_derive = "0.3.2"
serde_json = "1.0.46"
rand = "0.7.3"
regex = "1.3.4"

# Optional Dependencies
wasm-bindgen = { version = "0.2.58", optional = true }

[dev-dependencies]
criterion = "0.3.1"

[lib]
crate-type = ["cdylib", "lib"]
name = "boa"
bench = false

[[bench]]
name = "string"
harness = false

[[bench]]
name = "fib"
harness = false

[[bench]]
name = "exec"
harness = false

[[bench]]
name = "parser"
harness = false
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "boa_cli"
version = "0.1.0"
authors = ["razican <iban.eguia@cern.ch>"]
description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language."
repository = "https://github.com/jasonwilliams/boa"
keywords = ["javascript", "compiler", "lexer", "parser", "js", "cli"]
categories = ["command-line-utilities"]
license = "Unlicense/MIT"
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"]
edition = "2018"

[dependencies]
Boa = { path = "../boa" }
structopt = "0.3.9"
39 changes: 39 additions & 0 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#![deny(unused_qualifications, clippy::correctness, clippy::style)]
#![warn(clippy::perf)]
#![allow(clippy::cognitive_complexity)]

use boa::{exec, exec::Executor, forward_val, realm::Realm};
use std::{fs::read_to_string, path::PathBuf};
use structopt::StructOpt;

/// CLI configuration for Boa.
#[derive(Debug, StructOpt)]
#[structopt(author, about)]
struct Opt {
/// The javascript file to be evaluated.
#[structopt(name = "FILE", parse(from_os_str), default_value = "tests/js/test.js")]
file: PathBuf,
/// Open a boa shell (WIP).
#[structopt(short, long)]
shell: bool,
}

pub fn main() -> Result<(), std::io::Error> {
let args = Opt::from_args();

let buffer = read_to_string(args.file)?;

if args.shell {
let realm = Realm::create();
let mut engine = Executor::new(realm);

match forward_val(&mut engine, &buffer) {
Ok(v) => print!("{}", v.to_string()),
Err(v) => eprint!("{}", v.to_string()),
}
} else {
dbg!(exec(&buffer));
}

Ok(())
}
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Note that a dynamic `import` statement here is required due to
// webpack/webpack#6615, but in theory `import { greet } from './pkg/hello_world';`
// will work here one day as well!
const rust = import("./pkg");
const rust = import("./boa/pkg");
import * as monaco from "monaco-editor";
// const image = import("./assets/01_rust_loves_js.png");

Expand All @@ -14,8 +14,7 @@ greet('World')
`;

const editor = monaco.editor.create(
document.getElementsByClassName("textbox")[0],
{
document.getElementsByClassName("textbox")[0], {
value: initialCode,
language: "javascript",
theme: "vs",
Expand All @@ -42,4 +41,4 @@ function inputHandler(evt) {
let p = document.querySelector("p.output");
let result = window.evaluate(text);
p.textContent = `> ${result}`;
}
}
40 changes: 0 additions & 40 deletions src/bin/bin.rs

This file was deleted.

29 changes: 0 additions & 29 deletions src/bin/shell.rs

This file was deleted.

18 changes: 11 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const {
CleanWebpackPlugin
} = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
Expand All @@ -18,10 +20,13 @@ module.exports = {
template: "index.html"
}),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, ".")
crateDirectory: path.resolve(__dirname, "./boa/"),
outDir: path.resolve(__dirname, "./boa/pkg/")
}),
new CopyWebpackPlugin([
{ from: "./assets/*", to: "." },
new CopyWebpackPlugin([{
from: "./assets/*",
to: "."
},
{
from: "./node_modules/bootstrap/dist/css/bootstrap.min.css",
to: "./assets"
Expand All @@ -38,8 +43,7 @@ module.exports = {
})
],
module: {
rules: [
{
rules: [{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
Expand All @@ -50,4 +54,4 @@ module.exports = {
]
},
mode: "development"
};
};

0 comments on commit 5f6e4c2

Please sign in to comment.