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 : dispose; 28 import stdx.allocator.mallocator : Mallocator; 29 import dsymbol.semantic : TypeLookups, TypeLookupsAllocator; 30 31 alias ImportsAllocator = Mallocator; 32 alias Imports = UnrolledList!(DSymbol*, ImportsAllocator); 33 34 /** 35 * Contains information for deferred type resolution 36 */ 37 struct DeferredSymbol 38 { 39 ~this() 40 { 41 foreach (l; typeLookups[]) 42 TypeLookupsAllocator.instance.dispose(l); 43 foreach (i; imports[]) 44 ImportsAllocator.instance.dispose(i); 45 } 46 47 bool dependsOn(istring modulePath) 48 { 49 foreach (i; imports[]) 50 if (i.symbolFile == modulePath) 51 return true; 52 return false; 53 } 54 55 /// The symbol that needs its type resolved 56 DSymbol* symbol; 57 /// The imports that were in scope for the symbol's declaration' 58 Imports imports; 59 /// The type lookup information 60 TypeLookups typeLookups; 61 }