about summary refs log tree commit diff
path: root/pkg/lang/vm/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/vm/errors.go')
-rw-r--r--pkg/lang/vm/errors.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/pkg/lang/vm/errors.go b/pkg/lang/vm/errors.go
index 264dd3a..2f5b56a 100644
--- a/pkg/lang/vm/errors.go
+++ b/pkg/lang/vm/errors.go
@@ -4,6 +4,7 @@ import (
 	"errors"
 	"fmt"
 	"jinx/pkg/lang/vm/code"
+	"jinx/pkg/lang/vm/mem"
 	"jinx/pkg/lang/vm/text"
 	"jinx/pkg/lang/vm/value"
 )
@@ -31,6 +32,8 @@ var (
 	ErrReachedRootCallFrame = errors.New("reached root call frame")
 
 	ErrCallBaseCantBeNegative = errors.New("call base cannot be negative")
+
+	ErrEnvNotSet = errors.New("env not set")
 )
 
 type ErrLocalIndexOutOfBounds struct {
@@ -59,6 +62,32 @@ func (e ErrInvalidOp) Error() string {
 	return fmt.Sprintf("invalid opcode: %d", e.Op)
 }
 
+type ErrUnexpectedMemCell struct {
+	Ptr      mem.Ptr
+	Expected mem.CellKind
+	Got      mem.CellKind
+}
+
+func (e ErrUnexpectedMemCell) Error() string {
+	return fmt.Sprintf("unexpected memory cell at %s: expected %v, got %v", e.Ptr.String(), e.Expected, e.Got)
+}
+
+type ErrMemNilCell struct {
+	Ptr mem.Ptr
+}
+
+func (e ErrMemNilCell) Error() string {
+	return fmt.Sprintf("found no value at %s", e.Ptr.String())
+}
+
+type ErrCorruptedMemCell struct {
+	Ptr mem.Ptr
+}
+
+func (e ErrCorruptedMemCell) Error() string {
+	return fmt.Sprintf("corrupted memory cell at %s", e.Ptr.String())
+}
+
 // Non-fatal errors, which will later be implemented as catchable exceptions
 
 type ErrInvalidOperandType struct {