-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreturnresult.go
More file actions
48 lines (40 loc) · 1.25 KB
/
returnresult.go
File metadata and controls
48 lines (40 loc) · 1.25 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2023, Peter Ohler, All rights reserved.
package slip
// ReturnResult is returned by the return-from function.
type ReturnResult struct {
// Tag can be either a Symbol or nil and identifies the block name that
// the results should returned from.
Tag Object
// Result to return.
Result Object
}
// String returns a string representation of the object.
func (rr *ReturnResult) String() string {
return string(rr.Append(nil))
}
// Append the object to a byte slice.
func (rr *ReturnResult) Append(b []byte) []byte {
b = append(b, "#<return-result "...)
b = ObjectAppend(b, rr.Tag)
return append(b, '>')
}
// Simplify the Object into simple go types of nil, bool, int64, float64,
// string, []any, map[string]any, or time.Time.
func (rr *ReturnResult) Simplify() any {
return map[string]any{
"tag": Simplify(rr.Tag),
"result": Simplify(rr.Result),
}
}
// Equal returns true if this Object and the other are equal in value.
func (rr *ReturnResult) Equal(other Object) bool {
return rr == other
}
// Hierarchy returns the class hierarchy as symbols for the instance.
func (rr *ReturnResult) Hierarchy() []Symbol {
return []Symbol{TrueSymbol}
}
// Eval the object.
func (rr *ReturnResult) Eval(s *Scope, depth int) Object {
return rr
}