about summary refs log tree commit diff
path: root/pkg/lang/vm/stack/errors.go
blob: 55145d50bec83a9852e754a08517141d0d6593b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package stack

import (
	"errors"
	"fmt"
)

var (
	ErrStackOverflow  = errors.New("stack overflow (max depth: 1000)")
	ErrStackUnderflow = errors.New("local stack underflow")

	ErrReachedMaxCallDepth  = errors.New("reached max call depth (max depth: 1000)")
	ErrReachedRootCallFrame = errors.New("reached root call frame")
	ErrNotAtRootCallFrame   = errors.New("not at root call frame")

	ErrCallBaseCantBeNegative = errors.New("call base cannot be negative")
)

type ErrLocalIndexOutOfBounds struct {
	Index int
	Len   int
}

func (e ErrLocalIndexOutOfBounds) Error() string {
	return fmt.Sprintf("local index out of bounds: %d (len: %d)", e.Index, e.Len)
}

type ErrStackIndexOutOfBounds struct {
	Index int
	Len   int
}

func (e ErrStackIndexOutOfBounds) Error() string {
	return fmt.Sprintf("stack index out of bounds: %d (len: %d)", e.Index, e.Len)
}