changeset 23:460959608115

Branch merge.
author Robert Clipsham <robert@octarineparrot.com>
date Mon, 12 Apr 2010 17:00:08 +0100
parents 427f8aa74d28 (current diff) fd4acc376c45 (diff)
children 1b81e14880ef
files dmd/AssocArrayLiteralExp.d dmd/ClassDeclaration.d dmd/CompileDeclaration.d dmd/CompileExp.d dmd/CompileStatement.d dmd/ConditionalDeclaration.d dmd/DefaultInitExp.d dmd/Dsymbol.d dmd/EnumDeclaration.d dmd/Expression.d dmd/FileInitExp.d dmd/InterfaceDeclaration.d dmd/LineInitExp.d dmd/Module.d dmd/Parser.d dmd/Scope.d dmd/StaticAssert.d dmd/StaticIfDeclaration.d dmd/TemplateAliasParameter.d dmd/TemplateInstance.d dmd/TemplateMixin.d dmd/TraitsExp.d dmd/Tuple.d dmd/TupleDeclaration.d dmd/Type.d dmd/TypeDArray.d dmd/UAddExp.d dmd/UnionDeclaration.d dmd/VarDeclaration.d dmd/XorAssignExp.d
diffstat 90 files changed, 4349 insertions(+), 983 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Apr 12 16:29:33 2010 +0400
+++ b/.hgignore	Mon Apr 12 17:00:08 2010 +0100
@@ -1,1 +1,2 @@
 relre:win32/*
+dmd32/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/dmd.conf	Mon Apr 12 17:00:08 2010 +0100
@@ -0,0 +1,3 @@
+[Environment]
+DFLAGS=-I%@P%/../dmd32/dmd2/src/druntime/import/ -I%@P%/../dmd32/dmd2/src/druntime/src/common/ -I%@P%/../dmd32/dmd2/src/phobos/ -L-L%@P%/../dmd32/dmd2/linux/lib
+;CC=i686-unknown-linux-gnu-gcc
--- a/bridge/bridge.cpp	Mon Apr 12 16:29:33 2010 +0400
+++ b/bridge/bridge.cpp	Mon Apr 12 17:00:08 2010 +0100
@@ -4,6 +4,7 @@
 struct elem;
 struct Blockx;
 struct block;
+enum BC {};
 
 typedef TYPE type;
 
@@ -178,4 +179,4 @@
 unsigned int* get_tytouns()
 {
 	return (unsigned int*)tytouns;
-}
\ No newline at end of file
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build.sh	Mon Apr 12 17:00:08 2010 +0100
@@ -0,0 +1,4 @@
+#!/bin/sh
+#i686-unknown-linux-gnu-g++ -c bridge/bridge.cpp -obridge.o
+g++ -c bridge/bridge.cpp -obridge.o
+dmd @commands.linux.txt #|& head
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands.linux.txt	Mon Apr 12 17:00:08 2010 +0100
@@ -0,0 +1,386 @@
+-gc
+-debug
+-release
+-version=Bug3602
+-version=Bug4054
+-version=Bug4059
+-version=DMDV2
+-version=TX86
+-version=MARS
+-version=TARGET_LINUX
+-version=POSIX
+-version=ELFOBJ
+-version=ELFOBJ_OR_MACHOBJ
+-version=NobodyCares
+-version=DumbClone
+-version=STRUCTTHISREF
+-version=CCASTSYNTAX
+-version=CARRAYDECL
+-version=BREAKABI
+-version=SNAN_DEFAULT_INIT
+-ofbin/ddmd
+
+bridge.o
+-L-Ldmd32/dmd2/src/dmd
+-L-ldmd
+-L-lstdc++
+main.d
+dlib/CrashHandler.d
+dbg/ui/CrashWindow.d
+dbg/Debug.d
+dbg/symbol/CodeView.d
+dbg/image/PE.d
+dmd/AggregateDeclaration.d
+dmd/VarExp.d
+dmd/Tuple.d
+dmd/UnrolledLoopStatement.d
+dmd/SwitchErrorStatement.d
+dmd/NewAnonClassExp.d
+dmd/StructLiteralExp.d
+dmd/StaticIfCondition.d
+dmd/BoolExp.d
+dmd/ShlAssignExp.d
+dmd/ShrAssignExp.d
+dmd/UshrAssignExp.d
+dmd/CatAssignExp.d
+dmd/Port.d
+dmd/Gnuc.d
+dmd/declaration/Match.d
+dmd/templates/Util.d
+dmd/expression/Util.d
+dmd/expression/Add.d
+dmd/expression/Xor.d
+dmd/expression/Ptr.d
+dmd/expression/Min.d
+dmd/expression/And.d
+dmd/expression/Shr.d
+dmd/expression/Not.d
+dmd/expression/Mod.d
+dmd/expression/Mul.d
+dmd/expression/Com.d
+dmd/expression/Ushr.d
+dmd/expression/Shl.d
+dmd/expression/Div.d
+dmd/expression/Cmp.d
+dmd/expression/Identity.d
+dmd/expression/ArrayLength.d
+dmd/expression/Equal.d
+dmd/expression/Or.d
+dmd/expression/Neg.d
+dmd/expression/Cat.d
+dmd/expression/Slice.d
+dmd/expression/Index.d
+dmd/expression/shift_optimize.d
+dmd/expression/util/arrayTypeCompatible.d
+dmd/condition/util/findCondition.d
+dmd/OverExp.d
+dmd/Cast.d
+dmd/TupleExp.d
+dmd/ArrayLengthExp.d
+dmd/TypeInfoConstDeclaration.d
+dmd/TypeInfoInvariantDeclaration.d
+dmd/TypeInfoSharedDeclaration.d
+dmd/TypeInfoStructDeclaration.d
+dmd/TypeInfoInterfaceDeclaration.d
+dmd/TypeInfoEnumDeclaration.d
+dmd/TypeInfoClassDeclaration.d
+dmd/TypeInfoArrayDeclaration.d
+dmd/TypeInfoDelegateDeclaration.d
+dmd/TypeInfoTypedefDeclaration.d
+dmd/TypeInfoPointerDeclaration.d
+dmd/DsymbolExp.d
+dmd/GlobalExpressions.d
+dmd/NewExp.d
+dmd/PeelStatement.d
+dmd/HaltExp.d
+dmd/SymOffExp.d
+dmd/type/Util.d
+dmd/SymbolExp.d
+dmd/Optimize.d
+dmd/DotVarExp.d
+dmd/DeclarationExp.d
+dmd/TraitsExp.d
+dmd/ComplexExp.d
+dmd/ErrorExp.d
+dmd/AssignExp.d
+dmd/DotExp.d
+dmd/AliasDeclaration.d
+dmd/DefaultInitExp.d
+dmd/FileInitExp.d
+dmd/LineInitExp.d
+dmd/AnonDeclaration.d
+dmd/AliasThis.d
+dmd/AlignDeclaration.d
+dmd/AnonymousAggregateDeclaration.d
+dmd/Argument.d
+dmd/FuncExp.d
+dmd/ArrayLiteralExp.d
+dmd/AssocArrayLiteralExp.d
+dmd/AssertExp.d
+dmd/IsExp.d
+dmd/TypeExp.d
+dmd/StringExp.d
+dmd/NullExp.d
+dmd/RealExp.d
+dmd/ThisExp.d
+dmd/ScopeExp.d
+dmd/Array.d
+dmd/DotIdExp.d
+dmd/FileExp.d
+dmd/SuperExp.d
+dmd/TypeidExp.d
+dmd/CompileExp.d
+dmd/IdentifierExp.d
+dmd/DollarExp.d
+dmd/AndAndExp.d
+dmd/DotTemplateInstanceExp.d
+dmd/OrExp.d
+dmd/PostExp.d
+dmd/CallExp.d
+dmd/SliceExp.d
+dmd/ArrayExp.d
+dmd/AddrExp.d
+dmd/UAddExp.d
+dmd/XorExp.d
+dmd/CommaExp.d
+dmd/BinExp.d
+dmd/CondExp.d
+dmd/OrOrExp.d
+dmd/AndExp.d
+dmd/InExp.d
+dmd/EqualExp.d
+dmd/CmpExp.d
+dmd/ShlExp.d
+dmd/AddExp.d
+dmd/CatExp.d
+dmd/MinExp.d
+dmd/MulExp.d
+dmd/ModExp.d
+dmd/DivExp.d
+dmd/ShrExp.d
+dmd/UshrExp.d
+dmd/CastExp.d
+dmd/DeleteExp.d
+dmd/ComExp.d
+dmd/NotExp.d
+dmd/UnaExp.d
+dmd/NegExp.d
+dmd/PtrExp.d
+dmd/IntegerExp.d
+dmd/AddAssignExp.d
+dmd/AndAssignExp.d
+dmd/DivAssignExp.d
+dmd/MinAssignExp.d
+dmd/ModAssignExp.d
+dmd/MulAssignExp.d
+dmd/OrAssignExp.d
+dmd/XorAssignExp.d
+dmd/IdentityExp.d
+dmd/ArrayInitializer.d
+dmd/ArrayScopeSymbol.d
+dmd/ArrayTypes.d
+dmd/AsmStatement.d
+dmd/AttribDeclaration.d
+dmd/BUILTIN.d
+dmd/BaseClass.d
+dmd/BreakStatement.d
+dmd/CaseRangeStatement.d
+dmd/CaseStatement.d
+dmd/Catch.d
+dmd/ClassDeclaration.d
+dmd/ClassInfoDeclaration.d
+dmd/CompileDeclaration.d
+dmd/CompileStatement.d
+dmd/CompoundDeclarationStatement.d
+dmd/CompoundStatement.d
+dmd/Condition.d
+dmd/ConditionalDeclaration.d
+dmd/ConditionalStatement.d
+dmd/ContinueStatement.d
+dmd/CppMangleState.d
+dmd/CtorDeclaration.d
+dmd/DVCondition.d
+dmd/Dchar.d
+dmd/DebugCondition.d
+dmd/DebugSymbol.d
+dmd/Declaration.d
+dmd/DeclarationStatement.d
+dmd/DefaultStatement.d
+dmd/DeleteDeclaration.d
+dmd/DoStatement.d
+dmd/DocComment.d
+dmd/Dsymbol.d
+dmd/DsymbolTable.d
+dmd/DtorDeclaration.d
+dmd/EnumDeclaration.d
+dmd/EnumMember.d
+dmd/Escape.d
+dmd/ExpInitializer.d
+dmd/ExpStatement.d
+dmd/Expression.d
+dmd/File.d
+dmd/FileName.d
+dmd/ForStatement.d
+dmd/ForeachRangeStatement.d
+dmd/ForeachStatement.d
+dmd/FuncAliasDeclaration.d
+dmd/FuncDeclaration.d
+dmd/FuncLiteralDeclaration.d
+dmd/Global.d
+dmd/GotoCaseStatement.d
+dmd/GotoDefaultStatement.d
+dmd/GotoStatement.d
+dmd/HdrGenState.d
+dmd/ILS.d
+dmd/IRState.d
+dmd/Id.d
+dmd/Identifier.d
+dmd/IfStatement.d
+dmd/Import.d
+dmd/Initializer.d
+dmd/InlineCostState.d
+dmd/InlineDoState.d
+dmd/InlineScanState.d
+dmd/IntRange.d
+dmd/InterState.d
+dmd/InterfaceDeclaration.d
+dmd/InvariantDeclaration.d
+dmd/LINK.d
+dmd/LabelDsymbol.d
+dmd/LabelStatement.d
+dmd/Lexer.d
+dmd/Library.d
+dmd/LinkDeclaration.d
+dmd/Loc.d
+dmd/Lstring.d
+dmd/MATCH.d
+dmd/Macro.d
+dmd/Module.d
+dmd/ModuleDeclaration.d
+dmd/ModuleInfoDeclaration.d
+dmd/NewDeclaration.d
+dmd/ObjModule.d
+dmd/OnScopeStatement.d
+dmd/OutBuffer.d
+dmd/OverloadSet.d
+dmd/PREC.d
+dmd/PROT.d
+dmd/Package.d
+dmd/Param.d
+dmd/Parser.d
+dmd/PostBlitDeclaration.d
+dmd/PragmaDeclaration.d
+dmd/PragmaStatement.d
+dmd/ProtDeclaration.d
+dmd/RET.d
+dmd/ReturnStatement.d
+dmd/STC.d
+dmd/Scope.d
+dmd/ScopeDsymbol.d
+dmd/ScopeStatement.d
+dmd/Section.d
+dmd/Statement.d
+dmd/StaticAssert.d
+dmd/StaticAssertStatement.d
+dmd/StaticCtorDeclaration.d
+dmd/StaticDtorDeclaration.d
+dmd/StaticIfDeclaration.d
+dmd/StorageClassDeclaration.d
+dmd/String.d
+dmd/StringEntry.d
+dmd/StringTable.d
+dmd/StringValue.d
+dmd/StructDeclaration.d
+dmd/StructInitializer.d
+dmd/SwitchStatement.d
+dmd/SymbolDeclaration.d
+dmd/SynchronizedStatement.d
+dmd/TOK.d
+dmd/TY.d
+dmd/TemplateAliasParameter.d
+dmd/TemplateDeclaration.d
+dmd/TemplateInstance.d
+dmd/TemplateMixin.d
+dmd/TemplateParameter.d
+dmd/TemplateThisParameter.d
+dmd/TemplateTupleParameter.d
+dmd/TemplateTypeParameter.d
+dmd/TemplateValueParameter.d
+dmd/ThisDeclaration.d
+dmd/ThrowStatement.d
+dmd/Token.d
+dmd/TryCatchStatement.d
+dmd/TryFinallyStatement.d
+dmd/TupleDeclaration.d
+dmd/Type.d
+dmd/TypeAArray.d
+dmd/TypeArray.d
+dmd/TypeBasic.d
+dmd/TypeClass.d
+dmd/TypeDArray.d
+dmd/TypeDelegate.d
+dmd/TypeEnum.d
+dmd/TypeFunction.d
+dmd/TypeIdentifier.d
+dmd/TypeInfoDeclaration.d
+dmd/TypeInstance.d
+dmd/TypeNext.d
+dmd/TypePointer.d
+dmd/TypeQualified.d
+dmd/TypeReference.d
+dmd/TypeReturn.d
+dmd/TypeSArray.d
+dmd/EnumUtils.d
+dmd/TypeSlice.d
+dmd/TypeStruct.d
+dmd/TypeTuple.d
+dmd/TypeTypedef.d
+dmd/TypeTypeof.d
+dmd/TypedefDeclaration.d
+dmd/UnionDeclaration.d
+dmd/UnitTestDeclaration.d
+dmd/Utf.d
+dmd/Util.d
+dmd/DotTemplateExp.d
+dmd/DelegateExp.d
+dmd/RemoveExp.d
+dmd/TemplateExp.d
+dmd/DotTypeExp.d
+dmd/IndexExp.d
+dmd/VarDeclaration.d
+dmd/VersionCondition.d
+dmd/VersionSymbol.d
+dmd/VoidInitializer.d
+dmd/VolatileStatement.d
+dmd/WhileStatement.d
+dmd/WithScopeSymbol.d
+dmd/WithStatement.d
+dmd/backend/Blockx.d
+dmd/backend/enum_t.d
+dmd/backend/Symbol.d
+dmd/backend/Util.d
+dmd/backend/TYPE.d
+dmd/backend/TYM.d
+dmd/backend/mTY.d
+dmd/backend/block.d
+dmd/backend/code.d
+dmd/backend/glue.d
+dmd/backend/dt_t.d
+dmd/backend/elem.d
+dmd/backend/func_t.d
+dmd/backend/Cstate.d
+dmd/backend/TYFL.d
+dmd/backend/RTLSYM.d
+dmd/backend/symtab_t.d
+dmd/backend/Classsym.d
+dmd/backend/con_t.d
+dmd/backend/cse_t.d
+dmd/backend/struct_t.d
+dmd/backend/OPER.d
+dmd/backend/StringTab.d
+dmd/backend/DT.d
+dmd/backend/Configv.d
+dmd/backend/iasm.d
+dmd/backend/rel.d
+dmd/backend/LIST.d
+dmd/codegen/Util.d
--- a/dbg/ui/CrashWindow.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dbg/ui/CrashWindow.d	Mon Apr 12 17:00:08 2010 +0100
@@ -366,4 +366,7 @@
 }
 
 } // version(Gnome)
-else static assert(0);
\ No newline at end of file
+else version (NobodyCares)
+{
+}
+else static assert(0);
--- a/dlib/CrashHandler.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dlib/CrashHandler.d	Mon Apr 12 17:00:08 2010 +0100
@@ -37,9 +37,9 @@
 	import dbg.symbol.CodeView;
 }
 else version(Posix) {
-	import sys.posix.ucontext;
-	import std.c.signal;
-	import std.c.stdlib : free, exit, EXIT_FAILURE;
+	import core.sys.posix.ucontext;
+	import core.stdc.signal;
+	import core.stdc.stdlib : free, exit, EXIT_FAILURE;
 }
 else static assert(0, "Unsupported platform.");
 
@@ -53,14 +53,15 @@
 		SetUnhandledExceptionFilter(&UnhandledExceptionHandler);
 	}
 	else version(Posix) {
-		sigaction_t sa;
+	assert(0);
+	/+	sigaction_t sa;
 		sa.sa_handler = cast(sighandler_t)&SignalHandler;
 		sigemptyset(&sa.sa_mask);
 		sa.sa_flags = SA_RESTART | SA_SIGINFO;
 
 		sigaction(SIGILL, &sa, null);
 		sigaction(SIGFPE, &sa, null);
-		sigaction(SIGSEGV, &sa, null);
+		sigaction(SIGSEGV, &sa, null);+/
 	}
 	else static assert(0);
 }
@@ -91,7 +92,7 @@
 
 	void Dump() {
 		// TODO: support more dump methods
-		ShowCrashWindow(&this);
+		version(Windows) ShowCrashWindow(&this);
 	}
 
 	/**
@@ -216,6 +217,10 @@
 					}
 				}
 			}
+			else version(POSIX)
+			{
+				assert(0);
+			}
 			else static assert(0);
 
 			frame.moduleName = image.moduleName;
@@ -383,7 +388,8 @@
 	case SIGSEGV:	msg = "Segmentation fault";			break;
 	default:		msg = "Unknown signal";
 	}
-
+	assert(0);
+/+
 	SystemException e = new SystemException(msg);
 
 	e._context = ucontext;
@@ -400,8 +406,7 @@
 			e._backtrace[2] = cast(void*)ucontext.uc_mcontext.gregs[REG_EIP];
 	}
 	else static assert(0);
-
-	throw e;
+	throw e;+/
 }
 
 /**
@@ -409,10 +414,10 @@
  point, which should catch it and manually call this routine.
 */
 void UnhandledExceptionHandler(Throwable e) {
-	ErrorReport crashInfo = void;
+assert(0);
+/+	ErrorReport crashInfo = void;
 
 	with(crashInfo) {
-assert(0);
 	/+error = e;
 
 	// Get the module filename
@@ -443,7 +448,7 @@
 
 	} // with(crashInfo)
 
-	crashInfo.Dump();
+	crashInfo.Dump();+/
 }
 
 } // version(Posix)
--- a/dmd/AggregateDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/AggregateDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -640,4 +640,4 @@
 	}
 
     AggregateDeclaration isAggregateDeclaration() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/AliasDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/AliasDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -20,49 +20,75 @@
 
 class AliasDeclaration : Declaration
 {
-    Dsymbol aliassym;
-    Dsymbol overnext;		// next in overload list
-    int inSemantic;
+	Dsymbol aliassym;
+	Dsymbol overnext;		// next in overload list
+	int inSemantic;
 
-    this(Loc loc, Identifier ident, Type type)
+	this(Loc loc, Identifier ident, Type type)
 	{
 		super(ident);
-		
+
 		//printf("AliasDeclaration(id = '%s', type = %p)\n", id.toChars(), type);
 		//printf("type = '%s'\n", type.toChars());
 		this.loc = loc;
 		this.type = type;
 		this.aliassym = null;
-	version (_DH) {
-		this.htype = null;
-		this.haliassym = null;
-	}
+		version (_DH) {
+			this.htype = null;
+			this.haliassym = null;
+		}
 
 		assert(type);
 	}
-	
-    this(Loc loc, Identifier id, Dsymbol s)
+
+	this(Loc loc, Identifier id, Dsymbol s)
 	{
 		super(id);
-		
+
 		//printf("AliasDeclaration(id = '%s', s = %p)\n", id->toChars(), s);
 		assert(s !is this);	/// huh?
 		this.loc = loc;
 		this.type = null;
 		this.aliassym = s;
-	version (_DH) {
-		this.htype = null;
-		this.haliassym = null;
-	}
+		version (_DH) {
+			this.htype = null;
+			this.haliassym = null;
+		}
 		assert(s);
 	}
-	
-    Dsymbol syntaxCopy(Dsymbol)
+
+	Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+		//printf("AliasDeclaration::syntaxCopy()\n");
+		assert(!s);
+		AliasDeclaration sa;
+		if (type)
+			sa = new AliasDeclaration(loc, ident, type.syntaxCopy());
+		else
+			sa = new AliasDeclaration(loc, ident, aliassym.syntaxCopy(null));
+version (_DH) {
+		// Syntax copy for header file
+		if (!htype)	    // Don't overwrite original
+		{	if (type)	// Make copy for both old and new instances
+			{   htype = type.syntaxCopy();
+				sa.htype = type.syntaxCopy();
+			}
+		}
+		else			// Make copy of original for new instance
+			sa.htype = htype.syntaxCopy();
+		if (!haliassym)
+		{	if (aliassym)
+			{   haliassym = aliassym.syntaxCopy(s);
+				sa.haliassym = aliassym.syntaxCopy(s);
+			}
+		}
+		else
+			sa.haliassym = haliassym.syntaxCopy(s);
+} // version (_DH)
+		return sa;
 	}
