ListVariables returns a map with the names of all variables. The attached slice represents field names for records. All names are lowercased.
()
| 156 | // ListVariables returns a map with the names of all variables. The attached slice represents field names for records. |
| 157 | // All names are lowercased. |
| 158 | func (is *InterpreterStack) ListVariables() map[string][]string { |
| 159 | seen := make(map[string][]string) |
| 160 | for i := 0; i < is.stack.Len(); i++ { |
| 161 | for varName, iv := range is.stack.PeekDepth(i).variables { |
| 162 | var fieldNames []string |
| 163 | if len(iv.Record) > 0 { |
| 164 | for _, col := range iv.Record { |
| 165 | fieldNames = append(fieldNames, strings.ToLower(col.Name)) |
| 166 | } |
| 167 | } |
| 168 | seen[strings.ToLower(varName)] = fieldNames |
| 169 | } |
| 170 | } |
| 171 | return seen |
| 172 | } |
| 173 | |
| 174 | // NewRecord creates a new record in the current scope. If a record with the same name exists in a previous scope, then |
| 175 | // that record will be shadowed until the current scope exits. |
no test coverage detected