view dmd/DotExp.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents 010eb8f0e18d
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;
	}
}