-	
-    void semantic(Scope sc)
+
+	void semantic(Scope sc)
 	{
 		//printf("AliasDeclaration.semantic() %s\n", toChars());
 		if (aliassym)
@@ -100,7 +126,7 @@
 		if (s && ((s.getType() && type.equals(s.getType())) || s.isEnumMember()))
 			goto L2;			// it's a symbolic alias
 
-///version (DMDV2) {
+		///version (DMDV2) {
 		if (storage_class & STC.STCref)
 		{	// For 'ref' to be attached to function types, and picked
 			// up by Type.resolve(), it has to go into sc.
@@ -110,8 +136,8 @@
 			sc = sc.pop();
 		}
 		else
-///	#endif
-		type.resolve(loc, sc, &e, &t, &s);
+			///	#endif
+			type.resolve(loc, sc, &e, &t, &s);
 		if (s)
 		{
 			goto L2;
@@ -135,7 +161,7 @@
 		this.inSemantic = 0;
 		return;
 
-	  L2:
+L2:
 		//printf("alias is a symbol %s %s\n", s.kind(), s.toChars());
 		type = null;
 		VarDeclaration v = s.isVarDeclaration();
@@ -171,8 +197,8 @@
 		aliassym = s;
 		this.inSemantic = 0;
 	}
-	
-    bool overloadInsert(Dsymbol s)
+
+	bool overloadInsert(Dsymbol s)
 	{
 		/* Don't know yet what the aliased symbol is, so assume it can
 		 * be overloaded and check later for correctness.
@@ -189,17 +215,17 @@
 			return overnext.overloadInsert(s);
 		}
 	}
-	
-    string kind()
+
+	string kind()
 	{
 		return "alias";
 	}
-	
-    Type getType()
+
+	Type getType()
 	{
 		return type;
 	}
-    
+
 	Dsymbol toAlias()
 	{
 		//printf("AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s')\n", toChars(), this, aliassym, aliassym ? aliassym->kind() : "");
@@ -214,20 +240,20 @@
 		Dsymbol s = aliassym ? aliassym.toAlias() : this;
 		return s;
 	}
-	
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
-	}
-	
-version (_DH) {
-    Type htype;
-    Dsymbol haliassym;
-}
-    void toDocBuffer(OutBuffer buf)
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
 		assert(false);
 	}
 
-    AliasDeclaration isAliasDeclaration() { return this; }
-}
\ No newline at end of file
+	version (_DH) {
+		Type htype;
+		Dsymbol haliassym;
+	}
+	void toDocBuffer(OutBuffer buf)
+	{
+		assert(false);
+	}
+
+	AliasDeclaration isAliasDeclaration() { return this; }
+	}
--- a/dmd/Argument.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Argument.d	Mon Apr 12 17:00:08 2010 +0100
@@ -107,7 +107,7 @@
 		buf.writeByte('(');
 		if (args)
 		{	
-			OutBuffer argbuf;
+			OutBuffer argbuf = new OutBuffer();
 			HdrGenState hgs;
 
 			for (int i = 0; i < args.dim; i++)
@@ -275,4 +275,4 @@
 
 		return null;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/ArrayExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/ArrayExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -31,7 +31,7 @@
 
 	Expression syntaxCopy()
 	{
-		assert(false);
+	    return new ArrayExp(loc, e1.syntaxCopy(), arraySyntaxCopy(arguments));
 	}
 
 	Expression semantic(Scope sc)
--- a/dmd/AssertExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/AssertExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -157,7 +157,7 @@
 			if (global.params.useInvariants && t1.ty == Tclass &&
 				!(cast(TypeClass)t1).sym.isInterfaceDeclaration())
 			{
-		version (XXX) {///TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+		version (POSIX) {///TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
 				e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM__DINVARIANT]), e);
 		} else {
 				e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM_DINVARIANT]), e);
@@ -207,10 +207,10 @@
 						assertexp_sfilename.Sdt = dt;
 						assertexp_sfilename.Sfl = FLdata;
 			version (ELFOBJ) {
-						assertexp_sfilename.Sseg = CDATA;
+						assertexp_sfilename.Sseg = Segment.CDATA;
 			}
 			version (MACHOBJ) {
-						assertexp_sfilename.Sseg = DATA;
+						assertexp_sfilename.Sseg = Segment.DATA;
 			}
 						outdata(assertexp_sfilename);
 
--- a/dmd/AssocArrayLiteralExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/AssocArrayLiteralExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -5,6 +5,7 @@
 import dmd.InterState;
 import dmd.MATCH;
 import dmd.Type;
+import dmd.TypeAArray;
 import dmd.OutBuffer;
 import dmd.Loc;
 import dmd.Scope;
@@ -15,98 +16,188 @@
 import dmd.InlineScanState;
 import dmd.ArrayTypes;
 import dmd.TOK;
+import dmd.PREC;
+import dmd.expression.Util;
 
-class AssocArrayLiteralExp : Expression
-{
-	Expressions keys;
-	Expressions values;
-
-	this(Loc loc, Expressions keys, Expressions values)
+class AssocArrayLiteralExp : Expression
+{
+	Expressions keys;
+	Expressions values;
+
+	this(Loc loc, Expressions keys, Expressions values)
 	{
-		super(loc, TOKassocarrayliteral, AssocArrayLiteralExp.sizeof);
+		super(loc, TOK.TOKassocarrayliteral, this.sizeof);
 		assert(keys.dim == values.dim);
 		this.keys = keys;
-		this.values = values;
-	}
-
-	Expression syntaxCopy()
-	{
-		assert(false);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	bool isBool(bool result)
-	{
-		assert(false);
-	}
-
-	elem* toElem(IRState* irs)
-	{
-		assert(false);
-	}
-
-	bool checkSideEffect(int flag)
-	{
-		assert(false);
-	}
-
-	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
-	}
-
-	void toMangleBuffer(OutBuffer buf)
-	{
-		assert(false);
-	}
-
-	void scanForNestedRef(Scope sc)
-	{
-		assert(false);
-	}
-
-	Expression optimize(int result)
-	{
-		assert(false);
-	}
-
-	Expression interpret(InterState* istate)
-	{
-		assert(false);
-	}
-
-	MATCH implicitConvTo(Type t)
-	{
-		assert(false);
-	}
-
-	Expression castTo(Scope sc, Type t)
-	{
-		assert(false);
-	}
-
-	bool canThrow()
-	{
-		assert(false);
-	}
-
-	int inlineCost(InlineCostState* ics)
-	{
-		assert(false);
-	}
-
-	Expression doInline(InlineDoState ids)
-	{
-		assert(false);
-	}
-
-	Expression inlineScan(InlineScanState* iss)
-	{
-		assert(false);
-	}
-}
-
+		this.values = values;	
+	}
+
+	Expression syntaxCopy()
+	{
+		return new AssocArrayLiteralExp(loc,
+				arraySyntaxCopy(keys), arraySyntaxCopy(values));
+	}
+
+	Expression semantic(Scope sc)
+	{
+		Expression e;
+		Type tkey = null;
+		Type tvalue = null;
+
+		version (LOGSEMANTIC) {
+			printf("AssocArrayLiteralExp.semantic('%s')\n", toChars());
+		}
+
+		// Run semantic() on each element
+		for (size_t i = 0; i < keys.dim; i++)
+		{	Expression key = cast(Expression)keys.data[i];
+			Expression value = cast(Expression)values.data[i];
+
+			key = key.semantic(sc);
+			value = value.semantic(sc);
+
+			keys.data[i] = cast(void *)key;
+			values.data[i] = cast(void *)value;
+		}
+		expandTuples(keys);
+		expandTuples(values);
+		if (keys.dim != values.dim)
+		{
+			error("number of keys is %u, must match number of values %u", keys.dim, values.dim);
+			keys.setDim(0);
+			values.setDim(0);
+		}
+		for (size_t i = 0; i < keys.dim; i++)
+		{	Expression key = cast(Expression)keys.data[i];
+			Expression value = cast(Expression)values.data[i];
+
+			if (!key.type)
+				error("%s has no value", key.toChars());
+			if (!value.type)
+				error("%s has no value", value.toChars());
+			key = resolveProperties(sc, key);
+			value = resolveProperties(sc, value);
+
+			if (!tkey)
+				tkey = key.type;
+			else
+				key = key.implicitCastTo(sc, tkey);
+			keys.data[i] = cast(void *)key;
+
+			if (!tvalue)
+				tvalue = value.type;
+			else
+				value = value.implicitCastTo(sc, tvalue);
+			values.data[i] = cast(void *)value;
+		}
+
+		if (!tkey)
+			tkey = Type.tvoid;
+		if (!tvalue)
+			tvalue = Type.tvoid;
+		type = new TypeAArray(tvalue, tkey);
+		type = type.semantic(loc, sc);
+		return this;
+	}
+
+	bool isBool(bool result)
+	{
+		size_t dim = keys.dim;
+		return result ? (dim != 0) : (dim == 0);
+	}
+
+	elem* toElem(IRState* irs)
+	{
+		assert(false);
+	}
+
+	bool checkSideEffect(int flag)
+	{
+		bool f = false;
+
+		for (size_t i = 0; i < keys.dim; i++)
+		{	Expression key = cast(Expression)keys.data[i];
+			Expression value = cast(Expression)values.data[i];
+
+			f |= key.checkSideEffect(2);
+			f |= value.checkSideEffect(2);
+		}
+		if (flag == 0 && f == 0)
+			Expression.checkSideEffect(0);
+		return f;
+	}
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	{
+		buf.writeByte('[');
+		for (size_t i = 0; i < keys.dim; i++)
+		{	Expression key = cast(Expression)keys.data[i];
+			Expression value = cast(Expression)values.data[i];
+
+			if (i)
+				buf.writeByte(',');
+			expToCBuffer(buf, hgs, key, PREC.PREC_assign);
+			buf.writeByte(':');
+			expToCBuffer(buf, hgs, value, PREC.PREC_assign);
+		}
+		buf.writeByte(']');
+	}
+
+	void toMangleBuffer(OutBuffer buf)
+	{
+		size_t dim = keys.dim;
+		buf.printf("A%u", dim);
+		for (size_t i = 0; i < dim; i++)
+		{	Expression key = cast(Expression)keys.data[i];
+			Expression value = cast(Expression)values.data[i];
+
+			key.toMangleBuffer(buf);
+			value.toMangleBuffer(buf);
+		}
+	}
+
+	void scanForNestedRef(Scope sc)
+	{
+		assert(false);
+	}
+
+	Expression optimize(int result)
+	{
+		assert(false);
+	}
+
+	Expression interpret(InterState* istate)
+	{
+		assert(false);
+	}
+
+	MATCH implicitConvTo(Type t)
+	{
+		assert(false);
+	}
+
+	Expression castTo(Scope sc, Type t)
+	{
+		assert(false);
+	}
+
+	bool canThrow()
+	{
+		return true;
+	}
+
+	int inlineCost(InlineCostState* ics)
+	{
+		assert(false);
+	}
+
+	Expression doInline(InlineDoState ids)
+	{
+		assert(false);
+	}
+
+	Expression inlineScan(InlineScanState* iss)
+	{
+		assert(false);
+	}
+}
--- a/dmd/ClassDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/ClassDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -71,7 +71,7 @@
 
 struct Param
 {
-	int isf(FuncDeclaration fd2)
+	int isf(void*, FuncDeclaration fd2)
 	{
 		//printf("param = %p, fd = %p %s\n", param, fd, fd.toChars());
 		return fd is fd2;
@@ -908,7 +908,7 @@
 			{   
 				Dsymbol s2 = cast(Dsymbol)os.a.data[i];
 				FuncDeclaration f2 = s2.isFuncDeclaration();
-				if (f2 && overloadApply(f2, &p.isf))
+				if (f2 && overloadApply(f2, &p.isf, &p))
 					return false;
 			}
 			return true;
@@ -917,7 +917,7 @@
 		{
 			FuncDeclaration fdstart = s.isFuncDeclaration();
 			//printf("%s fdstart = %p\n", s.kind(), fdstart);
-			return !overloadApply(fdstart, &p.isf);
+			return !overloadApply(fdstart, &p.isf, &p);
 		}
 	}
 }
@@ -1242,10 +1242,10 @@
 		sinit.Sclass = scclass;
 		sinit.Sfl = FLdata;
 	version (ELFOBJ) { // Burton
-		sinit.Sseg = CDATA;
+		sinit.Sseg = Segment.CDATA;
 	}
 	version (MACHOBJ) {
-		sinit.Sseg = DATA;
+		sinit.Sseg = Segment.DATA;
 	}
 		toDt(&sinit.Sdt);
 		outdata(sinit);
@@ -1568,7 +1568,7 @@
 		csym.Sdt = dt;
 	version (ELFOBJ_OR_MACHOBJ) { // Burton
 		// ClassInfo cannot be const data, because we use the monitor on it
-		csym.Sseg = DATA;
+		csym.Sseg = Segment.DATA;
 	}
 		outdata(csym);
 		if (isExport())
@@ -1635,10 +1635,10 @@
 		vtblsym.Sclass = scclass;
 		vtblsym.Sfl = FLdata;
 	version (ELFOBJ) {
-		vtblsym.Sseg = CDATA;
+		vtblsym.Sseg = Segment.CDATA;
 	}
 	version (MACHOBJ) {
-		vtblsym.Sseg = DATA;
+		vtblsym.Sseg = Segment.DATA;
 	}
 		outdata(vtblsym);
 		if (isExport())
@@ -1882,4 +1882,4 @@
 
     ///ClassDeclaration isClassDeclaration() { return cast(ClassDeclaration)this; }	/// huh?
     ClassDeclaration isClassDeclaration() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/CompileDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/CompileDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -12,6 +12,10 @@
 import dmd.Scope;
 import dmd.OutBuffer;
 import dmd.HdrGenState;
+import dmd.TOK;
+import dmd.WANT;
+import dmd.StringExp;
+import dmd.Parser;
 
 // Mixin declarations
 
@@ -21,7 +25,7 @@
     ScopeDsymbol sd;
     bool compiled;
 
-    this(Loc loc, Expression exp)
+	this(Loc loc, Expression exp)
 	{
 		super(null);
 		//printf("CompileDeclaration(loc = %d)\n", loc.linnum);
@@ -31,14 +35,17 @@
 		this.compiled = false;
 	}
 
-    Dsymbol syntaxCopy(Dsymbol s)
+	Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+		//printf("CompileDeclaration.syntaxCopy('%s')\n", toChars());
+		CompileDeclaration sc = new CompileDeclaration(loc, exp.syntaxCopy());
+		return sc;
 	}
 
     bool addMember(Scope sc, ScopeDsymbol sd, bool memnum)
 	{
 		//printf("CompileDeclaration.addMember(sc = %p, memnum = %d)\n", sc, memnum);
+		bool m = false;
 		this.sd = sd;
 		if (!memnum)
 		{	/* No members yet, so parse the mixin now
@@ -50,15 +57,14 @@
 		return memnum;
 	}
 
-    void compileIt(Scope sc)
+	void compileIt(Scope sc)
 	{
 		//printf("CompileDeclaration.compileIt(loc = %d)\n", loc.linnum);
 		exp = exp.semantic(sc);
 		exp = resolveProperties(sc, exp);
-		exp = exp.optimize(WANTvalue | WANTinterpret);
-		if (exp.op != TOKstring)
-		{	
-			exp.error("argument to mixin must be a string, not (%s)", exp.toChars());
+		exp = exp.optimize(WANT.WANTvalue | WANT.WANTinterpret);
+		if (exp.op != TOK.TOKstring)
+		{	exp.error("argument to mixin must be a string, not (%s)", exp.toChars());
 		}
 		else
 		{
@@ -68,26 +74,29 @@
 			p.loc = loc;
 			p.nextToken();
 			decl = p.parseDeclDefs(0);
-			if (p.token.value != TOKeof)
+			if (p.token.value != TOK.TOKeof)
 				exp.error("incomplete mixin declaration (%s)", se.toChars());
 		}
 	}
 
-    void semantic(Scope sc)
+	void semantic(Scope sc)
 	{
 		//printf("CompileDeclaration.semantic()\n");
 
 		if (!compiled)
 		{
 			compileIt(sc);
-			AttribDeclaration.addMember(sc, sd, false);
-			compiled = true;
+			AttribDeclaration.addMember(sc, sd, 0);
+			compiled = 1;
 		}
 		AttribDeclaration.semantic(sc);
 	}
-	
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		buf.writestring("mixin(");
+		exp.toCBuffer(buf, hgs);
+		buf.writestring(");");
+		buf.writenl();
 	}
-}
\ No newline at end of file
+}
--- a/dmd/CompileExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/CompileExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -7,22 +7,50 @@
 import dmd.Scope;
 import dmd.HdrGenState;
 import dmd.TOK;
+import dmd.PREC;
+import dmd.WANT;
+import dmd.StringExp;
+import dmd.Type;
+import dmd.Parser;
 
-class CompileExp : UnaExp
-{
-	this(Loc loc, Expression e)
+import dmd.expression.Util;
+
+class CompileExp : UnaExp
+{
+	this(Loc loc, Expression e)
+	{
+		super(loc, TOK.TOKmixin, this.sizeof, e);
+	}
+
+	Expression semantic(Scope sc)
 	{
-		super(loc, TOKmixin, CompileExp.sizeof, e);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
-	}
-}
-
+		version (LOGSEMANTIC) {
+			printf("CompileExp.semantic('%s')\n", toChars());
+		}
+		UnaExp.semantic(sc);
+		e1 = resolveProperties(sc, e1);
+		e1 = e1.optimize(WANT.WANTvalue | WANT.WANTinterpret);
+		if (e1.op != TOK.TOKstring)
+		{	error("argument to mixin must be a string, not (%s)", e1.toChars());
+			type = Type.terror;
+			return this;
+		}
+		StringExp se = cast(StringExp)e1;
+		se = se.toUTF8(sc);
+		Parser p = new Parser(sc.module_, cast(ubyte*)se.string_, se.len, 0);
+		p.loc = loc;
+		p.nextToken();
+		//printf("p.loc.linnum = %d\n", p.loc.linnum);
+		Expression e = p.parseExpression();
+		if (p.token.value != TOK.TOKeof)
+			error("incomplete mixin expression (%s)", se.toChars());
+		return e.semantic(sc);
+	}
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	{
+		buf.writestring("mixin(");
+		expToCBuffer(buf, hgs, e1, PREC.PREC_assign);
+		buf.writeByte(')');
+	}
+}
--- a/dmd/CompileStatement.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/CompileStatement.d	Mon Apr 12 17:00:08 2010 +0100
@@ -7,34 +7,71 @@
 import dmd.OutBuffer;
 import dmd.HdrGenState;
 import dmd.ArrayTypes;
+import dmd.TOK;
+import dmd.WANT;
+import dmd.ParseStatementFlags;
+import dmd.Parser;
+import dmd.CompoundStatement;
+import dmd.StringExp;
 
 class CompileStatement : Statement
 {
-    Expression exp;
+	Expression exp;
 
-    this(Loc loc, Expression exp)
+	this(Loc loc, Expression exp)
 	{
 		super(loc);
 		this.exp = exp;
 	}
 
-    Statement syntaxCopy()
+	Statement syntaxCopy()
 	{
-		assert(false);
+		Expression e = exp.syntaxCopy();
+		CompileStatement es = new CompileStatement(loc, e);
+		return es;
 	}
 
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		buf.writestring("mixin(");
+		exp.toCBuffer(buf, hgs);
+		buf.writestring(");");
+		if (!hgs.FLinit.init)
+			buf.writenl();
 	}
 
-    Statements flatten(Scope sc)
+	Statements flatten(Scope sc)
 	{
-		assert(false);
+		//printf("CompileStatement::flatten() %s\n", exp->toChars());
+		exp = exp.semantic(sc);
+		exp = resolveProperties(sc, exp);
+		exp = exp.optimize(WANT.WANTvalue | WANT.WANTinterpret);
+		if (exp.op != TOK.TOKstring)
+		{	error("argument to mixin must be a string, not (%s)", exp.toChars());
+			return null;
+		}
+		StringExp se = cast(StringExp)exp;
+		se = se.toUTF8(sc);
+		Parser p = new Parser(sc.module_, cast(ubyte *)se.string_, se.len, 0);
+		p.loc = loc;
+		p.nextToken();
+
+		Statements a = new Statements();
+		while (p.token.value != TOK.TOKeof)
+		{
+			Statement s = p.parseStatement(ParseStatementFlags.PSsemi | ParseStatementFlags.PScurlyscope);
+			a.push(cast(void*)s);
+		}
+		return a;
 	}
 
-    Statement semantic(Scope sc)
+	Statement semantic(Scope sc)
 	{
-		assert(false);
+		//printf("CompileStatement::semantic() %s\n", exp->toChars());
+		Statements a = flatten(sc);
+		if (!a)
+			return null;
+		Statement s = new CompoundStatement(loc, a);
+		return s.semantic(sc);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/ConditionalDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/ConditionalDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -17,14 +17,20 @@
     this(Condition condition, Array decl, Array elsedecl)
 	{
 		super(decl);
-		//printf("ConditionalDeclaration::ConditionalDeclaration()\n");
+		//printf("ConditionalDeclaration.ConditionalDeclaration()\n");
 		this.condition = condition;
 		this.elsedecl = elsedecl;
 	}
 	
     Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+    ConditionalDeclaration dd;
+
+    assert(!s);
+    dd = new ConditionalDeclaration(condition.syntaxCopy(),
+	Dsymbol.arraySyntaxCopy(decl),
+	Dsymbol.arraySyntaxCopy(elsedecl));
+    return dd;
 	}
 	
     bool oneMember(Dsymbol* ps)
@@ -41,14 +47,29 @@
 	
     void emitComment(Scope sc)
 	{
-		assert(false);
+    //printf("ConditionalDeclaration.emitComment(sc = %p)\n", sc);
+    if (condition.inc)
+    {
+	AttribDeclaration.emitComment(sc);
+    }
+    else if (sc.docbuf)
+    {
+	/* If generating doc comment, be careful because if we're inside
+	 * a template, then include(NULL, NULL) will fail.
+	 */
+	Array d = decl ? decl : elsedecl;
+	for (uint i = 0; i < d.dim; i++)
+	{   Dsymbol s = cast(Dsymbol)d.data[i];
+	    s.emitComment(sc);
+	}
+    }
 	}
 	
 	// Decide if 'then' or 'else' code should be included
 
     Array include(Scope sc, ScopeDsymbol sd)
 	{
-		//printf("ConditionalDeclaration::include()\n");
+		//printf("ConditionalDeclaration.include()\n");
 		assert(condition);
 		return condition.include(sc, sd) ? decl : elsedecl;
 	}
@@ -72,7 +93,7 @@
 					for (uint i = 0; i < d.dim; i++)
 					{   
 						Dsymbol s = cast(Dsymbol)d.data[i];
-						//printf("ConditionalDeclaration::addComment %s\n", s->toChars());
+						//printf("ConditionalDeclaration::addComment %s\n", s.toChars());
 						s.addComment(comment);
 					}
 				}
@@ -83,6 +104,42 @@
 	
     void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+    condition.toCBuffer(buf, hgs);
+    if (decl || elsedecl)
+    {
+	buf.writenl();
+	buf.writeByte('{');
+	buf.writenl();
+	if (decl)
+	{
+	    for (uint i = 0; i < decl.dim; i++)
+	    {
+		Dsymbol s = cast(Dsymbol)decl.data[i];
+
+		buf.writestring("    ");
+		s.toCBuffer(buf, hgs);
+	    }
 	}
-}
\ No newline at end of file
+	buf.writeByte('}');
+	if (elsedecl)
+	{
+	    buf.writenl();
+	    buf.writestring("else");
+	    buf.writenl();
+	    buf.writeByte('{');
+	    buf.writenl();
+	    for (uint i = 0; i < elsedecl.dim; i++)
+	    {
+		Dsymbol s = cast(Dsymbol)elsedecl.data[i];
+
+		buf.writestring("    ");
+		s.toCBuffer(buf, hgs);
+	    }
+	    buf.writeByte('}');
+	}
+    }
+    else
+	buf.writeByte(':');
+    buf.writenl();
+	}
+}
--- a/dmd/Declaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Declaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -90,7 +90,6 @@
 	
     void semantic(Scope sc)
 	{
-		assert(false);
 	}
 	
     string kind()
@@ -180,7 +179,7 @@
 	}
 
     string mangle()
-	out (result)
+	/+out (result)
 	{
 		try
 		{
@@ -197,8 +196,9 @@
 			assert(false);
 		}
 	}
-	body
+	body+/
 	{
+version(Bug3602) { writef( "Bug3602: Uncomment outblock when fixed\n" );  }
 		//writef("Declaration.mangle(this = %p, '%s', parent = '%s', linkage = %d)\n", this, toChars(), parent ? parent.toChars() : "null", linkage);
 		if (!parent || parent.isModule() || linkage == LINK.LINKcpp) // if at global scope
 		{
@@ -308,4 +308,4 @@
 	}
 
     Declaration isDeclaration() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/DefaultInitExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/DefaultInitExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -6,25 +6,22 @@
 import dmd.Scope;
 import dmd.HdrGenState;
 import dmd.TOK;
+import dmd.Token;
 
-class DefaultInitExp : Expression
-{
-	TOK subop;
-
-	this(Loc loc, TOK subop, int size)
-	{
-		super(loc, TOKdefault, size);
-		this.subop = subop;
-	}
-
-	Expression resolve(Loc loc, Scope sc)
-	{
-		assert(false);
-	}
-
-	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
-	}
-}
-
+class DefaultInitExp : Expression
+{
+	TOK subop;
+
+	this(Loc loc, TOK subop, int size)
+	{
+		super(loc, subop, size);
+		this.subop = subop;
+	}
+
+	abstract Expression resolve(Loc loc, Scope sc);
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	{
+		buf.writestring(Token.toChars(subop));
+	}
+}
--- a/dmd/Dsymbol.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Dsymbol.d	Mon Apr 12 17:00:08 2010 +0100
@@ -69,7 +69,8 @@
 import dmd.backend.LIST;
 
 import core.stdc.string : strcmp, memcpy, strlen;
-import core.stdc.stdlib : alloca;
+version (Bug4054) import core.memory;
+else import core.stdc.stdlib : alloca;
 
 import std.stdio;
 
@@ -89,6 +90,22 @@
     return cast(Type)o;
 }
 
+/***********************
+ * Try to get arg as a type.
+ */
+
+Type getType(Object o)
+{
+    Type t = isType(o);
+    if (!t)
+    {   Expression e = isExpression(o);
+	if (e)
+	    t = e.type;
+    }
+    return t;
+}
+
+
 Dsymbol getDsymbol(Object oarg)
 {
 	Dsymbol sa;
@@ -322,6 +339,9 @@
 		}
 		--len;
 
+version (Bug4054)
+		char* s = cast(char*)GC.malloc(len);
+else
 		char* s = cast(char*)alloca(len);
 		char* q = s + len;
 
@@ -761,6 +781,9 @@
 
 		//printf("Dsymbol::toImport('%s')\n", sym->Sident);
 		n = sym.Sident.ptr;
+version (Bug4054)
+		id = cast(char*) GC.malloc(6 + strlen(n) + 1 + (type_paramsize_i(sym.Stype)).sizeof*3 + 1);
+else
 		id = cast(char*) alloca(6 + strlen(n) + 1 + (type_paramsize_i(sym.Stype)).sizeof*3 + 1);
 		if (sym.Stype.Tmangle == mTYman_std && tyfunc(sym.Stype.Tty))
 		{
@@ -803,6 +826,9 @@
 			n += 2;
 		}
 }
+		version (Bug4054)
+		id = cast(char*) GC.malloc(2 + nlen + size_t.sizeof * 3 + prefix.length + suffix.length + 1);
+		else
 		id = cast(char*) alloca(2 + nlen + size_t.sizeof * 3 + prefix.length + suffix.length + 1);
 		sprintf(id, "_D%.*s%lu%.*s%.*s", n, prefix.length, prefix, suffix);
 		
@@ -859,4 +885,4 @@
 version (TARGET_NET) {
     PragmaScope isPragmaScope() { return null; }
 }
-}
\ No newline at end of file
+}
--- a/dmd/EnumDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/EnumDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -19,6 +19,7 @@
 import dmd.HdrGenState;
 import dmd.Global;
 import dmd.Loc;
+import dmd.Module;
 import dmd.TypeEnum;
 import dmd.EnumMember;
 import dmd.DYNCAST;
@@ -64,7 +65,19 @@
 	
     Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+	    Type t = null;
+	    if (memtype)
+		t = memtype.syntaxCopy();
+
+	    EnumDeclaration ed;
+	    if (s)
+	    {	ed = cast(EnumDeclaration)s;
+		ed.memtype = t;
+	    }
+	    else
+		ed = new EnumDeclaration(loc, ident, t);
+	    ScopeDsymbol.syntaxCopy(ed);
+	    return ed;
 	}
 	
     void semantic(Scope sc)
@@ -285,14 +298,46 @@
 	
     bool oneMember(Dsymbol* ps)
 	{
-		if (isAnonymous())
+    		if (isAnonymous())
 			return Dsymbol.oneMembers(members, ps);
-		return Dsymbol.oneMember(ps);
+	    	return Dsymbol.oneMember(ps);
 	}
 	
     void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+	   int i;
+
+	    buf.writestring("enum ");
+	    if (ident)
+	    {	buf.writestring(ident.toChars());
+		buf.writeByte(' ');
+	    }
+	    if (memtype)
+	    {
+		buf.writestring(": ");
+		memtype.toCBuffer(buf, null, hgs);
+	    }
+	    if (!members)
+	    {
+		buf.writeByte(';');
+		buf.writenl();
+		return;
+	    }
+	    buf.writenl();
+	    buf.writeByte('{');
+	    buf.writenl();
+	    for (i = 0; i < members.dim; i++)
+	    {
+		EnumMember em = (cast(Dsymbol)members.data[i]).isEnumMember();
+		if (!em)
+		    continue;
+		//buf.writestring("    ");
+		em.toCBuffer(buf, hgs);
+		buf.writeByte(',');
+		buf.writenl();
+	    }
+	    buf.writeByte('}');
+	    buf.writenl();
 	}
 	
     Type getType()
@@ -308,7 +353,7 @@
 version (DMDV2) {
     Dsymbol search(Loc, Identifier ident, int flags)
 	{
-		//printf("%s.EnumDeclaration::search('%s')\n", toChars(), ident->toChars());
+		//printf("%s.EnumDeclaration.search('%s')\n", toChars(), ident.toChars());
 		if (scope_)
 			// Try one last time to resolve this enum
 			semantic(scope_);
@@ -342,7 +387,7 @@
 
     void toObjFile(int multiobj)			// compile to .obj file
 	{
-		//printf("EnumDeclaration::toObjFile('%s')\n", toChars());
+		//printf("EnumDeclaration.toObjFile('%s')\n", toChars());
 	version (DMDV2) {
 		if (isAnonymous())
 			return;
@@ -373,7 +418,7 @@
 		}
 		version (DMDV1) {
 			dtnbytes(&sinit.Sdt, tc.size(0), cast(char*)&tc.sym.defaultval);
-			//sinit->Sdt = tc->sym->init->toDt();
+			//sinit.Sdt = tc.sym.init.toDt();
 		}
 		version (DMDV2) {
 			tc.sym.defaultval.toDt(&sinit.Sdt);
@@ -415,4 +460,4 @@
 
 		return sinit;
 	}
-};
\ No newline at end of file
+};
--- a/dmd/EnumMember.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/EnumMember.d	Mon Apr 12 17:00:08 2010 +0100
@@ -11,42 +11,67 @@
 
 class EnumMember : Dsymbol
 {
-    Expression value;
-    Type type;
+	Expression value;
+	Type type;
 
-    this(Loc loc, Identifier id, Expression value, Type type)
+	this(Loc loc, Identifier id, Expression value, Type type)
 	{
 		super(id);
-		
+
 		this.value = value;
 		this.type = type;
 		this.loc = loc;
 	}
-	
-    Dsymbol syntaxCopy(Dsymbol s)
+
+	Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+		Expression e = null;
+		if (value)
+			e = value.syntaxCopy();
+
+		Type t = null;
+		if (type)
+			t = type.syntaxCopy();
+
+		EnumMember em;
+		if (s)
+		{	em = cast(EnumMember)s;
+			em.loc = loc;
+			em.value = e;
+			em.type = t;
+		}
+		else
+			em = new EnumMember(loc, ident, e, t);
+		return em;
 	}
-	
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		if (type)
+			type.toCBuffer(buf, ident, hgs);
+		else
+			buf.writestring(ident.toChars());
+		if (value)
+		{
+			buf.writestring(" = ");
+			value.toCBuffer(buf, hgs);
+		}
 	}
-	
-    string kind()
+
+	string kind()
+	{
+		return "enum member";
+	}
+
+	void emitComment(Scope sc)
 	{
 		assert(false);
 	}
 
-    void emitComment(Scope sc)
-	{
-		assert(false);
-	}
-	
-    void toDocBuffer(OutBuffer buf)
+	void toDocBuffer(OutBuffer buf)
 	{
 		assert(false);
 	}
 
-    EnumMember isEnumMember() { return this; }
-}
\ No newline at end of file
+	EnumMember isEnumMember() { return this; }
+}
--- a/dmd/ExpStatement.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/ExpStatement.d	Mon Apr 12 17:00:08 2010 +0100
@@ -15,6 +15,7 @@
 import dmd.BE;
 import dmd.TOK;
 import dmd.DeclarationStatement;
+import dmd.Util : printf;
 
 import dmd.backend.Blockx;
 import dmd.backend.Util;
@@ -122,4 +123,4 @@
 		if (exp) 
 			block_appendexp(blx.curblock, exp.toElem(irs));
 	}
-}
\ No newline at end of file
+}
--- a/dmd/Expression.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Expression.d	Mon Apr 12 17:00:08 2010 +0100
@@ -917,4 +917,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/File.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/File.d	Mon Apr 12 17:00:08 2010 +0100
@@ -5,7 +5,18 @@
 import dmd.Util;
 
 import core.stdc.stdlib;
-import core.sys.windows.windows;
+version (Windows)
+{
+    import core.sys.windows.windows;
+}
+version (POSIX)
+{
+    import core.sys.posix.fcntl;
+    import core.stdc.errno;
+    import core.sys.posix.unistd;
+    import core.sys.posix.utime;
+    import core.stdc.stdio;
+}
 
 import std.string : toStringz;
 
@@ -72,10 +83,11 @@
 		string name = this.name.toChars();
 
 		//printf("File::read('%s')\n",name);
-		int fd = open(name, O_RDONLY);
+		int fd = open(toStringz(name), O_RDONLY);
 		if (fd == -1) {
 			result = errno;
-			//printf("\topen error, errno = %d\n", errno);
+			printf("file: %s\n", toStringz(name));
+			printf("\topen error, errno = %d\n", errno);
 			goto err1;
 		}
 
@@ -86,7 +98,7 @@
 		ref_ = 0;       // we own the buffer now
 
 		//printf("\tfile opened\n");
