Removed defer/panic. #503
This commit is contained in:
@ -17,10 +17,7 @@ type stack struct {
|
||||
}
|
||||
|
||||
func (st *stack) push(d *big.Int) {
|
||||
if len(st.data) == maxStack {
|
||||
panic(fmt.Sprintf("stack limit reached (%d)", maxStack))
|
||||
}
|
||||
|
||||
// NOTE push limit (1024) is checked in baseCheck
|
||||
stackItem := new(big.Int).Set(d)
|
||||
if len(st.data) > st.ptr {
|
||||
st.data[st.ptr] = stackItem
|
||||
@ -52,10 +49,11 @@ func (st *stack) peek() *big.Int {
|
||||
return st.data[st.len()-1]
|
||||
}
|
||||
|
||||
func (st *stack) require(n int) {
|
||||
func (st *stack) require(n int) error {
|
||||
if st.len() < n {
|
||||
panic(fmt.Sprintf("stack underflow (%d <=> %d)", len(st.data), n))
|
||||
return fmt.Errorf("stack underflow (%d <=> %d)", len(st.data), n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *stack) Print() {
|
||||
|
Reference in New Issue
Block a user