define method

bool define(
  1. String varName,
  2. T decl, {
  3. bool override = false,
  4. bool throws = true,
})

define a declaration in this namespace, the defined id could be different from declaration's id

Implementation

bool define(String varName, T decl,
    {bool override = false, bool throws = true}) {
  if (!symbols.containsKey(varName) || override) {
    symbols[varName] = decl;
    return true;
  } else {
    if (throws) {
      throw HTError.defined(varName, ErrorType.staticWarning);
    }
  }

  return false;
}