Added GetSourceAt() with code pos

This commit is contained in:
smallmodel 2023-10-27 19:59:15 +02:00
parent dc028b87e4
commit bb97ec8933
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
2 changed files with 13 additions and 1 deletions

View file

@ -84,6 +84,17 @@ bool AbstractScript::GetSourceAt(size_t sourcePos, str *sourceLine, int& column,
return true;
}
bool AbstractScript::GetSourceAt(const unsigned char *sourcePos, str *sourceLine, int& column, int& line)
{
const sourceinfo_t *codePos = m_ProgToSource->findKeyValue(sourcePos);
if (!codePos) {
return false;
}
return GetSourceAt(codePos->sourcePos, sourceLine, column, line);
}
void AbstractScript::PrintSourcePos(sourceinfo_t *sourcePos, bool dev)
{
int line;

View file

@ -54,7 +54,7 @@ public:
size_t m_SourceLength;
// Developper variable
con_set<uchar *, sourceinfo_t> *m_ProgToSource;
con_set<const uchar *, sourceinfo_t> *m_ProgToSource;
public:
AbstractScript();
@ -62,6 +62,7 @@ public:
str & Filename(void);
const_str ConstFilename(void);
bool GetSourceAt(size_t sourcePos, str *sourceLine, int &column, int &line);
bool GetSourceAt(const unsigned char *sourcePos, str *sourceLine, int &column, int &line);
void PrintSourcePos(sourceinfo_t *sourcePos, bool dev);
void PrintSourcePos(size_t sourcePos, bool dev);
void PrintSourcePos(unsigned char *m_pCodePos, bool dev);