-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
25 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
package builtin | ||
|
||
type error interface { | ||
Error() string | ||
IsNone() bool | ||
NotNone() bool | ||
type error table { | ||
none bool | ||
message string | ||
} | ||
|
||
func (e *error) Error() string { | ||
return e.message | ||
} | ||
|
||
func (e *error) IsNone() bool { | ||
return e.none | ||
} | ||
|
||
func (e *error) NotNone() bool { | ||
return !e.none | ||
} | ||
|
||
type Type byte | ||
extern func copy(dst []Type, src []Type) int32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,17 @@ | ||
package errors | ||
|
||
type errorData table { | ||
none bool | ||
s string | ||
} | ||
|
||
func (e *errorData) Error() string { | ||
return e.s | ||
} | ||
|
||
func (e *errorData) IsNone() bool { | ||
return e.none | ||
} | ||
|
||
func (e *errorData) NotNone() bool { | ||
return !e.none | ||
const NONE = error { | ||
none: true | ||
} | ||
|
||
func New(text string) error { | ||
var e errorData | ||
e.s = text | ||
var e error | ||
e.message = text | ||
return e | ||
} | ||
|
||
func None() error { | ||
var e errorData | ||
e.none = true | ||
return e | ||
return NONE | ||
} | ||
|
||
var ErrUnsupported = New("unsupported operation") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters