@@ -314,11 +314,7 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
314
314
for (unsigned I = 0 ; I != 2 ; ++I) {
315
315
if (!this ->emitGetLocal (PT_Ptr, *SubExprOffset, CE))
316
316
return false ;
317
- if (!this ->emitConstUint8 (I, CE))
318
- return false ;
319
- if (!this ->emitArrayElemPtrPopUint8 (CE))
320
- return false ;
321
- if (!this ->emitLoadPop (SourceElemT, CE))
317
+ if (!this ->emitArrayElemPop (SourceElemT, I, CE))
322
318
return false ;
323
319
324
320
// Do the cast.
@@ -729,11 +725,8 @@ bool ByteCodeExprGen<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {
729
725
if (IsComplex) {
730
726
if (!this ->emitGetLocal (PT_Ptr, Offset, E))
731
727
return false ;
732
- if (!this ->emitConstUint8 (ElemIndex, E))
733
- return false ;
734
- if (!this ->emitArrayElemPtrPopUint8 (E))
735
- return false ;
736
- return this ->emitLoadPop (classifyComplexElementType (E->getType ()), E);
728
+ return this ->emitArrayElemPop (classifyComplexElementType (E->getType ()),
729
+ ElemIndex, E);
737
730
}
738
731
if (ElemIndex == 0 )
739
732
return this ->emitGetLocal (classifyPrim (E->getType ()), Offset, E);
@@ -3127,16 +3120,16 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
3127
3120
3128
3121
if (!this ->visit (SubExpr))
3129
3122
return false ;
3130
- if (!this ->emitConstUint8 (1 , E))
3131
- return false ;
3132
- if (!this ->emitArrayElemPtrPopUint8 (E))
3133
- return false ;
3123
+
3124
+ if (SubExpr->isLValue ()) {
3125
+ if (!this ->emitConstUint8 (1 , E))
3126
+ return false ;
3127
+ return this ->emitArrayElemPtrPopUint8 (E);
3128
+ }
3134
3129
3135
3130
// Since our _Complex implementation does not map to a primitive type,
3136
3131
// we sometimes have to do the lvalue-to-rvalue conversion here manually.
3137
- if (!SubExpr->isLValue ())
3138
- return this ->emitLoadPop (classifyPrim (E->getType ()), E);
3139
- return true ;
3132
+ return this ->emitArrayElemPop (classifyPrim (E->getType ()), 1 , E);
3140
3133
}
3141
3134
case UO_Extension:
3142
3135
return this ->delegate (SubExpr);
@@ -3347,17 +3340,15 @@ bool ByteCodeExprGen<Emitter>::emitComplexReal(const Expr *SubExpr) {
3347
3340
3348
3341
if (!this ->visit (SubExpr))
3349
3342
return false ;
3350
- if (!this ->emitConstUint8 (0 , SubExpr))
3351
- return false ;
3352
- if (!this ->emitArrayElemPtrPopUint8 (SubExpr))
3353
- return false ;
3343
+ if (SubExpr->isLValue ()) {
3344
+ if (!this ->emitConstUint8 (0 , SubExpr))
3345
+ return false ;
3346
+ return this ->emitArrayElemPtrPopUint8 (SubExpr);
3347
+ }
3354
3348
3355
- // Since our _Complex implementation does not map to a primitive type,
3356
- // we sometimes have to do the lvalue-to-rvalue conversion here manually.
3357
- if (!SubExpr->isLValue ())
3358
- return this ->emitLoadPop (classifyComplexElementType (SubExpr->getType ()),
3359
- SubExpr);
3360
- return true ;
3349
+ // Rvalue, load the actual element.
3350
+ return this ->emitArrayElemPop (classifyComplexElementType (SubExpr->getType ()),
3351
+ 0 , SubExpr);
3361
3352
}
3362
3353
3363
3354
template <class Emitter >
@@ -3366,11 +3357,7 @@ bool ByteCodeExprGen<Emitter>::emitComplexBoolCast(const Expr *E) {
3366
3357
PrimType ElemT = classifyComplexElementType (E->getType ());
3367
3358
// We emit the expression (__real(E) != 0 || __imag(E) != 0)
3368
3359
// for us, that means (bool)E[0] || (bool)E[1]
3369
- if (!this ->emitConstUint8 (0 , E))
3370
- return false ;
3371
- if (!this ->emitArrayElemPtrUint8 (E))
3372
- return false ;
3373
- if (!this ->emitLoadPop (ElemT, E))
3360
+ if (!this ->emitArrayElem (ElemT, 0 , E))
3374
3361
return false ;
3375
3362
if (ElemT == PT_Float) {
3376
3363
if (!this ->emitCastFloatingIntegral (PT_Bool, E))
@@ -3385,11 +3372,7 @@ bool ByteCodeExprGen<Emitter>::emitComplexBoolCast(const Expr *E) {
3385
3372
if (!this ->jumpTrue (LabelTrue))
3386
3373
return false ;
3387
3374
3388
- if (!this ->emitConstUint8 (1 , E))
3389
- return false ;
3390
- if (!this ->emitArrayElemPtrPopUint8 (E))
3391
- return false ;
3392
- if (!this ->emitLoadPop (ElemT, E))
3375
+ if (!this ->emitArrayElemPop (ElemT, 1 , E))
3393
3376
return false ;
3394
3377
if (ElemT == PT_Float) {
3395
3378
if (!this ->emitCastFloatingIntegral (PT_Bool, E))
0 commit comments