diff options
Diffstat (limited to 'pkg/lang/vm/stack/errors.go')
| -rw-r--r-- | pkg/lang/vm/stack/errors.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pkg/lang/vm/stack/errors.go b/pkg/lang/vm/stack/errors.go new file mode 100644 index 0000000..55ef2ea --- /dev/null +++ b/pkg/lang/vm/stack/errors.go @@ -0,0 +1,34 @@ +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") + + 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) +} |
