mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Revert with reason.
This commit is contained in:
		
							parent
							
								
									60a42f58a0
								
							
						
					
					
						commit
						021b312264
					
				| @ -123,9 +123,6 @@ string YulUtilFunctions::requireOrAssertFunction(bool _assert, Type const* _mess | ||||
| 			("functionName", functionName) | ||||
| 			.render(); | ||||
| 
 | ||||
| 
 | ||||
| 		solUnimplemented("require() with two parameters is not yet implemented."); | ||||
| 		// TODO The code below is completely untested as we don't support StringLiterals yet
 | ||||
| 		int const hashHeaderSize = 4; | ||||
| 		int const byteSize = 8; | ||||
| 		u256 const errorHash = | ||||
| @ -140,20 +137,24 @@ string YulUtilFunctions::requireOrAssertFunction(bool _assert, Type const* _mess | ||||
| 			); | ||||
| 
 | ||||
| 		return Whiskers(R"( | ||||
| 			function <functionName>(condition, message) { | ||||
| 			function <functionName>(condition <messageVars>) { | ||||
| 				if iszero(condition) { | ||||
| 					let fmp := mload(<freeMemPointer>) | ||||
| 					mstore(fmp, <errorHash>) | ||||
| 					let end := <abiEncodeFunc>(add(fmp, <hashHeaderSize>), message) | ||||
| 					let end := <abiEncodeFunc>(add(fmp, <hashHeaderSize>) <messageVars>) | ||||
| 					revert(fmp, sub(end, fmp)) | ||||
| 				} | ||||
| 			} | ||||
| 		)") | ||||
| 		("functionName", functionName) | ||||
| 		("freeMemPointer", to_string(CompilerUtils::freeMemoryPointer)) | ||||
| 		("errorHash", errorHash.str()) | ||||
| 		("errorHash", formatNumber(errorHash)) | ||||
| 		("abiEncodeFunc", encodeFunc) | ||||
| 		("hashHeaderSize", to_string(hashHeaderSize)) | ||||
| 		("messageVars", | ||||
| 			(_messageType->sizeOnStack() > 0 ? ", " : "") + | ||||
| 			suffixedVariableNameList("message_", 1, 1 + _messageType->sizeOnStack()) | ||||
| 		) | ||||
| 		.render(); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user