Mimicks `iris_obj.name()` but with different name resolution order.

    Similar to iris_obj.name() method, but using iris_obj.var_name first to
    enable roundtripping.
351952
def _name(iris_obj, default='unknown'):
    
    return (iris_obj.var_name or iris_obj.standard_name or
            iris_obj.long_name or default)
849120
public String getNameByReflection(Object obj)
    {
        Object name = null;
        try {
            java.lang.reflect.Method method = obj.getClass().getMethod("getName");
            
            if (method != null)
                name = method.invoke(obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (name == null)
            return null;
        else
            return name.toString();
    }
871715
private static GroupName nameFromObjectName(ObjectName obj_name, NamedResolverMap resolvedMap) {
        String name = obj_name.getKeyProperty("name");
        String type = obj_name.getKeyProperty("type");
        String domain = obj_name.getDomain();

        Map<String, MetricValue> tags = obj_name.getKeyPropertyList().entrySet().stream()
                .filter((entry) -> !entry.getKey().equals("name"))
                .filter((entry) -> !entry.getKey().equals("type"))
                .map(Tag::valueOf)
                .collect(Collectors.toMap((Tag t) -> t.getName(), (Tag t) -> t.getValue()));

        final List<String> path = new ArrayList<>();
        if (name != null) {
            path.addAll(Arrays.asList(name.split("\\.")));
        } else if (type != null) {
            path.addAll(Arrays.asList(domain.split("\\.")));
            path.add(type);
        } else {
            path.addAll(Arrays.asList(domain.split("\\.")));
        }
        return resolvedMap.getGroupName(path, tags);
    }
318807
def _resolve_name(self, name):
        
        res = [name]
        while True:
            orig_names = self._search("types", name)
            if orig_names is not None:
                name = orig_names[-1]
                # pop off the typedefd name
                res.pop()
                # add back on the original names
                res += orig_names
            else:
                break

        return res
640049
function markDuplicateVariableNames (row, i, rows) {
  var ast = row[kAst]

  var scope = scan.scope(ast)
  if (scope) {
    scope.forEach(function (binding, name) {
      binding[kShouldRename] = rows.usedGlobalVariables.has(name)
      rows.usedGlobalVariables.add(name)
    })
  }
}
1372190
function toBindingIdentifierName(name) {
  name = toIdentifier(name);
  if (name === "eval" || name === "arguments") name = "_" + name;
  return name;
}
1312006
def _pv_name_attribute(opts, key, is_name_attribute=true)
        if is_name_attribute
          if opts[key] == nil
            opts[key] = self.instance_variable_get("@name")
          end
        end
      end
944434
async def _roundtrip(cls):
        """"""
        getters = {
            name[4:]: getattr(cls, name) for name in dir(cls)
            if name.startswith("get_") and name != "get_config"
        }
        setters = {
            name[4:]: getattr(cls, name) for name in dir(cls)
            if name.startswith("set_") and name != "set_config"
        }

        for name, getter in getters.items():
            print(">>>", name)
            value = await getter()
            print(" ->", repr(value))
            print("   ", type(value))
            setter = setters[name]
            try:
                await setter(value)
            except CallError as error:
                print(error)
                print(error.content.decode("utf-8", "replace"))
            else:
                value2 = await getter()
                if value2 != value:
                    print(
                        "!!! Round-trip failed:", repr(value),
                        "-->", repr(value2))
138480
def get_local_variable_from_name(self, variable_name):
        
        return next((v for v in self.variables if v.name == variable_name), None)
1364167
function getUiViewName(attrs, inherited) {
        var name = attrs.uiView || attrs.name || '';
        return name.indexOf('@') >= 0 ? name : (name + '@' + (inherited ? inherited.state.name : ''));
    }
35596
def varnames(self):
        
        # We must sort to preserve the order between calls.
        # The set comprehension is to drop the duplicates.
        return self._argnames + tuple(sorted({
            instr.arg
            for instr in self.instrs
            if instr.uses_varname and instr.arg not in self._argnames
        }))
882531
def setName(self, name):
        
        self._name = name
        
        tree = self.treeWidget()
        if tree:
            col = tree.column('Name')
            if col != -1:
                self.setData(col, Qt.EditRole, wrapVariant(name))
609052
def unique_name(self, name, mark_as_used=True):
    
    scope_name = tf.get_variable_scope().name
    if scope_name:
      name = scope_name + "/" + name

    # As in TensorFlow, treat names as case insensitive when deciding whether
    # they are in use.
    name_key = name.lower()
    i = self._names_in_use.get(name_key, 0)
    if mark_as_used:
      self._names_in_use[name_key] = i + 1
    if i > 0:
      base_name_key = name_key
      while name_key in self._names_in_use:
        name_key = "%s_%d" % (base_name_key, i)
        i += 1
      if mark_as_used:
        self._names_in_use[name_key] = 1
      name = "%s_%d" % (name, i-1)

    return name
1174290
def _assign_name(self, obj, name, shaders):
        
        if self._is_global(obj):
            assert name not in self._global_ns
            self._global_ns[name] = obj
        else:
            for shader in shaders:
                ns = self._shader_ns[shader]
                assert name not in ns
                ns[name] = obj
        self._object_names[obj] = name
692022
def assign_variable_names(self):
        

        for var in self._variables:
            if isinstance(var, SimStackVariable):
                if var.name is not None:
                    continue
                if var.ident.startswith('iarg'):
                    var.name = 'arg_%x' % var.offset
                else:
                    var.name = 's_%x' % (-var.offset)
                    # var.name = var.ident
            elif isinstance(var, SimRegisterVariable):
                if var.name is not None:
                    continue
                var.name = var.ident
1145227
def get_var_shape(self, name):
        
        rank = self.get_var_rank(name)
        name = create_string_buffer(name)
        arraytype = ndpointer(dtype='int32',
                              ndim=1,
                              shape=(MAXDIMS, ),
                              flags='F')
        shape = np.empty((MAXDIMS, ), dtype='int32', order='F')
        self.library.get_var_shape.argtypes = [c_char_p, arraytype]
        self.library.get_var_shape(name, shape)
        return tuple(shape[:rank])
415652
def resolve_name(name):
    

    parts = name.split('.')
    cursor = len(parts) - 1
    module_name = parts[:cursor]
    attr_name = parts[-1]

    while cursor > 0:
        try:
            ret = __import__('.'.join(module_name), fromlist=[attr_name])
            break
        except ImportError:
            if cursor == 0:
                raise
            cursor -= 1
            module_name = parts[:cursor]
            attr_name = parts[cursor]
            ret = ''

    for part in parts[cursor:]:
        try:
            ret = getattr(ret, part)
        except AttributeError:
            raise ImportError(name)

    return ret