Commits

Iain Buclaw committed d53a8be

D2 postblit updates.

Comments (0)

Files changed (1)

 #if V2
 	    if (op != TOKblit)
 	    {
-		if (needsPostblit(elem_type))
+		if (needsPostblit(elem_type) != NULL)
 		{   
 		    tree e;
 		    AddrOfExpr aoe;
 	    return irs->compound(set_exp, dyn_array_exp);
 	} else {
 #if V2
-	    if (needsPostblit(elem_type) && op != TOKblit)
+	    if (op != TOKblit && needsPostblit(elem_type) != NULL)
 	    {
 		tree args[3] = {
 		    irs->typeinfoReference(elem_type),
 StructLiteralExp::toElem(IRState *irs)
 {
     assert(irs->typesSame(type->toBasetype(), sd->type->toBasetype()));
-    
+
     tree ctor = make_node( CONSTRUCTOR );
     CtorEltMaker ce;
     TREE_TYPE( ctor ) = type->toCtype();
 	    {
 		VarDeclaration * fld = (VarDeclaration *) sd->fields.data[i];
 #if V2
-		bool postblit = false;
+		Type * tb = fld->type->toBasetype();
 		StructDeclaration * sd;
-		Type * tb = fld->type->toBasetype();
-
-		if (sd = needsPostblit(tb))
-		    postblit = true;
-
-		if (tb->ty == Tstruct)
+		if ((sd = needsPostblit(tb)) != NULL)
 		{
-		    // Call postblit()
-		    if (sd)
+		    // Call postblit() on e
+		    if (tb->ty == Tstruct)
 		    {
+			Array args;
 			FuncDeclaration * fd = sd->postblit;
-			Array args;
-			tree result;
-			//result = irs->call(fd, /* e1? */ & args);
+			tree ec = save_expr(e->toElem(irs));
+			irs->doExp(irs->call(fd, irs->addressOf(ec), & args));
+			ce.cons(fld->csym->Stree, irs->convertTo(ec, e->type, fld->type));
 		    }
-		}
-		else if (postblit)
-		{
-		    /* Not implemented yet */
+		    else
+		    {
+			/* Not implemented yet */
+			assert(0);
+		    }
 		}
 		else
 #endif