Created
October 20, 2023 17:22
-
-
Save Dliteofficial/d4e470cff0937a0ad893e7cdbe1ca59a to your computer and use it in GitHub Desktop.
How To Build a Smart Contract Compiler Using Python Solc-x Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity 0.8.17; | |
contract access { | |
address public owner; | |
constructor() { | |
owner = msg.sender; | |
} | |
function updateOwner(address _address) public { | |
require(msg.sender == owner, "!Owner"); | |
owner = _address; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import solcx | |
import toml | |
from packaging import version | |
solidity_code = """ | |
//SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.0; | |
contract arrayContract { | |
uint[] public nums = [1, 2, 3]; | |
uint[3] public numsFixed = [4, 5, 6]; | |
function examples() external { | |
nums.push(4); | |
nums[2] = 777; | |
delete nums[1]; | |
nums.pop(); | |
} | |
function returnArray() external view returns(uint[] memory) { | |
return nums; | |
} | |
function memoryArray() external pure returns (uint) { | |
uint[] memory a = new uint[](5); | |
a[1] = 123; | |
return a[1]; | |
} | |
} | |
""" | |
def pragma_finder(file): | |
try: | |
with open(file, 'r', encoding='utf-8') as f: | |
lines = f.read().split("\n") | |
except Exception as e: | |
print(f"ERR: {e}") | |
# finding out the solidity compiler version that is used by the contract and the contract name | |
for line in lines: | |
if line.strip().startswith("pragma solidity "): | |
pragma_version = line.split("pragma solidity ")[-1].rstrip(";") | |
if pragma_version.startswith(">=") or pragma_version.startswith("<=") or pragma_version.startswith("="): | |
pragma_version = pragma_version.split("=")[-1] | |
break | |
elif pragma_version.startswith("<"): | |
pragma_version = find_lower_version(pragma_version.split("<")[-1]) | |
break | |
## figures out the pragma version to use when a higher version is required | |
elif pragma_version.startswith(">"): | |
pragma_version = find_higher_version(pragma_version.split(">")[-1]) | |
break | |
# Any version that includes a caret | |
# means the version itself can be used | |
elif pragma_version.startswith("^"): | |
pragma_version = pragma_version.split("^")[-1] | |
break | |
else: | |
continue | |
return pragma_version | |
## Resolves the imports of the contract | |
def resolve_imports(basePath:str) -> list: | |
remap_list = [] | |
## Checks if remappings.txt exist in the base path | |
if os.path.exists(os.path.join(basePath, 'remappings.txt')): | |
# Copies the content of the remappings file into 'remappings' else, it throws an exception/error | |
try: | |
with open(os.path.join(basePath, 'remappings.txt'), 'r', encoding="utf-8") as content: | |
remappings = content.read().split("\n") | |
except Exception as err: | |
print(f"FILE OPEN ERROR: {err}") | |
elif os.path.exists(os.path.join(basePath, "foundry.toml")): | |
try: | |
content = toml.load(os.path.join(basePath, "foundry.toml")) | |
for each in content["profile"]: | |
remappings = content["profile"][each]['remappings'] | |
except Exception as err: | |
print(f"FOUNDRY TOML OPERATION ERROR: {err}") | |
# For each remapping, split into from_path and to_path, verify that the path exist, then reconfigure the remappings | |
for remapping in remappings: | |
if len(remapping.split("=")) == 2: | |
from_path,to_path = remapping.split("=") | |
to_path = to_path.strip() | |
full_to_path = os.path.join(os.path.relpath(basePath), to_path) | |
if os.path.exists(full_to_path): | |
new_map = f"{from_path}={full_to_path}" | |
remap_list.append(new_map) | |
else: | |
print(f"Warning: Path does not exist: {full_to_path}") | |
else: | |
print(f"Warning: Malformed remapping line: {remapping}") | |
# Returns reamp list | |
return remap_list | |
# Remove functionname an function visibility to ensure that the compiler worksas it should | |
def compile_contract_source(solidity_code): | |
# Figure out the pragma version and install it. Since the contract requires anything above 0.8.0, we'll use 0.8.17 | |
pragma_version = "0.8.17" | |
found = False | |
# You can check to see if the version of the compiler you specifie is has been installed | |
# by checking if it is among the compilers installed on your machine | |
list_of_installed_compilers = solcx.get_installed_solc_versions() | |
for compiler in list_of_installed_compilers: | |
if str(compiler) == pragma_version: | |
found = True | |
break | |
if not found: solcx.install_solc(pragma_version) | |
# Actual compilations happen here | |
# It is good practice to catch possible errors in a try and catch statement | |
try: | |
ast = solcx.compile_source(solidity_code, output_values=["ast"], solc_version=pragma_version) | |
if ast: print(f"ABI of solidity code is printed below\n\n {ast}") | |
except solcx.exceptions.solcError as error: | |
print(f"ERR: AST COMPILATION MODE ERROR {error}") | |
try: | |
abi = solcx.compile_source(solidity_code, output_values=["abi"], solc_version=pragma_version) | |
if abi: print(f"\nABI of solidity code is printed below\n\n {abi}") | |
except solcx.exceptions.solcError as error: | |
print(f"ERR: ABI COMPILATION MODE ERROR {error}") | |
# Takes in the file path for the soliity contract you are | |
# trying to compile | |
def compile_contract_file(solidity_contract: str): | |
pragma_version = pragma_finder(solidity_contract) | |
found = False | |
# You can check to see if the version of the compiler you specifie is has been installed by checking if it is among the compilers installed on your machine | |
list_of_installed_compilers = solcx.get_installed_solc_versions() | |
for compiler in list_of_installed_compilers: | |
if str(compiler) == pragma_version: | |
found = True | |
break | |
if not found: solcx.install_solc(pragma_version) | |
# Actual compilations happen here | |
# It is good practice to catch possible errors in a try and catch statement | |
try: | |
BR = solcx.compile_files([solidity_contract], output_values=["bin-runtime"], solc_version=pragma_version) | |
if BR: print(f"Bin runtime of solidity code is printed below\n\n {BR}") | |
except solcx.exceptions.solcError as error: | |
print(f"ERR: BIN RUNTIME COMPILATION MODE ERROR {error}") | |
try: | |
abi = solcx.compile_files([solidity_contract], output_values=["abi"], solc_version=pragma_version) | |
if abi: print(f"\nABI of solidity code is printed below\n\n {abi}") | |
except solcx.exceptions.solcError as error: | |
print(f"ERR: ABI COMPILATION MODE ERROR {error}") | |
def find_higher_version(input_version:str) -> str: | |
version_input = version.parse(input_version) | |
higher_version = None | |
versions = [str(ver) for ver in solcx.get_installable_solc_versions()][::-1] | |
for ver in versions: | |
current_version = version.parse(ver) | |
if current_version > version_input: | |
higher_version = current_version | |
break | |
# Check if a higher version was found | |
if higher_version is not None: | |
return str(higher_version) | |
else: | |
return "No higher version found" | |
def find_lower_version(input_version:str) -> str: | |
version_input = version.parse(input_version) | |
lower_version = None | |
versions = [str(ver) for ver in solcx.get_installable_solc_versions()] | |
for ver in versions: | |
current_version = version.parse(ver) | |
if current_version < version_input: | |
lower_version = current_version | |
break | |
# Check if a higher version was found | |
if lower_version is not None: | |
return str(lower_version) | |
else: | |
return "lower version found" | |
compile_contract_source(solidity_code) | |
solidity_file = r"access.sol" | |
compile_contract_file(solidity_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'<stdin>:arrayContract': {'ast': {'absolutePath': '<stdin>', 'exportedSymbols': {'arrayContract': [79]}, 'id': 80, 'license': 'UNLICENSED', 'nodeType': 'SourceUnit', 'nodes': [{'id': 1, 'literals': ['solidity', '^', '0.8', '.0'], 'nodeType': 'PragmaDirective', 'src': '39:23:0'}, {'abstract': False, 'baseContracts': [], 'canonicalName': 'arrayContract', 'contractDependencies': [], 'contractKind': 'contract', 'fullyImplemented': True, 'id': 79, 'linearizedBaseContracts': [79], 'name': 'arrayContract', 'nameLocation': '73:13:0', 'nodeType': 'ContractDefinition', 'nodes': [{'constant': False, 'functionSelector': 'fd1ee54c', 'id': 8, 'mutability': 'mutable', 'name': 'nums', 'nameLocation': '108:4:0', 'nodeType': 'VariableDeclaration', 'scope': 79, 'src': '94:30:0', 'stateVariable': True, 'storageLocation': 'default', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage', 'typeString': 'uint256[]'}, 'typeName': {'baseType': {'id': 2, 'name': 'uint', 'nodeType': 'ElementaryTypeName', 'src': '94:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'id': 3, 'nodeType': 'ArrayTypeName', 'src': '94:6:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage_ptr', 'typeString': 'uint256[]'}}, 'value': {'components': [{'hexValue': '31', 'id': 4, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '116:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_1_by_1', 'typeString': 'int_const 1'}, 'value': '1'}, {'hexValue': '32', 'id': 5, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '119:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_2_by_1', 'typeString': 'int_const 2'}, 'value': '2'}, {'hexValue': '33', 'id': 6, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '122:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_3_by_1', 'typeString': 'int_const 3'}, 'value': '3'}], 'id': 7, 'isConstant': False, 'isInlineArray': True, 'isLValue': False, 'isPure': True, 'lValueRequested': False, 'nodeType': 'TupleExpression', 'src': '115:9:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint8_$3_memory_ptr', 'typeString': 'uint8[3] memory'}}, 'visibility': 'public'}, {'constant': False, 'functionSelector': '44395769', 'id': 16, 'mutability': 'mutable', 'name': 'numsFixed', 'nameLocation': '145:9:0', 'nodeType': 'VariableDeclaration', 'scope': 79, 'src': '130:36:0', 'stateVariable': True, 'storageLocation': 'default', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$3_storage', 'typeString': 'uint256[3]'}, 'typeName': {'baseType': {'id': 9, 'name': 'uint', 'nodeType': 'ElementaryTypeName', 'src': '130:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'id': 11, 'length': {'hexValue': '33', 'id': 10, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '135:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_3_by_1', 'typeString': 'int_const 3'}, 'value': '3'}, 'nodeType': 'ArrayTypeName', 'src': '130:7:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$3_storage_ptr', 'typeString': 'uint256[3]'}}, 'value': {'components': [{'hexValue': '34', 'id': 12, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '158:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_4_by_1', 'typeString': 'int_const 4'}, 'value': '4'}, {'hexValue': '35', 'id': 13, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '161:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_5_by_1', 'typeString': 'int_const 5'}, 'value': '5'}, {'hexValue': '36', 'id': 14, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '164:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_6_by_1', 'typeString': 'int_const 6'}, 'value': '6'}], 'id': 15, 'isConstant': False, 'isInlineArray': True, 'isLValue': False, 'isPure': True, 'lValueRequested': False, 'nodeType': 'TupleExpression', 'src': '157:9:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint8_$3_memory_ptr', 'typeString': 'uint8[3] memory'}}, 'visibility': 'public'}, {'body': {'id': 41, 'nodeType': 'Block', 'src': '202:96:0', 'statements': [{'expression': {'arguments': [{'hexValue': '34', 'id': 22, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '222:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_4_by_1', 'typeString': 'int_const 4'}, 'value': '4'}], 'expression': {'argumentTypes': [{'typeIdentifier': 't_rational_4_by_1', 'typeString': 'int_const 4'}], 'expression': {'id': 19, 'name': 'nums', 'nodeType': 'Identifier', 'overloadedDeclarations': [], 'referencedDeclaration': 8, 'src': '212:4:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage', 'typeString': 'uint256[] storage ref'}}, 'id': 21, 'isConstant': False, 'isLValue': False, 'isPure': False, 'lValueRequested': False, 'memberLocation': '217:4:0', 'memberName': 'push', 'nodeType': 'MemberAccess', 'src': '212:9:0', 'typeDescriptions': {'typeIdentifier': 't_function_arraypush_nonpayable$_t_array$_t_uint256_$dyn_storage_ptr_$_t_uint256_$returns$__$bound_to$_t_array$_t_uint256_$dyn_storage_ptr_$', 'typeString': 'function (uint256[] storage pointer,uint256)'}}, 'id': 23, 'isConstant': False, 'isLValue': False, 'isPure': False, 'kind': 'functionCall', 'lValueRequested': False, 'nameLocations': [], 'names': [], 'nodeType': 'FunctionCall', 'src': '212:12:0', 'tryCall': False, 'typeDescriptions': {'typeIdentifier': 't_tuple$__$', 'typeString': 'tuple()'}}, 'id': 24, 'nodeType': 'ExpressionStatement', 'src': '212:12:0'}, {'expression': {'id': 29, 'isConstant': False, 'isLValue': False, 'isPure': False, 'lValueRequested': False, 'leftHandSide': {'baseExpression': {'id': 25, 'name': 'nums', 'nodeType': 'Identifier', 'overloadedDeclarations': [], 'referencedDeclaration': 8, 'src': '234:4:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage', 'typeString': 'uint256[] storage ref'}}, 'id': 27, 'indexExpression': {'hexValue': '32', 'id': 26, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '239:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_2_by_1', 'typeString': 'int_const 2'}, 'value': '2'}, 'isConstant': False, 'isLValue': True, 'isPure': False, 'lValueRequested': True, 'nodeType': 'IndexAccess', 'src': '234:7:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'nodeType': 'Assignment', 'operator': '=', 'rightHandSide': {'hexValue': '373737', 'id': 28, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '244:3:0', 'typeDescriptions': {'typeIdentifier': 't_rational_777_by_1', 'typeString': 'int_const 777'}, 'value': '777'}, 'src': '234:13:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'id': 30, 'nodeType': 'ExpressionStatement', 'src': '234:13:0'}, {'expression': {'id': 34, 'isConstant': False, 'isLValue': False, 'isPure': False, 'lValueRequested': False, 'nodeType': 'UnaryOperation', 'operator': 'delete', 'prefix': True, 'src': '257:14:0', 'subExpression': {'baseExpression': {'id': 31, 'name': 'nums', 'nodeType': 'Identifier', 'overloadedDeclarations': [], 'referencedDeclaration': 8, 'src': '264:4:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage', 'typeString': 'uint256[] storage ref'}}, 'id': 33, 'indexExpression': {'hexValue': '31', 'id': 32, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '269:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_1_by_1', 'typeString': 'int_const 1'}, 'value': '1'}, 'isConstant': False, 'isLValue': True, 'isPure': False, 'lValueRequested': True, 'nodeType': 'IndexAccess', 'src': '264:7:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'typeDescriptions': {'typeIdentifier': 't_tuple$__$', 'typeString': 'tuple()'}}, 'id': 35, 'nodeType': 'ExpressionStatement', 'src': '257:14:0'}, {'expression': | |
{'arguments': [], 'expression': {'argumentTypes': [], 'expression': {'id': 36, 'name': 'nums', 'nodeType': 'Identifier', 'overloadedDeclarations': [], 'referencedDeclaration': 8, 'src': '281:4:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage', 'typeString': 'uint256[] storage ref'}}, 'id': 38, 'isConstant': False, 'isLValue': False, 'isPure': False, 'lValueRequested': False, 'memberLocation': '286:3:0', 'memberName': 'pop', 'nodeType': 'MemberAccess', 'src': '281:8:0', 'typeDescriptions': {'typeIdentifier': 't_function_arraypop_nonpayable$_t_array$_t_uint256_$dyn_storage_ptr_$returns$__$bound_to$_t_array$_t_uint256_$dyn_storage_ptr_$', 'typeString': 'function (uint256[] storage pointer)'}}, 'id': 39, 'isConstant': False, 'isLValue': False, 'isPure': False, 'kind': 'functionCall', 'lValueRequested': False, 'nameLocations': [], 'names': [], 'nodeType': 'FunctionCall', 'src': '281:10:0', 'tryCall': False, 'typeDescriptions': {'typeIdentifier': 't_tuple$__$', 'typeString': 'tuple()'}}, 'id': 40, 'nodeType': 'ExpressionStatement', 'src': '281:10:0'}]}, 'functionSelector': '335d00c2', 'id': 42, 'implemented': True, 'kind': 'function', 'modifiers': [], 'name': 'examples', 'nameLocation': '182:8:0', 'nodeType': 'FunctionDefinition', 'parameters': {'id': 17, 'nodeType': 'ParameterList', 'parameters': [], 'src': '190:2:0'}, 'returnParameters': {'id': 18, 'nodeType': 'ParameterList', 'parameters': [], 'src': '202:0:0'}, 'scope': 79, 'src': '173:125:0', 'stateMutability': 'nonpayable', 'virtual': False, 'visibility': 'external'}, {'body': {'id': 50, 'nodeType': 'Block', 'src': '364:26:0', 'statements': [{'expression': {'id': 48, 'name': 'nums', 'nodeType': 'Identifier', 'overloadedDeclarations': [], 'referencedDeclaration': 8, 'src': '379:4:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage', 'typeString': 'uint256[] storage ref'}}, 'functionReturnParameters': 47, | |
'id': 49, 'nodeType': 'Return', 'src': '372:11:0'}]}, 'functionSelector': '3cac14c8', 'id': 51, 'implemented': True, 'kind': 'function', 'modifiers': [], 'name': 'returnArray', 'nameLocation': '313:11:0', 'nodeType': 'FunctionDefinition', 'parameters': {'id': 43, 'nodeType': 'ParameterList', 'parameters': [], 'src': '324:2:0'}, 'returnParameters': {'id': 47, 'nodeType': 'ParameterList', 'parameters': [{'constant': False, 'id': 46, 'mutability': 'mutable', 'name': '', 'nameLocation': '-1:-1:-1', 'nodeType': 'VariableDeclaration', 'scope': 51, 'src': '349:13:0', 'stateVariable': False, 'storageLocation': 'memory', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_memory_ptr', 'typeString': 'uint256[]'}, 'typeName': {'baseType': {'id': 44, 'name': 'uint', 'nodeType': 'ElementaryTypeName', 'src': '349:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'id': 45, 'nodeType': 'ArrayTypeName', 'src': '349:6:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage_ptr', | |
'typeString': 'uint256[]'}}, 'visibility': 'internal'}], 'src': '348:15:0'}, 'scope': 79, 'src': '304:86:0', 'stateMutability': 'view', 'virtual': False, 'visibility': 'external'}, {'body': {'id': 77, 'nodeType': 'Block', 'src': '448:83:0', 'statements': [{'assignments': [60], 'declarations': [{'constant': False, 'id': 60, 'mutability': 'mutable', 'name': 'a', 'nameLocation': '470:1:0', 'nodeType': 'VariableDeclaration', 'scope': 77, 'src': '456:15:0', 'stateVariable': False, 'storageLocation': 'memory', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_memory_ptr', 'typeString': 'uint256[]'}, 'typeName': {'baseType': {'id': 58, 'name': 'uint', 'nodeType': 'ElementaryTypeName', 'src': '456:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'id': 59, 'nodeType': 'ArrayTypeName', 'src': '456:6:0', 'typeDescriptions': {'typeIdentifier': | |
't_array$_t_uint256_$dyn_storage_ptr', 'typeString': 'uint256[]'}}, 'visibility': 'internal'}], 'id': 66, 'initialValue': {'arguments': [{'hexValue': '35', 'id': 64, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '485:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_5_by_1', 'typeString': 'int_const 5'}, 'value': '5'}], 'expression': {'argumentTypes': [{'typeIdentifier': 't_rational_5_by_1', 'typeString': 'int_const 5'}], 'id': 63, 'isConstant': False, 'isLValue': False, 'isPure': True, 'lValueRequested': False, 'nodeType': 'NewExpression', 'src': '474:10:0', 'typeDescriptions': {'typeIdentifier': 't_function_objectcreation_pure$_t_uint256_$returns$_t_array$_t_uint256_$dyn_memory_ptr_$', 'typeString': 'function (uint256) pure returns (uint256[] memory)'}, 'typeName': {'baseType': {'id': 61, 'name': 'uint', 'nodeType': 'ElementaryTypeName', 'src': '478:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'id': 62, 'nodeType': 'ArrayTypeName', 'src': '478:6:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_storage_ptr', 'typeString': 'uint256[]'}}}, 'id': 65, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'functionCall', 'lValueRequested': False, 'nameLocations': [], 'names': [], 'nodeType': 'FunctionCall', 'src': '474:13:0', 'tryCall': False, 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_memory_ptr', 'typeString': 'uint256[] memory'}}, 'nodeType': 'VariableDeclarationStatement', 'src': '456:31:0'}, {'expression': {'id': 71, 'isConstant': False, 'isLValue': False, 'isPure': False, 'lValueRequested': False, 'leftHandSide': {'baseExpression': {'id': 67, 'name': 'a', 'nodeType': 'Identifier', 'overloadedDeclarations': [], 'referencedDeclaration': 60, 'src': '495:1:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_memory_ptr', 'typeString': 'uint256[] memory'}}, 'id': 69, 'indexExpression': {'hexValue': '31', 'id': 68, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '497:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_1_by_1', 'typeString': 'int_const 1'}, 'value': '1'}, 'isConstant': False, 'isLValue': True, 'isPure': False, 'lValueRequested': True, 'nodeType': 'IndexAccess', 'src': '495:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'nodeType': 'Assignment', 'operator': '=', | |
'rightHandSide': {'hexValue': '313233', 'id': 70, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '502:3:0', 'typeDescriptions': {'typeIdentifier': 't_rational_123_by_1', 'typeString': 'int_const 123'}, 'value': '123'}, 'src': '495:10:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'id': 72, 'nodeType': 'ExpressionStatement', 'src': '495:10:0'}, {'expression': {'baseExpression': {'id': 73, 'name': 'a', 'nodeType': 'Identifier', 'overloadedDeclarations': [], 'referencedDeclaration': 60, 'src': '520:1:0', 'typeDescriptions': {'typeIdentifier': 't_array$_t_uint256_$dyn_memory_ptr', 'typeString': 'uint256[] memory'}}, 'id': | |
75, 'indexExpression': {'hexValue': '31', 'id': 74, 'isConstant': False, 'isLValue': False, 'isPure': True, 'kind': 'number', 'lValueRequested': False, 'nodeType': 'Literal', 'src': '522:1:0', 'typeDescriptions': {'typeIdentifier': 't_rational_1_by_1', 'typeString': 'int_const 1'}, 'value': '1'}, | |
'isConstant': False, 'isLValue': True, 'isPure': False, 'lValueRequested': False, 'nodeType': 'IndexAccess', 'src': '520:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'functionReturnParameters': 55, 'id': 76, 'nodeType': 'Return', 'src': '513:11:0'}]}, 'functionSelector': '500e1355', 'id': 78, 'implemented': True, 'kind': 'function', 'modifiers': [], 'name': 'memoryArray', 'nameLocation': '405:11:0', 'nodeType': 'FunctionDefinition', 'parameters': {'id': 52, 'nodeType': 'ParameterList', 'parameters': [], 'src': '416:2:0'}, 'returnParameters': {'id': 55, 'nodeType': 'ParameterList', 'parameters': [{'constant': False, 'id': 54, 'mutability': 'mutable', 'name': '', 'nameLocation': '-1:-1:-1', 'nodeType': 'VariableDeclaration', 'scope': 78, 'src': '442:4:0', 'stateVariable': False, 'storageLocation': 'default', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}, 'typeName': {'id': 53, 'name': 'uint', 'nodeType': 'ElementaryTypeName', 'src': '442:4:0', 'typeDescriptions': {'typeIdentifier': 't_uint256', 'typeString': 'uint256'}}, 'visibility': 'internal'}], 'src': '441:6:0'}, 'scope': 79, 'src': '396:135:0', 'stateMutability': 'pure', 'virtual': False, 'visibility': 'external'}], 'scope': 80, 'src': '64:470:0', 'usedErrors': []}], 'src': '39:496:0'}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"<stdin>:arrayContract": { | |
"ast": { | |
"absolutePath": "<stdin>", | |
"exportedSymbols": {"arrayContract": [79]}, | |
"id": 80, | |
"license": "UNLICENSED", | |
"nodeType": "SourceUnit", | |
"nodes": [ | |
{ | |
"id": 1, | |
"literals": ["solidity", "^", "0.8", ".0"], | |
"nodeType": "PragmaDirective", | |
"src": "39:23:0", | |
}, | |
{ | |
"abstract": False, | |
"baseContracts": [], | |
"canonicalName": "arrayContract", | |
"contractDependencies": [], | |
"contractKind": "contract", | |
"fullyImplemented": True, | |
"id": 79, | |
"linearizedBaseContracts": [79], | |
"name": "arrayContract", | |
"nameLocation": "73:13:0", | |
"nodeType": "ContractDefinition", | |
"nodes": [ | |
{ | |
"constant": False, | |
"functionSelector": "fd1ee54c", | |
"id": 8, | |
"mutability": "mutable", | |
"name": "nums", | |
"nameLocation": "108:4:0", | |
"nodeType": "VariableDeclaration", | |
"scope": 79, | |
"src": "94:30:0", | |
"stateVariable": True, | |
"storageLocation": "default", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage", | |
"typeString": "uint256[]", | |
}, | |
"typeName": { | |
"baseType": { | |
"id": 2, | |
"name": "uint", | |
"nodeType": "ElementaryTypeName", | |
"src": "94:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"id": 3, | |
"nodeType": "ArrayTypeName", | |
"src": "94:6:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", | |
"typeString": "uint256[]", | |
}, | |
}, | |
"value": { | |
"components": [ | |
{ | |
"hexValue": "31", | |
"id": 4, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "116:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_1_by_1", | |
"typeString": "int_const 1", | |
}, | |
"value": "1", | |
}, | |
{ | |
"hexValue": "32", | |
"id": 5, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "119:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_2_by_1", | |
"typeString": "int_const 2", | |
}, | |
"value": "2", | |
}, | |
{ | |
"hexValue": "33", | |
"id": 6, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "122:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_3_by_1", | |
"typeString": "int_const 3", | |
}, | |
"value": "3", | |
}, | |
], | |
"id": 7, | |
"isConstant": False, | |
"isInlineArray": True, | |
"isLValue": False, | |
"isPure": True, | |
"lValueRequested": False, | |
"nodeType": "TupleExpression", | |
"src": "115:9:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint8_$3_memory_ptr", | |
"typeString": "uint8[3] memory", | |
}, | |
}, | |
"visibility": "public", | |
}, | |
{ | |
"constant": False, | |
"functionSelector": "44395769", | |
"id": 16, | |
"mutability": "mutable", | |
"name": "numsFixed", | |
"nameLocation": "145:9:0", | |
"nodeType": "VariableDeclaration", | |
"scope": 79, | |
"src": "130:36:0", | |
"stateVariable": True, | |
"storageLocation": "default", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$3_storage", | |
"typeString": "uint256[3]", | |
}, | |
"typeName": { | |
"baseType": { | |
"id": 9, | |
"name": "uint", | |
"nodeType": "ElementaryTypeName", | |
"src": "130:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"id": 11, | |
"length": { | |
"hexValue": "33", | |
"id": 10, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "135:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_3_by_1", | |
"typeString": "int_const 3", | |
}, | |
"value": "3", | |
}, | |
"nodeType": "ArrayTypeName", | |
"src": "130:7:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$3_storage_ptr", | |
"typeString": "uint256[3]", | |
}, | |
}, | |
"value": { | |
"components": [ | |
{ | |
"hexValue": "34", | |
"id": 12, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "158:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_4_by_1", | |
"typeString": "int_const 4", | |
}, | |
"value": "4", | |
}, | |
{ | |
"hexValue": "35", | |
"id": 13, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "161:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_5_by_1", | |
"typeString": "int_const 5", | |
}, | |
"value": "5", | |
}, | |
{ | |
"hexValue": "36", | |
"id": 14, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "164:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_6_by_1", | |
"typeString": "int_const 6", | |
}, | |
"value": "6", | |
}, | |
], | |
"id": 15, | |
"isConstant": False, | |
"isInlineArray": True, | |
"isLValue": False, | |
"isPure": True, | |
"lValueRequested": False, | |
"nodeType": "TupleExpression", | |
"src": "157:9:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint8_$3_memory_ptr", | |
"typeString": "uint8[3] memory", | |
}, | |
}, | |
"visibility": "public", | |
}, | |
{ | |
"body": { | |
"id": 41, | |
"nodeType": "Block", | |
"src": "202:96:0", | |
"statements": [ | |
{ | |
"expression": { | |
"arguments": [ | |
{ | |
"hexValue": "34", | |
"id": 22, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "222:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_4_by_1", | |
"typeString": "int_const 4", | |
}, | |
"value": "4", | |
} | |
], | |
"expression": { | |
"argumentTypes": [ | |
{ | |
"typeIdentifier": "t_rational_4_by_1", | |
"typeString": "int_const 4", | |
} | |
], | |
"expression": { | |
"id": 19, | |
"name": "nums", | |
"nodeType": "Identifier", | |
"overloadedDeclarations": [], | |
"referencedDeclaration": 8, | |
"src": "212:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage", | |
"typeString": "uint256[] storage ref", | |
}, | |
}, | |
"id": 21, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": False, | |
"lValueRequested": False, | |
"memberLocation": "217:4:0", | |
"memberName": "push", | |
"nodeType": "MemberAccess", | |
"src": "212:9:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_function_arraypush_nonpayable$_t_array$_t_uint256_$dyn_storage_ptr_$_t_uint256_$returns$__$bound_to$_t_array$_t_uint256_$dyn_storage_ptr_$", | |
"typeString": "function (uint256[] storage pointer,uint256)", | |
}, | |
}, | |
"id": 23, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": False, | |
"kind": "functionCall", | |
"lValueRequested": False, | |
"nameLocations": [], | |
"names": [], | |
"nodeType": "FunctionCall", | |
"src": "212:12:0", | |
"tryCall": False, | |
"typeDescriptions": { | |
"typeIdentifier": "t_tuple$__$", | |
"typeString": "tuple()", | |
}, | |
}, | |
"id": 24, | |
"nodeType": "ExpressionStatement", | |
"src": "212:12:0", | |
}, | |
{ | |
"expression": { | |
"id": 29, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": False, | |
"lValueRequested": False, | |
"leftHandSide": { | |
"baseExpression": { | |
"id": 25, | |
"name": "nums", | |
"nodeType": "Identifier", | |
"overloadedDeclarations": [], | |
"referencedDeclaration": 8, | |
"src": "234:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage", | |
"typeString": "uint256[] storage ref", | |
}, | |
}, | |
"id": 27, | |
"indexExpression": { | |
"hexValue": "32", | |
"id": 26, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "239:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_2_by_1", | |
"typeString": "int_const 2", | |
}, | |
"value": "2", | |
}, | |
"isConstant": False, | |
"isLValue": True, | |
"isPure": False, | |
"lValueRequested": True, | |
"nodeType": "IndexAccess", | |
"src": "234:7:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"nodeType": "Assignment", | |
"operator": "=", | |
"rightHandSide": { | |
"hexValue": "373737", | |
"id": 28, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "244:3:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_777_by_1", | |
"typeString": "int_const 777", | |
}, | |
"value": "777", | |
}, | |
"src": "234:13:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"id": 30, | |
"nodeType": "ExpressionStatement", | |
"src": "234:13:0", | |
}, | |
{ | |
"expression": { | |
"id": 34, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": False, | |
"lValueRequested": False, | |
"nodeType": "UnaryOperation", | |
"operator": "delete", | |
"prefix": True, | |
"src": "257:14:0", | |
"subExpression": { | |
"baseExpression": { | |
"id": 31, | |
"name": "nums", | |
"nodeType": "Identifier", | |
"overloadedDeclarations": [], | |
"referencedDeclaration": 8, | |
"src": "264:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage", | |
"typeString": "uint256[] storage ref", | |
}, | |
}, | |
"id": 33, | |
"indexExpression": { | |
"hexValue": "31", | |
"id": 32, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "269:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_1_by_1", | |
"typeString": "int_const 1", | |
}, | |
"value": "1", | |
}, | |
"isConstant": False, | |
"isLValue": True, | |
"isPure": False, | |
"lValueRequested": True, | |
"nodeType": "IndexAccess", | |
"src": "264:7:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"typeDescriptions": { | |
"typeIdentifier": "t_tuple$__$", | |
"typeString": "tuple()", | |
}, | |
}, | |
"id": 35, | |
"nodeType": "ExpressionStatement", | |
"src": "257:14:0", | |
}, | |
{ | |
"expression": { | |
"arguments": [], | |
"expression": { | |
"argumentTypes": [], | |
"expression": { | |
"id": 36, | |
"name": "nums", | |
"nodeType": "Identifier", | |
"overloadedDeclarations": [], | |
"referencedDeclaration": 8, | |
"src": "281:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage", | |
"typeString": "uint256[] storage ref", | |
}, | |
}, | |
"id": 38, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": False, | |
"lValueRequested": False, | |
"memberLocation": "286:3:0", | |
"memberName": "pop", | |
"nodeType": "MemberAccess", | |
"src": "281:8:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_function_arraypop_nonpayable$_t_array$_t_uint256_$dyn_storage_ptr_$returns$__$bound_to$_t_array$_t_uint256_$dyn_storage_ptr_$", | |
"typeString": "function (uint256[] storage pointer)", | |
}, | |
}, | |
"id": 39, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": False, | |
"kind": "functionCall", | |
"lValueRequested": False, | |
"nameLocations": [], | |
"names": [], | |
"nodeType": "FunctionCall", | |
"src": "281:10:0", | |
"tryCall": False, | |
"typeDescriptions": { | |
"typeIdentifier": "t_tuple$__$", | |
"typeString": "tuple()", | |
}, | |
}, | |
"id": 40, | |
"nodeType": "ExpressionStatement", | |
"src": "281:10:0", | |
}, | |
], | |
}, | |
"functionSelector": "335d00c2", | |
"id": 42, | |
"implemented": True, | |
"kind": "function", | |
"modifiers": [], | |
"name": "examples", | |
"nameLocation": "182:8:0", | |
"nodeType": "FunctionDefinition", | |
"parameters": { | |
"id": 17, | |
"nodeType": "ParameterList", | |
"parameters": [], | |
"src": "190:2:0", | |
}, | |
"returnParameters": { | |
"id": 18, | |
"nodeType": "ParameterList", | |
"parameters": [], | |
"src": "202:0:0", | |
}, | |
"scope": 79, | |
"src": "173:125:0", | |
"stateMutability": "nonpayable", | |
"virtual": False, | |
"visibility": "external", | |
}, | |
{ | |
"body": { | |
"id": 50, | |
"nodeType": "Block", | |
"src": "364:26:0", | |
"statements": [ | |
{ | |
"expression": { | |
"id": 48, | |
"name": "nums", | |
"nodeType": "Identifier", | |
"overloadedDeclarations": [], | |
"referencedDeclaration": 8, | |
"src": "379:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage", | |
"typeString": "uint256[] storage ref", | |
}, | |
}, | |
"functionReturnParameters": 47, | |
"id": 49, | |
"nodeType": "Return", | |
"src": "372:11:0", | |
} | |
], | |
}, | |
"functionSelector": "3cac14c8", | |
"id": 51, | |
"implemented": True, | |
"kind": "function", | |
"modifiers": [], | |
"name": "returnArray", | |
"nameLocation": "313:11:0", | |
"nodeType": "FunctionDefinition", | |
"parameters": { | |
"id": 43, | |
"nodeType": "ParameterList", | |
"parameters": [], | |
"src": "324:2:0", | |
}, | |
"returnParameters": { | |
"id": 47, | |
"nodeType": "ParameterList", | |
"parameters": [ | |
{ | |
"constant": False, | |
"id": 46, | |
"mutability": "mutable", | |
"name": "", | |
"nameLocation": "-1:-1:-1", | |
"nodeType": "VariableDeclaration", | |
"scope": 51, | |
"src": "349:13:0", | |
"stateVariable": False, | |
"storageLocation": "memory", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr", | |
"typeString": "uint256[]", | |
}, | |
"typeName": { | |
"baseType": { | |
"id": 44, | |
"name": "uint", | |
"nodeType": "ElementaryTypeName", | |
"src": "349:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"id": 45, | |
"nodeType": "ArrayTypeName", | |
"src": "349:6:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", | |
"typeString": "uint256[]", | |
}, | |
}, | |
"visibility": "internal", | |
} | |
], | |
"src": "348:15:0", | |
}, | |
"scope": 79, | |
"src": "304:86:0", | |
"stateMutability": "view", | |
"virtual": False, | |
"visibility": "external", | |
}, | |
{ | |
"body": { | |
"id": 77, | |
"nodeType": "Block", | |
"src": "448:83:0", | |
"statements": [ | |
{ | |
"assignments": [60], | |
"declarations": [ | |
{ | |
"constant": False, | |
"id": 60, | |
"mutability": "mutable", | |
"name": "a", | |
"nameLocation": "470:1:0", | |
"nodeType": "VariableDeclaration", | |
"scope": 77, | |
"src": "456:15:0", | |
"stateVariable": False, | |
"storageLocation": "memory", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr", | |
"typeString": "uint256[]", | |
}, | |
"typeName": { | |
"baseType": { | |
"id": 58, | |
"name": "uint", | |
"nodeType": "ElementaryTypeName", | |
"src": "456:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"id": 59, | |
"nodeType": "ArrayTypeName", | |
"src": "456:6:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", | |
"typeString": "uint256[]", | |
}, | |
}, | |
"visibility": "internal", | |
} | |
], | |
"id": 66, | |
"initialValue": { | |
"arguments": [ | |
{ | |
"hexValue": "35", | |
"id": 64, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "485:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_5_by_1", | |
"typeString": "int_const 5", | |
}, | |
"value": "5", | |
} | |
], | |
"expression": { | |
"argumentTypes": [ | |
{ | |
"typeIdentifier": "t_rational_5_by_1", | |
"typeString": "int_const 5", | |
} | |
], | |
"id": 63, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"lValueRequested": False, | |
"nodeType": "NewExpression", | |
"src": "474:10:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_function_objectcreation_pure$_t_uint256_$returns$_t_array$_t_uint256_$dyn_memory_ptr_$", | |
"typeString": "function (uint256) pure returns (uint256[] memory)", | |
}, | |
"typeName": { | |
"baseType": { | |
"id": 61, | |
"name": "uint", | |
"nodeType": "ElementaryTypeName", | |
"src": "478:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"id": 62, | |
"nodeType": "ArrayTypeName", | |
"src": "478:6:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_storage_ptr", | |
"typeString": "uint256[]", | |
}, | |
}, | |
}, | |
"id": 65, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "functionCall", | |
"lValueRequested": False, | |
"nameLocations": [], | |
"names": [], | |
"nodeType": "FunctionCall", | |
"src": "474:13:0", | |
"tryCall": False, | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr", | |
"typeString": "uint256[] memory", | |
}, | |
}, | |
"nodeType": "VariableDeclarationStatement", | |
"src": "456:31:0", | |
}, | |
{ | |
"expression": { | |
"id": 71, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": False, | |
"lValueRequested": False, | |
"leftHandSide": { | |
"baseExpression": { | |
"id": 67, | |
"name": "a", | |
"nodeType": "Identifier", | |
"overloadedDeclarations": [], | |
"referencedDeclaration": 60, | |
"src": "495:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr", | |
"typeString": "uint256[] memory", | |
}, | |
}, | |
"id": 69, | |
"indexExpression": { | |
"hexValue": "31", | |
"id": 68, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "497:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_1_by_1", | |
"typeString": "int_const 1", | |
}, | |
"value": "1", | |
}, | |
"isConstant": False, | |
"isLValue": True, | |
"isPure": False, | |
"lValueRequested": True, | |
"nodeType": "IndexAccess", | |
"src": "495:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"nodeType": "Assignment", | |
"operator": "=", | |
"rightHandSide": { | |
"hexValue": "313233", | |
"id": 70, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "502:3:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_123_by_1", | |
"typeString": "int_const 123", | |
}, | |
"value": "123", | |
}, | |
"src": "495:10:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"id": 72, | |
"nodeType": "ExpressionStatement", | |
"src": "495:10:0", | |
}, | |
{ | |
"expression": { | |
"baseExpression": { | |
"id": 73, | |
"name": "a", | |
"nodeType": "Identifier", | |
"overloadedDeclarations": [], | |
"referencedDeclaration": 60, | |
"src": "520:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_array$_t_uint256_$dyn_memory_ptr", | |
"typeString": "uint256[] memory", | |
}, | |
}, | |
"id": 75, | |
"indexExpression": { | |
"hexValue": "31", | |
"id": 74, | |
"isConstant": False, | |
"isLValue": False, | |
"isPure": True, | |
"kind": "number", | |
"lValueRequested": False, | |
"nodeType": "Literal", | |
"src": "522:1:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_rational_1_by_1", | |
"typeString": "int_const 1", | |
}, | |
"value": "1", | |
}, | |
"isConstant": False, | |
"isLValue": True, | |
"isPure": False, | |
"lValueRequested": False, | |
"nodeType": "IndexAccess", | |
"src": "520:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"functionReturnParameters": 55, | |
"id": 76, | |
"nodeType": "Return", | |
"src": "513:11:0", | |
}, | |
], | |
}, | |
"functionSelector": "500e1355", | |
"id": 78, | |
"implemented": True, | |
"kind": "function", | |
"modifiers": [], | |
"name": "memoryArray", | |
"nameLocation": "405:11:0", | |
"nodeType": "FunctionDefinition", | |
"parameters": { | |
"id": 52, | |
"nodeType": "ParameterList", | |
"parameters": [], | |
"src": "416:2:0", | |
}, | |
"returnParameters": { | |
"id": 55, | |
"nodeType": "ParameterList", | |
"parameters": [ | |
{ | |
"constant": False, | |
"id": 54, | |
"mutability": "mutable", | |
"name": "", | |
"nameLocation": "-1:-1:-1", | |
"nodeType": "VariableDeclaration", | |
"scope": 78, | |
"src": "442:4:0", | |
"stateVariable": False, | |
"storageLocation": "default", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
"typeName": { | |
"id": 53, | |
"name": "uint", | |
"nodeType": "ElementaryTypeName", | |
"src": "442:4:0", | |
"typeDescriptions": { | |
"typeIdentifier": "t_uint256", | |
"typeString": "uint256", | |
}, | |
}, | |
"visibility": "internal", | |
} | |
], | |
"src": "441:6:0", | |
}, | |
"scope": 79, | |
"src": "396:135:0", | |
"stateMutability": "pure", | |
"virtual": False, | |
"visibility": "external", | |
}, | |
], | |
"scope": 80, | |
"src": "64:470:0", | |
"usedErrors": [], | |
}, | |
], | |
"src": "39:496:0", | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment