trailofbits/manticore

Refactor/unify repetitive pattern

Open

#1,059 opened on Aug 16, 2018

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Python (481 forks)batch import
ethereumhelp wantedresearch

Repository metrics

Stars
 (3,469 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

This pattern comes up pretty regularly (in Solver.get_all_values, Solver.get_value, ConstraintSet.migrate), should we make a Expression.clone() ?

                if isinstance(foreign_var, Bool):
                    new_var = self.new_bool(name=migrated_name)
                elif isinstance(foreign_var, BitVec):
                    new_var = self.new_bitvec(foreign_var.size, name=migrated_name)
                elif isinstance(foreign_var, Array):
                    # Note that we are discarding the ArrayProxy encapsulation
                    new_var = self.new_array(index_max=foreign_var.index_max, index_bits=foreign_var.index_bits, value_bits=foreign_var.value_bits, name=migrated_name).array

Contributor guide