view dmd/Statement.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents cab4c37afb89
children 9e39c7de8438
line wrap: on
line source

module dmd.Statement;

import dmd.common;
import dmd.TryCatchStatement;
import dmd.GotoStatement;
import dmd.AsmStatement;
import dmd.ScopeStatement;
import dmd.DeclarationStatement;
import dmd.CompoundStatement;
import dmd.ReturnStatement;
import dmd.IfStatement;
import dmd.Scope;
import dmd.Loc;
import dmd.OutBuffer;
import dmd.HdrGenState;
import dmd.ArrayTypes;
import dmd.Expression;
import dmd.InterState;
import dmd.InlineCostState;
import dmd.InlineDoState;
import dmd.InlineScanState;
import dmd.IRState;
import dmd.BE;
import dmd.Global;
import dmd.Util;

template START()
{
	enum START = q{
		if (istate.start)
		{
			if (istate.start != this)
				return null;
			istate.start = null;
		}
	};
}

class Statement
{
    Loc loc;

    this(Loc loc)
	{
		this.loc = loc;
	}

    Statement syntaxCopy()
	{
		assert(false);
	}

    void print()
	{
		assert(false);
	}
	
    string toChars()
	{
		assert(false);
	}

    void error(T...)(string format, T t)
	{
		.error(loc, format, t);
	}
	
    void warning(T...)(string format, T t)
	{
		if (global.params.warnings && !global.gag)
		{
			writef("warning - ");
			.error(loc, format, t);
		}
	}

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

    TryCatchStatement isTryCatchStatement() { return null; }

    GotoStatement isGotoStatement() { return null; }

    AsmStatement isAsmStatement() { return null; }

version (_DH) {
    int incontract;
}
    ScopeStatement isScopeStatement() { return null; }

    Statement semantic(Scope sc)
	{
		assert(false);
	}
	
    Statement semanticScope(Scope sc, Statement sbreak, Statement scontinue)
	{
		Scope scd;
		Statement s;

		scd = sc.push();
		if (sbreak)
			scd.sbreak = sbreak;
		if (scontinue)
			scd.scontinue = scontinue;
		s = semantic(scd);
		scd.pop();
		return s;
	}
	
    bool hasBreak()
	{
		assert(false);
	}
	
    bool hasContinue()
	{
		assert(false);
	}
	
    bool usesEH()
	{
		assert(false);
	}
	
    BE blockExit()
	{
		assert(false);
	}
	
	// true if statement 'comes from' somewhere else, like a goto
    bool comeFrom()
	{
		//printf("Statement::comeFrom()\n");
		return false;
	}
	
	// Return TRUE if statement has no code in it
    bool isEmpty()
	{
		//printf("Statement::isEmpty()\n");
		return false;
	}
	
	/****************************************
	 * If this statement has code that needs to run in a finally clause
	 * at the end of the current scope, return that code in the form of
	 * a Statement.
	 * Output:
	 *	*sentry		code executed upon entry to the scope
	 *	*sexception	code executed upon exit from the scope via exception
	 *	*sfinally	code executed in finally block
	 */
    void scopeCode(Scope sc, Statement* sentry, Statement* sexception, Statement* sfinally)
	{
		//printf("Statement::scopeCode()\n");
		//print();
		*sentry = null;
		*sexception = null;
		*sfinally = null;
	}
	
	/*********************************
	 * Flatten out the scope by presenting the statement
	 * as an array of statements.
	 * Returns NULL if no flattening necessary.
	 */
    Statements flatten(Scope sc)
	{
		return null;
	}
	
    Expression interpret(InterState istate)
	{
		assert(false);
	}
	
    int inlineCost(InlineCostState* ics)
	{
		return COST_MAX;		// default is we can't inline it
	}
	
    Expression doInline(InlineDoState ids)
	{
		assert(false);
	}
	
    Statement inlineScan(InlineScanState* iss)
	{
		return this;
	}
	
    // Back end
    void toIR(IRState* irs)
	{
		assert(false);
	}
	
    // Avoid dynamic_cast
    DeclarationStatement isDeclarationStatement() { return null; }
    CompoundStatement isCompoundStatement() { return null; }
    ReturnStatement isReturnStatement() { return null; }
    IfStatement isIfStatement() { return null; }
}