Skip to content

Commit

Permalink
Refl S uses header, more info on self ref
Browse files Browse the repository at this point in the history
  • Loading branch information
acook committed Mar 7, 2021
1 parent de9d2ab commit 660bf64
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s Stack) Value() interface{} {
}

func (s Stack) Refl() string {
str := "<#" + s.Type + "#" + strconv.Itoa(s.ID) + "#" + strconv.Itoa(s.Depth()) + "# "
str := s.ReflHeader()

for _, i := range s.Items {
switch i.(type) {
Expand All @@ -50,7 +50,7 @@ func (s Stack) Refl() string {
str += "$*<...> "
case *Stack:
if i.(*Stack).ID == s.ID {
str += "<...> "
str += s.ReflHeader() + "...> "
} else {
str += i.Refl() + " "
}
Expand All @@ -67,7 +67,24 @@ func (s Stack) Refl() string {
str = str[:len(str)-1]
}

return str + ">"
return str + " >"
}

func (s *Stack) ReflHeader() string {
str := ""

switch s.Type {
case "user":
str += "S"
case "system":
str += "@"
default:
str += s.Type
}

str += strconv.Itoa(s.ID) + "#" + strconv.Itoa(s.Depth()) + "< "

return str
}

func (s *Stack) Kind() string {
Expand Down

0 comments on commit 660bf64

Please sign in to comment.