2003-10-17 18:08 UTC+0100 Ryszard Glab
This commit is contained in:
@@ -18,3 +18,5 @@ obj
|
||||
obj/*
|
||||
lib
|
||||
lib/*
|
||||
myapps
|
||||
myapps/*
|
||||
|
||||
@@ -8,6 +8,38 @@
|
||||
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2003-10-17 18:08 UTC+0100 Ryszard Glab <rglab@przesiew.imid.med.pl>
|
||||
|
||||
* include/hbapi.h
|
||||
* include/hbcomp.h
|
||||
* include/hbexpra.c
|
||||
* include/hbexprb.c
|
||||
* include/hbexprc.c
|
||||
* include/hbexprop.h
|
||||
* source/common/expropt1.c
|
||||
* source/compiler/expropta.c
|
||||
* source/compiler/exproptb.c
|
||||
* source/compiler/exproptc.c
|
||||
* source/compiler/harbour.c
|
||||
* source/compiler/harbour.l
|
||||
* source/compiler/harbour.sly
|
||||
* source/compiler/harbour.y
|
||||
* source/compiler/hbgenerr.c
|
||||
* source/macro/macro.y
|
||||
* source/macro/macroa.c
|
||||
* source/macro/macrob.c
|
||||
* source/macro/macroc.c
|
||||
* Fixed support for late/early evaluation of macro exressions in
|
||||
a codeblock (Flex version) (see tests/tstblock.prg for a sample)
|
||||
Harbour(flex) is now full Clipper compatible here.
|
||||
|
||||
* config/dos/watcom.cf
|
||||
* source/rdd/dbfcdx/dbfcdx1.h
|
||||
* source/common/hbffind.c
|
||||
* include/hbrddcdx.h
|
||||
* include/hbmath.h
|
||||
* Changed to compile correctly with WATCOM compilers
|
||||
|
||||
2003-10-16 13:17 UTC+0100 Antonio Linares <alinares@fivetechsoft.com>
|
||||
* source/rtl/round.c
|
||||
! hb_numRound() completely redesigned
|
||||
|
||||
@@ -74,7 +74,8 @@ $(AR) $(ARFLAGS) @__lib__.tmp
|
||||
endef
|
||||
|
||||
AR = wlib
|
||||
ARFLAGS = -c $(A_USR)
|
||||
ARFLAGS = -p=32 -c $(A_USR)
|
||||
|
||||
AR_RULE = $(create_library)
|
||||
|
||||
include $(TOP)$(ROOT)config/rules.cf
|
||||
|
||||
@@ -520,6 +520,7 @@ typedef struct HB_CBVAR_ /* This structure holds local variables declared in a
|
||||
{
|
||||
char * szName;
|
||||
BYTE bType;
|
||||
BOOL bUsed;
|
||||
struct HB_CBVAR_ * pNext;
|
||||
} HB_CBVAR, * HB_CBVAR_PTR;
|
||||
|
||||
|
||||
@@ -249,6 +249,20 @@ void hb_compPCodeEval( PFUNCTION, HB_PCODE_FUNC_PTR *, void * );
|
||||
#define VS_PUBLIC 128
|
||||
#define VS_MEMVAR ( VS_PUBLIC | VS_PRIVATE )
|
||||
|
||||
/* return detailed information about a class of variable */
|
||||
int hb_compVariableScope( char * );
|
||||
#define HB_VS_UNDECLARED 0
|
||||
/* variables declared in a current codeblock/function/procedure */
|
||||
#define HB_VS_CBLOCAL_VAR 1 /* local parameter of a codeblock */
|
||||
#define HB_VS_LOCAL_VAR 2
|
||||
#define HB_VS_LOCAL_MEMVAR 4
|
||||
#define HB_VS_LOCAL_FIELD 8
|
||||
#define HB_VS_STATIC_VAR 16
|
||||
/* variables declared outside of a current function/procedure */
|
||||
#define HB_VS_GLOBAL_MEMVAR (32 | HB_VS_LOCAL_MEMVAR)
|
||||
#define HB_VS_GLOBAL_FIELD (32 | HB_VS_LOCAL_FIELD)
|
||||
#define HB_VS_GLOBAL_STATIC (32 | HB_VS_STATIC_VAR)
|
||||
|
||||
#define VU_NOT_USED 0
|
||||
#define VU_INITIALIZED 1
|
||||
#define VU_USED 2
|
||||
@@ -315,10 +329,11 @@ extern void hb_compAutoOpenAdd( char * szName );
|
||||
#define hb_compErrorAlias( p ) hb_macroError( EG_NOALIAS, HB_MACRO_PARAM )
|
||||
#define hb_compErrorDuplVar( c ) hb_macroError( EG_SYNTAX, HB_MACRO_PARAM )
|
||||
#define hb_compWarnMeaningless( p )
|
||||
#define hb_compErrorMacro( p )
|
||||
|
||||
#else /* HB_MACRO_SUPPORT */
|
||||
|
||||
extern BOOL hb_compVariableMacroCheck( char * ); /* checks if passed variable can be used in macro */
|
||||
extern BOOL hb_compIsValidMacroVar( char * ); /* checks if passed variable can be used in macro */
|
||||
|
||||
extern ULONG hb_compGenJump( LONG ); /* generates the pcode to jump to a specific offset */
|
||||
extern ULONG hb_compGenJumpFalse( LONG ); /* generates the pcode to jump if false */
|
||||
@@ -361,6 +376,7 @@ extern void hb_compSequenceFinish( ULONG, int );
|
||||
/* Codeblocks */
|
||||
extern void hb_compCodeBlockStart( void ); /* starts a codeblock creation */
|
||||
extern void hb_compCodeBlockEnd( void ); /* end of codeblock creation */
|
||||
extern void hb_compCodeBlockStop( void ); /* end of fake codeblock */
|
||||
|
||||
/* support for FIELD declaration */
|
||||
extern void hb_compFieldSetAlias( char *, int );
|
||||
@@ -379,6 +395,8 @@ extern HB_EXPR_PTR hb_compErrorBound( HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compErrorAlias( HB_EXPR_PTR );
|
||||
extern void hb_compErrorDuplVar( char * );
|
||||
extern HB_EXPR_PTR hb_compWarnMeaningless( HB_EXPR_PTR );
|
||||
extern void hb_compErrorCodeblock( char * );
|
||||
extern void hb_compErrorMacro( char * );
|
||||
|
||||
extern void hb_compChkCompilerSwitch( int, char * Args[] );
|
||||
extern void hb_compChkEnvironVar( char * );
|
||||
|
||||
@@ -181,11 +181,11 @@ HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR pCB, char * szVarName, BYTE bType )
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compExprCBVarAdd(%s)", szVarName));
|
||||
|
||||
if( pCB->value.asList.pIndex )
|
||||
if( pCB->value.asCodeblock.pLocals )
|
||||
{
|
||||
/* add it to the end of the list
|
||||
*/
|
||||
pVar = ( HB_CBVAR_PTR ) pCB->value.asList.pIndex;
|
||||
pVar = pCB->value.asCodeblock.pLocals;
|
||||
while( pVar )
|
||||
{
|
||||
if( strcmp( szVarName, pVar->szName ) == 0 )
|
||||
@@ -206,9 +206,9 @@ HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR pCB, char * szVarName, BYTE bType )
|
||||
}
|
||||
else
|
||||
#ifdef HB_MACRO_SUPPORT
|
||||
pCB->value.asList.pIndex = ( HB_EXPR_PTR ) hb_compExprCBVarNew( szVarName, ' ' );
|
||||
pCB->value.asCodeblock.pLocals = hb_compExprCBVarNew( szVarName, ' ' );
|
||||
#else
|
||||
pCB->value.asList.pIndex = ( HB_EXPR_PTR ) hb_compExprCBVarNew( szVarName, bType );
|
||||
pCB->value.asCodeblock.pLocals = hb_compExprCBVarNew( szVarName, bType );
|
||||
#endif
|
||||
|
||||
return pCB;
|
||||
@@ -903,6 +903,7 @@ static HB_CBVAR_PTR hb_compExprCBVarNew( char * szVarName, BYTE bType )
|
||||
pVar->szName = szVarName;
|
||||
pVar->bType = bType;
|
||||
pVar->pNext = NULL;
|
||||
pVar->bUsed = FALSE;
|
||||
|
||||
return pVar;
|
||||
}
|
||||
@@ -980,7 +981,7 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr )
|
||||
/* create a codeblock
|
||||
* NOTE: we can ommit a local variable if HB_PARAM() is used
|
||||
*/
|
||||
return hb_compExprAddListExpr( hb_compExprNewCodeBlock(), pIIF );
|
||||
return hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock(NULL,0,0), pIIF );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -171,6 +171,15 @@ static HB_EXPR_FUNC( hb_compExprUseNE );
|
||||
static HB_EXPR_FUNC( hb_compExprUseIN );
|
||||
static HB_EXPR_FUNC( hb_compExprUseNegate );
|
||||
|
||||
/* other helper functions
|
||||
*/
|
||||
#if defined( HB_MACRO_SUPPORT )
|
||||
static void hb_compExprCodeblockPush( HB_EXPR_PTR, HB_MACRO_DECL );
|
||||
#else
|
||||
static void hb_compExprCodeblockPush( HB_EXPR_PTR );
|
||||
static void hb_compExprCodeblockEarly( HB_EXPR_PTR );
|
||||
#endif
|
||||
|
||||
HB_EXPR_FUNC_PTR hb_comp_ExprTable[] = {
|
||||
hb_compExprUseDummy,
|
||||
hb_compExprUseNil,
|
||||
@@ -337,9 +346,14 @@ static HB_EXPR_FUNC( hb_compExprUseString )
|
||||
break;
|
||||
case HB_EA_PUSH_PCODE:
|
||||
{
|
||||
char *szDupl;
|
||||
szDupl = hb_strupr( hb_strdup( pSelf->value.asString.string ) );
|
||||
HB_EXPR_PCODE2( hb_compGenPushString, pSelf->value.asString.string, pSelf->ulLength + 1 );
|
||||
if( hb_compExprCheckMacroVar( pSelf->value.asString.string ) )
|
||||
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROTEXT );
|
||||
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROTEXT );
|
||||
if( ! hb_compExprIsValidMacro( szDupl ) )
|
||||
hb_compErrorMacro( pSelf->value.asString.string );
|
||||
hb_xfree( szDupl );
|
||||
|
||||
}
|
||||
break;
|
||||
case HB_EA_POP_PCODE:
|
||||
@@ -375,64 +389,17 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock )
|
||||
break;
|
||||
case HB_EA_PUSH_PCODE:
|
||||
{
|
||||
HB_EXPR_PTR pExpr, pNext;
|
||||
HB_EXPR_PTR * pPrev;
|
||||
|
||||
HB_EXPR_PCODE0( hb_compCodeBlockStart );
|
||||
/* Define requested local variables
|
||||
*/
|
||||
#if defined( HB_MACRO_SUPPORT )
|
||||
HB_PCODE_DATA->pLocals = ( HB_CBVAR_PTR ) pSelf->value.asList.pIndex;
|
||||
#if defined(SIMPLEX) || defined(HB_MACRO_SUPPORT)
|
||||
HB_EXPR_PCODE1( hb_compExprCodeblockPush, pSelf );
|
||||
#else
|
||||
{
|
||||
HB_CBVAR_PTR pVar;
|
||||
|
||||
pVar = ( HB_CBVAR_PTR ) pSelf->value.asList.pIndex;
|
||||
while( pVar )
|
||||
{
|
||||
hb_compVariableAdd( pVar->szName, pVar->bType );
|
||||
pVar =pVar->pNext;
|
||||
}
|
||||
}
|
||||
if( !pSelf->value.asCodeblock.isMacro || pSelf->value.asCodeblock.lateEval )
|
||||
hb_compExprCodeblockPush( pSelf );
|
||||
else
|
||||
{
|
||||
/* early evaluation of a macro */
|
||||
hb_compExprCodeblockEarly( pSelf );
|
||||
}
|
||||
#endif
|
||||
pExpr = pSelf->value.asList.pExprList;
|
||||
pPrev = &pSelf->value.asList.pExprList;
|
||||
while( pExpr )
|
||||
{
|
||||
if( pExpr->ExprType == HB_ET_MACRO )
|
||||
{
|
||||
/* Clipper allows for list expressions in a codeblock
|
||||
* macro := "1,2"
|
||||
* EVAL( {|| ¯o} )
|
||||
*/
|
||||
pExpr->value.asMacro.SubType |= HB_ET_MACRO_PARE;
|
||||
}
|
||||
|
||||
/* store next expression in case the current will be reduced
|
||||
* NOTE: During reduction the expression can be replaced by the
|
||||
* new one - this will break the linked list of expressions.
|
||||
*/
|
||||
pNext = pExpr->pNext; /* store next expression in case the current will be reduced */
|
||||
pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE );
|
||||
/* Generate push/pop pcodes for all expresions except the last one
|
||||
* The value of the last expression is used as a return value
|
||||
* of a codeblock evaluation
|
||||
*/
|
||||
/* NOTE: This will genereate warnings if constant value is
|
||||
* used as an expression - some operators will generate it too
|
||||
* e.g.
|
||||
* EVAL( {|| 3+5, func()} )
|
||||
*/
|
||||
*pPrev = pExpr; /* store a new expression into the previous one */
|
||||
pExpr->pNext = pNext; /* restore the link to next expression */
|
||||
if( pNext )
|
||||
HB_EXPR_USE( pExpr, HB_EA_PUSH_POP );
|
||||
else
|
||||
HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE );
|
||||
pPrev = &pExpr->pNext;
|
||||
pExpr = pNext;
|
||||
}
|
||||
HB_EXPR_PCODE0( hb_compCodeBlockEnd );
|
||||
}
|
||||
break;
|
||||
case HB_EA_POP_PCODE:
|
||||
@@ -442,10 +409,10 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock )
|
||||
break;
|
||||
case HB_EA_DELETE:
|
||||
{
|
||||
HB_EXPR_PTR pExp = pSelf->value.asList.pExprList;
|
||||
HB_EXPR_PTR pExp = pSelf->value.asCodeblock.pExprList;
|
||||
HB_EXPR_PTR pNext;
|
||||
|
||||
hb_compExprCBVarDel( ( HB_CBVAR_PTR ) pSelf->value.asList.pIndex );
|
||||
hb_compExprCBVarDel( pSelf->value.asCodeblock.pLocals );
|
||||
|
||||
/* Delete all expressions of the block.
|
||||
*/
|
||||
@@ -462,6 +429,126 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock )
|
||||
return pSelf;
|
||||
}
|
||||
|
||||
/* This generates a push pcode for a codeblock (with no macro expression or
|
||||
with late evaluation of a macro)
|
||||
*/
|
||||
#if defined( HB_MACRO_SUPPORT )
|
||||
static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, HB_MACRO_DECL )
|
||||
#else
|
||||
static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf )
|
||||
#endif
|
||||
{
|
||||
HB_EXPR_PTR pExpr, pNext;
|
||||
HB_EXPR_PTR * pPrev;
|
||||
|
||||
HB_EXPR_PCODE0( hb_compCodeBlockStart );
|
||||
/* Define requested local variables
|
||||
*/
|
||||
#if defined( HB_MACRO_SUPPORT )
|
||||
HB_PCODE_DATA->pLocals = pSelf->value.asCodeblock.pLocals;
|
||||
#else
|
||||
{
|
||||
HB_CBVAR_PTR pVar;
|
||||
|
||||
pVar = pSelf->value.asCodeblock.pLocals;
|
||||
while( pVar )
|
||||
{
|
||||
hb_compVariableAdd( pVar->szName, pVar->bType );
|
||||
pVar =pVar->pNext;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
pExpr = pSelf->value.asCodeblock.pExprList;
|
||||
pPrev = &pSelf->value.asCodeblock.pExprList;
|
||||
while( pExpr )
|
||||
{
|
||||
if( pExpr->ExprType == HB_ET_MACRO )
|
||||
{
|
||||
/* Clipper allows for list expressions in a codeblock
|
||||
* macro := "1,2"
|
||||
* EVAL( {|| ¯o} )
|
||||
*/
|
||||
pExpr->value.asMacro.SubType |= HB_ET_MACRO_PARE;
|
||||
}
|
||||
|
||||
/* store next expression in case the current will be reduced
|
||||
* NOTE: During reduction the expression can be replaced by the
|
||||
* new one - this will break the linked list of expressions.
|
||||
*/
|
||||
pNext = pExpr->pNext; /* store next expression in case the current will be reduced */
|
||||
pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE );
|
||||
/* Generate push/pop pcodes for all expresions except the last one
|
||||
* The value of the last expression is used as a return value
|
||||
* of a codeblock evaluation
|
||||
*/
|
||||
/* NOTE: This will genereate warnings if constant value is
|
||||
* used as an expression - some operators will generate it too
|
||||
* e.g.
|
||||
* EVAL( {|| 3+5, func()} )
|
||||
*/
|
||||
*pPrev = pExpr; /* store a new expression into the previous one */
|
||||
pExpr->pNext = pNext; /* restore the link to next expression */
|
||||
if( pNext )
|
||||
HB_EXPR_USE( pExpr, HB_EA_PUSH_POP );
|
||||
else
|
||||
HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE );
|
||||
pPrev = &pExpr->pNext;
|
||||
pExpr = pNext;
|
||||
}
|
||||
HB_EXPR_PCODE0( hb_compCodeBlockEnd );
|
||||
}
|
||||
|
||||
/* This generates a push pcode for early evaluation of a macro
|
||||
*/
|
||||
#if !defined(HB_MACRO_SUPPORT)
|
||||
static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf )
|
||||
{
|
||||
HB_EXPR_PTR pExpr;
|
||||
|
||||
HB_EXPR_PCODE0( hb_compCodeBlockStart );
|
||||
|
||||
/* check first expression */
|
||||
pExpr = pSelf->value.asCodeblock.pExprList;
|
||||
if( pExpr->ExprType == HB_ET_MACRO && pExpr->value.asMacro.cMacroOp )
|
||||
{
|
||||
/* simple macro variable expansion: &variable
|
||||
* 'szMacro' is a variable name
|
||||
* {|| &variable} => &( '{||' + variable +'}' )
|
||||
*/
|
||||
HB_EXPR_PTR pVar, pNew;
|
||||
|
||||
pVar = hb_compExprNewVar( pExpr->value.asMacro.szMacro );
|
||||
pNew = hb_compExprNewString( "{||" );
|
||||
pNew = hb_compExprSetOperand( hb_compExprNewPlus( pNew ), pVar );
|
||||
pNew = hb_compExprSetOperand( hb_compExprNewPlus( pNew ), hb_compExprNewString( "}" ) );
|
||||
pNew = hb_compExprNewMacro( pNew, 0, NULL );
|
||||
HB_EXPR_USE( pNew, HB_EA_PUSH_PCODE );
|
||||
hb_compExprDelete( pNew );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* everything else is macro compiled at runtime
|
||||
* {|| &variable+1} => &( '{|| &variable+1}' )
|
||||
*/
|
||||
HB_EXPR_PTR pNew;
|
||||
char *szDupl;
|
||||
|
||||
szDupl = hb_strupr( hb_strdup( pSelf->value.asCodeblock.string ) );
|
||||
if( !hb_compExprIsValidMacro( szDupl ) )
|
||||
{
|
||||
hb_compErrorCodeblock( pSelf->value.asCodeblock.string );
|
||||
hb_compErrorMacro( pSelf->value.asCodeblock.string );
|
||||
}
|
||||
hb_xfree( szDupl );
|
||||
pNew = hb_compExprNewMacro( hb_compExprNewString(pSelf->value.asCodeblock.string), 0, NULL );
|
||||
HB_EXPR_USE( pNew, HB_EA_PUSH_PCODE );
|
||||
hb_compExprDelete( pNew );
|
||||
}
|
||||
|
||||
HB_EXPR_PCODE0( hb_compCodeBlockStop );
|
||||
}
|
||||
#endif /*HB_MACRO_SUPPORT*/
|
||||
|
||||
/* actions for HB_ET_LOGICAL expression
|
||||
*/
|
||||
static HB_EXPR_FUNC( hb_compExprUseLogical )
|
||||
|
||||
@@ -416,20 +416,20 @@ ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr )
|
||||
return ulCnt;
|
||||
}
|
||||
|
||||
BOOL hb_compExprCheckMacroVar( char * szText )
|
||||
BOOL hb_compExprIsValidMacro( char * szText )
|
||||
{
|
||||
char * pTmp = szText;
|
||||
BOOL bTextSubst;
|
||||
BOOL bMacroText = FALSE;
|
||||
BOOL bMacroText = TRUE;
|
||||
|
||||
while( ( pTmp = strchr( pTmp, '&' ) ) != NULL )
|
||||
while( (( pTmp = strchr( pTmp, '&' ) ) != NULL) && bMacroText )
|
||||
{
|
||||
/* Check if macro operator is used inside a string
|
||||
* Macro operator is ignored if it is the last char or
|
||||
* next char is '(' e.g. "this is &(ignored)"
|
||||
*
|
||||
* NOTE: This uses _a-zA-Z pattern to check for
|
||||
* variable name beginning
|
||||
* beginning of a variable name
|
||||
*/
|
||||
|
||||
++pTmp;
|
||||
@@ -459,12 +459,13 @@ BOOL hb_compExprCheckMacroVar( char * szText )
|
||||
|
||||
cSave = *pTmp;
|
||||
*pTmp = '\0';
|
||||
hb_compVariableMacroCheck( pStart );
|
||||
|
||||
bMacroText &= hb_compIsValidMacroVar( pStart );
|
||||
*pTmp = cSave;
|
||||
bMacroText = TRUE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return bMacroText;
|
||||
}
|
||||
|
||||
|
||||
@@ -205,6 +205,14 @@ typedef struct HB_EXPR_
|
||||
struct HB_EXPR_ *pIndex; /* array index, others */
|
||||
} asList;
|
||||
struct
|
||||
{
|
||||
BOOL isMacro; /* TRUE=codeblock contains macro expression */
|
||||
BOOL lateEval; /* TRUE=late evaluation of macro */
|
||||
char *string; /* source code of a codeblock */
|
||||
struct HB_EXPR_ *pExprList; /* list elements */
|
||||
HB_CBVAR_PTR pLocals; /* list of local variables */
|
||||
} asCodeblock;
|
||||
struct
|
||||
{
|
||||
struct HB_EXPR_ *pAlias; /* alias expression */
|
||||
struct HB_EXPR_ *pVar; /* aliased variable or macro */
|
||||
@@ -301,7 +309,11 @@ HB_EXPR_PTR hb_compExprNewLong( LONG );
|
||||
HB_EXPR_PTR hb_compExprNewString( char * );
|
||||
HB_EXPR_PTR hb_compExprNewLogical( int );
|
||||
HB_EXPR_PTR hb_compExprNewSelf( void );
|
||||
#if defined(SIMPLEX)
|
||||
HB_EXPR_PTR hb_compExprNewCodeBlock( void );
|
||||
#else
|
||||
HB_EXPR_PTR hb_compExprNewCodeBlock( char *, BOOL, BOOL );
|
||||
#endif
|
||||
HB_EXPR_PTR hb_compExprNewArray( HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprNewVar( char * );
|
||||
HB_EXPR_PTR hb_compExprNewAliasVar( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
@@ -348,6 +360,7 @@ HB_EXPR_PTR hb_compExprNewMethodCall( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprNewList( HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprNewArgList( HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprAddListExpr( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprAddCodeblockExpr( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR );
|
||||
HB_EXPR_PTR hb_compExprAssign( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
@@ -362,7 +375,7 @@ int hb_compExprType( HB_EXPR_PTR );
|
||||
void hb_compExprFree( HB_EXPR_PTR, HB_MACRO_DECL );
|
||||
void hb_compExprErrorType( HB_EXPR_PTR, HB_MACRO_DECL );
|
||||
HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR, HB_MACRO_DECL );
|
||||
BOOL hb_compExprCheckMacroVar( char * );
|
||||
BOOL hb_compExprIsValidMacro( char * );
|
||||
void hb_compExprCBVarDel( HB_CBVAR_PTR );
|
||||
HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR, HB_EXPR_PTR, HB_MACRO_DECL );
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ extern "C" {
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
#define HB_MATH_HANDLER
|
||||
#define exception _exception
|
||||
#elif defined(__BORLANDC__)
|
||||
#if (__BORLANDC__ == 1328) && defined(__cplusplus)
|
||||
/* NOTE: There seem to be a bug in Borland C++ 5.3 C++ mode which prevents
|
||||
|
||||
@@ -211,7 +211,7 @@ typedef CDXINDEX * LPCDXINDEX;
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma pack(push, 1);
|
||||
#pragma push(pack, 1);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
@@ -288,7 +288,7 @@ typedef CDXLEAFHEADER * LPCDXLEAFHEADER;
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma pack(pop);
|
||||
#pragma pop(pack);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
@@ -216,21 +216,51 @@ HB_EXPR_PTR hb_compExprNewLong( long lValue )
|
||||
}
|
||||
|
||||
|
||||
#if defined(SIMPLEX)
|
||||
HB_EXPR_PTR hb_compExprNewCodeBlock( void )
|
||||
#else
|
||||
HB_EXPR_PTR hb_compExprNewCodeBlock( char *string, BOOL isMacro, BOOL lateEval )
|
||||
#endif
|
||||
{
|
||||
HB_EXPR_PTR pExpr;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewCodeBlock()"));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewCodeBlock(%s,%u,%u)",string,isMacro,lateEval));
|
||||
|
||||
pExpr =hb_compExprNew( HB_ET_CODEBLOCK );
|
||||
|
||||
pExpr->value.asList.pExprList = NULL;
|
||||
pExpr->value.asList.pIndex = NULL; /* this will hold local variables declarations */
|
||||
pExpr->value.asCodeblock.pExprList = NULL;
|
||||
pExpr->value.asCodeblock.pLocals = NULL; /* this will hold local variables declarations */
|
||||
pExpr->ValType = HB_EV_CODEBLOCK;
|
||||
|
||||
#if defined(SIMPLEX)
|
||||
pExpr->value.asCodeblock.string = NULL;
|
||||
pExpr->value.asCodeblock.isMacro = FALSE;
|
||||
pExpr->value.asCodeblock.lateEval = FALSE;
|
||||
#else
|
||||
pExpr->value.asCodeblock.string = string;
|
||||
pExpr->value.asCodeblock.isMacro = isMacro;
|
||||
pExpr->value.asCodeblock.lateEval = lateEval;
|
||||
#endif
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
HB_EXPR_PTR hb_compExprAddCodeblockExpr( HB_EXPR_PTR pList, HB_EXPR_PTR pNewItem )
|
||||
{
|
||||
if( pList->value.asCodeblock.pExprList )
|
||||
{
|
||||
HB_EXPR_PTR pExpr;
|
||||
|
||||
/* add new item to the end of the list */
|
||||
pExpr = pList->value.asCodeblock.pExprList;
|
||||
while( pExpr->pNext )
|
||||
pExpr = pExpr->pNext;
|
||||
pExpr->pNext = pNewItem;
|
||||
}
|
||||
else
|
||||
pList->value.asCodeblock.pExprList = pNewItem;
|
||||
|
||||
return pList;
|
||||
}
|
||||
|
||||
HB_EXPR_PTR hb_compExprNewLogical( int iValue )
|
||||
{
|
||||
HB_EXPR_PTR pExpr;
|
||||
@@ -372,7 +402,12 @@ HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR pMacroExpr, unsigned char cMacroOp,
|
||||
* ? &var // this is OK
|
||||
* ? &var.ext // this is invalid
|
||||
*/
|
||||
hb_compExprCheckMacroVar( szName );
|
||||
char *szDupl;
|
||||
szDupl = hb_strupr( hb_strdup( szName ) );
|
||||
if( ! hb_compExprIsValidMacro( szDupl ) )
|
||||
hb_compErrorMacro( szName );
|
||||
hb_xfree( szDupl );
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -77,13 +77,33 @@ HB_FILE_VER( "$Id$" )
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <dos.h>
|
||||
#if !defined(__WATCOMC__)
|
||||
#include <dir.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
typedef struct
|
||||
{
|
||||
struct find_t entry;
|
||||
} HB_FFIND_INFO, * PHB_FFIND_INFO;
|
||||
|
||||
#define FA_ARCH _A_ARCH
|
||||
#define FA_DIREC _A_SUBDIR
|
||||
#define FA_HIDDEN _A_HIDDEN
|
||||
#define FA_RDONLY _A_RDONLY
|
||||
#define FA_LABEL _A_VOLID
|
||||
#define FA_SYSTEM _A_SYSTEM
|
||||
|
||||
#define ff_name name
|
||||
#define ff_fsize size
|
||||
#define ff_attrib attrib
|
||||
#else
|
||||
typedef struct
|
||||
{
|
||||
struct ffblk entry;
|
||||
} HB_FFIND_INFO, * PHB_FFIND_INFO;
|
||||
#endif
|
||||
|
||||
#elif defined(HB_OS_OS2)
|
||||
|
||||
@@ -604,7 +624,11 @@ PHB_FFIND hb_fsFindFirst( const char * pszFileName, USHORT uiAttr )
|
||||
|
||||
tzset();
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
bFound = ( _dos_findfirst( pszFileName, ( USHORT ) hb_fsAttrToRaw( uiAttr ), &info->entry ) == 0 );
|
||||
#else
|
||||
bFound = ( findfirst( pszFileName, &info->entry, ( USHORT ) hb_fsAttrToRaw( uiAttr ) ) == 0 );
|
||||
#endif
|
||||
#if defined(__DJGPP__) || defined(__RSX32__)
|
||||
if (errno==22)
|
||||
errno=2;
|
||||
@@ -784,7 +808,11 @@ BOOL hb_fsFindNext( PHB_FFIND ffind )
|
||||
|
||||
{
|
||||
errno = 0;
|
||||
#if defined(__WATCOMC__)
|
||||
bFound = ( _dos_findnext( &info->entry ) == 0 );
|
||||
#else
|
||||
bFound = ( findnext( &info->entry ) == 0 );
|
||||
#endif
|
||||
#if defined(__DJGPP__) || defined(__RSX32__)
|
||||
if (errno==22)
|
||||
errno=2;
|
||||
@@ -893,7 +921,11 @@ void hb_fsFindClose( PHB_FFIND ffind )
|
||||
}
|
||||
#else
|
||||
{
|
||||
#if defined(__WATCOMC__)
|
||||
_dos_findclose( &info->entry );
|
||||
#else
|
||||
findclose( &info->entry );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
/* hbexpra.c is also included from ../macro/macro.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 7 - ignore this magic number - this is used to force compilation
|
||||
* 8 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
#include "hbexpra.c"
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
/* hbexprb.c is also included from ../macro/macro.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 9 - ignore this magic number - this is used to force compilation
|
||||
* 10 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
#include "hbexprb.c"
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
/* hbexprc.c is also included from ../macro/macro.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 1 - ignore this magic number - this is used to force compilation
|
||||
* 2 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
#include "hbexprc.c"
|
||||
|
||||
@@ -756,16 +756,16 @@ void hb_compVariableAdd( char * szVarName, BYTE cValueType )
|
||||
* expression.
|
||||
* Only MEMVAR or undeclared (memvar will be assumed) variables can be used.
|
||||
*/
|
||||
BOOL hb_compVariableMacroCheck( char * szVarName )
|
||||
BOOL hb_compIsValidMacroVar( char * szVarName )
|
||||
{
|
||||
BOOL bValid = FALSE;
|
||||
|
||||
if( hb_compLocalGetPos( szVarName ) > 0 )
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );
|
||||
if( hb_compLocalGetPos( szVarName ) )
|
||||
;/* hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( hb_compStaticGetPos( szVarName, hb_comp_functions.pLast ) > 0 )
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );
|
||||
;/* hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( hb_compFieldGetPos( szVarName, hb_comp_functions.pLast ) > 0 )
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );
|
||||
;/* hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( ! hb_comp_bStartProc )
|
||||
{
|
||||
if( hb_compMemvarGetPos( szVarName, hb_comp_functions.pLast ) == 0 )
|
||||
@@ -773,9 +773,9 @@ BOOL hb_compVariableMacroCheck( char * szVarName )
|
||||
/* This is not a local MEMVAR
|
||||
*/
|
||||
if( hb_compFieldGetPos( szVarName, hb_comp_functions.pFirst ) > 0 )
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );
|
||||
; /*hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( hb_compStaticGetPos( szVarName, hb_comp_functions.pFirst ) > 0 )
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );
|
||||
; /*hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else
|
||||
bValid = TRUE; /* undeclared variable */
|
||||
}
|
||||
@@ -787,6 +787,36 @@ BOOL hb_compVariableMacroCheck( char * szVarName )
|
||||
return bValid;
|
||||
}
|
||||
|
||||
int hb_compVariableScope( char * szVarName )
|
||||
{
|
||||
int iScope = 0; /* undeclared */
|
||||
int iLocalPos;
|
||||
|
||||
iLocalPos = hb_compLocalGetPos( szVarName );
|
||||
if( iLocalPos > 0 )
|
||||
iScope = HB_VS_LOCAL_VAR;
|
||||
else if( iLocalPos < 0 )
|
||||
iScope = HB_VS_CBLOCAL_VAR;
|
||||
else if( hb_compStaticGetPos( szVarName, hb_comp_functions.pLast ) > 0 )
|
||||
iScope = HB_VS_STATIC_VAR;
|
||||
else if( hb_compFieldGetPos( szVarName, hb_comp_functions.pLast ) > 0 )
|
||||
iScope = HB_VS_LOCAL_FIELD;
|
||||
else if( hb_compMemvarGetPos( szVarName, hb_comp_functions.pLast ) > 0 )
|
||||
iScope = HB_VS_LOCAL_MEMVAR;
|
||||
else if( ! hb_comp_bStartProc )
|
||||
{
|
||||
/* Check file-wide variables
|
||||
*/
|
||||
if( hb_compMemvarGetPos( szVarName, hb_comp_functions.pFirst ) == 0 )
|
||||
iScope = HB_VS_GLOBAL_MEMVAR;
|
||||
else if( hb_compFieldGetPos( szVarName, hb_comp_functions.pFirst ) > 0 )
|
||||
iScope = HB_VS_GLOBAL_FIELD;
|
||||
else if( hb_compStaticGetPos( szVarName, hb_comp_functions.pFirst ) > 0 )
|
||||
iScope = HB_VS_GLOBAL_STATIC;
|
||||
}
|
||||
return iScope;
|
||||
}
|
||||
|
||||
PCOMCLASS hb_compClassAdd( char * szClassName )
|
||||
{
|
||||
PCOMCLASS pClass;
|
||||
@@ -3796,6 +3826,55 @@ void hb_compCodeBlockEnd( void )
|
||||
hb_xfree( ( void * ) pCodeblock );
|
||||
}
|
||||
|
||||
void hb_compCodeBlockStop( void )
|
||||
{
|
||||
PFUNCTION pCodeblock; /* pointer to the current codeblock */
|
||||
PFUNCTION pFunc;/* pointer to a function that owns a codeblock */
|
||||
USHORT wLocals = 0; /* number of referenced local variables */
|
||||
USHORT wUsed;
|
||||
PVAR pVar, pFree;
|
||||
|
||||
pCodeblock = hb_comp_functions.pLast;
|
||||
|
||||
/* return to pcode buffer of function/codeblock in which the current
|
||||
* codeblock was defined
|
||||
*/
|
||||
hb_comp_functions.pLast = pCodeblock->pOwner;
|
||||
|
||||
/* find the function that owns the codeblock */
|
||||
pFunc = pCodeblock->pOwner;
|
||||
while( pFunc->pOwner )
|
||||
pFunc = pFunc->pOwner;
|
||||
|
||||
pFunc->bFlags |= ( pCodeblock->bFlags & FUN_USES_STATICS );
|
||||
|
||||
/* Count the number of referenced local variables */
|
||||
pVar = pCodeblock->pStatics;
|
||||
while( pVar )
|
||||
{
|
||||
pVar = pVar->pNext;
|
||||
++wLocals;
|
||||
}
|
||||
|
||||
wUsed =0;
|
||||
pVar = pCodeblock->pLocals;
|
||||
while( pVar )
|
||||
{
|
||||
if( pVar->iUsed & VU_USED )
|
||||
wUsed = 1;
|
||||
|
||||
/* free used variables */
|
||||
pFree = pVar;
|
||||
|
||||
pVar = pVar->pNext;
|
||||
hb_xfree( ( void * ) pFree );
|
||||
}
|
||||
|
||||
hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, ( BOOL ) 0 );
|
||||
hb_xfree( ( void * ) pCodeblock->pCode );
|
||||
hb_xfree( ( void * ) pCodeblock );
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
/* initialize support variables */
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
/* helper functions */
|
||||
static int yy_ConvertNumber( char * szBuffer );
|
||||
extern int hb_ppInsideTextBlock;
|
||||
|
||||
/* YACC functions */
|
||||
void yyerror( char * );
|
||||
@@ -81,6 +82,10 @@ int yy_lex_input( char *, int );
|
||||
static int hb_comp_iState = LOOKUP;
|
||||
static int _iOpenBracket = 0;
|
||||
|
||||
/* Stores a codeblock picture for late/early evaluation
|
||||
*/
|
||||
char *hb_lex_codeblock = NULL;
|
||||
|
||||
#define DEBUG_STRINGS
|
||||
|
||||
%}
|
||||
@@ -165,14 +170,13 @@ Separator {SpaceTab}
|
||||
from direct calls for qout function
|
||||
QOUT([some string]) ; QOUT([some more])
|
||||
*/
|
||||
/* TODO: implement hb_ppInsideTextBlock it is PP
|
||||
if( hb_ppInsideTextBlock )
|
||||
{
|
||||
BEGIN STRING4START;
|
||||
unput( '(' );
|
||||
}
|
||||
else
|
||||
*/
|
||||
|
||||
yyless( 4 ); /* len of QOUT */
|
||||
|
||||
yylval.string = hb_compIdentifierNew( "QOUT", TRUE );
|
||||
@@ -1409,6 +1413,107 @@ Separator {SpaceTab}
|
||||
}
|
||||
}
|
||||
|
||||
%{
|
||||
/* ************************************************************************ */
|
||||
%}
|
||||
"\{"{Separator}*"\|".*/\n { /* codeblock scanning */
|
||||
/*
|
||||
We have to know if the codeblock contains the macro
|
||||
expression &var or &(var)
|
||||
In case of &var we have to store in the pcode the source code
|
||||
of the codeblock - the string with the whole codeblock
|
||||
have to be saved. At runtime, this string is macro
|
||||
expanded and the result string is next macro compiled to
|
||||
create a codeblock - this is called 'the early macro evaluation'.
|
||||
In contrast, the late macro evaluation &(var) creates
|
||||
the codeblock at compile time - the macro is expanded
|
||||
during the codeblock evaluation.
|
||||
The following code:
|
||||
//early evaluation
|
||||
PRIVATE a
|
||||
FOR i:=1 TO 3
|
||||
a:=STR(i)
|
||||
cb[i] := {|| &a} //the same as cb[i] := &( '{||'+a+'}' )
|
||||
NEXT
|
||||
....
|
||||
FOR i:=1 TO 3
|
||||
? EVAL( cb[i] ) //prints '1','2','3'
|
||||
NEXT
|
||||
//late evaluation
|
||||
FOR i:=1 TO 3
|
||||
a:=STR(i)
|
||||
cb[i] := {|| &(a)}
|
||||
NEXT
|
||||
....
|
||||
FOR i:=1 TO 3
|
||||
? EVAL( cb[i] ) //prints '3','3','3'
|
||||
NEXT
|
||||
*/
|
||||
char *cText;
|
||||
int iLen;
|
||||
int iPos=0;
|
||||
int iCode=1;
|
||||
char cMark='\0';
|
||||
|
||||
yylval.asCodeblock.isMacro = FALSE;
|
||||
yylval.asCodeblock.lateEval = FALSE;
|
||||
cText = yytext+1;
|
||||
iLen = 1;
|
||||
while( *cText || ((cMark != '\0') && (*cText == '\0')) )
|
||||
{
|
||||
iLen++;
|
||||
if( *cText == '\'' )
|
||||
{
|
||||
if( cMark == '\'' )
|
||||
cMark = '\0';
|
||||
else if( cMark == '\0' )
|
||||
cMark = '\'';
|
||||
}
|
||||
else if( *cText == '"' )
|
||||
{
|
||||
if( cMark == '"' )
|
||||
cMark = '\0';
|
||||
else if( cMark == '\0' )
|
||||
cMark = '"';
|
||||
}
|
||||
else if( *cText == '[' )
|
||||
{
|
||||
if( cMark == ']' )
|
||||
cMark = '\0';
|
||||
else if( cMark == '\0' )
|
||||
cMark = ']';
|
||||
}
|
||||
else if( *cText == '|' && iPos == 0 )
|
||||
iPos = iLen;
|
||||
else if( *cText == '&' && cMark == '\0' )
|
||||
{
|
||||
yylval.asCodeblock.isMacro = TRUE;
|
||||
++cText;
|
||||
while( *cText == ' ' || *cText == '\t' )
|
||||
++cText;
|
||||
if( *cText == '(' )
|
||||
yylval.asCodeblock.lateEval = TRUE;
|
||||
--cText;
|
||||
}
|
||||
else if( *cText == '{' && cMark == '\0' )
|
||||
iCode++;
|
||||
else if( *cText == '}' && cMark == '\0' )
|
||||
{
|
||||
iCode--;
|
||||
if( iCode == 0 )
|
||||
break;
|
||||
}
|
||||
cText++;
|
||||
}
|
||||
cMark = yytext[ iLen ];
|
||||
yylval.asCodeblock.string = hb_xgrab( iLen+1 );
|
||||
memcpy( (void *)yylval.asCodeblock.string, (void *)yytext, iLen );
|
||||
yylval.asCodeblock.string[iLen] = '\0';
|
||||
yylval.asCodeblock.length = iLen;
|
||||
yyless( iPos ); /* restart scanning after '{|' */
|
||||
return CBSTART;
|
||||
}
|
||||
|
||||
%{
|
||||
/* ************************************************************************ */
|
||||
%}
|
||||
|
||||
@@ -1046,7 +1046,7 @@ Get : _Get_ GetVar ','
|
||||
|
||||
pIIF = hb_compExprNewIIF( pIfList );
|
||||
|
||||
pSetGetBlock = hb_compExprNewCodeBlock();
|
||||
pSetGetBlock = hb_compExprNewCodeBlock(NULL,0,0);
|
||||
pSetGetBlock = hb_compExprCBVarAdd( pSetGetBlock, "_1", ' ' );
|
||||
|
||||
hb_compExprAddListExpr( pSetGetBlock, pIIF );
|
||||
@@ -1142,9 +1142,9 @@ GetA : _Get_ GetVarArray { pGetArgList = hb_compExprNewArgList( $2 ); bTra
|
||||
GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GETA"), pGetArgList ); pGetArgList = NULL; }
|
||||
;
|
||||
|
||||
GetVarArray : Variable ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(), $1 ); }
|
||||
| ObjectData ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(), $1 ); }
|
||||
| AliasVar ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(), $1 ); }
|
||||
GetVarArray : Variable ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); }
|
||||
| ObjectData ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); }
|
||||
| AliasVar ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddListExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); }
|
||||
| MacroVar ArrayIndex {
|
||||
pGetVarArray = $2; $$ = hb_compExprNewNil();
|
||||
|
||||
@@ -1167,7 +1167,7 @@ GetAExt : { /* Nothing*/ }
|
||||
| ',' GetArgList
|
||||
;
|
||||
|
||||
CodeBlock : '{' '|' { s_bBlock = TRUE; $<asExpr>$ = hb_compExprNewCodeBlock() } BlockNoVar '|' BlockExpList '}'
|
||||
CodeBlock : '{' '|' { s_bBlock = TRUE; $<asExpr>$ = hb_compExprNewCodeBlock(NULL,0,0) } BlockNoVar '|' BlockExpList '}'
|
||||
{
|
||||
if( s_bBlockMacro )
|
||||
{
|
||||
@@ -1199,7 +1199,7 @@ CodeBlock : '{' '|' { s_bBlock = TRUE; $<asExpr>$ = hb_compExprNewCodeBlock() }
|
||||
s_bBlock = FALSE; s_bBlockMacro = FALSE; s_bBlockDeclared = FALSE;
|
||||
}
|
||||
|
||||
| '{' '|' { s_bBlock = TRUE; $<asExpr>$ = hb_compExprNewCodeBlock(); } BlockVarList '|' BlockExpList '}'
|
||||
| '{' '|' { s_bBlock = TRUE; $<asExpr>$ = hb_compExprNewCodeBlock(NULL,0,0); } BlockVarList '|' BlockExpList '}'
|
||||
{
|
||||
if( s_bBlockMacro )
|
||||
{
|
||||
@@ -1234,8 +1234,8 @@ CodeBlock : '{' '|' { s_bBlock = TRUE; $<asExpr>$ = hb_compExprNewCodeBlock() }
|
||||
|
||||
/* NOTE: This uses $-2 then don't use BlockExpList in other context
|
||||
*/
|
||||
BlockExpList : Expression { pBlockSimple = $1; $$ = hb_compExprAddListExpr( $<asExpr>-2, $1 ); }
|
||||
| BlockExpList ',' Expression { pBlockSimple = NULL; $$ = hb_compExprAddListExpr( $<asExpr>-2, $3 ); }
|
||||
BlockExpList : Expression { pBlockSimple = $1; $$ = hb_compExprAddCodeblockExpr( $<asExpr>-2, $1 ); }
|
||||
| BlockExpList ',' Expression { pBlockSimple = NULL; $$ = hb_compExprAddCodeblockExpr( $<asExpr>-2, $3 ); }
|
||||
;
|
||||
|
||||
/* NOTE: This is really not needed however it allows the use of $-2 item
|
||||
|
||||
@@ -157,6 +157,13 @@ static void hb_compDebugStart( void ) { };
|
||||
char * szValue;
|
||||
} valDouble;
|
||||
HB_EXPR_PTR asExpr;
|
||||
struct
|
||||
{
|
||||
char *string;
|
||||
int length;
|
||||
BOOL lateEval; /* Flag for early {|| ¯o} (0) or late {|| &(macro)} (1) binding */
|
||||
BOOL isMacro;
|
||||
} asCodeblock;
|
||||
void * pVoid; /* to hold any memory structure we may need */
|
||||
};
|
||||
|
||||
@@ -171,6 +178,7 @@ static void hb_compDebugStart( void ) { };
|
||||
%token AS_ARRAY AS_BLOCK AS_CHARACTER AS_CLASS AS_DATE AS_LOGICAL AS_NUMERIC AS_OBJECT AS_VARIANT DECLARE OPTIONAL DECLARE_CLASS DECLARE_MEMBER
|
||||
%token AS_ARRAY_ARRAY AS_BLOCK_ARRAY AS_CHARACTER_ARRAY AS_CLASS_ARRAY AS_DATE_ARRAY AS_LOGICAL_ARRAY AS_NUMERIC_ARRAY AS_OBJECT_ARRAY
|
||||
%token PROCREQ GET
|
||||
%token CBSTART
|
||||
|
||||
/*the lowest precedence*/
|
||||
/*postincrement and postdecrement*/
|
||||
@@ -239,6 +247,7 @@ static void hb_compDebugStart( void ) { };
|
||||
%type <asExpr> DimIndex DimList
|
||||
%type <asExpr> FieldAlias FieldVarAlias
|
||||
%type <asExpr> PostOp
|
||||
%type <asCodeblock> CBSTART
|
||||
|
||||
%%
|
||||
|
||||
@@ -1012,16 +1021,16 @@ ElemList : Argument { $$ = hb_compExprNewList( $1 ); }
|
||||
| ElemList ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
|
||||
CodeBlock : '{' '|' { $<asExpr>$ = hb_compExprNewCodeBlock(); } BlockNoVar
|
||||
'|' BlockExpList '}' { $$ = $<asExpr>3; }
|
||||
| '{' '|' { $<asExpr>$ = hb_compExprNewCodeBlock(); } BlockVarList
|
||||
'|' BlockExpList '}' { $$ = $<asExpr>3; }
|
||||
CodeBlock : CBSTART { $<asExpr>$ = hb_compExprNewCodeBlock($1.string,$1.isMacro,$1.lateEval); } BlockNoVar
|
||||
'|' BlockExpList '}' { $$ = $<asExpr>2; }
|
||||
| CBSTART { $<asExpr>$ = hb_compExprNewCodeBlock($1.string,$1.isMacro,$1.lateEval); } BlockVarList
|
||||
'|' BlockExpList '}' { $$ = $<asExpr>2; }
|
||||
;
|
||||
|
||||
/* NOTE: This uses $-2 then don't use BlockExpList in other context
|
||||
*/
|
||||
BlockExpList : Expression { $$ = hb_compExprAddListExpr( $<asExpr>-2, $1 ); }
|
||||
| BlockExpList ',' Expression { $$ = hb_compExprAddListExpr( $<asExpr>-2, $3 ); }
|
||||
BlockExpList : Expression { $$ = hb_compExprAddCodeblockExpr( $<asExpr>-2, $1 ); }
|
||||
| BlockExpList ',' Expression { $$ = hb_compExprAddCodeblockExpr( $<asExpr>-2, $3 ); }
|
||||
;
|
||||
|
||||
/* NOTE: This is really not needed however it allows the use of $-2 item
|
||||
|
||||
@@ -224,3 +224,12 @@ HB_EXPR_PTR hb_compWarnMeaningless( HB_EXPR_PTR pExpr )
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
void hb_compErrorCodeblock( char * szBlock )
|
||||
{
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BLOCK, szBlock, NULL );
|
||||
}
|
||||
|
||||
void hb_compErrorMacro( char *szText )
|
||||
{
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szText, NULL );
|
||||
}
|
||||
@@ -745,11 +745,11 @@ ElemList : EmptyExpression { $$ = hb_compExprNewList( $1 ); }
|
||||
;
|
||||
|
||||
CodeBlock : '{' '|'
|
||||
{ $<asExpr>$ = hb_compExprNewCodeBlock(); } BlockNoVar
|
||||
{ $<asExpr>$ = hb_compExprNewCodeBlock(NULL,FALSE,FALSE); } BlockNoVar
|
||||
'|' BlockExpList '}'
|
||||
{ $$ = $<asExpr>3; }
|
||||
| '{' '|'
|
||||
{ $<asExpr>$ = hb_compExprNewCodeBlock(); }
|
||||
{ $<asExpr>$ = hb_compExprNewCodeBlock(NULL,FALSE,FALSE); }
|
||||
BlockVarList
|
||||
'|' BlockExpList '}'
|
||||
{ $$ = $<asExpr>3; }
|
||||
@@ -757,8 +757,8 @@ CodeBlock : '{' '|'
|
||||
|
||||
/* NOTE: This uses $-2 then don't use BlockExpList in other context
|
||||
*/
|
||||
BlockExpList : Expression { $$ = hb_compExprAddListExpr( $<asExpr>-2, $1 ); }
|
||||
| BlockExpList ',' Expression { $$ = hb_compExprAddListExpr( $<asExpr>-2, $3 ); }
|
||||
BlockExpList : Expression { $$ = hb_compExprAddCodeblockExpr( $<asExpr>-2, $1 ); }
|
||||
| BlockExpList ',' Expression { $$ = hb_compExprAddCodeblockExpr( $<asExpr>-2, $3 ); }
|
||||
;
|
||||
|
||||
/* NOTE: This is really not needed however it allows the use of $-2 item
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* hbexpra.c is also included from ../compiler/expropta.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 7 - ignore this magic number - this is used to force compilation
|
||||
* 8 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
|
||||
#define HB_MACRO_SUPPORT
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* hbexprb.c is also included from ../compiler/exproptb.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 3 - ignore this magic number - this is used to force compilation
|
||||
* 4 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
|
||||
#define HB_MACRO_SUPPORT
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* hbexprc.c is also included from ../compiler/exproptc.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 1 - ignore this magic number - this is used to force compilation
|
||||
* 2 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
|
||||
#define HB_MACRO_SUPPORT
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma pack(push, 1);
|
||||
#pragma push(pack, 1);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
@@ -154,7 +154,7 @@ typedef SORTSWAPITEM * LPSORTSWAPITEM;
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma pack(pop);
|
||||
#pragma pop(pack);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user