#include <math.h>
#include <stdlib.h>
#include <limits.h>
+#include "newalloc.h"
int cNestLevel ;
{
value *val ;
- ALLOC(val,sizeof(value));
+ val = Safe_calloc(sizeof(value));
return val ;
}
initList *nilist;
- ALLOC(nilist,sizeof(initList));
+ nilist = Safe_calloc(sizeof(initList));
nilist->type = type ;
nilist->lineno = yylineno ;
SPEC_NOUN(val->etype) = V_CHAR ;
SPEC_SCLS(val->etype) = S_LITERAL;
- ALLOC_ATOMIC(SPEC_CVAL(val->etype).v_char,strlen(s)+1);
+ SPEC_CVAL(val->etype).v_char = Safe_calloc(strlen(s)+1);
copyStr (SPEC_CVAL(val->etype).v_char,s);
return val;
}
/*------------------------------------------------------------------*/
value *reverseValWithType ( value *val )
{
- link *type ;
- link *etype;
+ sym_link *type ;
+ sym_link *etype;
if (!val)
return NULL ;
/*------------------------------------------------------------------*/
/* valFromType - creates a value from type given */
/*------------------------------------------------------------------*/
-value *valFromType ( link *type)
+value *valFromType ( sym_link *type)
{
value *val = newValue();
val->type = copyLinkChain(type);
/*------------------------------------------------------------------*/
/* valCastLiteral - casts a literal value to another type */
/*------------------------------------------------------------------*/
-value *valCastLiteral (link *dtype, double fval)
+value *valCastLiteral (sym_link *dtype, double fval)
{
value *val ;
/*------------------------------------------------------------------*/
/* getNelements - determines # of elements from init list */
/*------------------------------------------------------------------*/
-int getNelements (link *type,initList *ilist)
+int getNelements (sym_link *type,initList *ilist)
{
- link *etype = getSpec(type);
+ sym_link *etype = getSpec(type);
int i;
if (! ilist)
val->type = newLink();
if (SPEC_SCLS(arrExpr->left->etype) == S_CODE) {
DCL_TYPE(val->type) = CPOINTER ;
- DCL_PTR_CONST(val->type) = 1;
+ DCL_PTR_CONST(val->type) = port->mem.code_ro;
}
else
if (SPEC_SCLS(arrExpr->left->etype) == S_XDATA)
if (SPEC_SCLS(arrExpr->left->etype) == S_IDATA)
DCL_TYPE(val->type) = IPOINTER ;
else
- if (SPEC_SCLS(arrExpr->left->etype) == S_FLASH)
- DCL_TYPE(val->type) = FLPOINTER ;
+ if (SPEC_SCLS(arrExpr->left->etype) == S_EEPROM)
+ DCL_TYPE(val->type) = EEPPOINTER ;
else
DCL_TYPE(val->type) = POINTER ;
val->type->next = arrExpr->left->ftype;
val->type = newLink();
if (SPEC_SCLS(structT->etype) == S_CODE) {
DCL_TYPE(val->type) = CPOINTER ;
- DCL_PTR_CONST(val->type) = 1;
+ DCL_PTR_CONST(val->type) = port->mem.code_ro;
}
else
if (SPEC_SCLS(structT->etype) == S_XDATA)
if (SPEC_SCLS(structT->etype) == S_IDATA)
DCL_TYPE(val->type) = IPOINTER ;
else
- if (SPEC_SCLS(structT->etype) == S_FLASH)
- DCL_TYPE(val->type) = FLPOINTER ;
+ if (SPEC_SCLS(structT->etype) == S_EEPROM)
+ DCL_TYPE(val->type) = EEPPOINTER ;
else
DCL_TYPE(val->type) = POINTER ;
val->type->next = sym->type;
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, sym_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;
+}