From 241a8f66bc796f06d901b20a271c6cfb26122fc1 Mon Sep 17 00:00:00 2001 From: Jur van den Berg Date: Sat, 11 Jun 2022 20:29:49 +0200 Subject: [PATCH] update feature names --- Cargo.toml | 20 ++++++++++---------- src/frame.rs | 4 ++-- src/lib.rs | 4 ++-- src/machine.rs | 14 +++++++------- src/netstack.rs | 2 +- src/ops.rs | 36 ++++++++++++++++++------------------ 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3eec088..b43e340 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,15 +11,15 @@ lazy_static = "1.3.0" [features] default = ["bonus", "extra"] -bonus = ["bonus:network", "bonus:heap"] -"bonus:network" = [] -"bonus:heap" = [] +bonus = ["bonus.network", "bonus.heap"] +"bonus.network" = [] +"bonus.heap" = [] -extra = ["extra:sleep", "extra:arithmetic"] -"extra:sleep" = [] -"extra:arithmetic" = [] +extra = ["extra.sleep", "extra.arithmetic"] +"extra.sleep" = [] +"extra.arithmetic" = [] -debug = ["debug:instr", "debug:frame", "debug:gc"] -"debug:instr" = [] -"debug:frame" = [] -"debug:gc" = [] +debug = ["debug.instr", "debug.frame", "debug.gc"] +"debug.instr" = [] +"debug.frame" = [] +"debug.gc" = [] diff --git a/src/frame.rs b/src/frame.rs index fc158d6..6b6b864 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -12,7 +12,7 @@ pub struct Frame { impl Frame { pub fn new(num_locals: usize, base: usize) -> Frame { - if cfg!(feature = "debug:frame") { + if cfg!(feature = "debug.frame") { println!("Initializing frame of len {}", num_locals); } Frame { @@ -24,7 +24,7 @@ impl Frame { } pub fn new_extendable(base: usize) -> Frame { - if cfg!(feature = "debug:frame") { + if cfg!(feature = "debug.frame") { println!("Initializing extendable frame"); } Frame { diff --git a/src/lib.rs b/src/lib.rs index 7f0b3d3..35ad6ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,9 +14,9 @@ pub mod pool; pub mod frame; pub mod stubs; -#[cfg(feature = "bonus:network")] +#[cfg(feature = "bonus.network")] pub mod netstack; -#[cfg(feature = "bonus:heap")] +#[cfg(feature = "bonus.heap")] pub mod heap; type Result = ::std::result::Result; diff --git a/src/machine.rs b/src/machine.rs index ef14d26..7f70249 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -10,9 +10,9 @@ use pool::Pool; use stack::Stack; use Result; -#[cfg(feature = "bonus:heap")] +#[cfg(feature = "bonus.heap")] use heap::Heaps; -#[cfg(feature = "bonus:network")] +#[cfg(feature = "bonus.network")] use netstack::NetStack; use std::convert::TryInto; @@ -25,9 +25,9 @@ pub struct Machine { pub block: Block, pub frame: Vec, - #[cfg(feature = "bonus:network")] + #[cfg(feature = "bonus.network")] pub net: NetStack, - #[cfg(feature = "bonus:heap")] + #[cfg(feature = "bonus.heap")] pub heap: Heaps, pub stream_in: Box, @@ -45,10 +45,10 @@ impl Machine { stream_in: Box::new(::std::io::stdin()), stream_out: Arc::new(Mutex::new(::std::io::stdout())), - #[cfg(feature = "bonus:network")] + #[cfg(feature = "bonus.network")] net: NetStack::new(), - #[cfg(feature = "bonus:heap")] + #[cfg(feature = "bonus.heap")] heap: Heaps::new(), } } @@ -85,7 +85,7 @@ impl Machine { pub fn step(&mut self) -> Result<()> { match self.block.read_op() { Ok(Operation::Op(a, func, _)) => { - if cfg!(feature = "debug:instr") { + if cfg!(feature = "debug.instr") { println!("{}", a); println!("Stack: {:?}", self.cur_frame().stack.data); let x = func(self); diff --git a/src/netstack.rs b/src/netstack.rs index 898698a..4203bf9 100644 --- a/src/netstack.rs +++ b/src/netstack.rs @@ -66,7 +66,7 @@ impl NetStack { } } - #[cfg(feature = "bonus:network")] + #[cfg(feature = "bonus.network")] pub fn write_byte(&mut self, byte: u8) -> Result<()> { match self.stream { Some(ref mut stream) => { diff --git a/src/ops.rs b/src/ops.rs index e786148..cf3a216 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -45,7 +45,7 @@ lazy_static! { m[0x60] = Operation::Op("IADD", iadd, vec![]); m[0x64] = Operation::Op("ISUB", isub, vec![]); - #[cfg(feature = "extra:arithmetic")] + #[cfg(feature = "extra.arithmetic")] { m[0x70] = Operation::Op("SHL", shl, vec![]); m[0x71] = Operation::Op("SHR", shr, vec![]); @@ -68,7 +68,7 @@ lazy_static! { m[0xC4] = Operation::Op("WIDE", wide, vec![]); - #[cfg(feature = "bonus:heap")] + #[cfg(feature = "bonus.heap")] { m[0xD1] = Operation::Op("NEWARRAY", newarray, vec![]); m[0xD2] = Operation::Op("IALOAD", iaload, vec![]); @@ -76,7 +76,7 @@ lazy_static! { m[0xD4] = Operation::Op("GC", gc, vec![]); } - #[cfg(feature = "bonus:network")] + #[cfg(feature = "bonus.network")] { m[0xE1] = Operation::Op("NETBIND", netbind, vec![]); m[0xE2] = Operation::Op("NETCONNECT", netconnect, vec![]); @@ -85,7 +85,7 @@ lazy_static! { m[0xE5] = Operation::Op("NETCLOSE", netclose, vec![]); } - #[cfg(feature = "extra:sleep")] + #[cfg(feature = "extra.sleep")] { m[0xF0] = Operation::Op("SLP", slp, vec![Args::Byte]); } @@ -294,7 +294,7 @@ fn ireturn(machine: &mut Machine) -> Result<()> { machine.block.seek(return_addr as usize) } -#[cfg(feature = "extra:sleep")] +#[cfg(feature = "extra.sleep")] fn slp(machine: &mut Machine) -> Result<()> { use std::thread; use std::time; @@ -307,7 +307,7 @@ fn slp(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "bonus:network")] +#[cfg(feature = "bonus.network")] fn netbind(machine: &mut Machine) -> Result<()> { let port: i32 = machine.cur_stack().pop()?.try_into()?; @@ -319,7 +319,7 @@ fn netbind(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "bonus:network")] +#[cfg(feature = "bonus.network")] fn netconnect(machine: &mut Machine) -> Result<()> { let port: i32 = machine.cur_stack().pop()?.try_into()?; let host: i32 = machine.cur_stack().pop()?.try_into()?; @@ -331,7 +331,7 @@ fn netconnect(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "bonus:network")] +#[cfg(feature = "bonus.network")] fn netin(machine: &mut Machine) -> Result<()> { let netref: i32 = machine.cur_stack().pop()?.try_into()?; if netref != 1 { @@ -343,7 +343,7 @@ fn netin(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "bonus:network")] +#[cfg(feature = "bonus.network")] fn netout(machine: &mut Machine) -> Result<()> { let netref: i32 = machine.cur_stack().pop()?.try_into()?; if netref != 1 { @@ -354,7 +354,7 @@ fn netout(machine: &mut Machine) -> Result<()> { machine.net.write_byte(val as u8) } -#[cfg(feature = "bonus:network")] +#[cfg(feature = "bonus.network")] fn netclose(machine: &mut Machine) -> Result<()> { let netref: i32 = machine.cur_stack().pop()?.try_into()?; if netref != 1 { @@ -363,7 +363,7 @@ fn netclose(machine: &mut Machine) -> Result<()> { machine.net.close() } -#[cfg(feature = "bonus:heap")] +#[cfg(feature = "bonus.heap")] fn newarray(machine: &mut Machine) -> Result<()> { let size: i32 = machine.cur_stack().pop()?.try_into()?; let heap = machine.heap.alloc(size as usize); @@ -371,7 +371,7 @@ fn newarray(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "bonus:heap")] +#[cfg(feature = "bonus.heap")] fn iastore(machine: &mut Machine) -> Result<()> { use std::cell::RefCell; @@ -387,7 +387,7 @@ fn iastore(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "bonus:heap")] +#[cfg(feature = "bonus.heap")] fn iaload(machine: &mut Machine) -> Result<()> { let heap = match machine.cur_stack().pop()? { Value::HeapRef(a) => a, @@ -404,13 +404,13 @@ fn iaload(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "bonus:heap")] +#[cfg(feature = "bonus.heap")] fn gc(machine: &mut Machine) -> Result<()> { machine.heap.gc(); Ok(()) } -#[cfg(feature = "extra:arithmetic")] +#[cfg(feature = "extra.arithmetic")] fn shl(machine: &mut Machine) -> Result<()> { let shift: i32 = machine.cur_stack().pop()?.try_into()?; let value: i32 = machine.cur_stack().pop()?.try_into()?; @@ -419,7 +419,7 @@ fn shl(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "extra:arithmetic")] +#[cfg(feature = "extra.arithmetic")] fn shr(machine: &mut Machine) -> Result<()> { let shift: i32 = machine.cur_stack().pop()?.try_into()?; let value: i32 = machine.cur_stack().pop()?.try_into()?; @@ -429,7 +429,7 @@ fn shr(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "extra:arithmetic")] +#[cfg(feature = "extra.arithmetic")] fn imul(machine: &mut Machine) -> Result<()> { let a: i32 = machine.cur_stack().pop()?.try_into()?; let b: i32 = machine.cur_stack().pop()?.try_into()?; @@ -438,7 +438,7 @@ fn imul(machine: &mut Machine) -> Result<()> { Ok(()) } -#[cfg(feature = "extra:arithmetic")] +#[cfg(feature = "extra.arithmetic")] fn idiv(machine: &mut Machine) -> Result<()> { let divisor: i32 = machine.cur_stack().pop()?.try_into()?; let value: i32 = machine.cur_stack().pop()?.try_into()?;