diff options
| author | Mel <einebeere@gmail.com> | 2022-07-27 11:01:29 +0000 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-07-27 11:01:29 +0000 |
| commit | 22a69393f58abcf3bcf9e7039f994dae78422213 (patch) | |
| tree | 6f88f586bd57d298d54e345a6c4b8d7144a5d2ec /pkg/lang/vm/errors.go | |
| parent | 45b6f073fe398e820e9e4a82900bc282ee32af9b (diff) | |
| download | jinx-22a69393f58abcf3bcf9e7039f994dae78422213.tar.zst jinx-22a69393f58abcf3bcf9e7039f994dae78422213.zip | |
Implement VM modules and globals
Diffstat (limited to 'pkg/lang/vm/errors.go')
| -rw-r--r-- | pkg/lang/vm/errors.go | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/pkg/lang/vm/errors.go b/pkg/lang/vm/errors.go index bfc8a34..0dd73e7 100644 --- a/pkg/lang/vm/errors.go +++ b/pkg/lang/vm/errors.go @@ -9,16 +9,16 @@ import ( ) type Error struct { - Pc int + Pos code.Pos Line int Err error } func (e Error) Error() string { if e.Line == -1 { - return fmt.Sprintf("vm error at pc %d, unknown line: %v", e.Pc, e.Err) + return fmt.Sprintf("vm error in module '%d' at pc %d, unknown line: %v", e.Pos.Module, e.Pos.PC, e.Err) } - return fmt.Sprintf("vm error at pc %d, line %d: %v", e.Pc, e.Line, e.Err) + return fmt.Sprintf("vm error in module '%d' at pc %d, line %d: %v", e.Pos.Module, e.Pos.PC, e.Line, e.Err) } // Fatal errors @@ -111,3 +111,27 @@ type ErrWrongNumberOfArguments struct { func (e ErrWrongNumberOfArguments) Error() string { return fmt.Sprintf("wrong number of arguments: needed %d, got %d", e.Needed, e.Got) } + +type ErrCantAddGlobalFromMain struct { + GlobalName string +} + +func (e ErrCantAddGlobalFromMain) Error() string { + return fmt.Sprintf("can't export '%s' from main module", e.GlobalName) +} + +type ErrGlobalAlreadyExists struct { + GlobalName string +} + +func (e ErrGlobalAlreadyExists) Error() string { + return fmt.Sprintf("global '%s' already exists", e.GlobalName) +} + +type ErrNoSuchGlobal struct { + GlobalName string +} + +func (e ErrNoSuchGlobal) Error() string { + return fmt.Sprintf("no such global '%s'", e.GlobalName) +} |
