DCL_TYPE($3) = POINTER ;
break;
case S_CODE:
- DCL_PTR_CONST($3) = 1;
DCL_TYPE($3) = CPOINTER ;
break;
case S_EEPROM:
}
RRVAL (tree) = 1;
COPYTYPE (TTYPE (tree), TETYPE (tree), LTYPE (tree)->next);
- if (IS_PTR(LTYPE(tree))) {
- SPEC_CONST (TETYPE (tree)) = DCL_PTR_CONST (LTYPE(tree));
- }
return tree;
/*------------------------------------------------------------------*/
{
sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
COPYTYPE (TTYPE (tree), TETYPE (tree), ltc);
- if (!tree->initMode && IS_CONSTANT(TETYPE(tree)))
- werror (E_CODE_WRITE, "++/--");
+ if (!tree->initMode && IS_CONSTANT (TTYPE (tree)))
+ werror (E_CODE_WRITE, tree->opval.op==INC_OP ? "++" : "--");
if (tree->right)
RLVAL (tree) = 1;
goto errorTreeReturn;
}
if (SPEC_SCLS (tree->left->etype) == S_CODE)
- {
- DCL_TYPE (p) = CPOINTER;
- DCL_PTR_CONST (p) = port->mem.code_ro;
- }
+ DCL_TYPE (p) = CPOINTER;
else if (SPEC_SCLS (tree->left->etype) == S_XDATA)
DCL_TYPE (p) = FPOINTER;
else if (SPEC_SCLS (tree->left->etype) == S_XSTACK)
p->next = LTYPE (tree);
TTYPE (tree) = p;
TETYPE (tree) = getSpec (TTYPE (tree));
- DCL_PTR_CONST (p) = SPEC_CONST (TETYPE (tree));
- DCL_PTR_VOLATILE (p) = SPEC_VOLATILE (TETYPE (tree));
LLVAL (tree) = 1;
TLVAL (tree) = 1;
return tree;
TTYPE (tree) = copyLinkChain ((IS_PTR (LTYPE (tree)) || IS_ARRAY (LTYPE (tree))) ?
LTYPE (tree)->next : NULL);
TETYPE (tree) = getSpec (TTYPE (tree));
- SPEC_CONST (TETYPE (tree)) = DCL_PTR_CONST (LTYPE(tree));
return tree;
}
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
- if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
- werror (E_CODE_WRITE, " ");
+ if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ werror (E_CODE_WRITE, *tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "*= or /=");
+ werror (E_LVALUE_REQUIRED, *tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
goto errorTreeReturn;
}
LLVAL (tree) = 1;
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
- if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
- werror (E_CODE_WRITE, " ");
+ if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ werror (E_CODE_WRITE, "&= or |= or ^= or >>= or <<=");
if (LRVAL (tree))
{
computeType (LTYPE (tree),
RTYPE (tree)));
- if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
- werror (E_CODE_WRITE, " ");
+ if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ werror (E_CODE_WRITE, "-=");
if (LRVAL (tree))
{
computeType (LTYPE (tree),
RTYPE (tree)));
- if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
- werror (E_CODE_WRITE, " ");
+ if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ werror (E_CODE_WRITE, "+=");
if (LRVAL (tree))
{
RRVAL (tree) = 1;
LLVAL (tree) = 1;
if (!tree->initMode ) {
- if ((IS_SPEC(LETYPE(tree)) && IS_CONSTANT (LETYPE (tree))))
- werror (E_CODE_WRITE, " ");
+ if (IS_CONSTANT (LTYPE (tree)))
+ werror (E_CODE_WRITE, "=");
}
if (LRVAL (tree))
{
}
-#define INDENT(x,f) { int i ; for (i=0;i < x; i++) fprintf(f," "); }
+#define INDENT(x,f) { int i ; fprintf (f, "%d:", tree->lineno); for (i=0;i < x; i++) fprintf(f," "); }
/*-----------------------------------------------------------------*/
/* ast_print : prints the ast (for debugging purposes) */
/*-----------------------------------------------------------------*/
ast_print(tree->right,outfile,indent+2);
return;
case OR_ASSIGN:
- fprintf(outfile,"ORASS(*=) (%p) type (",tree);
+ fprintf(outfile,"ORASS(|=) (%p) type (",tree);
printTypeChain(tree->ftype,outfile);
fprintf(outfile,")\n");
ast_print(tree->left,outfile,indent+2);
ast_print(tree->right,outfile,indent+2);
return;
case XOR_ASSIGN:
- fprintf(outfile,"XORASS(*=) (%p) type (",tree);
+ fprintf(outfile,"XORASS(^=) (%p) type (",tree);
printTypeChain(tree->ftype,outfile);
fprintf(outfile,")\n");
ast_print(tree->left,outfile,indent+2);
ast_print(tree->right,outfile,indent+2);
return;
case LEFT_ASSIGN:
- fprintf(outfile,"LSHFTASS(*=) (%p) type (",tree);
+ fprintf(outfile,"LSHFTASS(<<=) (%p) type (",tree);
printTypeChain(tree->ftype,outfile);
fprintf(outfile,")\n");
ast_print(tree->left,outfile,indent+2);
val->type = newLink ();
if (SPEC_SCLS (expr->left->etype) == S_CODE) {
DCL_TYPE (val->type) = CPOINTER;
- DCL_PTR_CONST (val->type) = port->mem.code_ro;
}
else if (SPEC_SCLS (expr->left->etype) == S_XDATA)
DCL_TYPE (val->type) = FPOINTER;
val->type = newLink ();
if (SPEC_SCLS (expr->right->etype) == S_CODE) {
DCL_TYPE (val->type) = CPOINTER;
- DCL_PTR_CONST (val->type) = port->mem.code_ro;
}
else if (SPEC_SCLS (expr->right->etype) == S_XDATA)
DCL_TYPE (val->type) = FPOINTER;
if (IS_ITEMP (op) && !chkTemp)
return 0;
- opetype = getSpec (optype = operandType (op));
-
- if (IS_PTR (optype) && DCL_PTR_VOLATILE (optype))
- return 1;
-
- if (IS_VOLATILE (opetype))
- return 1;
- return 0;
+ return IS_VOLATILE(operandType(op));
}
/*-----------------------------------------------------------------*/
ptype = newLink ();
ptype->next = type;
- /* if the output class is generic */
+
+#ifdef JWK
+ /* if the output class is code */
if ((DCL_TYPE (ptype) = PTR_TYPE (SPEC_OCLS (etype))) == CPOINTER)
DCL_PTR_CONST (ptype) = port->mem.code_ro;
/* the variable was volatile then pointer to volatile */
if (IS_VOLATILE (etype))
DCL_PTR_VOLATILE (ptype) = 1;
+#else
+ DCL_TYPE (ptype) = PTR_TYPE (SPEC_OCLS (etype));
+#endif
+
return ptype;
}
sym_link *optype = operandType (op);
sym_link *opetype = getSpec (optype);
+#ifdef JWK
/* set the pointer depending on the storage class */
if ((DCL_TYPE (optype) = PTR_TYPE (SPEC_OCLS (opetype))) == CPOINTER)
DCL_PTR_CONST (optype) = port->mem.code_ro;
-
/* if the variable was declared a constant */
/* then the pointer points to a constant */
if (IS_CONSTANT (opetype))
/* the variable was volatile then pointer to volatile */
if (IS_VOLATILE (opetype))
DCL_PTR_VOLATILE (optype) = 1;
+#else
+ DCL_TYPE (optype) = PTR_TYPE (SPEC_OCLS (opetype));
+#endif
+
op->isaddr = 0;
return op;
}
p = newLink ();
p->class = DECLARATOR;
+#ifdef JWK
/* set the pointer depending on the storage class */
if ((DCL_TYPE (p) = PTR_TYPE (SPEC_OCLS (opetype))) == CPOINTER)
DCL_PTR_CONST (p) = port->mem.code_ro;
if (IS_VOLATILE (opetype))
DCL_PTR_VOLATILE (p) = 1;
+#else
+ DCL_TYPE (p) = PTR_TYPE (SPEC_OCLS (opetype));
+#endif
+
p->next = copyLinkChain (optype);
storage class of the type */
if (IS_SPEC (type))
{
- DCL_PTR_CONST (ptr) = SPEC_CONST (type);
- DCL_PTR_VOLATILE (ptr) = SPEC_VOLATILE (type);
switch (SPEC_SCLS (type))
{
case S_XDATA:
DCL_TYPE (ptr) = POINTER;
break;
case S_CODE:
- DCL_PTR_CONST (ptr) = port->mem.code_ro;
DCL_TYPE (ptr) = CPOINTER;
break;
case S_EEPROM:
}
/* if the type is an unknown pointer and has
- a tspec then take the storage class const & volatile
+ a tspec then take the const & volatile
attribute from the tspec & make it those of this
symbol */
+
if (p &&
- !IS_SPEC (p) &&
- //DCL_TYPE (p) == UPOINTER &&
+ IS_DECL (p) &&
+ DCL_TYPE (p) == UPOINTER &&
DCL_TSPEC (p))
{
+ // only for declarators
+ wassert (IS_DECL(sym->type));
+
if (!IS_SPEC (sym->etype))
{
sym->etype = sym->etype->next = newLink ();
sym->etype->class = SPECIFIER;
}
- SPEC_SCLS (sym->etype) = SPEC_SCLS (DCL_TSPEC (p));
- SPEC_CONST (sym->etype) = SPEC_CONST (DCL_TSPEC (p));
- SPEC_VOLATILE (sym->etype) = SPEC_VOLATILE (DCL_TSPEC (p));
+
+ DCL_PTR_CONST (sym->type) = SPEC_CONST (DCL_TSPEC (p));
+ DCL_PTR_VOLATILE (sym->type) = SPEC_VOLATILE (DCL_TSPEC (p));
DCL_TSPEC (p) = NULL;
}
break;
}
}
- /* search entry in list before "type" */
- for (search = start; search && search->next != type;)
- search = search->next;
- type = search;
- if (type)
- fputc (' ', of);
+ /* search entry in list before "type" */
+ for (search = start; search && search->next != type;)
+ search = search->next;
+ type = search;
+ if (type)
+ fputc (' ', of);
}
if (nlr)
fprintf (of, "\n");
{
DECLARATOR_TYPE dcl_type; /* POINTER,ARRAY or FUNCTION */
unsigned int num_elem; /* # of elems if type==array */
- short ptr_const:1; /* pointer is constant */
- short ptr_volatile:1; /* pointer is volatile */
+ unsigned ptr_const:1; /* pointer is constant */
+ unsigned ptr_volatile:1; /* pointer is volatile */
struct sym_link *tspec; /* pointer type specifier */
}
declarator;
unsigned hasVargs:1; /* functions has varargs */
unsigned calleeSaves:1; /* functions uses callee save */
unsigned hasbody:1; /* function body defined */
- //unsigned ret:1; /* return statement for a function */
unsigned hasFcall:1; /* does it call other functions */
unsigned reent:1; /* function is reentrant */
unsigned naked:1; /* naked function */
#define IS_LONG(x) (IS_SPEC(x) && x->select.s._long)
#define IS_UNSIGNED(x) (IS_SPEC(x) && x->select.s._unsigned)
#define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef)
-#define IS_CONSTANT(x) (IS_SPEC(x) && ( x->select.s._const == 1))
+#define IS_CONSTANT(x) (!x ? 0 : \
+ IS_SPEC(x) ? \
+ x->select.s._const == 1 : \
+ x->select.d.ptr_const)
#define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT)
#define IS_ABSOLUTE(x) (IS_SPEC(x) && x->select.s._absadr )
#define IS_REGISTER(x) (IS_SPEC(x) && SPEC_SCLS(x) == S_REGISTER)
#define IS_VOID(x) (IS_SPEC(x) && x->select.s.noun == V_VOID)
#define IS_CHAR(x) (IS_SPEC(x) && x->select.s.noun == V_CHAR)
#define IS_EXTERN(x) (IS_SPEC(x) && x->select.s._extern)
-#define IS_VOLATILE(x) (IS_SPEC(x) && x->select.s._volatile )
+#define IS_VOLATILE(x) (!x ? 0 : \
+ IS_SPEC(x) ? \
+ x->select.s._volatile : \
+ x->select.d.ptr_volatile)
#define IS_INTEGRAL(x) (IS_SPEC(x) && (x->select.s.noun == V_INT || \
x->select.s.noun == V_CHAR || \
x->select.s.noun == V_BIT || \
if (SPEC_SCLS (arrExpr->left->etype) == S_CODE)
{
DCL_TYPE (val->type) = CPOINTER;
- DCL_PTR_CONST (val->type) = port->mem.code_ro;
}
else if (SPEC_SCLS (arrExpr->left->etype) == S_XDATA)
DCL_TYPE (val->type) = FPOINTER;
if (SPEC_SCLS (structT->etype) == S_CODE)
{
DCL_TYPE (val->type) = CPOINTER;
- DCL_PTR_CONST (val->type) = port->mem.code_ro;
}
else if (SPEC_SCLS (structT->etype) == S_XDATA)
DCL_TYPE (val->type) = FPOINTER;