1 /**
2  * This file is part of DCD, a development tool for the D programming language.
3  * Copyright (C) 2014 Brian Schott
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 module dsymbol.deferred;
20 
21 import containers.unrolledlist;
22 import containers.openhashset;
23 import dsymbol.string_interning;
24 import dsymbol.import_;
25 import dsymbol.symbol;
26 import dsymbol.type_lookup;
27 import stdx.allocator;
28 import stdx.allocator.mallocator;
29 
30 /**
31  * Contains information for deferred type resolution
32  */
33 struct DeferredSymbol
34 {
35 	~this()
36 	{
37 		foreach (l; typeLookups[])
38 			Mallocator.instance.dispose(l);
39 		foreach (i; imports[])
40 			Mallocator.instance.dispose(i);
41 	}
42 
43 	bool dependsOn(istring modulePath)
44 	{
45 		foreach (i; imports[])
46 			if (i.symbolFile.ptr == modulePath.ptr)
47 				return true;
48 		return false;
49 	}
50 
51 	/// The symbol that needs its type resolved
52 	DSymbol* symbol;
53 	/// The imports that were in scope for the symbol's declaration'
54 	UnrolledList!(DSymbol*, Mallocator, false) imports;
55 	/// The type lookup information
56 	UnrolledList!(TypeLookup*, Mallocator, false) typeLookups;
57 }