summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorAndreas Bregas <ab@openoffice.org>2010-08-06 09:35:51 +0200
committerAndreas Bregas <ab@openoffice.org>2010-08-06 09:35:51 +0200
commit9134fb31919cd977801d2813e60bc3396c8910ec (patch)
tree983a87a3e35c54ef776c68f25c2f716357345ce9 /basic
parentd542107ff02c7cec79307f3e32ec79617a7e03e2 (diff)
mib18: #163121# Declare Rework
Diffstat (limited to 'basic')
-rw-r--r--basic/source/comp/codegen.cxx4
-rw-r--r--basic/source/comp/dim.cxx61
-rw-r--r--basic/source/comp/exprgen.cxx69
-rw-r--r--basic/source/comp/exprtree.cxx10
-rw-r--r--basic/source/inc/expr.hxx3
-rw-r--r--basic/source/inc/symtbl.hxx3
6 files changed, 84 insertions, 66 deletions
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index 42969287d6..256dcf92e0 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 ca0dc06a39..8a55a021d2 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 82b2d39dcf..2594899661 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 389b9e49c2..f858c428af 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 af7302d1e1..96604cbdd9 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 a2a5896943..fd0906e022 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; }