Deprecate built-in _PI

Fixes #670
This commit is contained in:
Rangi
2020-12-30 09:28:59 -05:00
committed by Eldred Habert
parent 2a9d52871b
commit 10e3f1a02b
9 changed files with 29 additions and 8 deletions

View File

@@ -17,6 +17,7 @@
#include "asm/mymath.h"
#include "asm/symbol.h"
#include "asm/warning.h"
#define fx2double(i) ((double)((i) / 65536.0))
#define double2fx(d) ((int32_t)((d) * 65536.0))
@@ -26,11 +27,13 @@
#endif
/*
* Define the _PI symbol
* Return the _PI symbol value
*/
void math_DefinePI(void)
int32_t math_Callback_PI(void)
{
sym_AddEqu("_PI", double2fx(M_PI));
warning(WARNING_OBSOLETE, "`_PI` is deprecated; use 3.14159\n");
return double2fx(M_PI);
}
/*

View File

@@ -720,5 +720,12 @@ void sym_Init(time_t now)
labelScope = NULL;
anonLabelID = 0;
math_DefinePI();
/* _PI is deprecated */
struct Symbol *_PISymbol = createBuiltinSymbol("_PI");
_PISymbol->type = SYM_EQU;
_PISymbol->src = NULL;
_PISymbol->fileLine = 0;
_PISymbol->hasCallback = true;
_PISymbol->numCallback = math_Callback_PI;
}