TODO: function return values determine expression types if in argument list
(block, args=None, tab='')
| 2062 | |
| 2063 | |
| 2064 | def postcrack(block, args=None, tab=''): |
| 2065 | """ |
| 2066 | TODO: |
| 2067 | function return values |
| 2068 | determine expression types if in argument list |
| 2069 | """ |
| 2070 | global usermodules, onlyfunctions |
| 2071 | |
| 2072 | if isinstance(block, list): |
| 2073 | gret = [] |
| 2074 | uret = [] |
| 2075 | for g in block: |
| 2076 | setmesstext(g) |
| 2077 | g = postcrack(g, tab=tab + '\t') |
| 2078 | # sort user routines to appear first |
| 2079 | if 'name' in g and '__user__' in g['name']: |
| 2080 | uret.append(g) |
| 2081 | else: |
| 2082 | gret.append(g) |
| 2083 | return uret + gret |
| 2084 | setmesstext(block) |
| 2085 | if not isinstance(block, dict) and 'block' not in block: |
| 2086 | raise Exception('postcrack: Expected block dictionary instead of ' + |
| 2087 | str(block)) |
| 2088 | if 'name' in block and not block['name'] == 'unknown_interface': |
| 2089 | outmess('%sBlock: %s\n' % (tab, block['name']), 0) |
| 2090 | block = analyzeargs(block) |
| 2091 | block = analyzecommon(block) |
| 2092 | block['vars'] = analyzevars(block) |
| 2093 | block['sortvars'] = sortvarnames(block['vars']) |
| 2094 | if 'args' in block and block['args']: |
| 2095 | args = block['args'] |
| 2096 | block['body'] = analyzebody(block, args, tab=tab) |
| 2097 | |
| 2098 | userisdefined = [] |
| 2099 | if 'use' in block: |
| 2100 | useblock = block['use'] |
| 2101 | for k in list(useblock.keys()): |
| 2102 | if '__user__' in k: |
| 2103 | userisdefined.append(k) |
| 2104 | else: |
| 2105 | useblock = {} |
| 2106 | name = '' |
| 2107 | if 'name' in block: |
| 2108 | name = block['name'] |
| 2109 | # and not userisdefined: # Build a __user__ module |
| 2110 | if 'externals' in block and block['externals']: |
| 2111 | interfaced = [] |
| 2112 | if 'interfaced' in block: |
| 2113 | interfaced = block['interfaced'] |
| 2114 | mvars = copy.copy(block['vars']) |
| 2115 | if name: |
| 2116 | mname = name + '__user__routines' |
| 2117 | else: |
| 2118 | mname = 'unknown__user__routines' |
| 2119 | if mname in userisdefined: |
| 2120 | i = 1 |
| 2121 | while '%s_%i' % (mname, i) in userisdefined: |
no test coverage detected