mib18: #163121# Declare Rework
This commit is contained in:
@@ -259,6 +259,10 @@ void SbiCodeGen::Save()
|
|||||||
if( !pProc->IsPublic() )
|
if( !pProc->IsPublic() )
|
||||||
pMeth->SetFlag( SBX_PRIVATE );
|
pMeth->SetFlag( SBX_PRIVATE );
|
||||||
|
|
||||||
|
// Declare? -> Hidden
|
||||||
|
if( pProc->GetLib().Len() > 0 )
|
||||||
|
pMeth->SetFlag( SBX_HIDDEN );
|
||||||
|
|
||||||
pMeth->nStart = pProc->GetAddr();
|
pMeth->nStart = pProc->GetAddr();
|
||||||
pMeth->nLine1 = pProc->GetLine1();
|
pMeth->nLine1 = pProc->GetLine1();
|
||||||
pMeth->nLine2 = pProc->GetLine2();
|
pMeth->nLine2 = pProc->GetLine2();
|
||||||
|
@@ -877,7 +877,7 @@ SbiProcDef* SbiParser::ProcDecl( BOOL bDecl )
|
|||||||
}
|
}
|
||||||
if( bCompatible && Peek() == PARAMARRAY )
|
if( bCompatible && Peek() == PARAMARRAY )
|
||||||
{
|
{
|
||||||
if( bByVal || bByVal || bOptional )
|
if( bByVal || bOptional )
|
||||||
Error( SbERR_UNEXPECTED, PARAMARRAY );
|
Error( SbERR_UNEXPECTED, PARAMARRAY );
|
||||||
Next();
|
Next();
|
||||||
bParamArray = TRUE;
|
bParamArray = TRUE;
|
||||||
@@ -949,6 +949,8 @@ void SbiParser::DefDeclare( BOOL bPrivate )
|
|||||||
Error( SbERR_UNEXPECTED, eCurTok );
|
Error( SbERR_UNEXPECTED, eCurTok );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool bFunction = (eCurTok == FUNCTION);
|
||||||
|
|
||||||
SbiProcDef* pDef = ProcDecl( TRUE );
|
SbiProcDef* pDef = ProcDecl( TRUE );
|
||||||
if( pDef )
|
if( pDef )
|
||||||
{
|
{
|
||||||
@@ -973,7 +975,64 @@ void SbiParser::DefDeclare( BOOL bPrivate )
|
|||||||
aPublics.Add( pDef );
|
aPublics.Add( pDef );
|
||||||
|
|
||||||
if ( pDef )
|
if ( pDef )
|
||||||
|
{
|
||||||
pDef->SetPublic( !bPrivate );
|
pDef->SetPublic( !bPrivate );
|
||||||
|
|
||||||
|
// New declare handling
|
||||||
|
if( pDef->GetLib().Len() > 0 )
|
||||||
|
{
|
||||||
|
USHORT nSavLine = nLine;
|
||||||
|
aGen.Statement();
|
||||||
|
pDef->Define();
|
||||||
|
pDef->SetLine1( nSavLine );
|
||||||
|
pDef->SetLine2( nSavLine );
|
||||||
|
|
||||||
|
SbiSymPool& rPool = pDef->GetParams();
|
||||||
|
USHORT nParCount = rPool.GetSize();
|
||||||
|
|
||||||
|
SbxDataType eType = pDef->GetType();
|
||||||
|
if( bFunction )
|
||||||
|
aGen.Gen( _PARAM, 0, sal::static_int_cast< UINT16 >( eType ) );
|
||||||
|
|
||||||
|
if( nParCount > 1 )
|
||||||
|
{
|
||||||
|
aGen.Gen( _ARGC );
|
||||||
|
|
||||||
|
for( USHORT i = 1 ; i < nParCount ; ++i )
|
||||||
|
{
|
||||||
|
SbiSymDef* pParDef = rPool.Get( i );
|
||||||
|
SbxDataType eParType = pParDef->GetType();
|
||||||
|
|
||||||
|
aGen.Gen( _PARAM, i, sal::static_int_cast< UINT16 >( eParType ) );
|
||||||
|
aGen.Gen( _ARGV );
|
||||||
|
|
||||||
|
USHORT nTyp = sal::static_int_cast< USHORT >( pParDef->GetType() );
|
||||||
|
if( pParDef->IsByVal() )
|
||||||
|
{
|
||||||
|
// Reset to avoid additional byval in call to wrapper function
|
||||||
|
pParDef->SetByVal( FALSE );
|
||||||
|
nTyp |= 0x8000;
|
||||||
|
}
|
||||||
|
aGen.Gen( _ARGTYP, nTyp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aGen.Gen( _LIB, aGblStrings.Add( pDef->GetLib() ) );
|
||||||
|
|
||||||
|
SbiOpcode eOp = pDef->IsCdecl() ? _CALLC : _CALL;
|
||||||
|
USHORT nId = pDef->GetId();
|
||||||
|
if( pDef->GetAlias().Len() )
|
||||||
|
nId = ( nId & 0x8000 ) | aGblStrings.Add( pDef->GetAlias() );
|
||||||
|
if( nParCount > 1 )
|
||||||
|
nId |= 0x8000;
|
||||||
|
aGen.Gen( eOp, nId, sal::static_int_cast< UINT16 >( eType ) );
|
||||||
|
|
||||||
|
if( bFunction )
|
||||||
|
aGen.Gen( _PUT );
|
||||||
|
|
||||||
|
aGen.Gen( _LEAVE );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -115,11 +115,6 @@ void SbiExprNode::Gen( RecursiveMode eRecMode )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SbiProcDef* pProc = aVar.pDef->GetProcDef();
|
|
||||||
// per DECLARE definiert?
|
|
||||||
if( pProc && pProc->GetLib().Len() )
|
|
||||||
eOp = pProc->IsCdecl() ? _CALLC : _CALL;
|
|
||||||
else
|
|
||||||
eOp = ( aVar.pDef->GetScope() == SbRTL ) ? _RTL :
|
eOp = ( aVar.pDef->GetScope() == SbRTL ) ? _RTL :
|
||||||
(aVar.pDef->IsGlobal() ? _FIND_G : _FIND);
|
(aVar.pDef->IsGlobal() ? _FIND_G : _FIND);
|
||||||
}
|
}
|
||||||
@@ -187,17 +182,6 @@ void SbiExprNode::GenElement( SbiOpcode eOp )
|
|||||||
aVar.pPar->Gen();
|
aVar.pPar->Gen();
|
||||||
}
|
}
|
||||||
|
|
||||||
SbiProcDef* pProc = aVar.pDef->GetProcDef();
|
|
||||||
// per DECLARE definiert?
|
|
||||||
if( pProc )
|
|
||||||
{
|
|
||||||
// Dann evtl. einen LIB-Befehl erzeugen
|
|
||||||
if( pProc->GetLib().Len() )
|
|
||||||
pGen->Gen( _LIB, pGen->GetParser()->aGblStrings.Add( pProc->GetLib() ) );
|
|
||||||
// und den Aliasnamen nehmen
|
|
||||||
if( pProc->GetAlias().Len() )
|
|
||||||
nId = ( nId & 0x8000 ) | pGen->GetParser()->aGblStrings.Add( pProc->GetAlias() );
|
|
||||||
}
|
|
||||||
pGen->Gen( eOp, nId, sal::static_int_cast< UINT16 >( GetType() ) );
|
pGen->Gen( eOp, nId, sal::static_int_cast< UINT16 >( GetType() ) );
|
||||||
|
|
||||||
if( aVar.pvMorePar )
|
if( aVar.pvMorePar )
|
||||||
@@ -225,11 +209,6 @@ void SbiExprList::Gen()
|
|||||||
// AB 10.1.96: Typ-Anpassung bei DECLARE
|
// AB 10.1.96: Typ-Anpassung bei DECLARE
|
||||||
USHORT nCount = 1, nParAnz = 0;
|
USHORT nCount = 1, nParAnz = 0;
|
||||||
SbiSymPool* pPool = NULL;
|
SbiSymPool* pPool = NULL;
|
||||||
if( pProc )
|
|
||||||
{
|
|
||||||
pPool = &pProc->GetParams();
|
|
||||||
nParAnz = pPool->GetSize();
|
|
||||||
}
|
|
||||||
for( SbiExpression* pExpr = pFirst; pExpr; pExpr = pExpr->pNext,nCount++ )
|
for( SbiExpression* pExpr = pFirst; pExpr; pExpr = pExpr->pNext,nCount++ )
|
||||||
{
|
{
|
||||||
pExpr->Gen();
|
pExpr->Gen();
|
||||||
@@ -239,6 +218,7 @@ void SbiExprList::Gen()
|
|||||||
USHORT nSid = pParser->aGblStrings.Add( pExpr->GetName() );
|
USHORT nSid = pParser->aGblStrings.Add( pExpr->GetName() );
|
||||||
pParser->aGen.Gen( _ARGN, nSid );
|
pParser->aGen.Gen( _ARGN, nSid );
|
||||||
|
|
||||||
|
/* TODO: Check after Declare concept change
|
||||||
// AB 10.1.96: Typanpassung bei named -> passenden Parameter suchen
|
// AB 10.1.96: Typanpassung bei named -> passenden Parameter suchen
|
||||||
if( pProc )
|
if( pProc )
|
||||||
{
|
{
|
||||||
@@ -246,39 +226,26 @@ void SbiExprList::Gen()
|
|||||||
pParser->Error( SbERR_NO_NAMED_ARGS );
|
pParser->Error( SbERR_NO_NAMED_ARGS );
|
||||||
|
|
||||||
// Spaeter, wenn Named Args bei DECLARE moeglich
|
// Spaeter, wenn Named Args bei DECLARE moeglich
|
||||||
/*
|
//for( USHORT i = 1 ; i < nParAnz ; i++ )
|
||||||
for( USHORT i = 1 ; i < nParAnz ; i++ )
|
//{
|
||||||
{
|
// SbiSymDef* pDef = pPool->Get( i );
|
||||||
SbiSymDef* pDef = pPool->Get( i );
|
// const String& rName = pDef->GetName();
|
||||||
const String& rName = pDef->GetName();
|
// if( rName.Len() )
|
||||||
if( rName.Len() )
|
// {
|
||||||
{
|
// if( pExpr->GetName().ICompare( rName )
|
||||||
if( pExpr->GetName().ICompare( rName )
|
// == COMPARE_EQUAL )
|
||||||
== COMPARE_EQUAL )
|
// {
|
||||||
{
|
// pParser->aGen.Gen( _ARGTYP, pDef->GetType() );
|
||||||
pParser->aGen.Gen( _ARGTYP, pDef->GetType() );
|
// break;
|
||||||
break;
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pParser->aGen.Gen( _ARGV );
|
pParser->aGen.Gen( _ARGV );
|
||||||
|
|
||||||
// Funktion mit DECLARE -> Typ-Anpassung
|
|
||||||
if( pProc && nCount < nParAnz )
|
|
||||||
{
|
|
||||||
SbiSymDef* pDef = pPool->Get( nCount );
|
|
||||||
USHORT nTyp = sal::static_int_cast< USHORT >(
|
|
||||||
pDef->GetType() );
|
|
||||||
// Zus<75>tzliches Flag f<>r BYVAL einbauen
|
|
||||||
if( pDef->IsByVal() )
|
|
||||||
nTyp |= 0x8000;
|
|
||||||
pParser->aGen.Gen( _ARGTYP, nTyp );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -338,15 +338,6 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
|
|||||||
// damit erwischen wir n% = 5 : print n
|
// damit erwischen wir n% = 5 : print n
|
||||||
eType = eDefType;
|
eType = eDefType;
|
||||||
}
|
}
|
||||||
// Funktion?
|
|
||||||
if( pDef->GetProcDef() )
|
|
||||||
{
|
|
||||||
SbiProcDef* pProc = pDef->GetProcDef();
|
|
||||||
if( pPar && pProc->GetLib().Len() ) // DECLARE benutzt?
|
|
||||||
pPar->SetProc( pProc );
|
|
||||||
// Wenn keine Pars, vorerst nichts machen
|
|
||||||
// Pruefung auf Typ-Anzahl waere denkbar
|
|
||||||
}
|
|
||||||
// Typcheck bei Variablen:
|
// Typcheck bei Variablen:
|
||||||
// ist explizit im Scanner etwas anderes angegeben?
|
// ist explizit im Scanner etwas anderes angegeben?
|
||||||
// Bei Methoden ist dies OK!
|
// Bei Methoden ist dies OK!
|
||||||
@@ -868,7 +859,6 @@ SbiExprList::SbiExprList( SbiParser* p )
|
|||||||
{
|
{
|
||||||
pParser = p;
|
pParser = p;
|
||||||
pFirst = NULL;
|
pFirst = NULL;
|
||||||
pProc = NULL;
|
|
||||||
nExpr =
|
nExpr =
|
||||||
nDim = 0;
|
nDim = 0;
|
||||||
bError =
|
bError =
|
||||||
|
@@ -234,7 +234,6 @@ class SbiExprList { // Basisklasse fuer Parameter und Dims
|
|||||||
protected:
|
protected:
|
||||||
SbiParser* pParser; // Parser
|
SbiParser* pParser; // Parser
|
||||||
SbiExpression* pFirst; // Expressions
|
SbiExpression* pFirst; // Expressions
|
||||||
SbiProcDef* pProc; // DECLARE-Funktion (Parameter-Anpassung)
|
|
||||||
short nExpr; // Anzahl Expressions
|
short nExpr; // Anzahl Expressions
|
||||||
short nDim; // Anzahl Dimensionen
|
short nDim; // Anzahl Dimensionen
|
||||||
BOOL bError; // TRUE: Fehler
|
BOOL bError; // TRUE: Fehler
|
||||||
@@ -249,8 +248,6 @@ public:
|
|||||||
SbiExpression* Get( short );
|
SbiExpression* Get( short );
|
||||||
BOOL Test( const SbiProcDef& ); // Parameter-Checks
|
BOOL Test( const SbiProcDef& ); // Parameter-Checks
|
||||||
void Gen(); // Code-Erzeugung
|
void Gen(); // Code-Erzeugung
|
||||||
// Setzen einer Funktionsdefinition zum Abgleich der Parameter
|
|
||||||
void SetProc( SbiProcDef* p ) { pProc = p; }
|
|
||||||
void addExpression( SbiExpression* pExpr );
|
void addExpression( SbiExpression* pExpr );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -159,7 +159,8 @@ public:
|
|||||||
void SetOptional() { bOpt = TRUE; }
|
void SetOptional() { bOpt = TRUE; }
|
||||||
void SetParamArray() { bParamArray = TRUE; }
|
void SetParamArray() { bParamArray = TRUE; }
|
||||||
void SetWithEvents() { bWithEvents = TRUE; }
|
void SetWithEvents() { bWithEvents = TRUE; }
|
||||||
void SetByVal() { bByVal = TRUE; }
|
void SetByVal( BOOL bByVal_ = TRUE )
|
||||||
|
{ bByVal = bByVal_; }
|
||||||
void SetStatic( BOOL bAsStatic = TRUE ) { bStatic = bAsStatic; }
|
void SetStatic( BOOL bAsStatic = TRUE ) { bStatic = bAsStatic; }
|
||||||
void SetNew() { bNew = TRUE; }
|
void SetNew() { bNew = TRUE; }
|
||||||
void SetDefinedAs() { bAs = TRUE; }
|
void SetDefinedAs() { bAs = TRUE; }
|
||||||
|
@@ -97,14 +97,22 @@ namespace basprov
|
|||||||
if ( pMethods )
|
if ( pMethods )
|
||||||
{
|
{
|
||||||
sal_Int32 nCount = pMethods->Count();
|
sal_Int32 nCount = pMethods->Count();
|
||||||
aChildNodes.realloc( nCount );
|
sal_Int32 nRealCount = 0;
|
||||||
Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray();
|
|
||||||
|
|
||||||
for ( sal_Int32 i = 0; i < nCount; ++i )
|
for ( sal_Int32 i = 0; i < nCount; ++i )
|
||||||
{
|
{
|
||||||
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) );
|
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) );
|
||||||
if ( pMethod )
|
if ( pMethod && !pMethod->IsHidden() )
|
||||||
pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) );
|
++nRealCount;
|
||||||
|
}
|
||||||
|
aChildNodes.realloc( nRealCount );
|
||||||
|
Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray();
|
||||||
|
|
||||||
|
sal_Int32 iTarget = 0;
|
||||||
|
for ( sal_Int32 i = 0; i < nCount; ++i )
|
||||||
|
{
|
||||||
|
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) );
|
||||||
|
if ( pMethod && !pMethod->IsHidden() )
|
||||||
|
pChildNodes[iTarget++] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -412,7 +412,7 @@ namespace basprov
|
|||||||
if ( pMethods )
|
if ( pMethods )
|
||||||
{
|
{
|
||||||
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( aMethod, SbxCLASS_METHOD ) );
|
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( aMethod, SbxCLASS_METHOD ) );
|
||||||
if ( pMethod )
|
if ( pMethod && !pMethod->IsHidden() )
|
||||||
{
|
{
|
||||||
if ( m_pDocBasicManager == pBasicMgr )
|
if ( m_pDocBasicManager == pBasicMgr )
|
||||||
xScript = new BasicScriptImpl( aDescription, pMethod, *m_pDocBasicManager, m_xInvocationContext );
|
xScript = new BasicScriptImpl( aDescription, pMethod, *m_pDocBasicManager, m_xInvocationContext );
|
||||||
|
Reference in New Issue
Block a user