| 284 | } |
| 285 | |
| 286 | void 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 | |
| 315 | void ContractCompiler::appendDelegatecallCheck() |
| 316 | { |
nothing calls this directly
no test coverage detected