VM improvements, tests + bugfixes (#61)

* changed vm commands to match more of the standard

* fixed Uint16 jmp bug in VM

* moved test to vm + fixed numnotequal bug

* fixed broken tests

* moved compiler tests to vm tests

* added basic for support + inc and dec stmts

* bumped version
This commit is contained in:
Anthony De Meulemeester 2018-04-02 17:04:42 +02:00 committed by GitHub
parent 931388b687
commit 69c3e645b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 521 additions and 159 deletions

View file

@ -61,7 +61,7 @@ func (e *Element) Prev() *Element {
// Will panic if the assertion failed which will be catched by the VM.
func (e *Element) BigInt() *big.Int {
switch t := e.value.(type) {
case *bigIntegerItem:
case *BigIntegerItem:
return t.value
default:
b := t.Value().([]uint8)
@ -99,6 +99,13 @@ func NewStack(n string) *Stack {
return s
}
// Clear will clear all elements on the stack and set its length to 0.
func (s *Stack) Clear() {
s.top.next = &s.top
s.top.prev = &s.top
s.len = 0
}
// Len return the number of elements that are on the stack.
func (s *Stack) Len() int {
return s.len