Mangle the name of `stmt` (typedef or grouping).

        Return the mangled name and dictionary where the definition is
        to be installed. The `inrpc` flag indicates when we are inside
        an RPC, in which case the name gets the "__rpc" suffix.
978875
def unique_def_name(self, stmt, inrpc=False):
        
        module = stmt.main_module()
        name = ""
        while True:
            pref = stmt.arg if stmt.arg else stmt.keyword
            name = "__" + pref + name
            if stmt.keyword == "grouping": name = "_" + name
            if stmt.parent.parent is None: break
            stmt = stmt.parent
        defs = (self.global_defs
                if stmt.keyword in ("grouping", "typedef")
                else self.local_defs)
        if inrpc: name += "__rpc"
        return (module.arg + name, defs)
1252426
public static final String GET_STG_NAME(STGroup stg){
		String ret = null;
		if(stg instanceof STGroupFile){
			ret = ((STGroupFile)stg).fileName;
		}
		else if(stg instanceof STGroupString){
			ret = ((STGroupString)stg).sourceName;
		}
		else if(stg instanceof STGroupDir){
			ret = ((STGroupDir)stg).groupDirName;
		}
		return StringUtils.substringBeforeLast(ret, ".");
	}
62668
def p_stmt_list(p):
    
    if len(p) == 2:
        p[0] = node.stmt_list([p[1]] if p[1] else [])
    elif len(p) == 3:
        p[0] = p[1]
        if p[2]:
            p[0].append(p[2])
    else:
        assert 0
59244
def search_grouping(stmt, name):
    """"""
    mod = stmt.i_orig_module
    while stmt is not None:
        if name in stmt.i_groupings:
            g = stmt.i_groupings[name]
            if (mod is not None and
                mod != g.i_orig_module and
                g.i_orig_module.keyword == 'submodule'):
                # make sure this submodule is included
                if mod.search_one('include', g.i_orig_module.arg) is None:
                    return None
            return g
        stmt = stmt.parent
    return None
472460
def iter_symbols(code):
    """"""
    for name in code.co_names:
        yield name
    for const in code.co_consts:
        if isinstance(const, six.string_types):
            yield const
        elif isinstance(const, CodeType):
            for name in iter_symbols(const):
                yield name
381530
def name_from_type(type_):
    # type: (InternalType) -> str
    
    if isinstance(type_, (DictType, ListType, TupleType, SetType, IteratorType)):
        return repr(type_)
    else:
        if type_.__name__ != 'NoneType':
            module = type_.__module__
            if module in BUILTIN_MODULES or module == '<unknown>':
                # Omit module prefix for known built-ins, for convenience. This
                # makes unit tests for this module simpler.
                # Also ignore '<uknown>' modules so pyannotate can parse these types
                return type_.__name__
            else:
                name = getattr(type_, '__qualname__', None) or type_.__name__
                delim = '.' if '.' not in name else ':'
                return '%s%s%s' % (module, delim, name)
        else:
            return 'None'
777282
def normalize_name(decl):
    
    if decl.cache.normalized_name is None:
        decl.cache.normalized_name = normalize(decl.name)
    return decl.cache.normalized_name
870625
def p_while_stmt(p):
    
    assert isinstance(p[4], node.stmt_list)
    p[0] = node.while_stmt(cond_expr=p[2], stmt_list=p[4])
247767
def rpc_get_names(self, filename, source, offset):
        """"""
        names = jedi.api.names(source=source,
                               path=filename, encoding='utf-8',
                               all_scopes=True,
                               definitions=True,
                               references=True)

        result = []
        for name in names:
            if name.module_path == filename:
                offset = linecol_to_pos(source, name.line, name.column)
            elif name.module_path is not None:
                with open(name.module_path) as f:
                    text = f.read()
                offset = linecol_to_pos(text, name.line, name.column)
            result.append({"name": name.name,
                           "filename": name.module_path,
                           "offset": offset})
        return result
232532
def _rpc_action_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
        """"""
        self._handle_child(RpcActionNode(), stmt, sctx)
511022
def _init_prtfmt(self, key="fmta"):
        """"""
        prtfmt = self.gosubdag.prt_attr[key]
        return prtfmt.replace("{NS}", "{NS} {hdr1usr01:2} {num_usrgos:>4} uGOs")
953840
def stmt_type(obj, mk=True):
    
    if isinstance(obj, Statement) and mk:
        return type(obj)
    else:
        return type(obj).__name__
1204937
def stripped_name(self):
        """"""

        name = self.name

        # Strip function parameters from name by recursively removing paired parenthesis
        while True:
            name, n = self._parenthesis_re.subn('', name)
            if not n:
                break

        # Strip const qualifier
        name = self._const_re.sub('', name)

        # Strip template parameters from name by recursively removing paired angles
        while True:
            name, n = self._angles_re.subn('', name)
            if not n:
                break

        return name
665785
def nvrtcGetLoweredName(self, prog, name_expression):
        
        lowered_name = c_char_p()
        code = self._lib.nvrtcGetLoweredName(prog,
                                             c_char_p(encode_str(name_expression)),
                                             byref(lowered_name))
        self._throw_on_error(code)
        return lowered_name.value.decode('utf-8')
666786
def rpc_get_name_at( self, name, block_height, **con_info ):
        
        if not check_name(name):
            return {'error': 'invalid name', 'http_status': 400}

        if not check_block(block_height):
            return self.success_response({'record': None})

        db = get_db_state(self.working_dir)
        names_at = db.get_name_at( name, block_height, include_expired=False )
        db.close()
        
        ret = []
        for name_rec in names_at:
            if 'opcode' not in name_rec:
                name_rec['opcode'] = op_get_opcode_name(name_rec['op'])
            
            ret.append(self.sanitize_rec(name_rec))

        return self.success_response( {'records': ret} )
1209133
def get_proc_name(cmd):
    
    if isinstance(cmd, Iterable) and not isinstance(cmd, str):
        cmd = " ".join(cmd)

    return cmd.split()[0].replace('(', '').replace(')', '')
834638
def rpc_get_names(self, filename, source, offset):
        
        source = get_source(source)
        if hasattr(self.backend, "rpc_get_names"):
            return self.backend.rpc_get_names(filename, source, offset)
        else:
            raise Fault("get_names not implemented by current backend",
                        code=400)