mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	smtr: Structs have local scope
Also unique_name can take field_name directly.
This commit is contained in:
		
							parent
							
								
									a2abbcb33f
								
							
						
					
					
						commit
						d6c5e13bf3
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -75,15 +75,16 @@ class SmtrStruct {
 | 
			
		|||
	};
 | 
			
		||||
	idict<IdString> field_names;
 | 
			
		||||
	vector<Field> fields;
 | 
			
		||||
	SmtrScope &scope;
 | 
			
		||||
	SmtrScope &global_scope;
 | 
			
		||||
	SmtrScope local_scope;
 | 
			
		||||
public:
 | 
			
		||||
	std::string name;
 | 
			
		||||
	SmtrStruct(std::string name, SmtrScope &scope) : scope(scope), name(name) {}
 | 
			
		||||
	SmtrStruct(std::string name, SmtrScope &scope) : global_scope(scope), local_scope(), name(name) {}
 | 
			
		||||
	void insert(IdString field_name, SmtrSort sort) {
 | 
			
		||||
		field_names(field_name);
 | 
			
		||||
		auto base_name = scope.unique_name("\\" + RTLIL::unescape_id(field_name));
 | 
			
		||||
		auto base_name = local_scope.unique_name(field_name);
 | 
			
		||||
		auto accessor = name + "-" + base_name;
 | 
			
		||||
		scope.reserve(accessor);
 | 
			
		||||
		global_scope.reserve(accessor);
 | 
			
		||||
		fields.emplace_back(Field{sort, accessor, base_name});
 | 
			
		||||
	}
 | 
			
		||||
	void write_definition(SExprWriter &w) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue