mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Yul proto fuzzer: Add create and call opcodes
This commit is contained in:
		
							parent
							
								
									6b27ef8fcb
								
							
						
					
					
						commit
						c889e6e015
					
				| @ -152,6 +152,12 @@ void ProtoConverter::visit(Expression const& _x) | ||||
| 		else | ||||
| 			m_output << dictionaryToken(); | ||||
| 		break; | ||||
| 	case Expression::kLowcall: | ||||
| 		visit(_x.lowcall()); | ||||
| 		break; | ||||
| 	case Expression::kCreate: | ||||
| 		visit(_x.create()); | ||||
| 		break; | ||||
| 	case Expression::EXPR_ONEOF_NOT_SET: | ||||
| 		m_output << dictionaryToken(); | ||||
| 		break; | ||||
| @ -713,6 +719,68 @@ void ProtoConverter::visit(FunctionCall const& _x) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void ProtoConverter::visit(LowLevelCall const& _x) | ||||
| { | ||||
| 	LowLevelCall_Type type = _x.callty(); | ||||
| 	switch (type) | ||||
| 	{ | ||||
| 	case LowLevelCall::CALL: | ||||
| 		m_output << "call("; | ||||
| 		break; | ||||
| 	case LowLevelCall::CALLCODE: | ||||
| 		m_output << "callcode("; | ||||
| 		break; | ||||
| 	case LowLevelCall::DELEGATECALL: | ||||
| 		m_output << "delegatecall("; | ||||
| 		break; | ||||
| 	case LowLevelCall::STATICCALL: | ||||
| 		m_output << "staticcall("; | ||||
| 		break; | ||||
| 	} | ||||
| 	visit(_x.gas()); | ||||
| 	m_output << ", "; | ||||
| 	visit(_x.addr()); | ||||
| 	m_output << ", "; | ||||
| 	if (type == LowLevelCall::CALL || LowLevelCall::CALLCODE) | ||||
| 	{ | ||||
| 		visit(_x.wei()); | ||||
| 		m_output << ", "; | ||||
| 	} | ||||
| 	visit(_x.in()); | ||||
| 	m_output << ", "; | ||||
| 	visit(_x.insize()); | ||||
| 	m_output << ", "; | ||||
| 	visit(_x.out()); | ||||
| 	m_output << ", "; | ||||
| 	visit(_x.outsize()); | ||||
| 	m_output << ")"; | ||||
| } | ||||
| 
 | ||||
| void ProtoConverter::visit(Create const& _x) | ||||
| { | ||||
| 	Create_Type type = _x.createty(); | ||||
| 	switch (type) | ||||
| 	{ | ||||
| 	case Create::CREATE: | ||||
| 		m_output << "create("; | ||||
| 		break; | ||||
| 	case Create::CREATE2: | ||||
| 		m_output << "create2("; | ||||
| 		break; | ||||
| 	} | ||||
| 	visit(_x.wei()); | ||||
| 	m_output << ", "; | ||||
| 	visit(_x.position()); | ||||
| 	m_output << ", "; | ||||
| 	visit(_x.size()); | ||||
| 	if (type == Create::CREATE2) | ||||
| 	{ | ||||
| 		m_output << ", "; | ||||
| 		visit(_x.value()); | ||||
| 	} | ||||
| 	m_output << ")"; | ||||
| } | ||||
| 
 | ||||
| void ProtoConverter::visit(IfStmt const& _x) | ||||
| { | ||||
| 	m_output << "if "; | ||||
|  | ||||
| @ -86,6 +86,8 @@ private: | ||||
| 	void visit(FunctionCall const&); | ||||
| 	void visit(FunctionDef const&); | ||||
| 	void visit(PopStmt const&); | ||||
| 	void visit(LowLevelCall const&); | ||||
| 	void visit(Create const&); | ||||
| 	void visit(Program const&); | ||||
| 
 | ||||
| 	/// Creates a new scope, and adds @a _funcParams to it if it
 | ||||
|  | ||||
| @ -21,6 +21,37 @@ message VarDecl { | ||||
|   required Expression expr = 1; | ||||
| } | ||||
| 
 | ||||
| message LowLevelCall { | ||||
|   enum Type { | ||||
|     CALL = 0; | ||||
|     CALLCODE = 1; | ||||
|     DELEGATECALL = 2; | ||||
|     STATICCALL = 3; | ||||
|   } | ||||
|   required Type callty = 1; | ||||
|   required Expression gas = 2; | ||||
|   required Expression addr = 3; | ||||
|   // Valid for call and callcode only | ||||
|   required Expression wei = 4; | ||||
|   required Expression in = 5; | ||||
|   required Expression insize = 6; | ||||
|   required Expression out = 7; | ||||
|   required Expression outsize = 8; | ||||
| } | ||||
| 
 | ||||
| message Create { | ||||
|   enum Type { | ||||
|     CREATE = 0; | ||||
|     CREATE2 = 1; | ||||
|   } | ||||
|   required Type createty = 1; | ||||
|   required Expression wei = 2; | ||||
|   required Expression position = 3; | ||||
|   required Expression size = 4; | ||||
|   // Valid for create2 only | ||||
|   required Expression value = 5; | ||||
| } | ||||
| 
 | ||||
| message FunctionCall { | ||||
|   enum Returns { | ||||
|     ZERO = 1; | ||||
| @ -225,6 +256,8 @@ message Expression { | ||||
|     TernaryOp top = 5; | ||||
|     NullaryOp nop = 6; | ||||
|     FunctionCall func_expr = 7; | ||||
|     LowLevelCall lowcall = 8; | ||||
|     Create create = 9; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user