Kaydet (Commit) a272f5b7 authored tarafından Tsutomu Uchino's avatar Tsutomu Uchino Kaydeden (comit) Caolán McNamara

Resolves: #i63614# fix strange type mismatch when Iif function is used

Second or later compilation uses value type returned by previous execution of code.
Use the defined type as return value of the runtime function of Basic always.

(cherry picked from commit 7470c682)

Conflicts:
	basic/inc/basic/sbxmeth.hxx
	basic/inc/basic/sbxobj.hxx
	basic/source/runtime/stdobj.cxx
	basic/source/sbx/sbxobj.cxx

Change-Id: I3064e8403286a9c1401ef658bf139bedeae11f17
üst 89b5423c
...@@ -161,7 +161,15 @@ SbiSymDef* SbiParser::CheckRTLForSym( const OUString& rSym, SbxDataType eType ) ...@@ -161,7 +161,15 @@ SbiSymDef* SbiParser::CheckRTLForSym( const OUString& rSym, SbxDataType eType )
if( pVar->IsA( TYPE(SbxMethod) ) ) if( pVar->IsA( TYPE(SbxMethod) ) )
{ {
SbiProcDef* pProc_ = aRtlSyms.AddProc( rSym ); SbiProcDef* pProc_ = aRtlSyms.AddProc( rSym );
pProc_->SetType( pVar->GetType() ); SbxMethod* pMethod = (SbxMethod*) pVar;
if ( pMethod && pMethod->IsRuntimeFunction() )
{
pProc_->SetType( pMethod->GetRuntimeFunctionReturnType() );
}
else
{
pProc_->SetType( pVar->GetType() );
}
pDef = pProc_; pDef = pProc_;
} }
else else
......
...@@ -802,7 +802,7 @@ SbxVariable* SbiStdObject::Find( const OUString& rName, SbxClassType t ) ...@@ -802,7 +802,7 @@ SbxVariable* SbiStdObject::Find( const OUString& rName, SbxClassType t )
{ {
eCT = SbxCLASS_METHOD; eCT = SbxCLASS_METHOD;
} }
pVar = Make( aName_, eCT, p->eType ); pVar = Make( aName_, eCT, p->eType, ( p->nArgs & _FUNCTION ) == _FUNCTION );
pVar->SetUserData( nIndex + 1 ); pVar->SetUserData( nIndex + 1 );
pVar->SetFlags( nAccess ); pVar->SetFlags( nAccess );
} }
......
...@@ -377,7 +377,7 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) ...@@ -377,7 +377,7 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx )
// If a new object will be established, this object will be indexed, // If a new object will be established, this object will be indexed,
// if an object of this name exists already. // if an object of this name exists already.
SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataType dt ) SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataType dt, bool bIsRuntimeFunction )
{ {
// Is the object already available? // Is the object already available?
SbxArray* pArray = NULL; SbxArray* pArray = NULL;
...@@ -410,7 +410,7 @@ SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataTyp ...@@ -410,7 +410,7 @@ SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataTyp
pVar = new SbxProperty( rName, dt ); pVar = new SbxProperty( rName, dt );
break; break;
case SbxCLASS_METHOD: case SbxCLASS_METHOD:
pVar = new SbxMethod( rName, dt ); pVar = new SbxMethod( rName, dt, bIsRuntimeFunction );
break; break;
case SbxCLASS_OBJECT: case SbxCLASS_OBJECT:
pVar = CreateObject( rName ); pVar = CreateObject( rName );
...@@ -964,14 +964,19 @@ void SbxObject::Dump( SvStream& rStrm, bool bFill ) ...@@ -964,14 +964,19 @@ void SbxObject::Dump( SvStream& rStrm, bool bFill )
--nLevel; --nLevel;
} }
SbxMethod::SbxMethod( const OUString& r, SbxDataType t ) SbxMethod::SbxMethod( const OUString& r, SbxDataType t, bool bIsRuntimeFunction )
: SbxVariable( t ) : SbxVariable(t)
, mbIsRuntimeFunction(bIsRuntimeFunction)
, mbRuntimeFunctionReturnType(t)
{ {
SetName( r ); SetName(r);
} }
SbxMethod::SbxMethod( const SbxMethod& r ) SbxMethod::SbxMethod( const SbxMethod& r )
: SvRefBase( r ), SbxVariable( r ) : SvRefBase(r)
, SbxVariable(r)
, mbIsRuntimeFunction(r.IsRuntimeFunction())
, mbRuntimeFunctionReturnType(r.GetRuntimeFunctionReturnType())
{ {
} }
......
...@@ -25,14 +25,18 @@ ...@@ -25,14 +25,18 @@
class BASIC_DLLPUBLIC SbxMethod : public SbxVariable class BASIC_DLLPUBLIC SbxMethod : public SbxVariable
{ {
bool mbIsRuntimeFunction;
SbxDataType mbRuntimeFunctionReturnType;
public: public:
SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_METHOD,1); SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_METHOD,1);
TYPEINFO_OVERRIDE(); TYPEINFO_OVERRIDE();
SbxMethod( const OUString& r, SbxDataType t ); SbxMethod( const OUString& r, SbxDataType t, bool bIsRuntimeFunction=false );
SbxMethod( const SbxMethod& r ); SbxMethod( const SbxMethod& r );
virtual ~SbxMethod(); virtual ~SbxMethod();
SbxMethod& operator=( const SbxMethod& r ) { SbxVariable::operator=( r ); return *this; } SbxMethod& operator=( const SbxMethod& r ) { SbxVariable::operator=( r ); return *this; }
virtual SbxClassType GetClass() const SAL_OVERRIDE; virtual SbxClassType GetClass() const SAL_OVERRIDE;
bool IsRuntimeFunction() const { return mbIsRuntimeFunction; }
SbxDataType GetRuntimeFunctionReturnType() const{ return mbRuntimeFunctionReturnType; }
}; };
#endif #endif
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
SbxVariable* Execute( const OUString& ); SbxVariable* Execute( const OUString& );
// Manage elements // Manage elements
virtual bool GetAll( SbxClassType ) { return true; } virtual bool GetAll( SbxClassType ) { return true; }
SbxVariable* Make( const OUString&, SbxClassType, SbxDataType ); SbxVariable* Make( const OUString&, SbxClassType, SbxDataType, bool bIsRuntimeFunction = false );
virtual SbxObject* MakeObject( const OUString&, const OUString& ); virtual SbxObject* MakeObject( const OUString&, const OUString& );
virtual void Insert( SbxVariable* ); virtual void Insert( SbxVariable* );
// AB 23.4.1997, Optimization, Insertion without check for duplicate Entries and // AB 23.4.1997, Optimization, Insertion without check for duplicate Entries and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment