boa.code.module.Module

What follows are the details of the Module implementation.

class boa.code.module.Module(path: str, module_name='', to_import=['*'])[source]
static ImportFromBlock(block: bytecode.cfg.BasicBlock, current_file_path)[source]
abi_entry_point = None
abi_methods = {}
actions = None
all_vm_tokens = {}
app_call_registrations = None
bc = None
blocks = None
build()[source]
cfg = None
export_abi_json(output_path)[source]

this method is used to generate a debug map for NEO debugger

export_debug(output_path)[source]

this method is used to generate a debug map for NEO debugger

extra_instructions
generate_abi_json(avm_name, file_hash)[source]
generate_avmdbgnfo(avm_name, file_hash)[source]
generate_debug_json(avm_name, file_hash)[source]
has_method(full_name)[source]
include_abi_method(method, types)[source]

Perform linkage of addresses between methods.

local_methods
main

Return the default method in this module.

Returns:the default method in this module
Return type:boa.code.method.Method
method_by_name(method_name)[source]

Look up a method by its name from the module methods list. :param method_name: the name of the method to look up :type method_name: str

Returns:the method ( if it is found)
Return type:boa.code.method.Method
methods = None
module_name = ''
orderered_methods

An ordered list of methods

Returns:A list of ordered methods is this module
Return type:list
path = None
set_abi_entry_point(method, types)[source]
to_import = None
to_s()[source]

this method is used to print the output of the executable in a readable/ tokenized format. sample usage:

>>> from boa.compiler import Compiler
>>> module = Compiler.load('./boa/tests/src/LambdaTest.py').default
>>> module.write()
>>> print(module.to_s())
12            3   LOAD_CONST          9                [data]
              4   STORE_FAST          j                [data]
22            11  LOAD_FAST           j                [data]
              17  CALL_FUNCTION       Main.<locals>.q_1                                           [<boa.code.pytoken.PyToken object at 0x10cb53c50>] [data] 22
              20  STORE_FAST          m                [data]
24            27  243                 b''      [data] 3
              30  LOAD_FAST           m                [data]
              35  NOP                                  [data]
              36  241                                  [data]
              37  242                                  [data]
              38  RETURN_VALUE                         [data]
20            49  243                 b''      [data] 3
              52  LOAD_FAST           x                [data]
              57  LOAD_CONST          1                [data]
              58  BINARY_ADD                           [data]
              59  NOP                                  [data]
              60  241                                  [data]
              61  242                                  [data]
              62  RETURN_VALUE                         [data]
write()[source]

Write the current module to a byte string.

Note that if you are using the Compiler.load('path/to/file.py'), you must call module.write() before any inspection of the module is possible.

Returns:A bytestring of representing the current module
Return type:bytes
write_methods()[source]

Write all methods in the current module to a byte string.

Returns:A bytestring of all current methods in this module
Return type:bytes