MCPcopy Create free account
hub / github.com/argotorg/solidity / appendConstructor

Method appendConstructor

libsolidity/codegen/ContractCompiler.cpp:286–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void ContractCompiler::appendConstructor(FunctionDefinition const& _constructor)
287{
288 CompilerContext::LocationSetter locationSetter(m_context, _constructor);
289 if (!_constructor.isPayable())
290 appendCallValueCheck();
291
292 // copy constructor arguments from code to memory and then to stack, they are supplied after the actual program
293 if (!_constructor.parameters().empty())
294 {
295 CompilerUtils(m_context).fetchFreeMemoryPointer();
296 // CODESIZE returns the actual size of the code,
297 // which is the size of the generated code (``programSize``)
298 // plus the constructor arguments added to the transaction payload.
299 m_context.appendProgramSize();
300 m_context << Instruction::CODESIZE << Instruction::SUB;
301 // stack: <memptr> <argument size>
302 m_context << Instruction::DUP1;
303 m_context.appendProgramSize();
304 m_context << Instruction::DUP4 << Instruction::CODECOPY;
305 // stack: <memptr> <argument size>
306 m_context << Instruction::DUP2 << Instruction::DUP2 << Instruction::ADD;
307 // stack: <memptr> <argument size> <mem end>
308 CompilerUtils(m_context).storeFreeMemoryPointer();
309 // stack: <memptr> <argument size>
310 CompilerUtils(m_context).abiDecode(FunctionType(_constructor).parameterTypes(), true);
311 }
312 _constructor.accept(*this);
313}
314
315void ContractCompiler::appendDelegatecallCheck()
316{

Callers

nothing calls this directly

Calls 11

parametersMethod · 0.80
abiDecodeMethod · 0.80
parameterTypesMethod · 0.80
CompilerUtilsClass · 0.70
FunctionTypeClass · 0.70
isPayableMethod · 0.45
emptyMethod · 0.45
appendProgramSizeMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected