Mercurial > projects > ddmd
view dmd/DsymbolTable.d @ 94:3a0b150c9841
Objects -> Vector!Object iteration 1
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 23:00:34 +0100 |
parents | 10317f0c89a5 |
children | e28b18c23469 |
line wrap: on
line source
module dmd.DsymbolTable; import dmd.StringTable; import dmd.Dsymbol; import dmd.Identifier; import dmd.StringValue; import std.stdio; class DsymbolTable { StringTable tab; this() { tab = new StringTable; } ~this() { delete tab; } // Look up Identifier. Return Dsymbol if found, NULL if not. Dsymbol lookup(Identifier ident) { debug { assert(ident); assert(tab); } StringValue* sv = tab.lookup(ident.string_); return (sv ? cast(Dsymbol)sv.ptrvalue : null); } // Insert Dsymbol in table. Return NULL if already there. Dsymbol insert(Dsymbol s) { Identifier ident = s.ident; debug { assert(ident); assert(tab); } return insert(ident, s); } // Look for Dsymbol in table. If there, return it. If not, insert s and return that. Dsymbol update(Dsymbol s) { assert(false); } Dsymbol insert(Identifier ident, Dsymbol s) // when ident and s are not the same { StringValue* sv = tab.insert(ident.toChars()); if (sv is null) { return null; // already in table } sv.ptrvalue = cast(void*)s; return s; } }