-		stat buf;
+		stat_t buf;
 		if (fstat(fd, &buf)) {
 			printf("\tfstat error, errno = %d\n", errno);
 			goto err2;
@@ -231,18 +243,16 @@
     int write()
 	{
 version (POSIX) {
-		assert(false);
-		/+
+		//assert(false);
+		
 		int fd;
 		ssize_t numwritten;
-		char *name;
-
-		name = this->name->toChars();
+		const(char)* name = toStringz(this.name.toChars());
 		fd = open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644);
 		if (fd == -1)
 		goto err;
 
-		numwritten = ::write(fd, buffer, len);
+		numwritten = core.sys.posix.unistd.write(fd, buffer, len);
 		if (len != numwritten)
 		goto err2;
 		
@@ -250,10 +260,10 @@
 		goto err;
 
 		if (touchtime)
-		{   struct utimbuf ubuf;
+		{   utimbuf ubuf;
 
-			ubuf.actime = ((struct stat *)touchtime)->st_atime;
-			ubuf.modtime = ((struct stat *)touchtime)->st_mtime;
+			ubuf.actime = (cast(stat_t *)touchtime).st_atime;
+			ubuf.modtime = (cast(stat_t *)touchtime).st_mtime;
 		if (utime(name, &ubuf))
 			goto err;
 		}
@@ -261,10 +271,10 @@
 
 	err2:
 		close(fd);
-		::remove(name);
+		.remove(name);
 	err:
 		return 1;
-		+/
+		
 } else version (_WIN32) {
 		HANDLE h;
 		DWORD numwritten;
@@ -388,11 +398,11 @@
     void remove()		// delete file
 	{
 version (POSIX) {
-		.remove(this.name.toChars());
+		.remove(toStringz(this.name.toChars()));
 } else version (_WIN32) {
 		DeleteFileA(toStringz(this.name.toChars()));
 } else {
 		assert(0);
 }
 	}
-}
\ No newline at end of file
+}
--- a/dmd/FileInitExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/FileInitExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -4,23 +4,31 @@
 import dmd.Loc;
 import dmd.Scope;
 import dmd.DefaultInitExp;
+import dmd.StringExp;
 import dmd.TOK;
+import dmd.Util;
+import dmd.Type;
 
-class FileInitExp : DefaultInitExp
-{
-	this(Loc loc)
+class FileInitExp : DefaultInitExp
+{
+	this(Loc loc)
+	{
+		super(loc, TOK.TOKfile, this.sizeof);
+	}
+
+	Expression semantic(Scope sc)
 	{
-		super(loc, TOKfile, FileInitExp.sizeof);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	Expression resolve(Loc loc, Scope sc)
-	{
-		assert(false);
-	}
-}
-
+		type = Type.tchar.invariantOf().arrayOf();
+		return this;
+	}
+
+	Expression resolve(Loc loc, Scope sc)
+	{
+		//printf("FileInitExp::resolve() %s\n", toChars());
+		string s = loc.filename ? loc.filename : sc.module_.ident.toChars();
+		Expression e = new StringExp(loc, s);
+		e = e.semantic(sc);
+		e = e.castTo(sc, type);
+		return e;
+	}
+}
--- a/dmd/FileName.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/FileName.d	Mon Apr 12 17:00:08 2010 +0100
@@ -15,7 +15,17 @@
 import std.string : cmp, icmp;
 import std.file : mkdirRecurse;
 
-import core.sys.windows.windows;
+version (Windows)
+{
+    import core.sys.windows.windows;
+}
+
+version (POSIX)
+{
+    import core.stdc.stdlib;
+    import core.sys.posix.sys.stat;
+    import std.conv;
+}
 
 class FileName : String
 {
@@ -359,7 +369,7 @@
 
 	version (POSIX) {
 						case '~':
-							buf.writestring(getenv("HOME"));
+							buf.writestring(to!string(getenv("HOME")));
 							continue;
 	}
 
@@ -454,7 +464,7 @@
 version (_WIN32) {
 		file.touchtime = GC.malloc(WIN32_FIND_DATA.sizeof);	// keep same file time
 } else version (POSIX) {
-		file.touchtime = GC.malloc(stat.sizeof); // keep same file time
+		file.touchtime = GC.malloc(stat_t.sizeof); // keep same file time
 } else {
 		static assert(0);
 }
@@ -494,13 +504,38 @@
 		
 		return null;
 	}
-	
+
+	static string searchPath(string[] path, string name, bool cwd)
+	{
+		if (absolute(name)) {
+			return exists(name) ? name : null;
+		}
+		
+		if (cwd) {
+			if (exists(name)) {
+				return name;
+			}
+		}
+		
+		if (path !is null) {
+			foreach (i, p; path)
+			{
+				string n = combine(p, name);
+
+				if (exists(n))
+					return n;
+			}
+		}
+		
+		return null;
+	}
+
     static int exists(string name)
 	{
 version (POSIX) {
-		stat st;
+		stat_t st;
 
-		if (stat(name, &st) < 0)
+		if (stat(toStringz(name), &st) < 0)
 			return 0;
 		if (S_ISDIR(st.st_mode))
 			return 2;
@@ -534,4 +569,4 @@
 		} catch {
 		}
 	}
-}
\ No newline at end of file
+}
--- a/dmd/FuncDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/FuncDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -112,6 +112,7 @@
 
 import core.stdc.stdio;
 import core.stdc.string;
+version (Bug4054) import core.memory;
 
 import std.string;
 
@@ -1658,7 +1659,7 @@
 		Param1 p;
 		p.t = t;
 		p.f = null;
-		overloadApply(this, &p.fp1);
+		overloadApply(this, &p.fp1, &p);
 		return p.f;
 	}
 	
@@ -2645,6 +2646,9 @@
 		type *t;
 
 		n = sym.Sident;
+		version (Bug4054)
+		id = cast(char*) GC.malloc(8 + 5 + strlen(n) + 1);
+		else
 		id = cast(char*) alloca(8 + 5 + strlen(n) + 1);
 		sprintf(id, "_thunk%d__%s", offset, n);
 		s = symbol_calloc(id);
@@ -2738,7 +2742,7 @@
 			// Pull in RTL startup code
 			if (func.isMain())
 			{   objextdef("_main");
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 				obj_ehsections();	// initialize exception handling sections
 } else {
 				objextdef("__acrtused_con");
@@ -2837,6 +2841,9 @@
 			pi += parameters.dim;
 
 		// Allow extra 2 for sthis and shidden
+		version (Bug4054)
+		params = cast(Symbol**)GC.malloc((pi + 2) * (Symbol*).sizeof);
+		else
 		params = cast(Symbol**)alloca((pi + 2) * (Symbol*).sizeof);
 
 		// Get the actual number of parameters, pi, and fill in the params[]
@@ -3077,7 +3084,7 @@
 			ss.toObjFile(0);
 		}
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 		// A hack to get a pointer to this function put in the .dtors segment
 		if (ident && ident.toChars() == "_STD") {
 			obj_staticdtor(s);
@@ -3245,4 +3252,4 @@
 	}
 
     FuncDeclaration isFuncDeclaration() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/Global.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Global.d	Mon Apr 12 17:00:08 2010 +0100
@@ -10,7 +10,7 @@
 	
 version (TARGET_WINDOS) {
     string obj_ext = "obj";
-} else version (XXX) {	// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+} else version (POSIX) {	// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
     string obj_ext = "o";
 } else version (TARGET_NET) {
 } else {
@@ -19,7 +19,7 @@
 
 version (TARGET_WINDOS) {
     string lib_ext = "lib";
-} else version (XXX) {	// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+} else version (POSIX) {	// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 	string lib_ext = "a";
 } else version (TARGET_NET) {
 } else {
@@ -49,4 +49,4 @@
 	}
 }
 
-Global global;
\ No newline at end of file
+Global global;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmd/Gnuc.d	Mon Apr 12 17:00:08 2010 +0100
@@ -0,0 +1,51 @@
+module dmd.Gnuc;
+
+int memicmp(const char *s1, const char *s2, int n)
+{
+    int result = 0;
+
+    for (int i = 0; i < n; i++)
+    {	char c1 = s1[i];
+	char c2 = s2[i];
+
+	result = c1 - c2;
+	if (result)
+	{
+	    if ('A' <= c1 && c1 <= 'Z')
+		c1 += 'a' - 'A';
+	    if ('A' <= c2 && c2 <= 'Z')
+		c2 += 'a' - 'A';
+	    result = c1 - c2;
+	    if (result)
+		break;
+	}
+    }
+    return result;
+}
+
+int stricmp(const(char) *s1, const(char) *s2)
+{
+    int result = 0;
+
+    for (;;)
+    {	char c1 = *s1;
+	char c2 = *s2;
+
+	result = c1 - c2;
+	if (result)
+	{
+	    if ('A' <= c1 && c1 <= 'Z')
+		c1 += 'a' - 'A';
+	    if ('A' <= c2 && c2 <= 'Z')
+		c2 += 'a' - 'A';
+	    result = c1 - c2;
+	    if (result)
+		break;
+	}
+	if (!c1)
+	    break;
+	s1++;
+	s2++;
+    }
+    return result;
+}
--- a/dmd/IntegerExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/IntegerExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -514,7 +514,10 @@
 
 	void toMangleBuffer(OutBuffer buf)
 	{
-		assert(false);
+	    if (cast(long)value < 0)
+		buf.printf("N%d", -value);
+	    else
+		buf.printf("%d", value);
 	}
 
 	Expression toLvalue(Scope sc, Expression e)
--- a/dmd/InterfaceDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/InterfaceDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -17,6 +17,7 @@
 import dmd.Dsymbol;
 import dmd.Scope;
 import dmd.Global;
+import dmd.Module;
 import dmd.BaseClass;
 import dmd.Id;
 
@@ -476,10 +477,10 @@
 
 		csym.Sdt = dt;
 	version (ELFOBJ) {
-		csym.Sseg = CDATA;
+		csym.Sseg = Segment.CDATA;
 	}
 	version (MACHOBJ) {
-		csym.Sseg = DATA;
+		csym.Sseg = Segment.DATA;
 	}
 		outdata(csym);
 		if (isExport())
@@ -508,4 +509,4 @@
 	}
 
     InterfaceDeclaration isInterfaceDeclaration() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/Library.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Library.d	Mon Apr 12 17:00:08 2010 +0100
@@ -150,7 +150,8 @@
 	
     return cmp((*p1).name, (*p2).name);
 }
-
+version (Windows)
+{
 /*******************************************
  * Write a single entry into dictionary.
  * Returns:
@@ -979,4 +980,26 @@
 		// Write library header at start of buffer
 		memcpy(libbuf.data, &libHeader, libHeader.sizeof);
 	}
-}
\ No newline at end of file
+}
+} // version (Windows)
+else version(TARGET_LINUX)
+{
+class Library
+{
+    void setFilename(string dir, string filename)
+    {
+    	assert(0);
+    }
+    
+    void addObject(string module_name, void *buf, size_t buflen)
+    {
+    	assert(0);
+    }
+    
+    void write()
+    {
+    	assert(0);
+    }
+	
+}
+}
--- a/dmd/LineInitExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/LineInitExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -4,22 +4,27 @@
 import dmd.Loc;
 import dmd.Scope;
 import dmd.DefaultInitExp;
+import dmd.IntegerExp;
 import dmd.TOK;
+import dmd.Type;
+
+class LineInitExp : DefaultInitExp
+{
+	this(Loc loc)
+	{
+		super(loc, TOK.TOKline, this.sizeof);
+	}
 
-class LineInitExp : DefaultInitExp
-{
-	this(Loc loc)
-	{
-		super(loc, TOKline, LineInitExp.sizeof);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	Expression resolve(Loc loc, Scope sc)
-	{
-		assert(false);
-	}
-}
\ No newline at end of file
+	Expression semantic(Scope sc)
+	{
+		type = Type.tint32;
+		return this;
+	}
+
+	Expression resolve(Loc loc, Scope sc)
+	{
+		Expression e = new IntegerExp(loc, loc.linnum, Type.tint32);
+		e = e.castTo(sc, type);
+		return e;
+	}
+}
--- a/dmd/MOD.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/MOD.d	Mon Apr 12 17:00:08 2010 +0100
@@ -1,6 +1,6 @@
 module dmd.MOD;
 
-enum MOD
+public enum MOD
 {
 	MODundefined = 0,
 	MODconst = 1,	// type is const
@@ -9,4 +9,4 @@
 }
 
 import dmd.EnumUtils;
-mixin(BringToCurrentScope!(MOD));
\ No newline at end of file
+mixin(BringToCurrentScope!(MOD));
--- a/dmd/ModAssignExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/ModAssignExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -17,13 +17,12 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
-		assert(false);
-		super(loc, TOK.init, 0, e1, e2);
+		super(loc, TOK.TOKmodass, this.sizeof, e1, e2);
 	}
 	
     Expression semantic(Scope sc)
 	{
-		assert(false);
+    		return commonSemanticAssign(sc);
 	}
 	
     Expression interpret(InterState* istate)
@@ -50,4 +49,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/Module.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Module.d	Mon Apr 12 17:00:08 2010 +0100
@@ -456,7 +456,7 @@
 			le = 1;
 
 			Lutf32:
-			OutBuffer dbuf;
+			OutBuffer dbuf = new OutBuffer();
 			uint* pu = cast(uint*)buf;
 			uint* pumax = &pu[buflen / 4];
 
@@ -491,7 +491,7 @@
 				le = 1;
 
 				Lutf16:
-				OutBuffer dbuf;
+				OutBuffer dbuf = new OutBuffer();
 				ushort* pu = cast(ushort*)(buf);
 				ushort *pumax = &pu[buflen / 2];
 
@@ -899,9 +899,9 @@
 					/* This should work, but causes optlink to fail in common/newlib.asm */
 					objextdef(s.Sident);
 } else {
-	version (XXX) {///ELFOBJ || MACHOBJ
-				int nbytes = reftoident(DATA, Offset(DATA), s, 0, CFoff);
-				Offset(DATA) += nbytes;
+	version (ELFOBJ_OR_MACHOBJ) {///ELFOBJ || MACHOBJ
+				int nbytes = reftoident(Segment.DATA, Offset(Segment.DATA), s, 0, CF.CFoff);
+				Offset(Segment.DATA) += nbytes;
 	} else {
 				int nbytes = reftoident(Segment.DATA, Doffset, s, 0, CF.CFoff);
 				Doffset() += nbytes;
@@ -1221,6 +1221,9 @@
 			}
 			else
 			{
+				version(Bug4054)
+				todo = cast(Dsymbol*)GC.malloc(len * (Dsymbol*).sizeof);
+				else
 				todo = cast(Dsymbol*)alloca(len * (Dsymbol*).sizeof);
 				assert(todo);
 			}
@@ -1564,4 +1567,4 @@
 	}
 
     Module isModule() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/Parser.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Parser.d	Mon Apr 12 17:00:08 2010 +0100
@@ -47,6 +47,7 @@
 import dmd.AssertExp;
 import dmd.CompileExp;
 import dmd.FileExp;
+import dmd.TemplateMixin;
 import dmd.TemplateParameter;
 import dmd.TemplateTypeParameter;
 import dmd.TypeidExp;
@@ -1076,6 +1077,7 @@
 	Lerr:
 		return tpl;
 	}
+<<<<<<< local
 	
 	/******************************************
 	 * Parse template mixin.
@@ -1085,6 +1087,17 @@
 	 *	mixin Foo!(args) identifier;
 	 *	mixin typeof(expr).identifier!(args);
 	 */
+=======
+
+/******************************************
+ * Parse template mixin.
+ *	mixin Foo;
+ *	mixin Foo!(args);
+ *	mixin a.b.c!(args).Foo!(args);
+ *	mixin Foo!(args) identifier;
+ *	mixin typeof(expr).identifier!(args);
+ */
+
     Dsymbol parseMixin()
 	{
 		TemplateMixin tm;
@@ -1129,10 +1142,8 @@
 				else
 					tiargs = parseTemplateArgument();
 			}
-
 			if (token.value != TOKdot)
 				break;
-
 			if (tiargs)
 			{   
 				TemplateInstance tempinst = new TemplateInstance(loc, id);
@@ -1141,7 +1152,6 @@
 				tiargs = null;
 			}
 			idents.push(cast(void*)id);
-
 			nextToken();
 			if (token.value != TOKidentifier)
 			{   
@@ -1152,7 +1162,6 @@
 			nextToken();
 		}
 		idents.push(cast(void*)id);
-
 		if (token.value == TOKidentifier)
 		{
 			id = token.ident;
@@ -1165,7 +1174,6 @@
 		if (token.value != TOKsemicolon)
 			error("';' expected after mixin");
 		nextToken();
-
 		return tm;
 	}
 	
@@ -6112,4 +6120,4 @@
 		s.addComment(combineComments(blockComment, token.lineComment));
 		token.lineComment = null;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/PragmaDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/PragmaDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -62,7 +62,7 @@
 					if (e.op == TOKstring)
 					{
 						StringExp se = cast(StringExp)e;
-						writef("%.*s", cast(int)se.len, cast(char*)se.string_);
+						writef("%s", se.toChars()[1..$-3] /*se.len, cast(char*)se.string_*/);
 					}
 					else
 						error("string expected for message, not '%s'", e.toChars());
@@ -286,4 +286,4 @@
 ///	}
 		AttribDeclaration.toObjFile(multiobj);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/Scope.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Scope.d	Mon Apr 12 17:00:08 2010 +0100
@@ -113,12 +113,14 @@
 		// Create root scope
 
 		//printf("Scope.Scope() %p\n", this);
+		this.docbuf = new OutBuffer;
 		this.structalign = global.structalign;
 	}
 	
     this(Module module_)
 	{
 		assert(false);
+		this.docbuf = new OutBuffer;
 	}
 	
     this(Scope enclosing)
@@ -352,4 +354,4 @@
 				//assert(0);
 		}
 	}
-}
\ No newline at end of file
+}
--- a/dmd/ScopeDsymbol.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/ScopeDsymbol.d	Mon Apr 12 17:00:08 2010 +0100
@@ -38,7 +38,15 @@
 	
     Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+	    //printf("ScopeDsymbol.syntaxCopy('%s')\n", toChars());
+
+	    ScopeDsymbol sd;
+	    if (s)
+		sd = cast(ScopeDsymbol)s;
+	    else
+		sd = new ScopeDsymbol(ident);
+	    sd.members = arraySyntaxCopy(members);
+	    return sd;
 	}
 	
     Dsymbol search(Loc loc, Identifier ident, int flags)
@@ -269,4 +277,4 @@
 	}
 
     ScopeDsymbol isScopeDsymbol() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/StaticAssert.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/StaticAssert.d	Mon Apr 12 17:00:08 2010 +0100
@@ -14,33 +14,37 @@
 
 class StaticAssert : Dsymbol
 {
-    Expression exp;
-    Expression msg;
+	Expression exp;
+	Expression msg;
 
-    this(Loc loc, Expression exp, Expression msg)
+	this(Loc loc, Expression exp, Expression msg)
 	{
 		super(Id.empty);
-		
+
 		this.loc = loc;
 		this.exp = exp;
 		this.msg = msg;
 	}
 
-    Dsymbol syntaxCopy(Dsymbol s)
+	Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+		StaticAssert sa;
+
+		assert(!s);
+		sa = new StaticAssert(loc, exp.syntaxCopy(), msg ? msg.syntaxCopy() : null);
+		return sa;
 	}
-	
-    bool addMember(Scope sc, ScopeDsymbol sd, bool memnum)
+
+	bool addMember(Scope sc, ScopeDsymbol sd, int memnum)
 	{
 		return false;		// we didn't add anything
 	}
-	
-    void semantic(Scope sc)
+
+	void semantic(Scope sc)
 	{
 	}
-	
-    void semantic2(Scope sc)
+
+	void semantic2(Scope sc)
 	{
 		Expression e;
 
@@ -75,31 +79,38 @@
 			error("(%s) is not evaluatable at compile time", exp.toChars());
 		}
 	}
-	
-    void inlineScan()
+
+	void inlineScan()
 	{
-		assert(false);
 	}
-	
-    bool oneMember(Dsymbol* ps)
+
+	bool oneMember(Dsymbol* ps)
 	{
 		//printf("StaticAssert.oneMember())\n");
 		*ps = null;
 		return true;
 	}
-	
-    void toObjFile(int multiobj)
+
+	void toObjFile(int multiobj)
 	{
-		assert(false);
 	}
-	
-    string kind()
+
+	string kind()
 	{
 		return "static assert";
 	}
-	
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		buf.writestring(kind());
+		buf.writeByte('(');
+		exp.toCBuffer(buf, hgs);
+		if (msg)
+		{
+			buf.writeByte(',');
+			msg.toCBuffer(buf, hgs);
+		}
+		buf.writestring(");");
+		buf.writenl();
 	}
-}
\ No newline at end of file
+}
--- a/dmd/StaticIfCondition.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/StaticIfCondition.d	Mon Apr 12 17:00:08 2010 +0100
@@ -22,7 +22,7 @@
 
 	Condition syntaxCopy()
 	{
-		assert(false);
+	    return new StaticIfCondition(loc, exp.syntaxCopy());
 	}
 
 	bool include(Scope sc, ScopeDsymbol s)
--- a/dmd/StaticIfDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/StaticIfDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -21,7 +21,13 @@
 	
     Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+	    StaticIfDeclaration dd;
+
+	    assert(!s);
+	    dd = new StaticIfDeclaration(condition.syntaxCopy(),
+		Dsymbol.arraySyntaxCopy(decl),
+		Dsymbol.arraySyntaxCopy(elsedecl));
+	    return dd;
 	}
 
     bool addMember(Scope sc, ScopeDsymbol sd, bool memnum)
@@ -75,4 +81,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/StringExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/StringExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -10,6 +10,7 @@
 import dmd.TypeDArray;
 import dmd.Type;
 import dmd.TOK;
+import dmd.Module;
 import dmd.OutBuffer;
 import dmd.Loc;
 import dmd.Scope;
@@ -17,6 +18,7 @@
 import dmd.StringExp;
 import dmd.HdrGenState;
 import dmd.Utf;
+import dmd.Util;
 import dmd.backend.dt_t;
 import dmd.backend.Symbol;
 import dmd.backend.StringTab;
@@ -572,7 +574,55 @@
 
 	void toMangleBuffer(OutBuffer buf)
 	{
-		assert(false);
+	    char m;
+	    OutBuffer tmp = new OutBuffer();
+	    string p;
+	    dchar c;
+	    size_t u;
+	    ubyte *q;
+	    uint qlen;
+
+	    /* Write string in UTF-8 format
+	     */
+	    switch (sz)
+	    {	case 1:
+		    m = 'a';
+		    q = cast(ubyte *)string_;
+		    qlen = len;
+		    break;
+		case 2:
+		    m = 'w';
+		    for (u = 0; u < len; )
+		    {
+			p = utf_decodeWchar(cast(wstring)string_[0..len], &u, &c);
+			if (p)
+			    error("%s", p);
+			else
+			    tmp.writeUTF8(c);
+		    }
+		    q = tmp.data;
+		    qlen = tmp.offset;
+		    break;
+		case 4:
+		    m = 'd';
+		    for (u = 0; u < len; u++)
+		    {
+			c = (cast(uint*)string_)[u];
+			if (!utf_isValidDchar(c))
+			    error("invalid UCS-32 char \\U%08x", c);
+			else
+			    tmp.writeUTF8(c);
+		    }
+		    q = tmp.data;
+		    qlen = tmp.offset;
+		    break;
+		default:
+		    assert(0);
+	    }
+	    buf.writeByte(m);
+	    buf.printf("%d_", qlen);
+	    for (size_t i = 0; i < qlen; i++)
+		buf.printf("%02x", q[i]);
 	}
 
 	elem* toElem(IRState* irs)
--- a/dmd/TemplateAliasParameter.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TemplateAliasParameter.d	Mon Apr 12 17:00:08 2010 +0100
@@ -11,25 +11,53 @@
 import dmd.OutBuffer;
 import dmd.HdrGenState;
 import dmd.Dsymbol;
-import dmd.TypeIdentifier;
+import dmd.WANT;
+import dmd.Expression;
+import dmd.Initializer;
+import dmd.ExpInitializer;
 import dmd.AliasDeclaration;
+import dmd.VarDeclaration;
+import dmd.TemplateDeclaration;
+import dmd.STC;
 import dmd.Util;
 
 import dmd.templates.Util;
 
+Object aliasParameterSemantic(Loc loc, Scope sc, Object o)
+{
+	if (o)
+	{
+		Expression ea = isExpression(o);
+		Type ta = isType(o);
+		if (ta)
+		{   Dsymbol s = ta.toDsymbol(sc);
+			if (s)
+				o = s;
+			else
+				o = ta.semantic(loc, sc);
+		}
+		else if (ea)
+		{
+			ea = ea.semantic(sc);
+			o = ea.optimize(WANT.WANTvalue | WANT.WANTinterpret);
+		}
+	}
+	return o;
+}
+
 class TemplateAliasParameter : TemplateParameter
 {
-    /* Syntax:
-     *	specType ident : specAlias = defaultAlias
-     */
+	/* Syntax:
+	 *	specType ident : specAlias = defaultAlias
+	 */
 
-    Type specType;
-    Object specAlias;
-    Object defaultAlias;
+	Type specType;
+	Object specAlias;
+	Object defaultAlias;
 
-    static Dsymbol sdummy;
+	static Dsymbol sdummy;
 
-    this(Loc loc, Identifier ident, Type specType, Object specAlias, Object defaultAlias)
+	this(Loc loc, Identifier ident, Type specType, Object specAlias, Object defaultAlias)
 	{
 		super(loc, ident);
 
@@ -38,12 +66,12 @@
 		this.defaultAlias = defaultAlias;
 	}
 
-    TemplateAliasParameter isTemplateAliasParameter()
+	TemplateAliasParameter isTemplateAliasParameter()
 	{
 		return this;
 	}
-	
-    TemplateParameter syntaxCopy()
+
+	TemplateParameter syntaxCopy()
 	{
 		TemplateAliasParameter tp = new TemplateAliasParameter(loc, ident, specType, specAlias, defaultAlias);
 		if (tp.specType)
@@ -52,16 +80,16 @@
 		tp.defaultAlias = objectSyntaxCopy(defaultAlias);
 		return tp;
 	}
-	
-    void declareParameter(Scope sc)
+
+	void declareParameter(Scope sc)
 	{
 		TypeIdentifier ti = new TypeIdentifier(loc, ident);
 		sparam = new AliasDeclaration(loc, ident, ti);
 		if (!sc.insert(sparam))
 			error(loc, "parameter '%s' multiply defined", ident.toChars());
 	}
-	
-    void semantic(Scope sc)
+
+	void semantic(Scope sc)
 	{
 		if (specType)
 		{
@@ -73,39 +101,165 @@
 			defaultAlias = defaultAlias.semantic(loc, sc);
 }
 	}
-	
-    void print(Object oarg, Object oded)
+
+	void print(Object oarg, Object oded)
 	{
-		assert(false);
+		printf(" %s\n", ident.toChars());
+
+		Dsymbol sa = isDsymbol(oded);
+		assert(sa);
+
+		printf("\tArgument alias: %s\n", sa.toChars());
 	}
-	
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		buf.writestring("alias ");
+		if (specType)
+		{	HdrGenState hg;
+			specType.toCBuffer(buf, ident, &hg);
+		}
+		else
+			buf.writestring(ident.toChars());
+		if (specAlias)
+		{
+			buf.writestring(" : ");
+			ObjectToCBuffer(buf, hgs, specAlias);
+		}
+		if (defaultAlias)
+		{
+			buf.writestring(" = ");
+			ObjectToCBuffer(buf, hgs, defaultAlias);
+		}
 	}
-	
-    Object specialization()
+
+	Object specialization()
 	{
-		assert(false);
+		return specAlias;
+	}
+
+	Object defaultArg(Loc loc, Scope sc)
+	{
+		Object o = aliasParameterSemantic(loc, sc, defaultAlias);
+		return o;
 	}
