_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q26400
schunk
train
def schunk(string, size): """Splits string into n sized chunks."""
python
{ "resource": "" }
q26401
mill
train
def mill(it, label='', hide=None, expected_size=None, every=1): """Progress iterator. Prints a mill while iterating over the items.""" def _mill_char(_i): if _i >= count: return ' ' else: return MILL_CHARS[(_i // every) % len(MILL_CHARS)] def _show(_i): if n...
python
{ "resource": "" }
q26402
min_width
train
def min_width(string, cols, padding=' '): """Returns given string with right padding.""" is_color = isinstance(string, ColoredString) stack = tsplit(str(string), NEWLINES)
python
{ "resource": "" }
q26403
join
train
def join(l, conj=CONJUNCTION, im_a_moron=MORON_MODE, separator=COMMA): """Joins lists of words. Oxford comma and all.""" collector = [] left = len(l) separator = separator + SPACE conj = conj + SPACE for _l in l[:]: left += -1 collector.append(_l) if left == 1: ...
python
{ "resource": "" }
q26404
site_data_dir
train
def site_data_dir(appname, appauthor=None, version=None): """Return full path to the user-shared data dir for this application. "appname" is the name of application. "appauthor" (only required and used on Windows) is the name of the appauthor or distributing body for this application. T...
python
{ "resource": "" }
q26405
user_log_dir
train
def user_log_dir(appname, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. "appauthor" (only required and used on Windows) is the name of the appauthor or distributing body for this...
python
{ "resource": "" }
q26406
APIETAGProcessor.get_etags_and_matchers
train
def get_etags_and_matchers(self, request): """Get the etags from the header and perform a validation against the required preconditions.""" # evaluate the preconditions, raises 428 if condition is not met self.evaluate_preconditions(request)
python
{ "resource": "" }
q26407
APIETAGProcessor.evaluate_preconditions
train
def evaluate_preconditions(self, request): """Evaluate whether the precondition for the request is met.""" if request.method.upper() in self.precondition_map.keys(): required_headers = self.precondition_map.get(request.method.upper(), []) # check the required headers ...
python
{ "resource": "" }
q26408
_slugify
train
def _slugify(text, delim=u'-'): """Generates an ASCII-only slug.""" result = [] for word in _punct_re.split(text.lower()): word = word.encode('utf-8')
python
{ "resource": "" }
q26409
Markdown.convert
train
def convert(self, text): """Convert the given text.""" # Main function. The order in which other subs are called here is # essential. Link and image substitutions need to happen before # _EscapeSpecialChars(), so that any *'s or _'s in the <a> # and <img> tags get encoded. ...
python
{ "resource": "" }
q26410
Markdown._hash_html_blocks
train
def _hash_html_blocks(self, text, raw=False): """Hashify HTML blocks We only want to do this for block-level HTML tags, such as headers, lists, and tables. That's because we still want to wrap <p>s around "paragraphs" that are wrapped in non-block-level tags, such as anchors, ph...
python
{ "resource": "" }
q26411
Markdown.header_id_from_text
train
def header_id_from_text(self, text, prefix, n): """Generate a header id attribute value from the given header HTML content. This is only called if the "header-ids" extra is enabled. Subclasses may override this for different header ids. @param text {str} The text of the header ...
python
{ "resource": "" }
q26412
UnicodeWithAttrs.toc_html
train
def toc_html(self): """Return the HTML for the current TOC. This expects the `_toc` attribute to have been set on this instance. """ if self._toc is None: return None def indent(): return ' ' * (len(h_stack) - 1) lines = [] h_stack = [0]...
python
{ "resource": "" }
q26413
Command.handle
train
def handle(self, *args, **options): """ Queues the function given with the first argument with the parameters given with the rest of the argument list. """
python
{ "resource": "" }
q26414
get_worker
train
def get_worker(*queue_names, **kwargs): """ Returns a RQ worker for all queues or specified ones. """ job_class = get_job_class(kwargs.pop('job_class', None)) queue_class = kwargs.pop('queue_class', None) queues = get_queues(*queue_names, **{'job_class': job_class, ...
python
{ "resource": "" }
q26415
commit
train
def commit(*args, **kwargs): """ Processes all jobs in the delayed queue. """ delayed_queue = get_queue()
python
{ "resource": "" }
q26416
get_queue_class
train
def get_queue_class(config=None, queue_class=None): """ Return queue class from config or from RQ settings, otherwise return DjangoRQ. If ``queue_class`` is provided, it takes priority. The full priority list for queue class sources: 1. ``queue_class`` argument 2. ``QUEUE_CLASS`` in ``config`` ...
python
{ "resource": "" }
q26417
get_redis_connection
train
def get_redis_connection(config, use_strict_redis=False): """ Returns a redis connection from a connection config """ redis_cls = redis.StrictRedis if use_strict_redis else redis.Redis if 'URL' in config: return redis_cls.from_url(config['URL'], db=config.get('DB')) if 'USE_REDIS_CACHE...
python
{ "resource": "" }
q26418
get_connection
train
def get_connection(name='default', use_strict_redis=False): """ Returns a Redis connection to use
python
{ "resource": "" }
q26419
get_queue
train
def get_queue(name='default', default_timeout=None, is_async=None, autocommit=None, connection=None, queue_class=None, job_class=None, **kwargs): """ Returns an rq Queue using parameters defined in ``RQ_QUEUES`` """ from .settings import QUEUES if kwargs.get('async') is not None: ...
python
{ "resource": "" }
q26420
get_queue_by_index
train
def get_queue_by_index(index): """ Returns an rq Queue using parameters defined in ``QUEUES_LIST`` """ from .settings import QUEUES_LIST config = QUEUES_LIST[int(index)] return get_queue_class(config)(
python
{ "resource": "" }
q26421
filter_connection_params
train
def filter_connection_params(queue_params): """ Filters the queue params to keep only the connection related params. """ CONNECTION_PARAMS = ('URL', 'DB', 'USE_REDIS_CACHE', 'UNIX_SOCKET_PATH', 'HOST', 'PORT', 'PASSWORD',
python
{ "resource": "" }
q26422
get_queues
train
def get_queues(*queue_names, **kwargs): """ Return queue instances from specified queue names. All instances must use the same Redis connection. """ from .settings import QUEUES if len(queue_names) <= 1: # Return "default" queue if no queue name is specified # or one queue with ...
python
{ "resource": "" }
q26423
get_unique_connection_configs
train
def get_unique_connection_configs(config=None): """ Returns a list of unique Redis connections from config """ if config is None: from .settings import QUEUES config = QUEUES connection_configs = [] for key, value in config.items():
python
{ "resource": "" }
q26424
enqueue_job
train
def enqueue_job(request, queue_index, job_id): """ Enqueue deferred jobs """ queue_index = int(queue_index) queue = get_queue_by_index(queue_index) job = Job.fetch(job_id, connection=queue.connection) if request.method == 'POST': queue.enqueue_job(job) # Remove job from correct...
python
{ "resource": "" }
q26425
job
train
def job(func_or_queue, connection=None, *args, **kwargs): """ The same as RQ's job decorator, but it automatically works out the ``connection`` argument from RQ_QUEUES. And also, it allows simplified ``@job`` syntax to put job into default queue. If RQ.DEFAULT_RESULT_TTL setting is set, it is ...
python
{ "resource": "" }
q26426
to_localtime
train
def to_localtime(time): '''Converts naive datetime to localtime based on settings''' utc_time = time.replace(tzinfo=timezone.utc)
python
{ "resource": "" }
q26427
SSD1306Base.command
train
def command(self, c): """Send command byte to display.""" if self._spi is not None: # SPI write. self._gpio.set_low(self._dc) self._spi.write([c]) else:
python
{ "resource": "" }
q26428
SSD1306Base.data
train
def data(self, c): """Send byte of data to display.""" if self._spi is not None: # SPI write. self._gpio.set_high(self._dc) self._spi.write([c]) else:
python
{ "resource": "" }
q26429
SSD1306Base.begin
train
def begin(self, vccstate=SSD1306_SWITCHCAPVCC): """Initialize display.""" # Save vcc state. self._vccstate = vccstate
python
{ "resource": "" }
q26430
SSD1306Base.set_contrast
train
def set_contrast(self, contrast): """Sets the contrast of the display. Contrast should be a value between 0 and 255."""
python
{ "resource": "" }
q26431
SSD1306Base.dim
train
def dim(self, dim): """Adjusts contrast to dim the display if dim is True, otherwise sets the contrast to normal brightness if dim is False. """ # Assume dim display. contrast = 0 # Adjust contrast based on VCC if not dimming.
python
{ "resource": "" }
q26432
MySQLQueryBuilder._select_sql
train
def _select_sql(self, **kwargs): """ Overridden function to generate the SELECT part of the SQL statement, with the addition of the a modifier if present. """ return 'SELECT {distinct}{modifier}{select}'.format( distinct='DISTINCT ' if self._distinct else '', ...
python
{ "resource": "" }
q26433
QueryBuilder.from_
train
def from_(self, selectable): """ Adds a table to the query. This function can only be called once and will raise an AttributeError if called a second time. :param selectable: Type: ``Table``, ``Query``, or ``str`` When a ``str`` is passed, a table with the name...
python
{ "resource": "" }
q26434
QueryBuilder._validate_table
train
def _validate_table(self, term): """ Returns False if the term references a table not already part of the FROM clause or JOINS and True otherwise. """ base_tables = self._from + [self._update_table] for field in term.fields(): table_in_base_tables = field.tab...
python
{ "resource": "" }
q26435
QueryBuilder._group_sql
train
def _group_sql(self, quote_char=None, groupby_alias=True, **kwargs): """ Produces the GROUP BY part of the query. This is a list of fields. The clauses are stored in the query under self._groupbys as a list fields. If an groupby field is used in the select clause, determined by...
python
{ "resource": "" }
q26436
Joiner.cross
train
def cross(self): """Return cross join"""
python
{ "resource": "" }
q26437
builder
train
def builder(func): """ Decorator for wrapper "builder" functions. These are functions on the Query class or other classes used for building queries which mutate the query and return self. To make the build functions immutable, this decorator is used which will deepcopy the current instance. This deco...
python
{ "resource": "" }
q26438
resolve_is_aggregate
train
def resolve_is_aggregate(values): """ Resolves the is_aggregate flag for an expression that contains multiple terms. This works like a voter system, each term votes True or False or abstains with None. :param values: A list of booleans (or None) for each term in the expression :return: If all valu...
python
{ "resource": "" }
q26439
Term.wrap_constant
train
def wrap_constant(self, val): """ Used for wrapping raw inputs such as numbers in Criterions and Operator. For example, the expression F('abc')+1 stores the integer part in a ValueWrapper object. :param val: Any value. :return: Raw string, number, or dec...
python
{ "resource": "" }
q26440
Function.for_
train
def for_(self, table): """ Replaces the tables of this term for the table parameter provided. Useful when reusing fields across queries. :param table: The table to replace with.
python
{ "resource": "" }
q26441
LevelDBReader._get_head_state
train
def _get_head_state(self): """Get head state. :return: """ if not self.head_state: root = self._get_head_block().state_root
python
{ "resource": "" }
q26442
LevelDBReader._get_account
train
def _get_account(self, address): """Get account by address. :param address: :return: """ state = self._get_head_state()
python
{ "resource": "" }
q26443
LevelDBReader._get_block_hash
train
def _get_block_hash(self, number): """Get block hash by block number. :param number:
python
{ "resource": "" }
q26444
LevelDBReader._get_head_block
train
def _get_head_block(self): """Get head block header. :return: """ if not self.head_block_header: block_hash = self.db.get(head_header_key) num = self._get_block_number(block_hash) self.head_block_header = self._get_block_header(block_hash, num) ...
python
{ "resource": "" }
q26445
LevelDBReader._get_block_number
train
def _get_block_number(self, block_hash): """Get block number by its hash. :param block_hash: :return:
python
{ "resource": "" }
q26446
LevelDBReader._get_block_header
train
def _get_block_header(self, block_hash, num): """Get block header by block header hash & number. :param block_hash: :param num: :return: """ header_key = header_prefix + num + block_hash
python
{ "resource": "" }
q26447
LevelDBReader._get_address_by_hash
train
def _get_address_by_hash(self, block_hash): """Get mapped address by its hash.
python
{ "resource": "" }
q26448
EthLevelDB.get_contracts
train
def get_contracts(self): """Iterate through all contracts.""" for account in self.reader._get_head_state().get_all_accounts(): if account.code is not None: code = _encode_hex(account.code)
python
{ "resource": "" }
q26449
EthLevelDB.search
train
def search(self, expression, callback_func): """Search through all contract accounts. :param expression: :param callback_func: """ cnt = 0 indexer = AccountIndexer(self) for contract, address_hash, balance in self.get_contracts(): if contract.matche...
python
{ "resource": "" }
q26450
EthLevelDB.contract_hash_to_address
train
def contract_hash_to_address(self, contract_hash): """Try to find corresponding account address. :param contract_hash: :return: """
python
{ "resource": "" }
q26451
EthLevelDB.eth_getBlockHeaderByNumber
train
def eth_getBlockHeaderByNumber(self, number): """Get block header by block number. :param number: :return: """ block_hash
python
{ "resource": "" }
q26452
EthLevelDB.eth_getBlockByNumber
train
def eth_getBlockByNumber(self, number): """Get block body by block number. :param number: :return: """ block_hash = self.reader._get_block_hash(number) block_number = _format_block_number(number)
python
{ "resource": "" }
q26453
EthLevelDB.eth_getCode
train
def eth_getCode(self, address): """Get account code. :param address: :return: """
python
{ "resource": "" }
q26454
EthLevelDB.eth_getBalance
train
def eth_getBalance(self, address): """Get account balance. :param address: :return:
python
{ "resource": "" }
q26455
EthLevelDB.eth_getStorageAt
train
def eth_getStorageAt(self, address, position): """Get account storage data at position. :param address: :param position: :return: """ account = self.reader._get_account(address)
python
{ "resource": "" }
q26456
native_contracts
train
def native_contracts(address: int, data: BaseCalldata) -> List[int]: """Takes integer address 1, 2, 3, 4. :param address: :param data: :return: """ functions = (ecrecover, sha256, ripemd160, identity) if isinstance(data, ConcreteCalldata):
python
{ "resource": "" }
q26457
get_call_parameters
train
def get_call_parameters( global_state: GlobalState, dynamic_loader: DynLoader, with_value=False ): """Gets call parameters from global state Pops the values from the stack and determines output parameters. :param global_state: state to look in :param dynamic_loader: dynamic loader to use :param...
python
{ "resource": "" }
q26458
get_callee_address
train
def get_callee_address( global_state: GlobalState, dynamic_loader: DynLoader, symbolic_to_address: Expression, ): """Gets the address of the callee. :param global_state: state to look in :param dynamic_loader: dynamic loader to use :param symbolic_to_address: The (symbolic) callee address ...
python
{ "resource": "" }
q26459
get_callee_account
train
def get_callee_account( global_state: GlobalState, callee_address: str, dynamic_loader: DynLoader ): """Gets the callees account from the global_state. :param global_state: state to look in :param callee_address: address of the callee :param dynamic_loader: dynamic loader to use :return: Accoun...
python
{ "resource": "" }
q26460
get_call_data
train
def get_call_data( global_state: GlobalState, memory_start: Union[int, BitVec], memory_size: Union[int, BitVec], ): """Gets call_data from the global_state. :param global_state: state to look in :param memory_start: Start index :param memory_size: Size :return: Tuple containing: call_da...
python
{ "resource": "" }
q26461
InstructionCoveragePlugin.initialize
train
def initialize(self, symbolic_vm: LaserEVM): """Initializes the instruction coverage plugin Introduces hooks for each instruction :param symbolic_vm: :return: """ self.coverage = {} self.initial_coverage = 0 self.tx_id = 0 @symbolic_vm.laser_hook...
python
{ "resource": "" }
q26462
execute_message_call
train
def execute_message_call(laser_evm, callee_address: str) -> None: """Executes a message call transaction from all open states. :param laser_evm: :param callee_address: """ # TODO: Resolve circular import between .transaction and ..svm to import LaserEVM here open_states = laser_evm.open_states[...
python
{ "resource": "" }
q26463
execute_contract_creation
train
def execute_contract_creation( laser_evm, contract_initialization_code, contract_name=None ) -> Account: """Executes a contract creation transaction from all open states. :param laser_evm: :param contract_initialization_code: :param contract_name: :return: """ # TODO: Resolve circular i...
python
{ "resource": "" }
q26464
_setup_global_state_for_execution
train
def _setup_global_state_for_execution(laser_evm, transaction) -> None: """Sets up global state and cfg for a transactions execution. :param laser_evm: :param transaction: """ # TODO: Resolve circular import between .transaction and ..svm to import LaserEVM here global_state = transaction.initia...
python
{ "resource": "" }
q26465
Mythril._init_config
train
def _init_config(self): """If no config file exists, create it and add default options. Default LevelDB path is specified based on OS dynamic loading is set to infura by default in the file Returns: leveldb directory """ system = platform.system().lower() leveld...
python
{ "resource": "" }
q26466
Mythril._init_solc_binary
train
def _init_solc_binary(version): """Figure out solc binary and version. Only proper versions are supported. No nightlies, commits etc (such as available in remix). """ if not version: return os.environ.get("SOLC") or "solc" # tried converting input to semver, seemed...
python
{ "resource": "" }
q26467
And
train
def And(*args: Union[Bool, bool]) -> Bool: """Create an And expression.""" union = [] args_list = [arg if isinstance(arg, Bool) else Bool(arg) for arg in args] for arg in args_list:
python
{ "resource": "" }
q26468
Or
train
def Or(a: Bool, b: Bool) -> Bool: """Create an or expression. :param a: :param b: :return: """ union = a.annotations
python
{ "resource": "" }
q26469
Not
train
def Not(a: Bool) -> Bool: """Create a Not expression. :param a: :return: """
python
{ "resource": "" }
q26470
Bool.value
train
def value(self) -> Union[bool, None]: """Returns the concrete value of this bool if concrete, otherwise None. :return: Concrete value or None """ self.simplify() if self.is_true:
python
{ "resource": "" }
q26471
synchronized
train
def synchronized(sync_lock): """A decorator synchronizing multi-process access to a resource.""" def wrapper(f): """The decorator's core function. :param f: :return: """ @functools.wraps(f) def inner_wrapper(*args, **kw): """ :param arg...
python
{ "resource": "" }
q26472
SignatureDB._normalize_byte_sig
train
def _normalize_byte_sig(byte_sig: str) -> str: """Adds a leading 0x to the byte signature if it's not already there. :param byte_sig: 4-byte signature string :return: normalized byte signature string """ if not byte_sig.startswith("0x"): byte_sig
python
{ "resource": "" }
q26473
SignatureDB.import_solidity_file
train
def import_solidity_file( self, file_path: str, solc_binary: str = "solc", solc_args: str = None ): """Import Function Signatures from solidity source files. :param solc_binary: :param solc_args: :param file_path: solidity source code file path :return: """ ...
python
{ "resource": "" }
q26474
SignatureDB.lookup_online
train
def lookup_online(byte_sig: str, timeout: int, proxies=None) -> List[str]: """Lookup function signatures from 4byte.directory. :param byte_sig: function signature hash as hexstr :param timeout: optional timeout for online lookup :param proxies: optional proxy servers for online lookup ...
python
{ "resource": "" }
q26475
IntegerOverflowUnderflowModule.execute
train
def execute(self, state: GlobalState): """Executes analysis module for integer underflow and integer overflow. :param state: Statespace to analyse :return: Found issues """ address = _get_address_from_state(state) has_overflow = self._overflow_cache.get(address, False) ...
python
{ "resource": "" }
q26476
get_transaction_sequence
train
def get_transaction_sequence(global_state, constraints): """Generate concrete transaction sequence. :param global_state: GlobalState to generate transaction sequence for :param constraints: list of constraints used to generate transaction sequence """ transaction_sequence = global_state.world_stat...
python
{ "resource": "" }
q26477
main
train
def main() -> None: """The main CLI interface entry point.""" parser = argparse.ArgumentParser( description="Security analysis of Ethereum smart contracts" ) create_parser(parser)
python
{ "resource": "" }
q26478
AccountIndexer.get_contract_by_hash
train
def get_contract_by_hash(self, contract_hash): """get mapped contract_address by its hash, if not found try indexing.""" contract_address = self.db.reader._get_address_by_hash(contract_hash) if
python
{ "resource": "" }
q26479
AccountIndexer._process
train
def _process(self, startblock): """Processesing method.""" log.debug("Processing blocks %d to %d" % (startblock, startblock + BATCH_SIZE)) addresses = [] for blockNum in range(startblock, startblock + BATCH_SIZE): block_hash = self.db.reader._get_block_hash(blockNum) ...
python
{ "resource": "" }
q26480
AccountIndexer.updateIfNeeded
train
def updateIfNeeded(self): """update address index.""" headBlock = self.db.reader._get_head_block() if headBlock is not None: # avoid restarting search if head block is same & we already initialized # this is required for fastSync handling if self.lastBlock is ...
python
{ "resource": "" }
q26481
instruction_list_to_easm
train
def instruction_list_to_easm(instruction_list: list) -> str: """Convert a list of instructions into an easm op code string. :param instruction_list: :return: """ result = "" for instruction in instruction_list:
python
{ "resource": "" }
q26482
get_opcode_from_name
train
def get_opcode_from_name(operation_name: str) -> int: """Get an op code based on its name. :param operation_name: :return: """ for op_code, value in
python
{ "resource": "" }
q26483
find_op_code_sequence
train
def find_op_code_sequence(pattern: list, instruction_list: list) -> Generator: """Returns all indices in instruction_list that point to instruction sequences following a pattern. :param pattern: The pattern to look for, e.g. [["PUSH1", "PUSH2"], ["EQ"]] where ["PUSH1", "EQ"] satisfies pattern :param in...
python
{ "resource": "" }
q26484
is_sequence_match
train
def is_sequence_match(pattern: list, instruction_list: list, index: int) -> bool: """Checks if the instructions starting at index follow a pattern. :param pattern: List of lists describing a pattern, e.g. [["PUSH1", "PUSH2"], ["EQ"]] where ["PUSH1", "EQ"] satisfies pattern :param instruction_list: List of ...
python
{ "resource": "" }
q26485
disassemble
train
def disassemble(bytecode: bytes) -> list: """Disassembles evm bytecode and returns a list of instructions. :param bytecode: :return: """ instruction_list = [] address = 0 length = len(bytecode) if "bzzr" in str(bytecode[-43:]): # ignore swarm hash length -= 43 while...
python
{ "resource": "" }
q26486
stat_smt_query
train
def stat_smt_query(func: Callable): """Measures statistics for annotated smt query check function""" stat_store = SolverStatistics() def function_wrapper(*args, **kwargs): if not stat_store.enabled: return func(*args, **kwargs) stat_store.query_count += 1
python
{ "resource": "" }
q26487
WorldState.create_account
train
def create_account( self, balance=0, address=None, concrete_storage=False, dynamic_loader=None, creator=None, ) -> Account: """Create non-contract account. :param address: The account's address :param balance: Initial balance for the account ...
python
{ "resource": "" }
q26488
WorldState.create_initialized_contract_account
train
def create_initialized_contract_account(self, contract_code, storage) -> None: """Creates a new contract account, based on the contract code and storage provided The contract code only includes the runtime contract bytecode. :param contract_code: Runtime bytecode for the contract ...
python
{ "resource": "" }
q26489
WorldState._generate_new_address
train
def _generate_new_address(self, creator=None) -> str: """Generates a new address for the global state. :return: """ if creator: # TODO: Use nounce return "0x" + str(mk_contract_address(creator, 0).hex()) while True:
python
{ "resource": "" }
q26490
PluginFactory.build_benchmark_plugin
train
def build_benchmark_plugin(name: str) -> LaserPlugin: """ Creates an instance of the benchmark plugin with the given name """
python
{ "resource": "" }
q26491
PluginFactory.build_mutation_pruner_plugin
train
def build_mutation_pruner_plugin() -> LaserPlugin: """ Creates an instance of the mutation pruner plugin""" from
python
{ "resource": "" }
q26492
PluginFactory.build_instruction_coverage_plugin
train
def build_instruction_coverage_plugin() -> LaserPlugin: """ Creates an instance of the instruction coverage plugin"""
python
{ "resource": "" }
q26493
Memory.get_word_at
train
def get_word_at(self, index: int) -> Union[int, BitVec]: """Access a word from a specified memory index. :param index: integer representing the index to access :return: 32 byte word at the specified index """ try: return symbol_factory.BitVecVal( util...
python
{ "resource": "" }
q26494
Memory.write_word_at
train
def write_word_at(self, index: int, value: Union[int, BitVec, bool, Bool]) -> None: """Writes a 32 byte word to memory at the specified index` :param index: index to write to :param value: the value to write to memory """ try: # Attempt to concretize value ...
python
{ "resource": "" }
q26495
BenchmarkPlugin.initialize
train
def initialize(self, symbolic_vm: LaserEVM): """Initializes the BenchmarkPlugin Introduces hooks in symbolic_vm to track the desired values :param symbolic_vm: Symbolic virtual machine to analyze """ self._reset() @symbolic_vm.laser_hook("execute_state") def exe...
python
{ "resource": "" }
q26496
BenchmarkPlugin._reset
train
def _reset(self): """Reset this plugin""" self.nr_of_executed_insns = 0
python
{ "resource": "" }
q26497
BenchmarkPlugin._write_to_graph
train
def _write_to_graph(self): """Write the coverage results to a graph""" traces = [] for byte_code, trace_data in self.coverage.items(): traces += [list(trace_data.keys()), list(trace_data.values()), "r--"] plt.plot(*traces)
python
{ "resource": "" }
q26498
DependenceMap._merge_buckets
train
def _merge_buckets(self, bucket_list: Set[DependenceBucket]) -> DependenceBucket: """ Merges the buckets in bucket list """ variables = [] # type: List[str] conditions = [] # type: List[z3.BoolRef] for bucket in bucket_list: self.buckets.remove(bucket)
python
{ "resource": "" }
q26499
IndependenceSolver.check
train
def check(self) -> z3.CheckSatResult: """Returns z3 smt check result. """ dependence_map = DependenceMap() for constraint in self.constraints: dependence_map.add_condition(constraint) self.models = [] for bucket in dependence_map.buckets: self.raw.reset()...
python
{ "resource": "" }