view dmd/TypeInfoDeclaration.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children fd4acc376c45
line wrap: on
line source

module dmd.TypeInfoDeclaration;

import dmd.VarDeclaration;
import dmd.Type;
import dmd.Dsymbol;
import dmd.Scope;
import dmd.Loc;
import dmd.STC;
import dmd.PROT;
import dmd.LINK;

import dmd.backend.Symbol;
import dmd.backend.dt_t;
import dmd.backend.DT;
import dmd.backend.SC;
import dmd.backend.FL;
import dmd.backend.glue;
import dmd.backend.Util;
import dmd.backend.TYPE;

import core.stdc.stdio;

class TypeInfoDeclaration : VarDeclaration
{
    Type tinfo;

    this(Type tinfo, int internal)
	{
		super(Loc(0), Type.typeinfo.type, tinfo.getTypeInfoIdent(internal), null);
		this.tinfo = tinfo;
		storage_class = STC.STCstatic | STC.STCgshared;
		protection = PROT.PROTpublic;
		linkage = LINK.LINKc;
	}
	
version (DumbClone) {
} else {
	Type clone()
	{
		assert(false);
	}
}
    Dsymbol syntaxCopy(Dsymbol)
	{
		assert(false);
	}

    void semantic(Scope sc)
	{
		assert(false);
	}

    void emitComment(Scope sc)
	{
		assert(false);
	}

    Symbol* toSymbol()
	{
		//printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage);
		return VarDeclaration.toSymbol();
	}

    void toObjFile(int multiobj)			// compile to .obj file
	{
		Symbol* s;
		uint sz;
		Dsymbol parent;

		//printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection);

		if (multiobj)
		{
			obj_append(this);
			return;
		}

		s = toSymbol();
		sz = cast(uint)type.size();

		parent = this.toParent();
		s.Sclass = SC.SCcomdat;
		s.Sfl = FL.FLdata;

		toDt(&s.Sdt);

		dt_optimize(s.Sdt);

		// See if we can convert a comdat to a comdef,
		// which saves on exe file space.
		if (s.Sclass == SC.SCcomdat &&
			s.Sdt.dt == DT.DT_azeros &&
			s.Sdt.DTnext == null)
		{
			s.Sclass = SC.SCglobal;
			s.Sdt.dt = DT.DT_common;
		}

version (XXX) { ///ELFOBJ || MACHOBJ // Burton
		if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null)
			s.Sseg = Segment.UDATA;
		else
			s.Sseg = Segment.DATA;
}
		outdata(s);
		if (isExport())
			obj_export(s,0);
	}

    void toDt(dt_t** pdt)
	{
		assert(false);
	}
}