MCPcopy Index your code
hub / github.com/numpy/numpy / updatevars

Function updatevars

numpy/f2py/crackfortran.py:1658–1832  ·  view source on GitHub ↗

Returns last_name, the variable name without special chars, parenthesis or dimension specifiers. Alters groupcache to add the name, typespec, attrspec (and possibly value) of current variable.

(typespec, selector, attrspec, entitydecl)

Source from the content-addressed store, hash-verified

1656
1657
1658def updatevars(typespec, selector, attrspec, entitydecl):
1659 """
1660 Returns last_name, the variable name without special chars, parenthesis
1661 or dimension specifiers.
1662
1663 Alters groupcache to add the name, typespec, attrspec (and possibly value)
1664 of current variable.
1665 """
1666 global groupcache, groupcounter
1667
1668 last_name = None
1669 kindselect, charselect, typename = cracktypespec(typespec, selector)
1670 # Clean up outer commas, whitespace and undesired chars from attrspec
1671 if attrspec:
1672 attrspec = [x.strip() for x in markoutercomma(attrspec).split('@,@')]
1673 l = []
1674 c = re.compile(r'(?P<start>[a-zA-Z]+)')
1675 for a in attrspec:
1676 if not a:
1677 continue
1678 m = c.match(a)
1679 if m:
1680 s = m.group('start').lower()
1681 a = s + a[len(s):]
1682 l.append(a)
1683 attrspec = l
1684 el = [x.strip() for x in markoutercomma(entitydecl).split('@,@')]
1685 el1 = []
1686 for e in el:
1687 for e1 in [x.strip() for x in markoutercomma(removespaces(markinnerspaces(e)), comma=' ').split('@ @')]:
1688 if e1:
1689 el1.append(e1.replace('@_@', ' '))
1690 for e in el1:
1691 m = namepattern.match(e)
1692 if not m:
1693 outmess(
1694 f'updatevars: no name pattern found for entity={repr(e)}. Skipping.\n')
1695 continue
1696 ename = rmbadname1(m.group('name'))
1697 edecl = {}
1698 if ename in groupcache[groupcounter]['vars']:
1699 edecl = groupcache[groupcounter]['vars'][ename].copy()
1700 not_has_typespec = 'typespec' not in edecl
1701 if not_has_typespec:
1702 edecl['typespec'] = typespec
1703 elif typespec and (not typespec == edecl['typespec']):
1704 current_typespec = edecl['typespec']
1705 outmess(f'updatevars: attempt to change the type of "{ename}" '
1706 f'("{current_typespec}") to "{typespec}". Ignoring.\n')
1707 if 'kindselector' not in edecl:
1708 edecl['kindselector'] = copy.copy(kindselect)
1709 elif kindselect:
1710 for k in list(kindselect.keys()):
1711 if k in edecl['kindselector'] and (not kindselect[k] == edecl['kindselector'][k]):
1712 current_kind = edecl['kindselector'][k]
1713 outmess('updatevars: attempt to change the kindselector '
1714 f'"{k}" of "{ename}" ("{current_kind}") to '
1715 f'"{kindselect[k]}". Ignoring.\n')

Callers 1

analyzelineFunction · 0.85

Calls 15

cracktypespecFunction · 0.85
markoutercommaFunction · 0.85
removespacesFunction · 0.85
markinnerspacesFunction · 0.85
rmbadname1Function · 0.85
errmessFunction · 0.85
markouterparenFunction · 0.85
unmarkouterparenFunction · 0.85
stripMethod · 0.80
splitMethod · 0.80
lowerMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…