From fcac8dc38eefeafb69745393dd913ff1b571ce37 Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Tue, 2 May 2000 12:47:25 +0000 Subject: [PATCH] ChangeLog 20000502-14:55 GMT+1 --- harbour/ChangeLog | 6 ++++++ harbour/source/vm/hvm.c | 32 +++++++++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 35c8a1ec0b..db34ff3c1d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +20000502-14:55 GMT+1 Ryszard Glab + + *source/vm/hvm.c + * fixed bug during accessing a constant arrays caused by + the optimization - { 1, 2, 3 }[ n ] + 20000502-14:25 GMT+1 Ryszard Glab *source/compiler/harbour.c diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 137caef589..aea612aa33 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -2390,21 +2390,27 @@ static void hb_vmArrayPush( void ) { if( ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen ) { - hb_arrayGet( pArray, ulIndex, pArray ); - hb_stackPop(); + if( pArray->item.asArray.value->uiHolders > 1 ) + { + /* this is a temporary copy of an array - we can overwrite + * it with no problem + */ + hb_arrayGet( pArray, ulIndex, pArray ); + hb_stackPop(); + } + else + { + /* this is a constant array { 1, 2, 3 } - we cannot use + * the optimization here + */ + HB_ITEM item; -/* Looks like this without optimization: + hb_arrayGet( pArray, ulIndex, &item ); + hb_stackPop(); - HB_ITEM item; - - hb_arrayGet( pArray, ulIndex, &item ); - hb_stackPop(); - hb_stackPop(); - - hb_itemCopy( hb_stack.pPos, &item ); - hb_itemClear( &item ); - hb_stackPush(); -*/ + hb_itemCopy( hb_stack.pPos - 1, &item ); + hb_itemClear( &item ); + } } else hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ) );