diff options
author | chriseth <chris@ethereum.org> | 2019-01-10 23:44:31 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2019-01-18 03:36:48 +0800 |
commit | e6fee257e68e7b145a47eee8c5937db7a7a99849 (patch) | |
tree | d4dce225357536d378d69f1ac87c4c5132d15613 /libsolidity/codegen/CompilerUtils.cpp | |
parent | 2fcfb216b5dcb5cec2d70d2ee7647df47c8166ca (diff) | |
download | dexon-solidity-e6fee257e68e7b145a47eee8c5937db7a7a99849.tar dexon-solidity-e6fee257e68e7b145a47eee8c5937db7a7a99849.tar.gz dexon-solidity-e6fee257e68e7b145a47eee8c5937db7a7a99849.tar.bz2 dexon-solidity-e6fee257e68e7b145a47eee8c5937db7a7a99849.tar.lz dexon-solidity-e6fee257e68e7b145a47eee8c5937db7a7a99849.tar.xz dexon-solidity-e6fee257e68e7b145a47eee8c5937db7a7a99849.tar.zst dexon-solidity-e6fee257e68e7b145a47eee8c5937db7a7a99849.zip |
Code generation for access to contract code.
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index bbc703c7..9b7244ba 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -1199,6 +1199,29 @@ void CompilerUtils::computeHashStatic() m_context << u256(32) << u256(0) << Instruction::KECCAK256; } +void CompilerUtils::copyContractCodeToMemory(ContractDefinition const& contract, bool _creation) +{ + string which = _creation ? "Creation" : "Runtime"; + m_context.callLowLevelFunction( + "$copyContract" + which + "CodeToMemory_" + contract.type()->identifier(), + 1, + 1, + [&contract, _creation](CompilerContext& _context) + { + // copy the contract's code into memory + eth::Assembly const& assembly = + _creation ? + _context.compiledContract(contract) : + _context.compiledContractRuntime(contract); + // pushes size + auto subroutine = _context.addSubroutine(make_shared<eth::Assembly>(assembly)); + _context << Instruction::DUP1 << subroutine; + _context << Instruction::DUP4 << Instruction::CODECOPY; + _context << Instruction::ADD; + } + ); +} + void CompilerUtils::storeStringData(bytesConstRef _data) { //@todo provide both alternatives to the optimiser |