view dmd/DotExp.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.DotExp;

import dmd.common;
import dmd.Expression;
import dmd.Loc;
import dmd.Scope;
import dmd.ScopeExp;
import dmd.TemplateDeclaration;
import dmd.DotTemplateExp;
import dmd.BinExp;
import dmd.TOK;

class DotExp : BinExp
{
	this(Loc loc, Expression e1, Expression e2)
	{
		register();
		super(loc, TOKdotexp, DotExp.sizeof, e1, e2);
	}

	override Expression semantic(Scope sc)
	{
version (LOGSEMANTIC) {
		printf("DotExp.semantic('%s')\n", toChars());
		if (type) printf("\ttype = %s\n", type.toChars());
}
		e1 = e1.semantic(sc);
		e2 = e2.semantic(sc);
		if (e2.op == TOKimport)
		{
			ScopeExp se = cast(ScopeExp)e2;
			TemplateDeclaration td = se.sds.isTemplateDeclaration();
			if (td)
			{   
				Expression e = new DotTemplateExp(loc, e1, td);
				e = e.semantic(sc);
				return e;
			}
		}
		if (!type)
			type = e2.type;
		return this;
	}
}