blob: f5dcc86b1cb1200faa949bda3793337eb2977666 (
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
36
|
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)
}
|