-	
-    Object defaultArg(Loc loc, Scope sc)
+
+	bool overloadMatch(TemplateParameter tp)
+	{
+		TemplateAliasParameter tap = tp.isTemplateAliasParameter();
+
+		if (tap)
+		{
+			if (specAlias != tap.specAlias)
+				goto Lnomatch;
+
+			return true;			// match
+		}
+
+Lnomatch:
+		return false;
+	}
+
+	MATCH matchArg(Scope sc, Objects tiargs, int i, TemplateParameters parameters, Objects dedtypes, Declaration* psparam, int flags)
 	{
-		assert(false);
-	}
-	
-    bool overloadMatch(TemplateParameter)
-	{
-		assert(false);
+		Object sa;
+		Object oarg;
+		Expression ea;
+		Dsymbol s;
+
+		//printf("TemplateAliasParameter.matchArg()\n");
+
+		if (i < tiargs.dim)
+			oarg = cast(Object)tiargs.data[i];
+		else
+		{	// Get default argument instead
+			oarg = defaultArg(loc, sc);
+			if (!oarg)
+			{   assert(i < dedtypes.dim);
+				// It might have already been deduced
+				oarg = cast(Object)dedtypes.data[i];
+				if (!oarg)
+					goto Lnomatch;
+			}
+		}
+
+		sa = getDsymbol(oarg);
+		if (sa)
+		{
+			/* specType means the alias must be a declaration with a type
+			 * that matches specType.
+			 */
+			if (specType)
+			{   Declaration d = (cast(Dsymbol)sa).isDeclaration();
+					if (!d)
+					goto Lnomatch;
+					if (!d.type.equals(specType))
+					goto Lnomatch;
+					}
+					}
+					else
+					{
+					sa = oarg;
+					ea = isExpression(oarg);
+					if (ea)
+					{   if (specType)
+					{
+					if (!ea.type.equals(specType))
+					goto Lnomatch;
+					}
+					}
+					else
+					goto Lnomatch;
+					}	
+			if (specAlias)
+			{
+				if (sa == sdummy)
+					goto Lnomatch;
+				if (sa != specAlias)
+					goto Lnomatch;
+			}
+			else if (dedtypes.data[i])
+			{   // Must match already deduced symbol
+				Object s_ = cast(Object)dedtypes.data[i];
+
+				if (!sa || s_ != sa)
+					goto Lnomatch;
+			}
+			dedtypes.data[i] = cast(void*)sa;
+
+			s = isDsymbol(sa);
+			if (s)
+				*psparam = new AliasDeclaration(loc, ident, s);
+			else
+			{
+				assert(ea);
+
+				// Declare manifest constant
+				Initializer init = new ExpInitializer(loc, ea);
+				VarDeclaration v = new VarDeclaration(loc, null, ident, init);
+				v.storage_class = STC.STCmanifest;
+				v.semantic(sc);
+				*psparam = v;
+			}
+			return MATCHexact;
+
+Lnomatch:
+			*psparam = null;
+			//printf("\tm = %d\n", MATCHnomatch);
+			return MATCHnomatch;
 	}
-	
-    MATCH matchArg(Scope sc, Objects tiargs, int i, TemplateParameters parameters, Objects dedtypes, Declaration* psparam, int flags)
+
+	void* dummyArg()
 	{
-		assert(false);
+		Object s;
+
+		s = specAlias;
+		if (!s)
+		{
+			if (!sdummy)
+				sdummy = new Dsymbol();
+			s = sdummy;
+		}
+		return cast(void*)s;
 	}
-	
-    void* dummyArg()
-	{
-		assert(false);
-	}
-}
\ No newline at end of file
+}
--- a/dmd/TemplateInstance.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TemplateInstance.d	Mon Apr 12 17:00:08 2010 +0100
@@ -36,6 +36,7 @@
 import dmd.FuncExp;
 import dmd.Declaration;
 import dmd.MATCH;
+import dmd.templates.Util;
 
 import dmd.backend.glue;
 
@@ -229,12 +230,31 @@
 
     static Objects arraySyntaxCopy(Objects objs)
 	{
-		assert(false);
+	    Objects a = null;
+	    if (objs)
+	    {	a = new Objects();
+		a.setDim(objs.dim);
+		for (size_t i = 0; i < objs.dim; i++)
+		{
+		    a.data[i] = cast(void*)objectSyntaxCopy(cast(Object)objs.data[i]);
+		}
+	    }
+	    return a;
 	}
 
-    Dsymbol syntaxCopy(Dsymbol)
+    Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+	    TemplateInstance ti;
+
+	    if (s)
+		ti = cast(TemplateInstance)s;
+	    else
+		ti = new TemplateInstance(loc, name);
+
+	    ti.tiargs = arraySyntaxCopy(tiargs);
+
+	    ScopeDsymbol.syntaxCopy(ti);
+	    return ti;
 	}
 
     void semantic(Scope sc)
@@ -527,7 +547,7 @@
 			}
 			--nest;
 		}
-		catch
+		catch (Exception e)
 		{
 			global.gag = 0;			// ensure error message gets printed
 			error("recursive expansion");
@@ -596,7 +616,7 @@
 
 		semanticRun = 2;
 	version (LOG) {
-		printf("+TemplateInstance::semantic2('%s')\n", toChars());
+		printf("+TemplateInstance.semantic2('%s')\n", toChars());
 	}
 
 		if (!errors && members)
@@ -621,7 +641,7 @@
 		}
 
 	version (LOG) {
-		printf("-TemplateInstance::semantic2('%s')\n", toChars());
+		printf("-TemplateInstance.semantic2('%s')\n", toChars());
 	}
 	}
 
