comparison dmd/cast.c @ 94:61615fa85940 trunk

[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca"). Added support for array .sort and .reverse properties. Fixed some bugs with pointer arithmetic. Disabled some DMD AST optimizations that was messing things up, destroying valuable information. Added a KDevelop project file, this is what I use for coding LLVMDC now :) Other minor stuff.
author lindquist
date Mon, 12 Nov 2007 06:32:46 +0100
parents 788401029ecf
children 5825d48b27d1
comparison
equal deleted inserted replaced
93:08508eebbb3e 94:61615fa85940
1114 e2 = new MulExp(loc, e2, new IntegerExp(0, stride, t)); 1114 e2 = new MulExp(loc, e2, new IntegerExp(0, stride, t));
1115 #endif 1115 #endif
1116 e2->type = t; 1116 e2->type = t;
1117 type = e1->type; 1117 type = e1->type;
1118 } 1118 }
1119 else if (t2b->ty && t1b->isintegral()) 1119 else if (t2b->ty == Tpointer && t1b->isintegral())
1120 { // Need to adjust operator by the stride 1120 { // Need to adjust operator by the stride
1121 // Replace (int + ptr) with (ptr + (int * stride)) 1121 // Replace (int + ptr) with (ptr + (int * stride))
1122 Type *t = Type::tptrdiff_t; 1122 Type *t = Type::tptrdiff_t;
1123 Expression *e; 1123 Expression *e;
1124 1124
1125 stride = t2b->next->size(); 1125 stride = t2b->next->size();
1126 if (!t->equals(t1b)) 1126 if (!t->equals(t1b))
1127 e = e1->castTo(sc, t); 1127 e = e1->castTo(sc, t);
1128 else 1128 else
1129 e = e1; 1129 e = e1;
1130 #if !IN_LLVM
1130 if (t2b->next->isbit()) 1131 if (t2b->next->isbit())
1131 // BUG: should add runtime check for misaligned offsets 1132 // BUG: should add runtime check for misaligned offsets
1132 e = new UshrExp(loc, e, new IntegerExp(0, 3, t)); 1133 e = new UshrExp(loc, e, new IntegerExp(0, 3, t));
1133 else 1134 else
1134 e = new MulExp(loc, e, new IntegerExp(0, stride, t)); 1135 e = new MulExp(loc, e, new IntegerExp(0, stride, t));
1136 #endif
1135 e->type = t; 1137 e->type = t;
1136 type = e2->type; 1138 type = e2->type;
1137 e1 = e2; 1139 e1 = e2;
1138 e2 = e; 1140 e2 = e;
1139 } 1141 }