view dmd/ConditionalStatement.d @ 49:0aa7d1437ada

AttribDeclaration.oneMember Lexer.decodeUTF WithStatement.ctor StructDeclaration.syntaxCopy CtorDeclaration.syntaxCopy ConditionalStatement.syntaxCopy ProtDeclaration.syntaxCopy ArrayScopeSymbol.this TemplateDeclaration.toChars
author korDen
date Sat, 21 Aug 2010 07:53:20 +0400
parents 10317f0c89a5
children 4290d870944a
line wrap: on
line source

module dmd.ConditionalStatement;

import dmd.Statement;
import dmd.Condition;
import dmd.Loc;
import dmd.OutBuffer;
import dmd.Scope;
import dmd.HdrGenState;
import dmd.ArrayTypes;
import dmd.BE;

class ConditionalStatement : Statement
{
    Condition condition;
    Statement ifbody;
    Statement elsebody;

    this(Loc loc, Condition condition, Statement ifbody, Statement elsebody)
	{
		super(loc);
		this.condition = condition;
		this.ifbody = ifbody;
		this.elsebody = elsebody;
	}
	
    Statement syntaxCopy()
	{
		Statement e = null;
		if (elsebody)
			e = elsebody.syntaxCopy();
		ConditionalStatement s = new ConditionalStatement(loc, condition.syntaxCopy(), ifbody.syntaxCopy(), e);
		return s;
	}
	
    Statement semantic(Scope sc)
	{
		assert(false);
	}
	
    Statements flatten(Scope sc)
	{
		Statement s;

		if (condition.include(sc, null))
			s = ifbody;
		else
			s = elsebody;

		Statements a = new Statements();
		a.push(cast(void*)s);

		return a;
	}
	
    bool usesEH()
	{
		assert(false);
	}
	
    BE blockExit()
	{
		assert(false);
	}

    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
	{
		assert(false);
	}
}