Renaming NO_OF_LOG_INSTRUCTIONS -> MAX_NO_OF_TOPICS

This commit is contained in:
Tomusdrw 2016-01-16 17:24:42 +01:00
parent d496a66a30
commit 5b9097a9ca
2 changed files with 5 additions and 5 deletions

View File

@ -380,7 +380,7 @@ pub const LOG1: Instruction = 0xa1; //< Makes a log entry; 1 topic.
pub const LOG2: Instruction = 0xa2; //< Makes a log entry; 2 topics. pub const LOG2: Instruction = 0xa2; //< Makes a log entry; 2 topics.
pub const LOG3: Instruction = 0xa3; //< Makes a log entry; 3 topics. pub const LOG3: Instruction = 0xa3; //< Makes a log entry; 3 topics.
pub const LOG4: Instruction = 0xa4; //< Makes a log entry; 4 topics. pub const LOG4: Instruction = 0xa4; //< Makes a log entry; 4 topics.
pub const NO_OF_LOG_INSTRUCTIONS : usize = 5; pub const MAX_NO_OF_TOPICS : usize = 4;
pub const CREATE: Instruction = 0xf0; //< create a new account with associated code pub const CREATE: Instruction = 0xf0; //< create a new account with associated code
pub const CALL: Instruction = 0xf1; //< message-call into an account pub const CALL: Instruction = 0xf1; //< message-call into an account

View File

@ -40,7 +40,7 @@ trait Stack<T> {
fn has(&self, no_of_elems: usize) -> bool; fn has(&self, no_of_elems: usize) -> bool;
/// Get element from top and remove it from Stack. Panics if stack is empty. /// Get element from top and remove it from Stack. Panics if stack is empty.
fn pop_back(&mut self) -> T; fn pop_back(&mut self) -> T;
/// Get (up to 5) elements from top and remove them from Stack. Panics if stack is empty. /// Get (up to `instructions::MAX_NO_OF_TOPICS`) elements from top and remove them from Stack. Panics if stack is empty.
fn pop_n(&mut self, no_of_elems: usize) -> &[T]; fn pop_n(&mut self, no_of_elems: usize) -> &[T];
/// Add element on top of the Stack /// Add element on top of the Stack
fn push(&mut self, elem: T); fn push(&mut self, elem: T);
@ -50,14 +50,14 @@ trait Stack<T> {
struct VecStack<S> { struct VecStack<S> {
stack: Vec<S>, stack: Vec<S>,
logs: [S; instructions::NO_OF_LOG_INSTRUCTIONS] logs: [S; instructions::MAX_NO_OF_TOPICS]
} }
impl<S : Copy> VecStack<S> { impl<S : Copy> VecStack<S> {
fn with_capacity(capacity: usize, zero: S) -> Self { fn with_capacity(capacity: usize, zero: S) -> Self {
VecStack { VecStack {
stack: Vec::with_capacity(capacity), stack: Vec::with_capacity(capacity),
logs: [zero; instructions::NO_OF_LOG_INSTRUCTIONS] logs: [zero; instructions::MAX_NO_OF_TOPICS]
} }
} }
} }
@ -91,7 +91,7 @@ impl<S> Stack<S> for VecStack<S> {
} }
fn pop_n(&mut self, no_of_elems: usize) -> &[S] { fn pop_n(&mut self, no_of_elems: usize) -> &[S] {
assert!(no_of_elems < instructions::NO_OF_LOG_INSTRUCTIONS); assert!(no_of_elems <= instructions::MAX_NO_OF_TOPICS);
for i in 0..no_of_elems { for i in 0..no_of_elems {
self.logs[i] = self.pop_back(); self.logs[i] = self.pop_back();