diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index e0f23c15d224..93fb18baf86e 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -259,6 +259,10 @@ void SbiCodeGen::Save() if( !pProc->IsPublic() ) pMeth->SetFlag( SBX_PRIVATE ); + // Declare? -> Hidden + if( pProc->GetLib().Len() > 0 ) + pMeth->SetFlag( SBX_HIDDEN ); + pMeth->nStart = pProc->GetAddr(); pMeth->nLine1 = pProc->GetLine1(); pMeth->nLine2 = pProc->GetLine2(); diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index b8fa3c089fd8..27b6e0e51871 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -877,7 +877,7 @@ SbiProcDef* SbiParser::ProcDecl( BOOL bDecl ) } if( bCompatible && Peek() == PARAMARRAY ) { - if( bByVal || bByVal || bOptional ) + if( bByVal || bOptional ) Error( SbERR_UNEXPECTED, PARAMARRAY ); Next(); bParamArray = TRUE; @@ -949,6 +949,8 @@ void SbiParser::DefDeclare( BOOL bPrivate ) Error( SbERR_UNEXPECTED, eCurTok ); else { + bool bFunction = (eCurTok == FUNCTION); + SbiProcDef* pDef = ProcDecl( TRUE ); if( pDef ) { @@ -973,7 +975,64 @@ void SbiParser::DefDeclare( BOOL bPrivate ) aPublics.Add( pDef ); if ( pDef ) + { 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 ); + } + } } } } diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx index 60869307aecf..dc4fda0a4682 100644 --- a/basic/source/comp/exprgen.cxx +++ b/basic/source/comp/exprgen.cxx @@ -115,13 +115,8 @@ void SbiExprNode::Gen( RecursiveMode eRecMode ) } 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 : - (aVar.pDef->IsGlobal() ? _FIND_G : _FIND); + eOp = ( aVar.pDef->GetScope() == SbRTL ) ? _RTL : + (aVar.pDef->IsGlobal() ? _FIND_G : _FIND); } if( eOp == _FIND ) @@ -187,17 +182,6 @@ void SbiExprNode::GenElement( SbiOpcode eOp ) 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() ) ); if( aVar.pvMorePar ) @@ -225,11 +209,6 @@ void SbiExprList::Gen() // AB 10.1.96: Typ-Anpassung bei DECLARE USHORT nCount = 1, nParAnz = 0; SbiSymPool* pPool = NULL; - if( pProc ) - { - pPool = &pProc->GetParams(); - nParAnz = pPool->GetSize(); - } for( SbiExpression* pExpr = pFirst; pExpr; pExpr = pExpr->pNext,nCount++ ) { pExpr->Gen(); @@ -239,6 +218,7 @@ void SbiExprList::Gen() USHORT nSid = pParser->aGblStrings.Add( pExpr->GetName() ); pParser->aGen.Gen( _ARGN, nSid ); + /* TODO: Check after Declare concept change // AB 10.1.96: Typanpassung bei named -> passenden Parameter suchen if( pProc ) { @@ -246,39 +226,26 @@ void SbiExprList::Gen() pParser->Error( SbERR_NO_NAMED_ARGS ); // Spaeter, wenn Named Args bei DECLARE moeglich - /* - for( USHORT i = 1 ; i < nParAnz ; i++ ) - { - SbiSymDef* pDef = pPool->Get( i ); - const String& rName = pDef->GetName(); - if( rName.Len() ) - { - if( pExpr->GetName().ICompare( rName ) - == COMPARE_EQUAL ) - { - pParser->aGen.Gen( _ARGTYP, pDef->GetType() ); - break; - } - } - } - */ + //for( USHORT i = 1 ; i < nParAnz ; i++ ) + //{ + // SbiSymDef* pDef = pPool->Get( i ); + // const String& rName = pDef->GetName(); + // if( rName.Len() ) + // { + // if( pExpr->GetName().ICompare( rName ) + // == COMPARE_EQUAL ) + // { + // pParser->aGen.Gen( _ARGTYP, pDef->GetType() ); + // break; + // } + // } + //} } + */ } else { 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ätzliches Flag für BYVAL einbauen - if( pDef->IsByVal() ) - nTyp |= 0x8000; - pParser->aGen.Gen( _ARGTYP, nTyp ); - } } } } diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 42969b98d0d8..7a4ea5965558 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -338,15 +338,6 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo ) // damit erwischen wir n% = 5 : print n 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: // ist explizit im Scanner etwas anderes angegeben? // Bei Methoden ist dies OK! @@ -868,7 +859,6 @@ SbiExprList::SbiExprList( SbiParser* p ) { pParser = p; pFirst = NULL; - pProc = NULL; nExpr = nDim = 0; bError = diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx index 9b8f51d09dea..851d0d6f1fe5 100644 --- a/basic/source/inc/expr.hxx +++ b/basic/source/inc/expr.hxx @@ -234,7 +234,6 @@ class SbiExprList { // Basisklasse fuer Parameter und Dims protected: SbiParser* pParser; // Parser SbiExpression* pFirst; // Expressions - SbiProcDef* pProc; // DECLARE-Funktion (Parameter-Anpassung) short nExpr; // Anzahl Expressions short nDim; // Anzahl Dimensionen BOOL bError; // TRUE: Fehler @@ -249,8 +248,6 @@ public: SbiExpression* Get( short ); BOOL Test( const SbiProcDef& ); // Parameter-Checks void Gen(); // Code-Erzeugung - // Setzen einer Funktionsdefinition zum Abgleich der Parameter - void SetProc( SbiProcDef* p ) { pProc = p; } void addExpression( SbiExpression* pExpr ); }; diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx index 9bd8cfd49754..f2fbaa0ac1f1 100644 --- a/basic/source/inc/symtbl.hxx +++ b/basic/source/inc/symtbl.hxx @@ -159,7 +159,8 @@ public: void SetOptional() { bOpt = TRUE; } void SetParamArray() { bParamArray = TRUE; } void SetWithEvents() { bWithEvents = TRUE; } - void SetByVal() { bByVal = TRUE; } + void SetByVal( BOOL bByVal_ = TRUE ) + { bByVal = bByVal_; } void SetStatic( BOOL bAsStatic = TRUE ) { bStatic = bAsStatic; } void SetNew() { bNew = TRUE; } void SetDefinedAs() { bAs = TRUE; } diff --git a/scripting/source/basprov/basmodnode.cxx b/scripting/source/basprov/basmodnode.cxx index 22f9e40571a4..fe6ed69fccab 100644 --- a/scripting/source/basprov/basmodnode.cxx +++ b/scripting/source/basprov/basmodnode.cxx @@ -97,14 +97,22 @@ namespace basprov if ( pMethods ) { sal_Int32 nCount = pMethods->Count(); - aChildNodes.realloc( nCount ); - Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray(); - + sal_Int32 nRealCount = 0; for ( sal_Int32 i = 0; i < nCount; ++i ) { SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) ); - if ( pMethod ) - pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) ); + if ( pMethod && !pMethod->IsHidden() ) + ++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 ) ); } } } diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index abd61f6c1285..69cc6f40cd3d 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -412,7 +412,7 @@ namespace basprov if ( pMethods ) { SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( aMethod, SbxCLASS_METHOD ) ); - if ( pMethod ) + if ( pMethod && !pMethod->IsHidden() ) { if ( m_pDocBasicManager == pBasicMgr ) xScript = new BasicScriptImpl( aDescription, pMethod, *m_pDocBasicManager, m_xInvocationContext );