view dmd/VersionSymbol.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 427f8aa74d28
line wrap: on
line source

module dmd.VersionSymbol;

import dmd.Dsymbol;
import dmd.Loc;
import dmd.Identifier;
import dmd.Module;
import dmd.Array;
import dmd.VersionCondition;
import dmd.Scope;
import dmd.ScopeDsymbol;
import dmd.HdrGenState;
import dmd.String;
import dmd.OutBuffer;

class VersionSymbol : Dsymbol
{
    uint level;

	/* VersionSymbol's happen for statements like:
	 *	version = identifier;
	 *	version = integer;
	 */
    this(Loc loc, Identifier ident)
	{
		super(ident);
		this.loc = loc;
	}
	
    this(Loc loc, uint level)
	{
		super();

		this.level = level;
		this.loc = loc;
	}
	
    Dsymbol syntaxCopy(Dsymbol s)
	{
		assert(false);
	}
	
    bool addMember(Scope sc, ScopeDsymbol s, int memnum)
	{
		//printf("VersionSymbol::addMember('%s') %s\n", sd->toChars(), toChars());

		// Do not add the member to the symbol table,
		// just make sure subsequent debug declarations work.
		Module m = s.isModule();
		if (ident)
		{
			VersionCondition.checkPredefined(loc, ident.toChars());
			if (!m)
				error("declaration must be at module level");
			else
			{
				if (findCondition(m.versionidsNot, ident))
					error("defined after use");
				if (!m.versionids)
					m.versionids = new Array();
				m.versionids.push(cast(void*)new String(ident.toChars()));
			}
		}
		else
		{
			if (!m)
				error("level declaration must be at module level");
			else
				m.versionlevel = level;
		}

		return false;
	}
	
    void semantic(Scope sc)
	{
	}
	
    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
	{
		assert(false);
	}
	
    string kind()
	{
		assert(false);
	}
}