@@ -693,7 +713,7 @@
     Dsymbol toAlias()			// resolve real symbol
 	{
 	version (LOG) {
-		printf("TemplateInstance::toAlias()\n");
+		printf("TemplateInstance.toAlias()\n");
 	}
 		if (!inst)
 		{	
@@ -714,12 +734,13 @@
 	
     string kind()
 	{
-		assert(false);
+	    return "template instance";
 	}
 	
     bool oneMember(Dsymbol* ps)
 	{
-		assert(false);
+	    *ps = null;
+	    return true;
 	}
 	
     string toChars()
@@ -733,12 +754,36 @@
 	
     string mangle()
 	{
-		assert(false);
+	    OutBuffer buf = new OutBuffer();
+	    string id;
+
+	static if (0) {
+	    printf("TemplateInstance.mangle() %s", toChars());
+	    if (parent)
+		printf("  parent = %s %s", parent.kind(), parent.toChars());
+	    printf("\n");
+	}
+	    id = ident ? ident.toChars() : toChars();
+	    if (!tempdecl)
+		error("is not defined");
+	    else if (tempdecl.parent)
+	    {
+		string p = tempdecl.parent.mangle();
+		if (p[0] == '_' && p[1] == 'D')
+		    p = p[2..$];
+		buf.writestring(p);
+	    }
+	    buf.printf("%d%s", id.length, id);
+	    id = buf.toChars();
+	    buf.data = null;
+	    //printf("TemplateInstance.mangle() %s = %s\n", toChars(), id);
+	    return id;
 	}
 	
     void printInstantiationTrace()
 	{
-		assert(false);
+	    if (global.gag)
+		return;
 	}
 
     void toObjFile(int multiobj)			// compile to .obj file
@@ -1159,7 +1204,7 @@
 	 */
     void declareParameters(Scope sc)
 	{
-		//printf("TemplateInstance::declareParameters()\n");
+		//printf("TemplateInstance.declareParameters()\n");
 		for (int i = 0; i < tdtypes.dim; i++)
 		{
 			TemplateParameter tp = cast(TemplateParameter)tempdecl.parameters.data[i];
@@ -1178,7 +1223,7 @@
     bool hasNestedArgs(Objects args)
 	{
 		bool nested = false;
-		//printf("TemplateInstance::hasNestedArgs('%s')\n", tempdecl.ident.toChars());
+		//printf("TemplateInstance.hasNestedArgs('%s')\n", tempdecl.ident.toChars());
 
 		/* A nested instance happens when an argument references a local
 		 * symbol that is on the stack.
@@ -1274,7 +1319,7 @@
 		string id;
 		Objects args;
 
-		//printf("TemplateInstance::genIdent('%s')\n", tempdecl.ident.toChars());
+		//printf("TemplateInstance.genIdent('%s')\n", tempdecl.ident.toChars());
 		id = tempdecl.ident.toChars();
 		buf.printf("__T%d%s", id.length, id);	///!
 		args = tiargs;
@@ -1383,4 +1428,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TemplateMixin.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TemplateMixin.d	Mon Apr 12 17:00:08 2010 +0100
@@ -10,13 +10,24 @@
 import dmd.Scope;
 import dmd.OutBuffer;
 import dmd.HdrGenState;
+import dmd.DYNCAST;
+import dmd.AggregateDeclaration;
+import dmd.TemplateDeclaration;
+import dmd.Expression;
+import dmd.DsymbolTable;
+import dmd.PROT;
+import dmd.ScopeDsymbol;
+import dmd.Global;
+import dmd.Util;
+
+extern(C++) void util_progress();
 
 class TemplateMixin : TemplateInstance
 {
-    Array idents;
-    Type tqual;
+	Array idents;
+	Type tqual;
 
-    this(Loc loc, Identifier ident, Type tqual, Array idents, Objects tiargs)
+	this(Loc loc, Identifier ident, Type tqual, Array idents, Objects tiargs)
 	{
 		super(loc, cast(Identifier)idents.data[idents.dim - 1]);
 		//printf("TemplateMixin(ident = '%s')\n", ident ? ident.toChars() : "");
@@ -25,61 +36,466 @@
 		this.idents = idents;
 		this.tiargs = tiargs ? tiargs : new Objects();
 	}
-	
-    Dsymbol syntaxCopy(Dsymbol s)
-	{
-		assert(false);
-	}
-	
-    void semantic(Scope sc)
-	{
-		assert(false);
-	}
-	
-    void semantic2(Scope sc)
-	{
-		assert(false);
-	}
-	
-    void semantic3(Scope sc)
-	{
-		assert(false);
-	}
-	
-    void inlineScan()
+
+	Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
-	}
-	
-    string kind()
-	{
-		assert(false);
-	}
-	
-    bool oneMember(Dsymbol* ps)
-	{
-		assert(false);
-	}
-	
-    bool hasPointers()
-	{
-		assert(false);
-	}
-	
-    string toChars()
-	{
-		assert(false);
-	}
-	
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
+		TemplateMixin tm;
+
+		Array ids = new Array();
+		ids.setDim(idents.dim);
+		for (int i = 0; i < idents.dim; i++)
+		{	// Matches TypeQualified.syntaxCopyHelper()
+			Identifier id = cast(Identifier)idents.data[i];
+			if (id.dyncast() == DYNCAST.DYNCAST_DSYMBOL)
+			{
+				TemplateInstance ti = cast(TemplateInstance)id;
+
+				ti = cast(TemplateInstance)ti.syntaxCopy(null);
+				id = cast(Identifier)ti;
+			}
+			ids.data[i] = cast(void*)id;
+		}
+
+		tm = new TemplateMixin(loc, ident,
+				cast(Type)(tqual ? tqual.syntaxCopy() : null),
+				ids, tiargs);
+		TemplateInstance.syntaxCopy(tm);
+		return tm;
 	}
 
-    void toObjFile(int multiobj)			// compile to .obj file
+	void semantic(Scope sc)
 	{
-		assert(false);
+		version (LOG) {
+			printf("+TemplateMixin.semantic('%s', this=%p)\n", toChars(), this);
+			fflush(stdout);
+		}
+		if (semanticRun &&
+				// This for when a class/struct contains mixin members, and
+				// is done over because of forward references
+				(!parent || !toParent().isAggregateDeclaration()))
+		{
+			version (LOG) {
+				printf("\tsemantic done\n");
+			}
+			return;
+		}
+		if (!semanticRun)
+			semanticRun = 1;
+		version (LOG) {
+			printf("\tdo semantic\n");
+		}
+		util_progress();
+
+		Scope scx = null;
+		if (scope_)
+		{	sc = scope_;
+			scx = scope_;		// save so we don't make redundant copies
+			scope_ = null;
+		}
+
+		// Follow qualifications to find the TemplateDeclaration
+		if (!tempdecl)
+		{	Dsymbol s;
+			int i;
+			Identifier id;
+
+			if (tqual)
+			{   s = tqual.toDsymbol(sc);
+				i = 0;
+			}
+			else
+			{
+				i = 1;
+				id = cast(Identifier)idents.data[0];
+				switch (id.dyncast())
+				{
+					case DYNCAST.DYNCAST_IDENTIFIER:
+						s = sc.search(loc, id, null);
+						break;
+
+					case DYNCAST.DYNCAST_DSYMBOL:
+						{
+							TemplateInstance ti = cast(TemplateInstance)id;
+							ti.semantic(sc);
+							s = ti;
+							break;
+						}
+					default:
+						assert(0);
+				}
+			}
+
+			for (; i < idents.dim; i++)
+			{
+				if (!s)
+					break;
+				id = cast(Identifier)idents.data[i];
+				s = s.searchX(loc, sc, id);
+			}
+			if (!s)
+			{
+				error("is not defined");
+				inst = this;
+				return;
+			}
+			tempdecl = s.toAlias().isTemplateDeclaration();
+			if (!tempdecl)
+			{
+				error("%s isn't a template", s.toChars());
+				inst = this;
+				return;
+			}
+		}
+
+		// Look for forward reference
+		assert(tempdecl);
+		for (TemplateDeclaration td = tempdecl; td; td = td.overnext)
+		{
+			if (!td.semanticRun)
+			{
+				/* Cannot handle forward references if mixin is a struct member,
+				 * because addField must happen during struct's semantic, not
+				 * during the mixin semantic.
+				 * runDeferred will re-run mixin's semantic outside of the struct's
+				 * semantic.
+				 */
+				semanticRun = 0;
+				AggregateDeclaration ad = toParent().isAggregateDeclaration();
+				if (ad)
+					ad.sizeok = 2;
+				else
+				{
+					// Forward reference
+					//printf("forward reference - deferring\n");
+					scope_ = scx ? scx : new Scope(sc);
+					scope_.setNoFree();
+					scope_.module_.addDeferredSemantic(this);
+				}
+				return;
+			}
+		}
+
+		// Run semantic on each argument, place results in tiargs[]
+		semanticTiargs(sc);
+
+		tempdecl = findBestMatch(sc);
+		if (!tempdecl)
+		{	inst = this;
+			return;		// error recovery
+		}
+
+		if (!ident)
+			ident = genIdent();
+
+		inst = this;
+		parent = sc.parent;
+
+		/* Detect recursive mixin instantiations.
+		 */
+		for (Dsymbol s = parent; s; s = s.parent)
+		{
+			//printf("\ts = '%s'\n", s.toChars());
+			TemplateMixin tm = s.isTemplateMixin();
+			if (!tm || tempdecl != tm.tempdecl)
+				continue;
+
+			/* Different argument list lengths happen with variadic args
+			 */
+			if (tiargs.dim != tm.tiargs.dim)
+				continue;
+
+			for (int i = 0; i < tiargs.dim; i++)
+			{   Object o = cast(Object)tiargs.data[i];
+				Type ta = isType(o);
+				Expression ea = isExpression(o);
+				Dsymbol sa = isDsymbol(o);
+				Object tmo = cast(Object)tm.tiargs.data[i];
+				if (ta)
+				{
+					Type tmta = isType(tmo);
+					if (!tmta)
+						goto Lcontinue;
+					if (!ta.equals(tmta))
+						goto Lcontinue;
+				}
+				else if (ea)
+				{	Expression tme = isExpression(tmo);
+					if (!tme || !ea.equals(tme))
+						goto Lcontinue;
+				}
+				else if (sa)
+				{
+					Dsymbol tmsa = isDsymbol(tmo);
+					if (sa != tmsa)
+						goto Lcontinue;
+				}
+				else
+					assert(0);
+			}
+			error("recursive mixin instantiation");
+			return;
+
+Lcontinue:
+			continue;
+		}
+
+
+		// Copy the syntax trees from the TemplateDeclaration
+		members = Dsymbol.arraySyntaxCopy(tempdecl.members);
+		if (!members)
+			return;
+
+		symtab = new DsymbolTable();
+
+		for (Scope sce = sc; 1; sce = sce.enclosing)
+		{
+			ScopeDsymbol sds = cast(ScopeDsymbol)sce.scopesym;
+			if (sds)
+			{
+				sds.importScope(this, PROT.PROTpublic);
+				break;
+			}
+		}
+
+		version (LOG) {
+			printf("\tcreate scope for template parameters '%s'\n", toChars());
+		}
+		Scope scy = sc;
+		scy = sc.push(this);
+		scy.parent = this;
+
+		argsym = new ScopeDsymbol();
+		argsym.parent = scy.parent;
+		Scope argscope = scy.push(argsym);
+
+		uint errorsave = global.errors;
+
+		// Declare each template parameter as an alias for the argument type
+		declareParameters(argscope);
+
+		// Add members to enclosing scope, as well as this scope
+		for (uint i = 0; i < members.dim; i++)
+		{   Dsymbol s;
+
+			s = cast(Dsymbol)members.data[i];
+			s.addMember(argscope, this, i);
+			//sc.insert(s);
+			//printf("sc.parent = %p, sc.scopesym = %p\n", sc.parent, sc.scopesym);
+			//printf("s.parent = %s\n", s.parent.toChars());
+		}
+
+		// Do semantic() analysis on template instance members
+		version (LOG) {
+			printf("\tdo semantic() on template instance members '%s'\n", toChars());
+		}
+		Scope sc2;
+		sc2 = argscope.push(this);
+		sc2.offset = sc.offset;
+
+
+		static int nest;
+		//printf("%d\n", nest);
+		if (++nest > 500)
+		{
+			global.gag = 0;			// ensure error message gets printed
+			error("recursive expansion");
+			fatal();
+		}
+
+		for (int i = 0; i < members.dim; i++)
+		{
+			Dsymbol s = cast(Dsymbol)members.data[i];
+			s.semantic(sc2);
+		}
+
+		nest--;
+
+		sc.offset = sc2.offset;
+
+		/* The problem is when to parse the initializer for a variable.
+		 * Perhaps VarDeclaration.semantic() should do it like it does
+		 * for initializers inside a function.
+		 */
+		//    if (sc.parent.isFuncDeclaration())
+
+		semantic2(sc2);
+
+		if (sc.func)
+		{
+			semantic3(sc2);
+		}
+
+		// Give additional context info if error occurred during instantiation
+		if (global.errors != errorsave)
+		{
+			error("error instantiating");
+		}
+
+		sc2.pop();
+
+		argscope.pop();
+
+		//    if (!isAnonymous())
+		{
+			scy.pop();
+		}
+		version (LOG) {
+			printf("-TemplateMixin.semantic('%s', this=%p)\n", toChars(), this);
+		}
 	}
 
-    TemplateMixin isTemplateMixin() { return this; }
-}
\ No newline at end of file
+	void semantic2(Scope sc)
+	{
+		int i;
+
+		if (semanticRun >= 2)
+			return;
+		semanticRun = 2;
+		version (LOG) {
+			printf("+TemplateMixin.semantic2('%s')\n", toChars());
+		}
+		if (members)
+		{
+			assert(sc);
+			sc = sc.push(argsym);
+			sc = sc.push(this);
+			for (i = 0; i < members.dim; i++)
+			{
+				Dsymbol s = cast(Dsymbol)members.data[i];
+				version (LOG) {
+					printf("\tmember '%s', kind = '%s'\n", s.toChars(), s.kind());
+				}
+				s.semantic2(sc);
+			}
+			sc = sc.pop();
+			sc.pop();
+		}
+		version (LOG) {
+			printf("-TemplateMixin.semantic2('%s')\n", toChars());
+		}
+	}
+
+	void semantic3(Scope sc)
+	{
+		int i;
+
+		if (semanticRun >= 3)
+			return;
+		semanticRun = 3;
+		version (LOG) {
+			printf("TemplateMixin.semantic3('%s')\n", toChars());
+		}
+		if (members)
+		{
+			sc = sc.push(argsym);
+			sc = sc.push(this);
+			for (i = 0; i < members.dim; i++)
+			{
+				Dsymbol s = cast(Dsymbol)members.data[i];
+				s.semantic3(sc);
+			}
+			sc = sc.pop();
+			sc.pop();
+		}
+	}
+
+	void inlineScan()
+	{
+		TemplateInstance.inlineScan();
+	}
+
+	string kind()
+	{
+		return "mixin";
+	}
+
+	bool oneMember(Dsymbol* ps)
+	{
+		return Dsymbol.oneMember(ps);
+	}
+
+	bool hasPointers()
+	{
+		//printf("TemplateMixin.hasPointers() %s\n", toChars());
+		for (size_t i = 0; i < members.dim; i++)
+		{
+			Dsymbol s = cast(Dsymbol)members.data[i];
+			//printf(" s = %s %s\n", s.kind(), s.toChars());
+			if (s.hasPointers())
+			{
+				return 1;
+			}
+		}
+		return 0;
+	}
+
+	string toChars()
+	{
+		OutBuffer buf = new OutBuffer();
+		HdrGenState hgs;
+		string s;
+
+		TemplateInstance.toCBuffer(buf, &hgs);
+		s = buf.toChars();
+		buf.data = null;
+		return s;
+	}
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	{
+		buf.writestring("mixin ");
+
+		for (int i = 0; i < idents.dim; i++)
+		{   Identifier id = cast(Identifier)idents.data[i];
+
+			if (i)
+				buf.writeByte('.');
+			buf.writestring(id.toChars());
+		}
+		buf.writestring("!(");
+		if (tiargs)
+		{
+			for (int i = 0; i < tiargs.dim; i++)
+			{   if (i)
+				buf.writebyte(',');
+				Object oarg = cast(Object)tiargs.data[i];
+				Type t = isType(oarg);
+				Expression e = isExpression(oarg);
+				Dsymbol s = isDsymbol(oarg);
+				if (t)
+					t.toCBuffer(buf, null, hgs);
+				else if (e)
+					e.toCBuffer(buf, hgs);
+				else if (s)
+				{
+					string p = s.ident ? s.ident.toChars() : s.toChars();
+					buf.writestring(p);
+				}
+				else if (!oarg)
+				{
+					buf.writestring("null");
+				}
+				else
+				{
+					assert(0);
+				}
+			}
+		}
+		buf.writebyte(')');
+		if (ident)
+		{
+			buf.writebyte(' ');
+			buf.writestring(ident.toChars());
+		}
+		buf.writebyte(';');
+		buf.writenl();
+	}
+
+	void toObjFile(int multiobj)			// compile to .obj file
+	{
+		//printf("TemplateMixin.toObjFile('%s')\n", toChars());
+		TemplateInstance.toObjFile(multiobj);
+	}
+
+	TemplateMixin isTemplateMixin() { return this; }
+}
--- a/dmd/Token.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Token.d	Mon Apr 12 17:00:08 2010 +0100
@@ -136,7 +136,7 @@
 version (CSTRINGS) {
 			p = string;
 } else {
-		{   OutBuffer buf;
+		{   OutBuffer buf = new OutBuffer();
 
 			buf.writeByte('"');
 			for (size_t i = 0; i < len; )
@@ -212,4 +212,4 @@
 
 		return p;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TraitsExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TraitsExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -8,32 +8,447 @@
 import dmd.Scope;
 import dmd.HdrGenState;
 import dmd.TOK;
+import dmd.TY;
+import dmd.STC;
+import dmd.WANT;
+import dmd.Id;
+import dmd.Global;
+import dmd.Lexer;
+import dmd.ArrayLiteralExp;
+import dmd.VarExp;
+import dmd.StringExp;
+import dmd.DotIdExp;
+import dmd.DotVarExp;
+import dmd.IntegerExp;
+import dmd.TupleExp;
+import dmd.Type;
+import dmd.Dsymbol;
+import dmd.DsymbolExp;
+import dmd.ScopeDsymbol;
+import dmd.FuncDeclaration;
+import dmd.ClassDeclaration;
+import dmd.TemplateDeclaration;
+import dmd.TemplateInstance;
+import dmd.TypeClass;
+import dmd.Util;
+import dmd.expression.Util;
 
-class TraitsExp : Expression
-{
-	Identifier ident;
-	Objects args;
-
-	this(Loc loc, Identifier ident, Objects args)
+import core.stdc.string : strcmp;
+
+/************************************************
+ * Delegate to be passed to overloadApply() that looks
+ * for virtual functions.
+ */
+
+struct Pvirtuals
+{
+	Expression e1;
+	Expressions exps;
+	int fpvirtuals(void* param, FuncDeclaration f)
+	{   Pvirtuals p = *cast(Pvirtuals*)param;
+
+		if (f.isVirtual())
+		{	Expression e;
+
+			if (p.e1.op == TOK.TOKdotvar)
+			{   DotVarExp dve = cast(DotVarExp)p.e1;
+				e = new DotVarExp(Loc(0), dve.e1, f);
+			}
+			else
+				e = new DsymbolExp(Loc(0), f);
+			p.exps.push(cast(void*)e);
+		}
+		return 0;
+	}
+}
+
+
+
+class TraitsExp : Expression
+{
+	Identifier ident;
+
+	Objects args;
+
+	this(Loc loc, Identifier ident, Objects args)
 	{
-		super(loc, TOKtraits, TraitsExp.sizeof);
+		super(loc, TOK.TOKtraits, this.sizeof);
 		this.ident = ident;
-		this.args = args;
-	}
-
-	Expression syntaxCopy()
-	{
-		assert(false);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
-	}
-}
-
+		this.args = args;
+	}
+
+	Expression syntaxCopy()
+	{
+		return new TraitsExp(loc, ident, TemplateInstance.arraySyntaxCopy(args));
+	}
+
+	Expression semantic(Scope sc)
+	{
+		version (LOGSEMANTIC) {
+			printf("TraitsExp.semantic() %s\n", toChars());
+		}
+		if (ident != Id.compiles && ident != Id.isSame)
+			TemplateInstance.semanticTiargs(loc, sc, args, 1);
+		size_t dim = args ? args.dim : 0;
+		Object o;
+		FuncDeclaration f;
+
+		string ISTYPE(string cond)
+		{
+			return `
+				for (size_t i = 0; i < dim; i++)
+				{   Type t = getType(cast(Object)args.data[i]);
+					if (!t)
+						goto Lfalse;
+					if (!(`~cond~`))
+						goto Lfalse;
+				}
+			if (!dim)
+				goto Lfalse;
+			goto Ltrue;
+			`;
+		}
+
+		string ISDSYMBOL(string cond)
+		{
+			return `for (size_t i = 0; i < dim; i++)
+			{   Dsymbol s = getDsymbol(cast(Object)args.data[i]);
+				if (!s)
+					goto Lfalse;
+				if (!(`~cond~`))
+					goto Lfalse;
+			}
+			if (!dim)
+				goto Lfalse;
+			goto Ltrue;`;
+		}
+
+		if (ident == Id.isArithmetic)
+		{
+			mixin(ISTYPE(`t.isintegral() || t.isfloating()`));
+		}
+		else if (ident == Id.isFloating)
+		{
+			mixin(ISTYPE(q{t.isfloating()}));
+		}
+		else if (ident == Id.isIntegral)
+		{
+			mixin(ISTYPE(q{t.isintegral()}));
+		}
+		else if (ident == Id.isScalar)
+		{
+			mixin(ISTYPE(q{t.isscalar()}));
+		}
+		else if (ident == Id.isUnsigned)
+		{
+			mixin(ISTYPE(q{t.isunsigned()}));
+		}
+		else if (ident == Id.isAssociativeArray)
+		{
+			mixin(ISTYPE(q{t.toBasetype().ty == TY.Taarray}));
+		}
+		else if (ident == Id.isStaticArray)
+		{
+			mixin(ISTYPE(q{t.toBasetype().ty == TY.Tsarray}));
+		}
+		else if (ident == Id.isAbstractClass)
+		{
+			mixin(ISTYPE(q{t.toBasetype().ty == TY.Tclass && (cast(TypeClass)t.toBasetype()).sym.isAbstract()}));
+		}
+		else if (ident == Id.isFinalClass)
+		{
+			mixin(ISTYPE(q{t.toBasetype().ty == TY.Tclass && (cast(TypeClass)t.toBasetype()).sym.storage_class & STC.STCfinal}));
+		}
+		else if (ident == Id.isAbstractFunction)
+		{
+			mixin(ISDSYMBOL(q{(f = s.isFuncDeclaration()) !is null && f.isAbstract()}));
+		}
+		else if (ident == Id.isVirtualFunction)
+		{
+			mixin(ISDSYMBOL(q{(f = s.isFuncDeclaration()) !is null && f.isVirtual()}));
+		}
+		else if (ident == Id.isFinalFunction)
+		{
+			mixin(ISDSYMBOL(q{(f = s.isFuncDeclaration()) !is null && f.isFinal()}));
+		}
+		else if (ident == Id.hasMember ||
+				ident == Id.getMember ||
+				ident == Id.getVirtualFunctions)
+		{
+			if (dim != 2)
+				goto Ldimerror;
+			Object o_ = cast(Object)args.data[0];
+			Expression e = isExpression(cast(Object)args.data[1]);
+			if (!e)
+			{   error("expression expected as second argument of __traits %s", ident.toChars());
+				goto Lfalse;
+			}
+			e = e.optimize(WANT.WANTvalue | WANT.WANTinterpret);
+			if (e.op != TOKstring)
+			{   error("string expected as second argument of __traits %s instead of %s", ident.toChars(), e.toChars());
+				goto Lfalse;
+			}
+			StringExp se = cast(StringExp)e;
+			se = se.toUTF8(sc);
+			if (se.sz != 1)
+			{   error("string must be chars");
+				goto Lfalse;
+			}
+			Identifier id = Lexer.idPool(fromStringz(cast(char*)se.string_));
+
+			Type t = isType(o_);
+			e = isExpression(o_);
+			Dsymbol s = isDsymbol(o_);
+			if (t)
+				e = typeDotIdExp(loc, t, id);
+			else if (e)
+				e = new DotIdExp(loc, e, id);
+			else if (s)
+			{   e = new DsymbolExp(loc, s);
+				e = new DotIdExp(loc, e, id);
+			}
+			else
+			{   error("invalid first argument");
+				goto Lfalse;
+			}
+
+			if (ident == Id.hasMember)
+			{   /* Take any errors as meaning it wasn't found
+			     */
+				e = e.trySemantic(sc);
+				if (!e)
+				{	if (global.gag)
+					global.errors++;
+					goto Lfalse;
+				}
+				else
+					goto Ltrue;
+			}
+			else if (ident == Id.getMember)
+			{
+				e = e.semantic(sc);
+				return e;
+			}
+			else if (ident == Id.getVirtualFunctions)
+			{
+				uint errors = global.errors;
+				Expression ex = e;
+				e = e.semantic(sc);
+				if (errors < global.errors)
+					error("%s cannot be resolved", ex.toChars());
+
+				/* Create tuple of virtual function overloads of e
+				 */
+				//e.dump(0);
+				Expressions exps = new Expressions();
+				FuncDeclaration f_;
+				if (e.op == TOKvar)
+				{	VarExp ve = cast(VarExp)e;
+					f_ = ve.var.isFuncDeclaration();
+				}
+				else if (e.op == TOKdotvar)
+				{	DotVarExp dve = cast(DotVarExp)e;
+					f_ = dve.var.isFuncDeclaration();
+				}
+				else
+					f_ = null;
+				Pvirtuals p;
+				p.exps = exps;
+				p.e1 = e;
+				overloadApply(f_, &p.fpvirtuals, &p);
+
+				TupleExp tup = new TupleExp(loc, exps);
+				return tup.semantic(sc);
+			}
+			else
+				assert(0);
+		}
+		else if (ident == Id.classInstanceSize)
+		{
+			if (dim != 1)
+				goto Ldimerror;
+			Object o_ = cast(Object)args.data[0];
+			Dsymbol s = getDsymbol(o_);
+			ClassDeclaration cd;
+			if (!s || (cd = s.isClassDeclaration()) is null)
+			{
+				error("first argument is not a class");
+				goto Lfalse;
+			}
+			return new IntegerExp(loc, cd.structsize, Type.tsize_t);
+		}
+		else if (ident == Id.allMembers || ident == Id.derivedMembers)
+		{
+			if (dim != 1)
+				goto Ldimerror;
+			Object o_ = cast(Object)args.data[0];
+			Dsymbol s = getDsymbol(o_);
+			ScopeDsymbol sd;
+			if (!s)
+			{
+				error("argument has no members");
+				goto Lfalse;
+			}
+			if ((sd = s.isScopeDsymbol()) is null)
+			{
+				error("%s %s has no members", s.kind(), s.toChars());
+				goto Lfalse;
+			}
+			Expressions exps = new Expressions;
+			while (1)
+			{   size_t dim_ = ScopeDsymbol.dim(sd.members);
+				for (size_t i = 0; i < dim_; i++)
+				{
+					Dsymbol sm = ScopeDsymbol.getNth(sd.members, i);
+					//printf("\t[%i] %s %s\n", i, sm.kind(), sm.toChars());
+					if (sm.ident)
+					{
+						//printf("\t%s\n", sm.ident.toChars());
+						auto str = sm.ident.toChars();
+
+						/* Skip if already present in exps[]
+						 */
+						for (size_t j = 0; j < exps.dim; j++)
+						{   StringExp se2 = cast(StringExp)exps.data[j];
+							if (strcmp(toStringz(str), cast(char*)se2.string_) == 0)
+								goto Lnext;
+						}
+
+						StringExp se = new StringExp(loc, str);
+						exps.push(cast(void*)se);
+					}
+Lnext:
+					;
+				}
+				ClassDeclaration cd = sd.isClassDeclaration();
+				if (cd && cd.baseClass && ident == Id.allMembers)
+					sd = cd.baseClass;	// do again with base class
+				else
+					break;
+			}
+			Expression e = new ArrayLiteralExp(loc, exps);
+			e = e.semantic(sc);
+			return e;
+		}
+		else if (ident == Id.compiles)
+		{
+			/* Determine if all the objects - types, expressions, or symbols -
+			 * compile without error
+			 */
+			if (!dim)
+				goto Lfalse;
+
+			for (size_t i = 0; i < dim; i++)
+			{   Object o_ = cast(Object)args.data[i];
+				Expression e;
+
+				uint errors = global.errors;
+				global.gag++;
+
+				Type t = isType(o_);
+				if (t)
+				{	Dsymbol s;
+					t.resolve(loc, sc, &e, &t, &s);
+					if (t)
+						t.semantic(loc, sc);
+					else if (e)
+						e.semantic(sc);
+				}
+				else
+				{	e = isExpression(o);
+					if (e)
+						e.semantic(sc);
+				}
+
+				global.gag--;
+				if (errors != global.errors)
+				{   if (global.gag == 0)
+					global.errors = errors;
+					goto Lfalse;
+				}
+			}
+			goto Ltrue;
+		}
+		else if (ident == Id.isSame)
+		{	/* Determine if two symbols are the same
+			 */
+			if (dim != 2)
+				goto Ldimerror;
+			TemplateInstance.semanticTiargs(loc, sc, args, 0);
+			Object o1 = cast(Object)args.data[0];
+			Object o2 = cast(Object)args.data[1];
+			Dsymbol s1 = getDsymbol(o1);
+			Dsymbol s2 = getDsymbol(o2);
+
+			static if (0) {
+				printf("o1: %p\n", o1);
+				printf("o2: %p\n", o2);
+				if (!s1)
+				{   Expression ea = isExpression(o1);
+					if (ea)
+						printf("%s\n", ea.toChars());
+					Type ta = isType(o1);
+					if (ta)
+						printf("%s\n", ta.toChars());
+					goto Lfalse;
+				}
+				else
+					printf("%s %s\n", s1.kind(), s1.toChars());
+			}
+			if (!s1 && !s2)
+			{   Expression ea1 = isExpression(o1);
+				Expression ea2 = isExpression(o2);
+				if (ea1 && ea2 && ea1.equals(ea2))
+					goto Ltrue;
+			}
+
+			if (!s1 || !s2)
+				goto Lfalse;
+
+			s1 = s1.toAlias();
+			s2 = s2.toAlias();
+
+			if (s1 == s2)
+				goto Ltrue;
+			else
+				goto Lfalse;
+		}
+		else
+		{	error("unrecognized trait %s", ident.toChars());
+			goto Lfalse;
+		}
+
+		return null;
+
+Lnottype:
+		error("%s is not a type", o/*.toChars()*/); // BUG: o is Object, no member toChars()
+		goto Lfalse;
+
+Ldimerror:
+		error("wrong number of arguments %d", dim);
+		goto Lfalse;
+
+
+Lfalse:
+		return new IntegerExp(loc, 0, Type.tbool);
+
+Ltrue:
+		return new IntegerExp(loc, 1, Type.tbool);
+	}
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	{
+		buf.writestring("__traits(");
+		buf.writestring(ident.toChars());
+		if (args)
+		{
+			for (int i = 0; i < args.dim; i++)
+			{
+				buf.writeByte(',');
+				Object oarg = cast(Object)args.data[i];
+				ObjectToCBuffer(buf, hgs, oarg);
+			}
+		}
+		buf.writeByte(')');
+	}
+}
--- a/dmd/Tuple.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Tuple.d	Mon Apr 12 17:00:08 2010 +0100
@@ -2,18 +2,17 @@
 
 import dmd.ArrayTypes;
 
-class Tuple
-{
-	Objects objects;
+class Tuple
+{
+	Objects objects;
 
 	this()
 	{
 		objects = new Objects();
 	}
-	
-	int dyncast()
-	{
-		assert(false);
-	}
-}
-
+
+	int dyncast()
+	{
+		assert(false);
+	}
+}
--- a/dmd/TupleDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TupleDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -1,21 +1,28 @@
 module dmd.TupleDeclaration;
 
 import dmd.Declaration;
+import dmd.Argument;
 import dmd.ArrayTypes;
 import dmd.TypeTuple;
 import dmd.Loc;
+import dmd.STC;
+import dmd.TOK;
 import dmd.Identifier;
 import dmd.Dsymbol;
 import dmd.Type;
+import dmd.DYNCAST;
+import dmd.OutBuffer;
+import dmd.Expression;
+import dmd.DsymbolExp;
 
 class TupleDeclaration : Declaration
 {
-    Objects objects;
-    int isexp;			// 1: expression tuple
+	Objects objects;
+	int isexp;			// 1: expression tuple
 
-    TypeTuple tupletype;	// !=NULL if this is a type tuple
+	TypeTuple tupletype;	// !=NULL if this is a type tuple
 
-    this(Loc loc, Identifier ident, Objects objects)
+	this(Loc loc, Identifier ident, Objects objects)
 	{
 		super(ident);
 		this.type = null;
@@ -24,25 +31,83 @@
 		this.tupletype = null;
 	}
 
-    Dsymbol syntaxCopy(Dsymbol)
-	{
-		assert(false);
-	}
-	
-    string kind()
+	Dsymbol syntaxCopy(Dsymbol)
 	{
 		assert(false);
 	}
 
-    Type getType()
+	string kind()
 	{
-		assert(false);
+		return "tuple";
 	}
-	
-    bool needThis()
+
+	Type getType()
 	{
-		assert(false);
+		/* If this tuple represents a type, return that type
+		 */
+
+		//printf("TupleDeclaration::getType() %s\n", toChars());
+		if (isexp)
+			return null;
+		if (!tupletype)
+		{
+			/* It's only a type tuple if all the Object's are types
+			 */
+			for (size_t i = 0; i < objects.dim; i++)
+			{   Dsymbol o = cast(Dsymbol)objects.data[i];
+
+				if (o.dyncast() != DYNCAST.DYNCAST_TYPE)
+				{
+					//printf("\tnot[%d], %p, %d\n", i, o, o->dyncast());
+					return null;
+				}
+			}
+
+			/* We know it's a type tuple, so build the TypeTuple
+			 */
+			Arguments args = new Arguments();
+			args.setDim(objects.dim);
+			OutBuffer buf = new OutBuffer();
+			for (size_t i = 0; i < objects.dim; i++)
+			{   Type t = cast(Type)objects.data[i];
+
+				//printf("type = %s\n", t->toChars());
+				static if (0) {
+					buf.printf("_%s_%d", ident.toChars(), i);
+					char *name = cast(char *)buf.extractData();
+					Identifier id = new Identifier(name, TOKidentifier);
+					Argument arg = new Argument(STCin, t, id, null);
+				} else {
+					Argument arg = new Argument(STCundefined, t, null, null);
+				}
+				args.data[i] = cast(void *)arg;
+			}
+
+			tupletype = new TypeTuple(args);
+		}
+
+		return tupletype;
 	}
-	
-    TupleDeclaration isTupleDeclaration() { return this; }
-};
\ No newline at end of file
+
+	bool needThis()
+	{
+		//printf("TupleDeclaration::needThis(%s)\n", toChars());
+		for (size_t i = 0; i < objects.dim; i++)
+		{   Dsymbol o = cast(Dsymbol)objects.data[i];
+			if (o.dyncast() == DYNCAST.DYNCAST_EXPRESSION)
+			{   Expression e = cast(Expression)o;
+				if (e.op == TOKdsymbol)
+				{	DsymbolExp ve = cast(DsymbolExp)e;
+					Declaration d = ve.s.isDeclaration();
+					if (d && d.needThis())
+					{
+						return 1;
+					}
+				}
+			}
+		}
+		return 0;
+	}
+
+	TupleDeclaration isTupleDeclaration() { return this; }
+}
--- a/dmd/TupleExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TupleExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -14,97 +14,236 @@
 import dmd.HdrGenState;
 import dmd.InlineScanState;
 import dmd.ArrayTypes;
+import dmd.TypeExp;
+import dmd.TypeTuple;
 import dmd.TOK;
+import dmd.TY;
+import dmd.Dsymbol;
+import dmd.DsymbolExp;
+import dmd.DYNCAST;
+import dmd.expression.Util;
+
+/****************************************
+ * Expand tuples.
+ */
+/+
+void expandTuples(Expressions exps)
+{
+    //printf("expandTuples()\n");
+    if (exps)
+    {
+	for (size_t i = 0; i < exps.dim; i++)
+	{   Expression arg = cast(Expression)exps.data[i];
+	    if (!arg)
+		continue;
+
+	    // Look for tuple with 0 members
+	    if (arg.op == TOKtype)
+	    {	TypeExp e = cast(TypeExp)arg;
+		if (e.type.toBasetype().ty == Ttuple)
+		{   TypeTuple tt = cast(TypeTuple)e.type.toBasetype();
+
+		    if (!tt.arguments || tt.arguments.dim == 0)
+		    {
+			exps.remove(i);
+			if (i == exps.dim)
+			    return;
+			i--;
+			continue;
+		    }
+		}
+	    }
+
+	    // Inline expand all the tuples
+	    while (arg.op == TOKtuple)
+	    {	TupleExp te = cast(TupleExp)arg;
+
+		exps.remove(i);		// remove arg
+		exps.insert(i, te.exps);	// replace with tuple contents
+		if (i == exps.dim)
+		    return;		// empty tuple, no more arguments
+		arg = cast(Expression)exps.data[i];
+	    }
+	}
+    }
+}
++/
+class TupleExp : Expression
+{
+	Expressions exps;
+
+	this(Loc loc, Expressions exps)
+	{
+		super(Loc(0), TOK.init, this.sizeof);
+		this.exps = exps;
+		this.type = null;
+	}
+
+	this(Loc loc, TupleDeclaration tup)
+	{
+		super(Loc(0), TOK.init, this.sizeof);
+		exps = new Expressions();
+		type = null;
 
-class TupleExp : Expression
-{
-	Expressions exps;
-
-	this(Loc loc, Expressions exps)
-	{
-		assert(false);
-		super(Loc(0), TOK.init, 0);
-	}
-
-	this(Loc loc, TupleDeclaration tup)
-	{
+		exps.reserve(tup.objects.dim);
+		for (size_t i = 0; i < tup.objects.dim; i++)
+		{   Dsymbol o = cast(Dsymbol)tup.objects.data[i];
+			if (o.dyncast() == DYNCAST.DYNCAST_EXPRESSION)
+			{
+				Expression e = cast(Expression)o;
+				e = e.syntaxCopy();
+				exps.push(cast(void*)e);
+			}
+			else if (o.dyncast() == DYNCAST.DYNCAST_DSYMBOL)
+			{
+				Dsymbol s = cast(Dsymbol)o;
+				Expression e = new DsymbolExp(loc, s);
+				exps.push(cast(void*)e);
+			}
+			else if (o.dyncast() == DYNCAST.DYNCAST_TYPE)
+			{
+				Type t = cast(Type)o;
+				Expression e = new TypeExp(loc, t);
+				exps.push(cast(void*)e);
+			}
+			else
+			{
+				error("%s is not an expression", o.toChars());
+			}
+		}
+	}
+
+	Expression syntaxCopy()
+	{
+		return new TupleExp(loc, arraySyntaxCopy(exps));
+	}
+
+	int equals(Object o)
+	{
+		TupleExp ne;
+
+		if (this == o)
+			return 1;
+		if ((cast(Expression)o).op == TOKtuple)
+		{
+			TupleExp te = cast(TupleExp)o;
+			if (exps.dim != te.exps.dim)
+				return 0;
+			for (size_t i = 0; i < exps.dim; i++)
+			{   Expression e1 = cast(Expression)exps.data[i];
+				Expression e2 = cast(Expression)te.exps.data[i];
+
+				if (!e1.equals(e2))
+					return 0;
+			}
+			return 1;
+		}
+		return 0;
+	}
+
+	Expression semantic(Scope sc)
+	{
+		version (LOGSEMANTIC) {
+			printf("+TupleExp::semantic(%s)\n", toChars());
+		}
+		if (type)
+			return this;
+
+		// Run semantic() on each argument
+		for (size_t i = 0; i < exps.dim; i++)
+		{	Expression e = cast(Expression)exps.data[i];
+
+			e = e.semantic(sc);
+			if (!e.type)
+			{   error("%s has no value", e.toChars());
+				e.type = Type.terror;
+			}
+			exps.data[i] = cast(void *)e;
+		}
+
+		expandTuples(exps);
+		if (0 && exps.dim == 1)
+		{
+			return cast(Expression)exps.data[0];
+		}
+		type = new TypeTuple(exps);
+		type = type.semantic(loc, sc);
+		//printf("-TupleExp::semantic(%s)\n", toChars());
+		return this;
+	}
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	{
+		buf.writestring("tuple(");
+		argsToCBuffer(buf, exps, hgs);
+		buf.writeByte(')');
+	}
+
+	void scanForNestedRef(Scope sc)
+	{
 		assert(false);
-		super(Loc(0), TOK.init, 0);
-	}
-
-	Expression syntaxCopy()
-	{
-		assert(false);
-	}
-
-	int equals(Object o)
-	{
-		assert(false);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
-	}
-
-	void scanForNestedRef(Scope sc)
-	{
-		assert(false);
-	}
-
-	void checkEscape()
-	{
-		assert(false);
-	}
-
-	bool checkSideEffect(int flag)
-	{
-		assert(false);
-	}
-
-	Expression optimize(int result)
-	{
-		assert(false);
-	}
-
-	Expression interpret(InterState* istate)
-	{
-		assert(false);
-	}
-
-	Expression castTo(Scope sc, Type t)
-	{
-		assert(false);
-	}
-
-	elem* toElem(IRState* irs)
-	{
-		assert(false);
-	}
-
-	bool canThrow()
-	{
-		assert(false);
-	}
-
-	int inlineCost(InlineCostState* ics)
-	{
-		assert(false);
-	}
-
-	Expression doInline(InlineDoState ids)
-	{
-		assert(false);
-	}
-
-	Expression inlineScan(InlineScanState* iss)
-	{
-		assert(false);
-	}
-}
-
+	}
+
+	void checkEscape()
+	{
+		for (size_t i = 0; i < exps.dim; i++)
+		{   Expression e = cast(Expression)exps.data[i];
+			e.checkEscape();
+		}
+	}
+
+	bool checkSideEffect(int flag)
+	{
+		bool f = false;
+
+		for (int i = 0; i < exps.dim; i++)
+		{	Expression e = cast(Expression)exps.data[i];
+
+			f |= e.checkSideEffect(2);
+		}
+		if (flag == 0 && f == 0)
+			Expression.checkSideEffect(0);
+		return f;
+	}
+
+	Expression optimize(int result)
+	{
+		assert(false);
+	}
+
+	Expression interpret(InterState* istate)
+	{
+		assert(false);
+	}
+
+	Expression castTo(Scope sc, Type t)
+	{
+		assert(false);
+	}
+
+	elem* toElem(IRState* irs)
+	{
+		assert(false);
+	}
+
+	bool canThrow()
+	{
+		return arrayExpressionCanThrow(exps);
+	}
+
+	int inlineCost(InlineCostState* ics)
+	{
+		assert(false);
+	}
+
+	Expression doInline(InlineDoState ids)
+	{
+		assert(false);
+	}
+
+	Expression inlineScan(InlineScanState* iss)
+	{
+		assert(false);
+	}
+}
+
--- a/dmd/Type.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Type.d	Mon Apr 12 17:00:08 2010 +0100
@@ -82,7 +82,7 @@
 	int REALSIZE = 16;
 	int REALPAD = 6;
 	int REALALIGNSIZE = 16;
-} else version (XXX) { /// TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+} else version (POSIX) { /// TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
 	int REALSIZE = 12;
 	int REALPAD = 2;
 	int REALALIGNSIZE = 4;
@@ -1837,6 +1837,9 @@
 			toDecoBuffer(buf);
 
 		len = buf.offset;
+		version (Bug4054)
+		name = cast(char*)GC.malloc(19 + len.sizeof * 3 + len + 1);
+		else
 		name = cast(char*)alloca(19 + len.sizeof * 3 + len + 1);
 		buf.writeByte(0);
 	version (TARGET_OSX) {
@@ -2444,4 +2447,4 @@
 	{
 		return tsize_t;			// matches hash_t alias
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeAArray.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeAArray.d	Mon Apr 12 17:00:08 2010 +0100
@@ -35,7 +35,8 @@
 
 import core.stdc.stdio;
 import core.stdc.stdlib;
-
+version (Bug4054)
+	import core.memory;
 class TypeAArray : TypeArray
 {
     Type index;		// key type
@@ -311,6 +312,9 @@
 
 		sz = next.size();		// it's just data, so we only care about the size
 		sz = (sz + 3) & ~3;		// reduce proliferation of library routines
+		version (Bug4054)
+		id = cast(char*)GC.malloc(3 + strlen(func) + buf.offset + sizeof(sz) * 3 + 1);
+		else
 		id = cast(char*)alloca(3 + strlen(func) + buf.offset + sizeof(sz) * 3 + 1);
 		buf.writeByte(0);
 		if (flags & 1)
@@ -318,6 +322,9 @@
 		else
 			sprintf(id, "_aa%s%s", func, buf.data);
 	} else {
+		version (Bug4054)
+		id = cast(char*)GC.malloc(3 + strlen(func) + 1);
+		else
 		id = cast(char*)alloca(3 + strlen(func) + 1);
 		sprintf(id, "_aa%s", func);
 	}
@@ -357,4 +364,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeBasic.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeBasic.d	Mon Apr 12 17:00:08 2010 +0100
@@ -211,7 +211,7 @@
 			sz = REALALIGNSIZE;
 			break;
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 		case TY.Tint64:
 		case TY.Tuns64:
 		case TY.Tfloat64:
@@ -776,4 +776,4 @@
 	{
 		return this;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeDArray.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeDArray.d	Mon Apr 12 17:00:08 2010 +0100
@@ -35,6 +35,7 @@
 
 import core.stdc.stdlib;
 import core.stdc.stdio;
+version (Bug4054) import core.memory;
 
 // Dynamic array, no dimension
 class TypeDArray : TypeArray
@@ -300,6 +301,9 @@
 			char *id;
 
 			assert(next.deco);
+			version (Bug4054)
+			id = cast(char*) GC.malloc(7 + next.deco.length + 1);
+			else
 			id = cast(char*) alloca(7 + next.deco.length + 1);
 			sprintf(id, "_Array_%.*s", next.deco);
 			s = symbol_calloc(id);
@@ -337,4 +341,4 @@
 		ctype = t;
 		return t;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -46,7 +46,7 @@
 
 	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		type.toCBuffer(buf, null, hgs);
 	}
 
 	Expression optimize(int result)
--- a/dmd/TypeFunction.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeFunction.d	Mon Apr 12 17:00:08 2010 +0100
@@ -707,7 +707,7 @@
 
 		case LINK.LINKc:
 			tyf = TYM.TYnfunc;
-	version (XXX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+	version (POSIX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 			if (retStyle() == RET.RETstack)
 				tyf = TYM.TYhfunc;
 	}
@@ -731,4 +731,4 @@
 	}
 		return tyf;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeInfoDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeInfoDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -3,6 +3,7 @@
 import dmd.VarDeclaration;
 import dmd.Type;
 import dmd.Dsymbol;
+import dmd.Module;
 import dmd.Scope;
 import dmd.Loc;
 import dmd.STC;
@@ -96,7 +97,7 @@
 			s.Sdt.dt = DT.DT_common;
 		}
 
-version (XXX) { ///ELFOBJ || MACHOBJ // Burton
+version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton
 		if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null)
 			s.Sseg = Segment.UDATA;
 		else
@@ -111,4 +112,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeInstance.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeInstance.d	Mon Apr 12 17:00:08 2010 +0100
@@ -1,7 +1,14 @@
 module dmd.TypeInstance;
 
 import dmd.TypeQualified;
+import dmd.TemplateAliasParameter;
+import dmd.TemplateDeclaration;
 import dmd.TemplateInstance;
+import dmd.TemplateParameter;
+import dmd.TemplateValueParameter;
+import dmd.TemplateTupleParameter;
+import dmd.Tuple;
+import dmd.VarExp;
 import dmd.MOD;
 import dmd.MATCH;
 import dmd.Loc;
@@ -13,43 +20,56 @@
 import dmd.Expression;
 import dmd.Scope;
 import dmd.ArrayTypes;
+import dmd.TOK;
 import dmd.TY;
+import dmd.Util : printf;
 
 /* Similar to TypeIdentifier, but with a TemplateInstance as the root
  */
 class TypeInstance : TypeQualified
 {
-    TemplateInstance tempinst;
+	TemplateInstance tempinst;
 
-    this(Loc loc, TemplateInstance tempinst)
+	this(Loc loc, TemplateInstance tempinst)
 	{
 		super(Tinstance, loc);
 		this.tempinst = tempinst;
 	}
-	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
+
+	version (DumbClone) {
+	} else {
+		Type clone()
+		{
+			assert(false);
+		}
 	}
-}
-	
-    Type syntaxCopy()
+
+	Type syntaxCopy()
 	{
-		assert(false);
+		//printf("TypeInstance::syntaxCopy() %s, %d\n", toChars(), idents.dim);
+		TypeInstance t;
+
+		t = new TypeInstance(loc, cast(TemplateInstance)tempinst.syntaxCopy(null));
+		t.syntaxCopyHelper(this);
+		t.mod = mod;
+		return t;
 	}
-	
-    //char *toChars();
-	
-    //void toDecoBuffer(OutBuffer *buf, int flag);
-	
-    void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
+
+	//char *toChars();
+
+	//void toDecoBuffer(OutBuffer *buf, int flag);
+
+	void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
 	{
-		assert(false);
+		if (mod != this.mod)
+		{	toCBuffer3(buf, hgs, mod);
+			return;
+		}
+		tempinst.toCBuffer(buf, hgs);
+		toCBuffer2Helper(buf, hgs);
 	}
-	
-    void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps)
+
+	void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps)
 	{
 		// Note close similarity to TypeIdentifier::resolve()
 		Dsymbol s;
@@ -58,13 +78,13 @@
 		*pt = null;
 		*ps = null;
 
-	static if (false) {
-		if (!idents.dim)
-		{
-			error(loc, "template instance '%s' has no identifier", toChars());
-			return;
+		static if (false) {
+			if (!idents.dim)
+			{
+				error(loc, "template instance '%s' has no identifier", toChars());
+				return;
+			}
 		}
-	}
 		//id = (Identifier *)idents.data[0];
 		//printf("TypeInstance::resolve(sc = %p, idents = '%s')\n", sc, id->toChars());
 		s = tempinst;
@@ -75,13 +95,42 @@
 			*pt = (*pt).addMod(mod);
 		//printf("pt = '%s'\n", (*pt)->toChars());
 	}
-	
-    Type semantic(Loc loc, Scope sc)
+
+	Type semantic(Loc loc, Scope sc)
 	{
-		assert(false);
+		Type t;
+		Expression e;
+		Dsymbol s;
+
+		//printf("TypeInstance::semantic(%s)\n", toChars());
+
+		if (sc.parameterSpecialization)
+		{
+			uint errors = global.errors;
+			global.gag++;
+
+			resolve(loc, sc, &e, &t, &s);
+
+			global.gag--;
+			if (errors != global.errors)
+			{   if (global.gag == 0)
+				global.errors = errors;
+				return this;
+			}
+		}
+		else
+			resolve(loc, sc, &e, &t, &s);
+
+		if (!t)
+		{
+			debug printf("2: ");
+			error(loc, "%s is used as a type", toChars());
+			t = tvoid;
+		}
+		return t;
 	}
-	
-    Dsymbol toDsymbol(Scope sc)
+
+	Dsymbol toDsymbol(Scope sc)
 	{
 		Type t;
 		Expression e;
@@ -110,9 +159,225 @@
 
 		return s;
 	}
-	
-    MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
+
+	MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
 	{
-		assert(false);
+static if (0) {
+		printf("TypeInstance::deduceType()\n");
+		printf("\tthis   = %d, ", ty); print();
+		printf("\ttparam = %d, ", tparam.ty); tparam.print();
+}
+
+		// Extra check
+		if (tparam && tparam.ty == Tinstance)
+		{
+			TypeInstance tp = cast(TypeInstance)tparam;
+
+			//printf("tempinst->tempdecl = %p\n", tempinst->tempdecl);
+			//printf("tp->tempinst->tempdecl = %p\n", tp->tempinst->tempdecl);
+			if (!tp.tempinst.tempdecl)
+			{   //printf("tp->tempinst->name = '%s'\n", tp->tempinst->name->toChars());
+				if (!tp.tempinst.name.equals(tempinst.name))
+				{
+					/* Handle case of:
+					 *  template Foo(T : sa!(T), alias sa)
+					 */
+					int i = templateIdentifierLookup(tp.tempinst.name, parameters);
+					if (i == -1)
+					{   /* Didn't find it as a parameter identifier. Try looking
+					     * it up and seeing if is an alias. See Bugzilla 1454
+					     */
+						Dsymbol s = tempinst.tempdecl.scope_.search(Loc(0), tp.tempinst.name, null);
+						if (s)
+						{
+							s = s.toAlias();
+							TemplateDeclaration td = s.isTemplateDeclaration();
+							if (td && td == tempinst.tempdecl)
+								goto L2;
+						}
+						goto Lnomatch;
+					}
+					TemplateParameter tpx = cast(TemplateParameter)parameters.data[i];
+					// This logic duplicates tpx->matchArg()
+					TemplateAliasParameter ta = tpx.isTemplateAliasParameter();
+					if (!ta)
+						goto Lnomatch;
+					Object sa = tempinst.tempdecl;
+					if (!sa)
+						goto Lnomatch;
+					if (ta.specAlias && sa != ta.specAlias)
+						goto Lnomatch;
+					if (dedtypes.data[i])
+					{   // Must match already deduced symbol
+						Object s = cast(Object)dedtypes.data[i];
+
+						if (s != sa)
+							goto Lnomatch;
+					}
+					dedtypes.data[i] = cast(void*)sa;
+				}
+			}
+			else if (tempinst.tempdecl != tp.tempinst.tempdecl)
+				goto Lnomatch;
+
+L2:
+
+			for (int i = 0; 1; i++)
+			{
+				//printf("\ttest: tempinst->tiargs[%d]\n", i);
+				Object o1;
+				if (i < tempinst.tiargs.dim)
+					o1 = cast(Object)tempinst.tiargs.data[i];
+				else if (i < tempinst.tdtypes.dim && i < tp.tempinst.tiargs.dim)
+					// Pick up default arg
+					o1 = cast(Object)tempinst.tdtypes.data[i];
+				else
+					break;
+
+				if (i >= tp.tempinst.tiargs.dim)
+					goto Lnomatch;
+
+				Object o2 = cast(Object)tp.tempinst.tiargs.data[i];
+
+				Type t1 = isType(o1);
+				Type t2 = isType(o2);
+
+				Expression e1 = isExpression(o1);
+				Expression e2 = isExpression(o2);
+
+				Dsymbol s1 = isDsymbol(o1);
+				Dsymbol s2 = isDsymbol(o2);
+
+				Tuple v1 = isTuple(o1);
+				Tuple v2 = isTuple(o2);
+static if (0) {
+				if (t1)	printf("t1 = %s\n", t1.toChars());
+				if (t2)	printf("t2 = %s\n", t2.toChars());
+				if (e1)	printf("e1 = %s\n", e1.toChars());
+				if (e2)	printf("e2 = %s\n", e2.toChars());
+				if (s1)	printf("s1 = %s\n", s1.toChars());
+				if (s2)	printf("s2 = %s\n", s2.toChars());
+				if (v1)	printf("v1 = %s\n", v1.toChars());
+				if (v2)	printf("v2 = %s\n", v2.toChars());
+}
+
+				TemplateTupleParameter ttp;
+				int j;
+				if (t2 &&
+						t2.ty == Tident &&
+						i == tp.tempinst.tiargs.dim - 1 &&
+						i == tempinst.tempdecl.parameters.dim - 1 &&
+						(ttp = tempinst.tempdecl.isVariadic()) !is null)
+				{
+					/* Given:
+					 *  struct A(B...) {}
+					 *  alias A!(int, float) X;
+					 *  static if (!is(X Y == A!(Z), Z))
+					 * deduce that Z is a tuple(int, float)
+					 */
+
+					j = templateParameterLookup(t2, parameters);
+					if (j == -1)
+						goto Lnomatch;
+
+					/* Create tuple from remaining args
+					 */
+					Tuple vt = new Tuple();
+					int vtdim = tempinst.tiargs.dim - i;
+					vt.objects.setDim(vtdim);
+					for (size_t k = 0; k < vtdim; k++)
+						vt.objects.data[k] = cast(void *)tempinst.tiargs.data[i + k];
+
+					Tuple v = cast(Tuple)dedtypes.data[j];
+					if (v)
+					{
+						if (!match(v, vt, tempinst.tempdecl, sc))
+							goto Lnomatch;
+					}
+					else
+						dedtypes.data[j] = cast(void*)vt;
+					break; //return MATCHexact;
+				}
+
+				if (t1 && t2)
+				{
+					if (!t1.deduceType(sc, t2, parameters, dedtypes))
+						goto Lnomatch;
+				}
+				else if (e1 && e2)
+				{
+					if (!e1.equals(e2))
+					{   if (e2.op == TOKvar)
+						{
+							/*
+							 * (T:Number!(e2), int e2)
+							 */
+							j = templateIdentifierLookup((cast(VarExp)e2).var.ident, parameters);
+							goto L1;
+						}
+						goto Lnomatch;
+					}
+				}
+				else if (e1 && t2 && t2.ty == Tident)
+				{
+					j = templateParameterLookup(t2, parameters);
+L1:
+					if (j == -1)
+						goto Lnomatch;
+					TemplateParameter tp_ = cast(TemplateParameter)parameters.data[j];
+					// BUG: use tp->matchArg() instead of the following
+					TemplateValueParameter tv = tp_.isTemplateValueParameter();
+					if (!tv)
+						goto Lnomatch;
+					Expression e = cast(Expression)dedtypes.data[j];
+					if (e)
+					{
+						if (!e1.equals(e))
+							goto Lnomatch;
+					}
+					else
+					{   Type vt = tv.valType.semantic(Loc(0), sc);
+						MATCH m = cast(MATCH)e1.implicitConvTo(vt);
+						if (!m)
+							goto Lnomatch;
+						dedtypes.data[j] = cast(void*)e1;
+					}
+				}
+				else if (s1 && t2 && t2.ty == Tident)
+				{
+					j = templateParameterLookup(t2, parameters);
+					if (j == -1)
+						goto Lnomatch;
+					TemplateParameter tp_ = cast(TemplateParameter)parameters.data[j];
+					// BUG: use tp->matchArg() instead of the following
+					TemplateAliasParameter ta = tp_.isTemplateAliasParameter();
+					if (!ta)
+						goto Lnomatch;
+					Dsymbol s = cast(Dsymbol)dedtypes.data[j];
+					if (s)
+					{
+						if (!s1.equals(s))
+							goto Lnomatch;
+					}
+					else
+					{
+						dedtypes.data[j] = cast(void*)s1;
+					}
+				}
+				else if (s1 && s2)
+				{
+					if (!s1.equals(s2))
+						goto Lnomatch;
+				}
+				// BUG: Need to handle tuple parameters
+				else
+					goto Lnomatch;
+			}
+		}
+		return Type.deduceType(sc, tparam, parameters, dedtypes);
+
+Lnomatch:
+		//printf("no match\n");
+		return MATCHnomatch;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeTuple.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypeTuple.d	Mon Apr 12 17:00:08 2010 +0100
@@ -11,68 +11,165 @@
 import dmd.HdrGenState;
 import dmd.Scope;
 import dmd.TY;
+import dmd.Id;
+import dmd.STC;
+import dmd.Argument;
+import dmd.ErrorExp;
+import dmd.IntegerExp;
 
 class TypeTuple : Type
 {
-    Arguments arguments;	// types making up the tuple
+	Arguments arguments;	// types making up the tuple
+
+	this(Arguments arguments)
+	{
+		super(TY.Ttuple);
+		//printf("TypeTuple(this = %p)\n", this);
+		this.arguments = arguments;
+		//printf("TypeTuple() %s\n", toChars());
+		debug {
+			if (arguments)
+			{
+				for (size_t i = 0; i < arguments.dim; i++)
+				{
+					Argument arg = cast(Argument)arguments.data[i];
+					assert(arg && arg.type);
+				}
+			}
+		}
+	}
+
+	version (DumbClone) {
+	} else {
+		Type clone()
+		{
+			assert(false);
+		}
+	}
 
-    this(Arguments arguments)
+	/****************
+	 * Form TypeTuple from the types of the expressions.
+	 * Assume exps[] is already tuple expanded.
+	 */
+	this(Expressions exps)
+	{
+		super(TY.Ttuple);
+		Arguments arguments = new Arguments;
+		if (exps)
+		{
+			arguments.setDim(exps.dim);
+			for (size_t i = 0; i < exps.dim; i++)
+			{   Expression e = cast(Expression)exps.data[i];
+				if (e.type.ty == Ttuple)
+					e.error("cannot form tuple of tuples");
+				Argument arg = new Argument(STCundefined, e.type, null, null);
+				arguments.data[i] = cast(void *)arg;
+			}
+		}
+		this.arguments = arguments;
+	}
+
+	Type syntaxCopy()
+	{
+		Arguments args = Argument.arraySyntaxCopy(arguments);
+		Type t = new TypeTuple(args);
+		t.mod = mod;
+		return t;
+	}
+
+	Type semantic(Loc loc, Scope sc)
+	{
+		//printf("TypeTuple::semantic(this = %p)\n", this);
+		//printf("TypeTuple::semantic() %s\n", toChars());
+		if (!deco)
+			deco = merge().deco;
+
+		/* Don't return merge(), because a tuple with one type has the
+		 * same deco as that type.
+		 */
+		return this;
+	}
+
+	int equals(Object o)
 	{
-		assert(false);
-		super(TY.init);
+		Type t;
+
+		t = cast(Type)o;
+		//printf("TypeTuple::equals(%s, %s)\n", toChars(), t-cast>toChars());
+		if (this == t)
+		{
+			return 1;
+		}
+		if (t.ty == Ttuple)
+		{	TypeTuple tt = cast(TypeTuple)t;
+
+			if (arguments.dim == tt.arguments.dim)
+			{
+				for (size_t i = 0; i < tt.arguments.dim; i++)
+				{   Argument arg1 = cast(Argument)arguments.data[i];
+					Argument arg2 = cast(Argument)tt.arguments.data[i];
+
+					if (!arg1.type.equals(arg2.type))
+						return 0;
+				}
+				return 1;
+			}
+		}
+		return 0;
 	}
-	
-version (DumbClone) {
-} else {
-	Type clone()
+
+	Type reliesOnTident()
+	{
+		if (arguments)
+		{
+			for (size_t i = 0; i < arguments.dim; i++)
+			{
+				Argument arg = cast(Argument)arguments.data[i];
+				Type t = arg.type.reliesOnTident();
+				if (t)
+					return t;
+			}
+		}
+		return null;
+	}
+
+	void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
+	{
+		Argument.argsToCBuffer(buf, hgs, arguments, 0);
+	}
+
+	void toDecoBuffer(OutBuffer buf, int flag)
+	{
+		//printf("TypeTuple::toDecoBuffer() this = %p, %s\n", this, toChars());
+		Type.toDecoBuffer(buf, flag);
+		OutBuffer buf2 = new OutBuffer();
+		Argument.argsToDecoBuffer(buf2, arguments);
+		uint len = buf2.offset;
+		//buf.printf("%d%.*s", len, len, cast(char *)buf2.extractData());
+		buf.printf("%d%s", len, buf2.extractString());
+	}
+
+	Expression getProperty(Loc loc, Identifier ident)
+	{
+		Expression e;
+
+		version (LOGDOTEXP) {
+			printf("TypeTuple::getProperty(type = '%s', ident = '%s')\n", toChars(), ident.toChars());
+		}
+		if (ident == Id.length)
+		{
+			e = new IntegerExp(loc, arguments.dim, Type.tsize_t);
+		}
+		else
+		{
+			error(loc, "no property '%s' for tuple '%s'", ident.toChars(), toChars());
+			e = new ErrorExp();
+		}
+		return e;
+	}
+
+	TypeInfoDeclaration getTypeInfoDeclaration()
 	{
 		assert(false);
 	}
 }
-	
-    this(Expressions exps)
-	{
-		assert(false);
-		super(TY.init);
-	}
-	
-    Type syntaxCopy()
-	{
-		assert(false);
-	}
-	
-    Type semantic(Loc loc, Scope sc)
-	{
-		assert(false);
-	}
-	
-    int equals(Object *o)
-	{
-		assert(false);
-	}
-	
-    Type reliesOnTident()
-	{
-		assert(false);
-	}
-	
-    void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
-	{
-		assert(false);
-	}
-	
-    void toDecoBuffer(OutBuffer buf, int flag)
-	{
-		assert(false);
-	}
-	
-    Expression getProperty(Loc loc, Identifier ident)
-	{
-		assert(false);
-	}
-	
-    TypeInfoDeclaration getTypeInfoDeclaration()
-	{
-		assert(false);
-	}
-}
\ No newline at end of file
--- a/dmd/TypedefDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/TypedefDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -6,6 +6,7 @@
 import dmd.Loc;
 import dmd.Identifier;
 import dmd.Dsymbol;
+import dmd.Module;
 import dmd.Scope;
 import dmd.OutBuffer;
 import dmd.ExpInitializer;
@@ -176,4 +177,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/UAddExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/UAddExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -7,21 +7,33 @@
 import dmd.Scope;
 import dmd.TOK;
 
-class UAddExp : UnaExp
-{
-	this(Loc loc, Expression e)
-	{
-		super(loc, TOKuadd, UAddExp.sizeof, e);
-	}
-
-	Expression semantic(Scope sc)
-	{
-		assert(false);
-	}
-
-	Identifier opId()
-	{
-		assert(false);
-	}
-}
-
+class UAddExp : UnaExp
+{
+	this(Loc loc, Expression e)
+	{
+		super(loc, TOK.TOKuadd, this.sizeof, e);
+	}
+
+	Expression semantic(Scope sc)
+	{
+		Expression e;
+
+		version (LOGSEMANTIC) {
+			printf("UAddExp.semantic('%s')\n", toChars());
+		}
+		assert(!type);
+		UnaExp.semantic(sc);
+		e1 = resolveProperties(sc, e1);
+		e = op_overload(sc);
+		if (e)
+			return e;
+		e1.checkNoBool();
+		e1.checkArithmetic();
+		return e1;
+	}
+
+	Identifier opId()
+	{
+		assert(false);
+	}
+}
--- a/dmd/UnionDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/UnionDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -7,20 +7,27 @@
 
 class UnionDeclaration : StructDeclaration
 {
-    this(Loc loc, Identifier id)
+	this(Loc loc, Identifier id)
 	{
 		super(loc, id);
 	}
-	
-    Dsymbol syntaxCopy(Dsymbol s)
+
+	Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
-	}
-	
-    string kind()
-	{
-		assert(false);
+		UnionDeclaration ud;
+
+		if (s)
+			ud = cast(UnionDeclaration)s;
+		else
+			ud = new UnionDeclaration(loc, ident);
+		StructDeclaration.syntaxCopy(ud);
+		return ud;
 	}
 
-    UnionDeclaration isUnionDeclaration() { return this; }
-}
\ No newline at end of file
+	string kind()
+	{
+		return "union";
+	}
+
+	UnionDeclaration isUnionDeclaration() { return this; }
+}
--- a/dmd/Utf.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Utf.d	Mon Apr 12 17:00:08 2010 +0100
@@ -17,7 +17,13 @@
 
 string utf_decodeWchar(const(wchar)[] s, size_t* pidx, dchar* presult)
 {
-	assert(false);
+	try {
+		*presult = decode(s, *pidx);
+	} catch (Exception e) {
+		return e.toString();
+	}
+
+	return null;
 }
 
 bool utf_isValidDchar(uint c)
