2008-10-14 11:51 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapi.h
* harbour/source/vm/macro.c
* added missing const attribute to hb_macroCompile() parameter
+ added new .prg function:
hb_macroBlock( <cExpr> ) -> <bCode>
which converts macro expression to codeblock. New codeblocks
do not inherit hb_macroBlock() caller scope/attributes.
This commit is contained in:
@@ -8,6 +8,15 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2008-10-14 11:51 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbapi.h
|
||||
* harbour/source/vm/macro.c
|
||||
* added missing const attribute to hb_macroCompile() parameter
|
||||
+ added new .prg function:
|
||||
hb_macroBlock( <cExpr> ) -> <bCode>
|
||||
which converts macro expression to codeblock. New codeblocks
|
||||
do not inherit hb_macroBlock() caller scope/attributes.
|
||||
|
||||
2008-10-14 08:44 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
|
||||
* contrib/examples/dbu/bld_vc.bat
|
||||
! Removed -TP C option.
|
||||
|
||||
@@ -976,7 +976,7 @@ extern void hb_macroSetValue( HB_ITEM_PTR pItem, BYTE flags ); /* assign a val
|
||||
extern void hb_macroTextValue( HB_ITEM_PTR pItem ); /* macro text substitution */
|
||||
extern void hb_macroPushSymbol( HB_ITEM_PTR pItem ); /* handle a macro function calls, e.g. var := ¯o() */
|
||||
extern void hb_macroRun( HB_MACRO_PTR pMacro ); /* executes pcode compiled by macro compiler */
|
||||
extern HB_MACRO_PTR hb_macroCompile( char * szString ); /* compile a string and return a pcode buffer */
|
||||
extern HB_MACRO_PTR hb_macroCompile( const char * szString ); /* compile a string and return a pcode buffer */
|
||||
extern void hb_macroDelete( HB_MACRO_PTR pMacro ); /* release all memory allocated for macro evaluation */
|
||||
extern char * hb_macroTextSymbol( const char *szString, ULONG ulLength, BOOL *pfNewString ); /* substitute macro variables occurences within a given string and check if result is a valid function or variable name */
|
||||
extern char * hb_macroExpandString( const char *szString, ULONG ulLength, BOOL *pfNewString ); /* expands valid '&' operator */
|
||||
|
||||
@@ -731,7 +731,7 @@ char * hb_macroTextSymbol( const char *szString, ULONG ulLength, BOOL *pfNewStri
|
||||
* NOTE: it can be called to implement an index key evaluation
|
||||
* use hb_macroRun() to evaluate a compiled pcode
|
||||
*/
|
||||
HB_MACRO_PTR hb_macroCompile( char * szString )
|
||||
HB_MACRO_PTR hb_macroCompile( const char * szString )
|
||||
{
|
||||
HB_MACRO_PTR pMacro;
|
||||
int iStatus;
|
||||
@@ -745,7 +745,7 @@ HB_MACRO_PTR hb_macroCompile( char * szString )
|
||||
HB_MACRO_GEN_LIST | HB_MACRO_GEN_PARE;
|
||||
pMacro->uiNameLen = HB_SYMBOL_NAME_LEN;
|
||||
pMacro->status = HB_MACRO_CONT;
|
||||
pMacro->string = szString;
|
||||
pMacro->string = ( char * ) szString;
|
||||
pMacro->length = strlen( szString );
|
||||
|
||||
iStatus = hb_macroParse( pMacro );
|
||||
@@ -758,6 +758,36 @@ HB_MACRO_PTR hb_macroCompile( char * szString )
|
||||
return pMacro;
|
||||
}
|
||||
|
||||
static void hb_macroBlock( const char * szString, PHB_ITEM pItem )
|
||||
{
|
||||
HB_MACRO_PTR pMacro = hb_macroCompile( szString );
|
||||
|
||||
if( pMacro )
|
||||
{
|
||||
pMacro->pCodeInfo->pCode[ pMacro->pCodeInfo->lPCodePos - 1 ] = HB_P_ENDBLOCK;
|
||||
|
||||
if( HB_IS_COMPLEX( pItem ) )
|
||||
hb_itemClear( pItem );
|
||||
|
||||
pItem->item.asBlock.value = hb_codeblockMacroNew( pMacro->pCodeInfo->pCode,
|
||||
pMacro->pCodeInfo->lPCodePos );
|
||||
pItem->type = HB_IT_BLOCK;
|
||||
pItem->item.asBlock.paramcnt = 0;
|
||||
pItem->item.asBlock.lineno = 0;
|
||||
pItem->item.asBlock.hclass = 0;
|
||||
pItem->item.asBlock.method = 0;
|
||||
|
||||
hb_macroDelete( pMacro );
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( HB_MACROBLOCK )
|
||||
{
|
||||
const char * szMacro = hb_parc( 1 );
|
||||
if( szMacro )
|
||||
hb_macroBlock( szMacro, hb_stackReturnItem() );
|
||||
}
|
||||
|
||||
/* This function handles a macro function calls, e.g. var :=¯o()
|
||||
* and creating memvar variables using PUBLIC/PRIVATE command
|
||||
* PUBLIC ¯o
|
||||
|
||||
Reference in New Issue
Block a user