view dmd/SwitchErrorStatement.d @ 187:b0d41ff5e0df

Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author Abscissa
date Tue, 07 Jun 2011 23:37:34 -0400
parents e3afd1303184
children
line wrap: on
line source

module dmd.SwitchErrorStatement;

import dmd.common;
import dmd.Statement;
import dmd.OutBuffer;
import dmd.Loc;
import dmd.IRState;
import dmd.HdrGenState;
import dmd.BE;

import dmd.backend.elem;
import dmd.backend.Blockx;
import dmd.backend.Util;
import dmd.backend.TYM;
import dmd.backend.OPER;
import dmd.backend.RTLSYM;

import dmd.DDMDExtensions;

class SwitchErrorStatement : Statement
{
	mixin insertMemberExtension!(typeof(this));

	this(Loc loc)
	{
		register();
		super(loc);
	}

	override BE blockExit()
	{
		return BE.BEthrow;
	}

	override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
	{
		buf.writestring("SwitchErrorStatement.toCBuffer()");
		buf.writenl();
	}

	override void toIR(IRState* irs)
	{
		elem* e;
		elem* elinnum;
		elem* efilename;
		Blockx* blx = irs.blx;

		//printf("SwitchErrorStatement.toIR()\n");

		efilename = blx.module_.toEmodulename();
		elinnum = el_long(TYM.TYint, loc.linnum);
		e = el_bin(OPER.OPcall, TYM.TYvoid, el_var(rtlsym[RTLSYM_DSWITCHERR]), el_param(elinnum, efilename));
		block_appendexp(blx.curblock, e);
	}
}