From f19a643d75072518e3aaef9f1318fa270a48049b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Wed, 3 Apr 2024 10:06:33 +0200 Subject: [PATCH] Update documentation --- docs/index.js | 2174 +++++++++-------- docs/opshin/builder.html | 72 +- docs/opshin/compiler.html | 54 +- docs/opshin/compiler_config.html | 282 +++ docs/opshin/index.html | 7 +- .../optimize/optimize_const_folding.html | 40 +- docs/opshin/tests/test_misc.html | 351 ++- docs/opshin/tests/test_ops.html | 449 ++++ .../opshin/tests/test_std/test_integrity.html | 2 + docs/opshin/tests/utils.html | 53 +- docs/opshin/type_inference.html | 52 +- docs/opshin/typed_ast.html | 2 - docs/opshin/types.html | 455 ++-- docs/opshin/util.html | 138 ++ 14 files changed, 2716 insertions(+), 1415 deletions(-) create mode 100644 docs/opshin/compiler_config.html diff --git a/docs/index.js b/docs/index.js index ca1f6220..855b1770 100644 --- a/docs/index.js +++ b/docs/index.js @@ -18,6 +18,7 @@ URLS=[ "opshin/tests/test_std/test_fractions.html", "opshin/tests/test_std/test_bitmap.html", "opshin/tests/test_stdlib.html", +"opshin/compiler_config.html", "opshin/fun_impls.html", "opshin/builder.html", "opshin/ledger/index.html", @@ -2200,6 +2201,12 @@ INDEX=[ "func":1 }, { +"ref":"opshin.tests.test_misc.MiscTest.test_isinstance_cast_if2", +"url":8, +"doc":"", +"func":1 +}, +{ "ref":"opshin.tests.test_misc.MiscTest.test_return_in_if_missing_return", "url":8, "doc":"", @@ -2332,6 +2339,12 @@ INDEX=[ "func":1 }, { +"ref":"opshin.tests.test_misc.MiscTest.test_empty_return", +"url":8, +"doc":"", +"func":1 +}, +{ "ref":"opshin.tests.test_ops", "url":9, "doc":"" @@ -2516,6 +2529,30 @@ INDEX=[ "func":1 }, { +"ref":"opshin.tests.test_ops.OpTest.test_in_list_data", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_not_in_list_data", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_not_in_list_int", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_not_in_list_bytes", +"url":9, +"doc":"", +"func":1 +}, +{ "ref":"opshin.tests.test_ops.OpTest.test_not_list", "url":9, "doc":"", @@ -2552,6 +2589,48 @@ INDEX=[ "func":1 }, { +"ref":"opshin.tests.test_ops.OpTest.test_eq_bool_int", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_neq_str", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_neq_int", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_neq_bytes", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_neq_bool", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_neq_bool_int", +"url":9, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.tests.test_ops.OpTest.test_neq_data", +"url":9, +"doc":"", +"func":1 +}, +{ "ref":"opshin.tests.test_ops.OpTest.test_mul_int_str", "url":9, "doc":"", @@ -3238,5729 +3317,5786 @@ INDEX=[ "func":1 }, { -"ref":"opshin.fun_impls", +"ref":"opshin.compiler_config", "url":19, "doc":"" }, { -"ref":"opshin.fun_impls.LenImpl", +"ref":"opshin.compiler_config.CompilationConfig", +"url":19, +"doc":"CompilationConfig(compress_patterns: Optional[bool] = None, iterative_unfold_patterns: Optional[bool] = None, constant_index_access_list: Optional[bool] = None, constant_folding: Optional[bool] = None, allow_isinstance_anything: Optional[bool] = None, force_three_params: Optional[bool] = None, remove_dead_code: Optional[bool] = None)" +}, +{ +"ref":"opshin.compiler_config.CompilationConfig.constant_folding", "url":19, "doc":"" }, { -"ref":"opshin.fun_impls.LenImpl.type_from_args", +"ref":"opshin.compiler_config.CompilationConfig.allow_isinstance_anything", +"url":19, +"doc":"" +}, +{ +"ref":"opshin.compiler_config.CompilationConfig.force_three_params", +"url":19, +"doc":"" +}, +{ +"ref":"opshin.compiler_config.CompilationConfig.remove_dead_code", "url":19, +"doc":"" +}, +{ +"ref":"opshin.fun_impls", +"url":20, +"doc":"" +}, +{ +"ref":"opshin.fun_impls.LenImpl", +"url":20, +"doc":"" +}, +{ +"ref":"opshin.fun_impls.LenImpl.type_from_args", +"url":20, "doc":"", "func":1 }, { "ref":"opshin.fun_impls.LenImpl.impl_from_args", -"url":19, +"url":20, "doc":"", "func":1 }, { "ref":"opshin.fun_impls.ReversedImpl", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.ReversedImpl.type_from_args", -"url":19, +"url":20, "doc":"", "func":1 }, { "ref":"opshin.fun_impls.ReversedImpl.impl_from_args", -"url":19, +"url":20, "doc":"", "func":1 }, { "ref":"opshin.fun_impls.PrintImpl", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PrintImpl.type_from_args", -"url":19, +"url":20, "doc":"", "func":1 }, { "ref":"opshin.fun_impls.PrintImpl.impl_from_args", -"url":19, +"url":20, "doc":"", "func":1 }, { "ref":"opshin.fun_impls.PythonBuiltIn", -"url":19, +"url":20, "doc":"An enumeration." }, { "ref":"opshin.fun_impls.PythonBuiltIn.all", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.any", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.abs", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.chr", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.breakpoint", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.hex", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.len", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.max", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.min", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.print", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.pow", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.oct", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.range", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.reversed", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.fun_impls.PythonBuiltIn.sum", -"url":19, +"url":20, "doc":"" }, { "ref":"opshin.builder", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.Purpose", -"url":20, +"url":21, "doc":"An enumeration." }, { "ref":"opshin.builder.Purpose.spending", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.Purpose.minting", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.Purpose.rewarding", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.Purpose.certifying", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.Purpose.any", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.Purpose.lib", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract", -"url":20, -"doc":"PlutusContract(contract: pycardano.plutus.PlutusV2Script, datum_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData = None, redeemer_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData = None, parameter_types: List[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData = , purpose: Iterable[opshin.builder.Purpose] = ( ,), version: Optional[str] = '1.0.0', title: str = 'validator', description: Optional[str] = 'opshin 0.19.1 Smart Contract', license: Optional[str] = None)" +"url":21, +"doc":"PlutusContract(contract: pycardano.plutus.PlutusV2Script, datum_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData = None, redeemer_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData = None, parameter_types: List[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData = , purpose: Iterable[opshin.builder.Purpose] = ( ,), version: Optional[str] = '1.0.0', title: str = 'validator', description: Optional[str] = 'opshin 0.21.0 Smart Contract', license: Optional[str] = None)" }, { "ref":"opshin.builder.PlutusContract.contract", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.parameter_types", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.datum_type", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.redeemer_type", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.purpose", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.version", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.title", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.description", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.license", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.cbor", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.cbor_hex", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.script_hash", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.policy_id", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.mainnet_addr", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.testnet_addr", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.plutus_json", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.blueprint", -"url":20, +"url":21, "doc":"" }, { "ref":"opshin.builder.PlutusContract.apply_parameter", -"url":20, +"url":21, "doc":"Returns a new OpShin Contract with the applied parameters", "func":1 }, { "ref":"opshin.builder.PlutusContract.dump", -"url":20, +"url":21, "doc":"", "func":1 }, { "ref":"opshin.builder.compile", -"url":20, +"url":21, "doc":"", "func":1 }, { "ref":"opshin.builder.build", -"url":20, +"url":21, "doc":"Expects a python module and returns the build artifacts from compiling it", "func":1 }, { "ref":"opshin.builder.to_plutus_schema", -"url":20, +"url":21, "doc":"Convert to a dictionary representing a json schema according to CIP 57 Plutus Blueprint Reference of the core structure: https: cips.cardano.org/cips/cip57/ corevocabulary Args: kwargs: Extra key word arguments to be passed to json.dumps() Returns: dict: a dict representing the schema of this class.", "func":1 }, { "ref":"opshin.builder.from_plutus_schema", -"url":20, +"url":21, "doc":"Convert from a dictionary representing a json schema according to CIP 57 Plutus Blueprint", "func":1 }, { "ref":"opshin.builder.apply_parameters", -"url":20, +"url":21, "doc":"Expects a plutus script (compiled) and returns the compiled script from applying parameters to it", "func":1 }, { "ref":"opshin.builder.load", -"url":20, +"url":21, "doc":"Load a contract from a file or directory and generate the artifacts", "func":1 }, { "ref":"opshin.ledger", -"url":21, +"url":22, "doc":"OpShin provides some helper classes that define concepts introduced in PlutusTx and used by the cardano node to encode data. In particular you find the definition of the entire Script Context for Plutus V2 in the file api_v2 . from opshin.ledger.api_v2 import " }, { "ref":"opshin.ledger.api_v2", -"url":22, +"url":23, "doc":"The PlutusV2 ledger API. All classes involved in defining the ScriptContext passed by the node." }, { "ref":"opshin.ledger.api_v2.TxId", -"url":22, +"url":23, "doc":"A transaction id, a 64 bytes long hash of the transaction body (also called transaction hash). Example value: TxId(bytes.fromhex(\"842a4d37b036da6ab3c04331240e67d81746beb44f23ad79703e026705361956\" " }, { "ref":"opshin.ledger.api_v2.TxId.tx_id", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxId.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TrueData", -"url":22, +"url":23, "doc":"A Datum that represents True in Haskell implementations. It is thus used as an encoding for True in the ScriptContext. Example value: TrueData()" }, { "ref":"opshin.ledger.api_v2.TrueData.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.FalseData", -"url":22, +"url":23, "doc":"A Datum that represents False in Haskell implementations. It is thus used as an encoding for False in the ScriptContext. Example value: FalseData()" }, { "ref":"opshin.ledger.api_v2.FalseData.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOutRef", -"url":22, +"url":23, "doc":"A reference to a transaction output (hash/id + index)" }, { "ref":"opshin.ledger.api_v2.TxOutRef.id", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOutRef.idx", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOutRef.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.PubKeyCredential", -"url":22, +"url":23, "doc":"Part of an address that is authenticated by a public key hash Example value: PubKeyCredential(bytes.fromhex(\"c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274\" " }, { "ref":"opshin.ledger.api_v2.PubKeyCredential.credential_hash", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.PubKeyCredential.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.ScriptCredential", -"url":22, +"url":23, "doc":"Part of an address that is authenticated by a smart cotnract Example value: ScriptCredential(bytes.fromhex(\"c06ddaad12fc4ded18e56feac72957c1aa75fce6096b40e63ec88274\" " }, { "ref":"opshin.ledger.api_v2.ScriptCredential.credential_hash", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.ScriptCredential.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.StakingHash", -"url":22, +"url":23, "doc":"Indicates that the stake of this address is controlled by the associated credential" }, { "ref":"opshin.ledger.api_v2.StakingHash.value", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.StakingHash.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.StakingPtr", -"url":22, +"url":23, "doc":"Indicates that the stake of this address is controlled by the associated pointer. In an address, a chain pointer refers to a point of the chain containing a stake key registration certificate. A point is identified by the 3 coordinates in this object." }, { "ref":"opshin.ledger.api_v2.StakingPtr.slot_no", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.StakingPtr.tx_index", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.StakingPtr.cert_index", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.StakingPtr.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.NoStakingCredential", -"url":22, +"url":23, "doc":"Indicates that this address has no staking credentials. Its funds can not be delegated." }, { "ref":"opshin.ledger.api_v2.NoStakingCredential.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeStakingCredential", -"url":22, +"url":23, "doc":"Indicates that this address has staking credentials. Its funds can be delegated by the credentialed user." }, { "ref":"opshin.ledger.api_v2.SomeStakingCredential.staking_credential", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeStakingCredential.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Address", -"url":22, +"url":23, "doc":"A Shelley address, consisting of a payment and staking credential" }, { "ref":"opshin.ledger.api_v2.Address.payment_credential", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Address.staking_credential", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Address.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeDatumHash", -"url":22, +"url":23, "doc":"Indicates that there is a datum associated with this output, which has the given hash." }, { "ref":"opshin.ledger.api_v2.SomeDatumHash.datum_hash", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeDatumHash.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeScriptHash", -"url":22, +"url":23, "doc":"Indicates that there is a script associated with this output, which has the given hash." }, { "ref":"opshin.ledger.api_v2.SomeScriptHash.script_hash", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeScriptHash.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.NoOutputDatum", -"url":22, +"url":23, "doc":"Indicates that there is no datum associated with an output" }, { "ref":"opshin.ledger.api_v2.NoOutputDatum.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeOutputDatumHash", -"url":22, +"url":23, "doc":"Indicates that there is an datum associated with an output, which has the attached hash" }, { "ref":"opshin.ledger.api_v2.SomeOutputDatumHash.datum_hash", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeOutputDatumHash.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeOutputDatum", -"url":22, +"url":23, "doc":"Indicates that there is an datum associated with an output, which is inlined and equal to the attached datum" }, { "ref":"opshin.ledger.api_v2.SomeOutputDatum.datum", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.SomeOutputDatum.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.NoScriptHash", -"url":22, +"url":23, "doc":"Indicates that there is no script associated with an output" }, { "ref":"opshin.ledger.api_v2.NoScriptHash.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOut", -"url":22, +"url":23, "doc":"The plutus representation of an transaction output, consisting of - address: address owning this output - value: tokens associated with this output - datum: datum associated with this output - reference_script: reference script associated with this output" }, { "ref":"opshin.ledger.api_v2.TxOut.address", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOut.value", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOut.datum", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOut.reference_script", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxOut.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInInfo", -"url":22, +"url":23, "doc":"The plutus representation of an transaction output, that is consumed by the transaction." }, { "ref":"opshin.ledger.api_v2.TxInInfo.out_ref", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInInfo.resolved", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInInfo.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertDelegRegKey", -"url":22, +"url":23, "doc":"DCertDelegRegKey(value: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr])" }, { "ref":"opshin.ledger.api_v2.DCertDelegRegKey.value", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertDelegRegKey.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertDelegDeRegKey", -"url":22, +"url":23, "doc":"DCertDelegDeRegKey(value: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr])" }, { "ref":"opshin.ledger.api_v2.DCertDelegDeRegKey.value", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertDelegDeRegKey.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertDelegDelegate", -"url":22, +"url":23, "doc":"DCertDelegDelegate(delegator: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr], delegatee: bytes)" }, { "ref":"opshin.ledger.api_v2.DCertDelegDelegate.delegator", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertDelegDelegate.delegatee", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertDelegDelegate.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertPoolRegister", -"url":22, +"url":23, "doc":"DCertPoolRegister(pool_id: bytes, pool_vfr: bytes)" }, { "ref":"opshin.ledger.api_v2.DCertPoolRegister.pool_id", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertPoolRegister.pool_vfr", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertPoolRegister.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertPoolRetire", -"url":22, +"url":23, "doc":"DCertPoolRetire(retirement_certificate: bytes, epoch: int)" }, { "ref":"opshin.ledger.api_v2.DCertPoolRetire.retirement_certificate", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertPoolRetire.epoch", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertPoolRetire.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertGenesis", -"url":22, +"url":23, "doc":"DCertGenesis()" }, { "ref":"opshin.ledger.api_v2.DCertGenesis.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.DCertMir", -"url":22, +"url":23, "doc":"DCertMir()" }, { "ref":"opshin.ledger.api_v2.DCertMir.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.NegInfPOSIXTime", -"url":22, +"url":23, "doc":"Negative infinite POSIX time, used to indicate that there is no lower bound for the execution of this transaction" }, { "ref":"opshin.ledger.api_v2.NegInfPOSIXTime.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.FinitePOSIXTime", -"url":22, +"url":23, "doc":"Finite POSIX time, used to indicate that there is a lower or upper bound for the execution of this transaction" }, { "ref":"opshin.ledger.api_v2.FinitePOSIXTime.time", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.FinitePOSIXTime.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.PosInfPOSIXTime", -"url":22, +"url":23, "doc":"Infinite POSIX time, used to indicate that there is no upper bound for the execution of this transaction" }, { "ref":"opshin.ledger.api_v2.PosInfPOSIXTime.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.UpperBoundPOSIXTime", -"url":22, +"url":23, "doc":"Upper bound for the execution of this transaction" }, { "ref":"opshin.ledger.api_v2.UpperBoundPOSIXTime.limit", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.UpperBoundPOSIXTime.closed", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.UpperBoundPOSIXTime.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.LowerBoundPOSIXTime", -"url":22, +"url":23, "doc":"Lower bound for the execution of this transaction" }, { "ref":"opshin.ledger.api_v2.LowerBoundPOSIXTime.limit", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.LowerBoundPOSIXTime.closed", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.LowerBoundPOSIXTime.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.POSIXTimeRange", -"url":22, +"url":23, "doc":"Time range in which this transaction can be executed" }, { "ref":"opshin.ledger.api_v2.POSIXTimeRange.lower_bound", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.POSIXTimeRange.upper_bound", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.POSIXTimeRange.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Minting", -"url":22, +"url":23, "doc":"Script purpose indicating that the given policy id is being minted or burned" }, { "ref":"opshin.ledger.api_v2.Minting.policy_id", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Minting.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Spending", -"url":22, +"url":23, "doc":"Script purpose indicating that the given transaction output is being spent, which is owned by the invoked contract" }, { "ref":"opshin.ledger.api_v2.Spending.tx_out_ref", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Spending.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Rewarding", -"url":22, +"url":23, "doc":"Rewarding(staking_credential: Union[opshin.ledger.api_v2.StakingHash, opshin.ledger.api_v2.StakingPtr])" }, { "ref":"opshin.ledger.api_v2.Rewarding.staking_credential", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Rewarding.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Certifying", -"url":22, +"url":23, "doc":"Certifying(d_cert: Union[opshin.ledger.api_v2.DCertDelegRegKey, opshin.ledger.api_v2.DCertDelegDeRegKey, opshin.ledger.api_v2.DCertDelegDelegate, opshin.ledger.api_v2.DCertPoolRegister, opshin.ledger.api_v2.DCertPoolRetire, opshin.ledger.api_v2.DCertGenesis, opshin.ledger.api_v2.DCertMir])" }, { "ref":"opshin.ledger.api_v2.Certifying.d_cert", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.Certifying.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo", -"url":22, +"url":23, "doc":"A complex agglomeration of everything that could be of interest to the executed script, regarding the transaction that invoked the script" }, { "ref":"opshin.ledger.api_v2.TxInfo.inputs", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.reference_inputs", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.outputs", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.fee", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.mint", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.dcert", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.wdrl", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.valid_range", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.signatories", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.redeemers", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.data", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.id", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.TxInfo.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.ScriptContext", -"url":22, +"url":23, "doc":"Auxiliary information about the transaction and reason for invocation of the called script." }, { "ref":"opshin.ledger.api_v2.ScriptContext.tx_info", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.ScriptContext.purpose", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.api_v2.ScriptContext.CONSTR_ID", -"url":22, +"url":23, "doc":"" }, { "ref":"opshin.ledger.interval", -"url":23, +"url":24, "doc":"A library to assist with interval handling" }, { "ref":"opshin.ledger.interval.compare", -"url":23, +"url":24, "doc":"", "func":1 }, { "ref":"opshin.ledger.interval.compare_extended_helper", -"url":23, +"url":24, "doc":"", "func":1 }, { "ref":"opshin.ledger.interval.compare_extended", -"url":23, +"url":24, "doc":"", "func":1 }, { "ref":"opshin.ledger.interval.get_bool", -"url":23, +"url":24, "doc":"", "func":1 }, { "ref":"opshin.ledger.interval.compare_upper_bound", -"url":23, +"url":24, "doc":"", "func":1 }, { "ref":"opshin.ledger.interval.compare_lower_bound", -"url":23, +"url":24, "doc":"", "func":1 }, { "ref":"opshin.ledger.interval.contains", -"url":23, +"url":24, "doc":"Returns True if the interval b is entirely contained in a .", "func":1 }, { "ref":"opshin.ledger.interval.make_range", -"url":23, +"url":24, "doc":"Create a bounded interval from the given time lower_bound up to the given upper_bound , including the given time", "func":1 }, { "ref":"opshin.ledger.interval.make_from", -"url":23, +"url":24, "doc":"Create a bounded interval from the given time lower_bound up to infinity, including the given time", "func":1 }, { "ref":"opshin.ledger.interval.make_to", -"url":23, +"url":24, "doc":"Create a bounded interval from negative infinity up to the given upper_bound , including the given time", "func":1 }, { "ref":"opshin.types", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.FunctionType", -"url":24, +"url":25, "doc":"FunctionType(argtyps: List[opshin.types.Type], rettyp: opshin.types.Type, bound_vars: Dict[str, opshin.types.Type] = , bind_self: Optional[str] = None)" }, { "ref":"opshin.types.FunctionType.argtyps", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.FunctionType.rettyp", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.FunctionType.bound_vars", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.FunctionType.bind_self", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.FunctionType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.FunctionType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.FunctionType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.FunctionType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.FunctionType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.FunctionType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.FunctionType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.FunctionType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.FunctionType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.FunctionType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.FunctionType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.FunctionType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.TypeInferenceError", -"url":24, +"url":25, "doc":"Assertion failed." }, { "ref":"opshin.types.Type", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.Type.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.Type.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.Type.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.Type.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.Type.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.Type.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.Type.copy_only_attributes", -"url":24, +"url":25, "doc":"Pluthon function that returns a copy of only the attributes of the object", "func":1 }, { "ref":"opshin.types.Type.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.Type.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.Type.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.Type.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.Type.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.Record", -"url":24, +"url":25, "doc":"Record(name: str, orig_name: str, constructor: int, fields: Union[List[Tuple[str, opshin.types.Type , frozenlist2.frozenlist])" }, { "ref":"opshin.types.Record.name", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.Record.orig_name", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.Record.constructor", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.Record.fields", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.ClassType", -"url":24, +"url":25, "doc":"ClassType()" }, { "ref":"opshin.types.ClassType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.ClassType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.ClassType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.ClassType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.ClassType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.ClassType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.ClassType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.ClassType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.ClassType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.ClassType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.ClassType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.ClassType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.AnyType", -"url":24, +"url":25, "doc":"The top element in the partial order on types (excluding FunctionTypes, which do not compare to anything)" }, { "ref":"opshin.types.AnyType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.AnyType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.AnyType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Need to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.AnyType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.AnyType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.AnyType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.AnyType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.AnyType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.AnyType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.AnyType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.AnyType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.AnyType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.AtomicType", -"url":24, +"url":25, "doc":"AtomicType()" }, { "ref":"opshin.types.AtomicType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.AtomicType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.AtomicType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.AtomicType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.AtomicType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.AtomicType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.AtomicType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.AtomicType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.AtomicType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.AtomicType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.AtomicType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.AtomicType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.RecordType", -"url":24, +"url":25, "doc":"RecordType(record: opshin.types.Record)" }, { "ref":"opshin.types.RecordType.record", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.RecordType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.RecordType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.RecordType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.RecordType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.RecordType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Need to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.RecordType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.RecordType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object", "func":1 }, { "ref":"opshin.types.RecordType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.RecordType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.RecordType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.RecordType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.RecordType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.UnionType", -"url":24, +"url":25, "doc":"UnionType(typs: List[opshin.types.RecordType])" }, { "ref":"opshin.types.UnionType.typs", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.UnionType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.UnionType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.UnionType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.UnionType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.UnionType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.UnionType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.UnionType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.UnionType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.UnionType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.UnionType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.UnionType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.UnionType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.TupleType", -"url":24, +"url":25, "doc":"TupleType(typs: List[opshin.types.Type])" }, { "ref":"opshin.types.TupleType.typs", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.TupleType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.TupleType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.TupleType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.TupleType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.TupleType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.TupleType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.TupleType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.TupleType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.TupleType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.TupleType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.TupleType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.TupleType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.PairType", -"url":24, +"url":25, "doc":"An internal type representing built-in PlutusData pairs" }, { "ref":"opshin.types.PairType.l_typ", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.PairType.r_typ", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.PairType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.PairType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.PairType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.PairType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.PairType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.PairType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.PairType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.PairType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.PairType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.PairType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.PairType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.PairType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.ListType", -"url":24, +"url":25, "doc":"ListType(typ: opshin.types.Type)" }, { "ref":"opshin.types.ListType.typ", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.ListType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.ListType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.ListType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.ListType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.ListType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.ListType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.ListType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.ListType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.ListType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.ListType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.ListType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.ListType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.DictType", -"url":24, +"url":25, "doc":"DictType(key_typ: opshin.types.Type, value_typ: opshin.types.Type)" }, { "ref":"opshin.types.DictType.key_typ", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.DictType.value_typ", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.DictType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.DictType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.DictType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.DictType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.DictType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.DictType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.DictType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.DictType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.DictType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.DictType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.DictType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.DictType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.InstanceType", -"url":24, +"url":25, "doc":"InstanceType(typ: opshin.types.ClassType)" }, { "ref":"opshin.types.InstanceType.typ", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.InstanceType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.InstanceType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.InstanceType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.InstanceType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.InstanceType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.InstanceType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.InstanceType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.InstanceType.copy_only_attributes", -"url":24, +"url":25, "doc":"Pluthon function that returns a copy of only the attributes of the object", "func":1 }, { "ref":"opshin.types.InstanceType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.InstanceType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.InstanceType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.InstanceType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.IntegerType", -"url":24, +"url":25, "doc":"IntegerType()" }, { "ref":"opshin.types.IntegerType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.IntegerType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.IntegerType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.IntegerType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.IntegerType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.IntegerType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.IntegerType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.IntegerType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.IntegerType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.IntegerType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.IntegerType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.IntegerType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.StringType", -"url":24, +"url":25, "doc":"StringType()" }, { "ref":"opshin.types.StringType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.StringType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.StringType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.StringType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.StringType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.StringType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.StringType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.StringType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.StringType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.StringType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.StringType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.StringType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.ByteStringType", -"url":24, +"url":25, "doc":"ByteStringType()" }, { "ref":"opshin.types.ByteStringType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.ByteStringType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.ByteStringType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.ByteStringType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.ByteStringType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.ByteStringType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.ByteStringType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.ByteStringType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.ByteStringType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.ByteStringType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.ByteStringType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.ByteStringType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.BoolType", -"url":24, +"url":25, "doc":"BoolType()" }, { "ref":"opshin.types.BoolType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.BoolType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.BoolType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.BoolType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.BoolType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.BoolType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.BoolType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.BoolType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.BoolType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.BoolType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.BoolType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.BoolType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.UnitType", -"url":24, +"url":25, "doc":"UnitType()" }, { "ref":"opshin.types.UnitType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.UnitType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.UnitType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.UnitType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.UnitType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.UnitType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.UnitType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.UnitType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.UnitType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.UnitType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.UnitType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.UnitType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.InaccessibleType", -"url":24, +"url":25, "doc":"A type that blocks overwriting of a function" }, { "ref":"opshin.types.InaccessibleType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.InaccessibleType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.InaccessibleType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.InaccessibleType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.InaccessibleType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.InaccessibleType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.InaccessibleType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.InaccessibleType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.InaccessibleType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.InaccessibleType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.InaccessibleType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.InaccessibleType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.repeated_addition", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.PowImpl", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.ByteStrIntMulImpl", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.StrIntMulImpl", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.PolymorphicFunction", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.PolymorphicFunction.type_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.PolymorphicFunction.impl_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.StrImpl", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.StrImpl.type_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.StrImpl.impl_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.IntImpl", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.IntImpl.type_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.IntImpl.impl_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.BoolImpl", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.BoolImpl.type_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.BoolImpl.impl_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.BytesImpl", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.BytesImpl.type_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.BytesImpl.impl_from_args", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType", -"url":24, +"url":25, "doc":"A special type of builtin that may act differently on different parameters" }, { "ref":"opshin.types.PolymorphicFunctionType.polymorphic_function", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.PolymorphicFunctionType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType", -"url":24, +"url":25, "doc":"PolymorphicFunctionInstanceType(typ: opshin.types.FunctionType, polymorphic_function: opshin.types.PolymorphicFunction)" }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.typ", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.polymorphic_function", -"url":24, +"url":25, "doc":"" }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.attribute_type", -"url":24, +"url":25, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.attribute", -"url":24, +"url":25, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.copy_only_attributes", -"url":24, +"url":25, "doc":"Pluthon function that returns a copy of only the attributes of the object", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.types.PolymorphicFunctionInstanceType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.types.empty_list", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.transform_ext_params_map", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.types.transform_output_map", -"url":24, +"url":25, "doc":"", "func":1 }, { "ref":"opshin.optimize", -"url":25, +"url":26, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_pass", -"url":26, +"url":27, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_pass.OptimizeRemovePass", -"url":26, +"url":27, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.optimize.optimize_remove_pass.OptimizeRemovePass.step", -"url":26, +"url":27, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_pass.OptimizeRemovePass.visit_Pass", -"url":26, +"url":27, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_pass.OptimizeRemovePass.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.optimize.optimize_remove_comments", -"url":28, +"url":29, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_comments.OptimizeRemoveDeadconstants", -"url":28, +"url":29, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.optimize.optimize_remove_comments.OptimizeRemoveDeadconstants.step", -"url":28, +"url":29, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_comments.OptimizeRemoveDeadconstants.visit_Expr", -"url":28, +"url":29, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_comments.OptimizeRemoveDeadconstants.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars", -"url":29, +"url":30, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_deadvars.NameLoadCollector", -"url":29, +"url":30, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.optimize.optimize_remove_deadvars.NameLoadCollector.step", -"url":29, +"url":30, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_deadvars.NameLoadCollector.visit_Name", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.NameLoadCollector.visit_ClassDef", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.NameLoadCollector.visit_FunctionDef", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.NameLoadCollector.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor", -"url":29, +"url":30, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor.step", -"url":29, +"url":30, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor.generic_visit", -"url":29, +"url":30, "doc":"Called if no explicit visitor function exists for a node.", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor.visit_Lambda", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor.visit_Constant", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor.visit_RawPlutoExpr", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor.visit_Name", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.SafeOperationVisitor.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars", -"url":29, +"url":30, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.step", -"url":29, +"url":30, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.loaded_vars", -"url":29, +"url":30, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.guaranteed_avail_names", -"url":29, +"url":30, "doc":"" }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.guaranteed", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.enter_scope", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.exit_scope", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.set_guaranteed", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_Module", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_If", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_While", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_For", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_Assign", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_AnnAssign", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_ClassDef", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit_FunctionDef", -"url":29, +"url":30, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_remove_deadvars.OptimizeRemoveDeadvars.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding", -"url":30, +"url":31, "doc":"" }, { "ref":"opshin.optimize.optimize_const_folding.ShallowNameDefCollector", -"url":30, +"url":31, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.optimize.optimize_const_folding.ShallowNameDefCollector.step", -"url":30, +"url":31, "doc":"" }, { "ref":"opshin.optimize.optimize_const_folding.ShallowNameDefCollector.visit_Name", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.ShallowNameDefCollector.visit_ClassDef", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.ShallowNameDefCollector.visit_FunctionDef", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.ShallowNameDefCollector.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor", -"url":30, +"url":31, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.step", -"url":30, +"url":31, "doc":"" }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_For", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_While", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_If", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_Name", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_ClassDef", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_FunctionDef", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_Import", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit_ImportFrom", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.DefinedTimesVisitor.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding", -"url":30, +"url":31, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.step", -"url":30, +"url":31, "doc":"" }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.enter_scope", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.add_var_visible", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.add_vars_visible", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.add_constant", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visible_vars", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.exit_scope", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.update_constants", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit_Module", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit_FunctionDef", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit_ClassDef", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit_ImportFrom", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit_Import", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit_Assign", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit_AnnAssign", -"url":30, +"url":31, "doc":"", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.generic_visit", -"url":30, +"url":31, "doc":"Called if no explicit visitor function exists for a node.", "func":1 }, { "ref":"opshin.optimize.optimize_const_folding.OptimizeConstantFolding.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.compiler", -"url":31, +"url":32, "doc":"" }, { "ref":"opshin.compiler.rec_constant_map_data", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.rec_constant_map", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.wrap_validator_double_function", -"url":31, +"url":32, "doc":"Wraps the validator function to enable a double function as minting script pass_through defines how many parameters x would normally take and should be passed through to x", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler", -"url":31, +"url":32, "doc":"Expects a TypedAST and returns UPLC/Pluto like code" }, { "ref":"opshin.compiler.PlutoCompiler.step", -"url":31, +"url":32, "doc":"" }, { "ref":"opshin.compiler.PlutoCompiler.visit_sequence", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_BinOp", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_BoolOp", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_UnaryOp", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Compare", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Module", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Constant", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_NoneType", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Assign", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_AnnAssign", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Name", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Expr", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Call", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_FunctionDef", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_While", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_For", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_If", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Return", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Pass", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Subscript", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Tuple", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_ClassDef", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Attribute", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Assert", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_RawPlutoExpr", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_List", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_Dict", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_IfExp", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_ListComp", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_DictComp", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_FormattedValue", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit_JoinedStr", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.generic_visit", -"url":31, +"url":32, "doc":"Called if no explicit visitor function exists for a node.", "func":1 }, { "ref":"opshin.compiler.PlutoCompiler.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.compiler.compile", -"url":31, +"url":32, "doc":"", "func":1 }, { "ref":"opshin.rewrite", -"url":32, +"url":33, "doc":"" }, { "ref":"opshin.rewrite.rewrite_cast_condition", -"url":33, +"url":34, "doc":"" }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions", -"url":33, +"url":34, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.step", -"url":33, +"url":34, "doc":"" }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.visit_Module", -"url":33, +"url":34, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.visit_If", -"url":33, +"url":34, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.visit_IfExp", -"url":33, +"url":34, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.visit_While", -"url":33, +"url":34, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.visit_BoolOp", -"url":33, +"url":34, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.visit_Assert", -"url":33, +"url":34, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_cast_condition.RewriteConditions.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_remove_type_stuff", -"url":34, +"url":35, "doc":"" }, { "ref":"opshin.rewrite.rewrite_remove_type_stuff.RewriteRemoveTypeStuff", -"url":34, +"url":35, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_remove_type_stuff.RewriteRemoveTypeStuff.step", -"url":34, +"url":35, "doc":"" }, { "ref":"opshin.rewrite.rewrite_remove_type_stuff.RewriteRemoveTypeStuff.visit_Assign", -"url":34, +"url":35, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_remove_type_stuff.RewriteRemoveTypeStuff.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_typing", -"url":35, +"url":36, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_typing.RewriteImportTyping", -"url":35, +"url":36, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import_typing.RewriteImportTyping.step", -"url":35, +"url":36, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_typing.RewriteImportTyping.imports_typing", -"url":35, +"url":36, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_typing.RewriteImportTyping.visit_ImportFrom", -"url":35, +"url":36, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_typing.RewriteImportTyping.visit_ClassDef", -"url":35, +"url":36, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_typing.RewriteImportTyping.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_inject_builtin_constr", -"url":36, +"url":37, "doc":"" }, { "ref":"opshin.rewrite.rewrite_inject_builtin_constr.RewriteInjectBuiltinsConstr", -"url":36, +"url":37, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_inject_builtin_constr.RewriteInjectBuiltinsConstr.step", -"url":36, +"url":37, "doc":"" }, { "ref":"opshin.rewrite.rewrite_inject_builtin_constr.RewriteInjectBuiltinsConstr.visit_Module", -"url":36, +"url":37, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_inject_builtin_constr.RewriteInjectBuiltinsConstr.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_dataclasses", -"url":37, +"url":38, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_dataclasses.RewriteImportDataclasses", -"url":37, +"url":38, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import_dataclasses.RewriteImportDataclasses.step", -"url":37, +"url":38, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_dataclasses.RewriteImportDataclasses.imports_dataclasses", -"url":37, +"url":38, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_dataclasses.RewriteImportDataclasses.visit_ImportFrom", -"url":37, +"url":38, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_dataclasses.RewriteImportDataclasses.visit_ClassDef", -"url":37, +"url":38, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_dataclasses.RewriteImportDataclasses.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_subscript38", -"url":38, +"url":39, "doc":"" }, { "ref":"opshin.rewrite.rewrite_subscript38.RewriteSubscript38", -"url":38, +"url":39, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_subscript38.RewriteSubscript38.step", -"url":38, +"url":39, "doc":"" }, { "ref":"opshin.rewrite.rewrite_subscript38.RewriteSubscript38.visit_Index", -"url":38, +"url":39, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_subscript38.RewriteSubscript38.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_empty_lists", -"url":39, +"url":40, "doc":"" }, { "ref":"opshin.rewrite.rewrite_empty_lists.RewriteEmptyLists", -"url":39, +"url":40, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_empty_lists.RewriteEmptyLists.step", -"url":39, +"url":40, "doc":"" }, { "ref":"opshin.rewrite.rewrite_empty_lists.RewriteEmptyLists.visit_List", -"url":39, +"url":40, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_empty_lists.RewriteEmptyLists.visit_Constant", -"url":39, +"url":40, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_empty_lists.RewriteEmptyLists.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping", -"url":40, +"url":41, "doc":"" }, { "ref":"opshin.rewrite.rewrite_scoping.ShallowNameDefCollector", -"url":40, +"url":41, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.rewrite.rewrite_scoping.ShallowNameDefCollector.step", -"url":40, +"url":41, "doc":"" }, { "ref":"opshin.rewrite.rewrite_scoping.ShallowNameDefCollector.visit_Name", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.ShallowNameDefCollector.visit_ClassDef", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.ShallowNameDefCollector.visit_FunctionDef", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.ShallowNameDefCollector.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping", -"url":40, +"url":41, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.latest_scope_id", -"url":40, +"url":41, "doc":"" }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.scopes", -"url":40, +"url":41, "doc":"" }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.step", -"url":40, +"url":41, "doc":"" }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.variable_scope_id", -"url":40, +"url":41, "doc":"find the id of the scope in which this variable is defined (closest to its usage)", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.enter_scope", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.exit_scope", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.set_variable_scope", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.map_name", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.visit_Module", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.visit_Name", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.visit_ClassDef", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.visit_FunctionDef", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.visit_NoneType", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RewriteScoping.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RecordScoper", -"url":40, +"url":41, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_scoping.RecordScoper.scope", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RecordScoper.visit_ClassDef", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_scoping.RecordScoper.visit_AnnAssign", -"url":40, +"url":41, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_empty_dicts", -"url":41, +"url":42, "doc":"" }, { "ref":"opshin.rewrite.rewrite_empty_dicts.RewriteEmptyDicts", -"url":41, +"url":42, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_empty_dicts.RewriteEmptyDicts.step", -"url":41, +"url":42, "doc":"" }, { "ref":"opshin.rewrite.rewrite_empty_dicts.RewriteEmptyDicts.visit_Dict", -"url":41, +"url":42, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_empty_dicts.RewriteEmptyDicts.visit_Constant", -"url":41, +"url":42, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_empty_dicts.RewriteEmptyDicts.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_augassign", -"url":42, +"url":43, "doc":"" }, { "ref":"opshin.rewrite.rewrite_augassign.RewriteAugAssign", -"url":42, +"url":43, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_augassign.RewriteAugAssign.step", -"url":42, +"url":43, "doc":"" }, { "ref":"opshin.rewrite.rewrite_augassign.RewriteAugAssign.visit_AugAssign", -"url":42, +"url":43, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_augassign.RewriteAugAssign.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_integrity_check", -"url":43, +"url":44, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_integrity_check.IntegrityCheckImpl", -"url":43, +"url":44, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_integrity_check.IntegrityCheckImpl.type_from_args", -"url":43, +"url":44, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_integrity_check.IntegrityCheckImpl.impl_from_args", -"url":43, +"url":44, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_integrity_check.RewriteImportIntegrityCheck", -"url":43, +"url":44, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import_integrity_check.RewriteImportIntegrityCheck.step", -"url":43, +"url":44, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_integrity_check.RewriteImportIntegrityCheck.visit_ImportFrom", -"url":43, +"url":44, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_integrity_check.RewriteImportIntegrityCheck.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_forbidden_overwrites", -"url":44, +"url":45, "doc":"" }, { "ref":"opshin.rewrite.rewrite_forbidden_overwrites.ForbiddenOverwriteError", -"url":44, +"url":45, "doc":"Inappropriate argument value (of correct type)." }, { "ref":"opshin.rewrite.rewrite_forbidden_overwrites.RewriteForbiddenOverwrites", -"url":44, +"url":45, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_forbidden_overwrites.RewriteForbiddenOverwrites.step", -"url":44, +"url":45, "doc":"" }, { "ref":"opshin.rewrite.rewrite_forbidden_overwrites.RewriteForbiddenOverwrites.visit_Name", -"url":44, +"url":45, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_forbidden_overwrites.RewriteForbiddenOverwrites.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_inject_builtins", -"url":45, +"url":46, "doc":"" }, { "ref":"opshin.rewrite.rewrite_inject_builtins.RewriteInjectBuiltins", -"url":45, +"url":46, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_inject_builtins.RewriteInjectBuiltins.step", -"url":45, +"url":46, "doc":"" }, { "ref":"opshin.rewrite.rewrite_inject_builtins.RewriteInjectBuiltins.visit_Module", -"url":45, +"url":46, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_inject_builtins.RewriteInjectBuiltins.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_plutusdata", -"url":46, +"url":47, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_plutusdata.RewriteImportPlutusData", -"url":46, +"url":47, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import_plutusdata.RewriteImportPlutusData.step", -"url":46, +"url":47, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_plutusdata.RewriteImportPlutusData.imports_plutus_data", -"url":46, +"url":47, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_plutusdata.RewriteImportPlutusData.visit_ImportFrom", -"url":46, +"url":47, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_plutusdata.RewriteImportPlutusData.visit_ClassDef", -"url":46, +"url":47, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_plutusdata.RewriteImportPlutusData.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_uplc_builtins", -"url":47, +"url":48, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_uplc_builtins.RewriteImportUPLCBuiltins", -"url":47, +"url":48, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import_uplc_builtins.RewriteImportUPLCBuiltins.step", -"url":47, +"url":48, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_uplc_builtins.RewriteImportUPLCBuiltins.imports_uplc_builtins", -"url":47, +"url":48, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_uplc_builtins.RewriteImportUPLCBuiltins.visit_ImportFrom", -"url":47, +"url":48, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_uplc_builtins.RewriteImportUPLCBuiltins.visit_FunctionDef", -"url":47, +"url":48, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_uplc_builtins.RewriteImportUPLCBuiltins.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib", -"url":48, +"url":49, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType", -"url":48, +"url":49, "doc":"A pseudo class that is the result of python hash functions that need a 'digest' call" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.attribute_type", -"url":48, +"url":49, "doc":"The types of the named attributes of this class", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.attribute", -"url":48, +"url":49, "doc":"The attributes of this class. Needs to be a lambda that expects as first argument the object itself", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.copy_only_attributes", -"url":24, +"url":25, "doc":"Returns a copy of this type with only the declared attributes (mapped to builtin values, thus checking atomic types too). For anything but record types and union types, this is the identity function.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.constr_type", -"url":24, +"url":25, "doc":"The type of the constructor for this class", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.constr", -"url":24, +"url":25, "doc":"The constructor for this class", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.cmp", -"url":24, +"url":25, "doc":"The implementation of comparing this type to type o via operator op. Returns a lambda that expects as first argument the object itself and as second the comparison.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.stringify", -"url":24, +"url":25, "doc":"Returns a stringified version of the object The recursive parameter informs the method whether it was invoked recursively from another invokation", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.binop_type", -"url":24, +"url":25, "doc":"Type of a binary operation between self and other.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.binop", -"url":24, +"url":25, "doc":"Implements a binary operation between self and other", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.unop_type", -"url":24, +"url":25, "doc":"Type of a unary operation on self.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.unop", -"url":24, +"url":25, "doc":"Implements a unary operation on self", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.HashType.id_map", -"url":24, +"url":25, "doc":"Returns a map from the constructor id to a descriptive typestring", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.PythonHashlib", -"url":48, +"url":49, "doc":"An enumeration." }, { "ref":"opshin.rewrite.rewrite_import_hashlib.PythonHashlib.sha256", -"url":48, +"url":49, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.PythonHashlib.sha3_256", -"url":48, +"url":49, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.PythonHashlib.blake2b", -"url":48, +"url":49, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.RewriteImportHashlib", -"url":48, +"url":49, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.RewriteImportHashlib.step", -"url":48, +"url":49, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.RewriteImportHashlib.imports_hashlib", -"url":48, +"url":49, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import_hashlib.RewriteImportHashlib.visit_ImportFrom", -"url":48, +"url":49, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import_hashlib.RewriteImportHashlib.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_tuple_assign", -"url":49, +"url":50, "doc":"" }, { "ref":"opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign", -"url":49, +"url":50, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign.step", -"url":49, +"url":50, "doc":"" }, { "ref":"opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign.unique_id", -"url":49, +"url":50, "doc":"" }, { "ref":"opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign.visit_Assign", -"url":49, +"url":50, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign.visit_For", -"url":49, +"url":50, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_comparison_chaining", -"url":50, +"url":51, "doc":"" }, { "ref":"opshin.rewrite.rewrite_comparison_chaining.RewriteComparisonChaining", -"url":50, +"url":51, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_comparison_chaining.RewriteComparisonChaining.step", -"url":50, +"url":51, "doc":"" }, { "ref":"opshin.rewrite.rewrite_comparison_chaining.RewriteComparisonChaining.visit_Compare", -"url":50, +"url":51, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_comparison_chaining.RewriteComparisonChaining.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_forbidden_return", -"url":51, +"url":52, "doc":"" }, { "ref":"opshin.rewrite.rewrite_forbidden_return.RewriteForbiddenReturn", -"url":51, +"url":52, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_forbidden_return.RewriteForbiddenReturn.step", -"url":51, +"url":52, "doc":"" }, { "ref":"opshin.rewrite.rewrite_forbidden_return.RewriteForbiddenReturn.visit_Return", -"url":51, +"url":52, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_forbidden_return.RewriteForbiddenReturn.visit_FunctionDef", -"url":51, +"url":52, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_forbidden_return.RewriteForbiddenReturn.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import", -"url":52, +"url":53, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import.import_module", -"url":52, +"url":53, "doc":"An approximate implementation of import.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import.RewriteLocation", -"url":52, +"url":53, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import.RewriteLocation.visit", -"url":52, +"url":53, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_import.RewriteImport", -"url":52, +"url":53, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_import.RewriteImport.step", -"url":52, +"url":53, "doc":"" }, { "ref":"opshin.rewrite.rewrite_import.RewriteImport.visit_ImportFrom", -"url":52, +"url":53, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_import.RewriteImport.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.rewrite.rewrite_orig_name", -"url":53, +"url":54, "doc":"" }, { "ref":"opshin.rewrite.rewrite_orig_name.RewriteOrigName", -"url":53, +"url":54, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.rewrite.rewrite_orig_name.RewriteOrigName.step", -"url":53, +"url":54, "doc":"" }, { "ref":"opshin.rewrite.rewrite_orig_name.RewriteOrigName.visit_Name", -"url":53, +"url":54, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_orig_name.RewriteOrigName.visit_ClassDef", -"url":53, +"url":54, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_orig_name.RewriteOrigName.visit_NoneType", -"url":53, +"url":54, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_orig_name.RewriteOrigName.visit_FunctionDef", -"url":53, +"url":54, "doc":"", "func":1 }, { "ref":"opshin.rewrite.rewrite_orig_name.RewriteOrigName.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.std", -"url":54, +"url":55, "doc":"OpShin provides a few features in its standard libary. You can import modules from there (i.e. the fractions module) with from opshin.std.fractions import " }, { "ref":"opshin.std.integrity", -"url":55, +"url":56, "doc":"A special libary that gives access to a function that checks the integrity of PlutusDatum objects." }, { "ref":"opshin.std.integrity.check_integrity", -"url":55, +"url":56, "doc":"Checks the integrity of a PlutusDatum object. In particular, it takes an object of any type and checks that - the constructor id matches the id defined in the type - the fields specified in the type are present - no additional fields are present This has no equivalent in Python.", "func":1 }, { "ref":"opshin.std.builtins", -"url":56, +"url":57, "doc":"A special libary that gives direct access to UPLC built-ins It is valid code and parts of it may be copied if not all built-ins are required by the user." }, { "ref":"opshin.std.builtins.add_integer", -"url":56, +"url":57, "doc":"Adds two integers and returns the result.", "func":1 }, { "ref":"opshin.std.builtins.subtract_integer", -"url":56, +"url":57, "doc":"Subtract fist integer by second and return the result.", "func":1 }, { "ref":"opshin.std.builtins.multiply_integer", -"url":56, +"url":57, "doc":"Multiply 2 integers and return the result.", "func":1 }, { "ref":"opshin.std.builtins.divide_integer", -"url":56, +"url":57, "doc":"Divide first integer by second and return the result.", "func":1 }, { "ref":"opshin.std.builtins.quotient_integer", -"url":56, +"url":57, "doc":"Quotient of first integer by second and return the result.", "func":1 }, { "ref":"opshin.std.builtins.remainder_integer", -"url":56, +"url":57, "doc":"Remainder of first integer by second and return the result.", "func":1 }, { "ref":"opshin.std.builtins.mod_integer", -"url":56, +"url":57, "doc":"Modulus of first integer by second and return the result.", "func":1 }, { "ref":"opshin.std.builtins.equals_integer", -"url":56, +"url":57, "doc":"Equality between two integers.", "func":1 }, { "ref":"opshin.std.builtins.less_than_integer", -"url":56, +"url":57, "doc":"Returns x < y", "func":1 }, { "ref":"opshin.std.builtins.less_than_equals_integer", -"url":56, +"url":57, "doc":"Returns x <= y.", "func":1 }, { "ref":"opshin.std.builtins.append_byte_string", -"url":56, +"url":57, "doc":"Concatenate two bytestrings.", "func":1 }, { "ref":"opshin.std.builtins.cons_byte_string", -"url":56, +"url":57, "doc":"Prepend a byte, represented by a natural number (Integer), to a bytestring.", "func":1 }, { "ref":"opshin.std.builtins.slice_byte_string", -"url":56, +"url":57, "doc":"Slice a bytestring using given indices (inclusive on both ends). The resulting bytestring is z[x:x+y].", "func":1 }, { "ref":"opshin.std.builtins.length_of_byte_string", -"url":56, +"url":57, "doc":"Get the length of a bytestring.", "func":1 }, { "ref":"opshin.std.builtins.index_byte_string", -"url":56, +"url":57, "doc":"Get the byte at given index from a bytestring.", "func":1 }, { "ref":"opshin.std.builtins.equals_byte_string", -"url":56, +"url":57, "doc":"Returns x y.", "func":1 }, { "ref":"opshin.std.builtins.less_than_byte_string", -"url":56, +"url":57, "doc":"Returns x < y.", "func":1 }, { "ref":"opshin.std.builtins.less_than_equals_byte_string", -"url":56, +"url":57, "doc":"Returns x <= y.", "func":1 }, { "ref":"opshin.std.builtins.sha2_256", -"url":56, +"url":57, "doc":"Hash a bytestring using SHA-256.", "func":1 }, { "ref":"opshin.std.builtins.sha3_256", -"url":56, +"url":57, "doc":"Hash a bytestring using SHA3-256.", "func":1 }, { "ref":"opshin.std.builtins.blake2b_256", -"url":56, +"url":57, "doc":"Hash a bytestring using Blake2B-256.", "func":1 }, { "ref":"opshin.std.builtins.verify_ed25519_signature", -"url":56, +"url":57, "doc":"Given PubKey, Message, and Signature, verify the Ed25519 signature.", "func":1 }, { "ref":"opshin.std.builtins.verify_ecdsa_secp256k1_signature", -"url":56, +"url":57, "doc":"Given PubKey, Message, and Signature, verify the ECDSA signature.", "func":1 }, { "ref":"opshin.std.builtins.verify_schnorr_secp256k1_signature", -"url":56, +"url":57, "doc":"Given PubKey, Message, and Signature, verify the Schnorr signature.", "func":1 }, { "ref":"opshin.std.builtins.append_string", -"url":56, +"url":57, "doc":"Concatenate two strings/texts.", "func":1 }, { "ref":"opshin.std.builtins.equals_string", -"url":56, +"url":57, "doc":"Returns x y.", "func":1 }, { "ref":"opshin.std.builtins.encode_utf8", -"url":56, +"url":57, "doc":"Encode a string/text using UTF-8.", "func":1 }, { "ref":"opshin.std.builtins.decode_utf8", -"url":56, +"url":57, "doc":"Decode a string/text using UTF-8.", "func":1 }, { "ref":"opshin.std.builtins.constr_data", -"url":56, +"url":57, "doc":"Create a datum with constructor id x and fields y.", "func":1 }, { "ref":"opshin.std.builtins.equals_data", -"url":56, +"url":57, "doc":"Equality between two complex classes.", "func":1 }, { "ref":"opshin.std.builtins.serialise_data", -"url":56, +"url":57, "doc":"Serialize a datum into its CBOR representation.", "func":1 }, { "ref":"opshin.std.bitmap", -"url":57, +"url":58, "doc":"The BitMap library provides tools to interact with a highly efficient datastructure that stores boolean values with minimal overhead (1 bit per bool)" }, { "ref":"opshin.std.bitmap.init_bitmap", -"url":57, +"url":58, "doc":"Creates an empty bitmap with size bits", "func":1 }, { "ref":"opshin.std.bitmap.test_bitmap", -"url":57, +"url":58, "doc":"Tests if bit at position i has been set to 1", "func":1 }, { "ref":"opshin.std.bitmap.set_bitmap", -"url":57, +"url":58, "doc":"Sets a bit in the bitmap to 1", "func":1 }, { "ref":"opshin.std.bitmap.reset_bitmap", -"url":57, +"url":58, "doc":"Sets a bit in the bitmap to 0", "func":1 }, { "ref":"opshin.std.bitmap.flip_bitmap", -"url":57, +"url":58, "doc":"Flips a bit in the bitmap", "func":1 }, { "ref":"opshin.std.bitmap.size_bitmap", -"url":57, +"url":58, "doc":"Returns the size of the bitmap in bits", "func":1 }, { "ref":"opshin.std.bitmap.any_bitmap", -"url":57, +"url":58, "doc":"Returns whether any bit was set to 1", "func":1 }, { "ref":"opshin.std.bitmap.all_bitmap", -"url":57, +"url":58, "doc":"Returns whether all bits were set to 1", "func":1 }, { "ref":"opshin.std.bitmap.none_bitmap", -"url":57, +"url":58, "doc":"Returns whether no bits were set to 1", "func":1 }, { "ref":"opshin.std.math", -"url":58, +"url":59, "doc":"An implementation of some math operations in opshin" }, { "ref":"opshin.std.math.gcd", -"url":58, +"url":59, "doc":"", "func":1 }, { "ref":"opshin.std.math.sign", -"url":58, +"url":59, "doc":"", "func":1 }, { "ref":"opshin.std.math.unsigned_int_from_bytes_big", -"url":58, +"url":59, "doc":"Converts a bytestring into the corresponding integer, big/network byteorder, unsigned", "func":1 }, { "ref":"opshin.std.math.bytes_big_from_unsigned_int", -"url":58, +"url":59, "doc":"Converts an integer into the corresponding bytestring, big/network byteorder, unsigned", "func":1 }, { "ref":"opshin.std.math.ceil", -"url":58, +"url":59, "doc":"Returns a divided by b rounded towards positive infinity", "func":1 }, { "ref":"opshin.std.math.floor", -"url":58, +"url":59, "doc":"Returns a divided by b rounded towards negative infinity", "func":1 }, { "ref":"opshin.std.hashlib", -"url":59, +"url":60, "doc":"A std library that imports all valid hash functions from the builtin python hashlib library: If you want to have all hash functions in scope, simply add from opshin.std.hashlib import to the top of you python file." }, { "ref":"opshin.std.fractions", -"url":60, +"url":61, "doc":"An implementation of fractions in opshin This does not maintain smallest possible notation invariants for the sake of efficiency - the user has full control over when to normalize the fractions and should do so using norm_fraction" }, { "ref":"opshin.std.fractions.Fraction", -"url":60, +"url":61, "doc":"Fraction(numerator: int, denominator: int)" }, { "ref":"opshin.std.fractions.Fraction.numerator", -"url":60, +"url":61, "doc":"" }, { "ref":"opshin.std.fractions.Fraction.denominator", -"url":60, +"url":61, "doc":"" }, { "ref":"opshin.std.fractions.Fraction.CONSTR_ID", -"url":60, +"url":61, "doc":"" }, { "ref":"opshin.std.fractions.add_fraction", -"url":60, +"url":61, "doc":"returns a + b", "func":1 }, { "ref":"opshin.std.fractions.neg_fraction", -"url":60, +"url":61, "doc":"returns -a", "func":1 }, { "ref":"opshin.std.fractions.sub_fraction", -"url":60, +"url":61, "doc":"returns a - b", "func":1 }, { "ref":"opshin.std.fractions.mul_fraction", -"url":60, +"url":61, "doc":"returns a b", "func":1 }, { "ref":"opshin.std.fractions.div_fraction", -"url":60, +"url":61, "doc":"returns a / b", "func":1 }, { "ref":"opshin.std.fractions.norm_fraction", -"url":60, +"url":61, "doc":"Restores the invariant that num/denom are in the smallest possible denomination and denominator > 0", "func":1 }, { "ref":"opshin.std.fractions.ge_fraction", -"url":60, +"url":61, "doc":"returns a >= b", "func":1 }, { "ref":"opshin.std.fractions.le_fraction", -"url":60, +"url":61, "doc":"returns a <= b", "func":1 }, { "ref":"opshin.std.fractions.eq_fraction", -"url":60, +"url":61, "doc":"returns a b", "func":1 }, { "ref":"opshin.std.fractions.lt_fraction", -"url":60, +"url":61, "doc":"returns a < b", "func":1 }, { "ref":"opshin.std.fractions.gt_fraction", -"url":60, +"url":61, "doc":"returns a > b", "func":1 }, { "ref":"opshin.std.fractions.floor_fraction", -"url":60, +"url":61, "doc":"", "func":1 }, { "ref":"opshin.std.fractions.ceil_fraction", -"url":60, +"url":61, "doc":"", "func":1 }, { "ref":"opshin.type_inference", -"url":61, +"url":62, "doc":"An aggressive type inference based on the work of Aycock [1]. It only allows a subset of legal python operations which allow us to infer the type of all involved variables statically. Using this we can resolve overloaded functions when translating Python into UPLC where there is no dynamic type checking. Additionally, this conveniently implements an additional layer of security into the Smart Contract by checking type correctness. [1]: https: legacy.python.org/workshops/2000-01/proceedings/papers/aycock/aycock.html" }, { "ref":"opshin.type_inference.record_from_plutusdata", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.constant_type", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.union_types", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.intersection_types", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.TypeCheckVisitor", -"url":61, +"url":62, "doc":"Generates the types to which objects are cast due to a boolean expression It returns a tuple of dictionaries which are a name -> type mapping for variable names that are assured to have a specific type if this expression is True/False respectively" }, { "ref":"opshin.type_inference.TypeCheckVisitor.generic_visit", -"url":61, +"url":62, "doc":"Called if no explicit visitor function exists for a node.", "func":1 }, { "ref":"opshin.type_inference.TypeCheckVisitor.visit_Call", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.TypeCheckVisitor.visit_BoolOp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.TypeCheckVisitor.visit_UnaryOp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.TypeCheckVisitor.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.type_inference.merge_scope", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer", -"url":61, +"url":62, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.step", -"url":61, +"url":62, "doc":"" }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.scopes", -"url":61, +"url":62, "doc":"" }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.variable_type", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.enter_scope", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.exit_scope", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.set_variable_type", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.implement_typechecks", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.type_from_annotation", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_sequence", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_ClassDef", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Constant", -"url":61, +"url":62, +"doc":"", +"func":1 +}, +{ +"ref":"opshin.type_inference.AggressiveTypeInferencer.visit_NoneType", +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Tuple", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_List", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Dict", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Assign", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_AnnAssign", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_If", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_While", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_For", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Name", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Compare", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_arg", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_arguments", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_FunctionDef", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Module", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Expr", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_BinOp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_BoolOp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_UnaryOp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Subscript", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Call", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Pass", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Return", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Attribute", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_Assert", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_RawPlutoExpr", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_IfExp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_comprehension", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_ListComp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_DictComp", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_FormattedValue", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_JoinedStr", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit_ImportFrom", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.generic_visit", -"url":61, +"url":62, "doc":"Called if no explicit visitor function exists for a node.", "func":1 }, { "ref":"opshin.type_inference.AggressiveTypeInferencer.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.type_inference.RecordReader", -"url":61, +"url":62, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.type_inference.RecordReader.name", -"url":61, +"url":62, "doc":"" }, { "ref":"opshin.type_inference.RecordReader.orig_name", -"url":61, +"url":62, "doc":"" }, { "ref":"opshin.type_inference.RecordReader.constructor", -"url":61, +"url":62, "doc":"" }, { "ref":"opshin.type_inference.RecordReader.attributes", -"url":61, +"url":62, "doc":"" }, { "ref":"opshin.type_inference.RecordReader.extract", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.RecordReader.visit_AnnAssign", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.RecordReader.visit_ClassDef", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.RecordReader.visit_Pass", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.RecordReader.visit_Assign", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.RecordReader.visit_Expr", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.RecordReader.generic_visit", -"url":61, +"url":62, "doc":"Called if no explicit visitor function exists for a node.", "func":1 }, { "ref":"opshin.type_inference.typed_ast", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.map_to_orig_name", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.ReturnExtractor", -"url":61, +"url":62, "doc":"Utility to check that all paths end in Return statements with the proper type Returns whether there is no remaining path" }, { "ref":"opshin.type_inference.ReturnExtractor.visit_sequence", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.ReturnExtractor.visit_If", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.ReturnExtractor.visit_For", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.ReturnExtractor.visit_While", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.ReturnExtractor.visit_Return", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.ReturnExtractor.check_fulfills", -"url":61, +"url":62, "doc":"", "func":1 }, { "ref":"opshin.type_inference.ReturnExtractor.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util", -"url":27, +"url":28, +"doc":"" +}, +{ +"ref":"opshin.util.FileContextFilter", +"url":28, +"doc":"This is a filter which injects contextual information into the log. The information is about the currently inspected AST node. The information needs to be updated inside the NodeTransformer and NodeVisitor classes. Initialize a filter. Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event." +}, +{ +"ref":"opshin.util.FileContextFilter.file_name", +"url":28, +"doc":"" +}, +{ +"ref":"opshin.util.FileContextFilter.node", +"url":28, "doc":"" }, { +"ref":"opshin.util.FileContextFilter.filter", +"url":28, +"doc":"Determine if the specified record is to be logged. Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.", +"func":1 +}, +{ "ref":"opshin.util.distinct", -"url":27, +"url":28, "doc":"Returns true iff the list consists of distinct elements", "func":1 }, { "ref":"opshin.util.TypedNodeTransformer", -"url":27, +"url":28, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.util.TypedNodeTransformer.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util.TypedNodeVisitor", -"url":27, +"url":28, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.util.TypedNodeVisitor.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util.CompilerError", -"url":27, +"url":28, "doc":"Common base class for all non-exit exceptions." }, { "ref":"opshin.util.CompilingNodeTransformer", -"url":27, +"url":28, "doc":"A :class: NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes. The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None , the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups ( foo ) to data['foo'] class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load( , slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth: generic_visit method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this node = YourTransformer().visit(node)" }, { "ref":"opshin.util.CompilingNodeTransformer.step", -"url":27, +"url":28, "doc":"" }, { "ref":"opshin.util.CompilingNodeTransformer.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util.NoOp", -"url":27, +"url":28, "doc":"A variation of the Compiling Node transformer that performs no changes" }, { "ref":"opshin.util.NoOp.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util.CompilingNodeVisitor", -"url":27, +"url":28, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.util.CompilingNodeVisitor.step", -"url":27, +"url":28, "doc":"" }, { "ref":"opshin.util.CompilingNodeVisitor.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util.data_from_json", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.datum_to_cbor", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.datum_to_json", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.custom_fix_missing_locations", -"url":27, +"url":28, "doc":"Works like ast.fix_missing_location but forces it onto everything", "func":1 }, { "ref":"opshin.util.make_pattern", -"url":27, +"url":28, "doc":"Creates a shared pattern from the given lambda, cached so that it is re-used in subsequent calls", "func":1 }, { "ref":"opshin.util.patternize", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.force_params", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameWriteCollector", -"url":27, +"url":28, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.util.NameWriteCollector.step", -"url":27, +"url":28, "doc":"" }, { "ref":"opshin.util.NameWriteCollector.visit_Name", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameWriteCollector.visit_ClassDef", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameWriteCollector.visit_FunctionDef", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameWriteCollector.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util.written_vars", -"url":27, +"url":28, "doc":"Returns all variable names written to in this node", "func":1 }, { "ref":"opshin.util.NameReadCollector", -"url":27, +"url":28, "doc":"A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the visit method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are 'visit_' + class name of the node. So a TryFinally node visit function would be visit_TryFinally . This behavior can be changed by overriding the visit method. If no visitor function exists for a node (return value None ) the generic_visit visitor is used instead. Don't use the NodeVisitor if you want to apply changes to nodes during traversing. For this a special visitor exists ( NodeTransformer ) that allows modifications." }, { "ref":"opshin.util.NameReadCollector.step", -"url":27, +"url":28, "doc":"" }, { "ref":"opshin.util.NameReadCollector.visit_AnnAssign", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameReadCollector.visit_FunctionDef", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameReadCollector.visit_Name", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameReadCollector.visit_ClassDef", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.NameReadCollector.visit", -"url":27, +"url":28, "doc":"Visit a node.", "func":1 }, { "ref":"opshin.util.read_vars", -"url":27, +"url":28, "doc":"Returns all variable names read to in this node", "func":1 }, { "ref":"opshin.util.all_vars", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.externally_bound_vars", -"url":27, +"url":28, "doc":"A superset of the variables bound from an outer scope", "func":1 }, { "ref":"opshin.util.opshin_name_scheme_compatible_varname", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.OVar", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.OLambda", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.OLet", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.SafeLambda", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.SafeOLambda", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.util.SafeApply", -"url":27, +"url":28, "doc":"", "func":1 }, { "ref":"opshin.prelude", -"url":62, +"url":63, "doc":"" }, { "ref":"opshin.prelude.Nothing", -"url":62, +"url":63, "doc":"Nothing, can be used to signify non-importance of a parameter to a function Example value: Nothing()" }, { "ref":"opshin.prelude.Nothing.CONSTR_ID", -"url":62, +"url":63, "doc":"" }, { "ref":"opshin.prelude.Token", -"url":62, +"url":63, "doc":"A token, represented by policy id and token name" }, { "ref":"opshin.prelude.Token.policy_id", -"url":62, +"url":63, "doc":"" }, { "ref":"opshin.prelude.Token.token_name", -"url":62, +"url":63, "doc":"" }, { "ref":"opshin.prelude.Token.CONSTR_ID", -"url":62, +"url":63, "doc":"" }, { "ref":"opshin.prelude.Nothing", -"url":62, +"url":63, "doc":"Nothing, can be used to signify non-importance of a parameter to a function Example value: Nothing()" }, { "ref":"opshin.prelude.Nothing.CONSTR_ID", -"url":62, +"url":63, "doc":"" }, { "ref":"opshin.prelude.all_tokens_unlocked_from_address", -"url":62, +"url":63, "doc":"Returns how many tokens of specified type are unlocked from given address", "func":1 }, { "ref":"opshin.prelude.all_tokens_locked_at_address_with_datum", -"url":62, +"url":63, "doc":"Returns how many tokens of specified type are locked at then given address with the specified datum", "func":1 }, { "ref":"opshin.prelude.all_tokens_locked_at_address", -"url":62, +"url":63, "doc":"Returns how many tokens of specified type are locked at the given address", "func":1 }, { "ref":"opshin.prelude.resolve_spent_utxo", -"url":62, +"url":63, "doc":"Returns the UTxO whose spending should be validated", "func":1 }, { "ref":"opshin.prelude.resolve_datum_unsafe", -"url":62, +"url":63, "doc":"Returns the datum attached to a given transaction output, independent of whether it was inlined or embedded. Raises an exception if no datum was attached.", "func":1 }, { "ref":"opshin.prelude.resolve_datum", -"url":62, +"url":63, "doc":"Returns SomeOutputDatum with the datum attached to a given transaction output, independent of whether it was inlined or embedded, if there was an attached datum. Otherwise it returns NoOutputDatum.", "func":1 }, { "ref":"opshin.prelude.own_spent_utxo", -"url":62, +"url":63, "doc":"", "func":1 }, { "ref":"opshin.prelude.own_policy_id", -"url":62, +"url":63, "doc":"obtain the policy id for which this contract can validate minting/burning", "func":1 }, { "ref":"opshin.prelude.own_address", -"url":62, +"url":63, "doc":"Computes the spending script address corresponding to the given policy ID", "func":1 }, { "ref":"opshin.prelude.token_present_in_inputs", -"url":62, +"url":63, "doc":"Returns whether the given token is spent in one of the inputs of the transaction", "func":1 } diff --git a/docs/opshin/builder.html b/docs/opshin/builder.html index 5055b4aa..0c26733a 100644 --- a/docs/opshin/builder.html +++ b/docs/opshin/builder.html @@ -81,7 +81,7 @@

Module opshin.builder

from pycardano import PlutusV2Script, IndefiniteList, PlutusData, Datum -from . import __version__, compiler +from . import __version__, compiler, DEFAULT_CONFIG import uplc.ast from uplc import flatten, ast as uplc_ast, eval as uplc_eval @@ -258,23 +258,16 @@

Module opshin.builder

def compile( program: Module, contract_filename: Optional[str] = None, - force_three_params=False, validator_function_name="validator", - remove_dead_code=True, - constant_folding=False, - allow_isinstance_anything=False, - **pluto_kwargs: Any, + config=DEFAULT_CONFIG, ) -> uplc_ast.Program: code = compiler.compile( program, filename=contract_filename, - force_three_params=force_three_params, validator_function_name=validator_function_name, - remove_dead_code=remove_dead_code, - constant_folding=constant_folding, - allow_isinstance_anything=allow_isinstance_anything, + config=config, ) - plt_code = plt_compile(code, **pluto_kwargs) + plt_code = plt_compile(code, config) return plt_code @@ -282,12 +275,8 @@

Module opshin.builder

def _static_compile( source_code: str, contract_file: str = "<unknown>", - force_three_params=False, validator_function_name="validator", - optimize_patterns=True, - remove_dead_code=True, - constant_folding=False, - allow_isinstance_anything=False, + config=DEFAULT_CONFIG, ): """ Expects a python module and returns the build artifacts from compiling it @@ -297,12 +286,8 @@

Module opshin.builder

code = compile( source_ast, contract_filename=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, - remove_dead_code=remove_dead_code, - constant_folding=constant_folding, - allow_isinstance_anything=allow_isinstance_anything, + config=config, ) return code @@ -311,12 +296,8 @@

Module opshin.builder

source_code: str, *args: typing.Union[pycardano.Datum, uplc_ast.Constant], contract_file: str = "<unknown>", - force_three_params=False, validator_function_name="validator", - optimize_patterns=True, - remove_dead_code=True, - constant_folding=False, - allow_isinstance_anything=False, + config=DEFAULT_CONFIG, ): """ Expects a python module and returns the build artifacts from compiling it @@ -325,12 +306,8 @@

Module opshin.builder

code = _static_compile( source_code, contract_file=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, - remove_dead_code=remove_dead_code, - constant_folding=constant_folding, - allow_isinstance_anything=allow_isinstance_anything, + config=config, ) code = _apply_parameters(code, *args) return code @@ -339,9 +316,8 @@

Module opshin.builder

def build( contract_file: str, *args: typing.Union[pycardano.Datum, uplc_ast.Constant], - force_three_params=False, validator_function_name="validator", - optimize_patterns=True, + config=DEFAULT_CONFIG, ): """ Expects a python module and returns the build artifacts from compiling it @@ -352,9 +328,8 @@

Module opshin.builder

source_code, *args, contract_file=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, + config=config, ) return _build(code) @@ -640,7 +615,7 @@

Functions

-def build(contract_file: str, *args: Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData, uplc.ast.Constant], force_three_params=False, validator_function_name='validator', optimize_patterns=True) +def build(contract_file: str, *args: Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData, uplc.ast.Constant], validator_function_name='validator', config=CompilationConfig(compress_patterns=False, iterative_unfold_patterns=False, constant_index_access_list=True, constant_folding=False, allow_isinstance_anything=False, force_three_params=False, remove_dead_code=True))

Expects a python module and returns the build artifacts from compiling it

@@ -651,9 +626,8 @@

Functions

def build(
     contract_file: str,
     *args: typing.Union[pycardano.Datum, uplc_ast.Constant],
-    force_three_params=False,
     validator_function_name="validator",
-    optimize_patterns=True,
+    config=DEFAULT_CONFIG,
 ):
     """
     Expects a python module and returns the build artifacts from compiling it
@@ -664,15 +638,14 @@ 

Functions

source_code, *args, contract_file=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, + config=config, ) return _build(code)
-def compile(program: ast.Module, contract_filename: Optional[str] = None, force_three_params=False, validator_function_name='validator', remove_dead_code=True, constant_folding=False, allow_isinstance_anything=False, **pluto_kwargs: Any) ‑> uplc.ast.Program +def compile(program: ast.Module, contract_filename: Optional[str] = None, validator_function_name='validator', config=CompilationConfig(compress_patterns=False, iterative_unfold_patterns=False, constant_index_access_list=True, constant_folding=False, allow_isinstance_anything=False, force_three_params=False, remove_dead_code=True)) ‑> uplc.ast.Program
@@ -683,23 +656,16 @@

Functions

def compile(
     program: Module,
     contract_filename: Optional[str] = None,
-    force_three_params=False,
     validator_function_name="validator",
-    remove_dead_code=True,
-    constant_folding=False,
-    allow_isinstance_anything=False,
-    **pluto_kwargs: Any,
+    config=DEFAULT_CONFIG,
 ) -> uplc_ast.Program:
     code = compiler.compile(
         program,
         filename=contract_filename,
-        force_three_params=force_three_params,
         validator_function_name=validator_function_name,
-        remove_dead_code=remove_dead_code,
-        constant_folding=constant_folding,
-        allow_isinstance_anything=allow_isinstance_anything,
+        config=config,
     )
-    plt_code = plt_compile(code, **pluto_kwargs)
+    plt_code = plt_compile(code, config)
     return plt_code
@@ -964,10 +930,10 @@

Classes

class PlutusContract -(contract: pycardano.plutus.PlutusV2Script, datum_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, redeemer_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, parameter_types: List[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = <factory>, purpose: Iterable[Purpose] = (<Purpose.any: 'any'>,), version: Optional[str] = '1.0.0', title: str = 'validator', description: Optional[str] = 'opshin 0.19.1 Smart Contract', license: Optional[str] = None) +(contract: pycardano.plutus.PlutusV2Script, datum_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, redeemer_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, parameter_types: List[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = <factory>, purpose: Iterable[Purpose] = (<Purpose.any: 'any'>,), version: Optional[str] = '1.0.0', title: str = 'validator', description: Optional[str] = 'opshin 0.21.0 Smart Contract', license: Optional[str] = None)
-

PlutusContract(contract: pycardano.plutus.PlutusV2Script, datum_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, redeemer_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, parameter_types: List[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = , purpose: Iterable[opshin.builder.Purpose] = (,), version: Optional[str] = '1.0.0', title: str = 'validator', description: Optional[str] = 'opshin 0.19.1 Smart Contract', license: Optional[str] = None)

+

PlutusContract(contract: pycardano.plutus.PlutusV2Script, datum_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, redeemer_type: Optional[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = None, parameter_types: List[Tuple[str, Type[Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData]]]] = , purpose: Iterable[opshin.builder.Purpose] = (,), version: Optional[str] = '1.0.0', title: str = 'validator', description: Optional[str] = 'opshin 0.21.0 Smart Contract', license: Optional[str] = None)

Expand source code diff --git a/docs/opshin/compiler.html b/docs/opshin/compiler.html index e06baee9..c9dee71a 100644 --- a/docs/opshin/compiler.html +++ b/docs/opshin/compiler.html @@ -71,6 +71,8 @@

Module opshin.compiler

import copy
 
 from uplc.ast import data_from_cbor
+
+from .compiler_config import DEFAULT_CONFIG
 from .optimize.optimize_const_folding import OptimizeConstantFolding
 from .optimize.optimize_remove_comments import OptimizeRemoveDeadconstants
 from .rewrite.rewrite_augassign import RewriteAugAssign
@@ -107,8 +109,6 @@ 

Module opshin.compiler

RawPlutoExpr, ) -_LOGGER = logging.getLogger(__name__) - BoolOpMap = { And: plt.And, @@ -300,7 +300,7 @@

Module opshin.compiler

else: possible_types = [second_last_arg.typ] if any(isinstance(t, UnitType) for t in possible_types): - _LOGGER.warning( + OPSHIN_LOGGER.warning( "The redeemer is annotated to be 'None'. This value is usually encoded in PlutusData with constructor id 0 and no fields. If you want the script to double function as minting and spending script, annotate the second argument with 'NoRedeemer'." ) enable_double_func_mint_spend = not any( @@ -309,7 +309,7 @@

Module opshin.compiler

for t in possible_types ) if not enable_double_func_mint_spend: - _LOGGER.warning( + OPSHIN_LOGGER.warning( "The second argument to the validator function potentially has constructor id 0. The validator will not be able to double function as minting script and spending script." ) @@ -401,7 +401,7 @@

Module opshin.compiler

except ValueError: pass else: - _LOGGER.warning( + OPSHIN_LOGGER.warning( f"The string {node.value} looks like it is supposed to be a hex-encoded bytestring but is actually utf8-encoded. Try using `bytes.fromhex('{node.value.decode()}')` instead." ) plt_val = plt.UPLCConstant(rec_constant_map(node.value)) @@ -1097,18 +1097,15 @@

Module opshin.compiler

def compile( prog: AST, filename=None, - force_three_params=False, - remove_dead_code=True, - constant_folding=False, validator_function_name="validator", - allow_isinstance_anything=False, + config=DEFAULT_CONFIG, ) -> plt.Program: compile_pipeline = [ # Important to call this one first - it imports all further files RewriteImport(filename=filename), # Rewrites that simplify the python code RewriteForbiddenReturn(), - OptimizeConstantFolding() if constant_folding else NoOp(), + OptimizeConstantFolding() if config.constant_folding else NoOp(), RewriteSubscript38(), RewriteAugAssign(), RewriteComparisonChaining(), @@ -1125,7 +1122,7 @@

Module opshin.compiler

RewriteOrigName(), RewriteScoping(), # The type inference needs to be run after complex python operations were rewritten - AggressiveTypeInferencer(allow_isinstance_anything), + AggressiveTypeInferencer(config.allow_isinstance_anything), # Rewrites that circumvent the type inference or use its results RewriteEmptyLists(), RewriteEmptyDicts(), @@ -1133,8 +1130,8 @@

Module opshin.compiler

RewriteInjectBuiltinsConstr(), RewriteRemoveTypeStuff(), # Apply optimizations - OptimizeRemoveDeadvars() if remove_dead_code else NoOp(), - OptimizeRemoveDeadconstants(), + OptimizeRemoveDeadvars() if config.remove_dead_code else NoOp(), + OptimizeRemoveDeadconstants() if config.remove_dead_code else NoOp(), OptimizeRemovePass(), ] for s in compile_pipeline: @@ -1143,7 +1140,7 @@

Module opshin.compiler

# the compiler runs last s = PlutoCompiler( - force_three_params=force_three_params, + force_three_params=config.force_three_params, validator_function_name=validator_function_name, ) prog = s.visit(prog) @@ -1159,7 +1156,7 @@

Module opshin.compiler

Functions

-def compile(prog: ast.AST, filename=None, force_three_params=False, remove_dead_code=True, constant_folding=False, validator_function_name='validator', allow_isinstance_anything=False) ‑> pluthon.pluthon_ast.Program +def compile(prog: ast.AST, filename=None, validator_function_name='validator', config=CompilationConfig(compress_patterns=False, iterative_unfold_patterns=False, constant_index_access_list=True, constant_folding=False, allow_isinstance_anything=False, force_three_params=False, remove_dead_code=True)) ‑> pluthon.pluthon_ast.Program
@@ -1170,18 +1167,15 @@

Functions

def compile(
     prog: AST,
     filename=None,
-    force_three_params=False,
-    remove_dead_code=True,
-    constant_folding=False,
     validator_function_name="validator",
-    allow_isinstance_anything=False,
+    config=DEFAULT_CONFIG,
 ) -> plt.Program:
     compile_pipeline = [
         # Important to call this one first - it imports all further files
         RewriteImport(filename=filename),
         # Rewrites that simplify the python code
         RewriteForbiddenReturn(),
-        OptimizeConstantFolding() if constant_folding else NoOp(),
+        OptimizeConstantFolding() if config.constant_folding else NoOp(),
         RewriteSubscript38(),
         RewriteAugAssign(),
         RewriteComparisonChaining(),
@@ -1198,7 +1192,7 @@ 

Functions

RewriteOrigName(), RewriteScoping(), # The type inference needs to be run after complex python operations were rewritten - AggressiveTypeInferencer(allow_isinstance_anything), + AggressiveTypeInferencer(config.allow_isinstance_anything), # Rewrites that circumvent the type inference or use its results RewriteEmptyLists(), RewriteEmptyDicts(), @@ -1206,8 +1200,8 @@

Functions

RewriteInjectBuiltinsConstr(), RewriteRemoveTypeStuff(), # Apply optimizations - OptimizeRemoveDeadvars() if remove_dead_code else NoOp(), - OptimizeRemoveDeadconstants(), + OptimizeRemoveDeadvars() if config.remove_dead_code else NoOp(), + OptimizeRemoveDeadconstants() if config.remove_dead_code else NoOp(), OptimizeRemovePass(), ] for s in compile_pipeline: @@ -1216,7 +1210,7 @@

Functions

# the compiler runs last s = PlutoCompiler( - force_three_params=force_three_params, + force_three_params=config.force_three_params, validator_function_name=validator_function_name, ) prog = s.visit(prog) @@ -1448,7 +1442,7 @@

Classes

else: possible_types = [second_last_arg.typ] if any(isinstance(t, UnitType) for t in possible_types): - _LOGGER.warning( + OPSHIN_LOGGER.warning( "The redeemer is annotated to be 'None'. This value is usually encoded in PlutusData with constructor id 0 and no fields. If you want the script to double function as minting and spending script, annotate the second argument with 'NoRedeemer'." ) enable_double_func_mint_spend = not any( @@ -1457,7 +1451,7 @@

Classes

for t in possible_types ) if not enable_double_func_mint_spend: - _LOGGER.warning( + OPSHIN_LOGGER.warning( "The second argument to the validator function potentially has constructor id 0. The validator will not be able to double function as minting script and spending script." ) @@ -1549,7 +1543,7 @@

Classes

except ValueError: pass else: - _LOGGER.warning( + OPSHIN_LOGGER.warning( f"The string {node.value} looks like it is supposed to be a hex-encoded bytestring but is actually utf8-encoded. Try using `bytes.fromhex('{node.value.decode()}')` instead." ) plt_val = plt.UPLCConstant(rec_constant_map(node.value)) @@ -2530,7 +2524,7 @@

Methods

except ValueError: pass else: - _LOGGER.warning( + OPSHIN_LOGGER.warning( f"The string {node.value} looks like it is supposed to be a hex-encoded bytestring but is actually utf8-encoded. Try using `bytes.fromhex('{node.value.decode()}')` instead." ) plt_val = plt.UPLCConstant(rec_constant_map(node.value)) @@ -2944,7 +2938,7 @@

Methods

else: possible_types = [second_last_arg.typ] if any(isinstance(t, UnitType) for t in possible_types): - _LOGGER.warning( + OPSHIN_LOGGER.warning( "The redeemer is annotated to be 'None'. This value is usually encoded in PlutusData with constructor id 0 and no fields. If you want the script to double function as minting and spending script, annotate the second argument with 'NoRedeemer'." ) enable_double_func_mint_spend = not any( @@ -2953,7 +2947,7 @@

Methods

for t in possible_types ) if not enable_double_func_mint_spend: - _LOGGER.warning( + OPSHIN_LOGGER.warning( "The second argument to the validator function potentially has constructor id 0. The validator will not be able to double function as minting script and spending script." ) diff --git a/docs/opshin/compiler_config.html b/docs/opshin/compiler_config.html new file mode 100644 index 00000000..e7b1f1d5 --- /dev/null +++ b/docs/opshin/compiler_config.html @@ -0,0 +1,282 @@ + + + + + + + + +opshin.compiler_config API documentation + + + + + + + + + + + +
+ + + + +
+
+

Module opshin.compiler_config

+
+
+
+ +Expand source code + +
from dataclasses import dataclass
+from typing import Optional
+
+import pluthon
+
+
+@dataclass(frozen=True)
+class CompilationConfig(pluthon.CompilationConfig):
+    constant_folding: Optional[bool] = None
+    allow_isinstance_anything: Optional[bool] = None
+    force_three_params: Optional[bool] = None
+    remove_dead_code: Optional[bool] = None
+
+
+# The default configuration for the compiler
+OPT_O0_CONFIG = (
+    CompilationConfig()
+    .update(pluthon.OPT_O0_CONFIG)
+    .update(
+        constant_folding=False,
+        remove_dead_code=False,
+    )
+)
+OPT_O1_CONFIG = (
+    CompilationConfig()
+    .update(pluthon.OPT_O1_CONFIG)
+    .update(OPT_O0_CONFIG)
+    .update(
+        remove_dead_code=True,
+    )
+)
+OPT_O2_CONFIG = (
+    CompilationConfig()
+    .update(pluthon.OPT_O2_CONFIG)
+    .update(OPT_O1_CONFIG)
+    .update(
+        constant_folding=True,
+    )
+)
+OPT_O3_CONFIG = (
+    CompilationConfig().update(pluthon.OPT_O3_CONFIG).update(OPT_O2_CONFIG).update()
+)
+OPT_CONFIGS = [OPT_O0_CONFIG, OPT_O1_CONFIG, OPT_O2_CONFIG, OPT_O3_CONFIG]
+
+DEFAULT_CONFIG = CompilationConfig(
+    allow_isinstance_anything=False,
+    force_three_params=False,
+).update(OPT_O1_CONFIG)
+
+ARGPARSE_ARGS = pluthon.ARGPARSE_ARGS.copy()
+ARGPARSE_ARGS.update(
+    {
+        "constant_folding": {
+            "__alts__": ["--cf"],
+            "help": "Enables experimental constant folding, including propagation and code execution.",
+        },
+        "allow_isinstance_anything": {
+            "help": "Enables the use of isinstance(x, D) in the contract where x is of type Anything. This is not recommended as it only checks the constructor id and not the actual type of the data.",
+        },
+        "force_three_params": {
+            "__alts__": ["--ftp"],
+            "help": "Enforces that the contract is always called with three virtual parameters on-chain. Enable if the script should support spending and other purposes.",
+        },
+        "remove_dead_code": {
+            "help": "Removes dead code and variables from the contract. Should be enabled for non-debugging purposes.",
+        },
+    }
+)
+for k in ARGPARSE_ARGS:
+    assert (
+        k in DEFAULT_CONFIG.__dict__
+    ), f"Key {k} not found in CompilationConfig.__dict__"
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class CompilationConfig +(compress_patterns: Optional[bool] = None, iterative_unfold_patterns: Optional[bool] = None, constant_index_access_list: Optional[bool] = None, constant_folding: Optional[bool] = None, allow_isinstance_anything: Optional[bool] = None, force_three_params: Optional[bool] = None, remove_dead_code: Optional[bool] = None) +
+
+

CompilationConfig(compress_patterns: Optional[bool] = None, iterative_unfold_patterns: Optional[bool] = None, constant_index_access_list: Optional[bool] = None, constant_folding: Optional[bool] = None, allow_isinstance_anything: Optional[bool] = None, force_three_params: Optional[bool] = None, remove_dead_code: Optional[bool] = None)

+
+ +Expand source code + +
@dataclass(frozen=True)
+class CompilationConfig(pluthon.CompilationConfig):
+    constant_folding: Optional[bool] = None
+    allow_isinstance_anything: Optional[bool] = None
+    force_three_params: Optional[bool] = None
+    remove_dead_code: Optional[bool] = None
+
+

Ancestors

+
    +
  • pluthon.compiler_config.CompilationConfig
  • +
+

Class variables

+
+
var allow_isinstance_anything : Optional[bool]
+
+
+
+
var constant_folding : Optional[bool]
+
+
+
+
var force_three_params : Optional[bool]
+
+
+
+
var remove_dead_code : Optional[bool]
+
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/opshin/index.html b/docs/opshin/index.html index b7f92ccb..25084b59 100644 --- a/docs/opshin/index.html +++ b/docs/opshin/index.html @@ -193,7 +193,7 @@

Supporters

import warnings -__version__ = "0.19.1" +__version__ = "0.21.0" __author__ = "nielstron" __author_email__ = "n.muendler@web.de" __copyright__ = "Copyright (C) 2023 nielstron" @@ -222,6 +222,10 @@

Sub-modules

+
opshin.compiler_config
+
+
+
opshin.fun_impls
@@ -361,6 +365,7 @@

Index

  • opshin.bridge
  • opshin.builder
  • opshin.compiler
  • +
  • opshin.compiler_config
  • opshin.fun_impls
  • opshin.ledger
  • opshin.optimize
  • diff --git a/docs/opshin/optimize/optimize_const_folding.html b/docs/opshin/optimize/optimize_const_folding.html index bb67a25f..cbd9fdb1 100644 --- a/docs/opshin/optimize/optimize_const_folding.html +++ b/docs/opshin/optimize/optimize_const_folding.html @@ -82,15 +82,13 @@

    Module opshin.optimize.optimize_const_folding

    Module opshin.optimize.optimize_const_foldingModule opshin.optimize.optimize_const_foldingModule opshin.optimize.optimize_const_foldingModule opshin.optimize.optimize_const_foldingMethods try: exec(unparse(node), g, l) except Exception as e: - _LOGGER.debug(e) + OPSHIN_LOGGER.debug(e) else: # the class is defined and added to the globals self.scopes_constants[-1].update(l) @@ -782,7 +784,7 @@

    Methods

    # we need to pass the global dict as local dict here to make closures possible (rec functions) exec(unparse(node), g, g) except Exception as e: - _LOGGER.debug(e) + OPSHIN_LOGGER.debug(e) else: # the class is defined and added to the globals self.scopes_constants[-1][node.name] = g[node.name] @@ -844,7 +846,11 @@

    Methods

    if isinstance(node, Constant): # prevents unneccessary computations return node - node_source = unparse(node) + try: + node_source = unparse(node) + except Exception as e: + OPSHIN_LOGGER.debug("Error when trying to unparse node: %s", e) + return node if "print(" in node_source: # do not optimize away print statements return node @@ -854,7 +860,7 @@

    Methods

    l = self._constant_vars() node_eval = eval(node_source, g, l) except Exception as e: - _LOGGER.debug(e) + OPSHIN_LOGGER.debug("Error trying to evaluate node: %s", e) return node if any( @@ -966,7 +972,11 @@

    Methods

    if isinstance(node, Constant): # prevents unneccessary computations return node - node_source = unparse(node) + try: + node_source = unparse(node) + except Exception as e: + OPSHIN_LOGGER.debug("Error when trying to unparse node: %s", e) + return node if "print(" in node_source: # do not optimize away print statements return node @@ -976,7 +986,7 @@

    Methods

    l = self._constant_vars() node_eval = eval(node_source, g, l) except Exception as e: - _LOGGER.debug(e) + OPSHIN_LOGGER.debug("Error trying to evaluate node: %s", e) return node if any( @@ -1006,7 +1016,7 @@

    Methods

    try: exec(unparse(node), g, l) except Exception as e: - _LOGGER.debug(e) + OPSHIN_LOGGER.debug(e) else: # the class is defined and added to the globals self.scopes_constants[-1].update(l)
    @@ -1114,7 +1124,7 @@

    Methods

    # we need to pass the global dict as local dict here to make closures possible (rec functions) exec(unparse(node), g, g) except Exception as e: - _LOGGER.debug(e) + OPSHIN_LOGGER.debug(e) else: # the class is defined and added to the globals self.scopes_constants[-1][node.name] = g[node.name] diff --git a/docs/opshin/tests/test_misc.html b/docs/opshin/tests/test_misc.html index 1bac34cf..9fb81f26 100644 --- a/docs/opshin/tests/test_misc.html +++ b/docs/opshin/tests/test_misc.html @@ -93,6 +93,7 @@

    Module opshin.tests.test_misc

    from .. import prelude, builder, Purpose, PlutusContract from .utils import eval_uplc_value, Unit, eval_uplc from ..bridge import wraps_builtin +from ..compiler_config import OPT_O2_CONFIG, DEFAULT_CONFIG hypothesis.settings.load_profile(PLUTUS_VM_PROFILE) @@ -101,6 +102,9 @@

    Module opshin.tests.test_misc

    from pycardano import RawPlutusData, RawCBOR from cbor2 import CBORTag +DEFAULT_CONFIG_FORCE_THREE_PARAMS = DEFAULT_CONFIG.update(force_three_params=True) +DEFAULT_CONFIG_CONSTANT_FOLDING = DEFAULT_CONFIG.update(constant_folding=True) + ALL_EXAMPLES = [ os.path.join(root, f) for root, dirs, files in os.walk("examples") @@ -147,6 +151,7 @@

    Module opshin.tests.test_misc

    "d8799fd8799f9fd8799fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffd8799fd8799fd87a9f581cdbe769758f26efb21f008dc097bb194cffc622acc37fcefc5372eee3ffd87a80ffa140a1401a00989680d87a9f5820dfab81872ce2bbe6ee5af9bbfee4047f91c1f57db5e30da727d5fef1e7f02f4dffd87a80ffffff809fd8799fd8799fd8799f581cdc315c289fee4484eda07038393f21dc4e572aff292d7926018725c2ffd87a80ffa140a14000d87980d87a80ffffa140a14000a140a1400080a0d8799fd8799fd87980d87a80ffd8799fd87b80d87a80ffff80a1d87a9fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffffd87980a15820dfab81872ce2bbe6ee5af9bbfee4047f91c1f57db5e30da727d5fef1e7f02f4dd8799f581cdc315c289fee4484eda07038393f21dc4e572aff292d7926018725c2ffd8799f5820746957f0eb57f2b11119684e611a98f373afea93473fefbb7632d579af2f6259ffffd87a9fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffffff" ) ), + config=DEFAULT_CONFIG.update(OPT_O2_CONFIG), ) self.assertEqual(ret, uplc.PlutusConstr(0, [])) @@ -489,14 +494,14 @@

    Module opshin.tests.test_misc

    input_file = "examples/smart_contracts/wrapped_token.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_dual_use_compile(self): # TODO devise tests for this input_file = "examples/smart_contracts/dual_use.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_marketplace_compile(self): # TODO devise tests for this @@ -510,14 +515,14 @@

    Module opshin.tests.test_misc

    input_file = "examples/smart_contracts/marketplace.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_parameterized_compile(self): # TODO devise tests for this input_file = "examples/smart_contracts/parameterized.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_dict_datum(self): input_file = "examples/dict_datum.py" @@ -1168,7 +1173,9 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> bytes: return bytes.fromhex("0011") """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, bytes.fromhex("0011")) @unittest.expectedFailure @@ -1188,7 +1195,9 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> List[int]: return list(range(0, 10, 2)) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con list<integer> [0, 2, 4, 6, 8])", code.dumps()) res = builder.uplc_eval(code) self.assertEqual( @@ -1202,7 +1211,9 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> Dict[str, bool]: return {"s": True, "m": False} """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn( "(con list<pair<data, data>> [[#4173, #01], [#416d, #00]]))", code.dumps() ) @@ -1224,7 +1235,7 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> Dict[str, List[Dict[bytes, int]]]: return {"s": [{b"": 0}, {b"0": 1}]} """ - res = eval_uplc(source_code, Unit(), constant_folding=True) + res = eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING) self.assertEqual( res, uplc.PlutusMap( @@ -1250,7 +1261,9 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> PubKeyCredential: return PubKeyCredential(bytes.fromhex("0011")) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con data #d8799f420011ff)", code.dumps()) res = uplc_eval(code) self.assertEqual( @@ -1268,7 +1281,9 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> int: return fib(10) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 55)", code.dumps()) res = uplc_eval(code) self.assertEqual( @@ -1284,7 +1299,7 @@

    Module opshin.tests.test_misc

    a = 10 return a """ - eval_uplc(source_code, Unit(), constant_folding=True) + eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.expectedFailure def test_constant_folding_for(self): @@ -1294,7 +1309,7 @@

    Module opshin.tests.test_misc

    a = 10 return a """ - eval_uplc(source_code, [], constant_folding=True) + eval_uplc(source_code, [], config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.expectedFailure def test_constant_folding_for_target(self): @@ -1304,7 +1319,7 @@

    Module opshin.tests.test_misc

    a = 10 return i """ - eval_uplc(source_code, [], constant_folding=True) + eval_uplc(source_code, [], config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.expectedFailure def test_constant_folding_while(self): @@ -1314,7 +1329,7 @@

    Module opshin.tests.test_misc

    a = 10 return a """ - eval_uplc(source_code, Unit(), constant_folding=True) + eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.skip("Fine from a guarantee perspective, but needs better inspection") def test_constant_folding_guaranteed_branch(self): @@ -1327,7 +1342,9 @@

    Module opshin.tests.test_misc

    b = 2 return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 40)", code.dumps()) @unittest.skip("Fine from a guarantee perspective, but needs better inspection") @@ -1339,7 +1356,9 @@

    Module opshin.tests.test_misc

    b = 5 * a return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 10)", code.dumps()) @unittest.skip("Fine from a guarantee perspective, but needs better inspection") @@ -1351,7 +1370,9 @@

    Module opshin.tests.test_misc

    b = 5 * a return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 10)", code.dumps()) def test_constant_folding_repeated_assign(self): @@ -1362,7 +1383,7 @@

    Module opshin.tests.test_misc

    a = 2 return a """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0))) self.assertEqual(res.value, 4) res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(1))) @@ -1375,7 +1396,7 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> int: return 2 ** 10 """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) code_src = code.dumps() self.assertIn(f"(con integer {2**10})", code_src) @@ -1408,7 +1429,9 @@

    Module opshin.tests.test_misc

    return 2 return int(5) """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, 2) def test_constant_folding_no_print_eval(self): @@ -1418,7 +1441,7 @@

    Module opshin.tests.test_misc

    def validator(_: None) -> None: return print("hello") """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) code_src = code.dumps() self.assertIn(f'(con string "hello")', code_src) @@ -2348,7 +2371,7 @@

    Module opshin.tests.test_misc

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True) + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) def test_double_import_direct(self): source_code = """ @@ -2375,7 +2398,7 @@

    Module opshin.tests.test_misc

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True) + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) def test_double_import_deep(self): source_code = """ @@ -2402,7 +2425,7 @@

    Module opshin.tests.test_misc

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True) + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) def test_bytearray_alternative(self): source_code = """ @@ -2448,7 +2471,7 @@

    Module opshin.tests.test_misc

    def test_wrapping_contract_apply(self): # TODO devise tests for this input_file = "examples/smart_contracts/wrapped_token.py" - contract = builder.build(input_file, force_three_params=True) + contract = builder.build(input_file, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) artifacts = PlutusContract( contract, datum_type=("datum", prelude.Nothing), @@ -2467,7 +2490,7 @@

    Module opshin.tests.test_misc

    def test_wrapping_contract_dump_load(self): input_file = "examples/smart_contracts/wrapped_token.py" - contract = builder.build(input_file, force_three_params=True) + contract = builder.build(input_file, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) artifacts = PlutusContract( contract, datum_type=("datum", prelude.Nothing), @@ -2617,7 +2640,7 @@

    Module opshin.tests.test_misc

    """ builder._compile(source_code) - def test_isinstance_cast_if(self): + def test_isinstance_cast_if2(self): source_code = """ from dataclasses import dataclass from typing import Dict, List, Union @@ -2683,7 +2706,7 @@

    Module opshin.tests.test_misc

    return b"" return 0 """ - builder.compile(source_code) + builder._compile(source_code) @unittest.expectedFailure def test_different_return_types_for_loop(self): @@ -2693,7 +2716,7 @@

    Module opshin.tests.test_misc

    return b"" return 0 """ - builder.compile(source_code) + builder._compile(source_code) def test_return_else_loop_while(self): source_code = """ @@ -2750,7 +2773,9 @@

    Module opshin.tests.test_misc

    a: List[int] = [] return a """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, []) def test_empty_dict_int_int(self): @@ -2768,7 +2793,9 @@

    Module opshin.tests.test_misc

    a: Dict[int, int] = {} return a """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, {}) def test_empty_dict_displaced_constant_folding(self): @@ -2781,7 +2808,9 @@

    Module opshin.tests.test_misc

    a = b.get(0, VAR) return a """ - res = eval_uplc_value(source_code, {1: {b"": 0}}, constant_folding=True) + res = eval_uplc_value( + source_code, {1: {b"": 0}}, config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, {}) def test_union_subset_call(self): @@ -3047,7 +3076,15 @@

    Module opshin.tests.test_misc

    self.assertEqual( B.CONSTR_ID, res, "Invalid constr id generation (does not match pycardano)" - )
    + ) + + def test_empty_return(self): + source_code = """ +def validator(_: None) -> None: + return +""" + res = eval_uplc(source_code, Unit()) + self.assertEqual(res, uplc.PlutusConstr(0, []), "Invalid return")
    @@ -3200,6 +3237,7 @@

    Class variables

    "d8799fd8799f9fd8799fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffd8799fd8799fd87a9f581cdbe769758f26efb21f008dc097bb194cffc622acc37fcefc5372eee3ffd87a80ffa140a1401a00989680d87a9f5820dfab81872ce2bbe6ee5af9bbfee4047f91c1f57db5e30da727d5fef1e7f02f4dffd87a80ffffff809fd8799fd8799fd8799f581cdc315c289fee4484eda07038393f21dc4e572aff292d7926018725c2ffd87a80ffa140a14000d87980d87a80ffffa140a14000a140a1400080a0d8799fd8799fd87980d87a80ffd8799fd87b80d87a80ffff80a1d87a9fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffffd87980a15820dfab81872ce2bbe6ee5af9bbfee4047f91c1f57db5e30da727d5fef1e7f02f4dd8799f581cdc315c289fee4484eda07038393f21dc4e572aff292d7926018725c2ffd8799f5820746957f0eb57f2b11119684e611a98f373afea93473fefbb7632d579af2f6259ffffd87a9fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffffff" ) ), + config=DEFAULT_CONFIG.update(OPT_O2_CONFIG), ) self.assertEqual(ret, uplc.PlutusConstr(0, [])) @@ -3542,14 +3580,14 @@

    Class variables

    input_file = "examples/smart_contracts/wrapped_token.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_dual_use_compile(self): # TODO devise tests for this input_file = "examples/smart_contracts/dual_use.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_marketplace_compile(self): # TODO devise tests for this @@ -3563,14 +3601,14 @@

    Class variables

    input_file = "examples/smart_contracts/marketplace.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_parameterized_compile(self): # TODO devise tests for this input_file = "examples/smart_contracts/parameterized.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True) + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) def test_dict_datum(self): input_file = "examples/dict_datum.py" @@ -4221,7 +4259,9 @@

    Class variables

    def validator(_: None) -> bytes: return bytes.fromhex("0011") """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, bytes.fromhex("0011")) @unittest.expectedFailure @@ -4241,7 +4281,9 @@

    Class variables

    def validator(_: None) -> List[int]: return list(range(0, 10, 2)) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con list<integer> [0, 2, 4, 6, 8])", code.dumps()) res = builder.uplc_eval(code) self.assertEqual( @@ -4255,7 +4297,9 @@

    Class variables

    def validator(_: None) -> Dict[str, bool]: return {"s": True, "m": False} """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn( "(con list<pair<data, data>> [[#4173, #01], [#416d, #00]]))", code.dumps() ) @@ -4277,7 +4321,7 @@

    Class variables

    def validator(_: None) -> Dict[str, List[Dict[bytes, int]]]: return {"s": [{b"": 0}, {b"0": 1}]} """ - res = eval_uplc(source_code, Unit(), constant_folding=True) + res = eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING) self.assertEqual( res, uplc.PlutusMap( @@ -4303,7 +4347,9 @@

    Class variables

    def validator(_: None) -> PubKeyCredential: return PubKeyCredential(bytes.fromhex("0011")) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con data #d8799f420011ff)", code.dumps()) res = uplc_eval(code) self.assertEqual( @@ -4321,7 +4367,9 @@

    Class variables

    def validator(_: None) -> int: return fib(10) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 55)", code.dumps()) res = uplc_eval(code) self.assertEqual( @@ -4337,7 +4385,7 @@

    Class variables

    a = 10 return a """ - eval_uplc(source_code, Unit(), constant_folding=True) + eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.expectedFailure def test_constant_folding_for(self): @@ -4347,7 +4395,7 @@

    Class variables

    a = 10 return a """ - eval_uplc(source_code, [], constant_folding=True) + eval_uplc(source_code, [], config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.expectedFailure def test_constant_folding_for_target(self): @@ -4357,7 +4405,7 @@

    Class variables

    a = 10 return i """ - eval_uplc(source_code, [], constant_folding=True) + eval_uplc(source_code, [], config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.expectedFailure def test_constant_folding_while(self): @@ -4367,7 +4415,7 @@

    Class variables

    a = 10 return a """ - eval_uplc(source_code, Unit(), constant_folding=True) + eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING) @unittest.skip("Fine from a guarantee perspective, but needs better inspection") def test_constant_folding_guaranteed_branch(self): @@ -4380,7 +4428,9 @@

    Class variables

    b = 2 return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 40)", code.dumps()) @unittest.skip("Fine from a guarantee perspective, but needs better inspection") @@ -4392,7 +4442,9 @@

    Class variables

    b = 5 * a return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 10)", code.dumps()) @unittest.skip("Fine from a guarantee perspective, but needs better inspection") @@ -4404,7 +4456,9 @@

    Class variables

    b = 5 * a return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 10)", code.dumps()) def test_constant_folding_repeated_assign(self): @@ -4415,7 +4469,7 @@

    Class variables

    a = 2 return a """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0))) self.assertEqual(res.value, 4) res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(1))) @@ -4428,7 +4482,7 @@

    Class variables

    def validator(_: None) -> int: return 2 ** 10 """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) code_src = code.dumps() self.assertIn(f"(con integer {2**10})", code_src) @@ -4461,7 +4515,9 @@

    Class variables

    return 2 return int(5) """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, 2) def test_constant_folding_no_print_eval(self): @@ -4471,7 +4527,7 @@

    Class variables

    def validator(_: None) -> None: return print("hello") """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) code_src = code.dumps() self.assertIn(f'(con string "hello")', code_src) @@ -5401,7 +5457,7 @@

    Class variables

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True) + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) def test_double_import_direct(self): source_code = """ @@ -5428,7 +5484,7 @@

    Class variables

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True) + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) def test_double_import_deep(self): source_code = """ @@ -5455,7 +5511,7 @@

    Class variables

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True) + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) def test_bytearray_alternative(self): source_code = """ @@ -5501,7 +5557,7 @@

    Class variables

    def test_wrapping_contract_apply(self): # TODO devise tests for this input_file = "examples/smart_contracts/wrapped_token.py" - contract = builder.build(input_file, force_three_params=True) + contract = builder.build(input_file, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) artifacts = PlutusContract( contract, datum_type=("datum", prelude.Nothing), @@ -5520,7 +5576,7 @@

    Class variables

    def test_wrapping_contract_dump_load(self): input_file = "examples/smart_contracts/wrapped_token.py" - contract = builder.build(input_file, force_three_params=True) + contract = builder.build(input_file, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS) artifacts = PlutusContract( contract, datum_type=("datum", prelude.Nothing), @@ -5670,7 +5726,7 @@

    Class variables

    """ builder._compile(source_code) - def test_isinstance_cast_if(self): + def test_isinstance_cast_if2(self): source_code = """ from dataclasses import dataclass from typing import Dict, List, Union @@ -5736,7 +5792,7 @@

    Class variables

    return b"" return 0 """ - builder.compile(source_code) + builder._compile(source_code) @unittest.expectedFailure def test_different_return_types_for_loop(self): @@ -5746,7 +5802,7 @@

    Class variables

    return b"" return 0 """ - builder.compile(source_code) + builder._compile(source_code) def test_return_else_loop_while(self): source_code = """ @@ -5803,7 +5859,9 @@

    Class variables

    a: List[int] = [] return a """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, []) def test_empty_dict_int_int(self): @@ -5821,7 +5879,9 @@

    Class variables

    a: Dict[int, int] = {} return a """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, {}) def test_empty_dict_displaced_constant_folding(self): @@ -5834,7 +5894,9 @@

    Class variables

    a = b.get(0, VAR) return a """ - res = eval_uplc_value(source_code, {1: {b"": 0}}, constant_folding=True) + res = eval_uplc_value( + source_code, {1: {b"": 0}}, config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, {}) def test_union_subset_call(self): @@ -6100,7 +6162,15 @@

    Class variables

    self.assertEqual( B.CONSTR_ID, res, "Invalid constr id generation (does not match pycardano)" - ) + ) + + def test_empty_return(self): + source_code = """ +def validator(_: None) -> None: + return +""" + res = eval_uplc(source_code, Unit()) + self.assertEqual(res, uplc.PlutusConstr(0, []), "Invalid return")

    Ancestors

      @@ -6226,6 +6296,7 @@

      Methods

      "d8799fd8799f9fd8799fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffd8799fd8799fd87a9f581cdbe769758f26efb21f008dc097bb194cffc622acc37fcefc5372eee3ffd87a80ffa140a1401a00989680d87a9f5820dfab81872ce2bbe6ee5af9bbfee4047f91c1f57db5e30da727d5fef1e7f02f4dffd87a80ffffff809fd8799fd8799fd8799f581cdc315c289fee4484eda07038393f21dc4e572aff292d7926018725c2ffd87a80ffa140a14000d87980d87a80ffffa140a14000a140a1400080a0d8799fd8799fd87980d87a80ffd8799fd87b80d87a80ffff80a1d87a9fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffffd87980a15820dfab81872ce2bbe6ee5af9bbfee4047f91c1f57db5e30da727d5fef1e7f02f4dd8799f581cdc315c289fee4484eda07038393f21dc4e572aff292d7926018725c2ffd8799f5820746957f0eb57f2b11119684e611a98f373afea93473fefbb7632d579af2f6259ffffd87a9fd8799fd8799f582055d353acacaab6460b37ed0f0e3a1a0aabf056df4a7fa1e265d21149ccacc527ff01ffffff" ) ), + config=DEFAULT_CONFIG.update(OPT_O2_CONFIG), ) self.assertEqual(ret, uplc.PlutusConstr(0, [])) @@ -7196,7 +7267,9 @@

      Methods

      def validator(_: None) -> bytes: return bytes.fromhex("0011") """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, bytes.fromhex("0011"))
    @@ -7216,7 +7289,7 @@

    Methods

    def validator(_: None) -> Dict[str, List[Dict[bytes, int]]]: return {"s": [{b"": 0}, {b"0": 1}]} """ - res = eval_uplc(source_code, Unit(), constant_folding=True) + res = eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING) self.assertEqual( res, uplc.PlutusMap( @@ -7252,7 +7325,9 @@

    Methods

    def validator(_: None) -> Dict[str, bool]: return {"s": True, "m": False} """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn( "(con list<pair<data, data>> [[#4173, #01], [#416d, #00]]))", code.dumps() ) @@ -7305,7 +7380,7 @@

    Methods

    a = 10 return a """ - eval_uplc(source_code, [], constant_folding=True) + eval_uplc(source_code, [], config=DEFAULT_CONFIG_CONSTANT_FOLDING)
    @@ -7325,7 +7400,7 @@

    Methods

    a = 10 return i """ - eval_uplc(source_code, [], constant_folding=True)
    + eval_uplc(source_code, [], config=DEFAULT_CONFIG_CONSTANT_FOLDING)
    @@ -7348,7 +7423,9 @@

    Methods

    b = 2 return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 40)", code.dumps())
    @@ -7369,7 +7446,7 @@

    Methods

    a = 10 return a """ - eval_uplc(source_code, Unit(), constant_folding=True) + eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING)
    @@ -7389,7 +7466,9 @@

    Methods

    return 2 return int(5) """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, 2)
    @@ -7409,7 +7488,9 @@

    Methods

    def validator(_: None) -> List[int]: return list(range(0, 10, 2)) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con list<integer> [0, 2, 4, 6, 8])", code.dumps()) res = builder.uplc_eval(code) self.assertEqual( @@ -7433,7 +7514,7 @@

    Methods

    def validator(_: None) -> int: return 2 ** 10 """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) code_src = code.dumps() self.assertIn(f"(con integer {2**10})", code_src) @@ -7454,7 +7535,7 @@

    Methods

    def validator(_: None) -> None: return print("hello") """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) code_src = code.dumps() self.assertIn(f'(con string "hello")', code_src) @@ -7477,7 +7558,9 @@

    Methods

    b = 5 * a return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 10)", code.dumps()) @@ -7497,7 +7580,9 @@

    Methods

    def validator(_: None) -> PubKeyCredential: return PubKeyCredential(bytes.fromhex("0011")) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con data #d8799f420011ff)", code.dumps()) res = uplc_eval(code) self.assertEqual( @@ -7525,7 +7610,7 @@

    Methods

    a = 2 return a """ - code = builder._compile(source_code, constant_folding=True) + code = builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING) res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0))) self.assertEqual(res.value, 4) res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(1))) @@ -7550,7 +7635,9 @@

    Methods

    b = 5 * a return b """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 10)", code.dumps()) @@ -7571,7 +7658,9 @@

    Methods

    def validator(_: None) -> int: return fib(10) """ - code = builder._compile(source_code, Unit(), constant_folding=True) + code = builder._compile( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertIn("(con integer 55)", code.dumps()) res = uplc_eval(code) self.assertEqual( @@ -7597,7 +7686,7 @@

    Methods

    a = 10 return a """ - eval_uplc(source_code, Unit(), constant_folding=True) + eval_uplc(source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING)
    @@ -7869,7 +7958,7 @@

    Methods

    return b"" return 0 """ - builder.compile(source_code)
    + builder._compile(source_code)
    @@ -7889,7 +7978,7 @@

    Methods

    return b"" return 0 """ - builder.compile(source_code)
    + builder._compile(source_code)
    @@ -7926,7 +8015,7 @@

    Methods

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True)
    + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING)
    @@ -7963,7 +8052,7 @@

    Methods

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True)
    + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING)
    @@ -8000,7 +8089,7 @@

    Methods

    """ # would fail because Address is assigned multiple times and then not constant folded # TODO find a better way - builder._compile(source_code, constant_folding=True)
    + builder._compile(source_code, config=DEFAULT_CONFIG_CONSTANT_FOLDING)
    @@ -8017,7 +8106,7 @@

    Methods

    input_file = "examples/smart_contracts/dual_use.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True)
    + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS)
    @@ -8039,7 +8128,9 @@

    Methods

    a = b.get(0, VAR) return a """ - res = eval_uplc_value(source_code, {1: {b"": 0}}, constant_folding=True) + res = eval_uplc_value( + source_code, {1: {b"": 0}}, config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, {})
    @@ -8077,7 +8168,9 @@

    Methods

    a: Dict[int, int] = {} return a """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, {}) @@ -8143,10 +8236,30 @@

    Methods

    a: List[int] = [] return a """ - res = eval_uplc_value(source_code, Unit(), constant_folding=True) + res = eval_uplc_value( + source_code, Unit(), config=DEFAULT_CONFIG_CONSTANT_FOLDING + ) self.assertEqual(res, []) +
    +def test_empty_return(self) +
    +
    +
    +
    + +Expand source code + +
        def test_empty_return(self):
    +        source_code = """
    +def validator(_: None) -> None:
    +    return
    +"""
    +        res = eval_uplc(source_code, Unit())
    +        self.assertEqual(res, uplc.PlutusConstr(0, []), "Invalid return")
    +
    +
    def test_failing_annotated_type(self)
    @@ -8901,7 +9014,45 @@

    Methods

    -def test_isinstance_cast_if(self) +def test_isinstance_cast_if(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @hypothesis.given(a_or_b)
    +    def test_isinstance_cast_if(self, x):
    +        source_code = """
    +from dataclasses import dataclass
    +from typing import Dict, List, Union
    +from pycardano import Datum as Anything, PlutusData
    +
    +@dataclass()
    +class A(PlutusData):
    +    CONSTR_ID = 0
    +    foo: int
    +
    +@dataclass()
    +class B(PlutusData):
    +    CONSTR_ID = 1
    +    foobar: int
    +    bar: int
    +
    +def validator(x: Union[A, B]) -> int:
    +    if isinstance(x, A):
    +        k = x.foo
    +    elif isinstance(x, B):
    +        k = x.bar
    +    return k
    +"""
    +        res = eval_uplc_value(source_code, x)
    +        self.assertEqual(res, x.foo if isinstance(x, A) else x.bar)
    +
    +
    +
    +def test_isinstance_cast_if2(self)
    @@ -8909,7 +9060,7 @@

    Methods

    Expand source code -
        def test_isinstance_cast_if(self):
    +
        def test_isinstance_cast_if2(self):
             source_code = """
     from dataclasses import dataclass
     from typing import Dict, List, Union
    @@ -9258,7 +9409,7 @@ 

    Methods

    input_file = "examples/smart_contracts/marketplace.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True)
    + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS)
    @@ -9638,7 +9789,7 @@

    Methods

    input_file = "examples/smart_contracts/parameterized.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True)
    + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS)
    @@ -11071,7 +11222,7 @@

    Methods

    def test_wrapping_contract_apply(self):
         # TODO devise tests for this
         input_file = "examples/smart_contracts/wrapped_token.py"
    -    contract = builder.build(input_file, force_three_params=True)
    +    contract = builder.build(input_file, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS)
         artifacts = PlutusContract(
             contract,
             datum_type=("datum", prelude.Nothing),
    @@ -11103,7 +11254,7 @@ 

    Methods

    input_file = "examples/smart_contracts/wrapped_token.py" with open(input_file) as fp: source_code = fp.read() - builder._compile(source_code, force_three_params=True)
    + builder._compile(source_code, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS)
    @@ -11117,7 +11268,7 @@

    Methods

    def test_wrapping_contract_dump_load(self):
         input_file = "examples/smart_contracts/wrapped_token.py"
    -    contract = builder.build(input_file, force_three_params=True)
    +    contract = builder.build(input_file, config=DEFAULT_CONFIG_FORCE_THREE_PARAMS)
         artifacts = PlutusContract(
             contract,
             datum_type=("datum", prelude.Nothing),
    @@ -11450,6 +11601,7 @@ 

    test_empty_list_data
  • test_empty_list_int
  • test_empty_list_int_constant_folding
  • +
  • test_empty_return
  • test_failing_annotated_type
  • test_fib_iter
  • test_fib_rec
  • @@ -11474,6 +11626,7 @@

    test_isinstance_cast_complex_or_else
  • test_isinstance_cast_complex_or_sameconstr
  • test_isinstance_cast_if
  • +
  • test_isinstance_cast_if2
  • test_isinstance_cast_ifexpr
  • test_isinstance_cast_random
  • test_isinstance_cast_shortcut_and
  • diff --git a/docs/opshin/tests/test_ops.html b/docs/opshin/tests/test_ops.html index dcb7d890..075f6dce 100644 --- a/docs/opshin/tests/test_ops.html +++ b/docs/opshin/tests/test_ops.html @@ -140,6 +140,7 @@

    Module opshin.tests.test_ops

    rec_data_strategies, max_leaves=4, ) +uplc_data_list = st.builds(lambda x: PlutusList(frozenlist(x)), st.lists(uplc_data)) # TODO fix handling of these strings formattable_text = st.from_regex(r"\A((?!['\\])[ -~])*\Z") @@ -553,6 +554,50 @@

    Module opshin.tests.test_ops

    ret = eval_uplc_value(source_code, xs, y) self.assertEqual(ret, y in xs, "list in returned wrong value") + @given(xs=uplc_data_list, y=uplc_data) + def test_in_list_data(self, xs, y): + source_code = """ +from typing import Dict, List, Union +from pycardano import Datum as Anything, PlutusData +def validator(x: List[Anything], y: Anything) -> bool: + return y in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y in xs.value, "list in returned wrong value") + + @given(xs=uplc_data_list, y=uplc_data) + def test_not_in_list_data(self, xs, y): + source_code = """ +from typing import Dict, List, Union +from pycardano import Datum as Anything, PlutusData +def validator(x: List[Anything], y: Anything) -> bool: + return y not in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y not in xs.value, "list not in returned wrong value") + + @given(xs=st.lists(st.integers()), y=st.integers()) + @example(xs=[0, 1], y=-1) + @example(xs=[0, 1], y=0) + def test_not_in_list_int(self, xs, y): + source_code = """ +from typing import Dict, List, Union +def validator(x: List[int], y: int) -> bool: + return y not in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y not in xs, "list not in returned wrong value") + + @given(xs=st.lists(st.binary()), y=st.binary()) + def test_not_in_list_bytes(self, xs, y): + source_code = """ +from typing import Dict, List, Union +def validator(x: List[bytes], y: bytes) -> bool: + return y not in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y not in xs, "list not in returned wrong value") + @given(x=st.lists(st.integers())) def test_not_list(self, x): source_code = """ @@ -609,6 +654,71 @@

    Module opshin.tests.test_ops

    ret = eval_uplc_value(source_code, x, y) self.assertEqual(ret, x == y, "any eq returned wrong value") + @given(x=st.booleans(), y=st.integers()) + def test_eq_bool_int(self, x, y): + source_code = """ +def validator(x: bool, y: int) -> bool: + return x == y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x == y, "bool eq int returned wrong value") + + @given(x=st.text(), y=st.text()) + def test_neq_str(self, x, y): + source_code = """ +def validator(x: str, y: str) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x.encode("utf8"), y.encode("utf8")) + self.assertEqual(ret, x != y, "str neq returned wrong value") + + @given(x=st.integers(), y=st.integers()) + def test_neq_int(self, x, y): + source_code = """ +def validator(x: int, y: int) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "int neq returned wrong value") + + @given(x=st.binary(), y=st.binary()) + def test_neq_bytes(self, x, y): + source_code = """ +def validator(x: bytes, y: bytes) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "bytes neq returned wrong value") + + @given(x=st.booleans(), y=st.booleans()) + def test_neq_bool(self, x, y): + source_code = """ +def validator(x: bool, y: bool) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "bool neq returned wrong value") + + @given(x=st.booleans(), y=st.integers()) + def test_neq_bool_int(self, x, y): + source_code = """ +def validator(x: bool, y: int) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "bool neq int returned wrong value") + + @given(x=uplc_data, y=uplc_data) + def test_neq_data(self, x, y): + source_code = """ +from opshin.prelude import * + +def validator(x: Anything, y: Anything) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "any neq returned wrong value") + @given(x=st.integers(min_value=0, max_value=150), y=st.text()) def test_mul_int_str(self, x, y): source_code = """ @@ -1454,6 +1564,50 @@

    Classes

    ret = eval_uplc_value(source_code, xs, y) self.assertEqual(ret, y in xs, "list in returned wrong value") + @given(xs=uplc_data_list, y=uplc_data) + def test_in_list_data(self, xs, y): + source_code = """ +from typing import Dict, List, Union +from pycardano import Datum as Anything, PlutusData +def validator(x: List[Anything], y: Anything) -> bool: + return y in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y in xs.value, "list in returned wrong value") + + @given(xs=uplc_data_list, y=uplc_data) + def test_not_in_list_data(self, xs, y): + source_code = """ +from typing import Dict, List, Union +from pycardano import Datum as Anything, PlutusData +def validator(x: List[Anything], y: Anything) -> bool: + return y not in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y not in xs.value, "list not in returned wrong value") + + @given(xs=st.lists(st.integers()), y=st.integers()) + @example(xs=[0, 1], y=-1) + @example(xs=[0, 1], y=0) + def test_not_in_list_int(self, xs, y): + source_code = """ +from typing import Dict, List, Union +def validator(x: List[int], y: int) -> bool: + return y not in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y not in xs, "list not in returned wrong value") + + @given(xs=st.lists(st.binary()), y=st.binary()) + def test_not_in_list_bytes(self, xs, y): + source_code = """ +from typing import Dict, List, Union +def validator(x: List[bytes], y: bytes) -> bool: + return y not in x + """ + ret = eval_uplc_value(source_code, xs, y) + self.assertEqual(ret, y not in xs, "list not in returned wrong value") + @given(x=st.lists(st.integers())) def test_not_list(self, x): source_code = """ @@ -1510,6 +1664,71 @@

    Classes

    ret = eval_uplc_value(source_code, x, y) self.assertEqual(ret, x == y, "any eq returned wrong value") + @given(x=st.booleans(), y=st.integers()) + def test_eq_bool_int(self, x, y): + source_code = """ +def validator(x: bool, y: int) -> bool: + return x == y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x == y, "bool eq int returned wrong value") + + @given(x=st.text(), y=st.text()) + def test_neq_str(self, x, y): + source_code = """ +def validator(x: str, y: str) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x.encode("utf8"), y.encode("utf8")) + self.assertEqual(ret, x != y, "str neq returned wrong value") + + @given(x=st.integers(), y=st.integers()) + def test_neq_int(self, x, y): + source_code = """ +def validator(x: int, y: int) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "int neq returned wrong value") + + @given(x=st.binary(), y=st.binary()) + def test_neq_bytes(self, x, y): + source_code = """ +def validator(x: bytes, y: bytes) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "bytes neq returned wrong value") + + @given(x=st.booleans(), y=st.booleans()) + def test_neq_bool(self, x, y): + source_code = """ +def validator(x: bool, y: bool) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "bool neq returned wrong value") + + @given(x=st.booleans(), y=st.integers()) + def test_neq_bool_int(self, x, y): + source_code = """ +def validator(x: bool, y: int) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "bool neq int returned wrong value") + + @given(x=uplc_data, y=uplc_data) + def test_neq_data(self, x, y): + source_code = """ +from opshin.prelude import * + +def validator(x: Anything, y: Anything) -> bool: + return x != y + """ + ret = eval_uplc_value(source_code, x, y) + self.assertEqual(ret, x != y, "any neq returned wrong value") + @given(x=st.integers(min_value=0, max_value=150), y=st.text()) def test_mul_int_str(self, x, y): source_code = """ @@ -2007,6 +2226,25 @@

    Methods

    self.assertEqual(ret, x == y, "bool eq returned wrong value")
    +
    +def test_eq_bool_int(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(x=st.booleans(), y=st.integers())
    +    def test_eq_bool_int(self, x, y):
    +        source_code = """
    +def validator(x: bool, y: int) -> bool:
    +    return x == y
    +            """
    +        ret = eval_uplc_value(source_code, x, y)
    +        self.assertEqual(ret, x == y, "bool eq int returned wrong value")
    +
    +
    def test_eq_bytes(self) ‑> None
    @@ -2495,6 +2733,27 @@

    Methods

    self.assertEqual(ret, y in xs, "list in returned wrong value")
    +
    +def test_in_list_data(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(xs=uplc_data_list, y=uplc_data)
    +    def test_in_list_data(self, xs, y):
    +        source_code = """
    +from typing import Dict, List, Union
    +from pycardano import Datum as Anything, PlutusData
    +def validator(x: List[Anything], y: Anything) -> bool:
    +    return y in x
    +            """
    +        ret = eval_uplc_value(source_code, xs, y)
    +        self.assertEqual(ret, y in xs.value, "list in returned wrong value")
    +
    +
    def test_in_list_int(self) ‑> None
    @@ -2746,6 +3005,122 @@

    Methods

    self.assertFalse(fail, "** worked with negative exponent") +
    +def test_neq_bool(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(x=st.booleans(), y=st.booleans())
    +    def test_neq_bool(self, x, y):
    +        source_code = """
    +def validator(x: bool, y: bool) -> bool:
    +    return x != y
    +            """
    +        ret = eval_uplc_value(source_code, x, y)
    +        self.assertEqual(ret, x != y, "bool neq returned wrong value")
    +
    +
    +
    +def test_neq_bool_int(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(x=st.booleans(), y=st.integers())
    +    def test_neq_bool_int(self, x, y):
    +        source_code = """
    +def validator(x: bool, y: int) -> bool:
    +    return x != y
    +            """
    +        ret = eval_uplc_value(source_code, x, y)
    +        self.assertEqual(ret, x != y, "bool neq int returned wrong value")
    +
    +
    +
    +def test_neq_bytes(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(x=st.binary(), y=st.binary())
    +    def test_neq_bytes(self, x, y):
    +        source_code = """
    +def validator(x: bytes, y: bytes) -> bool:
    +    return x != y
    +            """
    +        ret = eval_uplc_value(source_code, x, y)
    +        self.assertEqual(ret, x != y, "bytes neq returned wrong value")
    +
    +
    +
    +def test_neq_data(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(x=uplc_data, y=uplc_data)
    +    def test_neq_data(self, x, y):
    +        source_code = """
    +from opshin.prelude import *
    +
    +def validator(x: Anything, y: Anything) -> bool:
    +    return x != y
    +            """
    +        ret = eval_uplc_value(source_code, x, y)
    +        self.assertEqual(ret, x != y, "any neq returned wrong value")
    +
    +
    +
    +def test_neq_int(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(x=st.integers(), y=st.integers())
    +    def test_neq_int(self, x, y):
    +        source_code = """
    +def validator(x: int, y: int) -> bool:
    +    return x != y
    +            """
    +        ret = eval_uplc_value(source_code, x, y)
    +        self.assertEqual(ret, x != y, "int neq returned wrong value")
    +
    +
    +
    +def test_neq_str(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(x=st.text(), y=st.text())
    +    def test_neq_str(self, x, y):
    +        source_code = """
    +def validator(x: str, y: str) -> bool:
    +    return x != y
    +            """
    +        ret = eval_uplc_value(source_code, x.encode("utf8"), y.encode("utf8"))
    +        self.assertEqual(ret, x != y, "str neq returned wrong value")
    +
    +
    def test_not_bool(self) ‑> None
    @@ -2803,6 +3178,69 @@

    Methods

    self.assertEqual(bool(ret), not x, "not returned wrong value") +
    +def test_not_in_list_bytes(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(xs=st.lists(st.binary()), y=st.binary())
    +    def test_not_in_list_bytes(self, xs, y):
    +        source_code = """
    +from typing import Dict, List, Union
    +def validator(x: List[bytes], y: bytes) -> bool:
    +    return y not in x
    +            """
    +        ret = eval_uplc_value(source_code, xs, y)
    +        self.assertEqual(ret, y not in xs, "list not in returned wrong value")
    +
    +
    +
    +def test_not_in_list_data(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(xs=uplc_data_list, y=uplc_data)
    +    def test_not_in_list_data(self, xs, y):
    +        source_code = """
    +from typing import Dict, List, Union
    +from pycardano import Datum as Anything, PlutusData
    +def validator(x: List[Anything], y: Anything) -> bool:
    +    return y not in x
    +            """
    +        ret = eval_uplc_value(source_code, xs, y)
    +        self.assertEqual(ret, y not in xs.value, "list not in returned wrong value")
    +
    +
    +
    +def test_not_in_list_int(self) ‑> None +
    +
    +
    +
    + +Expand source code + +
        @given(xs=st.lists(st.integers()), y=st.integers())
    +    @example(xs=[0, 1], y=-1)
    +    @example(xs=[0, 1], y=0)
    +    def test_not_in_list_int(self, xs, y):
    +        source_code = """
    +from typing import Dict, List, Union
    +def validator(x: List[int], y: int) -> bool:
    +    return y not in x
    +            """
    +        ret = eval_uplc_value(source_code, xs, y)
    +        self.assertEqual(ret, y not in xs, "list not in returned wrong value")
    +
    +
    def test_not_int(self) ‑> None
    @@ -3332,6 +3770,7 @@

    test_and_bool
  • test_div_int
  • test_eq_bool
  • +
  • test_eq_bool_int
  • test_eq_bytes
  • test_eq_data
  • test_eq_int
  • @@ -3352,6 +3791,7 @@

    test_fmt_tuple_int
  • test_fmt_tuple_str
  • test_in_list_bytes
  • +
  • test_in_list_data
  • test_in_list_int
  • test_index_bytes
  • test_index_dict
  • @@ -3363,9 +3803,18 @@

    test_mul_int_str
  • test_mul_str_int
  • test_neg_pow_int
  • +
  • test_neq_bool
  • +
  • test_neq_bool_int
  • +
  • test_neq_bytes
  • +
  • test_neq_data
  • +
  • test_neq_int
  • +
  • test_neq_str
  • test_not_bool
  • test_not_bytes
  • test_not_dict
  • +
  • test_not_in_list_bytes
  • +
  • test_not_in_list_data
  • +
  • test_not_in_list_int
  • test_not_int
  • test_not_list
  • test_not_string
  • diff --git a/docs/opshin/tests/test_std/test_integrity.html b/docs/opshin/tests/test_std/test_integrity.html index 82bbea4b..e14479c1 100644 --- a/docs/opshin/tests/test_std/test_integrity.html +++ b/docs/opshin/tests/test_std/test_integrity.html @@ -215,7 +215,9 @@

    Module opshin.tests.test_std.test_integrity

    @parameterized.expand( [ [[0, 1, 2], [1, 1, 1]], + # check for incorrect type in keys [[b"hello", 1], [1, 1]], + # check for incorrect type in values [[1, 2], [1, b"hello"]], ] ) diff --git a/docs/opshin/tests/utils.html b/docs/opshin/tests/utils.html index e845c7a9..d0ea12b8 100644 --- a/docs/opshin/tests/utils.html +++ b/docs/opshin/tests/utils.html @@ -77,6 +77,7 @@

    Module opshin.tests.utils

    from pycardano import PlutusData from uplc import eval as uplc_eval +from .. import DEFAULT_CONFIG from ..builder import _compile @@ -89,23 +90,15 @@

    Module opshin.tests.utils

    source_code: str, *args: typing.Union[pycardano.Datum, uplc_ast.Constant], contract_file: str = "<unknown>", - force_three_params=False, validator_function_name="validator", - optimize_patterns=True, - remove_dead_code=True, - constant_folding=False, - allow_isinstance_anything=False, + config=DEFAULT_CONFIG, ): code = _compile( source_code, *args, contract_file=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, - remove_dead_code=remove_dead_code, - constant_folding=constant_folding, - allow_isinstance_anything=allow_isinstance_anything, + config=config, ) return uplc_eval(code) @@ -114,23 +107,15 @@

    Module opshin.tests.utils

    source_code: str, *args: typing.Union[pycardano.Datum, uplc_ast.Constant], contract_file: str = "<unknown>", - force_three_params=False, validator_function_name="validator", - optimize_patterns=True, - remove_dead_code=True, - constant_folding=False, - allow_isinstance_anything=False, + config=DEFAULT_CONFIG, ): return eval_uplc( source_code, *args, contract_file=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, - remove_dead_code=remove_dead_code, - constant_folding=constant_folding, - allow_isinstance_anything=allow_isinstance_anything, + config=config, ).value @@ -142,7 +127,7 @@

    Module opshin.tests.utils

    Functions

    -def eval_uplc(source_code: str, *args: Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData, uplc.ast.Constant], contract_file: str = '<unknown>', force_three_params=False, validator_function_name='validator', optimize_patterns=True, remove_dead_code=True, constant_folding=False, allow_isinstance_anything=False) +def eval_uplc(source_code: str, *args: Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData, uplc.ast.Constant], contract_file: str = '<unknown>', validator_function_name='validator', config=CompilationConfig(compress_patterns=False, iterative_unfold_patterns=False, constant_index_access_list=True, constant_folding=False, allow_isinstance_anything=False, force_three_params=False, remove_dead_code=True))
    @@ -154,29 +139,21 @@

    Functions

    source_code: str, *args: typing.Union[pycardano.Datum, uplc_ast.Constant], contract_file: str = "<unknown>", - force_three_params=False, validator_function_name="validator", - optimize_patterns=True, - remove_dead_code=True, - constant_folding=False, - allow_isinstance_anything=False, + config=DEFAULT_CONFIG, ): code = _compile( source_code, *args, contract_file=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, - remove_dead_code=remove_dead_code, - constant_folding=constant_folding, - allow_isinstance_anything=allow_isinstance_anything, + config=config, ) return uplc_eval(code)
    -def eval_uplc_value(source_code: str, *args: Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData, uplc.ast.Constant], contract_file: str = '<unknown>', force_three_params=False, validator_function_name='validator', optimize_patterns=True, remove_dead_code=True, constant_folding=False, allow_isinstance_anything=False) +def eval_uplc_value(source_code: str, *args: Union[pycardano.plutus.PlutusData, dict, int, bytes, pycardano.serialization.IndefiniteList, pycardano.serialization.RawCBOR, pycardano.plutus.RawPlutusData, uplc.ast.Constant], contract_file: str = '<unknown>', validator_function_name='validator', config=CompilationConfig(compress_patterns=False, iterative_unfold_patterns=False, constant_index_access_list=True, constant_folding=False, allow_isinstance_anything=False, force_three_params=False, remove_dead_code=True))
    @@ -188,23 +165,15 @@

    Functions

    source_code: str, *args: typing.Union[pycardano.Datum, uplc_ast.Constant], contract_file: str = "<unknown>", - force_three_params=False, validator_function_name="validator", - optimize_patterns=True, - remove_dead_code=True, - constant_folding=False, - allow_isinstance_anything=False, + config=DEFAULT_CONFIG, ): return eval_uplc( source_code, *args, contract_file=contract_file, - force_three_params=force_three_params, validator_function_name=validator_function_name, - optimize_patterns=optimize_patterns, - remove_dead_code=remove_dead_code, - constant_folding=constant_folding, - allow_isinstance_anything=allow_isinstance_anything, + config=config, ).value
    diff --git a/docs/opshin/type_inference.html b/docs/opshin/type_inference.html index 7ca046bc..fd85399d 100644 --- a/docs/opshin/type_inference.html +++ b/docs/opshin/type_inference.html @@ -103,8 +103,6 @@

    Module opshin.type_inference

    # from frozendict import frozendict -_LOGGER = logging.getLogger(__name__) - INITIAL_SCOPE = { # class annotations @@ -229,9 +227,11 @@

    Module opshin.type_inference

    if not (isinstance(node.func, Name) and node.func.orig_id == "isinstance"): return ({}, {}) # special case for Union - assert isinstance( - node.args[0], Name - ), "Target 0 of an isinstance cast must be a variable name" + if not isinstance(node.args[0], Name): + OPSHIN_LOGGER.warning( + "Target 0 of an isinstance cast must be a variable name for type casting to work. You can still proceed, but the inferred type of the isinstance cast will not be accurate." + ) + return ({}, {}) assert isinstance( node.args[1], Name ), "Target 1 of an isinstance cast must be a class name" @@ -454,6 +454,11 @@

    Module opshin.type_inference

    tc.typ = constant_type(node.value) return tc + def visit_NoneType(self, node: None) -> TypedConstant: + tc = Constant(value=None) + tc.typ = constant_type(tc.value) + return tc + def visit_Tuple(self, node: Tuple) -> TypedTuple: tt = copy(node) tt.elts = [self.visit(e) for e in node.elts] @@ -1541,6 +1546,11 @@

    Classes

    tc.typ = constant_type(node.value) return tc + def visit_NoneType(self, node: None) -> TypedConstant: + tc = Constant(value=None) + tc.typ = constant_type(tc.value) + return tc + def visit_Tuple(self, node: Tuple) -> TypedTuple: tt = copy(node) tt.elts = [self.visit(e) for e in node.elts] @@ -2972,6 +2982,21 @@

    Methods

    return tn +
    +def visit_NoneType(self, node: None) ‑> TypedConstant +
    +
    +
    +
    + +Expand source code + +
    def visit_NoneType(self, node: None) -> TypedConstant:
    +    tc = Constant(value=None)
    +    tc.typ = constant_type(tc.value)
    +    return tc
    +
    +
    def visit_Pass(self, node: ast.Pass) ‑> TypedPass
    @@ -3787,9 +3812,11 @@

    Methods

    if not (isinstance(node.func, Name) and node.func.orig_id == "isinstance"): return ({}, {}) # special case for Union - assert isinstance( - node.args[0], Name - ), "Target 0 of an isinstance cast must be a variable name" + if not isinstance(node.args[0], Name): + OPSHIN_LOGGER.warning( + "Target 0 of an isinstance cast must be a variable name for type casting to work. You can still proceed, but the inferred type of the isinstance cast will not be accurate." + ) + return ({}, {}) assert isinstance( node.args[1], Name ), "Target 1 of an isinstance cast must be a class name" @@ -3940,9 +3967,11 @@

    Methods

    if not (isinstance(node.func, Name) and node.func.orig_id == "isinstance"): return ({}, {}) # special case for Union - assert isinstance( - node.args[0], Name - ), "Target 0 of an isinstance cast must be a variable name" + if not isinstance(node.args[0], Name): + OPSHIN_LOGGER.warning( + "Target 0 of an isinstance cast must be a variable name for type casting to work. You can still proceed, but the inferred type of the isinstance cast will not be accurate." + ) + return ({}, {}) assert isinstance( node.args[1], Name ), "Target 1 of an isinstance cast must be a class name" @@ -4106,6 +4135,7 @@

    visit_ListComp
  • visit_Module
  • visit_Name
  • +
  • visit_NoneType
  • visit_Pass
  • visit_RawPlutoExpr
  • visit_Return
  • diff --git a/docs/opshin/typed_ast.html b/docs/opshin/typed_ast.html index 65265dae..97c1bf36 100644 --- a/docs/opshin/typed_ast.html +++ b/docs/opshin/typed_ast.html @@ -70,8 +70,6 @@

    Module opshin.typed_ast

    from .types import *
     
    -_LOGGER = logging.getLogger(__name__)
    -
     
     class TypedAST(AST):
         typ: Type
    diff --git a/docs/opshin/types.html b/docs/opshin/types.html
    index 548d522a..108a7da5 100644
    --- a/docs/opshin/types.html
    +++ b/docs/opshin/types.html
    @@ -81,8 +81,6 @@ 

    Module opshin.types

    from .util import * -_LOGGER = logging.getLogger(__name__) - class TypeInferenceError(AssertionError): pass @@ -311,10 +309,39 @@

    Module opshin.types

    ) ), ) + if ( + isinstance(o, ListType) + and isinstance(o.typ, InstanceType) + and (o.typ.typ >= self or self >= o.typ.typ) + ): + if isinstance(op, In): + return OLambda( + ["x", "y"], + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ), + ) return super().cmp(op, o) def stringify(self, recursive: bool = False) -> plt.AST: - _LOGGER.warning( + OPSHIN_LOGGER.warning( "Serializing AnyType will result in RawPlutusData (CBOR representation) to be printed without additional type information. Annotate types where possible to avoid this warning." ) return OLambda( @@ -635,21 +662,24 @@

    Module opshin.types

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsData( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsData), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConstrData( - plt.AddInteger( - plt.Constructor(OVar("x")), plt.Integer(1) - ), - plt.MkNilData(plt.Unit()), - ), ), ), ) @@ -863,21 +893,24 @@

    Module opshin.types

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsData( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsData), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConstrData( - plt.AddInteger( - plt.Constructor(OVar("x")), plt.Integer(1) - ), - plt.MkNilData(plt.Unit()), - ), ), ), ) @@ -1393,23 +1426,15 @@

    Module opshin.types

    OLet( [ ("hfst", plt.FstPair(OVar("h"))), - ( - "found_elem", - plt.FindList( - OVar("t"), - OLambda( - ["e"], - plt.EqualsData( - OVar("hfst"), plt.FstPair(OVar("e")) - ), - ), - plt.UPLCConstant(uplc.PlutusConstr(-1, [])), - ), - ), ], - plt.EqualsData( - OVar("found_elem"), - plt.UPLCConstant(uplc.PlutusConstr(-1, [])), + plt.Not( + plt.AnyList( + OVar("t"), + OLambda( + ["e"], + plt.EqualsData(OVar("hfst"), plt.FstPair(OVar("e"))), + ), + ) ), ), ), @@ -1592,15 +1617,22 @@

    Module opshin.types

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsInteger( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsInteger), OVar("x") + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsInteger), OVar("x") ), - # this simply ensures the default is always unequal to the searched value - plt.AddInteger(OVar("x"), plt.Integer(1)), ), ), ) @@ -1759,6 +1791,10 @@

    Module opshin.types

    if isinstance(o, StringType): if isinstance(op, Eq): return plt.BuiltIn(uplc.BuiltInFun.EqualsString) + if isinstance(op, NotEq): + return OLambda( + ["x", "y"], plt.Not(plt.EqualsString(OVar("x"), OVar("y"))) + ) return super().cmp(op, o) def stringify(self, recursive: bool = False) -> plt.AST: @@ -1956,16 +1992,24 @@

    Module opshin.types

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsByteString( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsByteString), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsByteString), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConsByteString(plt.Integer(0), OVar("x")), ), ), ) @@ -2176,9 +2220,20 @@

    Module opshin.types

    plt.EqualsInteger(OVar("x"), plt.Integer(0)), ), ) + if isinstance(op, NotEq): + return OLambda( + ["y", "x"], + plt.Ite( + OVar("y"), + plt.NotEqualsInteger(OVar("x"), plt.Integer(1)), + plt.NotEqualsInteger(OVar("x"), plt.Integer(0)), + ), + ) if isinstance(o, BoolType): if isinstance(op, Eq): return OLambda(["x", "y"], plt.Iff(OVar("x"), OVar("y"))) + if isinstance(op, NotEq): + return OLambda(["x", "y"], plt.Not(plt.Iff(OVar("x"), OVar("y")))) return super().cmp(op, o) def stringify(self, recursive: bool = False) -> plt.AST: @@ -3110,10 +3165,39 @@

    Classes

    ) ), ) + if ( + isinstance(o, ListType) + and isinstance(o.typ, InstanceType) + and (o.typ.typ >= self or self >= o.typ.typ) + ): + if isinstance(op, In): + return OLambda( + ["x", "y"], + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ), + ) return super().cmp(op, o) def stringify(self, recursive: bool = False) -> plt.AST: - _LOGGER.warning( + OPSHIN_LOGGER.warning( "Serializing AnyType will result in RawPlutusData (CBOR representation) to be printed without additional type information. Annotate types where possible to avoid this warning." ) return OLambda( @@ -3415,6 +3499,35 @@

    Methods

    ) ), ) + if ( + isinstance(o, ListType) + and isinstance(o.typ, InstanceType) + and (o.typ.typ >= self or self >= o.typ.typ) + ): + if isinstance(op, In): + return OLambda( + ["x", "y"], + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ), + ) return super().cmp(op, o)
    @@ -3480,7 +3593,7 @@

    Methods

    Expand source code
    def stringify(self, recursive: bool = False) -> plt.AST:
    -    _LOGGER.warning(
    +    OPSHIN_LOGGER.warning(
             "Serializing AnyType will result in RawPlutusData (CBOR representation) to be printed without additional type information. Annotate types where possible to avoid this warning."
         )
         return OLambda(
    @@ -4019,9 +4132,20 @@ 

    Methods

    plt.EqualsInteger(OVar("x"), plt.Integer(0)), ), ) + if isinstance(op, NotEq): + return OLambda( + ["y", "x"], + plt.Ite( + OVar("y"), + plt.NotEqualsInteger(OVar("x"), plt.Integer(1)), + plt.NotEqualsInteger(OVar("x"), plt.Integer(0)), + ), + ) if isinstance(o, BoolType): if isinstance(op, Eq): return OLambda(["x", "y"], plt.Iff(OVar("x"), OVar("y"))) + if isinstance(op, NotEq): + return OLambda(["x", "y"], plt.Not(plt.Iff(OVar("x"), OVar("y")))) return super().cmp(op, o) def stringify(self, recursive: bool = False) -> plt.AST: @@ -4119,9 +4243,20 @@

    Methods

    plt.EqualsInteger(OVar("x"), plt.Integer(0)), ), ) + if isinstance(op, NotEq): + return OLambda( + ["y", "x"], + plt.Ite( + OVar("y"), + plt.NotEqualsInteger(OVar("x"), plt.Integer(1)), + plt.NotEqualsInteger(OVar("x"), plt.Integer(0)), + ), + ) if isinstance(o, BoolType): if isinstance(op, Eq): return OLambda(["x", "y"], plt.Iff(OVar("x"), OVar("y"))) + if isinstance(op, NotEq): + return OLambda(["x", "y"], plt.Not(plt.Iff(OVar("x"), OVar("y")))) return super().cmp(op, o)
    @@ -4383,16 +4518,24 @@

    Methods

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsByteString( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsByteString), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsByteString), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConsByteString(plt.Integer(0), OVar("x")), ), ), ) @@ -4799,16 +4942,24 @@

    Methods

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsByteString( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsByteString), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsByteString), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConsByteString(plt.Integer(0), OVar("x")), ), ), ) @@ -5631,23 +5782,15 @@

    Methods

    OLet( [ ("hfst", plt.FstPair(OVar("h"))), - ( - "found_elem", - plt.FindList( - OVar("t"), - OLambda( - ["e"], - plt.EqualsData( - OVar("hfst"), plt.FstPair(OVar("e")) - ), - ), - plt.UPLCConstant(uplc.PlutusConstr(-1, [])), - ), - ), ], - plt.EqualsData( - OVar("found_elem"), - plt.UPLCConstant(uplc.PlutusConstr(-1, [])), + plt.Not( + plt.AnyList( + OVar("t"), + OLambda( + ["e"], + plt.EqualsData(OVar("hfst"), plt.FstPair(OVar("e"))), + ), + ) ), ), ), @@ -5964,23 +6107,15 @@

    Methods

    OLet( [ ("hfst", plt.FstPair(OVar("h"))), - ( - "found_elem", - plt.FindList( - OVar("t"), - OLambda( - ["e"], - plt.EqualsData( - OVar("hfst"), plt.FstPair(OVar("e")) - ), - ), - plt.UPLCConstant(uplc.PlutusConstr(-1, [])), - ), - ), ], - plt.EqualsData( - OVar("found_elem"), - plt.UPLCConstant(uplc.PlutusConstr(-1, [])), + plt.Not( + plt.AnyList( + OVar("t"), + OLambda( + ["e"], + plt.EqualsData(OVar("hfst"), plt.FstPair(OVar("e"))), + ), + ) ), ), ), @@ -7161,15 +7296,22 @@

    Methods

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsInteger( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsInteger), OVar("x") + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsInteger), OVar("x") ), - # this simply ensures the default is always unequal to the searched value - plt.AddInteger(OVar("x"), plt.Integer(1)), ), ), ) @@ -7427,15 +7569,22 @@

    Methods

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsInteger( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsInteger), OVar("x") + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsInteger), OVar("x") ), - # this simply ensures the default is always unequal to the searched value - plt.AddInteger(OVar("x"), plt.Integer(1)), ), ), ) @@ -8778,21 +8927,24 @@

    Class variables

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsData( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsData), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConstrData( - plt.AddInteger( - plt.Constructor(OVar("x")), plt.Integer(1) - ), - plt.MkNilData(plt.Unit()), - ), ), ), ) @@ -9017,21 +9169,24 @@

    Methods

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsData( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsData), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConstrData( - plt.AddInteger( - plt.Constructor(OVar("x")), plt.Integer(1) - ), - plt.MkNilData(plt.Unit()), - ), ), ), ) @@ -9317,6 +9472,10 @@

    Methods

    if isinstance(o, StringType): if isinstance(op, Eq): return plt.BuiltIn(uplc.BuiltInFun.EqualsString) + if isinstance(op, NotEq): + return OLambda( + ["x", "y"], plt.Not(plt.EqualsString(OVar("x"), OVar("y"))) + ) return super().cmp(op, o) def stringify(self, recursive: bool = False) -> plt.AST: @@ -9442,6 +9601,10 @@

    Methods

    if isinstance(o, StringType): if isinstance(op, Eq): return plt.BuiltIn(uplc.BuiltInFun.EqualsString) + if isinstance(op, NotEq): + return OLambda( + ["x", "y"], plt.Not(plt.EqualsString(OVar("x"), OVar("y"))) + ) return super().cmp(op, o) @@ -10295,21 +10458,24 @@

    Ancestors

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsData( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsData), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConstrData( - plt.AddInteger( - plt.Constructor(OVar("x")), plt.Integer(1) - ), - plt.MkNilData(plt.Unit()), - ), ), ), ) @@ -10548,21 +10714,24 @@

    Methods

    if isinstance(op, In): return OLambda( ["x", "y"], - plt.EqualsData( - OVar("x"), - plt.FindList( + plt.AnyList( + OVar("y"), + plt.Apply( + plt.BuiltIn(uplc.BuiltInFun.EqualsData), + OVar("x"), + ), + ), + ) + if isinstance(op, NotIn): + return OLambda( + ["x", "y"], + plt.Not( + plt.AnyList( OVar("y"), plt.Apply( plt.BuiltIn(uplc.BuiltInFun.EqualsData), OVar("x"), ), - # this simply ensures the default is always unequal to the searched value - plt.ConstrData( - plt.AddInteger( - plt.Constructor(OVar("x")), plt.Integer(1) - ), - plt.MkNilData(plt.Unit()), - ), ), ), ) diff --git a/docs/opshin/util.html b/docs/opshin/util.html index 597e6c74..bf892b91 100644 --- a/docs/opshin/util.html +++ b/docs/opshin/util.html @@ -71,6 +71,7 @@

    Module opshin.util

    from _ast import Name, Store, ClassDef, FunctionDef, Load
     from collections import defaultdict
     from copy import copy, deepcopy
    +import logging
     
     import typing
     
    @@ -85,6 +86,40 @@ 

    Module opshin.util

    import pluthon as plt from hashlib import sha256 +OPSHIN_LOGGER = logging.getLogger("opshin") +OPSHIN_LOG_HANDLER = logging.StreamHandler() +OPSHIN_LOGGER.addHandler(OPSHIN_LOG_HANDLER) + + +class FileContextFilter(logging.Filter): + """ + This is a filter which injects contextual information into the log. + + The information is about the currently inspected AST node. + The information needs to be updated inside the NodeTransformer and NodeVisitor classes. + """ + + file_name = "unknown" + node: ast.AST = None + + def filter(self, record): + + if self.node is None: + record.lineno = 1 + record.col_offset = 0 + record.end_lineno = 1 + record.end_col_offset = 0 + else: + record.lineno = self.node.lineno + record.col_offset = self.node.col_offset + record.end_lineno = self.node.end_lineno + record.end_col_offset = self.node.end_col_offset + return True + + +OPSHIN_LOG_CONTEXT_FILTER = FileContextFilter() +OPSHIN_LOG_HANDLER.addFilter(OPSHIN_LOG_CONTEXT_FILTER) + def distinct(xs: list): """Returns true iff the list consists of distinct elements""" @@ -94,6 +129,7 @@

    Module opshin.util

    class TypedNodeTransformer(ast.NodeTransformer): def visit(self, node): """Visit a node.""" + OPSHIN_LOG_CONTEXT_FILTER.node = node node_class_name = node.__class__.__name__ if node_class_name.startswith("Typed"): node_class_name = node_class_name[len("Typed") :] @@ -105,6 +141,7 @@

    Module opshin.util

    class TypedNodeVisitor(ast.NodeVisitor): def visit(self, node): """Visit a node.""" + OPSHIN_LOG_CONTEXT_FILTER.node = node node_class_name = node.__class__.__name__ if node_class_name.startswith("Typed"): node_class_name = node_class_name[len("Typed") :] @@ -124,6 +161,7 @@

    Module opshin.util

    step = "Node transformation" def visit(self, node): + OPSHIN_LOG_CONTEXT_FILTER.node = node try: return super().visit(node) except Exception as e: @@ -775,6 +813,7 @@

    Ancestors

    step = "Node transformation" def visit(self, node): + OPSHIN_LOG_CONTEXT_FILTER.node = node try: return super().visit(node) except Exception as e: @@ -843,6 +882,7 @@

    Methods

    Expand source code
    def visit(self, node):
    +    OPSHIN_LOG_CONTEXT_FILTER.node = node
         try:
             return super().visit(node)
         except Exception as e:
    @@ -938,6 +978,92 @@ 

    Methods

    +
    +class FileContextFilter +(name='') +
    +
    +

    This is a filter which injects contextual information into the log.

    +

    The information is about the currently inspected AST node. +The information needs to be updated inside the NodeTransformer and NodeVisitor classes.

    +

    Initialize a filter.

    +

    Initialize with the name of the logger which, together with its +children, will have its events allowed through the filter. If no +name is specified, allow every event.

    +
    + +Expand source code + +
    class FileContextFilter(logging.Filter):
    +    """
    +    This is a filter which injects contextual information into the log.
    +
    +    The information is about the currently inspected AST node.
    +    The information needs to be updated inside the NodeTransformer and NodeVisitor classes.
    +    """
    +
    +    file_name = "unknown"
    +    node: ast.AST = None
    +
    +    def filter(self, record):
    +
    +        if self.node is None:
    +            record.lineno = 1
    +            record.col_offset = 0
    +            record.end_lineno = 1
    +            record.end_col_offset = 0
    +        else:
    +            record.lineno = self.node.lineno
    +            record.col_offset = self.node.col_offset
    +            record.end_lineno = self.node.end_lineno
    +            record.end_col_offset = self.node.end_col_offset
    +        return True
    +
    +

    Ancestors

    +
      +
    • logging.Filter
    • +
    +

    Class variables

    +
    +
    var file_name
    +
    +
    +
    +
    var node : ast.AST
    +
    +
    +
    +
    +

    Methods

    +
    +
    +def filter(self, record) +
    +
    +

    Determine if the specified record is to be logged.

    +

    Returns True if the record should be logged, or False otherwise. +If deemed appropriate, the record may be modified in-place.

    +
    + +Expand source code + +
    def filter(self, record):
    +
    +    if self.node is None:
    +        record.lineno = 1
    +        record.col_offset = 0
    +        record.end_lineno = 1
    +        record.end_col_offset = 0
    +    else:
    +        record.lineno = self.node.lineno
    +        record.col_offset = self.node.col_offset
    +        record.end_lineno = self.node.end_lineno
    +        record.end_col_offset = self.node.end_col_offset
    +    return True
    +
    +
    +
    +
    class NameReadCollector
    @@ -1269,6 +1395,7 @@

    Methods

    class TypedNodeTransformer(ast.NodeTransformer):
         def visit(self, node):
             """Visit a node."""
    +        OPSHIN_LOG_CONTEXT_FILTER.node = node
             node_class_name = node.__class__.__name__
             if node_class_name.startswith("Typed"):
                 node_class_name = node_class_name[len("Typed") :]
    @@ -1298,6 +1425,7 @@ 

    Methods

    def visit(self, node):
         """Visit a node."""
    +    OPSHIN_LOG_CONTEXT_FILTER.node = node
         node_class_name = node.__class__.__name__
         if node_class_name.startswith("Typed"):
             node_class_name = node_class_name[len("Typed") :]
    @@ -1337,6 +1465,7 @@ 

    Methods

    class TypedNodeVisitor(ast.NodeVisitor):
         def visit(self, node):
             """Visit a node."""
    +        OPSHIN_LOG_CONTEXT_FILTER.node = node
             node_class_name = node.__class__.__name__
             if node_class_name.startswith("Typed"):
                 node_class_name = node_class_name[len("Typed") :]
    @@ -1367,6 +1496,7 @@ 

    Methods

    def visit(self, node):
         """Visit a node."""
    +    OPSHIN_LOG_CONTEXT_FILTER.node = node
         node_class_name = node.__class__.__name__
         if node_class_name.startswith("Typed"):
             node_class_name = node_class_name[len("Typed") :]
    @@ -1487,6 +1617,14 @@ 

    FileContextFilter

    + + +
  • NameReadCollector