@@ -25,4 +31,4 @@
 	return isValidDchar(c);
 }
 
-extern (C++) extern int HtmlNamedEntity(ubyte* p, int length);
\ No newline at end of file
+extern (C++) extern int HtmlNamedEntity(ubyte* p, int length);
--- a/dmd/Util.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/Util.d	Mon Apr 12 17:00:08 2010 +0100
@@ -13,19 +13,47 @@
 import std.process : getenv;
 import std.c.string;
 import std.stdio : writef, writefln, write;
-import std.c.process : spawnl, spawnlp;
+version (Windows)
+{
+    import std.c.process : spawnl, spawnlp;
+}
+version (POSIX)
+{
+    import core.sys.posix.unistd;
+}
 import core.stdc.stdlib;
 import core.stdc.ctype;
 import core.stdc.stdarg;
-import core.stdc.stdio;
+public import core.stdc.stdio;
+version (Bug4054) import core.memory;
 
 extern(C) int putenv(char*);
-
+/+version (LOG) 
+{
+	static if( !is(typeof(printf)) )
+		extern (C) int printf(const char*,...);
+}+/
 //version = LOG;
 
-version (Windows) {
-} else {
-	import core.sys.posix.stdlib : putenv;
+version (TARGET_OSX)
+{
+	version = TARGET_FOS; // FreeBSD, OS X, Solaris
+}
+version (TARGET_FREEBSD)
+{
+	version = TARGET_FOS; // FreeBSD, OS X, Solaris
+}
+version (TARGET_SOLARIS)
+{
+	version = TARGET_FOS; // FreeBSD, OS X, Solaris
+}
+
+version (POSIX)
+{
+	import dmd.Array;
+	import dmd.Gnuc;
+	import core.sys.posix.stdlib;
+	version (TARGET_FOS) import core.stdc.limits;
 }
 
 enum MAX_PATH = 256; ///
@@ -136,20 +164,20 @@
 }
 				filename = FileName.replaceName(argv0, inifile);
 				if (!FileName.exists(filename)) {
-version (XXX) { /// linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
-	version (XXX) { /// __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun&&__SVR4   // This fix by Thomas Kuehne
+version (POSIX) { /// linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+	version (POSIX) { /// __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun&&__SVR4   // This fix by Thomas Kuehne
 					/* argv0 might be a symbolic link,
 					* so try again looking past it to the real path
 					*/
-		version (XXX) {/// #if __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+		version (TARGET_FOS) {/// #if __APPLE__ || __FreeBSD__ || __sun&&__SVR4
 					char resolved_name[PATH_MAX + 1];
-					char* real_argv0 = realpath(argv0, resolved_name);
+					char* real_argv0 = realpath(toStringz(argv0), resolved_name);
 		} else {
-					char* real_argv0 = realpath(argv0, null);
+					char* real_argv0 = realpath(toStringz(argv0), null);
 		}
 					//printf("argv0 = %s, real_argv0 = %p\n", argv0, real_argv0);
 					if (real_argv0) {
-						filename = FileName.replaceName(real_argv0, inifile);
+						filename = FileName.replaceName(fromStringz(real_argv0), inifile);
 		version (linux) {
 						///free(real_argv0);
 		}
@@ -162,11 +190,11 @@
 	}
 					if (true) {
 						// Search PATH for argv0
-						const(char)* p = getenv("PATH");
+						const(char)* p = toStringz(getenv("PATH"));
 	version (LOG) {
 						writef("\tPATH='%s'\n", p);
 	}
-						Array paths = FileName.splitPath(p);
+						auto paths = FileName.splitPath(fromStringz(p));
 						filename = FileName.searchPath(paths, argv0, 0);
 						if (!filename) {
 							goto Letc;		// argv0 not found on path
@@ -272,7 +300,12 @@
 							if (l <= tmp.sizeof)
 								p = tmp.ptr;
 							else
+							{
+							version (Bug4054)
+								p = cast(char*)GC.malloc(l);
+							else
 								p = cast(char*)alloca(l);
+							}
 							l--;
 							memcpy(p, &line[k + 1], l);
 							p[l] = 0;
@@ -784,63 +817,55 @@
 		///delete lnkfilename;
     }
     return status;
-} else if (XXX) {/// linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
-	assert(false);
-	/+
+} else version (POSIX) {/// linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
     pid_t childpid;
     int i;
     int status;
 
     // Build argv[]
-    Array argv;
+    Array argv = new Array();
 
-    const char *cc = getenv("CC");
+    const(char)* cc = core.stdc.stdlib.getenv("CC");
     if (!cc)
 	cc = "gcc";
-    argv.push((void *)cc);
-    argv.insert(1, global.params.objfiles);
+    argv.push(cast(void *)cc);
+    Array objfiles = new Array;
+    for( i = 0; i < global.params.objfiles.dim; i++ )
+    {   string str = (cast(String)global.params.objfiles.data[i]).str; 
+    	objfiles.push(cast(void*)toStringz(str));
+    }
+    argv.insert(1, objfiles);
 
     // None of that a.out stuff. Use explicit exe file name, or
     // generate one from name of first source file.
-    argv.push((void *)"-o");
+    argv.push(cast(void *)cast(char*)"-o");
     if (global.params.exefile)
     {
-	argv.push(global.params.exefile);
+	argv.push(cast(void*)toStringz(global.params.exefile));
     }
     else
     {	// Generate exe file name from first obj name
-	char *n = (char *)global.params.objfiles.data[0];
-	char *e;
-	char *ex;
-
+	string n = (cast(String)global.params.objfiles.data[0]).str;
 	n = FileName.name(n);
-	e = FileName.ext(n);
-	if (e)
-	{
-	    e--;			// back up over '.'
-	    ex = (char *)mem.malloc(e - n + 1);
-	    memcpy(ex, n, e - n);
-	    ex[e - n] = 0;
-	}
-	else
-	    ex = (char *)"a.out";	// no extension, so give up
-	argv.push(ex);
+	string e = FileName.ext(n);
+	string ex = e ? n[0..$-(e.length+1)] : "a.out";
+
+	argv.push(cast(void*)toStringz(ex));
 	global.params.exefile = ex;
     }
 
     // Make sure path to exe file exists
-    {	char *p = FileName.path(global.params.exefile);
+    {	string p = FileName.path(global.params.exefile);
 	FileName.ensurePathExists(p);
-	mem.free(p);
     }
 
     if (global.params.symdebug)
-	argv.push((void *)"-g");
+	argv.push(cast(void *)cast(char*)"-g");
 
     if (global.params.isX86_64)
-	argv.push((void *)"-m64");
+	argv.push(cast(void *)cast(char*)"-m64");
     else
-	argv.push((void *)"-m32");
+	argv.push(cast(void *)cast(char*)"-m32");
 
     if (0 && global.params.exefile)
     {
@@ -853,16 +878,16 @@
 	 * Thomas Kuehne has verified that it works with ld 2.16.1.
 	 * BUG: disabled because it causes exception handling to fail
 	 */
-	argv.push((void *)"-Xlinker");
-	argv.push((void *)"--gc-sections");
+	argv.push(cast(void *)cast(char*)"-Xlinker");
+	argv.push(cast(void *)cast(char*)"--gc-sections");
     }
 
     for (i = 0; i < global.params.linkswitches.dim; i++)
-    {	char *p = (char *)global.params.linkswitches.data[i];
+    {	char *p = cast(char *)global.params.linkswitches.data[i];
 	if (!p || !p[0] || !(p[0] == '-' && p[1] == 'l'))
 	    // Don't need -Xlinker if switch starts with -l
-	    argv.push((void *)"-Xlinker");
-	argv.push((void *) p);
+	    argv.push(cast(void *)cast(char*)"-Xlinker");
+	argv.push(cast(void *) p);
     }
 
     /* Add each library, prefixing it with "-l".
@@ -874,17 +899,17 @@
      *  4. standard libraries.
      */
     for (i = 0; i < global.params.libfiles.dim; i++)
-    {	char *p = (char *)global.params.libfiles.data[i];
+    {	char *p = cast(char *)global.params.libfiles.data[i];
 	size_t plen = strlen(p);
 	if (plen > 2 && p[plen - 2] == '.' && p[plen -1] == 'a')
-	    argv.push((void *)p);
+	    argv.push(cast(void *)p);
 	else
 	{
-	    char *s = (char *)mem.malloc(plen + 3);
+	    char *s = cast(char *)malloc(plen + 3);
 	    s[0] = '-';
 	    s[1] = 'l';
 	    memcpy(s + 2, p, plen + 1);
-	    argv.push((void *)s);
+	    argv.push(cast(void *)s);
 	}
     }
 
@@ -894,20 +919,20 @@
     const char *libname = (global.params.symdebug)
 				? global.params.debuglibname
 				: global.params.defaultlibname;
-    char *buf = (char *)malloc(2 + strlen(libname) + 1);
+    char *buf = cast(char *)malloc(2 + strlen(libname) + 1);
     strcpy(buf, "-l");
     strcpy(buf + 2, libname);
-    argv.push((void *)buf);		// turns into /usr/lib/libphobos2.a
+    argv.push(cast(void *)buf);		// turns into /usr/lib/libphobos2.a
 
 //    argv.push((void *)"-ldruntime");
-    argv.push((void *)"-lpthread");
-    argv.push((void *)"-lm");
+    argv.push(cast(void *)cast(char*)"-lpthread");
+    argv.push(cast(void *)cast(char*)"-lm");
 
     if (!global.params.quiet || global.params.verbose)
     {
 	// Print it
 	for (i = 0; i < argv.dim; i++)
-	    printf("%s ", (char *)argv.data[i]);
+	    printf("%s ", cast(char *)argv.data[i]);
 	printf("\n");
 	fflush(stdout);
     }
@@ -916,8 +941,8 @@
     childpid = fork();
     if (childpid == 0)
     {
-	execvp((char *)argv.data[0], (char **)argv.data);
-	perror((char *)argv.data[0]);		// failed to execute
+	execvp(cast(char *)argv.data[0], cast(char **)argv.data);
+	perror(cast(char *)argv.data[0]);		// failed to execute
 	return -1;
     }
 
@@ -927,7 +952,7 @@
     if (status)
 	printf("--- errorlevel %d\n", status);
     return status;
-	+/
+	
 } else {
     writef ("Linking is not yet supported for this version of DMD.\n");
     return -1;
@@ -1004,6 +1029,9 @@
 			case 2: envname[0] = '%';	break;
 			default: break;	///
 		}
+		version (Bug4054)
+		q = cast(char*) GC.malloc(envname.sizeof + len + 1);
+		else
 		q = cast(char*) alloca(envname.sizeof + len + 1);
 		sprintf(q, "%s=%s", envname.ptr + 1, args);
 		status = putenv(q);
@@ -1086,4 +1114,4 @@
     static assert(false);
 }
 }
-}
\ No newline at end of file
+}
--- a/dmd/VarDeclaration.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/VarDeclaration.d	Mon Apr 12 17:00:08 2010 +0100
@@ -40,6 +40,7 @@
 import dmd.TOK;
 import dmd.TupleExp;
 import dmd.Global;
+import dmd.Module;
 import dmd.FuncDeclaration;
 import dmd.Type;
 import dmd.TY;
@@ -245,7 +246,7 @@
 		for (size_t i = 0; i < nelems; i++)
 		{   Argument arg = Argument.getNth(tt.arguments, i);
 
-			OutBuffer buf;
+			OutBuffer buf = new OutBuffer();
 			buf.printf("_%s_field_%zu", ident.toChars(), i);
 			buf.writeByte(0);
 			string name = buf.extractString();
@@ -1214,4 +1215,4 @@
 
     // Eliminate need for dynamic_cast
     VarDeclaration isVarDeclaration() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/XorAssignExp.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/XorAssignExp.d	Mon Apr 12 17:00:08 2010 +0100
@@ -17,12 +17,12 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
-		super(loc, TOKxorass, XorAssignExp.sizeof, e1, e2);
+		super(loc, TOK.TOKxorass, this.sizeof, e1, e2);
 	}
 	
     Expression semantic(Scope sc)
 	{
-		assert(false);
+    		return commonSemanticAssignIntegral(sc);
 	}
 	
     Expression interpret(InterState* istate)
@@ -49,4 +49,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/backend/Config.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/Config.d	Mon Apr 12 17:00:08 2010 +0100
@@ -8,7 +8,7 @@
 	void cod3_set386();
 }
 
-extern (C++) extern
+debug extern (C) extern
 {
 	__gshared char debuga;		/* cg - watch assignaddr()		*/
 	__gshared char debugb;		/* watch block optimization		*/
@@ -62,7 +62,7 @@
 enum CFG3relax = 0x200;	// relaxed type checking (C only)
 enum CFG3cpp = 0x400;	// C++ compile
 enum CFG3igninc = 0x800;	// ignore standard include directory
-version (XXX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS) {
+version (POSIX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS) {
 enum CFG3mars = 0x1000;	// use mars libs and headers
 enum NO_FAR	= true;	// always ignore __far and __huge keywords
 } else {
@@ -129,8 +129,6 @@
 
 mixin(BringToCurrentScope!(TARGET));
 
-enum CV4 = 2;		// Codeview 4 symbolic info
-
 struct Config
 {
     char language;		// 'C' = C, 'D' = C++
@@ -192,16 +190,16 @@
     LINKAGE linkage;	// default function call linkage
 }
 
-extern (C++) extern __gshared Config config;
+extern (C) extern __gshared Config config;
 
 enum CVNONE = 0;		// No symbolic info
-///enum CVOLD = 1;		// Codeview 1 symbolic info
-///enum CV4 = 2;		// Codeview 4 symbolic info
-///enum CVSYM = 3;		// Symantec format
-///enum CVTDB = 4;		// Symantec format written to file
-///enum CVDWARF_C = 5;		// Dwarf in C format
-///enum CVDWARF_D = 6;		// Dwarf in D format
-///enum CVSTABS = 7;		// Elf Stabs in C format
+enum CVOLD = 1;		// Codeview 1 symbolic info
+enum CV4 = 2;		// Codeview 4 symbolic info
+enum CVSYM = 3;		// Symantec format
+enum CVTDB = 4;		// Symantec format written to file
+enum CVDWARF_C = 5;		// Dwarf in C format
+enum CVDWARF_D = 6;		// Dwarf in D format
+enum CVSTABS = 7;		// Elf Stabs in C format
 
 enum CFGuchar = 1;	// chars are unsigned
 enum CFGsegs = 2;	// new code seg for each far func
@@ -256,4 +254,4 @@
 enum WFthunk = 0x1000;	// use fixups instead of direct ref to CS
 enum WFsaveds = 0x2000;	// use push/pop DS for far functions
 enum WFdsnedgroup = 0x4000;	// DS != DGROUP
-enum WFexe = 0x8000;	// generating code for Windows EXE
\ No newline at end of file
+enum WFexe = 0x8000;	// generating code for Windows EXE
--- a/dmd/backend/Cstate.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/Cstate.d	Mon Apr 12 17:00:08 2010 +0100
@@ -18,4 +18,4 @@
     char* modname;		// module unique identifier
 }
 
-extern (C++) extern __gshared Cstate cstate;
\ No newline at end of file
+extern (C) extern __gshared Cstate cstate;
--- a/dmd/backend/LIST.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/LIST.d	Mon Apr 12 17:00:08 2010 +0100
@@ -1,1 +1,26 @@
-module dmd.backend.LIST;

import dmd.backend.Symbol;

struct LIST
{
	/* Do not access items in this struct directly, use the		*/
	/* functions designed for that purpose.				*/
	LIST* next;	/* next element in list			*/
	int count;		/* when 0, element may be deleted	*/

	union
	{
		void *ptr;	/* data pointer				*/
		int data;
	}
}

alias LIST* list_t;			/* pointer to a list entry		*/
alias list_t symlist_t;		/* pointer to a list entry		*/

extern (C++) extern {
	__gshared list_t slist;
	list_t list_prepend(list_t* plist, void* ptr);
	void slist_add(Symbol* s);
}
\ No newline at end of file
+module dmd.backend.LIST;
+
+import dmd.backend.Symbol;
+
+struct LIST
+{
+	/* Do not access items in this struct directly, use the		*/
+	/* functions designed for that purpose.				*/
+	LIST* next;	/* next element in list			*/
+	int count;		/* when 0, element may be deleted	*/
+
+	union
+	{
+		void *ptr;	/* data pointer				*/
+		int data;
+	}
+}
+
+alias LIST* list_t;			/* pointer to a list entry		*/
+alias list_t symlist_t;		/* pointer to a list entry		*/
+
+extern (C++) extern {
+	extern(C) extern __gshared list_t slist;
+	list_t list_prepend(list_t* plist, void* ptr);
+	void slist_add(Symbol* s);
+}
--- a/dmd/backend/OPER.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/OPER.d	Mon Apr 12 17:00:08 2010 +0100
@@ -282,10 +282,20 @@
 
 enum RELOPMIN = cast(int)OPER.OPle;
 
-extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab1;
-extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab2;
-extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab3;
-extern(C++) extern __gshared const ubyte[OPER.OPMAX] opcost;
+version (Windows)
+{
+	extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab1;
+	extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab2;
+	extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab3;
+	extern(C++) extern __gshared const ubyte[OPER.OPMAX] opcost;
+}
+else
+{
+	extern(C) extern __gshared const ubyte[OPER.OPMAX] optab1;
+	extern(C) extern __gshared const ubyte[OPER.OPMAX] optab2;
+	extern(C) extern __gshared const ubyte[OPER.OPMAX] optab3;
+	extern(C) extern __gshared const ubyte[OPER.OPMAX] opcost;
+}
 
 enum _OT
 {
@@ -355,4 +365,4 @@
 +/
 
 import dmd.EnumUtils;
-mixin(BringToCurrentScope!(OPER));
\ No newline at end of file
+mixin(BringToCurrentScope!(OPER));
--- a/dmd/backend/RTLSYM.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/RTLSYM.d	Mon Apr 12 17:00:08 2010 +0100
@@ -98,4 +98,5 @@
 import dmd.EnumUtils;
 mixin(BringToCurrentScope!(RTLSYM));
 
-extern(C++) extern __gshared Symbol* rtlsym[RTLSYM.RTLSYM_MAX];
\ No newline at end of file
+//extern(C++) extern __gshared Symbol* rtlsym[RTLSYM.RTLSYM_MAX];
+extern(C) extern __gshared Symbol* rtlsym[RTLSYM.RTLSYM_MAX];
--- a/dmd/backend/SFL.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/SFL.d	Mon Apr 12 17:00:08 2010 +0100
@@ -27,7 +27,7 @@
 	SFLdyninit = 0x200000,	// symbol has dynamic initializer
 	SFLtmp = 0x400000,	// symbol is a generated temporary
 
-///version (XXX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+///version (POSIX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 ///    SFLthunk = 0x40000, // symbol is temporary for thunk
 ///}
 
@@ -64,4 +64,4 @@
 }
 
 import dmd.EnumUtils;
-mixin(BringToCurrentScope!(SFL));
\ No newline at end of file
+mixin(BringToCurrentScope!(SFL));
--- a/dmd/backend/Symbol.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/Symbol.d	Mon Apr 12 17:00:08 2010 +0100
@@ -82,6 +82,18 @@
 
     const(char)* prettyIdent;	// the symbol identifer as the user sees it
 
+version (ELFOBJ_OR_MACHOBJ)
+{
+    ptrdiff_t     obj_si;       // Symbol index of coff or elf symbol
+    size_t        dwarf_off;    // offset into .debug section
+    targ_size_t   code_off;	// rel. offset from start of block where var is initialized
+    targ_size_t   last_off;	// last offset using var
+}
+version (TARGET_OSX)
+{
+    targ_size_t Slocalgotoffset;
+}
+
     enum_SC Sclass;		// storage class (SCxxxx)
     char Sfl;			// flavor (FLxxxx)
     SYMFLGS Sflags;		// flag bits (SFLxxxx)
@@ -385,4 +397,4 @@
 		assert(false);
 	}
 }
-+/
\ No newline at end of file
++/
--- a/dmd/backend/TYFL.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/TYFL.d	Mon Apr 12 17:00:08 2010 +0100
@@ -121,17 +121,17 @@
 +/
 
 /* Detect function type	*/
-ubyte tyfunc(uint ty) {
+ubyte tyfunc(ulong ty) {
 	return (tytab2[(ty) & 0xFF] & TYFL.TYFLfunc);
 }
 
 /* Detect function type where parameters are pushed in reverse order	*/
-ubyte tyrevfunc(uint ty) {
+ubyte tyrevfunc(ulong ty) {
 	return (tytab2[(ty) & 0xFF] & TYFL.TYFLrevparam);
 }
 
 /* Detect unsigned types */
-ubyte tyuns(uint ty) {
+ubyte tyuns(ulong ty) {
 	return (tytab[(ty) & 0xFF] & (TYFL.TYFLuns | TYFL.TYFLptr));
 }
 
@@ -153,7 +153,7 @@
 /* Array to convert a type to its unsigned equivalent	*/
 extern(C++) extern tym_t* get_tytouns();
 
-tym_t touns(int ty) {
+tym_t touns(ulong ty) {
 	return get_tytouns[ty & 0xFF];
 }
 
@@ -172,4 +172,4 @@
 #ifndef tyrelax
 #define tyrelax(ty)	(_tyrelax[tybasic(ty)])
 #endif
-+/
\ No newline at end of file
++/
--- a/dmd/backend/TYM.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/TYM.d	Mon Apr 12 17:00:08 2010 +0100
@@ -76,9 +76,9 @@
 ///#endif
 }
 
-extern (C++) extern {
+extern (C) extern {
 	__gshared int TYptrdiff, TYsize, TYsize_t;
 }
 
 import dmd.EnumUtils;
-mixin(BringToCurrentScope!(TYM));
\ No newline at end of file
+mixin(BringToCurrentScope!(TYM));
--- a/dmd/backend/TYPE.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/TYPE.d	Mon Apr 12 17:00:08 2010 +0100
@@ -23,7 +23,7 @@
     ushort Tflags;	// TFxxxxx
 
 version (TX86) {
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 ///#define mTYnoret	0x010000	// function has no return
 ///#define mTYtransu	0x010000	// transparent union
 } else {
@@ -37,7 +37,7 @@
 ///#define mTYsyscall	0x400000
 ///#define mTYjava		0x800000
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 ///#define mTYTFF		0xFE0000
 } else {
 ///#define mTYTFF		0xFF0000
@@ -97,8 +97,8 @@
 
 alias type* typep_t;
 
-extern(C++) extern __gshared typep_t tstypes[TYM.TYMAX];
-extern(C++) extern __gshared typep_t tsptr2types[TYM.TYMAX];
+extern(C) extern __gshared typep_t tstypes[TYM.TYMAX];
+extern(C) extern __gshared typep_t tsptr2types[TYM.TYMAX];
 
 ref type* tsbool	  () { return tstypes[TYM.TYbool]; }
 ref type* tschar    () { return tstypes[TYM.TYchar]; }
@@ -118,10 +118,10 @@
 ref type* tsdouble  () { return tstypes[TYM.TYdouble]; }
 ref type* tsreal64  () { return tstypes[TYM.TYdouble_alias]; }
 ref type* tsldouble () { return tstypes[TYM.TYldouble]; }
-ref type* tsvoid	() { return tstypes[TYM.TYvoid]; }
+ref type* tsvoid    () { return tstypes[TYM.TYvoid]; }
 ref type* tsifloat   () { return tstypes[TYM.TYifloat]; }
 ref type* tsidouble  () { return tstypes[TYM.TYidouble]; }
 ref type* tsildouble () { return tstypes[TYM.TYildouble]; }
 ref type* tscfloat   () { return tstypes[TYM.TYcfloat]; }
 ref type* tscdouble  () { return tstypes[TYM.TYcdouble]; }
-ref type* tscldouble () { return tstypes[TYM.TYcldouble]; }
\ No newline at end of file
+ref type* tscldouble () { return tstypes[TYM.TYcldouble]; }
--- a/dmd/backend/Util.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/Util.d	Mon Apr 12 17:00:08 2010 +0100
@@ -49,7 +49,8 @@
 	ectorgates = new Array();
 }
 
-alias uint tym_t;		// data type big enough for type masks
+alias size_t tym_t;		// data type big enough for type masks
+//alias ulong tym_t;		// data type big enough for type masks
 alias elem* elem_p;		// data type big enough for type masks
 
 void el_setLoc(elem* e, Loc loc) {
@@ -69,31 +70,78 @@
 }
 ///#define struct_free(st)	((void)(st))
 
+version (Bug4059)
+{
+	private extern (C) {
+		void _Z12obj_initfilePKcS0_S0_(const(char)* filename, const(char)* csegname, const(char)* modname);
+		elem_p _Z6el_binjmP4elemS0_(uint, tym_t, elem_p, elem_p);
+		elem_p _Z7el_pairmP4elemS0_(tym_t, elem_p, elem_p);
+		elem_p _Z10el_combineP4elemS0_(elem_p, elem_p);
+		elem* _Z8el_paramP4elemS0_(elem* e1, elem* e2);
+		Symbol* _Z13symbol_callocPKc(const(char)* id);
+		int _Z9objextdefPKc(const(char)* name);
+		void _Z14obj_includelibPKc(const(char)* name);
+		Symbol* _Z11symbol_namePKciP4TYPE(const(char)* name, int sclass, type* t);
+		dt_t ** _Z8dtnbytesPP4dt_tmPKc(dt_t** pdtend, targ_size_t size, const(char)* ptr);
+		dt_t** _Z8dtabytesPP4dt_tmmmPKc(dt_t** pdtend, tym_t ty, targ_size_t offset, targ_size_t size, const(char)* ptr);
+		type* _Z10type_settyPP4TYPEl(type**, long);
+
+		void _Z10cod3_thunkP6SymbolS0_jmmim(Symbol* sthunk, Symbol* sfunc, uint p, tym_t thisty, targ_size_t d, int i, targ_size_t d2);
+	}
+	void obj_initfile(const(char)* filename, const(char)* csegname, const(char)* modname) { return _Z12obj_initfilePKcS0_S0_(filename, csegname, modname); }
+	elem_p el_bin(uint a, tym_t b, elem_p c, elem_p d) { return _Z6el_binjmP4elemS0_(a, b, c, d);  }
+	elem_p el_pair(tym_t a, elem_p b, elem_p c) { return _Z7el_pairmP4elemS0_(a, b, c); }
+	elem_p el_combine(elem_p a, elem_p b) { return _Z10el_combineP4elemS0_(a, b); }
+	elem* el_param(elem* e1, elem* e2) { return _Z8el_paramP4elemS0_(e1, e2); }
+	Symbol* symbol_calloc(const(char)* id) { return _Z13symbol_callocPKc(id); }
+	int objextdef(const(char)* name) { return _Z9objextdefPKc(name); }
+	void obj_includelib(const(char)* name) { return _Z14obj_includelibPKc(name); }
+	Symbol* symbol_name(const(char)* name, int sclass, type* t) { return _Z11symbol_namePKciP4TYPE(name, sclass, t); }
+	dt_t ** dtnbytes(dt_t** pdtend, targ_size_t size, const(char)* ptr) { return _Z8dtnbytesPP4dt_tmPKc(pdtend, size, ptr); }
+	dt_t** dtabytes(dt_t** pdtend, tym_t ty, targ_size_t offset, targ_size_t size, const(char)* ptr) { return _Z8dtabytesPP4dt_tmmmPKc(pdtend, ty, offset, size, ptr); }
+	type* type_setty(type** a, long b) { return _Z10type_settyPP4TYPEl(a, b); }
+
+	void cod3_thunk(Symbol* sthunk, Symbol* sfunc, uint p, tym_t thisty, targ_size_t d, int i, targ_size_t d2) { return _Z10cod3_thunkP6SymbolS0_jmmim(sthunk, sfunc, p, thisty, d, i, d2); }
+}
+else
+{
+	extern (C++) {
+		void obj_initfile(const(char)* filename, const(char)* csegname, const(char)* modname);
+		dt_t ** dtnbytes(dt_t** pdtend, targ_size_t size, const(char)* ptr);
+		elem_p el_bin(uint, tym_t, elem_p, elem_p);
+		elem_p el_pair(tym_t, elem_p, elem_p);
+		elem_p el_combine(elem_p, elem_p);
+		elem* el_param(elem* e1, elem* e2);
+		Symbol* symbol_calloc(const(char)* id);
+		int objextdef(const(char)* name);
+		void obj_includelib(const(char)* name);
+		Symbol* symbol_name(const(char)* name, int sclass, type* t);
+		dt_t** dtabytes(dt_t** pdtend, tym_t ty, targ_size_t offset, targ_size_t size, const(char)* ptr);
+		type* type_setty(type**, long);
+	
+		void cod3_thunk(Symbol* sthunk, Symbol* sfunc, uint p, tym_t thisty, targ_size_t d, int i, targ_size_t d2);
+	}
+}
+
 extern (C++) {
+//__gshared:
+	void obj_ehsections();
+	void obj_staticdtor(Symbol *s);
 	void* mem_fcalloc(uint numbytes);
-	void obj_initfile(const(char)* filename, const(char)* csegname, const(char)* modname);
-	Symbol* symbol_calloc(const(char)* id);
 	type* type_fake(tym_t);
 	dt_t** dtnzeros(dt_t** pdtend, targ_size_t size);
 	void outdata(Symbol* s);
 	int reftoident(int seg, targ_size_t offset, Symbol* s, targ_size_t val, int flags);
-	dt_t ** dtnbytes(dt_t** pdtend, targ_size_t size, const(char)* ptr);
 	type* type_alloc(tym_t ty);
 	elem_p el_params(elem_p, ...);
 	elem_p el_ptr(Symbol*);
 	elem_p el_long(tym_t, targ_long);
-	elem_p el_bin(uint, tym_t, elem_p, elem_p);
 	elem_p el_var(Symbol*);
-	elem_p el_combine(elem_p, elem_p);
 	block* block_calloc();
 	void writefunc(Symbol* sfunc);
 	void obj_termfile();
-	int objextdef(const(char)* name);
-	void obj_includelib(const(char)* name);
 	SYMIDX symbol_add(Symbol* s);
-	elem* el_param(elem* e1, elem* e2);
-	elem* el_una(uint op, tym_t ty, elem* e1);
-	Symbol* symbol_name(const(char)* name, int sclass, type* t);
+	elem_p el_una(uint op, tym_t ty, elem_p e1);
 	type* type_setcv(type** pt, tym_t cv);
 	int type_jparam(type* t);
 	void obj_export(Symbol* s, uint argsize);
@@ -105,7 +153,6 @@
 	void block_next(Blockx* bctx, BC bc, block* bn);
 	dt_t** dtxoff(dt_t** pdtend, Symbol* s,targ_size_t offset, tym_t ty);
 	dt_t** dtdword(dt_t** pdtend, int value);
-	dt_t** dtabytes(dt_t** pdtend, tym_t ty, targ_size_t offset, targ_size_t size, const(char)* ptr);
 	void obj_moduleinfo(Symbol* scc);
 	Symbol* symbol_genauto(TYPE* t);
 	elem* el_same(elem**);
@@ -113,12 +160,10 @@
 	Symbol* symbol_generate(int sclass, type* t);
 	elem* el_calloc();
 	void dt_optimize(dt_t* dt);
-	type* type_setty(type**, int);
 	type* type_setmangle(type** pt, mangle_t mangle);
 	list_t list_append(list_t* plist, void* ptr);
 	dt_t** dtcat(dt_t** pdtend, dt_t* dt);
 	elem_p el_copytree(elem_p);
-	elem_p el_pair(tym_t, elem_p, elem_p);
 	int el_allbits(elem *e, int bit);
 	block* block_goto(Blockx* bctx, BC bc, block* bn);
 	block* block_calloc(Blockx* blx);
@@ -129,10 +174,9 @@
 	elem* el_const(tym_t, eve*);
 	elem *el_params(void** args, int length);
 	
-	void cod3_thunk(Symbol* sthunk, Symbol* sfunc, uint p, tym_t thisty, targ_size_t d, int i, targ_size_t d2);
 	
 	version (SEH) {
 		void nteh_declarvars(Blockx* bx);
 		elem* nteh_setScopeTableIndex(Blockx* blx, int scope_index);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/backend/glue.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/glue.d	Mon Apr 12 17:00:08 2010 +0100
@@ -20,9 +20,9 @@
 
 __gshared Array obj_symbols_towrite;
 
-extern (C++) extern
+extern (C++) /+extern+/
 {
-	__gshared Outbuffer objbuf;
+	extern(C) extern __gshared Outbuffer objbuf;
 	int go_flag(char* cp);
 	void util_set64();
 	void util_set386();
@@ -127,8 +127,9 @@
 version (_WIN32) {
 		*cast(ushort*)p = cast(short)v;
 } else {
-		p[0] = v;
-		p[1] = v >> 8;
+                assert(0, "Check this");
+		p[0] = cast(ubyte)v;
+		p[1] = cast(ubyte)(v >> 8);
 }
 		p += 2;
     }
@@ -271,6 +272,16 @@
     obj_symbols_towrite.push(cast(void*)s);
 }
 
+version (Bug4059)
+{
+	private extern (C) void _Z8obj_initP9OutbufferPKcS2_(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);
+	void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname) { return _Z8obj_initP9OutbufferPKcS2_(objbuf, filename, csegname); }
+}
+else
+{
+	void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);	
+}
+
 extern (C++) {
 	void backend_init();
 	void backend_term();
@@ -280,7 +291,6 @@
 	void el_reset();
 	void cg87_reset();
 	void out_reset();
-	void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);
 }
 
 void clearStringTab()
@@ -549,4 +559,4 @@
     debugx = params.debugx;
     debugy = params.debugy;
 }
-}
\ No newline at end of file
+}
--- a/dmd/backend/iasm.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/iasm.d	Mon Apr 12 17:00:08 2010 +0100
@@ -77,16 +77,25 @@
 	"word".ptr,
 ];
 
