package mem import ( "errors" "fmt" ) var ( ErrMemOverflow = errors.New("memory overflow, cannot allocate more than 10000 memory cells") ) type ErrInvalidCellKind struct { Kind CellKind } func (e ErrInvalidCellKind) Error() string { return fmt.Sprintf("cannot allocate cell of kind %s", e.Kind) } type ErrInvalidMemAccess struct { Ptr Ptr } func (e ErrInvalidMemAccess) Error() string { return fmt.Sprintf("invalid memory access at %d", e.Ptr) } type ErrDifferingCellKind struct { Ptr Ptr Expected CellKind Got CellKind } func (e ErrDifferingCellKind) Error() string { return fmt.Sprintf("tried assigning %v to mem cell of type %v at %d", e.Got, e.Expected, e.Ptr) }