def call(self, from_inst_num, func_args=None): setglobal('call_counter', call_counter + 1) res = {"objects": create_empty()} prev_state = _state for code in self.cfgs: call_stack.append((code, from_inst_num)) cfgobj = self._create_cfgobj(code, func_args) self.process_cfg(cfgobj) # print call_stack self.store_call_result(cfgobj, *call_stack.pop()) # res["types"] |= cfgobj.bbs['exit'].states.states['normal'].stack.vars[-1]["types"] got_res = cfgobj.bbs['exit'].states.states['normal'].stack.vars[-1] res["types"] |= got_res["types"] if "aliases" in got_res.keys(): res["aliases"] = got_res["aliases"] else: res["aliases"] = create_empty_alias(None, None) print cfgobj.bbs['exit'].states.states['normal'].stack _megastore.add_one(cfgobj) print cfgobj.prefix, cfgobj.bbs['exit'].states.states['normal'] self._set_state(prev_state) setglobal('call_counter', call_counter - 1) if self.is_generator: # new_res = VarTypes(init_from={TypeGeneratorObject.implemented_types[0]: None}) new_res = {"types": VarTypes(init_consts=[[]])} new_res["types"].types['TypeSuperList'].append(res) return new_res["types"].get_iter(None, TypeGeneratorObject) else: return res
def call(self, from_inst_num, func_args=None): setglobal('call_counter', call_counter+1) res = {"objects":create_empty()} prev_state = _state for code in self.cfgs: call_stack.append((code, from_inst_num)) cfgobj = self._create_cfgobj(code, func_args) self.process_cfg(cfgobj) # print call_stack self.store_call_result(cfgobj, *call_stack.pop()) # res["types"] |= cfgobj.bbs['exit'].states.states['normal'].stack.vars[-1]["types"] got_res = cfgobj.bbs['exit'].states.states['normal'].stack.vars[-1] res["types"] |= got_res["types"] if "aliases" in got_res.keys(): res["aliases"] = got_res["aliases"] else: res["aliases"] = create_empty_alias(None,None) print cfgobj.bbs['exit'].states.states['normal'].stack _megastore.add_one(cfgobj) print cfgobj.prefix, cfgobj.bbs['exit'].states.states['normal'] self._set_state(prev_state) setglobal('call_counter', call_counter-1) if self.is_generator: # new_res = VarTypes(init_from={TypeGeneratorObject.implemented_types[0]: None}) new_res = {"types":VarTypes(init_consts=[[]])} new_res["types"].types['TypeSuperList'].append(res) return new_res["types"].get_iter(None, TypeGeneratorObject) else: return res
def lge(self, *args, **kwargs): lc = getglobal('lge_counter') # checking for cyclic references if lc > 20: print "Warning: lge_counter reached %r - possibly got cyclic references" % lc return (0, 0, 1) else: setglobal('lge_counter', lc + 1) # print "======== lge_counter reached %r" % lc lres = self._lge_inner(*args, **kwargs) setglobal('lge_counter', lc) return lres
def __repr__(self): rc = getglobal('repr_counter') # checking for cyclic references if rc > 20: print "Warning: repr_counter reached %r - possibly got cyclic references" % rc return "..." elif id(self) in repr_list: if getglobal('dublicate_repr'): return self._show_dublicates() else: setglobal('dublicate_repr', True) # print "Info: got cyclic references for %r" % self.clsname res = "Dublicate{%s}" % self._show_dublicates() setglobal('dublicate_repr', False) return res else: setglobal('repr_counter', rc + 1) repr_list.append(id(self)) # print "======== repr_counter reached %r" % lc if getglobal('DEBUG_PRINT'): rres = self._repr_inner(*args, **kwargs) else: rres = self._pretty_inner(*args, **kwargs) repr_list.pop() setglobal('repr_counter', rc) return rres
def _set_state(state): setglobal('stack', state.stack) setglobal('smtbl', state.smtbl) setglobal('_aso', state._aso) setglobal('_state', state)