Some small fixes and compile flaggery
This commit is contained in:
@@ -66,7 +66,7 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Ok(Operation::Invalid(a)) => {
|
Ok(Operation::Invalid(a)) => {
|
||||||
println!("OP: {}", a);
|
println!("UNDEFINED OP: 0x{:X}", a);
|
||||||
Err("Invalid op")
|
Err("Invalid op")
|
||||||
},
|
},
|
||||||
Err(str) => Err(str)
|
Err(str) => Err(str)
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
use ijvm::Result;
|
use std::net::TcpStream;
|
||||||
use std::io::{Read, Write};
|
|
||||||
use std::net::{TcpListener, TcpStream};
|
|
||||||
|
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
|
use ijvm::Result;
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
|
use std::net::TcpListener;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NetStack {
|
pub struct NetStack {
|
||||||
@@ -15,6 +19,7 @@ impl NetStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
pub fn bind(&mut self, port: u16) -> Result<()> {
|
pub fn bind(&mut self, port: u16) -> Result<()> {
|
||||||
let listener = match TcpListener::bind(format!("0.0.0.0:{}", port)) {
|
let listener = match TcpListener::bind(format!("0.0.0.0:{}", port)) {
|
||||||
Ok(a) => a,
|
Ok(a) => a,
|
||||||
@@ -30,6 +35,7 @@ impl NetStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
pub fn connect(&mut self, host: u32, port: u16) -> Result<()> {
|
pub fn connect(&mut self, host: u32, port: u16) -> Result<()> {
|
||||||
let h1 = (host & (0xFF << 24)) >> 24 as u8;
|
let h1 = (host & (0xFF << 24)) >> 24 as u8;
|
||||||
let h2 = (host & (0xFF << 16)) >> 16 as u8;
|
let h2 = (host & (0xFF << 16)) >> 16 as u8;
|
||||||
@@ -44,6 +50,7 @@ impl NetStack {
|
|||||||
Err("Could not connect to address")
|
Err("Could not connect to address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
pub fn close(&mut self) -> Result<()> {
|
pub fn close(&mut self) -> Result<()> {
|
||||||
if let None = self.stream {
|
if let None = self.stream {
|
||||||
return Err("Cannot close a nonexistent socket")
|
return Err("Cannot close a nonexistent socket")
|
||||||
@@ -53,6 +60,7 @@ impl NetStack {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
pub fn read_byte(&mut self) -> Result<i8> {
|
pub fn read_byte(&mut self) -> Result<i8> {
|
||||||
return match self.stream {
|
return match self.stream {
|
||||||
Some(ref mut stream) => {
|
Some(ref mut stream) => {
|
||||||
@@ -65,6 +73,7 @@ impl NetStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bonus:network")]
|
||||||
pub fn write_byte(&mut self, byte: u8) -> Result<()> {
|
pub fn write_byte(&mut self, byte: u8) -> Result<()> {
|
||||||
return match self.stream {
|
return match self.stream {
|
||||||
Some(ref mut stream) => {
|
Some(ref mut stream) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user