view dmd/templates/Util.d @ 192:eb38fdcb3e62 default tip

updated to compile with dmd2.062
author korDen
date Sat, 02 Mar 2013 01:25:52 -0800
parents e28b18c23469
children
line wrap: on
line source

module dmd.templates.Util;

import dmd.common;
import dmd.Dsymbol;
import dmd.Type;
import dmd.Expression;
import dmd.Loc;
import dmd.Scope;
import dmd.WANT;

version (DMDV2) {
	Object objectSyntaxCopy(Object o)
	{
		if (!o)
			return null;

		Type t = isType(o);
		if (t)
			return t.syntaxCopy();

		Expression e = isExpression(o);
		if (e)
			return e.syntaxCopy();

		return o;
	}
}

Object aliasParameterSemantic(Loc loc, Scope sc, Object o)
{
    if (o)
    {
		Expression ea = isExpression(o);
		Type ta = isType(o);
		if (ta)
		{   
			Dsymbol s = ta.toDsymbol(sc);
			if (s)
				o = s;
			else
				o = ta.semantic(loc, sc);
		}
		else if (ea)
		{
			ea = ea.semantic(sc);
			o = ea.optimize(WANTvalue | WANTinterpret);
		}
    }
    return o;
}