Avoid reserved identifiers

Change-Id: I3fbc7cb107bdab770d5ce9ed3ecddb962d2d4666
This commit is contained in:
Stephan Bergmann
2016-04-05 21:04:31 +02:00
parent b87c4d8a75
commit 7beeced463
8 changed files with 280 additions and 280 deletions

View File

@@ -1481,7 +1481,7 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine,
{ {
SbiOpcode eOp = (SbiOpcode ) ( *p++ ); SbiOpcode eOp = (SbiOpcode ) ( *p++ );
nPC++; nPC++;
if( bFollowJumps && eOp == _JUMP && pImg ) if( bFollowJumps && eOp == JUMP_ && pImg )
{ {
SAL_WARN_IF( !pImg, "basic", "FindNextStmnt: pImg==NULL with FollowJumps option" ); SAL_WARN_IF( !pImg, "basic", "FindNextStmnt: pImg==NULL with FollowJumps option" );
sal_uInt32 nOp1 = *p++; nOp1 |= *p++ << 8; sal_uInt32 nOp1 = *p++; nOp1 |= *p++ << 8;
@@ -1493,7 +1493,7 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine,
p += 4; p += 4;
nPC += 4; nPC += 4;
} }
else if( eOp == _STMNT ) else if( eOp == STMNT_ )
{ {
sal_uInt32 nl, nc; sal_uInt32 nl, nc;
nl = *p++; nl |= *p++ << 8; nl = *p++; nl |= *p++ << 8;

View File

@@ -71,7 +71,7 @@ void SbiCodeGen::GenStmnt()
if( bStmnt ) if( bStmnt )
{ {
bStmnt = false; bStmnt = false;
Gen( _STMNT, nLine, nCol ); Gen( STMNT_, nLine, nCol );
} }
} }
@@ -508,17 +508,17 @@ public:
m_ConvertedBuf += (sal_uInt8)eOp; m_ConvertedBuf += (sal_uInt8)eOp;
switch( eOp ) switch( eOp )
{ {
case _JUMP: case JUMP_:
case _JUMPT: case JUMPT_:
case _JUMPF: case JUMPF_:
case _GOSUB: case GOSUB_:
case _CASEIS: case CASEIS_:
case _RETURN: case RETURN_:
case _ERRHDL: case ERRHDL_:
case _TESTFOR: case TESTFOR_:
nOp1 = static_cast<T>( convertBufferOffSet(m_pStart, nOp1) ); nOp1 = static_cast<T>( convertBufferOffSet(m_pStart, nOp1) );
break; break;
case _RESUME: case RESUME_:
if ( nOp1 > 1 ) if ( nOp1 > 1 )
nOp1 = static_cast<T>( convertBufferOffSet(m_pStart, nOp1) ); nOp1 = static_cast<T>( convertBufferOffSet(m_pStart, nOp1) );
break; break;
@@ -531,7 +531,7 @@ public:
virtual void processOpCode2( SbiOpcode eOp, T nOp1, T nOp2 ) override virtual void processOpCode2( SbiOpcode eOp, T nOp1, T nOp2 ) override
{ {
m_ConvertedBuf += (sal_uInt8)eOp; m_ConvertedBuf += (sal_uInt8)eOp;
if ( eOp == _CASEIS ) if ( eOp == CASEIS_ )
if ( nOp1 ) if ( nOp1 )
nOp1 = static_cast<T>( convertBufferOffSet(m_pStart, nOp1) ); nOp1 = static_cast<T>( convertBufferOffSet(m_pStart, nOp1) );
m_ConvertedBuf += static_cast<S>(nOp1); m_ConvertedBuf += static_cast<S>(nOp1);

View File

@@ -197,7 +197,7 @@ void SbiParser::TypeDecl( SbiSymDef& rDef, bool bAsNewAlreadyParsed )
void SbiParser::Dim() void SbiParser::Dim()
{ {
DefVar( _DIM, pProc && bVBASupportOn && pProc->IsStatic() ); DefVar( DIM_, pProc && bVBASupportOn && pProc->IsStatic() );
} }
void SbiParser::DefVar( SbiOpcode eOp, bool bStatic ) void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
@@ -248,7 +248,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
// SbiParser::Parse() under these conditions // SbiParser::Parse() under these conditions
if( bNewGblDefs && nGblChain == 0 ) if( bNewGblDefs && nGblChain == 0 )
{ {
nGblChain = aGen.Gen( _JUMP, 0 ); nGblChain = aGen.Gen( JUMP_, 0 );
bNewGblDefs = false; bNewGblDefs = false;
} }
Next(); Next();
@@ -290,8 +290,8 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
if( Peek() == PRESERVE ) if( Peek() == PRESERVE )
{ {
Next(); Next();
if( eOp == _REDIM ) if( eOp == REDIM_ )
eOp = _REDIMP; eOp = REDIMP_;
else else
Error( ERRCODE_BASIC_UNEXPECTED, eCurTok ); Error( ERRCODE_BASIC_UNEXPECTED, eCurTok );
} }
@@ -302,7 +302,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
sal_uInt32 nEndOfStaticLbl = 0; sal_uInt32 nEndOfStaticLbl = 0;
if( !bVBASupportOn && bStatic ) if( !bVBASupportOn && bStatic )
{ {
nEndOfStaticLbl = aGen.Gen( _JUMP, 0 ); nEndOfStaticLbl = aGen.Gen( JUMP_, 0 );
aGen.Statement(); // catch up on static here aGen.Statement(); // catch up on static here
} }
@@ -324,7 +324,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
if( pOld ) if( pOld )
bRtlSym = true; bRtlSym = true;
} }
if( pOld && !(eOp == _REDIM || eOp == _REDIMP) ) if( pOld && !(eOp == REDIM_ || eOp == REDIMP_) )
{ {
if( pDef->GetScope() == SbLOCAL && pOld->GetScope() != SbLOCAL ) if( pDef->GetScope() == SbLOCAL && pOld->GetScope() != SbLOCAL )
pOld = nullptr; pOld = nullptr;
@@ -333,7 +333,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
{ {
bDefined = true; bDefined = true;
// always an error at a RTL-S // always an error at a RTL-S
if( !bRtlSym && (eOp == _REDIM || eOp == _REDIMP) ) if( !bRtlSym && (eOp == REDIM_ || eOp == REDIMP_) )
{ {
// compare the attributes at a REDIM // compare the attributes at a REDIM
SbxDataType eDefType; SbxDataType eDefType;
@@ -359,27 +359,27 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
// #36374: Create the variable in front of the distinction IsNew() // #36374: Create the variable in front of the distinction IsNew()
// Otherwise error at Dim Identifier As New Type and option explicit // Otherwise error at Dim Identifier As New Type and option explicit
if( !bDefined && !(eOp == _REDIM || eOp == _REDIMP) if( !bDefined && !(eOp == REDIM_ || eOp == REDIMP_)
&& ( !bConst || pDef->GetScope() == SbGLOBAL ) ) && ( !bConst || pDef->GetScope() == SbGLOBAL ) )
{ {
// Declare variable or global constant // Declare variable or global constant
SbiOpcode eOp2; SbiOpcode eOp2;
switch ( pDef->GetScope() ) switch ( pDef->GetScope() )
{ {
case SbGLOBAL: eOp2 = bPersistantGlobal ? _GLOBAL_P : _GLOBAL; case SbGLOBAL: eOp2 = bPersistantGlobal ? GLOBAL_P_ : GLOBAL_;
goto global; goto global;
case SbPUBLIC: eOp2 = bPersistantGlobal ? _PUBLIC_P : _PUBLIC; case SbPUBLIC: eOp2 = bPersistantGlobal ? PUBLIC_P_ : PUBLIC_;
// #40689, no own Opcode anymore // #40689, no own Opcode anymore
if( bVBASupportOn && bStatic ) if( bVBASupportOn && bStatic )
{ {
eOp2 = _STATIC; eOp2 = STATIC_;
break; break;
} }
global: aGen.BackChain( nGblChain ); global: aGen.BackChain( nGblChain );
nGblChain = 0; nGblChain = 0;
bGblDefs = bNewGblDefs = true; bGblDefs = bNewGblDefs = true;
break; break;
default: eOp2 = _LOCAL; default: eOp2 = LOCAL_;
} }
sal_uInt32 nOpnd2 = sal::static_int_cast< sal_uInt16 >( pDef->GetType() ); sal_uInt32 nOpnd2 = sal::static_int_cast< sal_uInt16 >( pDef->GetType() );
if( pDef->IsWithEvents() ) if( pDef->IsWithEvents() )
@@ -425,35 +425,35 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
if( pDim ) if( pDim )
{ {
if( eOp == _REDIMP ) if( eOp == REDIMP_ )
{ {
SbiExpression aExpr( this, *pDef, nullptr ); SbiExpression aExpr( this, *pDef, nullptr );
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _REDIMP_ERASE ); aGen.Gen( REDIMP_ERASE_ );
pDef->SetDims( pDim->GetDims() ); pDef->SetDims( pDim->GetDims() );
SbiExpression aExpr2( this, *pDef, std::move(pDim) ); SbiExpression aExpr2( this, *pDef, std::move(pDim) );
aExpr2.Gen(); aExpr2.Gen();
aGen.Gen( _DCREATE_REDIMP, pDef->GetId(), pDef->GetTypeId() ); aGen.Gen( DCREATE_REDIMP_, pDef->GetId(), pDef->GetTypeId() );
} }
else else
{ {
pDef->SetDims( pDim->GetDims() ); pDef->SetDims( pDim->GetDims() );
SbiExpression aExpr( this, *pDef, std::move(pDim) ); SbiExpression aExpr( this, *pDef, std::move(pDim) );
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _DCREATE, pDef->GetId(), pDef->GetTypeId() ); aGen.Gen( DCREATE_, pDef->GetId(), pDef->GetTypeId() );
} }
} }
else else
{ {
SbiExpression aExpr( this, *pDef ); SbiExpression aExpr( this, *pDef );
aExpr.Gen(); aExpr.Gen();
SbiOpcode eOp_ = pDef->IsNew() ? _CREATE : _TCREATE; SbiOpcode eOp_ = pDef->IsNew() ? CREATE_ : TCREATE_;
aGen.Gen( eOp_, pDef->GetId(), pDef->GetTypeId() ); aGen.Gen( eOp_, pDef->GetId(), pDef->GetTypeId() );
if ( bVBASupportOn ) if ( bVBASupportOn )
aGen.Gen( _VBASET ); aGen.Gen( VBASET_ );
else else
aGen.Gen( _SET ); aGen.Gen( SET_ );
} }
} }
else else
@@ -476,7 +476,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
// Create code only for the global constant! // Create code only for the global constant!
aVar.Gen(); aVar.Gen();
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _PUTC ); aGen.Gen( PUTC_ );
} }
SbiConstDef* pConst = pDef->GetConstDef(); SbiConstDef* pConst = pDef->GetConstDef();
if( aExpr.GetType() == SbxSTRING ) if( aExpr.GetType() == SbxSTRING )
@@ -489,7 +489,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
{ {
// Dimension the variable // Dimension the variable
// Delete the var at REDIM beforehand // Delete the var at REDIM beforehand
if( eOp == _REDIM ) if( eOp == REDIM_ )
{ {
SbiExpression aExpr( this, *pDef, nullptr ); SbiExpression aExpr( this, *pDef, nullptr );
aExpr.Gen(); aExpr.Gen();
@@ -498,15 +498,15 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
// clear the variable ( this // clear the variable ( this
// allows the processing of // allows the processing of
// the param to happen as normal without errors ( ordinary ERASE just clears the array ) // the param to happen as normal without errors ( ordinary ERASE just clears the array )
aGen.Gen( _ERASE_CLEAR ); aGen.Gen( ERASE_CLEAR_ );
else else
aGen.Gen( _ERASE ); aGen.Gen( ERASE_ );
} }
else if( eOp == _REDIMP ) else if( eOp == REDIMP_ )
{ {
SbiExpression aExpr( this, *pDef, nullptr ); SbiExpression aExpr( this, *pDef, nullptr );
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _REDIMP_ERASE ); aGen.Gen( REDIMP_ERASE_ );
} }
pDef->SetDims( pDim->GetDims() ); pDef->SetDims( pDim->GetDims() );
if( bPersistantGlobal ) if( bPersistantGlobal )
@@ -514,7 +514,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
SbiExpression aExpr( this, *pDef, std::move(pDim) ); SbiExpression aExpr( this, *pDef, std::move(pDim) );
aExpr.Gen(); aExpr.Gen();
pDef->SetGlobal( false ); pDef->SetGlobal( false );
aGen.Gen( (eOp == _STATIC) ? _DIM : eOp ); aGen.Gen( (eOp == STATIC_) ? DIM_ : eOp );
} }
} }
if( !TestComma() ) if( !TestComma() )
@@ -536,7 +536,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
if( !bVBASupportOn && bStatic ) if( !bVBASupportOn && bStatic )
{ {
// maintain the global chain // maintain the global chain
nGblChain = aGen.Gen( _JUMP, 0 ); nGblChain = aGen.Gen( JUMP_, 0 );
bGblDefs = bNewGblDefs = true; bGblDefs = bNewGblDefs = true;
// Register for Sub a jump to the end of statics // Register for Sub a jump to the end of statics
@@ -549,7 +549,7 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
void SbiParser::ReDim() void SbiParser::ReDim()
{ {
DefVar( _REDIM, pProc && bVBASupportOn && pProc->IsStatic() ); DefVar( REDIM_, pProc && bVBASupportOn && pProc->IsStatic() );
} }
// ERASE array, ... // ERASE array, ...
@@ -560,7 +560,7 @@ void SbiParser::Erase()
{ {
SbiExpression aExpr( this, SbLVALUE ); SbiExpression aExpr( this, SbLVALUE );
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _ERASE ); aGen.Gen( ERASE_ );
if( !TestComma() ) break; if( !TestComma() ) break;
} }
} }
@@ -782,7 +782,7 @@ void SbiParser::DefEnum( bool bPrivate )
if( !bPrivate ) if( !bPrivate )
{ {
SbiOpcode eOp = _GLOBAL; SbiOpcode eOp = GLOBAL_;
aGen.BackChain( nGblChain ); aGen.BackChain( nGblChain );
nGblChain = 0; nGblChain = 0;
bGblDefs = bNewGblDefs = true; bGblDefs = bNewGblDefs = true;
@@ -792,8 +792,8 @@ void SbiParser::DefEnum( bool bPrivate )
aVar.Gen(); aVar.Gen();
sal_uInt16 nStringId = aGen.GetParser()->aGblStrings.Add( nCurrentEnumValue, SbxLONG ); sal_uInt16 nStringId = aGen.GetParser()->aGblStrings.Add( nCurrentEnumValue, SbxLONG );
aGen.Gen( _NUMBER, nStringId ); aGen.Gen( NUMBER_, nStringId );
aGen.Gen( _PUTC ); aGen.Gen( PUTC_ );
} }
SbiConstDef* pConst = pElem->GetConstDef(); SbiConstDef* pConst = pElem->GetConstDef();
@@ -1057,7 +1057,7 @@ void SbiParser::DefDeclare( bool bPrivate )
{ {
if( bNewGblDefs && nGblChain == 0 ) if( bNewGblDefs && nGblChain == 0 )
{ {
nGblChain = aGen.Gen( _JUMP, 0 ); nGblChain = aGen.Gen( JUMP_, 0 );
bNewGblDefs = false; bNewGblDefs = false;
} }
@@ -1073,19 +1073,19 @@ void SbiParser::DefDeclare( bool bPrivate )
SbxDataType eType = pDef->GetType(); SbxDataType eType = pDef->GetType();
if( bFunction ) if( bFunction )
{ {
aGen.Gen( _PARAM, 0, sal::static_int_cast< sal_uInt16 >( eType ) ); aGen.Gen( PARAM_, 0, sal::static_int_cast< sal_uInt16 >( eType ) );
} }
if( nParCount > 1 ) if( nParCount > 1 )
{ {
aGen.Gen( _ARGC ); aGen.Gen( ARGC_ );
for( sal_uInt16 i = 1 ; i < nParCount ; ++i ) for( sal_uInt16 i = 1 ; i < nParCount ; ++i )
{ {
SbiSymDef* pParDef = rPool.Get( i ); SbiSymDef* pParDef = rPool.Get( i );
SbxDataType eParType = pParDef->GetType(); SbxDataType eParType = pParDef->GetType();
aGen.Gen( _PARAM, i, sal::static_int_cast< sal_uInt16 >( eParType ) ); aGen.Gen( PARAM_, i, sal::static_int_cast< sal_uInt16 >( eParType ) );
aGen.Gen( _ARGV ); aGen.Gen( ARGV_ );
sal_uInt16 nTyp = sal::static_int_cast< sal_uInt16 >( pParDef->GetType() ); sal_uInt16 nTyp = sal::static_int_cast< sal_uInt16 >( pParDef->GetType() );
if( pParDef->IsByVal() ) if( pParDef->IsByVal() )
@@ -1094,13 +1094,13 @@ void SbiParser::DefDeclare( bool bPrivate )
pParDef->SetByVal( false ); pParDef->SetByVal( false );
nTyp |= 0x8000; nTyp |= 0x8000;
} }
aGen.Gen( _ARGTYP, nTyp ); aGen.Gen( ARGTYP_, nTyp );
} }
} }
aGen.Gen( _LIB, aGblStrings.Add( pDef->GetLib() ) ); aGen.Gen( LIB_, aGblStrings.Add( pDef->GetLib() ) );
SbiOpcode eOp = pDef->IsCdecl() ? _CALLC : _CALL; SbiOpcode eOp = pDef->IsCdecl() ? CALLC_ : CALL_;
sal_uInt16 nId = pDef->GetId(); sal_uInt16 nId = pDef->GetId();
if( !pDef->GetAlias().isEmpty() ) if( !pDef->GetAlias().isEmpty() )
{ {
@@ -1114,9 +1114,9 @@ void SbiParser::DefDeclare( bool bPrivate )
if( bFunction ) if( bFunction )
{ {
aGen.Gen( _PUT ); aGen.Gen( PUT_ );
} }
aGen.Gen( _LEAVE ); aGen.Gen( LEAVE_ );
} }
} }
} }
@@ -1151,7 +1151,7 @@ void SbiParser::Call()
{ {
SbiExpression aVar( this, SbSYMBOL ); SbiExpression aVar( this, SbSYMBOL );
aVar.Gen( FORCE_CALL ); aVar.Gen( FORCE_CALL );
aGen.Gen( _GET ); aGen.Gen( GET_ );
} }
// SUB/FUNCTION // SUB/FUNCTION
@@ -1271,7 +1271,7 @@ void SbiParser::DefProc( bool bStatic, bool bPrivate )
// Open labels? // Open labels?
pProc->GetLabels().CheckRefs(); pProc->GetLabels().CheckRefs();
CloseBlock(); CloseBlock();
aGen.Gen( _LEAVE ); aGen.Gen( LEAVE_ );
pProc = nullptr; pProc = nullptr;
} }
@@ -1295,7 +1295,7 @@ void SbiParser::DefStatic( bool bPrivate )
// SbiParser::Parse() under these conditions // SbiParser::Parse() under these conditions
if( bNewGblDefs && nGblChain == 0 ) if( bNewGblDefs && nGblChain == 0 )
{ {
nGblChain = aGen.Gen( _JUMP, 0 ); nGblChain = aGen.Gen( JUMP_, 0 );
bNewGblDefs = false; bNewGblDefs = false;
} }
Next(); Next();
@@ -1310,7 +1310,7 @@ void SbiParser::DefStatic( bool bPrivate )
// global Pool // global Pool
p = pPool; p = pPool;
pPool = &aPublics; pPool = &aPublics;
DefVar( _STATIC, true ); DefVar( STATIC_, true );
pPool = p; pPool = p;
break; break;
} }

