view dmd/TemplateAliasParameter.d @ 13:427f8aa74d28

On the road to make Phobos compilable
author korDen
date Mon, 12 Apr 2010 16:29:33 +0400
parents 89cc05dbdae1
children 460959608115
line wrap: on
line source

module dmd.TemplateAliasParameter;

import dmd.TemplateParameter;
import dmd.Loc;
import dmd.Identifier;
import dmd.Type;
import dmd.ArrayTypes;
import dmd.Scope;
import dmd.Declaration;
import dmd.MATCH;
import dmd.OutBuffer;
import dmd.HdrGenState;
import dmd.Dsymbol;
import dmd.TypeIdentifier;
import dmd.AliasDeclaration;
import dmd.Util;

import dmd.templates.Util;

class TemplateAliasParameter : TemplateParameter
{
    /* Syntax:
     *	specType ident : specAlias = defaultAlias
     */

    Type specType;
    Object specAlias;
    Object defaultAlias;

    static Dsymbol sdummy;

    this(Loc loc, Identifier ident, Type specType, Object specAlias, Object defaultAlias)
	{
		super(loc, ident);

		this.specType = specType;
		this.specAlias = specAlias;
		this.defaultAlias = defaultAlias;
	}

    TemplateAliasParameter isTemplateAliasParameter()
	{
		return this;
	}
	
    TemplateParameter syntaxCopy()
	{
		TemplateAliasParameter tp = new TemplateAliasParameter(loc, ident, specType, specAlias, defaultAlias);
		if (tp.specType)
			tp.specType = specType.syntaxCopy();
		tp.specAlias = objectSyntaxCopy(specAlias);
		tp.defaultAlias = objectSyntaxCopy(defaultAlias);
		return tp;
	}
	
    void declareParameter(Scope sc)
	{
		TypeIdentifier ti = new TypeIdentifier(loc, ident);
		sparam = new AliasDeclaration(loc, ident, ti);
		if (!sc.insert(sparam))
			error(loc, "parameter '%s' multiply defined", ident.toChars());
	}
	
    void semantic(Scope sc)
	{
		if (specType)
		{
			specType = specType.semantic(loc, sc);
		}
		specAlias = aliasParameterSemantic(loc, sc, specAlias);
static if (false) { // Don't do semantic() until instantiation
		if (defaultAlias)
			defaultAlias = defaultAlias.semantic(loc, sc);
}
	}
	
    void print(Object oarg, Object oded)
	{
		assert(false);
	}
	
    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
	{
		assert(false);
	}
	
    Object specialization()
	{
		assert(false);
	}
	
    Object defaultArg(Loc loc, Scope sc)
	{
		assert(false);
	}
	
    bool overloadMatch(TemplateParameter)
	{
		assert(false);
	}
	
    MATCH matchArg(Scope sc, Objects tiargs, int i, TemplateParameters parameters, Objects dedtypes, Declaration* psparam, int flags)
	{
		assert(false);
	}
	
    void* dummyArg()
	{
		assert(false);
	}
}