-extern (Pascal) extern {
-	code* cat(code* c1 , code* c2 );
+extern (C) code * cat(code *c1,code *c2);
+
+version (Bug4059)
+{
+	private extern(C) OP* _Z13asm_op_lookupPKc(const(char)* s);
+	private extern(C) int _Z6binaryPKcPS0_i(const(char)* p , const(char)** tab, int high);
+	OP* asm_op_lookup(const(char)* s) { return _Z13asm_op_lookupPKc(s); }
+	int binary(const(char)* p , const(char)** tab, int high) { return _Z6binaryPKcPS0_i(p, tab, high); }
 }
-
-extern (C++) extern 
+else
+{
+	OP* asm_op_lookup(const(char)* s);
+	int binary(const(char)* p , const(char)** tab, int high);
+}
+
+extern (C++) //extern 
 {
 	void init_optab();
-	OP* asm_op_lookup(const(char)* s);
 	const(char)* asm_opstr(OP* pop);
-	int binary(const(char)* p , const(char)** tab, int high);
 }
 
 static ubyte asm_TKlbra_seen = false;
@@ -182,15 +191,15 @@
 enum mST0 = (1 << ST0);	// 0x4000
 enum mST01 = (1 << ST01);	// 0x8000
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
     // To support positional independent code,
     // must be able to remove BX from available registers
-///extern regm_t ALLREGS;			
-///#define ALLREGS_INIT		(mAX|mBX|mCX|mDX|mSI|mDI)
-///#define ALLREGS_INIT_PIC	(mAX|mCX|mDX|mSI|mDI)
-///extern regm_t BYTEREGS;			
-///#define BYTEREGS_INIT		(mAX|mBX|mCX|mDX)
-///#define BYTEREGS_INIT_PIC	(mAX|mCX|mDX)
+extern (C) extern __gshared regm_t ALLREGS;			
+enum ALLREGS_INIT = (mAX|mBX|mCX|mDX|mSI|mDI);
+enum ALLREGS_INIT_PIC = (mAX|mCX|mDX|mSI|mDI);
+extern (C) extern regm_t BYTEREGS;			
+enum BYTEREGS_INIT = (mAX|mBX|mCX|mDX);
+enum BYTEREGS_INIT_PIC = (mAX|mCX|mDX);
 } else {
 enum ALLREGS = (mAX|mBX|mCX|mDX|mSI|mDI);
 ///#define ALLREGS_INIT		ALLREGS
@@ -1026,10 +1035,12 @@
 			}
 			else
 			{	
-				asm_make_modrm_byte(
-///debug {
+				debug asm_make_modrm_byte(
 				auchOpcode, &usIdx,
-///}
+				pc, 
+				ptb.pptb1.usFlags,
+				popnd1, null);
+				else asm_make_modrm_byte(
 				pc, 
 				ptb.pptb1.usFlags,
 				popnd1, null);
@@ -1119,23 +1130,21 @@
 					ptb.pptb0.usOpcode == 0x660F7E	// MOVD _rm32,_xmm
 				   )
 				{
-					asm_make_modrm_byte(
-///debug {
-					auchOpcode, &usIdx,
-///}
-					pc, 
-					ptb.pptb1.usFlags,
-					popnd1, popnd2);
+					debug asm_make_modrm_byte(
+						auchOpcode, &usIdx,
+						pc, 
+						ptb.pptb1.usFlags,
+						popnd1, popnd2);
+					else asm_make_modrm_byte(pc, ptb.pptb1.usFlags, popnd1, popnd2);
 				}
 				else
 				{
-					asm_make_modrm_byte(
-///debug {
-					auchOpcode, &usIdx,
-///}
-					pc, 
-					ptb.pptb1.usFlags,
-					popnd2, popnd1);
+					debug asm_make_modrm_byte(
+						auchOpcode, &usIdx,
+						pc, 
+						ptb.pptb1.usFlags,
+						popnd2, popnd1);
+					else asm_make_modrm_byte(pc, ptb.pptb1.usFlags, popnd2, popnd1);
 				}
 				popndTmp = popnd1;
 				aoptyTmp = aoptyTable1;
@@ -1179,23 +1188,31 @@
 					 ptb.pptb0.usOpcode == 0x660FD7 ||
 					 ptb.pptb0.usOpcode == 0x0FD7)
 				{
-					asm_make_modrm_byte(
+					debug asm_make_modrm_byte(
 ///debug {
 						auchOpcode, &usIdx,
 ///}
 						pc, 
 						ptb.pptb1.usFlags,
 						popnd2, popnd1);
+					else asm_make_modrm_byte(
+						pc, 
+						ptb.pptb1.usFlags,
+						popnd2, popnd1); 
 				}
 				else
 				{
-					asm_make_modrm_byte(
+					debug asm_make_modrm_byte(
 ///debug {
 						auchOpcode, &usIdx,
 ///}
 						pc, 
 						ptb.pptb1.usFlags,
 						popnd1, popnd2);
+					else asm_make_modrm_byte(
+						pc, 
+						ptb.pptb1.usFlags,
+						popnd1, popnd2); 
 
 				}
 				if (aoptyTable1 == ASM_OPERAND_TYPE._imm)
@@ -1217,13 +1234,17 @@
 			if (aoptyTable2 == ASM_OPERAND_TYPE._m || aoptyTable2 == ASM_OPERAND_TYPE._rm ||
 				usOpcode == 0x0FC5) // PEXTRW
 			{
-				asm_make_modrm_byte(
+				debug asm_make_modrm_byte(
 ///debug {
 					auchOpcode, &usIdx,
 ///}
 					pc, 
 					ptb.pptb1.usFlags,
 					popnd2, popnd1);
+				else asm_make_modrm_byte(
+					pc, 
+					ptb.pptb1.usFlags,
+					popnd2, popnd1); 
 				popndTmp = popnd3;
 				aoptyTmp = aoptyTable3;
 				uSizemaskTmp = cast(ushort)uSizemaskTable3;
@@ -1257,14 +1278,19 @@
 }
 				}
 				else
-					asm_make_modrm_byte(
+				{
+					debug asm_make_modrm_byte(
 ///debug {
 						auchOpcode, &usIdx,
 ///}
 						pc, 
 						ptb.pptb1.usFlags,
 						popnd1, popnd2);
-
+					else asm_make_modrm_byte(
+						pc, 
+						ptb.pptb1.usFlags,
+						popnd1, popnd2); 
+				}
 				popndTmp = popnd3;
 				aoptyTmp = aoptyTable3;
 				uSizemaskTmp = cast(ushort)uSizemaskTable3;
@@ -2221,16 +2247,16 @@
 	return X(r1, 9);
 }
 
-void asm_make_modrm_byte(
-///debug {
-	ubyte[] puchOpcode, uint* pusIdx,
-///}
-	code *pc,
-	ushort usFlags,
-	OPND *popnd, OPND *popnd2)
+// Save a copy/pasted function
+template Tuple(T...) { alias T Tuple; }
+debug alias Tuple!(ubyte[], uint*) asm_make_modrm_args;
+else alias Tuple!() asm_make_modrm_args;
+
+void asm_make_modrm_byte(asm_make_modrm_args ocidx, code *pc, ushort usFlags, OPND *popnd, OPND *popnd2)
 {
 ///    #undef modregrm
-
+debug alias ocidx[0] puchOpcode;
+debug alias ocidx[1] pusIdx;
     union MODRM_BYTE			// mrmb
 	{
 		struct MODRM
@@ -4432,4 +4458,4 @@
 	return(szReg.length == 2 && (szReg[0] == 's' || szReg[0] == 'S') &&
 		(szReg[1] == 't' || szReg[1] == 'T'));
 }
-}
\ No newline at end of file
+}
--- a/dmd/backend/mTY.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/backend/mTY.d	Mon Apr 12 17:00:08 2010 +0100
@@ -38,6 +38,6 @@
 import dmd.EnumUtils;
 mixin(BringToCurrentScope!(mTY));
 
-uint tybasic(uint ty) {
+uint tybasic(ulong ty) {
 	return ((ty) & mTY.mTYbasic);
-}
\ No newline at end of file
+}
--- a/dmd/codegen/Util.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/codegen/Util.d	Mon Apr 12 17:00:08 2010 +0100
@@ -14,6 +14,7 @@
 import dmd.Argument;
 import dmd.STC;
 import dmd.Global;
+import dmd.Module;
 import dmd.InterfaceDeclaration;
 import dmd.AggregateDeclaration;
 import dmd.AttribDeclaration;
@@ -1121,7 +1122,7 @@
     s.Sflags |= SFLnodebug;
     s.Stype = t;
 version (ELFOBJ_OR_MACHOBJ) {
-    s.Sseg = DATA;
+    s.Sseg = Segment.DATA;
 }
     slist_add(s);
     return s;
@@ -1149,4 +1150,4 @@
 			s.lblock.Btry = null;
     }
     return s.lblock;
