Browse Source

Moved to a workspace architecture (#247)

* Moved to a workspace architecture
pull/249/head
Iban Eguia 5 years ago committed by GitHub
parent
commit
5f6e4c22c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 708
      Cargo.lock
  2. 89
      Cargo.toml
  3. 48
      boa/Cargo.toml
  4. 0
      boa/benches/exec.rs
  5. 0
      boa/benches/fib.rs
  6. 0
      boa/benches/parser.rs
  7. 0
      boa/benches/string.rs
  8. 0
      boa/src/builtins/array.rs
  9. 0
      boa/src/builtins/boolean.rs
  10. 0
      boa/src/builtins/console.rs
  11. 0
      boa/src/builtins/error.rs
  12. 0
      boa/src/builtins/function.rs
  13. 0
      boa/src/builtins/json.rs
  14. 0
      boa/src/builtins/math.rs
  15. 0
      boa/src/builtins/mod.rs
  16. 0
      boa/src/builtins/number.rs
  17. 0
      boa/src/builtins/object.rs
  18. 0
      boa/src/builtins/object/internal_state.rs
  19. 0
      boa/src/builtins/property.rs
  20. 0
      boa/src/builtins/regexp.rs
  21. 0
      boa/src/builtins/string.rs
  22. 0
      boa/src/builtins/symbol.rs
  23. 0
      boa/src/builtins/value.rs
  24. 0
      boa/src/environment/declarative_environment_record.rs
  25. 0
      boa/src/environment/environment_record_trait.rs
  26. 0
      boa/src/environment/function_environment_record.rs
  27. 0
      boa/src/environment/global_environment_record.rs
  28. 0
      boa/src/environment/lexical_environment.rs
  29. 0
      boa/src/environment/mod.rs
  30. 0
      boa/src/environment/object_environment_record.rs
  31. 0
      boa/src/exec.rs
  32. 0
      boa/src/lib.rs
  33. 0
      boa/src/realm.rs
  34. 0
      boa/src/syntax/ast/constant.rs
  35. 0
      boa/src/syntax/ast/expr.rs
  36. 0
      boa/src/syntax/ast/keyword.rs
  37. 0
      boa/src/syntax/ast/mod.rs
  38. 0
      boa/src/syntax/ast/op.rs
  39. 0
      boa/src/syntax/ast/pos.rs
  40. 0
      boa/src/syntax/ast/punc.rs
  41. 0
      boa/src/syntax/ast/token.rs
  42. 0
      boa/src/syntax/lexer.rs
  43. 0
      boa/src/syntax/mod.rs
  44. 0
      boa/src/syntax/parser.rs
  45. 0
      boa/src/wasm.rs
  46. 15
      boa_cli/Cargo.toml
  47. 39
      boa_cli/src/main.rs
  48. 7
      index.js
  49. 40
      src/bin/bin.rs
  50. 29
      src/bin/shell.rs
  51. 18
      webpack.config.js

708
Cargo.lock generated

File diff suppressed because it is too large Load Diff

89
Cargo.toml

@ -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
boa/Cargo.toml

@ -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

0
benches/exec.rs → boa/benches/exec.rs

0
benches/fib.rs → boa/benches/fib.rs

0
benches/parser.rs → boa/benches/parser.rs

0
benches/string.rs → boa/benches/string.rs

0
src/lib/builtins/array.rs → boa/src/builtins/array.rs

0
src/lib/builtins/boolean.rs → boa/src/builtins/boolean.rs

0
src/lib/builtins/console.rs → boa/src/builtins/console.rs

0
src/lib/builtins/error.rs → boa/src/builtins/error.rs

0
src/lib/builtins/function.rs → boa/src/builtins/function.rs

0
src/lib/builtins/json.rs → boa/src/builtins/json.rs

0
src/lib/builtins/math.rs → boa/src/builtins/math.rs

0
src/lib/builtins/mod.rs → boa/src/builtins/mod.rs

0
src/lib/builtins/number.rs → boa/src/builtins/number.rs

0
src/lib/builtins/object.rs → boa/src/builtins/object.rs

0
src/lib/builtins/object/internal_state.rs → boa/src/builtins/object/internal_state.rs

0
src/lib/builtins/property.rs → boa/src/builtins/property.rs

0
src/lib/builtins/regexp.rs → boa/src/builtins/regexp.rs

0
src/lib/builtins/string.rs → boa/src/builtins/string.rs

0
src/lib/builtins/symbol.rs → boa/src/builtins/symbol.rs

0
src/lib/builtins/value.rs → boa/src/builtins/value.rs

0
src/lib/environment/declarative_environment_record.rs → boa/src/environment/declarative_environment_record.rs

0
src/lib/environment/environment_record_trait.rs → boa/src/environment/environment_record_trait.rs

0
src/lib/environment/function_environment_record.rs → boa/src/environment/function_environment_record.rs

0
src/lib/environment/global_environment_record.rs → boa/src/environment/global_environment_record.rs

0
src/lib/environment/lexical_environment.rs → boa/src/environment/lexical_environment.rs

0
src/lib/environment/mod.rs → boa/src/environment/mod.rs

0
src/lib/environment/object_environment_record.rs → boa/src/environment/object_environment_record.rs

0
src/lib/exec.rs → boa/src/exec.rs

0
src/lib/lib.rs → boa/src/lib.rs

0
src/lib/realm.rs → boa/src/realm.rs

0
src/lib/syntax/ast/constant.rs → boa/src/syntax/ast/constant.rs

0
src/lib/syntax/ast/expr.rs → boa/src/syntax/ast/expr.rs

0
src/lib/syntax/ast/keyword.rs → boa/src/syntax/ast/keyword.rs

0
src/lib/syntax/ast/mod.rs → boa/src/syntax/ast/mod.rs

0
src/lib/syntax/ast/op.rs → boa/src/syntax/ast/op.rs

0
src/lib/syntax/ast/pos.rs → boa/src/syntax/ast/pos.rs

0
src/lib/syntax/ast/punc.rs → boa/src/syntax/ast/punc.rs

0
src/lib/syntax/ast/token.rs → boa/src/syntax/ast/token.rs

0
src/lib/syntax/lexer.rs → boa/src/syntax/lexer.rs

0
src/lib/syntax/mod.rs → boa/src/syntax/mod.rs

0
src/lib/syntax/parser.rs → boa/src/syntax/parser.rs

0
src/lib/wasm.rs → boa/src/wasm.rs

15
boa_cli/Cargo.toml

@ -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
boa_cli/src/main.rs

@ -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
index.js

@ -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");
@ -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",
@ -42,4 +41,4 @@ function inputHandler(evt) {
let p = document.querySelector("p.output");
let result = window.evaluate(text);
p.textContent = `> ${result}`;
}
}

