allVariables property

List<Variable<T>> allVariables

Retrieves every variable within this scope and its ancestors.

Variable names will not be repeated; this produces the effect of shadowed variables.

This list is unmodifiable.

Implementation

List<Variable<T>> get allVariables {
  var distinct = <String>[];
  var out = <Variable<T>>[];

  void crawl(SymbolTable<T> table) {
    for (var v in table._variables) {
      if (!distinct.contains(v.name)) {
        distinct.add(v.name);
        out.add(v);
      }
    }

    if (table._parent != null) crawl(table._parent!);
  }

  crawl(this);
  return List<Variable<T>>.unmodifiable(out);
}