mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix non-const labels with callbacks having incorrect values when diffed
Basically, this broke PC, which is currently the only label-typed symbol with a callback.
This commit is contained in:
@@ -70,6 +70,7 @@ static inline bool sym_IsExported(struct sSymbol const *sym)
|
|||||||
return sym->isExported;
|
return sym->isExported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sym_GetValue(struct sSymbol const *sym);
|
||||||
uint32_t sym_CalcHash(const char *s);
|
uint32_t sym_CalcHash(const char *s);
|
||||||
void sym_SetExportAll(uint8_t set);
|
void sym_SetExportAll(uint8_t set);
|
||||||
void sym_AddLocalReloc(char const *tzSym);
|
void sym_AddLocalReloc(char const *tzSym);
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ void rpn_BinaryOp(enum RPNCommand op, struct Expression *expr,
|
|||||||
struct sSymbol const *symbol1 = symbolOf(src1);
|
struct sSymbol const *symbol1 = symbolOf(src1);
|
||||||
struct sSymbol const *symbol2 = symbolOf(src2);
|
struct sSymbol const *symbol2 = symbolOf(src2);
|
||||||
|
|
||||||
expr->nVal = symbol1->nValue - symbol2->nValue;
|
expr->nVal = sym_GetValue(symbol1) - sym_GetValue(symbol2);
|
||||||
expr->isKnown = true;
|
expr->isKnown = true;
|
||||||
} else {
|
} else {
|
||||||
/* If it's not known, start computing the RPN expression */
|
/* If it's not known, start computing the RPN expression */
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ static int32_t CallbackPC(struct sSymbol const *self)
|
|||||||
/*
|
/*
|
||||||
* Get the nValue field of a symbol
|
* Get the nValue field of a symbol
|
||||||
*/
|
*/
|
||||||
static int32_t getvaluefield(struct sSymbol const *sym)
|
int32_t sym_GetValue(struct sSymbol const *sym)
|
||||||
{
|
{
|
||||||
if (sym->Callback)
|
if (sym->Callback)
|
||||||
return sym->Callback(sym);
|
return sym->Callback(sym);
|
||||||
@@ -268,11 +268,11 @@ uint32_t sym_GetConstantValue(char const *s)
|
|||||||
if (pCurrentSection->nOrg == -1)
|
if (pCurrentSection->nOrg == -1)
|
||||||
yyerror("Expected constant PC but section is not fixed");
|
yyerror("Expected constant PC but section is not fixed");
|
||||||
else
|
else
|
||||||
return getvaluefield(psym);
|
return sym_GetValue(psym);
|
||||||
|
|
||||||
} else if (psym != NULL) {
|
} else if (psym != NULL) {
|
||||||
if (sym_IsConstant(psym))
|
if (sym_IsConstant(psym))
|
||||||
return getvaluefield(psym);
|
return sym_GetValue(psym);
|
||||||
|
|
||||||
fatalerror("\"%s\" does not have a constant value", s);
|
fatalerror("\"%s\" does not have a constant value", s);
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ uint32_t sym_GetDefinedValue(char const *s)
|
|||||||
if (!sym_IsNumeric(psym))
|
if (!sym_IsNumeric(psym))
|
||||||
yyerror("'%s' is a macro or string symbol", s);
|
yyerror("'%s' is a macro or string symbol", s);
|
||||||
|
|
||||||
return getvaluefield(psym);
|
return sym_GetValue(psym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user