40
src/bin/bin.rs

@ -1,40 +0,0 @@
#![deny(unused_qualifications, clippy::correctness, clippy::style)]
#![warn(clippy::perf)]
#![allow(clippy::cognitive_complexity)]
use boa::exec;
use std::{env, fs::read_to_string, process::exit};
fn print_usage() {
println!(
"Usage:
boa [file.js]
Interpret and execute file.js
(if no file given, defaults to tests/js/test.js"
);
}
pub fn main() -> Result<(), std::io::Error> {
let args: Vec<String> = env::args().collect();
let read_file;
match args.len() {
// No arguments passed, default to "test.js"
1 => {
read_file = "tests/js/test.js";
}
// One argument passed, assumed this is the test file
2 => {
read_file = &args[1];
}
// Some other number of arguments passed: not supported
_ => {
print_usage();
exit(1);
}
}
let buffer = read_to_string(read_file)?;
dbg!(exec(&buffer));
Ok(())
}

29
src/bin/shell.rs

@ -1,29 +0,0 @@
#![deny(unused_qualifications, clippy::correctness, clippy::style)]
#![warn(clippy::perf)]
#![allow(clippy::cognitive_complexity)]
use boa::realm::Realm;
use boa::{exec::Executor, forward_val};
use std::{fs::read_to_string, path::PathBuf};
use structopt::StructOpt;
#[derive(StructOpt)]
struct Opt {
#[structopt(parse(from_os_str), help = "the javascript file to be evaluated")]
file: PathBuf,
}
pub fn main() -> Result<(), std::io::Error> {
let args = Opt::from_args();
let buffer = read_to_string(args.file)?;
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()),
}
Ok(())
}

18
webpack.config.js

@ -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");
@ -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"
@ -38,8 +43,7 @@ module.exports = {
})
],
module: {
rules: [
{
rules: [{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
@ -50,4 +54,4 @@ module.exports = {
]
},
mode: "development"
};
};
Loading…
Cancel
Save