pushToStringStack checks for circular references and pushes an object onto the toString stack. Returns true if the object is already in the stack (circular reference detected), false otherwise. If false is returned, the caller must ensure the object is popped from the stack when done.
(o *Object)
| 166 | // Returns true if the object is already in the stack (circular reference detected), false otherwise. |
| 167 | // If false is returned, the caller must ensure the object is popped from the stack when done. |
| 168 | func (r *Runtime) pushToStringStack(o *Object) bool { |
| 169 | // Check for circular reference in the toString stack |
| 170 | for _, obj := range r.toStringStack { |
| 171 | if o == obj { |
| 172 | // Circular reference detected |
| 173 | return true |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // Push this object onto the stack |
| 178 | r.toStringStack = append(r.toStringStack, o) |
| 179 | return false |
| 180 | } |
| 181 | |
| 182 | // popFromStringStack removes an object from the toString stack. |
| 183 | func (r *Runtime) popFromStringStack() { |
no outgoing calls
no test coverage detected