view dmd/DsymbolTable.d @ 184:9f4e5ac4f0a3

One step closer to building on posix. There are two missing symbols so it actually doesn't build but previously it didn't build correctly anyway.
author Jacob Carlborg <doob@me.com>
date Tue, 02 Nov 2010 08:46:11 +0100
parents e3afd1303184
children b0d41ff5e0df
line wrap: on
line source

module dmd.DsymbolTable;

import dmd.common;
import dmd.StringTable;
import dmd.Dsymbol;
import dmd.Identifier;
import dmd.StringValue;

import std.stdio;

import dmd.TObject;

class DsymbolTable : TObject
{
    StringTable tab;

    this()
	{
		register();
	}

    // Look up Identifier. Return Dsymbol if found, NULL if not.
    Dsymbol lookup(Identifier ident)
	{
debug {
		assert(ident);
}
		Object* sv = tab.lookup(ident.string_);
		return (sv ? cast(Dsymbol)*sv : null);
	}

    // Insert Dsymbol in table. Return NULL if already there.
    Dsymbol insert(Dsymbol s)
	{
		Identifier ident = s.ident;
debug {
		assert(ident);
}

		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
	{
		Object* sv = tab.insert(ident.toChars());
		if (sv is null) {
			return null;		// already in table
		}

		*sv = s;
		return s;
	}
}