Fix error reporting from function pre-flighting.
This commit is contained in:
parent
a97f2fb22a
commit
050bbcdb4f
|
@ -605,7 +605,7 @@ void CONTEXT::ReportError( const wxString& aErrorMsg )
|
|||
m_errorStatus.stage = CST_RUNTIME;
|
||||
|
||||
if( m_errorCallback )
|
||||
m_errorCallback( m_errorStatus );
|
||||
m_errorCallback( m_errorStatus.message, m_errorStatus.srcPos );
|
||||
}
|
||||
|
||||
|
||||
|
@ -802,15 +802,19 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext )
|
|||
if( func )
|
||||
{
|
||||
// Preflight the function call
|
||||
wxString paramStr;
|
||||
|
||||
if( node->value.str )
|
||||
paramStr = *node->value.str;
|
||||
|
||||
wxString paramStr = *node->leaf[1]->leaf[1]->value.str;
|
||||
VALUE* param = aPreflightContext->AllocValue();
|
||||
|
||||
param->Set( paramStr );
|
||||
aPreflightContext->Push( param );
|
||||
|
||||
aPreflightContext->SetErrorCallback(
|
||||
[&]( const wxString& aMessage, int aOffset )
|
||||
{
|
||||
size_t loc = node->leaf[1]->leaf[1]->srcPos- paramStr.Length();
|
||||
reportError( CST_CODEGEN, aMessage, (int) loc - 1 );
|
||||
} );
|
||||
|
||||
try
|
||||
{
|
||||
func( aPreflightContext, vref.get() );
|
||||
|
@ -819,13 +823,6 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext )
|
|||
catch( ... )
|
||||
{
|
||||
}
|
||||
|
||||
if( !aPreflightContext->IsErrorPending() )
|
||||
{
|
||||
size_t loc = node->leaf[1]->leaf[1]->srcPos - paramStr.Length();
|
||||
reportError( CST_CODEGEN, aPreflightContext->GetError().message,
|
||||
(int) loc - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
node->leaf[0]->isVisited = true;
|
||||
|
|
|
@ -285,7 +285,11 @@ public:
|
|||
return m_stack.size();
|
||||
};
|
||||
|
||||
void SetErrorCallback( std::function<void(const ERROR_STATUS&)> aCallback );
|
||||
void SetErrorCallback( std::function<void( const wxString& aMessage, int aOffset )> aCallback )
|
||||
{
|
||||
m_errorCallback = std::move( aCallback );
|
||||
}
|
||||
|
||||
void ReportError( const wxString& aErrorMsg );
|
||||
bool IsErrorPending() const { return m_errorStatus.pendingError; }
|
||||
const ERROR_STATUS& GetError() const { return m_errorStatus; }
|
||||
|
@ -294,7 +298,8 @@ private:
|
|||
std::vector<VALUE*> m_ownedValues;
|
||||
std::stack<VALUE*> m_stack;
|
||||
ERROR_STATUS m_errorStatus;
|
||||
std::function<void(const ERROR_STATUS&)> m_errorCallback;
|
||||
|
||||
std::function<void( const wxString& aMessage, int aOffset )> m_errorCallback;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue