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