Refactor VM and operators
Some checks failed
Build / build (push) Failing after 5m54s
Publish Image / publish (push) Failing after 44s
Test / build (push) Failing after 5m21s

This commit is contained in:
Chuck Smith
2024-03-29 17:59:34 -04:00
parent 7435a993d9
commit 3b6df3e813
11 changed files with 979 additions and 639 deletions

20
internal/object/errors.go Normal file
View File

@@ -0,0 +1,20 @@
package object
import (
"fmt"
)
// BinaryOpError is an binary operation error usually resulting from mismatched types
type BinaryOpError struct {
left, right Object
op string
}
func (e BinaryOpError) Error() string {
return fmt.Sprintf("unsupported types for binary operation: %s %s %s", e.left.Type(), e.op, e.right.Type())
}
// NewBinaryOpError returns a new BinaryOpError
func NewBinaryOpError(left, right Object, op string) BinaryOpError {
return BinaryOpError{left, right, op}
}