Sets correct dimension information for each variable/parameter
(block)
| 2570 | |
| 2571 | |
| 2572 | def analyzevars(block): |
| 2573 | """ |
| 2574 | Sets correct dimension information for each variable/parameter |
| 2575 | """ |
| 2576 | |
| 2577 | global f90modulevars |
| 2578 | |
| 2579 | setmesstext(block) |
| 2580 | implicitrules, attrrules = buildimplicitrules(block) |
| 2581 | vars = copy.copy(block['vars']) |
| 2582 | if block['block'] == 'function' and block['name'] not in vars: |
| 2583 | vars[block['name']] = {} |
| 2584 | if '' in block['vars']: |
| 2585 | del vars[''] |
| 2586 | if 'attrspec' in block['vars']['']: |
| 2587 | gen = block['vars']['']['attrspec'] |
| 2588 | for n in set(vars) | {b['name'] for b in block['body']}: |
| 2589 | for k in ['public', 'private']: |
| 2590 | if k in gen: |
| 2591 | vars[n] = setattrspec(vars.get(n, {}), k) |
| 2592 | svars = [] |
| 2593 | args = block['args'] |
| 2594 | for a in args: |
| 2595 | try: |
| 2596 | vars[a] |
| 2597 | svars.append(a) |
| 2598 | except KeyError: |
| 2599 | pass |
| 2600 | for n in list(vars.keys()): |
| 2601 | if n not in args: |
| 2602 | svars.append(n) |
| 2603 | |
| 2604 | params = get_parameters(vars, get_useparameters(block)) |
| 2605 | # At this point, params are read and interpreted, but |
| 2606 | # the params used to define vars are not yet parsed |
| 2607 | dep_matches = {} |
| 2608 | name_match = re.compile(r'[A-Za-z][\w$]*').match |
| 2609 | for v in list(vars.keys()): |
| 2610 | m = name_match(v) |
| 2611 | if m: |
| 2612 | n = v[m.start():m.end()] |
| 2613 | try: |
| 2614 | dep_matches[n] |
| 2615 | except KeyError: |
| 2616 | dep_matches[n] = re.compile(rf'.*\b{v}\b', re.I).match |
| 2617 | for n in svars: |
| 2618 | if n[0] in list(attrrules.keys()): |
| 2619 | vars[n] = setattrspec(vars[n], attrrules[n[0]]) |
| 2620 | if 'typespec' not in vars[n]: |
| 2621 | if not ('attrspec' in vars[n] and 'external' in vars[n]['attrspec']): |
| 2622 | if implicitrules: |
| 2623 | ln0 = n[0].lower() |
| 2624 | for k in list(implicitrules[ln0].keys()): |
| 2625 | if k == 'typespec' and implicitrules[ln0][k] == 'undefined': |
| 2626 | continue |
| 2627 | if k not in vars[n]: |
| 2628 | vars[n][k] = implicitrules[ln0][k] |
| 2629 | elif k == 'attrspec': |
no test coverage detected
searching dependent graphs…