mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #6627 from ethereum/add-memory-log
Proto fuzzer: Add missing memory and log opcodes and fix visitation bug
This commit is contained in:
		
						commit
						18104a08b8
					
				| @ -126,6 +126,12 @@ void ProtoConverter::visit(Expression const& _x) | |||||||
| 		case Expression::kUnop: | 		case Expression::kUnop: | ||||||
| 			visit(_x.unop()); | 			visit(_x.unop()); | ||||||
| 			break; | 			break; | ||||||
|  | 		case Expression::kTop: | ||||||
|  | 			visit(_x.top()); | ||||||
|  | 			break; | ||||||
|  | 		case Expression::kNop: | ||||||
|  | 			visit(_x.nop()); | ||||||
|  | 			break; | ||||||
| 		case Expression::EXPR_ONEOF_NOT_SET: | 		case Expression::EXPR_ONEOF_NOT_SET: | ||||||
| 			m_output << "1"; | 			m_output << "1"; | ||||||
| 			break; | 			break; | ||||||
| @ -327,6 +333,89 @@ void ProtoConverter::visit(TernaryOp const& _x) | |||||||
| 	m_output << ")"; | 	m_output << ")"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void ProtoConverter::visit(NullaryOp const& _x) | ||||||
|  | { | ||||||
|  | 	switch (_x.op()) | ||||||
|  | 	{ | ||||||
|  | 		case NullaryOp::PC: | ||||||
|  | 			m_output << "pc()"; | ||||||
|  | 			break; | ||||||
|  | 		case NullaryOp::MSIZE: | ||||||
|  | 			m_output << "msize()"; | ||||||
|  | 			break; | ||||||
|  | 		case NullaryOp::GAS: | ||||||
|  | 			m_output << "gas()"; | ||||||
|  | 			break; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ProtoConverter::visit(LogFunc const& _x) | ||||||
|  | { | ||||||
|  | 	switch (_x.num_topics()) | ||||||
|  | 	{ | ||||||
|  | 		case LogFunc::ZERO: | ||||||
|  | 			m_output << "log0"; | ||||||
|  | 			m_output << "("; | ||||||
|  | 			visit(_x.pos()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.size()); | ||||||
|  | 			m_output << ")\n"; | ||||||
|  | 			break; | ||||||
|  | 		case LogFunc::ONE: | ||||||
|  | 			m_output << "log1"; | ||||||
|  | 			m_output << "("; | ||||||
|  | 			visit(_x.pos()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.size()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t1()); | ||||||
|  | 			m_output << ")\n"; | ||||||
|  | 			break; | ||||||
|  | 		case LogFunc::TWO: | ||||||
|  | 			m_output << "log2"; | ||||||
|  | 			m_output << "("; | ||||||
|  | 			visit(_x.pos()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.size()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t1()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t2()); | ||||||
|  | 			m_output << ")\n"; | ||||||
|  | 			break; | ||||||
|  | 		case LogFunc::THREE: | ||||||
|  | 			m_output << "log3"; | ||||||
|  | 			m_output << "("; | ||||||
|  | 			visit(_x.pos()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.size()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t1()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t2()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t3()); | ||||||
|  | 			m_output << ")\n"; | ||||||
|  | 			break; | ||||||
|  | 		case LogFunc::FOUR: | ||||||
|  | 			m_output << "log4"; | ||||||
|  | 			m_output << "("; | ||||||
|  | 			visit(_x.pos()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.size()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t1()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t2()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t3()); | ||||||
|  | 			m_output << ", "; | ||||||
|  | 			visit(_x.t4()); | ||||||
|  | 			m_output << ")\n"; | ||||||
|  | 			break; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void ProtoConverter::visit(AssignmentStatement const& _x) | void ProtoConverter::visit(AssignmentStatement const& _x) | ||||||
| { | { | ||||||
| 	visit(_x.ref_id()); | 	visit(_x.ref_id()); | ||||||
| @ -353,6 +442,9 @@ void ProtoConverter::visit(StoreFunc const& _x) | |||||||
| 		case StoreFunc::SSTORE: | 		case StoreFunc::SSTORE: | ||||||
| 			m_output << "sstore("; | 			m_output << "sstore("; | ||||||
| 			break; | 			break; | ||||||
|  | 		case StoreFunc::MSTORE8: | ||||||
|  | 			m_output << "mstore8("; | ||||||
|  | 			break; | ||||||
| 	} | 	} | ||||||
| 	visit(_x.loc()); | 	visit(_x.loc()); | ||||||
| 	m_output << ", "; | 	m_output << ", "; | ||||||
| @ -440,6 +532,9 @@ void ProtoConverter::visit(Statement const& _x) | |||||||
| 			if (m_inForScope.top()) | 			if (m_inForScope.top()) | ||||||
| 				m_output << "continue\n"; | 				m_output << "continue\n"; | ||||||
| 			break; | 			break; | ||||||
|  | 		case Statement::kLogFunc: | ||||||
|  | 			visit(_x.log_func()); | ||||||
|  | 			break; | ||||||
| 		case Statement::STMT_ONEOF_NOT_SET: | 		case Statement::STMT_ONEOF_NOT_SET: | ||||||
| 			break; | 			break; | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -67,6 +67,8 @@ private: | |||||||
| 	void visit(CaseStmt const&); | 	void visit(CaseStmt const&); | ||||||
| 	void visit(SwitchStmt const&); | 	void visit(SwitchStmt const&); | ||||||
| 	void visit(TernaryOp const&); | 	void visit(TernaryOp const&); | ||||||
|  | 	void visit(NullaryOp const&); | ||||||
|  | 	void visit(LogFunc const&); | ||||||
| 	template <class T> | 	template <class T> | ||||||
| 	void visit(google::protobuf::RepeatedPtrField<T> const& _repeated_field); | 	void visit(google::protobuf::RepeatedPtrField<T> const& _repeated_field); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -122,22 +122,51 @@ message TernaryOp { | |||||||
|   required Expression arg3 = 4; |   required Expression arg3 = 4; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | message NullaryOp { | ||||||
|  |   enum NOp { | ||||||
|  |     PC = 1; | ||||||
|  |     MSIZE = 2; | ||||||
|  |     GAS = 3; | ||||||
|  |   } | ||||||
|  |   required NOp op = 1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| message StoreFunc { | message StoreFunc { | ||||||
|   enum Storage { |   enum Storage { | ||||||
|     MSTORE = 0; |     MSTORE = 0; | ||||||
|     SSTORE = 1; |     SSTORE = 1; | ||||||
|  |     MSTORE8 = 2; | ||||||
|   } |   } | ||||||
|   required Expression loc = 1; |   required Expression loc = 1; | ||||||
|   required Expression val = 2; |   required Expression val = 2; | ||||||
|   required Storage st = 3; |   required Storage st = 3; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | message LogFunc { | ||||||
|  |   enum NumTopics { | ||||||
|  |     ZERO = 0; | ||||||
|  |     ONE = 1; | ||||||
|  |     TWO = 2; | ||||||
|  |     THREE = 3; | ||||||
|  |     FOUR = 4; | ||||||
|  |   } | ||||||
|  |   required Expression pos = 1; | ||||||
|  |   required Expression size = 2; | ||||||
|  |   required NumTopics num_topics = 3; | ||||||
|  |   required Expression t1 = 4; | ||||||
|  |   required Expression t2 = 5; | ||||||
|  |   required Expression t3 = 6; | ||||||
|  |   required Expression t4 = 7; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| message Expression { | message Expression { | ||||||
|   oneof expr_oneof { |   oneof expr_oneof { | ||||||
|     VarRef varref = 1; |     VarRef varref = 1; | ||||||
|     Literal cons = 2; |     Literal cons = 2; | ||||||
|     BinaryOp binop = 3; |     BinaryOp binop = 3; | ||||||
|     UnaryOp unop = 4; |     UnaryOp unop = 4; | ||||||
|  |     TernaryOp top = 5; | ||||||
|  |     NullaryOp nop = 6; | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -180,6 +209,7 @@ message Statement { | |||||||
|     SwitchStmt          switchstmt    = 7; |     SwitchStmt          switchstmt    = 7; | ||||||
|     BreakStmt           breakstmt     = 8; |     BreakStmt           breakstmt     = 8; | ||||||
|     ContinueStmt        contstmt      = 9; |     ContinueStmt        contstmt      = 9; | ||||||
|  |     LogFunc             log_func      = 10; | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user