-}
\ No newline at end of file
+}
--- a/dmd/expression/Add.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/expression/Add.d	Mon Apr 12 17:00:08 2010 +0100
@@ -9,6 +9,7 @@
 import dmd.TOK;
 import dmd.SymOffExp;
 import dmd.Complex;
+import dmd.Util : printf;
 
 Expression Add(Type type, Expression e1, Expression e2)
 {   
@@ -102,4 +103,4 @@
 		e = new IntegerExp(loc, e1.toInteger() + e2.toInteger(), type);
 
     return e;
-}
\ No newline at end of file
+}
--- a/dmd/expression/Slice.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/expression/Slice.d	Mon Apr 12 17:00:08 2010 +0100
@@ -8,6 +8,7 @@
 import dmd.GlobalExpressions;
 import dmd.ArrayLiteralExp;
 import dmd.ArrayTypes;
+import dmd.Util : printf;
 
 import core.memory;
 
@@ -16,6 +17,7 @@
 
 import std.contracts;
 
+
 /* Also return EXP_CANT_INTERPRET if this fails
  */
 Expression Slice(Type type, Expression e1, Expression lwr, Expression upr)
@@ -78,4 +80,4 @@
 		}
     }
     return e;
-}
\ No newline at end of file
+}
--- a/dmd/expression/Util.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/dmd/expression/Util.d	Mon Apr 12 17:00:08 2010 +0100
@@ -129,7 +129,7 @@
  *	1	done
  */
 
-int overloadApply(FuncDeclaration fstart, int delegate(FuncDeclaration) dg)
+int overloadApply(FuncDeclaration fstart, int delegate(void*, FuncDeclaration) dg, void* param)
 {
     FuncDeclaration f;
     Declaration d;
@@ -141,7 +141,7 @@
 
 		if (fa)
 		{
-			if (overloadApply(fa.funcalias, dg))
+			if (overloadApply(fa.funcalias, dg, param))
 				return 1;
 			next = fa.overnext;
 		}
@@ -166,7 +166,7 @@
 					d.error("is aliased to a function");
 					break;		// BUG: should print error message?
 				}
-				if (dg(f))
+				if (dg(param, f))
 					return 1;
 
 				next = f.overnext;
@@ -186,7 +186,7 @@
     Expression ethis;
     Expressions arguments;
 	
-	int fp2(FuncDeclaration f)
+	int fp2(void*, FuncDeclaration f)
 	{   
 		MATCH match;
 
@@ -250,7 +250,7 @@
     Type t;		// type to match
     FuncDeclaration f;	// return value
 	
-	int fp1(FuncDeclaration f)
+	int fp1(void*, FuncDeclaration f)
 	{   
 		if (t.equals(f.type))
 		{	
@@ -283,7 +283,7 @@
     p.m = m;
     p.ethis = ethis;
     p.arguments = arguments;
-    overloadApply(fstart, &p.fp2);
+    overloadApply(fstart, &p.fp2, &p);
 }
 
 void templateResolve(Match* m, TemplateDeclaration td, Scope sc, Loc loc, Objects targsi, Expression ethis, Expressions arguments)
@@ -772,6 +772,25 @@
     }
 }
 
+/******************************
+ * Perform canThrow() on an array of Expressions.
+ */
+
+version (DMDV2) {
+bool arrayExpressionCanThrow(Expressions exps)
+{
+    if (exps)
+    {
+	for (size_t i = 0; i < exps.dim; i++)
+	{   Expression e = cast(Expression)exps.data[i];
+	    if (e && e.canThrow())
+		return true;
+	}
+    }
+    return false;
+}
+}
+
 /****************************************
  * Expand tuples.
  */
@@ -1239,7 +1258,7 @@
 	 * analogous to func.overloadResolveX().
 	 */
 
-	int fp3(FuncDeclaration f)
+	int fp3(void*, FuncDeclaration f)
 	{
 		TypeFunction tf = cast(TypeFunction)f.type;
 		if (inferApplyArgTypesY(tf, arguments) == 1)
@@ -1258,7 +1277,7 @@
 {
 	Param3 p3;
 	p3.arguments = arguments;
-    overloadApply(fstart, &p3.fp3);
+    overloadApply(fstart, &p3.fp3, cast(void*)arguments);
 }
 
 /******************************
@@ -1360,4 +1379,4 @@
 			}
 		}
     }
-}
\ No newline at end of file
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux_lib.mak	Mon Apr 12 17:00:08 2010 +0100
@@ -0,0 +1,572 @@
+
+C=backend
+TK=tk
+ROOT=root
+
+CC=g++ -m32
+#CC=/usr/bin/i686-unknown-linux-gnu-g++
+
+#OPT=-g -g3
+#OPT=-O2
+
+#COV=-fprofile-arcs -ftest-coverage
+
+GFLAGS = -Wno-deprecated -D__near= -D__pascal= -fno-exceptions -g -DDEBUG=1 $(COV)
+#GFLAGS = -Wno-deprecated -D__near= -D__pascal= -fno-exceptions -O2
+
+CFLAGS = $(GFLAGS) -I$(ROOT) -D__I86__=1 -DMARS=1 -DTARGET_LINUX=1 -D_DH
+MFLAGS = $(GFLAGS) -I$C -I$(TK) -D__I86__=1 -DMARS=1 -DTARGET_LINUX=1 -D_DH
+
+CH= $C/cc.h $C/global.h $C/parser.h $C/oper.h $C/code.h $C/type.h \
+	$C/dt.h $C/cgcv.h $C/el.h $C/iasm.h
+TOTALH=
+
+DMD_OBJS = \
+	access.o array.o attrib.o bcomplex.o bit.o blockopt.o \
+	cast.o code.o cg.o cg87.o cgcod.o cgcs.o cgcv.o cgelem.o cgen.o \
+	cgreg.o cgsched.o class.o cod1.o cod2.o cod3.o cod4.o cod5.o \
+	constfold.o irstate.o dchar.o cond.o debug.o \
+	declaration.o dsymbol.o dt.o dump.o e2ir.o ee.o eh.o el.o \
+	dwarf.o enum.o evalu8.o expression.o func.o gdag.o gflow.o \
+	glocal.o gloop.o glue.o gnuc.o go.o gother.o html.o iasm.o id.o \
+	identifier.o impcnvtab.o import.o inifile.o init.o inline.o \
+	lexer.o link.o lstring.o mangle.o mars.o rmem.o module.o msc.o mtype.o \
+	nteh.o cppmangle.o opover.o optimize.o os.o out.o outbuf.o \
+	parse.o ph.o ptrntab.o root.o rtlsym.o s2ir.o scope.o statement.o \
+	stringtable.o struct.o csymbol.o template.o tk.o tocsym.o todt.o \
+	type.o typinf.o util.o var.o version.o strtold.o utf.o staticassert.o \
+	unialpha.o toobj.o toctype.o toelfdebug.o entity.o doc.o macro.o \
+	hdrgen.o delegatize.o aa.o ti_achar.o toir.o interpret.o traits.o \
+	builtin.o clone.o aliasthis.o \
+	man.o arrayop.o port.o response.o async.o \
+	libelf.o elfobj.o
+
+SRC = win32.mak linux.mak osx.mak freebsd.mak solaris.mak \
+	mars.c enum.c struct.c dsymbol.c import.c idgen.c impcnvgen.c \
+	identifier.c mtype.c expression.c optimize.c template.h \
+	template.c lexer.c declaration.c cast.c cond.h cond.c link.c \
+	aggregate.h parse.c statement.c constfold.c version.h version.c \
+	inifile.c iasm.c module.c scope.c dump.c init.h init.c attrib.h \
+	attrib.c opover.c class.c mangle.c bit.c tocsym.c func.c inline.c \
+	access.c complex_t.h irstate.h irstate.c glue.c msc.c ph.c tk.c \
+	s2ir.c todt.c e2ir.c util.c identifier.h parse.h objfile.h \
+	scope.h enum.h import.h mars.h module.h mtype.h dsymbol.h \
+	declaration.h lexer.h expression.h irstate.h statement.h eh.c \
+	utf.h utf.c staticassert.h staticassert.c unialpha.c \
+	typinf.c toobj.c toctype.c tocvdebug.c toelfdebug.c entity.c \
+	doc.h doc.c macro.h macro.c hdrgen.h hdrgen.c arraytypes.h \
+	delegatize.c toir.h toir.c interpret.c traits.c cppmangle.c \
+	builtin.c clone.c lib.h libomf.c libelf.c libmach.c arrayop.c \
+	aliasthis.h aliasthis.c \
+	$C/cdef.h $C/cc.h $C/oper.h $C/ty.h $C/optabgen.c \
+	$C/global.h $C/parser.h $C/code.h $C/type.h $C/dt.h $C/cgcv.h \
+	$C/el.h $C/iasm.h $C/rtlsym.h $C/html.h \
+	$C/bcomplex.c $C/blockopt.c $C/cg.c $C/cg87.c \
+	$C/cgcod.c $C/cgcs.c $C/cgcv.c $C/cgelem.c $C/cgen.c $C/cgobj.c \
+	$C/cgreg.c $C/var.c $C/strtold.c \
+	$C/cgsched.c $C/cod1.c $C/cod2.c $C/cod3.c $C/cod4.c $C/cod5.c \
+	$C/code.c $C/symbol.c $C/debug.c $C/dt.c $C/ee.c $C/el.c \
+	$C/evalu8.c $C/go.c $C/gflow.c $C/gdag.c \
+	$C/gother.c $C/glocal.c $C/gloop.c $C/html.c $C/newman.c \
+	$C/nteh.c $C/os.c $C/out.c $C/outbuf.c $C/ptrntab.c $C/rtlsym.c \
+	$C/type.c $C/melf.h $C/mach.h $C/bcomplex.h \
+	$C/cdeflnx.h $C/outbuf.h $C/token.h $C/tassert.h \
+	$C/elfobj.c $C/cv4.h $C/dwarf2.h $C/cpp.h $C/exh.h $C/go.h \
+	$C/dwarf.c $C/dwarf.h $C/aa.h $C/aa.c $C/tinfo.h $C/ti_achar.c \
+	$C/machobj.c \
+	$(TK)/filespec.h $(TK)/mem.h $(TK)/list.h $(TK)/vec.h \
+	$(TK)/filespec.c $(TK)/mem.c $(TK)/vec.c $(TK)/list.c \
+	$(ROOT)/dchar.h $(ROOT)/dchar.c $(ROOT)/lstring.h \
+	$(ROOT)/lstring.c $(ROOT)/root.h $(ROOT)/root.c $(ROOT)/array.c \
+	$(ROOT)/rmem.h $(ROOT)/rmem.c $(ROOT)/port.h $(ROOT)/port.c \
+	$(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \
+	$(ROOT)/stringtable.h $(ROOT)/stringtable.c \
+	$(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c
+
+
+all: dmd
+
+dmd: id.o optabgen $(DMD_OBJS)
+	ar rs libdmd.a $(DMD_OBJS)
+
+clean:
+	rm -f $(DMD_OBJS) dmd optab.o id.o impcnvgen idgen id.c id.h \
+	impcnvtab.c optabgen debtab.c optab.c cdxxx.c elxxx.c fltables.c \
+	tytab.c core \
+	*.cov *.gcda *.gcno
+
+######## optabgen generates some source
+
+optabgen: $C/optabgen.c $C/cc.h $C/oper.h
+	$(CC) $(MFLAGS) $< -o optabgen
+	./optabgen
+
+debtab.c optab.c cdxxx.c elxxx.c fltables.c tytab.c : optabgen
+	./optabgen
+
+######## idgen generates some source
+
+id.h id.c : idgen
+	./idgen
+
+idgen : idgen.c
+	$(CC) idgen.c -o idgen
+
+id.o : id.h id.c
+	$(CC) -c $(CFLAGS) id.c
+
+######### impcnvgen generates some source
+
+impcnvtab.c : impcnvgen
+	./impcnvgen
+
+impcnvgen : mtype.h impcnvgen.c
+	$(CC) $(CFLAGS) impcnvgen.c -o impcnvgen
+
+#########
+
+aa.o: $C/aa.h $C/tinfo.h $C/aa.c
+	$(CC) -c $(MFLAGS) -I. $C/aa.c
+
+access.o: access.c
+	$(CC) -c $(CFLAGS) $<
+
+aliasthis.o: aliasthis.c
+	$(CC) -c $(CFLAGS) $<
+
+array.o: $(ROOT)/array.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+arrayop.o: arrayop.c
+	$(CC) -c $(CFLAGS) $<
+
+async.o: $(ROOT)/async.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+attrib.o: attrib.c
+	$(CC) -c $(CFLAGS) $<
+
+bcomplex.o: $C/bcomplex.c
+	$(CC) -c $(MFLAGS) $C/bcomplex.c
+
+bit.o: expression.h bit.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) bit.c
+
+blockopt.o: $C/blockopt.c
+	$(CC) -c $(MFLAGS) $C/blockopt.c
+
+builtin.o: builtin.c
+	$(CC) -c $(CFLAGS) $<
+
+cast.o: cast.c
+	$(CC) -c $(CFLAGS) $< 
+
+cg.o: fltables.c $C/cg.c
+	$(CC) -c $(MFLAGS) -I. $C/cg.c
+
+cg87.o: $C/cg87.c
+	$(CC) -c $(MFLAGS) $<
+
+cgcod.o: $C/cgcod.c
+	$(CC) -c $(MFLAGS) -I. $<
+
+cgcs.o: $C/cgcs.c
+	$(CC) -c $(MFLAGS) $<
+
+cgcv.o: $C/cgcv.c
+	$(CC) -c $(MFLAGS) $<
+
+cgelem.o: $C/rtlsym.h $C/cgelem.c
+	$(CC) -c $(MFLAGS) -I. $C/cgelem.c
+
+cgen.o: $C/rtlsym.h $C/cgen.c
+	$(CC) -c $(MFLAGS) $C/cgen.c
+
+cgobj.o: $C/cgobj.c
+	$(CC) -c $(MFLAGS) $<
+
+cgreg.o: $C/cgreg.c
+	$(CC) -c $(MFLAGS) $<
+
+cgsched.o: $C/rtlsym.h $C/cgsched.c
+	$(CC) -c $(MFLAGS) $C/cgsched.c
+
+class.o: class.c
+	$(CC) -c $(CFLAGS) $<
+
+clone.o: clone.c
+	$(CC) -c $(CFLAGS) $<
+
+cod1.o: $C/rtlsym.h $C/cod1.c
+	$(CC) -c $(MFLAGS) $C/cod1.c
+
+cod2.o: $C/rtlsym.h $C/cod2.c
+	$(CC) -c $(MFLAGS) $C/cod2.c
+
+cod3.o: $C/rtlsym.h $C/cod3.c
+	$(CC) -c $(MFLAGS) $C/cod3.c
+
+cod4.o: $C/cod4.c
+	$(CC) -c $(MFLAGS) $<
+
+cod5.o: $C/cod5.c
+	$(CC) -c $(MFLAGS) $<
+
+code.o: $C/code.c
+	$(CC) -c $(MFLAGS) $<
+
+constfold.o: constfold.c
+	$(CC) -c $(CFLAGS) $<
+
+irstate.o: irstate.h irstate.c
+	$(CC) -c $(MFLAGS) irstate.c
+
+csymbol.o : $C/symbol.c
+	$(CC) -c $(MFLAGS) $C/symbol.c -o csymbol.o
+
+dchar.o: $(ROOT)/dchar.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+cond.o: cond.c
+	$(CC) -c $(CFLAGS) $<
+
+cppmangle.o: cppmangle.c
+	$(CC) -c $(CFLAGS) $<
+
+debug.o: $C/debug.c
+	$(CC) -c $(MFLAGS) -I. $<
+
+declaration.o: declaration.c
+	$(CC) -c $(CFLAGS) $<
+
+delegatize.o: delegatize.c
+	$(CC) -c $(CFLAGS) $<
+
+doc.o: doc.c
+	$(CC) -c $(CFLAGS) $<
+
+dsymbol.o: dsymbol.c
+	$(CC) -c $(CFLAGS) $<
+
+dt.o: $C/dt.h $C/dt.c
+	$(CC) -c $(MFLAGS) $C/dt.c
+
+dump.o: dump.c
+	$(CC) -c $(CFLAGS) $<
+
+dwarf.o: $C/dwarf.h $C/dwarf.c
+	$(CC) -c $(MFLAGS) $C/dwarf.c
+
+e2ir.o: $C/rtlsym.h expression.h toir.h e2ir.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) e2ir.c
+
+ee.o: $C/ee.c
+	$(CC) -c $(MFLAGS) $<
+
+eh.o : $C/cc.h $C/code.h $C/type.h $C/dt.h eh.c
+	$(CC) -c $(MFLAGS) eh.c
+
+el.o: $C/rtlsym.h $C/el.h $C/el.c
+	$(CC) -c $(MFLAGS) $C/el.c
+
+elfobj.o: $C/elfobj.c
+	$(CC) -c $(MFLAGS) $<
+
+entity.o: entity.c
+	$(CC) -c $(CFLAGS) $<
+
+enum.o: enum.c
+	$(CC) -c $(CFLAGS) $<
+
+evalu8.o: $C/evalu8.c
+	$(CC) -c $(MFLAGS) $<
+
+expression.o: expression.c
+	$(CC) -c $(CFLAGS) $<
+
+func.o: func.c
+	$(CC) -c $(CFLAGS) $<
+
+gdag.o: $C/gdag.c
+	$(CC) -c $(MFLAGS) $<
+
+gflow.o: $C/gflow.c
+	$(CC) -c $(MFLAGS) $<
+
+#globals.o: globals.c
+#	$(CC) -c $(CFLAGS) $<
+
+glocal.o: $C/rtlsym.h $C/glocal.c
+	$(CC) -c $(MFLAGS) $C/glocal.c
+
+gloop.o: $C/gloop.c
+	$(CC) -c $(MFLAGS) $<
+
+glue.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h glue.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) glue.c
+
+gnuc.o: $(ROOT)/gnuc.h $(ROOT)/gnuc.c
+	$(CC) -c $(GFLAGS) $(ROOT)/gnuc.c
+
+go.o: $C/go.c
+	$(CC) -c $(MFLAGS) $<
+
+gother.o: $C/gother.c
+	$(CC) -c $(MFLAGS) $<
+
+hdrgen.o: hdrgen.c
+	$(CC) -c $(CFLAGS) $<
+
+html.o: $(CH) $(TOTALH) $C/html.h $C/html.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) $C/html.c
+
+iasm.o : $(CH) $(TOTALH) $C/iasm.h iasm.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) iasm.c
+
+identifier.o: identifier.c
+	$(CC) -c $(CFLAGS) $<
+
+impcnvtab.o: mtype.h impcnvtab.c
+	$(CC) -c $(CFLAGS) -I$(ROOT) impcnvtab.c
+
+import.o: import.c
+	$(CC) -c $(CFLAGS) $<
+
+inifile.o: inifile.c
+	$(CC) -c $(CFLAGS) $<
+
+init.o: init.c
+	$(CC) -c $(CFLAGS) $<
+
+inline.o: inline.c
+	$(CC) -c $(CFLAGS) $<
+
+interpret.o: interpret.c
+	$(CC) -c $(CFLAGS) $<
+
+lexer.o: lexer.c
+	$(CC) -c $(CFLAGS) $<
+
+libelf.o: libelf.c $C/melf.h
+	$(CC) -c $(CFLAGS) -I$C $<
+
+libmach.o: libmach.c $C/mach.h
+	$(CC) -c $(CFLAGS) -I$C $<
+
+link.o: link.c
+	$(CC) -c $(CFLAGS) $<
+
+lstring.o: $(ROOT)/lstring.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+machobj.o: $C/machobj.c
+	$(CC) -c $(MFLAGS) $<
+
+macro.o: macro.c
+	$(CC) -c $(CFLAGS) $<
+
+man.o: $(ROOT)/man.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+mangle.o: mangle.c
+	$(CC) -c $(CFLAGS) $<
+
+mars.o: mars.c
+	$(CC) -c $(CFLAGS) $<
+
+rmem.o: $(ROOT)/rmem.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $(ROOT)/rmem.c
+	
+module.o: $(TOTALH) $C/html.h module.c
+	$(CC) -c $(CFLAGS) -I$C module.c
+
+msc.o: $(CH) mars.h msc.c
+	$(CC) -c $(MFLAGS) msc.c
+
+mtype.o: mtype.c
+	$(CC) -c $(CFLAGS) $<
+
+nteh.o: $C/rtlsym.h $C/nteh.c
+	$(CC) -c $(MFLAGS) $C/nteh.c
+
+opover.o: opover.c
+	$(CC) -c $(CFLAGS) $<
+
+optimize.o: optimize.c
+	$(CC) -c $(CFLAGS) $<
+
+os.o: $C/os.c
+	$(CC) -c $(MFLAGS) $<
+
+out.o: $C/out.c
+	$(CC) -c $(MFLAGS) $<
+
+outbuf.o : $C/outbuf.h $C/outbuf.c
+	$(CC) -c $(MFLAGS) $C/outbuf.c
+
+parse.o: parse.c
+	$(CC) -c $(CFLAGS) $<
+
+ph.o: ph.c
+	$(CC) -c $(MFLAGS) $<
+
+port.o: $(ROOT)/port.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+ptrntab.o: $C/iasm.h $C/ptrntab.c
+	$(CC) -c $(MFLAGS) $C/ptrntab.c
+
+response.o: $(ROOT)/response.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+root.o: $(ROOT)/root.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+rtlsym.o: $C/rtlsym.h $C/rtlsym.c
+	$(CC) -c $(MFLAGS) $C/rtlsym.c
+
+s2ir.o : $C/rtlsym.h statement.h s2ir.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) s2ir.c
+
+scope.o: scope.c
+	$(CC) -c $(CFLAGS) $<
+
+statement.o: statement.c
+	$(CC) -c $(CFLAGS) $<
+
+staticassert.o: staticassert.h staticassert.c
+	$(CC) -c $(CFLAGS) staticassert.c
+
+stringtable.o: $(ROOT)/stringtable.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+strtold.o: $C/strtold.c
+	$(CC) -c $C/strtold.c
+
+struct.o: struct.c
+	$(CC) -c $(CFLAGS) $<
+
+template.o: template.c
+	$(CC) -c $(CFLAGS) $<
+
+ti_achar.o: $C/tinfo.h $C/ti_achar.c
+	$(CC) -c $(MFLAGS) -I. $C/ti_achar.c
+
+tk.o: tk.c
+	$(CC) -c $(MFLAGS) tk.c
+
+tocsym.o: $(CH) $(TOTALH) mars.h module.h tocsym.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) tocsym.c
+
+toctype.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h toctype.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) toctype.c
+
+todt.o : mtype.h expression.h $C/dt.h todt.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) todt.c
+
+toelfdebug.o: $(CH) $(TOTALH) mars.h toelfdebug.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) toelfdebug.c
+
+toir.o: $C/rtlsym.h expression.h toir.h toir.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) toir.c
+
+toobj.o: $(CH) $(TOTALH) mars.h module.h toobj.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) toobj.c
+
+traits.o: $(TOTALH) traits.c
+	$(CC) -c $(CFLAGS) $<
+
+type.o: $C/type.c
+	$(CC) -c $(MFLAGS) $C/type.c
+
+typinf.o: $(CH) $(TOTALH) mars.h module.h mtype.h typinf.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) typinf.c
+
+util.o: util.c
+	$(CC) -c $(MFLAGS) $<
+
+utf.o: utf.h utf.c
+	$(CC) -c $(CFLAGS) utf.c
+
+unialpha.o: unialpha.c
+	$(CC) -c $(CFLAGS) $<
+
+var.o: $C/var.c optab.c
+	$(CC) -c $(MFLAGS) -I. $C/var.c
+
+version.o: version.c
+	$(CC) -c $(CFLAGS) $<
+
+######################################################
+
+gcov:
+	gcov access.c
+	gcov aliasthis.c
+	gcov arrayop.c
+	gcov attrib.c
+	gcov bit.c
+	gcov builtin.c
+	gcov cast.c
+	gcov class.c
+	gcov clone.c
+	gcov cond.c
+	gcov constfold.c
+	gcov declaration.c
+	gcov delegatize.c
+	gcov doc.c
+	gcov dsymbol.c
+	gcov dump.c
+	gcov e2ir.c
+	gcov eh.c
+	gcov entity.c
+	gcov enum.c
+	gcov expression.c
+	gcov func.c
+	gcov glue.c
+	gcov iasm.c
+	gcov identifier.c
+	gcov import.c
+	gcov inifile.c
+	gcov init.c
+	gcov inline.c
+	gcov interpret.c
+	gcov irstate.c
+	gcov lexer.c
+	gcov libelf.c
+	gcov link.c
+	gcov macro.c
+	gcov mangle.c
+	gcov mars.c
+	gcov module.c
+	gcov msc.c
+	gcov mtype.c
+	gcov opover.c
+	gcov optimize.c
+	gcov parse.c
+	gcov ph.c
+	gcov scope.c
+	gcov statement.c
+	gcov staticassert.c
+	gcov s2ir.c
+	gcov struct.c
+	gcov template.c
+	gcov tk.c
+	gcov tocsym.c
+	gcov todt.c
+	gcov toobj.c
+	gcov toctype.c
+	gcov toelfdebug.c
+	gcov typinf.c
+	gcov unialpha.c
+	gcov utf.c
+	gcov util.c
+	gcov version.c
+
+#	gcov hdrgen.c
+#	gcov tocvdebug.c
+
+######################################################
+
+zip:
+	-rm -f dmdsrc.zip
+	zip dmdsrc $(SRC)
--- a/main.d	Mon Apr 12 16:29:33 2010 +0400
+++ b/main.d	Mon Apr 12 17:00:08 2010 +0100
@@ -57,8 +57,12 @@
 
 shared bool _d_isHalting = false;
 
-import win32.windows;
-
+version (Windows)
+{
+   import win32.windows;
+}
+/* Link to druntimes main() */
+/+
 extern (C) int main(int argc, char **argv)
 {
     char[][] args;
@@ -141,9 +145,10 @@
 
     return result;
 }
-
++/
 int main(string[] args)
 {
+    GC.disable();
     Array files = new Array();
     Array libmodules = new Array();
     Module m;
@@ -179,7 +184,7 @@
 
 version (TARGET_WINDOS) {
     global.params.defaultlibname = "phobos";
-} else version (XXX) { //#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+} else version (POSIX) { //#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
     global.params.defaultlibname = "phobos2";
 } else version (TARGET_NET) {
 } else {
@@ -228,8 +233,8 @@
 
 version (_WIN32) {
     inifile(args[0], "sc.ini");
-} else version (XXX) {///linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
-    inifile(argv[0], "dmd.conf");
+} else version (POSIX) {///linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+    inifile(args[0], "dmd.conf");
 } else {
         static assert (false, "fix this");
 }
@@ -1102,4 +1107,4 @@
     }
 
     return status;
-}
\ No newline at end of file
+}