MCPcopy Create free account
hub / github.com/numpy/numpy / analyzevars

Function analyzevars

numpy/f2py/crackfortran.py:2606–2994  ·  view source on GitHub ↗

Sets correct dimension information for each variable/parameter

(block)

Source from the content-addressed store, hash-verified

2604
2605
2606def analyzevars(block):
2607 """
2608 Sets correct dimension information for each variable/parameter
2609 """
2610
2611 global f90modulevars
2612
2613 setmesstext(block)
2614 implicitrules, attrrules = buildimplicitrules(block)
2615 vars = copy.copy(block['vars'])
2616 if block['block'] == 'function' and block['name'] not in vars:
2617 vars[block['name']] = {}
2618 if '' in block['vars']:
2619 del vars['']
2620 if 'attrspec' in block['vars']['']:
2621 gen = block['vars']['']['attrspec']
2622 for n in set(vars) | set(b['name'] for b in block['body']):
2623 for k in ['public', 'private']:
2624 if k in gen:
2625 vars[n] = setattrspec(vars.get(n, {}), k)
2626 svars = []
2627 args = block['args']
2628 for a in args:
2629 try:
2630 vars[a]
2631 svars.append(a)
2632 except KeyError:
2633 pass
2634 for n in list(vars.keys()):
2635 if n not in args:
2636 svars.append(n)
2637
2638 params = get_parameters(vars, get_useparameters(block))
2639 # At this point, params are read and interpreted, but
2640 # the params used to define vars are not yet parsed
2641 dep_matches = {}
2642 name_match = re.compile(r'[A-Za-z][\w$]*').match
2643 for v in list(vars.keys()):
2644 m = name_match(v)
2645 if m:
2646 n = v[m.start():m.end()]
2647 try:
2648 dep_matches[n]
2649 except KeyError:
2650 dep_matches[n] = re.compile(r'.*\b%s\b' % (v), re.I).match
2651 for n in svars:
2652 if n[0] in list(attrrules.keys()):
2653 vars[n] = setattrspec(vars[n], attrrules[n[0]])
2654 if 'typespec' not in vars[n]:
2655 if not('attrspec' in vars[n] and 'external' in vars[n]['attrspec']):
2656 if implicitrules:
2657 ln0 = n[0].lower()
2658 for k in list(implicitrules[ln0].keys()):
2659 if k == 'typespec' and implicitrules[ln0][k] == 'undefined':
2660 continue
2661 if k not in vars[n]:
2662 vars[n][k] = implicitrules[ln0][k]
2663 elif k == 'attrspec':

Callers 1

postcrackFunction · 0.85

Calls 15

setmesstextFunction · 0.85
buildimplicitrulesFunction · 0.85
setattrspecFunction · 0.85
get_parametersFunction · 0.85
get_useparametersFunction · 0.85
markoutercommaFunction · 0.85
rmbadnameFunction · 0.85
param_parseFunction · 0.85
l_orFunction · 0.85
isarrayFunction · 0.85
compute_depsFunction · 0.85
isstringFunction · 0.85

Tested by

no test coverage detected