2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-09-17 09:03:42 +00:00
|
|
|
|
2015-05-17 10:08:59 +02:00
|
|
|
#include "parser.hxx"
|
2014-11-14 22:52:35 +01:00
|
|
|
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// All symbol names are laid down int the symbol-pool's stringpool, so that
|
|
|
|
// all symbols are handled in the same case. On saving the code-image, the
|
|
|
|
// global stringpool with the respective symbols is also saved.
|
|
|
|
// The local stringpool holds all the symbols that don't move to the image
|
|
|
|
// (labels, constant names etc.).
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
|*
|
|
|
|
|* SbiStringPool
|
|
|
|
|*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2015-06-07 17:44:13 +02:00
|
|
|
SbiStringPool::SbiStringPool( )
|
|
|
|
{}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
SbiStringPool::~SbiStringPool()
|
|
|
|
{}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& SbiStringPool::Find( sal_uInt32 n ) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-11-20 23:44:21 -05:00
|
|
|
if( n == 0 || n > aData.size() )
|
|
|
|
return aEmpty; //hack, returning a reference to a simulation of null
|
2000-09-18 15:18:56 +00:00
|
|
|
else
|
2011-11-20 23:44:21 -05:00
|
|
|
return aData[n - 1];
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
short SbiStringPool::Add( const OUString& rVal, bool bNoCase )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-11-20 23:44:21 -05:00
|
|
|
sal_uInt32 n = aData.size();
|
|
|
|
for( sal_uInt32 i = 0; i < n; ++i )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString& p = aData[i];
|
2011-11-20 23:44:21 -05:00
|
|
|
if( ( bNoCase && p == rVal )
|
|
|
|
|| ( !bNoCase && p.equalsIgnoreAsciiCase( rVal ) ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
return i+1;
|
|
|
|
}
|
2011-11-20 23:44:21 -05:00
|
|
|
|
2011-11-26 00:06:05 -05:00
|
|
|
aData.push_back(rVal);
|
2011-11-20 23:44:21 -05:00
|
|
|
return (short) ++n;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short SbiStringPool::Add( double n, SbxDataType t )
|
|
|
|
{
|
|
|
|
char buf[ 40 ];
|
|
|
|
switch( t )
|
|
|
|
{
|
2003-03-18 15:28:40 +00:00
|
|
|
case SbxINTEGER: snprintf( buf, sizeof(buf), "%d", (short) n ); break;
|
|
|
|
case SbxLONG: snprintf( buf, sizeof(buf), "%ld", (long) n ); break;
|
|
|
|
case SbxSINGLE: snprintf( buf, sizeof(buf), "%.6g", (float) n ); break;
|
|
|
|
case SbxDOUBLE: snprintf( buf, sizeof(buf), "%.16g", n ); break;
|
2006-06-19 16:43:20 +00:00
|
|
|
default: break;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
return Add( OUString::createFromAscii( buf ) );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
|*
|
|
|
|
|* SbiSymPool
|
|
|
|
|*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2015-06-07 17:44:13 +02:00
|
|
|
SbiSymPool::SbiSymPool( SbiStringPool& r, SbiSymScope s, SbiParser* pP ) : rStrings( r ), pParser( pP )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
eScope = s;
|
|
|
|
pParent = NULL;
|
|
|
|
nCur =
|
|
|
|
nProcId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SbiSymPool::~SbiSymPool()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
SbiSymDef* SbiSymPool::First()
|
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
nCur = (sal_uInt16) -1;
|
2000-09-18 15:18:56 +00:00
|
|
|
return Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
SbiSymDef* SbiSymPool::Next()
|
|
|
|
{
|
2012-06-10 12:47:02 +02:00
|
|
|
if( ++nCur >= aData.size() )
|
2000-09-18 15:18:56 +00:00
|
|
|
return NULL;
|
|
|
|
else
|
2014-07-17 14:19:37 +09:00
|
|
|
return &aData[ nCur ];
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
SbiSymDef* SbiSymPool::AddSym( const OUString& rName )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
SbiSymDef* p = new SbiSymDef( rName );
|
2012-06-10 12:47:02 +02:00
|
|
|
p->nPos = aData.size();
|
2000-09-18 15:18:56 +00:00
|
|
|
p->nId = rStrings.Add( rName );
|
|
|
|
p->nProcId = nProcId;
|
|
|
|
p->pIn = this;
|
2012-06-10 12:47:02 +02:00
|
|
|
aData.insert( aData.begin() + p->nPos, p );
|
2000-09-18 15:18:56 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
SbiProcDef* SbiSymPool::AddProc( const OUString& rName )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
SbiProcDef* p = new SbiProcDef( pParser, rName );
|
2012-06-10 12:47:02 +02:00
|
|
|
p->nPos = aData.size();
|
2000-09-18 15:18:56 +00:00
|
|
|
p->nId = rStrings.Add( rName );
|
2011-08-27 21:37:14 +02:00
|
|
|
// procs are always local
|
2000-09-18 15:18:56 +00:00
|
|
|
p->nProcId = 0;
|
|
|
|
p->pIn = this;
|
2012-06-10 12:47:02 +02:00
|
|
|
aData.insert( aData.begin() + p->nPos, p );
|
2000-09-18 15:18:56 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// adding an externally constructed symbol definition
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
void SbiSymPool::Add( SbiSymDef* pDef )
|
|
|
|
{
|
|
|
|
if( pDef && pDef->pIn != this )
|
|
|
|
{
|
|
|
|
if( pDef->pIn )
|
|
|
|
{
|
2009-07-10 14:03:42 +02:00
|
|
|
#ifdef DBG_UTIL
|
2011-08-27 21:37:14 +02:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
pParser->Error( SbERR_INTERNAL_ERROR, "Dbl Pool" );
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-10 12:47:02 +02:00
|
|
|
pDef->nPos = aData.size();
|
2000-09-18 15:18:56 +00:00
|
|
|
if( !pDef->nId )
|
|
|
|
{
|
2011-08-27 21:37:14 +02:00
|
|
|
// A unique name must be created in the string pool
|
|
|
|
// for static variables (Form ProcName:VarName)
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString aName( pDef->aName );
|
2000-09-18 15:18:56 +00:00
|
|
|
if( pDef->IsStatic() )
|
|
|
|
{
|
|
|
|
aName = pParser->aGblStrings.Find( nProcId );
|
2012-11-06 23:34:23 -06:00
|
|
|
aName += ":";
|
2000-09-18 15:18:56 +00:00
|
|
|
aName += pDef->aName;
|
|
|
|
}
|
|
|
|
pDef->nId = rStrings.Add( aName );
|
|
|
|
}
|
2011-08-27 21:37:14 +02:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
if( !pDef->GetProcDef() )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
pDef->nProcId = nProcId;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
pDef->pIn = this;
|
2012-06-10 12:47:02 +02:00
|
|
|
aData.insert( aData.begin() + pDef->nPos, pDef );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-17 14:19:37 +09:00
|
|
|
SbiSymDef* SbiSymPool::Find( const OUString& rName )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2012-06-10 12:47:02 +02:00
|
|
|
sal_uInt16 nCount = aData.size();
|
2011-01-10 14:40:57 +01:00
|
|
|
for( sal_uInt16 i = 0; i < nCount; i++ )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2014-07-17 14:19:37 +09:00
|
|
|
SbiSymDef &r = aData[ nCount - i - 1 ];
|
|
|
|
if( ( !r.nProcId || ( r.nProcId == nProcId)) &&
|
|
|
|
( r.aName.equalsIgnoreAsciiCase(rName)))
|
2012-11-06 23:34:23 -06:00
|
|
|
{
|
2014-07-17 14:19:37 +09:00
|
|
|
return &r;
|
2012-11-06 23:34:23 -06:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
if( pParent )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
return pParent->Find( rName );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
else
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
return NULL;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// find via position (from 0)
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2014-07-17 14:19:37 +09:00
|
|
|
SbiSymDef* SbiSymPool::Get( sal_uInt16 n )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2012-06-10 12:47:02 +02:00
|
|
|
if( n >= aData.size() )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
return NULL;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
else
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2014-07-17 14:19:37 +09:00
|
|
|
return &aData[ n ];
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
sal_uInt32 SbiSymPool::Define( const OUString& rName )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
SbiSymDef* p = Find( rName );
|
|
|
|
if( p )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
|
|
|
if( p->IsDefined() )
|
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
pParser->Error( SbERR_LABEL_DEFINED, rName );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
p = AddSym( rName );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
return p->Define();
|
|
|
|
}
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
sal_uInt32 SbiSymPool::Reference( const OUString& rName )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
SbiSymDef* p = Find( rName );
|
|
|
|
if( !p )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
p = AddSym( rName );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2011-08-27 21:37:14 +02:00
|
|
|
// to be sure
|
2000-09-18 15:18:56 +00:00
|
|
|
pParser->aGen.GenStmnt();
|
|
|
|
return p->Reference();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SbiSymPool::CheckRefs()
|
|
|
|
{
|
2015-05-28 14:29:05 +02:00
|
|
|
for( size_t i = 0; i < aData.size(); i++ )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2014-07-17 14:19:37 +09:00
|
|
|
SbiSymDef &r = aData[ i ];
|
|
|
|
if( !r.IsDefined() )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2014-07-17 14:19:37 +09:00
|
|
|
pParser->Error( SbERR_UNDEF_LABEL, r.GetName() );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
|*
|
2011-08-27 21:37:14 +02:00
|
|
|
|* symbol definitions
|
2000-09-18 15:18:56 +00:00
|
|
|
|*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
SbiSymDef::SbiSymDef( const OUString& rName ) : aName( rName )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
eType = SbxEMPTY;
|
2006-11-03 14:11:10 +00:00
|
|
|
nDims = 0;
|
|
|
|
nTypeId = 0;
|
|
|
|
nProcId = 0;
|
|
|
|
nId = 0;
|
|
|
|
nPos = 0;
|
|
|
|
nLen = 0;
|
2000-09-18 15:18:56 +00:00
|
|
|
nChain = 0;
|
|
|
|
bAs =
|
|
|
|
bNew =
|
|
|
|
bStatic =
|
|
|
|
bOpt =
|
2005-01-28 15:06:49 +00:00
|
|
|
bParamArray =
|
2010-06-15 20:02:53 +02:00
|
|
|
bWithEvents =
|
2011-03-25 10:40:25 +01:00
|
|
|
bWithBrackets =
|
2000-09-18 15:18:56 +00:00
|
|
|
bByVal =
|
2001-09-04 09:07:46 +00:00
|
|
|
bChained =
|
2012-08-14 07:32:51 +09:00
|
|
|
bGlobal = false;
|
2000-09-18 15:18:56 +00:00
|
|
|
pIn =
|
|
|
|
pPool = NULL;
|
2004-03-17 12:33:51 +00:00
|
|
|
nDefaultId = 0;
|
2010-06-15 20:02:53 +02:00
|
|
|
nFixedStringLength = -1;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SbiSymDef::~SbiSymDef()
|
|
|
|
{
|
|
|
|
delete pPool;
|
|
|
|
}
|
|
|
|
|
|
|
|
SbiProcDef* SbiSymDef::GetProcDef()
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SbiConstDef* SbiSymDef::GetConstDef()
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
const OUString& SbiSymDef::GetName()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if( pIn )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
aName = pIn->rStrings.Find( nId );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
return aName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SbiSymDef::SetType( SbxDataType t )
|
|
|
|
{
|
|
|
|
if( t == SbxVARIANT && pIn )
|
|
|
|
{
|
2014-11-14 14:18:51 +00:00
|
|
|
//See if there have been any deftype statements to set the default type
|
|
|
|
//of a variable based on its starting letter
|
2012-11-06 23:34:23 -06:00
|
|
|
sal_Unicode cu = aName[0];
|
2004-09-09 06:43:30 +00:00
|
|
|
if( cu < 256 )
|
|
|
|
{
|
2012-11-06 23:34:23 -06:00
|
|
|
char ch = (char)cu;
|
|
|
|
if( ch == '_' )
|
|
|
|
{
|
|
|
|
ch = 'Z';
|
|
|
|
}
|
2006-10-12 13:27:56 +00:00
|
|
|
int ch2 = toupper( ch );
|
2014-11-14 14:18:51 +00:00
|
|
|
int nIndex = ch2 - 'A';
|
|
|
|
if (nIndex >= 0 && nIndex < N_DEF_TYPES)
|
|
|
|
t = pIn->pParser->eDefTypes[nIndex];
|
2004-09-09 06:43:30 +00:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
eType = t;
|
|
|
|
}
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// construct a backchain, if not yet defined
|
|
|
|
// the value that shall be stored as an operand is returned
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 SbiSymDef::Reference()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if( !bChained )
|
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 n = nChain;
|
2000-09-18 15:18:56 +00:00
|
|
|
nChain = pIn->pParser->aGen.GetOffset();
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
else return nChain;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 SbiSymDef::Define()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 n = pIn->pParser->aGen.GetPC();
|
2000-09-18 15:18:56 +00:00
|
|
|
pIn->pParser->aGen.GenStmnt();
|
2012-11-06 23:34:23 -06:00
|
|
|
if( nChain )
|
|
|
|
{
|
|
|
|
pIn->pParser->aGen.BackChain( nChain );
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
nChain = n;
|
2012-08-14 07:32:51 +09:00
|
|
|
bChained = true;
|
2000-09-18 15:18:56 +00:00
|
|
|
return nChain;
|
|
|
|
}
|
|
|
|
|
2013-10-04 16:57:18 +02:00
|
|
|
// A symbol definition may have its own pool. This is the case
|
2011-08-27 21:37:14 +02:00
|
|
|
// for objects and procedures (local variable)
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
SbiSymPool& SbiSymDef::GetPool()
|
|
|
|
{
|
|
|
|
if( !pPool )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2015-06-07 17:44:13 +02:00
|
|
|
pPool = new SbiSymPool( pIn->pParser->aGblStrings, SbLOCAL, pIn->pParser ); // is dumped
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
return *pPool;
|
|
|
|
}
|
|
|
|
|
|
|
|
SbiSymScope SbiSymDef::GetScope() const
|
|
|
|
{
|
|
|
|
return pIn ? pIn->GetScope() : SbLOCAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// The procedure definition has three pools:
|
|
|
|
// 1) aParams: is filled by the definition. Contains the
|
|
|
|
// parameters' names, like they're used inside the body.
|
|
|
|
// The first element is the return value.
|
|
|
|
// 2) pPool: all local variables
|
|
|
|
// 3) aLabels: labels
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
SbiProcDef::SbiProcDef( SbiParser* pParser, const OUString& rName,
|
2012-08-22 19:20:19 +09:00
|
|
|
bool bProcDecl )
|
2002-08-12 10:57:34 +00:00
|
|
|
: SbiSymDef( rName )
|
2015-06-07 17:44:13 +02:00
|
|
|
, aParams( pParser->aGblStrings, SbPARAM, pParser ) // is dumped
|
|
|
|
, aLabels( pParser->aLclStrings, SbLOCAL, pParser ) // is not dumped
|
2002-08-12 10:57:34 +00:00
|
|
|
, mbProcDecl( bProcDecl )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
aParams.SetParent( &pParser->aPublics );
|
2015-06-07 17:44:13 +02:00
|
|
|
pPool = new SbiSymPool( pParser->aGblStrings, SbLOCAL, pParser );
|
2000-09-18 15:18:56 +00:00
|
|
|
pPool->SetParent( &aParams );
|
|
|
|
nLine1 =
|
|
|
|
nLine2 = 0;
|
2015-06-04 08:29:58 +02:00
|
|
|
mePropMode = PropertyMode::NONE;
|
2012-08-20 09:44:32 +09:00
|
|
|
bPublic = true;
|
2012-08-22 19:20:19 +09:00
|
|
|
bCdecl = false;
|
|
|
|
bStatic = false;
|
2011-08-27 21:37:14 +02:00
|
|
|
// For return values the first element of the parameter
|
|
|
|
// list is always defined with name and type of the proc
|
2000-09-18 15:18:56 +00:00
|
|
|
aParams.AddSym( aName );
|
|
|
|
}
|
|
|
|
|
|
|
|
SbiProcDef::~SbiProcDef()
|
|
|
|
{}
|
|
|
|
|
|
|
|
SbiProcDef* SbiProcDef::GetProcDef()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SbiProcDef::SetType( SbxDataType t )
|
|
|
|
{
|
|
|
|
SbiSymDef::SetType( t );
|
|
|
|
aParams.Get( 0 )->SetType( eType );
|
|
|
|
}
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// match with a forward-declaration
|
|
|
|
// if the match is OK, pOld is replaced by this in the pool
|
|
|
|
// pOld is deleted in any case!
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
void SbiProcDef::Match( SbiProcDef* pOld )
|
|
|
|
{
|
2013-10-07 11:18:59 +01:00
|
|
|
SbiSymDef *pn=NULL;
|
2011-08-27 21:37:14 +02:00
|
|
|
// parameter 0 is the function name
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 i;
|
2000-09-18 15:18:56 +00:00
|
|
|
for( i = 1; i < aParams.GetSize(); i++ )
|
|
|
|
{
|
2013-10-07 11:18:59 +01:00
|
|
|
SbiSymDef* po = pOld->aParams.Get( i );
|
2000-09-18 15:18:56 +00:00
|
|
|
pn = aParams.Get( i );
|
2011-08-27 21:37:14 +02:00
|
|
|
// no type matching - that is done during running
|
|
|
|
// but is it maybe called with too little parameters?
|
2005-01-28 15:06:49 +00:00
|
|
|
if( !po && !pn->IsOptional() && !pn->IsParamArray() )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2013-10-07 11:18:59 +01:00
|
|
|
pOld->aParams.Next();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2011-08-27 21:37:14 +02:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
if( pn && i < aParams.GetSize() && pOld->pIn )
|
|
|
|
{
|
2011-08-27 21:37:14 +02:00
|
|
|
// mark the whole line
|
2000-09-18 15:18:56 +00:00
|
|
|
pOld->pIn->GetParser()->SetCol1( 0 );
|
|
|
|
pOld->pIn->GetParser()->Error( SbERR_BAD_DECLARATION, aName );
|
|
|
|
}
|
|
|
|
if( !pIn && pOld->pIn )
|
|
|
|
{
|
2011-11-24 23:56:22 -08:00
|
|
|
// Replace old entry with the new one
|
2000-09-18 15:18:56 +00:00
|
|
|
nPos = pOld->nPos;
|
|
|
|
nId = pOld->nId;
|
|
|
|
pIn = pOld->pIn;
|
2014-07-17 14:19:37 +09:00
|
|
|
pIn->aData.replace( nPos, this ).release();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
delete pOld;
|
|
|
|
}
|
|
|
|
|
2004-11-02 10:54:38 +00:00
|
|
|
void SbiProcDef::setPropertyMode( PropertyMode ePropMode )
|
|
|
|
{
|
|
|
|
mePropMode = ePropMode;
|
2015-06-04 08:29:58 +02:00
|
|
|
if( mePropMode != PropertyMode::NONE )
|
2004-11-02 10:54:38 +00:00
|
|
|
{
|
|
|
|
// Prop name = original scanned procedure name
|
|
|
|
maPropName = aName;
|
|
|
|
|
|
|
|
// CompleteProcName includes "Property xxx "
|
|
|
|
// to avoid conflicts with other symbols
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString aCompleteProcName = "Property ";
|
2004-11-02 10:54:38 +00:00
|
|
|
switch( mePropMode )
|
|
|
|
{
|
2015-06-04 08:29:58 +02:00
|
|
|
case PropertyMode::Get: aCompleteProcName += "Get "; break;
|
|
|
|
case PropertyMode::Let: aCompleteProcName += "Let "; break;
|
|
|
|
case PropertyMode::Set: aCompleteProcName += "Set "; break;
|
|
|
|
case PropertyMode::NONE: OSL_FAIL( "Illegal PropertyMode PropertyMode::NONE" ); break;
|
2004-11-02 10:54:38 +00:00
|
|
|
}
|
|
|
|
aCompleteProcName += aName;
|
|
|
|
aName = aCompleteProcName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
SbiConstDef::SbiConstDef( const OUString& rName )
|
2000-09-18 15:18:56 +00:00
|
|
|
: SbiSymDef( rName )
|
|
|
|
{
|
|
|
|
nVal = 0; eType = SbxINTEGER;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SbiConstDef::Set( double n, SbxDataType t )
|
|
|
|
{
|
2014-12-18 13:20:44 +01:00
|
|
|
aVal.clear(); nVal = n; eType = t;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
void SbiConstDef::Set( const OUString& n )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
aVal = n; nVal = 0; eType = SbxSTRING;
|
|
|
|
}
|
|
|
|
|
|
|
|
SbiConstDef::~SbiConstDef()
|
|
|
|
{}
|
|
|
|
|
|
|
|
SbiConstDef* SbiConstDef::GetConstDef()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|