Fixed some more intialization things
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 29 Apr 2000 22:25:35 +0000 (22:25 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 29 Apr 2000 22:25:35 +0000 (22:25 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@239 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCglue.c
src/SDCCval.c
src/SDCCval.h

index 7d032076a57093c90a5895580e1538fd1a917f77..4920cd18d98aea3fe4e9a5f2c4d0997e76e7d8c8 100644 (file)
@@ -299,7 +299,21 @@ value *initPointer (initList *ilist)
            expr->left->opval.op == PTR_OP &&
            IS_ADDRESS_OF_OP(expr->left->left))
                return valForStructElem(expr->left->left->left,
            expr->left->opval.op == PTR_OP &&
            IS_ADDRESS_OF_OP(expr->left->left))
                return valForStructElem(expr->left->left->left,
-                                       expr->left->right);     
+                                       expr->left->right);
+
+    }
+    /* case 3. (((char *) &a) +/- constant) */
+    if (IS_AST_OP(expr) && 
+       (expr->opval.op == '+' || expr->opval.op == '-') &&
+       IS_AST_OP(expr->left) && expr->left->opval.op == CAST &&
+       IS_AST_OP(expr->left->right) && 
+       expr->left->right->opval.op == '&' &&
+       IS_AST_LIT_VALUE(expr->right)) {
+       
+       return valForCastAggr(expr->left->right->left,
+                             expr->left->left->opval.lnk,
+                             expr->right,expr->opval.op);
+       
     }
 
  wrong:    
     }
 
  wrong:    
index daf3f930f4c6497b6ea7bbbde5a9056370864bc7..69e9a53ba4e9b1a02d72c60e1f11a61ec055d6b9 100644 (file)
@@ -1290,3 +1290,25 @@ value *valForStructElem(ast *structT, ast *elemT)
     val->etype = getSpec(val->type);
     return val; 
 }
     val->etype = getSpec(val->type);
     return val; 
 }
+
+/*-----------------------------------------------------------------*/
+/* valForCastAggr - will return value for a cast of an aggregate   */
+/*                  plus minus a constant                          */
+/*-----------------------------------------------------------------*/
+value *valForCastAggr (ast *aexpr, link *type, ast *cnst, int op)
+{
+    value *val;
+
+    if (!IS_AST_SYM_VALUE(aexpr)) return NULL;
+    if (!IS_AST_LIT_VALUE(cnst)) return NULL;
+
+    val = newValue();
+
+    sprintf(val->name,"(%s %c %d)",
+          AST_SYMBOL(aexpr)->rname, op,
+          getSize(type->next)*(int)AST_LIT_VALUE(cnst));
+
+    val->type = type;
+    val->etype = getSpec(val->type);
+    return val;
+}
index 23b03936be455fb3f52a54ecc238d211e68c9e24..3751bc6d654237cf14973ef4a645c6129a33ae52 100644 (file)
@@ -95,5 +95,5 @@ value                   *constFloatVal    (char *               );
 int                      getNelements     (link *, initList *   );
 value                   *valForArray      (struct ast  *        );
 value                   *valForStructElem (struct ast  *, struct ast *);
 int                      getNelements     (link *, initList *   );
 value                   *valForArray      (struct ast  *        );
 value                   *valForStructElem (struct ast  *, struct ast *);
+value                   *valForCastAggr   (struct ast *, link *, struct ast *, int ) ;
 #endif
 #endif