mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Emit ast id.
This commit is contained in:
		
							parent
							
								
									a72f4f3993
								
							
						
					
					
						commit
						8b3748e5b7
					
				| @ -340,6 +340,7 @@ string IRGenerator::generateFunction(FunctionDefinition const& _function) | |||||||
| 	return m_context.functionCollector().createFunction(functionName, [&]() { | 	return m_context.functionCollector().createFunction(functionName, [&]() { | ||||||
| 		m_context.resetLocalVariables(); | 		m_context.resetLocalVariables(); | ||||||
| 		Whiskers t(R"( | 		Whiskers t(R"( | ||||||
|  | 			/// @ast-id <astID>
 | ||||||
| 			<sourceLocationComment> | 			<sourceLocationComment> | ||||||
| 			function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> { | 			function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> { | ||||||
| 				<retInit> | 				<retInit> | ||||||
| @ -348,6 +349,7 @@ string IRGenerator::generateFunction(FunctionDefinition const& _function) | |||||||
| 			<contractSourceLocationComment> | 			<contractSourceLocationComment> | ||||||
| 		)"); | 		)"); | ||||||
| 
 | 
 | ||||||
|  | 		t("astID", to_string(_function.id())); | ||||||
| 		t("sourceLocationComment", dispenseLocationComment(_function)); | 		t("sourceLocationComment", dispenseLocationComment(_function)); | ||||||
| 		t( | 		t( | ||||||
| 			"contractSourceLocationComment", | 			"contractSourceLocationComment", | ||||||
| @ -407,6 +409,7 @@ string IRGenerator::generateModifier( | |||||||
| 	return m_context.functionCollector().createFunction(functionName, [&]() { | 	return m_context.functionCollector().createFunction(functionName, [&]() { | ||||||
| 		m_context.resetLocalVariables(); | 		m_context.resetLocalVariables(); | ||||||
| 		Whiskers t(R"( | 		Whiskers t(R"( | ||||||
|  | 			/// @ast-id <astID>
 | ||||||
| 			<sourceLocationComment> | 			<sourceLocationComment> | ||||||
| 			function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> { | 			function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> { | ||||||
| 				<assignRetParams> | 				<assignRetParams> | ||||||
| @ -437,6 +440,7 @@ string IRGenerator::generateModifier( | |||||||
| 			_modifierInvocation.name().annotation().referencedDeclaration | 			_modifierInvocation.name().annotation().referencedDeclaration | ||||||
| 		); | 		); | ||||||
| 		solAssert(modifier, ""); | 		solAssert(modifier, ""); | ||||||
|  | 		t("astID", to_string(modifier->id())); | ||||||
| 		t("sourceLocationComment", dispenseLocationComment(*modifier)); | 		t("sourceLocationComment", dispenseLocationComment(*modifier)); | ||||||
| 		t( | 		t( | ||||||
| 			"contractSourceLocationComment", | 			"contractSourceLocationComment", | ||||||
| @ -542,12 +546,14 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) | |||||||
| 			solAssert(paramTypes.empty(), ""); | 			solAssert(paramTypes.empty(), ""); | ||||||
| 			solUnimplementedAssert(type->sizeOnStack() == 1, ""); | 			solUnimplementedAssert(type->sizeOnStack() == 1, ""); | ||||||
| 			return Whiskers(R"( | 			return Whiskers(R"( | ||||||
|  | 				/// @ast-id <astID>
 | ||||||
| 				<sourceLocationComment> | 				<sourceLocationComment> | ||||||
| 				function <functionName>() -> rval { | 				function <functionName>() -> rval { | ||||||
| 					rval := loadimmutable("<id>") | 					rval := loadimmutable("<id>") | ||||||
| 				} | 				} | ||||||
| 				<contractSourceLocationComment> | 				<contractSourceLocationComment> | ||||||
| 			)") | 			)") | ||||||
|  | 			("astID", to_string(_varDecl.id())) | ||||||
| 			("sourceLocationComment", dispenseLocationComment(_varDecl)) | 			("sourceLocationComment", dispenseLocationComment(_varDecl)) | ||||||
| 			( | 			( | ||||||
| 				"contractSourceLocationComment", | 				"contractSourceLocationComment", | ||||||
| @ -561,12 +567,14 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) | |||||||
| 		{ | 		{ | ||||||
| 			solAssert(paramTypes.empty(), ""); | 			solAssert(paramTypes.empty(), ""); | ||||||
| 			return Whiskers(R"( | 			return Whiskers(R"( | ||||||
|  | 				/// @ast-id <astID>
 | ||||||
| 				<sourceLocationComment> | 				<sourceLocationComment> | ||||||
| 				function <functionName>() -> <ret> { | 				function <functionName>() -> <ret> { | ||||||
| 					<ret> := <constantValueFunction>() | 					<ret> := <constantValueFunction>() | ||||||
| 				} | 				} | ||||||
| 				<contractSourceLocationComment> | 				<contractSourceLocationComment> | ||||||
| 			)") | 			)") | ||||||
|  | 			("astID", to_string(_varDecl.id())) | ||||||
| 			("sourceLocationComment", dispenseLocationComment(_varDecl)) | 			("sourceLocationComment", dispenseLocationComment(_varDecl)) | ||||||
| 			( | 			( | ||||||
| 				"contractSourceLocationComment", | 				"contractSourceLocationComment", | ||||||
| @ -683,6 +691,7 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return Whiskers(R"( | 		return Whiskers(R"( | ||||||
|  | 			/// @ast-id <astID>
 | ||||||
| 			<sourceLocationComment> | 			<sourceLocationComment> | ||||||
| 			function <functionName>(<params>) -> <retVariables> { | 			function <functionName>(<params>) -> <retVariables> { | ||||||
| 				<code> | 				<code> | ||||||
| @ -693,6 +702,7 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) | |||||||
| 		("params", joinHumanReadable(parameters)) | 		("params", joinHumanReadable(parameters)) | ||||||
| 		("retVariables", joinHumanReadable(returnVariables)) | 		("retVariables", joinHumanReadable(returnVariables)) | ||||||
| 		("code", std::move(code)) | 		("code", std::move(code)) | ||||||
|  | 		("astID", to_string(_varDecl.id())) | ||||||
| 		("sourceLocationComment", dispenseLocationComment(_varDecl)) | 		("sourceLocationComment", dispenseLocationComment(_varDecl)) | ||||||
| 		( | 		( | ||||||
| 			"contractSourceLocationComment", | 			"contractSourceLocationComment", | ||||||
| @ -804,7 +814,7 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract) | |||||||
| 		m_context.resetLocalVariables(); | 		m_context.resetLocalVariables(); | ||||||
| 		m_context.functionCollector().createFunction(IRNames::constructor(*contract), [&]() { | 		m_context.functionCollector().createFunction(IRNames::constructor(*contract), [&]() { | ||||||
| 			Whiskers t(R"( | 			Whiskers t(R"( | ||||||
| 				<sourceLocationComment> | 				<astIDComment><sourceLocationComment> | ||||||
| 				function <functionName>(<params><comma><baseParams>) { | 				function <functionName>(<params><comma><baseParams>) { | ||||||
| 					<evalBaseArguments> | 					<evalBaseArguments> | ||||||
| 					<sourceLocationComment> | 					<sourceLocationComment> | ||||||
| @ -819,6 +829,10 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract) | |||||||
| 				for (ASTPointer<VariableDeclaration> const& varDecl: contract->constructor()->parameters()) | 				for (ASTPointer<VariableDeclaration> const& varDecl: contract->constructor()->parameters()) | ||||||
| 					params += m_context.addLocalVariable(*varDecl).stackSlots(); | 					params += m_context.addLocalVariable(*varDecl).stackSlots(); | ||||||
| 
 | 
 | ||||||
|  | 			if (contract->constructor()) | ||||||
|  | 				t("astIDComment", "/// @ast-id " + to_string(contract->constructor()->id()) + "\n"); | ||||||
|  | 			else | ||||||
|  | 				t("astIDComment", ""); | ||||||
| 			t("sourceLocationComment", dispenseLocationComment( | 			t("sourceLocationComment", dispenseLocationComment( | ||||||
| 				contract->constructor() ? | 				contract->constructor() ? | ||||||
| 				dynamic_cast<ASTNode const&>(*contract->constructor()) : | 				dynamic_cast<ASTNode const&>(*contract->constructor()) : | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user