#include "SDCCval.h"
#include "SDCCmem.h"
#include "SDCCast.h"
+
extern int yyerror (char *);
extern FILE *yyin;
extern char srcLstFname[];
}
if (SPEC_SCLS(tree->left->etype) == S_CODE) {
DCL_TYPE(p) = CPOINTER ;
- DCL_PTR_CONST(p) = 1;
+ DCL_PTR_CONST(p) = port->mem.code_ro;
}
else
if (SPEC_SCLS(tree->left->etype) == S_XDATA)
val->type = newLink();
if (SPEC_SCLS(expr->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(expr->left->etype) == S_XDATA)
ptype->next = type;
/* if the output class is generic */
if ((DCL_TYPE(ptype) = PTR_TYPE(SPEC_OCLS(etype))) == CPOINTER)
- DCL_PTR_CONST(ptype) = 1;
+ DCL_PTR_CONST(ptype) = port->mem.code_ro;
/* if the variable was declared a constant */
/* then the pointer points to a constant */
/* set the pointer depending on the storage class */
if ((DCL_TYPE(optype) = PTR_TYPE(SPEC_OCLS(opetype))) == CPOINTER)
- DCL_PTR_CONST(optype) = 1;
+ DCL_PTR_CONST(optype) = port->mem.code_ro;
/* if the variable was declared a constant */
/* set the pointer depending on the storage class */
if ((DCL_TYPE(p) = PTR_TYPE(SPEC_OCLS(opetype))) == CPOINTER)
- DCL_PTR_CONST(p) = 1;
+ DCL_PTR_CONST(p) = port->mem.code_ro;
/* make sure we preserve the const & volatile */
if (IS_CONSTANT(opetype))
DCL_TYPE(ptr) = POINTER ;
break;
case S_CODE:
- DCL_PTR_CONST(ptr) = 1;
+ DCL_PTR_CONST(ptr) = port->mem.code_ro;
DCL_TYPE(ptr) = CPOINTER ;
break;
case S_EEPROM:
/* global variables declared const put into code */
if (sym->level == 0 &&
- SPEC_SCLS(sym->etype) == S_CONSTANT)
+ SPEC_SCLS(sym->etype) == S_CONSTANT) {
SPEC_SCLS(sym->etype) = S_CODE ;
-
+ SPEC_CONST(sym->etype) = 1;
+ }
/* global variable in code space is a constant */
if (sym->level == 0 &&
- SPEC_SCLS(sym->etype) == S_CODE)
+ SPEC_SCLS(sym->etype) == S_CODE &&
+ port->mem.code_ro )
SPEC_CONST(sym->etype) = 1;
if (SPEC_SCLS(sym->etype) == S_CODE &&
sym->ival == NULL &&
!sym->level &&
+ port->mem.code_ro &&
!IS_EXTERN(sym->etype))
werror(E_CODE_NO_INIT,sym->name);
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)
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)
"GSFINAL (CODE)",
NULL,
NULL,
+ 0,
},
{
-1, 1, 4, 1, 1
return 0;
}
pack:
+ /* if in far space & tru symbol then don't */
+ if ((IS_TRUE_SYM(IC_RESULT(ic))) && isOperandInFarSpace(IC_RESULT(ic)))
+ return 0;
/* found the definition */
/* replace the result with the result of */
/* this assignment and remove this assignment */
"OSEG (OVR,DATA)",
"GSFINAL (CODE)",
NULL,
- NULL
+ NULL,
+ 1
},
{
+1, 1, 4, 1, 1
const char *post_static_name;
struct memmap *default_local_map ; /* default location for auto vars */
struct memmap *default_globl_map ; /* default location for globl vars*/
+ int code_ro; /* code space read-only 1=yes */
} mem;
/* stack related information */
"_OVERLAY",
"_GSFINAL",
NULL,
- NULL
+ NULL,
+ 1
},
{
-1, 0, 0, 8, 0