mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			433 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			433 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
| contract D {
 | |
|     uint256 x;
 | |
| 
 | |
|     constructor() {
 | |
|         x = 7;
 | |
|     }
 | |
| 
 | |
|     function f() public view returns (uint256) {
 | |
|         return x;
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| contract C {
 | |
|     function test() public returns (uint256) {
 | |
|         bytes memory c = type(D).creationCode;
 | |
|         D d;
 | |
|         assembly {
 | |
|             d := create(0, add(c, 0x20), mload(c))
 | |
|         }
 | |
|         return d.f();
 | |
|     }
 | |
| }
 | |
| 
 | |
| // ====
 | |
| // compileViaYul: also
 | |
| // ----
 | |
| // test() -> 7
 |