View File

@@ -30,30 +30,30 @@ typedef struct {
} OpTable; } OpTable;
static const OpTable aOpTable [] = { static const OpTable aOpTable [] = {
{ EXPON,_EXP }, { EXPON,EXP_ },
{ MUL, _MUL }, { MUL, MUL_ },
{ DIV, _DIV }, { DIV, DIV_ },
{ IDIV, _IDIV }, { IDIV, IDIV_ },
{ MOD, _MOD }, { MOD, MOD_ },
{ PLUS, _PLUS }, { PLUS, PLUS_ },
{ MINUS,_MINUS }, { MINUS,MINUS_ },
{ EQ, _EQ }, { EQ, EQ_ },
{ NE, _NE }, { NE, NE_ },
{ LE, _LE }, { LE, LE_ },
{ GE, _GE }, { GE, GE_ },
{ LT, _LT }, { LT, LT_ },
{ GT, _GT }, { GT, GT_ },
{ AND, _AND }, { AND, AND_ },
{ OR, _OR }, { OR, OR_ },
{ XOR, _XOR }, { XOR, XOR_ },
{ EQV, _EQV }, { EQV, EQV_ },
{ IMP, _IMP }, { IMP, IMP_ },
{ NOT, _NOT }, { NOT, NOT_ },
{ NEG, _NEG }, { NEG, NEG_ },
{ CAT, _CAT }, { CAT, CAT_ },
{ LIKE, _LIKE }, { LIKE, LIKE_ },
{ IS, _IS }, { IS, IS_ },
{ NIL, _NOP }}; { NIL, NOP_ }};
// Output of an element // Output of an element
void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode ) void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
@@ -65,18 +65,18 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
switch( GetType() ) switch( GetType() )
{ {
case SbxEMPTY: case SbxEMPTY:
rGen.Gen( _EMPTY ); rGen.Gen( EMPTY_ );
break; break;
case SbxINTEGER: case SbxINTEGER:
rGen.Gen( _CONST, (short) nVal ); rGen.Gen( CONST_, (short) nVal );
break; break;
case SbxSTRING: case SbxSTRING:
nStringId = rGen.GetParser()->aGblStrings.Add( aStrVal ); nStringId = rGen.GetParser()->aGblStrings.Add( aStrVal );
rGen.Gen( _SCONST, nStringId ); rGen.Gen( SCONST_, nStringId );
break; break;
default: default:
nStringId = rGen.GetParser()->aGblStrings.Add( nVal, eType ); nStringId = rGen.GetParser()->aGblStrings.Add( nVal, eType );
rGen.Gen( _NUMBER, nStringId ); rGen.Gen( NUMBER_, nStringId );
break; break;
} }
} }
@@ -86,7 +86,7 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
SbiOpcode eOp; SbiOpcode eOp;
if( aVar.pDef->GetScope() == SbPARAM ) if( aVar.pDef->GetScope() == SbPARAM )
{ {
eOp = _PARAM; eOp = PARAM_;
if( 0 == aVar.pDef->GetPos() ) if( 0 == aVar.pDef->GetPos() )
{ {
bool bTreatFunctionAsParam = true; bool bTreatFunctionAsParam = true;
@@ -103,32 +103,32 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
} }
if( !bTreatFunctionAsParam ) if( !bTreatFunctionAsParam )
{ {
eOp = aVar.pDef->IsGlobal() ? _FIND_G : _FIND; eOp = aVar.pDef->IsGlobal() ? FIND_G_ : FIND_;
} }
} }
} }
// special treatment for WITH // special treatment for WITH
else if( (pWithParent_ = GetWithParent()) != nullptr ) else if( (pWithParent_ = GetWithParent()) != nullptr )
{ {
eOp = _ELEM; // .-Term in WITH eOp = ELEM_; // .-Term in WITH
} }
else 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_);
} }
if( eOp == _FIND ) if( eOp == FIND_ )
{ {
SbiProcDef* pProc = aVar.pDef->GetProcDef(); SbiProcDef* pProc = aVar.pDef->GetProcDef();
if ( rGen.GetParser()->bClassModule ) if ( rGen.GetParser()->bClassModule )
{ {
eOp = _FIND_CM; eOp = FIND_CM_;
} }
else if ( aVar.pDef->IsStatic() || (pProc && pProc->IsStatic()) ) else if ( aVar.pDef->IsStatic() || (pProc && pProc->IsStatic()) )
{ {
eOp = _FIND_STATIC; eOp = FIND_STATIC_;
} }
} }
for( SbiExprNode* p = this; p; p = p->aVar.pNext ) for( SbiExprNode* p = this; p; p = p->aVar.pNext )
@@ -138,17 +138,17 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
pWithParent_->Gen(rGen); pWithParent_->Gen(rGen);
} }
p->GenElement( rGen, eOp ); p->GenElement( rGen, eOp );
eOp = _ELEM; eOp = ELEM_;
} }
} }
else if( IsTypeOf() ) else if( IsTypeOf() )
{ {
pLeft->Gen(rGen); pLeft->Gen(rGen);
rGen.Gen( _TESTCLASS, nTypeStrId ); rGen.Gen( TESTCLASS_, nTypeStrId );
} }
else if( IsNew() ) else if( IsNew() )
{ {
rGen.Gen( _CREATE, 0, nTypeStrId ); rGen.Gen( CREATE_, 0, nTypeStrId );
} }
else else
{ {
@@ -172,14 +172,14 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp ) void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp )
{ {
#ifdef DBG_UTIL #ifdef DBG_UTIL
if ((eOp < _RTL || eOp > _CALLC) && eOp != _FIND_G && eOp != _FIND_CM && eOp != _FIND_STATIC) if ((eOp < RTL_ || eOp > CALLC_) && eOp != FIND_G_ && eOp != FIND_CM_ && eOp != FIND_STATIC_)
rGen.GetParser()->Error( ERRCODE_BASIC_INTERNAL_ERROR, "Opcode" ); rGen.GetParser()->Error( ERRCODE_BASIC_INTERNAL_ERROR, "Opcode" );
#endif #endif
SbiSymDef* pDef = aVar.pDef; SbiSymDef* pDef = aVar.pDef;
// The ID is either the position or the String-ID // The ID is either the position or the String-ID
// If the bit Bit 0x8000 is set, the variable have // If the bit Bit 0x8000 is set, the variable have
// a parameter list. // a parameter list.
sal_uInt16 nId = ( eOp == _PARAM ) ? pDef->GetPos() : pDef->GetId(); sal_uInt16 nId = ( eOp == PARAM_ ) ? pDef->GetPos() : pDef->GetId();
// Build a parameter list // Build a parameter list
if( aVar.pPar && aVar.pPar->GetSize() ) if( aVar.pPar && aVar.pPar->GetSize() )
{ {
@@ -194,7 +194,7 @@ void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp )
for( auto& pExprList: *aVar.pvMorePar ) for( auto& pExprList: *aVar.pvMorePar )
{ {
pExprList->Gen(rGen); pExprList->Gen(rGen);
rGen.Gen( _ARRAYACCESS ); rGen.Gen( ARRAYACCESS_ );
} }
} }
} }
@@ -207,7 +207,7 @@ void SbiExprList::Gen(SbiCodeGen& rGen)
{ {
if( !aData.empty() ) if( !aData.empty() )
{ {
rGen.Gen( _ARGC ); rGen.Gen( ARGC_ );
// Type adjustment at DECLARE // Type adjustment at DECLARE
sal_uInt16 nCount = 1; sal_uInt16 nCount = 1;
@@ -218,7 +218,7 @@ void SbiExprList::Gen(SbiCodeGen& rGen)
{ {
// named arg // named arg
sal_uInt16 nSid = rGen.GetParser()->aGblStrings.Add( pExpr->GetName() ); sal_uInt16 nSid = rGen.GetParser()->aGblStrings.Add( pExpr->GetName() );
rGen.Gen( _ARGN, nSid ); rGen.Gen( ARGN_, nSid );
/* TODO: Check after Declare concept change /* TODO: Check after Declare concept change
// From 1996-01-10: Type adjustment at named -> search suitable parameter // From 1996-01-10: Type adjustment at named -> search suitable parameter
@@ -237,7 +237,7 @@ void SbiExprList::Gen(SbiCodeGen& rGen)
// 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;
// } // }
// } // }
@@ -247,7 +247,7 @@ void SbiExprList::Gen(SbiCodeGen& rGen)
} }
else else
{ {
rGen.Gen( _ARGV ); rGen.Gen( ARGV_ );
} }
nCount++; nCount++;
} }
@@ -261,7 +261,7 @@ void SbiExpression::Gen( RecursiveMode eRecMode )
pExpr->Gen( pParser->aGen, eRecMode ); pExpr->Gen( pParser->aGen, eRecMode );
if( bByVal ) if( bByVal )
{ {
pParser->aGen.Gen( _BYVAL ); pParser->aGen.Gen( BYVAL_ );
} }
if( bBased ) if( bBased )
{ {
@@ -270,8 +270,8 @@ void SbiExpression::Gen( RecursiveMode eRecMode )
{ {
uBase |= 0x8000; // #109275 Flag compatibility uBase |= 0x8000; // #109275 Flag compatibility
} }
pParser->aGen.Gen( _BASED, uBase ); pParser->aGen.Gen( BASED_, uBase );
pParser->aGen.Gen( _ARGV ); pParser->aGen.Gen( ARGV_ );
} }
} }

View File

@@ -33,7 +33,7 @@ bool SbiParser::Channel( bool bAlways )
while( Peek() == COMMA || Peek() == SEMICOLON ) while( Peek() == COMMA || Peek() == SEMICOLON )
Next(); Next();
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _CHANNEL ); aGen.Gen( CHANNEL_ );
bRes = true; bRes = true;
} }
else if( bAlways ) else if( bAlways )
@@ -56,7 +56,7 @@ void SbiParser::Print()
pExpr->Gen(); pExpr->Gen();
pExpr.reset(); pExpr.reset();
Peek(); Peek();
aGen.Gen( eCurTok == COMMA ? _PRINTF : _BPRINT ); aGen.Gen( eCurTok == COMMA ? PRINTF_ : BPRINT_ );
} }
if( eCurTok == COMMA || eCurTok == SEMICOLON ) if( eCurTok == COMMA || eCurTok == SEMICOLON )
{ {
@@ -65,12 +65,12 @@ void SbiParser::Print()
} }
else else
{ {
aGen.Gen( _PRCHAR, '\n' ); aGen.Gen( PRCHAR_, '\n' );
break; break;
} }
} }
if( bChan ) if( bChan )
aGen.Gen( _CHAN0 ); aGen.Gen( CHAN0_ );
} }
// WRITE #chan, expr, ... // WRITE #chan, expr, ...
@@ -84,21 +84,21 @@ void SbiParser::Write()
std::unique_ptr<SbiExpression> pExpr(new SbiExpression( this )); std::unique_ptr<SbiExpression> pExpr(new SbiExpression( this ));
pExpr->Gen(); pExpr->Gen();
pExpr.reset(); pExpr.reset();
aGen.Gen( _BWRITE ); aGen.Gen( BWRITE_ );
if( Peek() == COMMA ) if( Peek() == COMMA )
{ {
aGen.Gen( _PRCHAR, ',' ); aGen.Gen( PRCHAR_, ',' );
Next(); Next();
if( IsEoln( Peek() ) ) break; if( IsEoln( Peek() ) ) break;
} }
else else
{ {
aGen.Gen( _PRCHAR, '\n' ); aGen.Gen( PRCHAR_, '\n' );
break; break;
} }
} }
if( bChan ) if( bChan )
aGen.Gen( _CHAN0 ); aGen.Gen( CHAN0_ );
} }
@@ -136,16 +136,16 @@ void SbiParser::LineInput()
if( pExpr->GetType() != SbxVARIANT && pExpr->GetType() != SbxSTRING ) if( pExpr->GetType() != SbxVARIANT && pExpr->GetType() != SbxSTRING )
Error( ERRCODE_BASIC_CONVERSION ); Error( ERRCODE_BASIC_CONVERSION );
pExpr->Gen(); pExpr->Gen();
aGen.Gen( _LINPUT ); aGen.Gen( LINPUT_ );
pExpr.reset(); pExpr.reset();
aGen.Gen( _CHAN0 ); // ResetChannel() not in StepLINPUT() anymore aGen.Gen( CHAN0_ ); // ResetChannel() not in StepLINPUT() anymore
} }
// INPUT // INPUT
void SbiParser::Input() void SbiParser::Input()
{ {
aGen.Gen( _RESTART ); aGen.Gen( RESTART_ );
Channel( true ); Channel( true );
std::unique_ptr<SbiExpression> pExpr(new SbiExpression( this, SbOPERAND )); std::unique_ptr<SbiExpression> pExpr(new SbiExpression( this, SbOPERAND ));
while( !bAbort ) while( !bAbort )
@@ -153,7 +153,7 @@ void SbiParser::Input()
if( !pExpr->IsVariable() ) if( !pExpr->IsVariable() )
Error( ERRCODE_BASIC_VAR_EXPECTED ); Error( ERRCODE_BASIC_VAR_EXPECTED );
pExpr->Gen(); pExpr->Gen();
aGen.Gen( _INPUT ); aGen.Gen( INPUT_ );
if( Peek() == COMMA ) if( Peek() == COMMA )
{ {
Next(); Next();
@@ -162,7 +162,7 @@ void SbiParser::Input()
else break; else break;
} }
pExpr.reset(); pExpr.reset();
aGen.Gen( _CHAN0 ); aGen.Gen( CHAN0_ );
} }
// OPEN stringexpr FOR mode ACCESS access mode AS Channel [Len=n] // OPEN stringexpr FOR mode ACCESS access mode AS Channel [Len=n]
@@ -266,7 +266,7 @@ void SbiParser::Open()
if( pChan ) if( pChan )
pChan->Gen(); pChan->Gen();
aFileName.Gen(); aFileName.Gen();
aGen.Gen( _OPEN, static_cast<sal_uInt32>(nMode), static_cast<sal_uInt32>(nFlags) ); aGen.Gen( OPEN_, static_cast<sal_uInt32>(nMode), static_cast<sal_uInt32>(nFlags) );
bInStatement = false; bInStatement = false;
} }
@@ -292,7 +292,7 @@ void SbiParser::Name()
SbiExpression aExpr2( this ); SbiExpression aExpr2( this );
aExpr1.Gen(); aExpr1.Gen();
aExpr2.Gen(); aExpr2.Gen();
aGen.Gen( _RENAME ); aGen.Gen( RENAME_ );
} }
// CLOSE [n,...] // CLOSE [n,...]
@@ -301,7 +301,7 @@ void SbiParser::Close()
{ {
Peek(); Peek();
if( IsEoln( eCurTok ) ) if( IsEoln( eCurTok ) )
aGen.Gen( _CLOSE, 0 ); aGen.Gen( CLOSE_, 0 );
else else
for( ;; ) for( ;; )
{ {
@@ -309,8 +309,8 @@ void SbiParser::Close()
while( Peek() == COMMA || Peek() == SEMICOLON ) while( Peek() == COMMA || Peek() == SEMICOLON )
Next(); Next();
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _CHANNEL ); aGen.Gen( CHANNEL_ );
aGen.Gen( _CLOSE, 1 ); aGen.Gen( CLOSE_, 1 );
if( IsEoln( Peek() ) ) if( IsEoln( Peek() ) )
break; break;

View File

@@ -41,7 +41,7 @@ void SbiParser::If()
sal_uInt16 iJmp = 0; // current table index sal_uInt16 iJmp = 0; // current table index
// multiline IF // multiline IF
nEndLbl = aGen.Gen( _JUMPF, 0 ); nEndLbl = aGen.Gen( JUMPF_, 0 );
eTok = Peek(); eTok = Peek();
while( !( eTok == ELSEIF || eTok == ELSE || eTok == ENDIF ) && while( !( eTok == ELSEIF || eTok == ELSE || eTok == ENDIF ) &&
!bAbort && Parse() ) !bAbort && Parse() )
@@ -59,7 +59,7 @@ void SbiParser::If()
{ {
Error( ERRCODE_BASIC_PROG_TOO_LARGE ); bAbort = true; return; Error( ERRCODE_BASIC_PROG_TOO_LARGE ); bAbort = true; return;
} }
pnJmpToEndLbl[iJmp++] = aGen.Gen( _JUMP, 0 ); pnJmpToEndLbl[iJmp++] = aGen.Gen( JUMP_, 0 );
Next(); Next();
aGen.BackChain( nEndLbl ); aGen.BackChain( nEndLbl );
@@ -67,7 +67,7 @@ void SbiParser::If()
aGen.Statement(); aGen.Statement();
std::unique_ptr<SbiExpression> pCond(new SbiExpression( this )); std::unique_ptr<SbiExpression> pCond(new SbiExpression( this ));
pCond->Gen(); pCond->Gen();
nEndLbl = aGen.Gen( _JUMPF, 0 ); nEndLbl = aGen.Gen( JUMPF_, 0 );
pCond.reset(); pCond.reset();
TestToken( THEN ); TestToken( THEN );
eTok = Peek(); eTok = Peek();
@@ -85,7 +85,7 @@ void SbiParser::If()
{ {
Next(); Next();
sal_uInt32 nElseLbl = nEndLbl; sal_uInt32 nElseLbl = nEndLbl;
nEndLbl = aGen.Gen( _JUMP, 0 ); nEndLbl = aGen.Gen( JUMP_, 0 );
aGen.BackChain( nElseLbl ); aGen.BackChain( nElseLbl );
aGen.Statement(); aGen.Statement();
@@ -105,7 +105,7 @@ void SbiParser::If()
{ {
// single line IF // single line IF
bSingleLineIf = true; bSingleLineIf = true;
nEndLbl = aGen.Gen( _JUMPF, 0 ); nEndLbl = aGen.Gen( JUMPF_, 0 );
Push( eCurTok ); Push( eCurTok );
while( !bAbort ) while( !bAbort )
{ {
@@ -118,7 +118,7 @@ void SbiParser::If()
{ {
Next(); Next();
sal_uInt32 nElseLbl = nEndLbl; sal_uInt32 nElseLbl = nEndLbl;
nEndLbl = aGen.Gen( _JUMP, 0 ); nEndLbl = aGen.Gen( JUMP_, 0 );
aGen.BackChain( nElseLbl ); aGen.BackChain( nElseLbl );
while( !bAbort ) while( !bAbort )
{ {
@@ -158,10 +158,10 @@ void SbiParser::DoLoop()
{ {
SbiExpression aExpr( this ); SbiExpression aExpr( this );
aExpr.Gen(); aExpr.Gen();
aGen.Gen( eTok == UNTIL ? _JUMPF : _JUMPT, nStartLbl ); aGen.Gen( eTok == UNTIL ? JUMPF_ : JUMPT_, nStartLbl );
} else } else
if (eTok == EOLN || eTok == REM) if (eTok == EOLN || eTok == REM)
aGen.Gen (_JUMP, nStartLbl); aGen.Gen (JUMP_, nStartLbl);
else else
Error( ERRCODE_BASIC_EXPECTED, WHILE ); Error( ERRCODE_BASIC_EXPECTED, WHILE );
} }
@@ -173,10 +173,10 @@ void SbiParser::DoLoop()
SbiExpression aCond( this ); SbiExpression aCond( this );
aCond.Gen(); aCond.Gen();
} }
sal_uInt32 nEndLbl = aGen.Gen( eTok == UNTIL ? _JUMPT : _JUMPF, 0 ); sal_uInt32 nEndLbl = aGen.Gen( eTok == UNTIL ? JUMPT_ : JUMPF_, 0 );
StmntBlock( LOOP ); StmntBlock( LOOP );
TestEoln(); TestEoln();
aGen.Gen( _JUMP, nStartLbl ); aGen.Gen( JUMP_, nStartLbl );
aGen.BackChain( nEndLbl ); aGen.BackChain( nEndLbl );
} }
CloseBlock(); CloseBlock();
@@ -189,9 +189,9 @@ void SbiParser::While()
SbiExpression aCond( this ); SbiExpression aCond( this );
sal_uInt32 nStartLbl = aGen.GetPC(); sal_uInt32 nStartLbl = aGen.GetPC();
aCond.Gen(); aCond.Gen();
sal_uInt32 nEndLbl = aGen.Gen( _JUMPF, 0 ); sal_uInt32 nEndLbl = aGen.Gen( JUMPF_, 0 );
StmntBlock( WEND ); StmntBlock( WEND );
aGen.Gen( _JUMP, nStartLbl ); aGen.Gen( JUMP_, nStartLbl );
aGen.BackChain( nEndLbl ); aGen.BackChain( nEndLbl );
} }
@@ -211,7 +211,7 @@ void SbiParser::For()
SbiExpression aCollExpr( this, SbOPERAND ); SbiExpression aCollExpr( this, SbOPERAND );
aCollExpr.Gen(); // Collection var to for stack aCollExpr.Gen(); // Collection var to for stack
TestEoln(); TestEoln();
aGen.Gen( _INITFOREACH ); aGen.Gen( INITFOREACH_ );
} }
else else
{ {
@@ -235,16 +235,16 @@ void SbiParser::For()
TestEoln(); TestEoln();
// The stack has all 4 elements now: variable, start, end, increment // The stack has all 4 elements now: variable, start, end, increment
// bind start value // bind start value
aGen.Gen( _INITFOR ); aGen.Gen( INITFOR_ );
} }
sal_uInt32 nLoop = aGen.GetPC(); sal_uInt32 nLoop = aGen.GetPC();
// do tests, maybe free the stack // do tests, maybe free the stack
sal_uInt32 nEndTarget = aGen.Gen( _TESTFOR, 0 ); sal_uInt32 nEndTarget = aGen.Gen( TESTFOR_, 0 );
OpenBlock( FOR ); OpenBlock( FOR );
StmntBlock( NEXT ); StmntBlock( NEXT );
aGen.Gen( _NEXT ); aGen.Gen( NEXT_ );
aGen.Gen( _JUMP, nLoop ); aGen.Gen( JUMP_, nLoop );
// are there variables after NEXT? // are there variables after NEXT?
if( Peek() == SYMBOL ) if( Peek() == SYMBOL )
{ {
@@ -294,7 +294,7 @@ void SbiParser::OnGoto()
{ {
SbiExpression aCond( this ); SbiExpression aCond( this );
aCond.Gen(); aCond.Gen();
sal_uInt32 nLabelsTarget = aGen.Gen( _ONJUMP, 0 ); sal_uInt32 nLabelsTarget = aGen.Gen( ONJUMP_, 0 );
SbiToken eTok = Next(); SbiToken eTok = Next();
if( eTok != GOTO && eTok != GOSUB ) if( eTok != GOTO && eTok != GOSUB )
{ {
@@ -309,7 +309,7 @@ void SbiParser::OnGoto()
if( MayBeLabel() ) if( MayBeLabel() )
{ {
sal_uInt32 nOff = pProc->GetLabels().Reference( aSym ); sal_uInt32 nOff = pProc->GetLabels().Reference( aSym );
aGen.Gen( _JUMP, nOff ); aGen.Gen( JUMP_, nOff );
nLbl++; nLbl++;
} }
else Error( ERRCODE_BASIC_LABEL_EXPECTED ); else Error( ERRCODE_BASIC_LABEL_EXPECTED );
@@ -324,7 +324,7 @@ void SbiParser::OnGoto()
void SbiParser::Goto() void SbiParser::Goto()
{ {
SbiOpcode eOp = eCurTok == GOTO ? _JUMP : _GOSUB; SbiOpcode eOp = eCurTok == GOTO ? JUMP_ : GOSUB_;
Next(); Next();
if( MayBeLabel() ) if( MayBeLabel() )
{ {
@@ -342,9 +342,9 @@ void SbiParser::Return()
if( MayBeLabel() ) if( MayBeLabel() )
{ {
sal_uInt32 nOff = pProc->GetLabels().Reference( aSym ); sal_uInt32 nOff = pProc->GetLabels().Reference( aSym );
aGen.Gen( _RETURN, nOff ); aGen.Gen( RETURN_, nOff );
} }
else aGen.Gen( _RETURN, 0 ); else aGen.Gen( RETURN_, 0 );
} }
// SELECT CASE // SELECT CASE
@@ -355,7 +355,7 @@ void SbiParser::Select()
SbiExpression aCase( this ); SbiExpression aCase( this );
SbiToken eTok = NIL; SbiToken eTok = NIL;
aCase.Gen(); aCase.Gen();
aGen.Gen( _CASE ); aGen.Gen( CASE_ );
TestEoln(); TestEoln();
sal_uInt32 nNextTarget = 0; sal_uInt32 nNextTarget = 0;
sal_uInt32 nDoneTarget = 0; sal_uInt32 nDoneTarget = 0;
@@ -397,7 +397,7 @@ void SbiParser::Select()
SbiExpression aCompare( this ); SbiExpression aCompare( this );
aCompare.Gen(); aCompare.Gen();
nTrueTarget = aGen.Gen( nTrueTarget = aGen.Gen(
_CASEIS, nTrueTarget, CASEIS_, nTrueTarget,
sal::static_int_cast< sal_uInt16 >( sal::static_int_cast< sal_uInt16 >(
SbxEQ + ( eTok2 - EQ ) ) ); SbxEQ + ( eTok2 - EQ ) ) );
} }
@@ -411,11 +411,11 @@ void SbiParser::Select()
Next(); Next();
SbiExpression aCase2( this ); SbiExpression aCase2( this );
aCase2.Gen(); aCase2.Gen();
nTrueTarget = aGen.Gen( _CASETO, nTrueTarget ); nTrueTarget = aGen.Gen( CASETO_, nTrueTarget );
} }
else else
// CASE a // CASE a
nTrueTarget = aGen.Gen( _CASEIS, nTrueTarget, SbxEQ ); nTrueTarget = aGen.Gen( CASEIS_, nTrueTarget, SbxEQ );
} }
if( Peek() == COMMA ) Next(); if( Peek() == COMMA ) Next();
@@ -428,7 +428,7 @@ void SbiParser::Select()
if( !bElse ) if( !bElse )
{ {
nNextTarget = aGen.Gen( _JUMP, nNextTarget ); nNextTarget = aGen.Gen( JUMP_, nNextTarget );
aGen.BackChain( nTrueTarget ); aGen.BackChain( nTrueTarget );
} }
// build the statement body // build the statement body
@@ -443,7 +443,7 @@ void SbiParser::Select()
break; break;
} }
if( !bElse ) if( !bElse )
nDoneTarget = aGen.Gen( _JUMP, nDoneTarget ); nDoneTarget = aGen.Gen( JUMP_, nDoneTarget );
} }
else if( !IsEoln( eTok ) ) else if( !IsEoln( eTok ) )
break; break;
@@ -454,7 +454,7 @@ done:
if( nNextTarget ) if( nNextTarget )
aGen.BackChain( nNextTarget ); aGen.BackChain( nNextTarget );
aGen.BackChain( nDoneTarget ); aGen.BackChain( nDoneTarget );
aGen.Gen( _ENDCASE ); aGen.Gen( ENDCASE_ );
} }
// ON Error/Variable // ON Error/Variable
@@ -489,12 +489,12 @@ void SbiParser::On()
{ {
if( eCurTok == NUMBER && !nVal ) if( eCurTok == NUMBER && !nVal )
{ {
aGen.Gen( _STDERROR ); aGen.Gen( STDERROR_ );
} }
else else
{ {
sal_uInt32 nOff = pProc->GetLabels().Reference( aSym ); sal_uInt32 nOff = pProc->GetLabels().Reference( aSym );
aGen.Gen( _ERRHDL, nOff ); aGen.Gen( ERRHDL_, nOff );
} }
} }
else if( eCurTok == MINUS ) else if( eCurTok == MINUS )
@@ -502,7 +502,7 @@ void SbiParser::On()
Next(); Next();
if( eCurTok == NUMBER && nVal == 1 ) if( eCurTok == NUMBER && nVal == 1 )
{ {
aGen.Gen( _STDERROR ); aGen.Gen( STDERROR_ );
} }
else else
{ {
@@ -517,7 +517,7 @@ void SbiParser::On()
else if( eCurTok == RESUME ) else if( eCurTok == RESUME )
{ {
TestToken( NEXT ); TestToken( NEXT );
aGen.Gen( _NOERROR ); aGen.Gen( NOERROR_ );
} }
else Error( ERRCODE_BASIC_EXPECTED, "GoTo/Resume" ); else Error( ERRCODE_BASIC_EXPECTED, "GoTo/Resume" );
} }
@@ -533,23 +533,23 @@ void SbiParser::Resume()
{ {
case EOS: case EOS:
case EOLN: case EOLN:
aGen.Gen( _RESUME, 0 ); aGen.Gen( RESUME_, 0 );
break; break;
case NEXT: case NEXT:
aGen.Gen( _RESUME, 1 ); aGen.Gen( RESUME_, 1 );
Next(); Next();
break; break;
case NUMBER: case NUMBER:
if( !nVal ) if( !nVal )
{ {
aGen.Gen( _RESUME, 0 ); aGen.Gen( RESUME_, 0 );
break; break;
} // fall through } // fall through
case SYMBOL: case SYMBOL:
if( MayBeLabel() ) if( MayBeLabel() )
{ {
nLbl = pProc->GetLabels().Reference( aSym ); nLbl = pProc->GetLabels().Reference( aSym );
aGen.Gen( _RESUME, nLbl ); aGen.Gen( RESUME_, nLbl );
Next(); Next();
break; break;
} // fall through } // fall through

View File

@@ -140,7 +140,7 @@ SbiParser::SbiParser( StarBASIC* pb, SbModule* pm )
aGlobals.SetParent( &aRtlSyms ); aGlobals.SetParent( &aRtlSyms );
nGblChain = aGen.Gen( _JUMP, 0 ); nGblChain = aGen.Gen( JUMP_, 0 );
rTypeArray = new SbxArray; // array for user defined types rTypeArray = new SbxArray; // array for user defined types
rEnumArray = new SbxArray; // array for Enum types rEnumArray = new SbxArray; // array for Enum types
@@ -184,7 +184,7 @@ bool SbiParser::HasGlobalCode()
if( bGblDefs && nGblChain ) if( bGblDefs && nGblChain )
{ {
aGen.BackChain( nGblChain ); aGen.BackChain( nGblChain );
aGen.Gen( _LEAVE ); aGen.Gen( LEAVE_ );
nGblChain = 0; nGblChain = 0;
} }
return bGblDefs; return bGblDefs;
@@ -233,7 +233,7 @@ void SbiParser::Exit()
if( eTok == eExitTok || if( eTok == eExitTok ||
(eTok == PROPERTY && (eExitTok == GET || eExitTok == LET) ) ) // #i109051 (eTok == PROPERTY && (eExitTok == GET || eExitTok == LET) ) ) // #i109051
{ {
p->nChain = aGen.Gen( _JUMP, p->nChain ); p->nChain = aGen.Gen( JUMP_, p->nChain );
return; return;
} }
} }
@@ -333,7 +333,7 @@ bool SbiParser::Parse()
// AB #40689: Due to the new static-handling there // AB #40689: Due to the new static-handling there
// can be another nGblChain, so ask for it before. // can be another nGblChain, so ask for it before.
if( bNewGblDefs && nGblChain == 0 ) if( bNewGblDefs && nGblChain == 0 )
nGblChain = aGen.Gen( _JUMP, 0 ); nGblChain = aGen.Gen( JUMP_, 0 );
return false; return false;
} }
@@ -427,7 +427,7 @@ bool SbiParser::Parse()
if( bNewGblDefs && nGblChain == 0 && if( bNewGblDefs && nGblChain == 0 &&
( eCurTok == SUB || eCurTok == FUNCTION || eCurTok == PROPERTY ) ) ( eCurTok == SUB || eCurTok == FUNCTION || eCurTok == PROPERTY ) )
{ {
nGblChain = aGen.Gen( _JUMP, 0 ); nGblChain = aGen.Gen( JUMP_, 0 );
bNewGblDefs = false; bNewGblDefs = false;
} }
// statement-opcode at the beginning of a sub, too, please // statement-opcode at the beginning of a sub, too, please
@@ -525,7 +525,7 @@ void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo )
{ {
if( !bEQ ) if( !bEQ )
{ {
aGen.Gen( _GET ); aGen.Gen( GET_ );
} }
else else
{ {
@@ -535,17 +535,17 @@ void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo )
TestToken( EQ ); TestToken( EQ );
SbiExpression aExpr( this ); SbiExpression aExpr( this );
aExpr.Gen(); aExpr.Gen();
SbiOpcode eOp = _PUT; SbiOpcode eOp = PUT_;
if( pDef ) if( pDef )
{ {
if( pDef->GetConstDef() ) if( pDef->GetConstDef() )
Error( ERRCODE_BASIC_DUPLICATE_DEF, pDef->GetName() ); Error( ERRCODE_BASIC_DUPLICATE_DEF, pDef->GetName() );
if( pDef->GetType() == SbxOBJECT ) if( pDef->GetType() == SbxOBJECT )
{ {
eOp = _SET; eOp = SET_;
if( pDef->GetTypeId() ) if( pDef->GetTypeId() )
{ {
aGen.Gen( _SETCLASS, pDef->GetTypeId() ); aGen.Gen( SETCLASS_, pDef->GetTypeId() );
return; return;
} }
} }
@@ -571,8 +571,8 @@ void SbiParser::Assign()
nLen = aLvalue.GetRealVar()->GetLen(); nLen = aLvalue.GetRealVar()->GetLen();
} }
if( nLen ) if( nLen )
aGen.Gen( _PAD, nLen ); aGen.Gen( PAD_, nLen );
aGen.Gen( _PUT ); aGen.Gen( PUT_ );
} }
// assignments of an object-variable // assignments of an object-variable
@@ -597,8 +597,8 @@ void SbiParser::Set()
TypeDecl( *pTypeDef, true ); TypeDecl( *pTypeDef, true );
aLvalue.Gen(); aLvalue.Gen();
aGen.Gen( _CREATE, pDef->GetId(), pTypeDef->GetTypeId() ); aGen.Gen( CREATE_, pDef->GetId(), pTypeDef->GetTypeId() );
aGen.Gen( _SETCLASS, pDef->GetTypeId() ); aGen.Gen( SETCLASS_, pDef->GetTypeId() );
} }
else else
{ {
@@ -613,16 +613,16 @@ void SbiParser::Set()
if( pDef->GetTypeId() ) if( pDef->GetTypeId() )
{ {
if ( bVBASupportOn ) if ( bVBASupportOn )
aGen.Gen( _VBASETCLASS, pDef->GetTypeId() ); aGen.Gen( VBASETCLASS_, pDef->GetTypeId() );
else else
aGen.Gen( _SETCLASS, pDef->GetTypeId() ); aGen.Gen( SETCLASS_, pDef->GetTypeId() );
} }
else else
{ {
if ( bVBASupportOn ) if ( bVBASupportOn )
aGen.Gen( _VBASET ); aGen.Gen( VBASET_ );
else else
aGen.Gen( _SET ); aGen.Gen( SET_ );
} }
} }
} }
@@ -644,7 +644,7 @@ void SbiParser::LSet()
SbiExpression aExpr( this ); SbiExpression aExpr( this );
aLvalue.Gen(); aLvalue.Gen();
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _LSET ); aGen.Gen( LSET_ );
} }
// JSM 07.10.95 // JSM 07.10.95
@@ -662,7 +662,7 @@ void SbiParser::RSet()
SbiExpression aExpr( this ); SbiExpression aExpr( this );
aLvalue.Gen(); aLvalue.Gen();
aExpr.Gen(); aExpr.Gen();
aGen.Gen( _RSET ); aGen.Gen( RSET_ );
} }
// DEFINT, DEFLNG, DEFSNG, DEFDBL, DEFSTR and so on // DEFINT, DEFLNG, DEFSNG, DEFDBL, DEFSTR and so on
@@ -702,7 +702,7 @@ void SbiParser::DefXXX()
void SbiParser::Stop() void SbiParser::Stop()
{ {
aGen.Gen( _STOP ); aGen.Gen( STOP_ );
Peek(); // #35694: only Peek(), so that EOL is recognized in Single-Line-If Peek(); // #35694: only Peek(), so that EOL is recognized in Single-Line-If
} }
@@ -855,7 +855,7 @@ void SbiParser::AddConstants()
addStringConst( aPublics, "vbCrLf", "\x0D\x0A" ); addStringConst( aPublics, "vbCrLf", "\x0D\x0A" );
addStringConst( aPublics, "vbFormFeed", "\x0C" ); addStringConst( aPublics, "vbFormFeed", "\x0C" );
addStringConst( aPublics, "vbLf", "\x0A" ); addStringConst( aPublics, "vbLf", "\x0A" );
#ifndef _WIN32 #ifndef WIN32_
addStringConst( aPublics, "vbNewLine", "\x0D\x0A" ); addStringConst( aPublics, "vbNewLine", "\x0D\x0A" );
#else #else
addStringConst( aPublics, "vbNewLine", "\x0A" ); addStringConst( aPublics, "vbNewLine", "\x0A" );
@@ -875,7 +875,7 @@ void SbiParser::ErrorStmnt()
{ {
SbiExpression aPar( this ); SbiExpression aPar( this );
aPar.Gen(); aPar.Gen();
aGen.Gen( _ERROR ); aGen.Gen( ERROR_ );
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -27,133 +27,133 @@
enum SbiOpcode { enum SbiOpcode {
// all opcodes without operands // all opcodes without operands
_NOP = 0, NOP_ = 0,
SbOP0_START = _NOP, SbOP0_START = NOP_,
// operators // operators
// the following operators are ordered // the following operators are ordered
// the same way as the enum SbxVarOp // the same way as the enum SbxVarOp
_EXP, _MUL, _DIV, _MOD, _PLUS, _MINUS, _NEG, EXP_, MUL_, DIV_, MOD_, PLUS_, MINUS_, NEG_,
_EQ, _NE, _LT, _GT, _LE, _GE, EQ_, NE_, LT_, GT_, LE_, GE_,
_IDIV, _AND, _OR, _XOR, _EQV, _IMP, _NOT, IDIV_, AND_, OR_, XOR_, EQV_, IMP_, NOT_,
_CAT, CAT_,
// end of enum SbxVarOp // end of enum SbxVarOp
_LIKE, _IS, LIKE_, IS_,
// load/save // load/save
_ARGC, // establish new Argv ARGC_, // establish new Argv
_ARGV, // TOS ==> current Argv ARGV_, // TOS ==> current Argv
_INPUT, // Input ==> TOS INPUT_, // Input ==> TOS
_LINPUT, // Line Input ==> TOS LINPUT_, // Line Input ==> TOS
_GET, // touch TOS GET_, // touch TOS
_SET, // save object TOS ==> TOS-1 SET_, // save object TOS ==> TOS-1
_PUT, // TOS ==> TOS-1 PUT_, // TOS ==> TOS-1
_PUTC, // TOS ==> TOS-1, then ReadOnly PUTC_, // TOS ==> TOS-1, then ReadOnly
_DIM, // DIM DIM_, // DIM
_REDIM, // REDIM REDIM_, // REDIM
_REDIMP, // REDIM PRESERVE REDIMP_, // REDIM PRESERVE
_ERASE, // delete TOS ERASE_, // delete TOS
// branch // branch
_STOP, // end of program STOP_, // end of program
_INITFOR, // initialize FOR-variable INITFOR_, // initialize FOR-variable
_NEXT, // increment FOR-variable NEXT_, // increment FOR-variable
_CASE, // beginning CASE CASE_, // beginning CASE
_ENDCASE, // end CASE ENDCASE_, // end CASE
_STDERROR, // standard error handling STDERROR_, // standard error handling
_NOERROR, // no error handling NOERROR_, // no error handling
_LEAVE, // leave UP LEAVE_, // leave UP
// E/A // E/A
_CHANNEL, // TOS = channel number CHANNEL_, // TOS = channel number
_BPRINT, // print TOS BPRINT_, // print TOS
_PRINTF, // print TOS in field PRINTF_, // print TOS in field
_BWRITE, // write TOS BWRITE_, // write TOS
_RENAME, // Rename Tos+1 to Tos RENAME_, // Rename Tos+1 to Tos
_PROMPT, // TOS = Prompt for Input PROMPT_, // TOS = Prompt for Input
_RESTART, // define restart point RESTART_, // define restart point
_CHAN0, // I/O-channel 0 CHAN0_, // I/O-channel 0
// miscellaneous // miscellaneous
_EMPTY, // empty expression on stack EMPTY_, // empty expression on stack
_ERROR, // TOS = error code ERROR_, // TOS = error code
_LSET, // saving object TOS ==> TOS-1 LSET_, // saving object TOS ==> TOS-1
_RSET, // saving object TOS ==> TOS-1 RSET_, // saving object TOS ==> TOS-1
_REDIMP_ERASE, // Copies array to be later used by REDIM PRESERVE before erasing it REDIMP_ERASE_, // Copies array to be later used by REDIM PRESERVE before erasing it
_INITFOREACH, INITFOREACH_,
_VBASET, // VBA-like Set VBASET_, // VBA-like Set
_ERASE_CLEAR, // Erase array and clear variable ERASE_CLEAR_, // Erase array and clear variable
_ARRAYACCESS, // Assign parameters to TOS and get value, used for array of arrays ARRAYACCESS_, // Assign parameters to TOS and get value, used for array of arrays
_BYVAL, // byref -> byval for lvalue parameter passed in call BYVAL_, // byref -> byval for lvalue parameter passed in call
SbOP0_END = _BYVAL, SbOP0_END = BYVAL_,
// all opcodes with one operand // all opcodes with one operand
_NUMBER = 0x40, // loading a numeric constant (+ID) NUMBER_ = 0x40, // loading a numeric constant (+ID)
SbOP1_START = _NUMBER, SbOP1_START = NUMBER_,
_SCONST, // loading a stringconstant (+ID) SCONST_, // loading a stringconstant (+ID)
_CONST, // Immediate Load (+ value) CONST_, // Immediate Load (+ value)
_ARGN, // saving a named Arg in Argv (+StringID) ARGN_, // saving a named Arg in Argv (+StringID)
_PAD, // bring string to a firm length (+length) PAD_, // bring string to a firm length (+length)
// Verzweigungen // Verzweigungen
_JUMP, // jump (+target) JUMP_, // jump (+target)
_JUMPT, // evaluate TOS, conditional jump (+target) JUMPT_, // evaluate TOS, conditional jump (+target)
_JUMPF, // evaluate TOS, conditional jump (+target) JUMPF_, // evaluate TOS, conditional jump (+target)
_ONJUMP, // evaluate TOS, jump into JUMP-table (+MaxVal) ONJUMP_, // evaluate TOS, jump into JUMP-table (+MaxVal)
_GOSUB, // UP-call (+Target) GOSUB_, // UP-call (+Target)
_RETURN, // UP-return (+0 or Target) RETURN_, // UP-return (+0 or Target)
_TESTFOR, // test FOR-variable, increment (+Endlabel) TESTFOR_, // test FOR-variable, increment (+Endlabel)
_CASETO, // Tos+1 <= Case <= Tos, 2xremove (+Target) CASETO_, // Tos+1 <= Case <= Tos, 2xremove (+Target)
_ERRHDL, // error handler (+Offset) ERRHDL_, // error handler (+Offset)
_RESUME, // Resume after errors (+0 or 1 or Label) RESUME_, // Resume after errors (+0 or 1 or Label)
// E/A // E/A
_CLOSE, // (+channel/0) CLOSE_, // (+channel/0)
_PRCHAR, // (+char) PRCHAR_, // (+char)
// Verwaltung // Verwaltung
_SETCLASS, // test set + class names (+StringId) SETCLASS_, // test set + class names (+StringId)
_TESTCLASS, // Check TOS class (+StringId) TESTCLASS_, // Check TOS class (+StringId)
_LIB, // set lib name for declare-procs (+StringId) LIB_, // set lib name for declare-procs (+StringId)
_BASED, // TOS is incremented by BASE, BASE is pushed before (+base) BASED_, // TOS is incremented by BASE, BASE is pushed before (+base)
// type adjustment in the Argv // type adjustment in the Argv
_ARGTYP, // convert last parameter in Argv (+type) ARGTYP_, // convert last parameter in Argv (+type)
_VBASETCLASS, // VBA-like Set VBASETCLASS_, // VBA-like Set
SbOP1_END = _VBASETCLASS, SbOP1_END = VBASETCLASS_,
// all opcodes with two operands // all opcodes with two operands
_RTL = 0x80, // load from the RTL (+StringID+Typ) RTL_ = 0x80, // load from the RTL (+StringID+Typ)
SbOP2_START = _RTL, SbOP2_START = RTL_,
_FIND, // load (+StringID+Typ) FIND_, // load (+StringID+Typ)
_ELEM, // load element (+StringID+Typ) ELEM_, // load element (+StringID+Typ)
_PARAM, // parameters (+Offset+Typ) PARAM_, // parameters (+Offset+Typ)
// branch // branch
_CALL, // call DECLARE-method (+StringID+Typ) CALL_, // call DECLARE-method (+StringID+Typ)
_CALLC, // call Cdecl-DECLARE-Method (+StringID+Typ) CALLC_, // call Cdecl-DECLARE-Method (+StringID+Typ)
_CASEIS, // case-test (+Test-Opcode+True-Target) CASEIS_, // case-test (+Test-Opcode+True-Target)
// management // management
_STMNT, // begin of a statement (+Line+Col) STMNT_, // begin of a statement (+Line+Col)
// E/A // E/A
_OPEN, // (+StreamMode+Flags) OPEN_, // (+StreamMode+Flags)
// objects // objects
_LOCAL, // define locals variables (+StringID+Typ) LOCAL_, // define locals variables (+StringID+Typ)
_PUBLIC, // module global variables (+StringID+Typ) PUBLIC_, // module global variables (+StringID+Typ)
_GLOBAL, // define global variables, public command (+StringID+Typ) GLOBAL_, // define global variables, public command (+StringID+Typ)
_CREATE, // create object (+StringId+StringID) CREATE_, // create object (+StringId+StringID)
_STATIC, // static variable (+StringID+Typ) JSM STATIC_, // static variable (+StringID+Typ) JSM
_TCREATE, // create user-defined object TCREATE_, // create user-defined object
_DCREATE, // create object-array (+StringId+StringID) DCREATE_, // create object-array (+StringId+StringID)
_GLOBAL_P, // define global variable that's not overwritten on restarting GLOBAL_P_, // define global variable that's not overwritten on restarting
// the Basic, P=PERSIST (+StringID+Typ) // the Basic, P=PERSIST (+StringID+Typ)
_FIND_G, // finds global variable with special treatment due to _GLOBAL_P FIND_G_, // finds global variable with special treatment due to GLOBAL_P_
_DCREATE_REDIMP, // redimension object-array (+StringId+StringID) DCREATE_REDIMP_, // redimension object-array (+StringId+StringID)
_FIND_CM, // Search inside a class module (CM) to enable global search in time FIND_CM_, // Search inside a class module (CM) to enable global search in time
_PUBLIC_P, // Module global Variable (persisted between calls)(+StringID+Typ) PUBLIC_P_, // Module global Variable (persisted between calls)(+StringID+Typ)
_FIND_STATIC, // local static var lookup (+StringID+Typ) FIND_STATIC_, // local static var lookup (+StringID+Typ)
SbOP2_END = _FIND_STATIC SbOP2_END = FIND_STATIC_
}; };
#endif #endif