/*------------------------------------------------------------------*/
/* initSymt () - initialises symbol table related stuff */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* initSymt () - initialises symbol table related stuff */
/*------------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* hashKey - computes the hashkey given a symbol name */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* hashKey - computes the hashkey given a symbol name */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* addSym - adds a symbol to the hash Table */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* addSym - adds a symbol to the hash Table */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* deleteSym - deletes a symbol from the hash Table entry */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* deleteSym - deletes a symbol from the hash Table entry */
/*-----------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* sclsFromPtr - Return the storage class a pointer points into. */
/* S_FIXED is returned for generic pointers or other */
/*------------------------------------------------------------------*/
/* sclsFromPtr - Return the storage class a pointer points into. */
/* S_FIXED is returned for generic pointers or other */
/*------------------------------------------------------------------*/
/* pointerTypes - do the computation for the pointer types */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* pointerTypes - do the computation for the pointer types */
/*------------------------------------------------------------------*/
if (IS_PTR(ptr) && DCL_TYPE(ptr)!=UPOINTER) {
pointerTypes (ptr->next, type);
return;
if (IS_PTR(ptr) && DCL_TYPE(ptr)!=UPOINTER) {
pointerTypes (ptr->next, type);
return;
/*------------------------------------------------------------------*/
/* addDecl - adds a declarator @ the end of a chain */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* addDecl - adds a declarator @ the end of a chain */
/*------------------------------------------------------------------*/
addDecl (symbol * sym, int type, sym_link * p)
{
static sym_link *empty = NULL;
addDecl (symbol * sym, int type, sym_link * p)
{
static sym_link *empty = NULL;
fprintf (stderr, "checking sanity for %s %p\n", name, etype);
}
fprintf (stderr, "checking sanity for %s %p\n", name, etype);
}
SPEC_NOUN(etype)==V_VOID) &&
(SPEC_SHORT(etype) || SPEC_LONG(etype))) {
// long or short for char float double or void
werror (E_LONG_OR_SHORT_INVALID, noun, name);
}
SPEC_NOUN(etype)==V_VOID) &&
(SPEC_SHORT(etype) || SPEC_LONG(etype))) {
// long or short for char float double or void
werror (E_LONG_OR_SHORT_INVALID, noun, name);
}
(etype->select.s.b_signed || SPEC_USIGN(etype))) {
// signed or unsigned for float double or void
werror (E_SIGNED_OR_UNSIGNED_INVALID, noun, name);
(etype->select.s.b_signed || SPEC_USIGN(etype))) {
// signed or unsigned for float double or void
werror (E_SIGNED_OR_UNSIGNED_INVALID, noun, name);
werror (E_SIGNED_AND_UNSIGNED_INVALID, noun, name);
}
if (SPEC_SHORT(etype) && SPEC_LONG(etype)) {
werror (E_SIGNED_AND_UNSIGNED_INVALID, noun, name);
}
if (SPEC_SHORT(etype) && SPEC_LONG(etype)) {
SPEC_ENUM (dest) |= SPEC_ENUM (src);
if (SPEC_ARGREG(src) && !SPEC_ARGREG(dest))
SPEC_ARGREG(dest) = SPEC_ARGREG(src);
SPEC_ENUM (dest) |= SPEC_ENUM (src);
if (SPEC_ARGREG(src) && !SPEC_ARGREG(dest))
SPEC_ARGREG(dest) = SPEC_ARGREG(src);
in a specifier while parsing */
FUNC_NONBANKED(dest) |= FUNC_NONBANKED(src);
FUNC_BANKED(dest) |= FUNC_BANKED(src);
in a specifier while parsing */
FUNC_NONBANKED(dest) |= FUNC_NONBANKED(src);
FUNC_BANKED(dest) |= FUNC_BANKED(src);
/*------------------------------------------------------------------*/
/* getSize - returns size of a type chain in bytes */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* getSize - returns size of a type chain in bytes */
/*------------------------------------------------------------------*/
- // werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ // werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
/*------------------------------------------------------------------*/
/* bitsForType - returns # of bits required to store this type */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* bitsForType - returns # of bits required to store this type */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* addSymChain - adds a symbol chain to the symboltable */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* addSymChain - adds a symbol chain to the symboltable */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* funcInChain - DCL Type 'FUNCTION' found in type chain */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* funcInChain - DCL Type 'FUNCTION' found in type chain */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* compStructSize - computes the size of a structure */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* compStructSize - computes the size of a structure */
/*------------------------------------------------------------------*/
else {
if( TARGET_IS_PIC16 && getenv("PIC16_PACKED_BITFIELDS") ) {
/* if PIC16 && enviroment variable is set, then
else {
if( TARGET_IS_PIC16 && getenv("PIC16_PACKED_BITFIELDS") ) {
/* if PIC16 && enviroment variable is set, then
base = field->offset;
subfield = copySymbolChain (SPEC_STRUCT (field->type)->fields);
if (!subfield)
continue; /* just in case it's empty */
base = field->offset;
subfield = copySymbolChain (SPEC_STRUCT (field->type)->fields);
if (!subfield)
continue; /* just in case it's empty */
/*------------------------------------------------------------------*/
/* checkSClass - check the storage class specification */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* checkSClass - check the storage class specification */
/*------------------------------------------------------------------*/
if (getenv("DEBUG_SANITY")) {
fprintf (stderr, "checkSClass: %s \n", sym->name);
}
if (getenv("DEBUG_SANITY")) {
fprintf (stderr, "checkSClass: %s \n", sym->name);
}
/* type is literal can happen for enums change to auto */
if (SPEC_SCLS (sym->etype) == S_LITERAL && !SPEC_ENUM (sym->etype))
SPEC_SCLS (sym->etype) = S_AUTO;
/* type is literal can happen for enums change to auto */
if (SPEC_SCLS (sym->etype) == S_LITERAL && !SPEC_ENUM (sym->etype))
SPEC_SCLS (sym->etype) = S_AUTO;
/* if sfr or sbit then must also be volatile */
if (SPEC_SCLS (sym->etype) == S_SBIT ||
SPEC_SCLS (sym->etype) == S_SFR)
{
SPEC_VOLATILE (sym->etype) = 1;
}
/* if sfr or sbit then must also be volatile */
if (SPEC_SCLS (sym->etype) == S_SBIT ||
SPEC_SCLS (sym->etype) == S_SFR)
{
SPEC_VOLATILE (sym->etype) = 1;
}
* control this allocation, but the code was originally that way, and
* changing it for non-390 ports breaks the compiler badly.
*/
* control this allocation, but the code was originally that way, and
* changing it for non-390 ports breaks the compiler badly.
*/
/*------------------------------------------------------------------*/
/* changePointer - change pointer to functions */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* changePointer - change pointer to functions */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* checkDecl - does semantic validation of a declaration */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* checkDecl - does semantic validation of a declaration */
/*------------------------------------------------------------------*/
/* cleanUpBlock - cleansup the symbol table specified for all the */
/* symbols in the given block */
/*------------------------------------------------------------------*/
/* cleanUpBlock - cleansup the symbol table specified for all the */
/* symbols in the given block */
/*------------------------------------------------------------------*/
/* cleanUpLevel - cleansup the symbol table specified for all the */
/* symbols in the given level */
/*------------------------------------------------------------------*/
/* cleanUpLevel - cleansup the symbol table specified for all the */
/* symbols in the given level */
/*------------------------------------------------------------------*/
/* if both are bitvars choose the larger one */
else if (IS_BITVAR (etype1) && IS_BITVAR (etype2))
rType = SPEC_BLEN (etype1) >= SPEC_BLEN (etype2) ?
copyLinkChain (type1) : copyLinkChain (type1);
/* if both are bitvars choose the larger one */
else if (IS_BITVAR (etype1) && IS_BITVAR (etype2))
rType = SPEC_BLEN (etype1) >= SPEC_BLEN (etype2) ?
copyLinkChain (type1) : copyLinkChain (type1);
/* if only one of them is a bit variable then the other one prevails */
else if (IS_BITVAR (etype1) && !IS_BITVAR (etype2))
{
/* if only one of them is a bit variable then the other one prevails */
else if (IS_BITVAR (etype1) && !IS_BITVAR (etype2))
{
Homework: - why is (200 * 200 < 0) true?
- why is { char l = 200, r = 200; (r * l > 0) } true?
*/
Homework: - why is (200 * 200 < 0) true?
- why is { char l = 200, r = 200; (r * l > 0) } true?
*/
compareTypeExact (sym_link * dest, sym_link * src, int level)
{
STORAGE_CLASS srcScls, destScls;
compareTypeExact (sym_link * dest, sym_link * src, int level)
{
STORAGE_CLASS srcScls, destScls;
/* if one them ended we have a problem */
if ((exargs && !acargs && !IS_VOID (exargs->type)) ||
(!exargs && acargs && !IS_VOID (acargs->type)))
/* if one them ended we have a problem */
if ((exargs && !acargs && !IS_VOID (exargs->type)) ||
(!exargs && acargs && !IS_VOID (acargs->type)))
/* Compensate for const to const code change in checkSClass() */
if (!level & port->mem.code_ro && SPEC_CONST (dest))
{
/* Compensate for const to const code change in checkSClass() */
if (!level & port->mem.code_ro && SPEC_CONST (dest))
{
/*------------------------------------------------------------------*/
/* checkFunction - does all kinds of check on a function */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* checkFunction - does all kinds of check on a function */
/*------------------------------------------------------------------*/
// this can happen for reentrant functions
werror(E_PARAM_NAME_OMITTED, sym->name, argCnt);
// the show must go on: synthesize a name and symbol
// this can happen for reentrant functions
werror(E_PARAM_NAME_OMITTED, sym->name, argCnt);
// the show must go on: synthesize a name and symbol
acargs->sym->etype = getSpec (acargs->sym->type);
acargs->sym->_isparm = 1;
strncpyz (acargs->sym->rname, acargs->name, sizeof(acargs->sym->rname));
acargs->sym->etype = getSpec (acargs->sym->type);
acargs->sym->_isparm = 1;
strncpyz (acargs->sym->rname, acargs->name, sizeof(acargs->sym->rname));
/*-----------------------------------------------------------------*/
/* processFuncPtrArgs - does some processing with args of func ptrs*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* processFuncPtrArgs - does some processing with args of func ptrs*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* processFuncArgs - does some processing with function args */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* processFuncArgs - does some processing with function args */
/*-----------------------------------------------------------------*/
SNPRINTF (buffer, sizeof(buffer), "%s parameter %d", func->name, pNum);
checkTypeSanity (val->etype, buffer);
SNPRINTF (buffer, sizeof(buffer), "%s parameter %d", func->name, pNum);
checkTypeSanity (val->etype, buffer);
"_%s_PARM_%d", func->name, pNum++);
val->sym = newSymbol (val->name, 1);
if (SPEC_SCLS(val->etype) == S_BIT)
"_%s_PARM_%d", func->name, pNum++);
val->sym = newSymbol (val->name, 1);
if (SPEC_SCLS(val->etype) == S_BIT)
/*-----------------------------------------------------------------*/
/* isSymbolEqual - compares two symbols return 1 if they match */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* isSymbolEqual - compares two symbols return 1 if they match */
/*-----------------------------------------------------------------*/
isSymbolEqual (symbol * dest, symbol * src)
{
/* if pointers match then equal */
isSymbolEqual (symbol * dest, symbol * src)
{
/* if pointers match then equal */
{
case S_DATA: dbuf_append_str (dbuf, "data-"); break;
case S_XDATA: dbuf_append_str (dbuf, "xdata-"); break;
{
case S_DATA: dbuf_append_str (dbuf, "data-"); break;
case S_XDATA: dbuf_append_str (dbuf, "xdata-"); break;
(IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "),
(IFFUNC_ISJAVANATIVE(type) ? "_JavaNative" : " "));
dbuf_append_str (dbuf, "( ");
(IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "),
(IFFUNC_ISJAVANATIVE(type) ? "_JavaNative" : " "));
dbuf_append_str (dbuf, "( ");
(IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "),
(IFFUNC_ISJAVANATIVE(type) ? "_JavaNative" : " "));
fprintf (of, "( ");
(IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "),
(IFFUNC_ISJAVANATIVE(type) ? "_JavaNative" : " "));
fprintf (of, "( ");
{
case S_DATA: fprintf (of, "data-"); break;
case S_XDATA: fprintf (of, "xdata-"); break;
{
case S_DATA: fprintf (of, "data-"); break;
case S_XDATA: fprintf (of, "xdata-"); break;
/* examples : "ig*" - generic int * */
/* "cx*" - char xdata * */
/* "ui" - unsigned int */
/* examples : "ig*" - generic int * */
/* "cx*" - char xdata * */
/* "ui" - unsigned int */
- werror(E_INTERNAL_ERROR, __FILE__, __LINE__,
+ werror(E_INTERNAL_ERROR, __FILE__, __LINE__,
/*-----------------------------------------------------------------*/
/* initCSupport - create functions for C support routines */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* initCSupport - create functions for C support routines */
/*-----------------------------------------------------------------*/
"Internal error: validateLink failed in %s(%s) @ %s:%u:"
" expected %s, got %s\n",
"Internal error: validateLink failed in %s(%s) @ %s:%u:"
" expected %s, got %s\n",
- macro, args, file, line,
+ macro, args, file, line,
DECLSPEC2TXT(select), l ? DECLSPEC2TXT(l->class) : "null-link");
exit(EXIT_FAILURE);
return l; // never reached, makes compiler happy.
DECLSPEC2TXT(select), l ? DECLSPEC2TXT(l->class) : "null-link");
exit(EXIT_FAILURE);
return l; // never reached, makes compiler happy.
/* Determine the range of the enumerated values */
sym = enumlist;
min = max = (int) ulFromVal (valFromType (sym->type));
/* Determine the range of the enumerated values */
sym = enumlist;
min = max = (int) ulFromVal (valFromType (sym->type));