From c441e84e2a0e3d2ef8b61ed6b87196e01d5794a4 Mon Sep 17 00:00:00 2001 From: Antonio Linares Date: Fri, 27 Jun 2003 08:21:02 +0000 Subject: [PATCH] IL implementation for HB_P_POPLOCALNEAR and HB_P_PUSHLOCALNEAR --- harbour/source/compiler/gencli.c | 95 ++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/harbour/source/compiler/gencli.c b/harbour/source/compiler/gencli.c index 25e775481d..3cab8a0a71 100644 --- a/harbour/source/compiler/gencli.c +++ b/harbour/source/compiler/gencli.c @@ -1134,28 +1134,34 @@ static HB_GENC_FUNC( hb_p_poplocal ) static HB_GENC_FUNC( hb_p_poplocalnear ) { - fprintf( cargo->yyc, "\tHB_P_POPLOCALNEAR, %i,", - pFunc->pCode[ lPCodePos + 1 ] ); - if( cargo->bVerbose ) - { - char wVar = ( char ) pFunc->pCode[ lPCodePos + 1 ]; - /* Variable with negative order are local variables - * referenced in a codeblock -handle it with care - */ + // important: check the below code for codeblock locals management + // warning: IL requires zero based locals index + + fprintf( cargo->yyc, " stloc.%i\n", pFunc->pCode[ lPCodePos + 1 ] - 1 ); + + // fprintf( cargo->yyc, "\tHB_P_POPLOCALNEAR, %i,", + // pFunc->pCode[ lPCodePos + 1 ] ); + // if( cargo->bVerbose ) + // { + // char wVar = ( char ) pFunc->pCode[ lPCodePos + 1 ]; + // /* Variable with negative order are local variables + // * referenced in a codeblock -handle it with care + // */ + // + // if( cargo->iNestedCodeblock ) + // { + // /* we are accesing variables within a codeblock */ + // /* the names of codeblock variable are lost */ + // if( wVar < 0 ) + // fprintf( cargo->yyc, "\t/* localvar%i */", -wVar ); + // else + // fprintf( cargo->yyc, "\t/* codeblockvar%i */", wVar ); + // } + // else + // fprintf( cargo->yyc, "\t/* %s */", hb_compLocalVariableFind( pFunc, wVar )->szName ); + // } + // fprintf( cargo->yyc, "\n" ); - if( cargo->iNestedCodeblock ) - { - /* we are accesing variables within a codeblock */ - /* the names of codeblock variable are lost */ - if( wVar < 0 ) - fprintf( cargo->yyc, "\t/* localvar%i */", -wVar ); - else - fprintf( cargo->yyc, "\t/* codeblockvar%i */", wVar ); - } - else - fprintf( cargo->yyc, "\t/* %s */", hb_compLocalVariableFind( pFunc, wVar )->szName ); - } - fprintf( cargo->yyc, "\n" ); return 2; } @@ -1392,28 +1398,33 @@ static HB_GENC_FUNC( hb_p_pushlocal ) static HB_GENC_FUNC( hb_p_pushlocalnear ) { - fprintf( cargo->yyc, "\tHB_P_PUSHLOCALNEAR, %i,", - pFunc->pCode[ lPCodePos + 1 ] ); - if( cargo->bVerbose ) - { - signed char wVar = ( signed char ) pFunc->pCode[ lPCodePos + 1 ]; - /* Variable with negative order are local variables - * referenced in a codeblock -handle it with care - */ + // Important: check the below code for codeblocks locals + // Warning: IL uses zero based locals indexes + fprintf( cargo->yyc, " ldloc.%i\n", pFunc->pCode[ lPCodePos + 1 ] - 1 ); + + // fprintf( cargo->yyc, "\tHB_P_PUSHLOCALNEAR, %i,", + // pFunc->pCode[ lPCodePos + 1 ] ); + // if( cargo->bVerbose ) + // { + // signed char wVar = ( signed char ) pFunc->pCode[ lPCodePos + 1 ]; + // /* Variable with negative order are local variables + // * referenced in a codeblock -handle it with care + // */ + // + // if( cargo->iNestedCodeblock ) + // { + // /* we are accesing variables within a codeblock */ + // /* the names of codeblock variable are lost */ + // if( wVar < 0 ) + // fprintf( cargo->yyc, "\t/* localvar%i */", -wVar ); + // else + // fprintf( cargo->yyc, "\t/* codeblockvar%i */", wVar ); + // } + // else + // fprintf( cargo->yyc, "\t/* %s */", hb_compLocalVariableFind( pFunc, wVar )->szName ); + // } + // fprintf( cargo->yyc, "\n" ); - if( cargo->iNestedCodeblock ) - { - /* we are accesing variables within a codeblock */ - /* the names of codeblock variable are lost */ - if( wVar < 0 ) - fprintf( cargo->yyc, "\t/* localvar%i */", -wVar ); - else - fprintf( cargo->yyc, "\t/* codeblockvar%i */", wVar ); - } - else - fprintf( cargo->yyc, "\t/* %s */", hb_compLocalVariableFind( pFunc, wVar )->szName ); - } - fprintf( cargo->yyc, "\n" ); return 2; }