view dmd/ComExp.d @ 63:cab4c37afb89

A bunch of implementations
author korDen
date Mon, 23 Aug 2010 16:52:24 +0400
parents 10317f0c89a5
children 2e2a5c3f943a
line wrap: on
line source

module dmd.ComExp;

import dmd.Expression;
import dmd.Identifier;
import dmd.backend.elem;
import dmd.UnaExp;
import dmd.InterState;
import dmd.OutBuffer;
import dmd.Loc;
import dmd.Scope;
import dmd.IRState;
import dmd.ArrayTypes;
import dmd.TOK;
import dmd.TY;

import dmd.backend.Util;
import dmd.backend.OPER;

import dmd.expression.Util;
import dmd.expression.Com;

class ComExp : UnaExp
{
	this(Loc loc, Expression e)
	{
		super(loc, TOKtilde, ComExp.sizeof, e);
	}

	Expression semantic(Scope sc)
	{
		Expression e;

		if (!type)
		{
			UnaExp.semantic(sc);
			e1 = resolveProperties(sc, e1);
			e = op_overload(sc);
			if (e)
				return e;

			e1.checkNoBool();
			if (e1.op != TOKslice)
				e1 = e1.checkIntegral();
			type = e1.type;
		}
		return this;
	}

	Expression optimize(int result)
	{
		Expression e;

		e1 = e1.optimize(result);
		if (e1.isConst() == 1)
		{
			e = Com(type, e1);
		}
		else
			e = this;

		return e;
	}

	Expression interpret(InterState istate)
	{
		assert(false);
	}

	void buildArrayIdent(OutBuffer buf, Expressions arguments)
	{
		assert(false);
	}

	Expression buildArrayLoop(Arguments fparams)
	{
		assert(false);
	}

	Identifier opId()
	{
		assert(false);
	}

	elem* toElem(IRState* irs)
	{
		elem *e;

		elem *e1 = this.e1.toElem(irs);
		tym_t ty = type.totym();
		if (this.e1.type.toBasetype().ty == Tbool)
			e = el_bin(OPxor, ty, e1, el_long(ty, 1));
		else
			e = el_una(OPcom,ty,e1);
		el_setLoc(e,loc);
		return e;
	}
}