diff --git a/.idea/vulcan-emu.iml b/.idea/vulcan-emu.iml index cd90ee6..071d209 100644 --- a/.idea/vulcan-emu.iml +++ b/.idea/vulcan-emu.iml @@ -8,6 +8,8 @@ + + diff --git a/Cargo.lock b/Cargo.lock index 68fc157..9feec9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,8 +412,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if 1.0.0", + "js-sys", "libc", "wasi 0.10.2+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -1254,6 +1256,13 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "vasm" version = "0.1.0" +dependencies = [ + "vasm_core", +] + +[[package]] +name = "vasm_core" +version = "0.1.0" dependencies = [ "pest", "pest_derive", @@ -1264,6 +1273,7 @@ dependencies = [ name = "vcore" version = "0.1.0" dependencies = [ + "getrandom", "rand", ] @@ -1273,7 +1283,7 @@ version = "0.1.0" dependencies = [ "pixels", "rand", - "vasm", + "vasm_core", "vcore", "winit", ] @@ -1296,10 +1306,18 @@ dependencies = [ name = "vtest" version = "0.1.0" dependencies = [ - "vasm", + "vasm_core", "vcore", ] +[[package]] +name = "vweb" +version = "0.1.0" +dependencies = [ + "vcore", + "wasm-bindgen", +] + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index c22e198..67b14a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,8 @@ members = [ "vcore", "vemu", "vasm_core", + "vasm", "vtest", - "vlua" + "vlua", + "vweb" ] \ No newline at end of file diff --git a/vasm/Cargo.toml b/vasm/Cargo.toml new file mode 100644 index 0000000..f8328d0 --- /dev/null +++ b/vasm/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "vasm" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +vasm_core = { path = "../vasm_core" } diff --git a/vasm/src/main.rs b/vasm/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/vasm/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/vasm_core/Cargo.toml b/vasm_core/Cargo.toml index 173f7db..3396edf 100644 --- a/vasm_core/Cargo.toml +++ b/vasm_core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "vasm" +name = "vasm_core" version = "0.1.0" edition = "2021" diff --git a/vasm_core/src/vasm_assembler.rs b/vasm_core/src/vasm_assembler.rs index 86adcc2..eb0b417 100644 --- a/vasm_core/src/vasm_assembler.rs +++ b/vasm_core/src/vasm_assembler.rs @@ -1,8 +1,8 @@ +use std::collections::btree_map::BTreeMap; use crate::ast::{Label, Scope, VASMLine}; use crate::parse_error::{AssembleError, Location}; use crate::vasm_evaluator::eval; use crate::vasm_preprocessor::{Line, LineSource}; -use std::collections::BTreeMap; use std::fs; /// This will solve all the .equ directives and return a symbol table of them. @@ -163,7 +163,7 @@ fn code_bounds( /// bytes long and index 0 will represent 0x400. /// ``` /// assert_eq!( -/// vasm::assemble_snippet(".org 0x400 \n push 5 \n add 7".lines().map(String::from)), +/// vasm_core::assemble_snippet(".org 0x400 \n push 5 \n add 7".lines().map(String::from)), /// Ok(vec![0x01, 0x05, 0x05, 0x07]) /// ) /// ``` @@ -186,7 +186,6 @@ pub fn assemble_snippet>( pub fn assemble_file(filename: &str) -> Result, AssembleError> { let lines = lines_from_file(filename)?; let line_results: Vec> = LineSource::new(filename, lines, |file| { - println!("Including {}", file); lines_from_file(file.as_str()) }) .collect(); diff --git a/vasm_core/src/vasm_preprocessor.rs b/vasm_core/src/vasm_preprocessor.rs index 15b7ed7..2df5544 100644 --- a/vasm_core/src/vasm_preprocessor.rs +++ b/vasm_core/src/vasm_preprocessor.rs @@ -1,7 +1,7 @@ +use std::collections::vec_deque::VecDeque; use crate::ast::{Macro, VASMLine}; use crate::parse_error::{AssembleError, Location}; use crate::vasm_parser::parse_vasm_line; -use std::collections::VecDeque; use std::iter::Enumerate; #[derive(Debug, PartialEq, Clone)] diff --git a/vcore/Cargo.toml b/vcore/Cargo.toml index 0d4e4c6..4e2fba7 100644 --- a/vcore/Cargo.toml +++ b/vcore/Cargo.toml @@ -6,4 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +getrandom = { version = "0.2", features = ["js"] } rand = "0.8.0" diff --git a/vemu/Cargo.toml b/vemu/Cargo.toml index be66e24..18e7003 100644 --- a/vemu/Cargo.toml +++ b/vemu/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] vcore = { path = "../vcore" } -vasm = { path = "../vasm_core" } +vasm_core = { path = "../vasm_core" } rand = "0.8.0" winit = "0.26.1" pixels = "0.9.0" \ No newline at end of file diff --git a/vemu/src/main.rs b/vemu/src/main.rs index 2c52767..23ed9bd 100644 --- a/vemu/src/main.rs +++ b/vemu/src/main.rs @@ -14,7 +14,7 @@ use std::collections::VecDeque; use std::fs::File; use std::io::Read; use std::time::{Duration, Instant}; -use vasm::{assemble_file, assemble_snippet}; +use vasm_core::{assemble_file, assemble_snippet}; use vcore::cpu::CPU; use vcore::memory::{Memory, PeekPoke}; use vcore::word::Word; diff --git a/vtest/Cargo.toml b/vtest/Cargo.toml index 7592f18..704cfc1 100644 --- a/vtest/Cargo.toml +++ b/vtest/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" [dependencies] vcore = { path = "../vcore" } -vasm = { path = "../vasm_core" } \ No newline at end of file +vasm_core = { path = "../vasm_core" } \ No newline at end of file diff --git a/vtest/src/integration_tests.rs b/vtest/src/integration_tests.rs index 9b6571c..7802a1d 100644 --- a/vtest/src/integration_tests.rs +++ b/vtest/src/integration_tests.rs @@ -1,5 +1,5 @@ -use std::collections::BTreeMap; -use vasm::assemble_snippet; +use std::collections::btree_map::BTreeMap; +use vasm_core::assemble_snippet; use vcore::memory::{Memory, PeekPokeExt}; use vcore::word::Word; use vcore::CPU;