| 140 | } |
| 141 | |
| 142 | func findField(l *State, objectIndex, level int) bool { |
| 143 | if level == 0 || !l.IsTable(-1) { |
| 144 | return false |
| 145 | } |
| 146 | for l.PushNil(); l.Next(-2); l.Pop(1) { // for each pair in table |
| 147 | if l.IsString(-2) { // ignore non-string keys |
| 148 | if l.RawEqual(objectIndex, -1) { // found object? |
| 149 | l.Pop(1) // remove value (but keep name) |
| 150 | return true |
| 151 | } else if findField(l, objectIndex, level-1) { // try recursively |
| 152 | l.Remove(-2) // remove table (but keep name) |
| 153 | l.PushString(".") |
| 154 | l.Insert(-2) // place "." between the two names |
| 155 | l.Concat(3) |
| 156 | return true |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | return false |
| 161 | } |
| 162 | |
| 163 | func pushGlobalFunctionName(l *State, f Frame) bool { |
| 164 | top := l.Top() |