Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target
Cargo.lock
*.swp
*~
*.iml
3 changes: 1 addition & 2 deletions src/marshal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ pub mod common;
pub mod decode;

use std::io;
use std::collections::HashSet;
use super::objects::{Code, ObjectContent, Object, ObjectRef, ObjectStore};
use super::objects::{Code, ObjectContent, ObjectRef, ObjectStore};
use self::common::Object as MarshalObject;
use self::common::Code as MarshalCode;

Expand Down
7 changes: 3 additions & 4 deletions src/objects/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;
use std::sync::Mutex;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};

#[derive(Debug)]
#[derive(Clone)]
Expand Down Expand Up @@ -51,7 +50,7 @@ pub struct ObjectRef {
id: usize,
}

static current_ref_id: AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
static CURRENT_REF_ID: AtomicUsize = ATOMIC_USIZE_INIT;

#[derive(Debug)]
pub struct ObjectStore {
Expand All @@ -64,7 +63,7 @@ impl ObjectStore {
}

pub fn allocate(&mut self, obj: ObjectContent) -> ObjectRef {
let obj_ref = ObjectRef { id: current_ref_id.fetch_add(1, Ordering::SeqCst) };
let obj_ref = ObjectRef { id: CURRENT_REF_ID.fetch_add(1, Ordering::SeqCst) };
self.all_objects.insert(obj_ref.clone(), Object { content: obj });
obj_ref
}
Expand Down
4 changes: 1 addition & 3 deletions src/processor/instructions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::str::Bytes;

#[derive(PartialEq)]
#[derive(PartialEq)]
#[derive(Debug)]
pub enum Instruction {
PopTop,
Expand Down
4 changes: 2 additions & 2 deletions src/processor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod instructions;

use super::objects::{Object, Code, ObjectStore, ObjectRef, ObjectContent};
use super::objects::{Code, ObjectStore, ObjectRef, ObjectContent};
use super::sandbox::EnvProxy;
use super::stack::{Stack, VectorStack};
use self::instructions::Instruction;
Expand Down Expand Up @@ -29,7 +29,7 @@ fn run_code<EP: EnvProxy>(envproxy: &mut EP, store: &mut ObjectStore, code: Code
let instructions: Vec<Instruction> = instructions::InstructionDecoder::new(bytecode.iter()).into_iter().collect();
let mut program_counter = 0 as usize;
let mut stack = VectorStack::new();
while true {
loop {
let instruction = try!(instructions.get(program_counter).ok_or(ProcessorError::InvalidProgramCounter));
program_counter += 1;
match *instruction {
Expand Down
5 changes: 2 additions & 3 deletions src/sandbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ pub trait EnvProxy {


/// An EnvProxy that exposes the real environment
pub struct RealEnvProxy {
}
pub struct RealEnvProxy;

impl RealEnvProxy {
pub fn new() -> RealEnvProxy {
RealEnvProxy { }
RealEnvProxy
}
}

Expand Down