* harbour/include/hbvm.h
* harbour/include/hbrdddbf.h
* harbour/include/hbapidbg.h
* harbour/include/hbset.h
* harbour/include/hbcomp.h
* harbour/include/hbapirdd.h
* harbour/include/hbstack.h
* harbour/include/hbsxfunc.h
* harbour/include/hbapilng.h
* harbour/include/hbgtcore.h
* harbour/include/hbapifs.h
* harbour/include/hbdbsort.h
* harbour/include/hbapigt.h
* harbour/include/hbapi.h
* harbour/include/hbapierr.h
* harbour/include/hbapiitm.h
* harbour/include/hbrddfpt.h
* harbour/contrib/hbmysql/mysql.c
* harbour/contrib/hbct/bitnum.c
* harbour/contrib/hbct/token2.c
* harbour/contrib/hbct/charsprd.c
* harbour/contrib/hbct/ctnet.c
* harbour/contrib/hbct/charonly.c
* harbour/contrib/hbct/atadjust.c
* harbour/contrib/hbct/ctwin.c
* harbour/contrib/hbct/charsort.c
* harbour/contrib/hbct/ctwin.h
* harbour/contrib/hbct/charmix.c
* harbour/contrib/hbct/charevod.c
* harbour/contrib/hbct/maxline.c
* harbour/contrib/hbct/wordrepl.c
* harbour/contrib/hbct/charrepl.c
* harbour/contrib/hbct/files.c
* harbour/contrib/hbct/video.c
* harbour/contrib/hbct/charswap.c
* harbour/contrib/hbct/dattime3.c
* harbour/contrib/hbct/charop.c
* harbour/contrib/hbct/misc2.c
* harbour/contrib/hbct/charone.c
* harbour/contrib/hbct/ctstr.c
* harbour/contrib/hbct/screen1.c
* harbour/contrib/hbct/token1.c
* harbour/contrib/hbct/ctstr.h
* harbour/contrib/hbct/charmirr.c
* harbour/contrib/hbct/relation.c
* harbour/contrib/hbct/atnum.c
* harbour/contrib/hbct/like.c
* harbour/contrib/hbct/count.c
* harbour/contrib/hbct/disk.c
* harbour/contrib/hbct/ctstrfil.c
* harbour/contrib/hbct/posdiff.c
* harbour/contrib/hbct/addascii.c
* harbour/contrib/hbct/tab.c
* harbour/contrib/hbct/numline.c
* harbour/contrib/hbct/dattime2.c
* harbour/contrib/hbct/asciisum.c
* harbour/contrib/hbct/expand.c
* harbour/contrib/hbct/pos2.c
* harbour/contrib/hbct/numat.c
* harbour/contrib/hbct/atrepl.c
* harbour/contrib/hbct/wordtoch.c
* harbour/contrib/hbct/print.c
* harbour/contrib/hbct/justify.c
* harbour/contrib/xhb/hbxml.c
* harbour/contrib/xhb/dbf2txt.c
* harbour/contrib/xhb/xhbis.c
* harbour/contrib/xhb/fparse.c
* harbour/contrib/xhb/xstrdel.c
* harbour/contrib/xhb/hbcomprs.c
* harbour/contrib/xhb/datesxhb.c
* harbour/contrib/xhb/xhbmsgs.c
* harbour/contrib/xhb/freadlin.c
* harbour/contrib/xhb/txtline.c
* harbour/contrib/xhb/xhbtrim.c
* harbour/contrib/xhb/xhbcopyf.c
* harbour/contrib/xhb/cstructc.c
* harbour/contrib/xhb/xhbfunc.c
* harbour/contrib/hbtpathy/tplinux.c
* harbour/contrib/hbgt/charmixg.c
* harbour/contrib/hbgt/strexpan.c
* harbour/contrib/hbgt/charodd.c
* harbour/contrib/hbgt/strright.c
* harbour/contrib/hbgt/asciisgt.c
* harbour/contrib/hbgt/strdiffg.c
* harbour/contrib/hbgt/chrtotal.c
* harbour/contrib/hbgt/strcount.c
* harbour/contrib/hbgt/strleft.c
* harbour/contrib/hbgt/ascposgt.c
* harbour/contrib/hbgt/chrfirst.c
* harbour/contrib/hbgt/chrcount.c
* harbour/contrib/hbgt/strpbrk.c
* harbour/contrib/hbgt/chareven.c
* harbour/contrib/hbgt/strcspn.c
* harbour/contrib/hbgt/atdiff.c
* harbour/contrib/hbsqlit3/hbsqlit3.c
* harbour/contrib/hbmzip/hbmzip.c
* harbour/contrib/hbnf/proper.c
* harbour/contrib/hbnf/fttext.c
* harbour/contrib/hbnf/chdir.c
* harbour/contrib/hbnf/getver.c
* harbour/contrib/hbnf/ftattr.c
* harbour/contrib/hbnf/mkdir.c
* harbour/contrib/hbnf/rmdir.c
* harbour/contrib/Makefile
* harbour/contrib/hbcurl/hbcurl.c
* harbour/contrib/rddsql/sddmy/mysqldd.c
* harbour/contrib/rddsql/sddpg/pgsqldd.c
* harbour/contrib/rddsql/sddfb/fbirddd.c
* harbour/contrib/rddsql/sddodbc/odbcdd.c
* harbour/contrib/rddsql/sqlmix.c
* harbour/contrib/hbhpdf/harupdf.c
* harbour/contrib/rddads/adsx.c
* harbour/contrib/rddads/adsfunc.c
* harbour/contrib/rddads/rddads.h
* harbour/contrib/rddads/ads1.c
* harbour/contrib/hbmisc/hb_f.c
* harbour/contrib/hbmisc/strfmt.c
* harbour/contrib/hbmisc/stringsx.c
* harbour/contrib/hbmisc/spd.c
* harbour/contrib/hbtip/utils.c
* harbour/contrib/hbwin/wapi_winbase.c
* harbour/contrib/hbwin/win_misc.c
* harbour/contrib/hbbtree/hb_btree.h
* harbour/contrib/hbbtree/hb_btree.c
* harbour/source/pp/hbpp.c
* harbour/source/vm/runner.c
* harbour/source/vm/estack.c
* harbour/source/vm/itemapi.c
* harbour/source/vm/hvm.c
* harbour/source/vm/cmdarg.c
* harbour/source/vm/memvars.c
* harbour/source/vm/dynlibhb.c
* harbour/source/vm/set.c
* harbour/source/main/harbour.c
* harbour/source/debug/dbgentry.c
* harbour/source/common/hbfsapi.c
* harbour/source/common/hbfopen.c
* harbour/source/rtl/gtdos/gtdos.c
* harbour/source/rtl/diskspac.c
* harbour/source/rtl/console.c
* harbour/source/rtl/chrasc.c
* harbour/source/rtl/fscopy.c
* harbour/source/rtl/run.c
* harbour/source/rtl/spfiles.c
* harbour/source/rtl/defpath.c
* harbour/source/rtl/philes.c
* harbour/source/rtl/oldbox.c
* harbour/source/rtl/math.c
* harbour/source/rtl/hbgtcore.c
* harbour/source/rtl/cdpapi.c
* harbour/source/rtl/gtcrs/gtcrs.c
* harbour/source/rtl/dirdrive.c
* harbour/source/rtl/hbi18n1.c
* harbour/source/rtl/trim.c
* harbour/source/rtl/hbzlibgz.c
* harbour/source/rtl/philesx.c
* harbour/source/rtl/mlcfunc.c
* harbour/source/rtl/filehb.c
* harbour/source/rtl/fstemp.c
* harbour/source/rtl/is.c
* harbour/source/rtl/hbrunfun.c
* harbour/source/rtl/ampm.c
* harbour/source/rtl/setcolor.c
* harbour/source/rtl/oemansi.c
* harbour/source/rtl/disksphb.c
* harbour/source/rtl/hbzlib.c
* harbour/source/rtl/strpeek.c
* harbour/source/rtl/replic.c
* harbour/source/rtl/stuff.c
* harbour/source/rtl/hbstrfmt.c
* harbour/source/rtl/transfrm.c
* harbour/source/rtl/hbhex.c
* harbour/source/rtl/trace.c
* harbour/source/rtl/hbadler.c
* harbour/source/rtl/samples.c
* harbour/source/rtl/filebuf.c
* harbour/source/rtl/hbcrc.c
* harbour/source/rtl/gete.c
* harbour/source/rtl/hbmd5.c
* harbour/source/rtl/langapi.c
* harbour/source/rtl/gtcgi/gtcgi.c
* harbour/source/rtl/errapi.c
* harbour/source/rtl/hbregexc.c
* harbour/source/rtl/natmsg.c
* harbour/source/rtl/fssize.c
* harbour/source/rtl/hbinet.c
* harbour/source/rtl/colorind.c
* harbour/source/rtl/copyfile.c
* harbour/source/rtl/mouseapi.c
* harbour/source/rtl/soundex.c
* harbour/source/rtl/memofile.c
* harbour/source/rtl/hbffind.c
* harbour/source/rtl/gtapi.c
* harbour/source/rtl/direct.c
* harbour/source/rtl/filesys.c
* harbour/source/rtl/file.c
* harbour/source/rtl/val.c
* harbour/source/rtl/hbregex.c
* harbour/source/rtl/rat.c
* harbour/source/rtl/isprint.c
* harbour/source/rdd/dbfntx/dbfntx1.c
* harbour/source/rdd/dbsql.c
* harbour/source/rdd/workarea.c
* harbour/source/rdd/wacore.c
* harbour/source/rdd/sdf1.c
* harbour/source/rdd/dbdetach.c
* harbour/source/rdd/dbcmdx.c
* harbour/source/rdd/dbfnsx/dbfnsx1.c
* harbour/source/rdd/dbcmd.c
* harbour/source/rdd/dbfcdx/dbfcdx1.c
* harbour/source/rdd/delim1.c
* harbour/source/rdd/dbf1.c
* harbour/source/rdd/hsx/hsx.c
* harbour/source/rdd/dbcmd53.c
* harbour/source/rdd/usrrdd/usrrdd.c
* harbour/source/rdd/wafunc.c
* harbour/source/rdd/dbffpt/dbffpt1.c
* harbour/source/rdd/hbsix/sxsem.c
* harbour/source/rdd/hbsix/sxord.c
* harbour/source/rdd/hbsix/sxfname.c
* harbour/source/rdd/hbsix/sxtable.c
* harbour/source/rdd/hbsix/sxdate.c
* harbour/source/rdd/hbsix/sxutil.c
* harbour/source/rdd/hbsix/sxcompr.c
* harbour/source/compiler/hbmain.c
* harbour/source/compiler/cmdcheck.c
* harbour/source/compiler/hbpcode.c
* harbour/source/compiler/genc.c
* harbour/source/compiler/gencc.c
* harbour/source/compiler/hbcmplib.c
* harbour/source/compiler/ppcomp.c
* changed 'char *' and changed 'BYTE *' to 'const char *' in
the following functions:
const char * hb_vmFindModuleSymbolName( PHB_SYMB pSym );
void hb_vmInitSymbolGroup( void * hNewDynLib, int argc,
const char * argv[] );
void hb_dbgEntry( int nMode, int nLine, const char *szName,
int nIndex, PHB_ITEM pFrame );
void hb_dbgAddBreak( void *handle, const char *cModule,
int nLine, const char *szFunction );
void hb_dbgAddWatch( void *handle, const char *szExpr, BOOL bTrace );
PHB_ITEM hb_dbgGetExpressionValue( void *handle,
const char *expression );
BOOL hb_dbgIsValidStopLine( void *handle, const char *szModule,
int nLine );
void hb_dbgSetToCursor( void *handle, const char *szModule,
int nLine );
void hb_dbgSetWatch( void *handle, int nWatch,
const char *szExpr, BOOL bTrace );
const char * hb_setGetCPtr( HB_set_enum set_specifier );
const char * hb_setGetAltFile( void );
const char * hb_setGetDateFormat( void );
const char * hb_setGetTimeFormat( void );
const char * hb_setGetDefault( void );
const char * hb_setGetDelimChars( void );
const char * hb_setGetDevice( void );
const char * hb_setGetExtraFile( void );
const char * hb_setGetPath( void );
const char * hb_setGetMFileExt( void );
const char * hb_setGetPrintFile( void );
const char * hb_setGetEOL( void );
const char * hb_setGetHBOUTLOG( void );
const char * hb_setGetHBOUTLOGINFO( void );
const char * hb_setGetOSCODEPAGE( void );
void hb_compInitPP( HB_COMP_DECL, int argc,
const char * const argv[] );
void hb_compGenPCodeN( const BYTE * pBuffer, ULONG ulSize,
HB_COMP_DECL );
int hb_compMain( int argc, const char * const argv[],
BYTE ** pBufPtr, ULONG * pulSize,
const char * szSource );
void hb_compChkCompilerSwitch( HB_COMP_DECL, int,
const char * const args[] );
void hb_compChkDefines( HB_COMP_DECL, int iArg,
const char * const args[] );
void hb_compGenCString( FILE * yyc, const BYTE * pText, ULONG ulLen );
AREAP hb_rddRequestArea( const char * szAlias, PHB_ITEM pCargo,
BOOL fNewArea, BOOL fWait );
char * hb_stackDirBuffer( void );
LONG hb_sxPtoD( const char * pDate );
const char * hb_langID( void );
const char * hb_langSelectID( const char * pszID );
const char * hb_langDGetItem( int iIndex );
const char * hb_langDGetErrorDesc( ULONG ulIndex );
BOOL hb_fsChDir( const char * pszDirName );
HB_FHANDLE hb_fsCreate( const char * pszFileName, ULONG ulAttr );
HB_FHANDLE hb_fsCreateEx( const char * pszFilename, ULONG ulAttr,
USHORT uiFlags );
HB_FHANDLE hb_fsCreateTemp( const char * pszDir,
const char * pszPrefix,
ULONG ulAttr, char * pszName );
HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir,
const char * pszPrefix,
const char * pszExt, ULONG ulAttr );
const char * hb_fsCurDir( USHORT uiDrive );
USHORT hb_fsCurDirBuff( USHORT uiDrive, char * pbyBuffer,
ULONG ulLen );
void hb_fsBaseDirBuff( char * pbyBuffer );
BOOL hb_fsDelete( const char * pszFileName );
BOOL hb_fsFile( const char * pszFileName );
BOOL hb_fsIsDirectory( const char * pszFilename );
HB_FOFFSET hb_fsFSize( const char * pszFileName, BOOL bUseDirEntry );
HB_FHANDLE hb_fsExtOpen( const char * pszFileName,
const char * pDefExt,
char * hb_fsExtName( const char * pFilename,
const char * pDefExt, USHORT uiExFlags,
const char * pPaths );
BOOL hb_fsMkDir( const char * pszDirName );
HB_FHANDLE hb_fsOpen( const char * pszFileName, USHORT uiFlags );
BOOL hb_fsRmDir( const char * pszDirName );
BOOL hb_fsRename( const char * pszOldName,
const char * pszNewName );
BOOL hb_fsGetFileTime( const char * pszFileName,
LONG * plJulian, LONG * plMillisec );
BOOL hb_fsSetFileTime( const char * pszFileName,
LONG lJulian, LONG lMillisec );
BOOL hb_fsGetAttr( const char * pszFileName, ULONG * pulAttr );
BOOL hb_fsSetAttr( const char * pszFileName, ULONG ulAttr );
HB_FHANDLE hb_fsPOpen( const char * pFilename, const char * pMode );
BOOL hb_fsCopy( const char * pSource, const char * pDest );
BOOL hb_spFile( const char * pFilename, char * pRetPath );
BOOL hb_spFileExists( const char * pFilename, char * pRetPath );
HB_FHANDLE hb_spOpen( const char * pFilename, USHORT uiFlags );
HB_FHANDLE hb_spCreate( const char * pFilename, ULONG ulAttr );
HB_FHANDLE hb_spCreateEx( const char * pFilename,
ULONG ulAttr, USHORT uiFlags );
PHB_FILE hb_fileExtOpen( const char * pFilename,
const char * pDefExt, USHORT uiExFlags,
const char * pPaths, PHB_ITEM pError );
PHB_FILE hb_fileCreateTemp( const char * pszDir,
const char * pszPrefix,
ULONG ulAttr, char * pszName );
PHB_FILE hb_fileCreateTempEx( char * pszName, const char * pszDir,
const char * pszPrefix,
const char * pszExt, ULONG ulAttr );
HB_ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom,
SHORT uiRight, const BYTE * pbyFrame );
HB_ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom,
SHORT uiRight, const BYTE * pbyFrame,
int iColor );
HB_ERRCODE hb_gtWrite( const BYTE * pbyStr, ULONG ulLen );
HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol,
const BYTE * pbyStr, ULONG ulLen );
HB_ERRCODE hb_gtWriteCon( const BYTE * pbyStr, ULONG ulLen );
HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol,
const BYTE * pStr, ULONG ulLength,
int iColor );
HB_ERRCODE hb_gtOutStd( const BYTE * pbyStr, ULONG ulLen );
HB_ERRCODE hb_gtOutErr( const BYTE * pbyStr, ULONG ulLen );
HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight,
const BYTE * pbyFrame, int iColor );
void hb_mouseRestoreState( const BYTE * pBuffer );
const char * hb_strLTrim( const char * szText, ULONG * ulLen );
const char * hb_conNewLine( void );
const char * hb_conSetColor( const char * szColor );
const char * hb_errGetDescription( PHB_ITEM pError );
const char * hb_errGetFileName( PHB_ITEM pError );
const char * hb_errGetOperation( PHB_ITEM pError );
const char * hb_errGetSubSystem( PHB_ITEM pError );
int hb_ctwAddWindowBox( int iWindow, const BYTE * szBox, int iColor );
const char *ct_at_exact_forward
( const char *pcString, size_t sStrLen,
const char *pcMatch, size_t sMatchLen,
size_t *psMatchStrLen );
const char *ct_at_exact_backward
( const char *pcString, size_t sStrLen,
const char *pcMatch, size_t sMatchLen,
size_t *psMatchStrLen );
const char *ct_at_wildcard_forward
( const char *pcString, size_t sStrLen,
const char *pcMatch, size_t sMatchLen,
char cWildCard, size_t *psMatchStrLen );
const char *ct_at_wildcard_backward
( const char *pcString, size_t sStrLen,
const char *pcMatch, size_t sMatchLen,
char cWildCard, size_t *psMatchStrLen );
const char *ct_at_charset_forward
( const char *pcString, size_t sStrLen,
const char *pcCharSet, size_t sCharSetLen,
size_t *psMatchedCharPos );
const char *ct_at_charset_backward
( const char *pcString, size_t sStrLen,
const char *pcCharSet, size_t sCharSetLen,
size_t *psMatchedCharPos );
char * hb_adsOemToAnsi( const char * pcString, ULONG ulLen );
char * hb_adsAnsiToOem( const char * pcString, ULONG ulLen );
struct hb_BTree * hb_BTreeNew( const char *FileName,
USHORT usPageSize, USHORT usKeySize,
ULONG ulFlags, USHORT usBuffers );
struct hb_BTree * hb_BTreeOpen( const char *FileName, ULONG lFlags,
USHORT usBuffers );
BOOL hb_BTreeInsert( struct hb_BTree * pBTree, const char * szKey,
PHB_ITEM pData );
BOOL hb_BTreeDelete( struct hb_BTree * pBTree, const char * szKey,
LONG lData );
BOOL hb_BTreeSeek( struct hb_BTree * pBTree, const char * szKey,
LONG lData, BOOL bSoftSeek );
const char * hb_BTreeKey( struct hb_BTree * pBTree );
* modified RDD methods:
HB_ERRCODE PUTVALUEFILE( AREAP, USHORT, const char *, USHORT );
HB_ERRCODE GETVALUEFILE( AREAP, USHORT, const char *, USHORT );
* modified GT methods:
void REST( HB_GT_PTR, int, int, int, int, const BYTE * );
void PUTTEXT( HB_GT_PTR, int, int, BYTE, const BYTE *, ULONG );
void WRITEAT( HB_GT_PTR, int, int, const BYTE *, ULONG );
void WRITE( HB_GT_PTR, const BYTE *, ULONG );
void WRITECON( HB_GT_PTR, const BYTE *, ULONG );
void BOX( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE );
void BOXD( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE );
void BOXS( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE );
void OUTSTD( HB_GT_PTR, BYTE *, ULONG );
void OUTERR( HB_GT_PTR, BYTE *, ULONG );
void MOUSERESTORESTATE( HB_GT_PTR, const BYTE * );
* modified RDD structers:
DBFIELDINFO, DBOPENINFO, DBORDERCONDINFO, DBCONSTRAINTINFO,
DBORDERCREATEINFO
+ modified parameters and behevior:
const char * hb_fsNameConv( const char * szFileName, char ** pszFree );
const char * hb_osEncode( const char * szFileName, char ** pszFree );
const char * hb_osDecode( const char * szFileName, char ** pszFree );
Please look at implementation and current usage of these functions.
+ added new function:
BOOL hb_itemGetWriteCL( PHB_ITEM pItem,
char ** pszValue, ULONG * pulLen );
which converts item string buffer to writable state to use with
functions like FREAD() instead of hb_itemUnShare*()
* updatd other code to respect above modifications
! fixed bugs (also GPF traps) located by above modifications
TODO: please make build tests. Especially in OS2 - not tested at all.
2298 lines
55 KiB
C
2298 lines
55 KiB
C
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* Harbour Project source code:
|
|
* Compiler C source with real code generation
|
|
*
|
|
* Copyright 2006-2009 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
|
|
* www - http://www.harbour-project.org
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this software; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
|
*
|
|
* As a special exception, the Harbour Project gives permission for
|
|
* additional uses of the text contained in its release of Harbour.
|
|
*
|
|
* The exception is that, if you link the Harbour libraries with other
|
|
* files to produce an executable, this does not by itself cause the
|
|
* resulting executable to be covered by the GNU General Public License.
|
|
* Your use of that executable is in no way restricted on account of
|
|
* linking the Harbour library code into it.
|
|
*
|
|
* This exception does not however invalidate any other reasons why
|
|
* the executable file might be covered by the GNU General Public License.
|
|
*
|
|
* This exception applies only to the code released by the Harbour
|
|
* Project under the name Harbour. If you copy code from other
|
|
* Harbour Project or Free Software Foundation releases into a copy of
|
|
* Harbour, as the General Public License permits, the exception does
|
|
* not apply to the code that you add in this way. To avoid misleading
|
|
* anyone as to the status of such modified files, you must delete
|
|
* this exception notice from them.
|
|
*
|
|
* If you write modifications of your own for Harbour, it is your choice
|
|
* whether to permit this exception to apply to your modifications.
|
|
* If you do not wish that, delete this exception notice.
|
|
*
|
|
*/
|
|
|
|
#include "hbcomp.h"
|
|
#include "hbdate.h"
|
|
#include "hbassert.h"
|
|
|
|
#define HB_GENC_FUNC( func ) HB_PCODE_FUNC( func, PHB_LABEL_INFO )
|
|
typedef HB_GENC_FUNC( HB_GENC_FUNC_ );
|
|
typedef HB_GENC_FUNC_ * HB_GENC_FUNC_PTR;
|
|
|
|
#define HB_GENC_GETLABEL(l) ( (l) < pFunc->lPCodePos ? cargo->pulLabels[ (l) ] : 0 )
|
|
|
|
#define HB_GENC_LABEL() do { \
|
|
ULONG ulLab = HB_GENC_GETLABEL( lPCodePos ); \
|
|
if( ulLab != 0 ) \
|
|
fprintf( cargo->yyc, "lab%05ld: ;\n", ulLab ); \
|
|
} while( 0 )
|
|
|
|
#define HB_GENC_ERROR(s) do { \
|
|
fprintf( cargo->yyc, "\t#error: \"" s "\"\n" ); \
|
|
} while( 0 )
|
|
|
|
void hb_compGenCString( FILE * yyc, const BYTE * pText, ULONG ulLen )
|
|
{
|
|
ULONG ulPos;
|
|
|
|
fputc( '"', yyc );
|
|
for( ulPos = 0; ulPos < ulLen; ulPos++ )
|
|
{
|
|
BYTE uchr = ( BYTE ) pText[ ulPos ];
|
|
/*
|
|
* NOTE: After optimization some CHR(n) can be converted
|
|
* into a string containing nonprintable characters.
|
|
*
|
|
* ? is escaped to avoid conflicts with trigraph sequences which
|
|
* are part of ANSI C standard
|
|
*/
|
|
if( uchr == '"' || uchr == '\\' || uchr == '?' )
|
|
fprintf( yyc, "\\%c", uchr );
|
|
else if( uchr < ( BYTE ) ' ' || uchr >= 127 )
|
|
{
|
|
BYTE uchrnext = ulPos < ulLen - 1 ? pText[ ulPos + 1 ] : 0;
|
|
|
|
fprintf( yyc, "\\x%02X%s", uchr,
|
|
( uchrnext >= ( BYTE ) '0' && uchrnext <= ( BYTE ) '9' ) ||
|
|
( uchrnext >= ( BYTE ) 'a' && uchrnext <= ( BYTE ) 'z' ) ||
|
|
( uchrnext >= ( BYTE ) 'A' && uchrnext <= ( BYTE ) 'Z' ) ? "\" \"" : "" );
|
|
}
|
|
else
|
|
fprintf( yyc, "%c", uchr );
|
|
}
|
|
fputc( '"', yyc );
|
|
}
|
|
|
|
static void hb_gencc_copyLocals( FILE * yyc, int iLocal1, int iLocal2 )
|
|
{
|
|
if( iLocal1 != iLocal2 )
|
|
fprintf( yyc, "\thb_xvmCopyLocals( %d, %d );\n", iLocal1, iLocal2 );
|
|
}
|
|
|
|
static int hb_gencc_checkJumpCondAhead( LONG lValue, PFUNCTION pFunc, ULONG lPCodePos, PHB_LABEL_INFO cargo,
|
|
const char * szFunc )
|
|
{
|
|
if( HB_GENC_GETLABEL( lPCodePos + 1 ) == 0 )
|
|
{
|
|
LONG lOffset = 0;
|
|
BOOL fNot = FALSE;
|
|
int iSize = 0;
|
|
|
|
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
|
{
|
|
case HB_P_JUMPFALSENEAR:
|
|
lOffset = ( signed char ) ( pFunc->pCode[ lPCodePos + 2 ] );
|
|
fNot = TRUE;
|
|
iSize = 3;
|
|
break;
|
|
|
|
case HB_P_JUMPFALSE:
|
|
lOffset = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 2 ] );
|
|
fNot = TRUE;
|
|
iSize = 4;
|
|
break;
|
|
|
|
case HB_P_JUMPFALSEFAR:
|
|
lOffset = HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 2 ] );
|
|
fNot = TRUE;
|
|
iSize = 5;
|
|
break;
|
|
|
|
case HB_P_JUMPTRUENEAR:
|
|
lOffset = ( signed char ) ( pFunc->pCode[ lPCodePos + 2 ] );
|
|
iSize = 3;
|
|
break;
|
|
|
|
case HB_P_JUMPTRUE:
|
|
lOffset = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 2 ] );
|
|
iSize = 4;
|
|
break;
|
|
|
|
case HB_P_JUMPTRUEFAR:
|
|
lOffset = HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 2 ] );
|
|
iSize = 5;
|
|
break;
|
|
}
|
|
|
|
if( iSize )
|
|
{
|
|
fprintf( cargo->yyc, "\tif( hb_xvm%sIntIs( %ld, &fValue ) ) break;\n",
|
|
szFunc, lValue );
|
|
fprintf( cargo->yyc, "\tif( %sfValue )\n\t\tgoto lab%05ld;\n",
|
|
fNot ? "!" : "", HB_GENC_GETLABEL( lPCodePos + 1 + lOffset ) );
|
|
return iSize;
|
|
}
|
|
}
|
|
fprintf( cargo->yyc, "\tif( hb_xvm%sInt( %ld ) ) break;\n",
|
|
szFunc, lValue );
|
|
return 1;
|
|
}
|
|
|
|
static int hb_gencc_checkNumAhead( LONG lValue, PFUNCTION pFunc, ULONG lPCodePos, PHB_LABEL_INFO cargo )
|
|
{
|
|
if( HB_GENC_GETLABEL( lPCodePos ) == 0 )
|
|
{
|
|
switch( pFunc->pCode[ lPCodePos ] )
|
|
{
|
|
case HB_P_POPLOCAL:
|
|
fprintf( cargo->yyc, "\thb_xvmLocalSetInt( %d, %ld );\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
lValue );
|
|
return 3;
|
|
|
|
case HB_P_POPLOCALNEAR:
|
|
fprintf( cargo->yyc, "\thb_xvmLocalSetInt( %d, %ld );\n",
|
|
( signed char ) pFunc->pCode[ lPCodePos + 1 ], lValue );
|
|
return 2;
|
|
|
|
case HB_P_EQUAL:
|
|
case HB_P_EXACTLYEQUAL:
|
|
return hb_gencc_checkJumpCondAhead( lValue, pFunc, lPCodePos, cargo, "Equal" );
|
|
|
|
case HB_P_NOTEQUAL:
|
|
return hb_gencc_checkJumpCondAhead( lValue, pFunc, lPCodePos, cargo, "NotEqual" );
|
|
|
|
case HB_P_GREATER:
|
|
return hb_gencc_checkJumpCondAhead( lValue, pFunc, lPCodePos, cargo, "GreaterThen" );
|
|
|
|
case HB_P_GREATEREQUAL:
|
|
return hb_gencc_checkJumpCondAhead( lValue, pFunc, lPCodePos, cargo, "GreaterEqualThen" );
|
|
|
|
case HB_P_LESS:
|
|
return hb_gencc_checkJumpCondAhead( lValue, pFunc, lPCodePos, cargo, "LessThen" );
|
|
|
|
case HB_P_LESSEQUAL:
|
|
return hb_gencc_checkJumpCondAhead( lValue, pFunc, lPCodePos, cargo, "LessEqualThen" );
|
|
|
|
case HB_P_ARRAYPUSH:
|
|
if( lValue > 0 )
|
|
{
|
|
fprintf( cargo->yyc, "\tif( hb_xvmArrayItemPush( %ld ) ) break;\n", lValue );
|
|
return 1;
|
|
}
|
|
break;
|
|
|
|
case HB_P_ARRAYPOP:
|
|
if( lValue > 0 )
|
|
{
|
|
fprintf( cargo->yyc, "\tif( hb_xvmArrayItemPop( %ld ) ) break;\n", lValue );
|
|
return 1;
|
|
}
|
|
break;
|
|
|
|
case HB_P_MULT:
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMultByInt( %ld ) ) break;\n", lValue );
|
|
return 1;
|
|
|
|
case HB_P_DIVIDE:
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDivideByInt( %ld ) ) break;\n", lValue );
|
|
return 1;
|
|
|
|
case HB_P_MINUS:
|
|
if( lValue > 0 )
|
|
{
|
|
fprintf( cargo->yyc, "\tif( hb_xvmAddInt( -%ld ) ) break;\n", lValue );
|
|
return 1;
|
|
}
|
|
lValue = -lValue;
|
|
/* no break */
|
|
|
|
case HB_P_PLUS:
|
|
fprintf( cargo->yyc, "\tif( hb_xvmAddInt( %ld ) ) break;\n", lValue );
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int hb_gencc_checkPlusAhead( PFUNCTION pFunc, ULONG lPCodePos, PHB_LABEL_INFO cargo )
|
|
{
|
|
if( HB_GENC_GETLABEL( lPCodePos ) == 0 )
|
|
{
|
|
switch( pFunc->pCode[ lPCodePos ] )
|
|
{
|
|
case HB_P_POPLOCALNEAR:
|
|
fprintf( cargo->yyc, "\thb_xvmLocalAdd( %d );\n",
|
|
( signed char ) pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
|
|
case HB_P_POPLOCAL:
|
|
fprintf( cargo->yyc, "\thb_xvmLocalAdd( %d );\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
|
|
case HB_P_POPSTATIC:
|
|
fprintf( cargo->yyc, "\thb_xvmStaticAdd( %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
|
|
case HB_P_POPMEMVAR:
|
|
fprintf( cargo->yyc, "\thb_xvmMemvarAdd( symbols + %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_and )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmAnd() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_arraypush )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmArrayPush() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_arraypushref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmArrayPushRef() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_arraypop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmArrayPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_dec )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDec() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_arraydim )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmArrayDim( %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_divide )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDivide() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_do )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDo( %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_doshort )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDo( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_duplicate )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmDuplicate();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_duplunref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmDuplUnRef();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushunref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushUnRef();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_swap )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmSwap(%d);\n", pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_equal )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmEqual() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_exactlyequal )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmExactlyEqual() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_endblock )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
HB_GENC_ERROR( "HB_P_ENDBLOCK" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_endproc )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\t/* *** END PROC *** */\n" );
|
|
if( lPCodePos < pFunc->lPCodePos - 1 )
|
|
{
|
|
if( cargo->iNestedBlock )
|
|
{
|
|
cargo->fEndRequest = TRUE;
|
|
fprintf( cargo->yyc, "\thb_xvmEndProc();\n" );
|
|
}
|
|
fprintf( cargo->yyc, "\tbreak;\n" );
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_false )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushLogical( FALSE );\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_fortest )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmForTest() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_frame )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmFrame( %hu, %hu );\n",
|
|
pFunc->pCode[ lPCodePos + 1 ], pFunc->pCode[ lPCodePos + 2 ] );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_funcptr )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmFuncPtr();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_function )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmFunction( %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_functionshort )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmFunction( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_arraygen )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmArrayGen( %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_hashgen )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmHashGen( %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_greater )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmGreater() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_greaterequal )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmGreaterEqual() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_inc )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmInc() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_instring )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmInstring() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumpnear )
|
|
{
|
|
LONG lOffset = ( signed char ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jump )
|
|
{
|
|
LONG lOffset = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumpfar )
|
|
{
|
|
LONG lOffset = HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumpfalsenear )
|
|
{
|
|
LONG lOffset = ( signed char ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopLogical( &fValue ) ) break;\n\tif( !fValue )\n\t\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumpfalse )
|
|
{
|
|
LONG lOffset = HB_PCODE_MKSHORT( &( pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopLogical( &fValue ) ) break;\n\tif( !fValue )\n\t\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumpfalsefar )
|
|
{
|
|
LONG lOffset = HB_PCODE_MKINT24( &( pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopLogical( &fValue ) ) break;\n\tif( !fValue )\n\t\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumptruenear )
|
|
{
|
|
LONG lOffset = ( signed char ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopLogical( &fValue ) ) break;\n\tif( fValue )\n\t\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumptrue )
|
|
{
|
|
LONG lOffset = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopLogical( &fValue ) ) break;\n\tif( fValue )\n\t\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_jumptruefar )
|
|
{
|
|
LONG lOffset = HB_PCODE_MKINT24( &( pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopLogical( &fValue ) ) break;\n\tif( fValue )\n\t\tgoto lab%05ld;\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_less )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLess() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_lessequal )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLessEqual() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_line )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmSetLine( %d );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_localname )
|
|
{
|
|
USHORT usLen;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
usLen = strlen( ( char * ) &pFunc->pCode[ lPCodePos + 3 ] );
|
|
fprintf( cargo->yyc, "\thb_xvmLocalName( %hu, ",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 3 ], usLen );
|
|
fprintf( cargo->yyc, " );\n" );
|
|
return usLen + 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPop( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropopaliased )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPopAliased( %d ) ) break;\n", pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropush )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPush( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropushref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPushRef() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macrodo )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroDo( %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macrofunc )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroFunc( %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macrosend )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroSend( %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macroarraygen )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroArrayGen( %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropushlist )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPushList( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropushindex )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPushIndex() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropushpare )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPushPare( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macropushaliased )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroPushAliased( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macrosymbol )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroSymbol() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_macrotext )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMacroText() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_message )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushSymbol( symbols + %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_minus )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMinus() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_modulename )
|
|
{
|
|
USHORT usLen;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
usLen = strlen( ( char * ) &pFunc->pCode[ lPCodePos + 1 ] );
|
|
fprintf( cargo->yyc, "\thb_xvmModuleName( " );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 1 ], usLen );
|
|
fprintf( cargo->yyc, " );\n" );
|
|
return usLen + 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_modulus )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmModulus() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_mult )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMult() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_negate )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmNegate() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_not )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmNot() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_notequal )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmNotEqual() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_or )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmOr() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_parameter )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmParameter( symbols + %hu, %d );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
pFunc->pCode[ lPCodePos + 3 ] );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_plus )
|
|
{
|
|
int iSkip;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
iSkip = hb_gencc_checkPlusAhead( pFunc, lPCodePos + 1, cargo );
|
|
|
|
if( iSkip != 0 )
|
|
return 1 + iSkip;
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPlus() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_stackPop();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popalias )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopAlias() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popaliasedfield )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopAliasedField( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popaliasedfieldnear )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopAliasedField( symbols + %hu ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popaliasedvar )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopAliasedVar( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popfield )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopField( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_poplocal )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPopLocal( %hd );\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_poplocalnear )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPopLocal( %d );\n",
|
|
( signed char ) pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popmemvar )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopMemvar( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popstatic )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPopStatic( %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_popvariable )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPopVariable( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_power )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPower() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushalias )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushAlias() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushaliasedfield )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushAliasedField( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushaliasedfieldnear )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushAliasedField( symbols + %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushaliasedvar )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushAliasedVar( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushblockshort )
|
|
{
|
|
USHORT usSize, us;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
usSize = pFunc->pCode[ lPCodePos + 1 ] - 2;
|
|
lPCodePos += 2;
|
|
|
|
fprintf( cargo->yyc, "\t{\n\t\tstatic const BYTE codeblock[ %hd ] = {", usSize );
|
|
|
|
for( us = 0; us < usSize; ++us )
|
|
{
|
|
if( ( us & 0x0f ) == 0 )
|
|
fprintf( cargo->yyc, "\n\t\t\t" );
|
|
if( us == usSize - 1 )
|
|
fprintf( cargo->yyc, "%d", pFunc->pCode[ lPCodePos + us ] );
|
|
else
|
|
fprintf( cargo->yyc, "%d, ", pFunc->pCode[ lPCodePos + us ] );
|
|
}
|
|
fprintf( cargo->yyc, " };\n\t\thb_xvmPushBlockShort( codeblock, symbols );\n\t}\n" );
|
|
|
|
return 2 + usSize;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushblock )
|
|
{
|
|
USHORT usSize, us;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
usSize = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) - 3;
|
|
lPCodePos += 3;
|
|
|
|
fprintf( cargo->yyc, "\t{\n\t\tstatic const BYTE codeblock[ %hd ] = {", usSize );
|
|
|
|
for( us = 0; us < usSize; ++us )
|
|
{
|
|
if( ( us & 0x0f ) == 0 )
|
|
fprintf( cargo->yyc, "\n\t\t\t" );
|
|
if( us == usSize - 1 )
|
|
fprintf( cargo->yyc, "%d", pFunc->pCode[ lPCodePos + us ] );
|
|
else
|
|
fprintf( cargo->yyc, "%d, ", pFunc->pCode[ lPCodePos + us ] );
|
|
}
|
|
fprintf( cargo->yyc, " };\n\t\thb_xvmPushBlock( codeblock, symbols );\n\t}\n" );
|
|
|
|
return 3 + usSize;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushblocklarge )
|
|
{
|
|
ULONG ulSize, ul;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
ulSize = HB_PCODE_MKUINT24( &pFunc->pCode[ lPCodePos + 1 ] ) - 4;
|
|
lPCodePos += 4;
|
|
|
|
fprintf( cargo->yyc, "\t{\n\t\tstatic const BYTE codeblock[ %lu ] = {", ulSize );
|
|
|
|
for( ul = 0; ul < ulSize; ++ul )
|
|
{
|
|
if( ( ul & 0x0f ) == 0 )
|
|
fprintf( cargo->yyc, "\n\t\t\t" );
|
|
if( ul == ulSize - 1 )
|
|
fprintf( cargo->yyc, "%d", pFunc->pCode[ lPCodePos + ul ] );
|
|
else
|
|
fprintf( cargo->yyc, "%d, ", pFunc->pCode[ lPCodePos + ul ] );
|
|
}
|
|
fprintf( cargo->yyc, " };\n\t\thb_xvmPushBlock( codeblock, symbols );\n\t}\n" );
|
|
|
|
return 4 + ulSize;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushdouble )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
#if 0
|
|
fprintf( cargo->yyc, "\thb_xvmPushDouble( %.*f, %d, %d );\n",
|
|
pFunc->pCode[ lPCodePos + 1 + sizeof( double ) + sizeof( BYTE ) ] + 1,
|
|
HB_PCODE_MKDOUBLE( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
pFunc->pCode[ lPCodePos + 1 + sizeof( double ) ],
|
|
pFunc->pCode[ lPCodePos + 1 + sizeof( double ) + sizeof( BYTE ) ] );
|
|
#else
|
|
/*
|
|
* This version keeps double calculation compatible with RT FL functions
|
|
*/
|
|
fprintf( cargo->yyc, "\thb_xvmPushDouble( * ( double * ) " );
|
|
{
|
|
double d = HB_PCODE_MKDOUBLE( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
hb_compGenCString( cargo->yyc, ( BYTE * ) &d, sizeof( double ) );
|
|
}
|
|
fprintf( cargo->yyc, ", %d, %d );\n",
|
|
pFunc->pCode[ lPCodePos + 1 + sizeof( double ) ],
|
|
pFunc->pCode[ lPCodePos + 1 + sizeof( double ) + sizeof( BYTE ) ] );
|
|
#endif
|
|
return sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ) + 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushfield )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushField( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushbyte )
|
|
{
|
|
int iVal = ( signed char ) pFunc->pCode[ lPCodePos + 1 ], iSkip;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
iSkip = hb_gencc_checkNumAhead( iVal, pFunc, lPCodePos + 2, cargo );
|
|
|
|
if( iSkip == 0 )
|
|
fprintf( cargo->yyc, "\thb_xvmPushInteger( %d );\n", iVal );
|
|
return 2 + iSkip;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushint )
|
|
{
|
|
int iVal = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ), iSkip;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
iSkip = hb_gencc_checkNumAhead( iVal, pFunc, lPCodePos + 3, cargo );
|
|
|
|
if( iSkip == 0 )
|
|
fprintf( cargo->yyc, "\thb_xvmPushInteger( %d );\n", iVal );
|
|
return 3 + iSkip;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushlocal )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
if( HB_GENC_GETLABEL( lPCodePos + 3 ) == 0 )
|
|
{
|
|
switch( pFunc->pCode[ lPCodePos + 3 ] )
|
|
{
|
|
case HB_P_POPLOCALNEAR:
|
|
hb_gencc_copyLocals( cargo->yyc,
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
( signed char ) pFunc->pCode[ lPCodePos + 4 ] );
|
|
return 5;
|
|
|
|
case HB_P_POPLOCAL:
|
|
hb_gencc_copyLocals( cargo->yyc,
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 4 ] ) );
|
|
return 6;
|
|
}
|
|
}
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushLocal( %d );\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushlocalnear )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
if( HB_GENC_GETLABEL( lPCodePos + 2 ) == 0 )
|
|
{
|
|
switch( pFunc->pCode[ lPCodePos + 2 ] )
|
|
{
|
|
case HB_P_POPLOCALNEAR:
|
|
hb_gencc_copyLocals( cargo->yyc,
|
|
( signed char ) pFunc->pCode[ lPCodePos + 1 ],
|
|
( signed char ) pFunc->pCode[ lPCodePos + 3 ] );
|
|
return 4;
|
|
|
|
case HB_P_POPLOCAL:
|
|
hb_gencc_copyLocals( cargo->yyc,
|
|
( signed char ) pFunc->pCode[ lPCodePos + 1 ],
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 3 ] ) );
|
|
return 5;
|
|
}
|
|
}
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushLocal( %d );\n",
|
|
( signed char ) pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushlocalref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushLocalByRef( %d );\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushlong )
|
|
{
|
|
LONG lVal = HB_PCODE_MKLONG( &pFunc->pCode[ lPCodePos + 1 ] ), iSkip;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
iSkip = hb_gencc_checkNumAhead( lVal, pFunc, lPCodePos + 5, cargo );
|
|
|
|
if( iSkip == 0 )
|
|
{
|
|
#if HB_INT_MAX >= INT32_MAX
|
|
fprintf( cargo->yyc, "\thb_xvmPushInteger( %d );\n", ( int ) lVal );
|
|
#else
|
|
fprintf( cargo->yyc, "\thb_xvmPushLong( %ldL );\n", ( long ) lVal );
|
|
#endif
|
|
}
|
|
return 5 + iSkip;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushlonglong )
|
|
{
|
|
#ifdef HB_LONG_LONG_OFF
|
|
HB_GENC_LABEL();
|
|
fprintf( cargo->yyc, "\thb_xvmPushLongLong( %.1f );\n", HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 9;
|
|
#elif LONG_MAX == LONGLONG_MAX
|
|
LONGLONG llVal = HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ), iSkip;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
iSkip = hb_gencc_checkNumAhead( llVal, pFunc, lPCodePos + 9, cargo );
|
|
|
|
if( iSkip == 0 )
|
|
{
|
|
fprintf( cargo->yyc, "\thb_xvmPushLong( %ldL );\n", ( long ) llVal );
|
|
}
|
|
return 9 + iSkip;
|
|
#else
|
|
char szBuf[ 24 ];
|
|
HB_GENC_LABEL();
|
|
fprintf( cargo->yyc, "\thb_xvmPushLongLong( HB_LL( %s ) );\n",
|
|
hb_numToStr( szBuf, sizeof( szBuf ),
|
|
HB_PCODE_MKLONGLONG( &pFunc->pCode[ lPCodePos + 1 ] ) ) );
|
|
return 9;
|
|
#endif
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushmemvar )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushMemvar( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushmemvarref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushMemvarByRef( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushnil )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushNil();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushself )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushSelf();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushstatic )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushStatic( %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushstaticref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushStaticByRef( %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushstrshort )
|
|
{
|
|
USHORT usLen = pFunc->pCode[ lPCodePos + 1 ] - 1;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushStringConst( " );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 2 ], usLen );
|
|
fprintf( cargo->yyc, ", %hu );\n", usLen );
|
|
|
|
return 3 + usLen;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushstr )
|
|
{
|
|
USHORT usLen = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) - 1;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushStringConst( " );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 3 ], usLen );
|
|
fprintf( cargo->yyc, ", %hu );\n", usLen );
|
|
|
|
return 4 + usLen;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushstrlarge )
|
|
{
|
|
ULONG ulLen = HB_PCODE_MKUINT24( &pFunc->pCode[ lPCodePos + 1 ] ) - 1;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushStringConst( " );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 4 ], ulLen );
|
|
fprintf( cargo->yyc, ", %lu );\n", ulLen );
|
|
|
|
return 5 + ulLen;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushstrhidden )
|
|
{
|
|
USHORT usLen = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 2 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushStringHidden( %d, ",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 4 ], usLen );
|
|
fprintf( cargo->yyc, ", %hu );\n", usLen );
|
|
|
|
return 4 + usLen;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushsym )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
if( HB_GENC_GETLABEL( lPCodePos + 3 ) == 0 &&
|
|
pFunc->pCode[ lPCodePos + 3 ] == HB_P_PUSHNIL &&
|
|
HB_GENC_GETLABEL( lPCodePos + 3 ) == 0 )
|
|
{
|
|
fprintf( cargo->yyc, "\thb_xvmPushFuncSymbol( symbols + %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 4;
|
|
}
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushSymbol( symbols + %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushsymnear )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
if( HB_GENC_GETLABEL( lPCodePos + 2 ) == 0 &&
|
|
pFunc->pCode[ lPCodePos + 2 ] == HB_P_PUSHNIL &&
|
|
HB_GENC_GETLABEL( lPCodePos + 2 ) == 0 )
|
|
{
|
|
fprintf( cargo->yyc, "\thb_xvmPushFuncSymbol( symbols + %hu );\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 3;
|
|
}
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushSymbol( symbols + %d );\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushfuncsym )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushFuncSymbol( symbols + %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushvariable )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushVariable( symbols + %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_retvalue )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmRetValue();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_send )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmSend( %hu ) ) break;\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_sendshort )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmSend( %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ] );
|
|
return 2;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushovarref )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPushObjectVarRef() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_seqalways )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmSeqAlways();\n\tdo {\n" );
|
|
cargo->iNestedBlock++;
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_alwaysbegin )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\t} while( 0 );\n\tif( hb_xvmAlwaysBegin() ) break;\n\tdo {\n" );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_alwaysend )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\t} while( 0 );\n\tif( hb_xvmAlwaysEnd() ) break;\n" );
|
|
cargo->iNestedBlock--;
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_seqblock )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmSeqBlock() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_seqbegin )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmSeqBegin();\n\tdo {\n" );
|
|
cargo->iNestedBlock++;
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_seqend )
|
|
{
|
|
LONG lOffset = HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
if( lOffset == 4 ) /* no RECOVER clasue */
|
|
fprintf( cargo->yyc, "\t} while( 0 );\n\tif( hb_xvmSeqEnd() ) break;\n" );
|
|
else /* RECOVER exists */
|
|
fprintf( cargo->yyc, "\tif( hb_xvmSeqEndTest() ) break;\n\tgoto lab%05ld;\n\t} while( 0 );\n",
|
|
HB_GENC_GETLABEL( lPCodePos + lOffset ) );
|
|
cargo->iNestedBlock--;
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_seqrecover )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmSeqRecover() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_sframe )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmSFrame( symbols + %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_statics )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmStatics( symbols + %hu, %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 3 ] ) );
|
|
return 5;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_staticname )
|
|
{
|
|
USHORT usLen;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
usLen = strlen( ( char * ) &pFunc->pCode[ lPCodePos + 4 ] );
|
|
fprintf( cargo->yyc, "\thb_xvmStaticName( %hu, %hu, ",
|
|
( USHORT ) pFunc->pCode[ lPCodePos + 1 ],
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 2 ] ) );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 4 ], usLen );
|
|
fprintf( cargo->yyc, " );\n" );
|
|
return usLen + 5;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_threadstatics )
|
|
{
|
|
USHORT w;
|
|
ULONG ulSize, ul;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
w = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
ulSize = ( ULONG ) w << 1;
|
|
|
|
fprintf( cargo->yyc, "\t{\n\t\tstatic const BYTE statics[ %lu ] = {", ulSize );
|
|
|
|
for( ul = 0; ul < ulSize; ++ul )
|
|
{
|
|
if( ( ul & 0x0f ) == 0 )
|
|
fprintf( cargo->yyc, "\n\t\t\t" );
|
|
if( ul == ulSize - 1 )
|
|
fprintf( cargo->yyc, "%d", pFunc->pCode[ lPCodePos + ul + 3 ] );
|
|
else
|
|
fprintf( cargo->yyc, "%d, ", pFunc->pCode[ lPCodePos + ul + 3 ] );
|
|
}
|
|
fprintf( cargo->yyc, " };\n\t\thb_xvmThreadStatics( %hu, statics );\n\t}\n", w );
|
|
|
|
return 3 + ulSize;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_swapalias )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmSwapAlias() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_true )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushLogical( TRUE );\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_one )
|
|
{
|
|
int iSkip;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
iSkip = hb_gencc_checkNumAhead( 1, pFunc, lPCodePos + 1, cargo );
|
|
if( iSkip == 0 )
|
|
fprintf( cargo->yyc, "\thb_xvmPushInteger( 1 );\n" );
|
|
return 1 + iSkip;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_zero )
|
|
{
|
|
int iSkip;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
iSkip = hb_gencc_checkNumAhead( 0, pFunc, lPCodePos + 1, cargo );
|
|
if( iSkip == 0 )
|
|
fprintf( cargo->yyc, "\thb_xvmPushInteger( 0 );\n" );
|
|
return 1 + iSkip;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_noop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_dummy )
|
|
{
|
|
HB_SYMBOL_UNUSED( cargo );
|
|
HB_SYMBOL_UNUSED( pFunc );
|
|
HB_SYMBOL_UNUSED( lPCodePos );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_enumstart )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmEnumStart( %d, %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ], pFunc->pCode[ lPCodePos + 2 ] );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_enumnext )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmEnumNext() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_enumprev )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmEnumPrev() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_enumend )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmEnumEnd();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_switch )
|
|
{
|
|
USHORT usCases = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ), us;
|
|
ULONG ulStart = lPCodePos, ulNewPos;
|
|
BOOL fNum = FALSE, fStr = FALSE, fDefault = FALSE;
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
lPCodePos += 3;
|
|
for( us = 0; us < usCases; ++us )
|
|
{
|
|
switch( pFunc->pCode[ lPCodePos ] )
|
|
{
|
|
case HB_P_PUSHLONG:
|
|
fNum = TRUE;
|
|
lPCodePos += 5;
|
|
break;
|
|
case HB_P_PUSHSTRSHORT:
|
|
fStr = TRUE;
|
|
lPCodePos += 2 + pFunc->pCode[ lPCodePos + 1 ];
|
|
break;
|
|
case HB_P_PUSHNIL:
|
|
/* default clause */
|
|
fDefault = TRUE;
|
|
lPCodePos++;
|
|
break;
|
|
}
|
|
switch( pFunc->pCode[ lPCodePos ] )
|
|
{
|
|
case HB_P_JUMPNEAR:
|
|
ulNewPos = lPCodePos + ( signed char ) pFunc->pCode[ lPCodePos + 1 ];
|
|
lPCodePos += 2;
|
|
break;
|
|
case HB_P_JUMP:
|
|
ulNewPos = lPCodePos + HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
lPCodePos += 3;
|
|
break;
|
|
/*case HB_P_JUMPFAR:*/
|
|
default:
|
|
ulNewPos = lPCodePos + HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
lPCodePos += 4;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( fStr || fNum )
|
|
{
|
|
fprintf( cargo->yyc, "\t{\n\t\tPHB_ITEM pSwitch;\n\t\tHB_TYPE type;\n" );
|
|
if( fStr )
|
|
fprintf( cargo->yyc, "\t\tconst char * pszText;\n\t\tULONG ulLen;\n" );
|
|
if( fNum )
|
|
fprintf( cargo->yyc, "\t\tlong lVal;\n" );
|
|
fprintf( cargo->yyc, "\t\tif( hb_xvmSwitchGet( &pSwitch ) ) break;\n"
|
|
"\t\ttype = hb_itemType( pSwitch );\n" );
|
|
if( fStr )
|
|
{
|
|
fprintf( cargo->yyc, "\t\tpszText = (type & HB_IT_STRING) ? hb_itemGetCPtr( pSwitch ) : NULL;\n" );
|
|
fprintf( cargo->yyc, "\t\tulLen = pszText ? hb_itemGetCLen( pSwitch ) : 0;\n" );
|
|
}
|
|
if( fNum )
|
|
fprintf( cargo->yyc, "\t\tlVal = (type & HB_IT_NUMINT) ? hb_itemGetNL( pSwitch ) : 0;\n\n" );
|
|
}
|
|
|
|
lPCodePos = ulStart + 3;
|
|
for( us = 0; us < usCases; ++us )
|
|
{
|
|
switch( pFunc->pCode[ lPCodePos ] )
|
|
{
|
|
case HB_P_PUSHLONG:
|
|
fprintf( cargo->yyc, "\t\tif( (type & HB_IT_NUMINT) != 0 && lVal == %ldL )\n",
|
|
HB_PCODE_MKLONG( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
lPCodePos += 5;
|
|
break;
|
|
case HB_P_PUSHSTRSHORT:
|
|
fprintf( cargo->yyc, "\t\tif( pszText && ulLen == %d && !memcmp( pszText, ",
|
|
pFunc->pCode[ lPCodePos + 1 ] - 1 );
|
|
hb_compGenCString( cargo->yyc, &pFunc->pCode[ lPCodePos + 2 ],
|
|
pFunc->pCode[ lPCodePos + 1 ] - 1 );
|
|
fprintf( cargo->yyc, ", %d ) )\n", pFunc->pCode[ lPCodePos + 1 ] - 1 );
|
|
lPCodePos += 2 + pFunc->pCode[ lPCodePos + 1 ];
|
|
break;
|
|
case HB_P_PUSHNIL:
|
|
/* default clause */
|
|
lPCodePos++;
|
|
break;
|
|
}
|
|
switch( pFunc->pCode[ lPCodePos ] )
|
|
{
|
|
case HB_P_JUMPNEAR:
|
|
ulNewPos = lPCodePos + ( signed char ) pFunc->pCode[ lPCodePos + 1 ];
|
|
lPCodePos += 2;
|
|
break;
|
|
case HB_P_JUMP:
|
|
ulNewPos = lPCodePos + HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
lPCodePos += 3;
|
|
break;
|
|
/*case HB_P_JUMPFAR:*/
|
|
default:
|
|
ulNewPos = lPCodePos + HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
lPCodePos += 4;
|
|
break;
|
|
}
|
|
fprintf( cargo->yyc, "\t\t{\n\t\t\thb_stackPop();\n\t\t\tgoto lab%05ld;\n\t\t}\n",
|
|
HB_GENC_GETLABEL( ulNewPos ) );
|
|
}
|
|
if( !fDefault )
|
|
fprintf( cargo->yyc, "\t\thb_stackPop();\n" );
|
|
if( fStr || fNum )
|
|
fprintf( cargo->yyc, "\t}\n" );
|
|
|
|
return lPCodePos - ulStart;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushdate )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushDate( %ldL );\n",
|
|
( long ) HB_PCODE_MKLONG( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 5;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushtimestamp )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushTimeStamp( %ldL, %ldL );\n",
|
|
( long ) HB_PCODE_MKLONG( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
( long ) HB_PCODE_MKLONG( &pFunc->pCode[ lPCodePos + 5 ] ) );
|
|
return 9;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_localnearaddint )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLocalAddInt( %d, %d ) ) break;\n",
|
|
pFunc->pCode[ lPCodePos + 1 ],
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 2 ] ) );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_localaddint )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLocalAddInt( %d, %d ) ) break;\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 3 ] ) );
|
|
return 5;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_localinc )
|
|
{
|
|
int iLocal = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
if( HB_GENC_GETLABEL( lPCodePos + 3 ) == 0 &&
|
|
( ( pFunc->pCode[ lPCodePos + 3 ] == HB_P_PUSHLOCAL &&
|
|
iLocal == HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 4 ] ) ) ||
|
|
( pFunc->pCode[ lPCodePos + 3 ] == HB_P_PUSHLOCALNEAR &&
|
|
iLocal == pFunc->pCode[ lPCodePos + 4 ] ) ) )
|
|
{
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLocalIncPush( %d ) ) break;\n", iLocal );
|
|
return ( pFunc->pCode[ lPCodePos + 3 ] == HB_P_PUSHLOCAL ) ? 6 : 5;
|
|
}
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLocalInc( %d ) ) break;\n", iLocal );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_localdec )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLocalDec( %d ) ) break;\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_localincpush )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmLocalIncPush( %d ) ) break;\n",
|
|
HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) );
|
|
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pluseqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPlusEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_minuseqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMinusEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_multeqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMultEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_diveqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDivEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_modeqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmModEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_expeqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmExpEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_deceqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDecEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_inceqpop )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmIncEqPop() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pluseq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmPlusEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_minuseq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMinusEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_multeq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmMultEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_diveq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDivEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_modeq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmModEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_expeq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmExpEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_deceq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmDecEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_inceq )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\tif( hb_xvmIncEq() ) break;\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_withobjectstart )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmWithObjectStart();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_withobjectend )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmWithObjectEnd();\n" );
|
|
return 1;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_withobjectmessage )
|
|
{
|
|
USHORT usSym = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
|
|
|
HB_GENC_LABEL();
|
|
|
|
if( usSym == 0xFFFF )
|
|
fprintf( cargo->yyc, "\thb_xvmWithObjectMessage( NULL );\n" );
|
|
else
|
|
fprintf( cargo->yyc, "\thb_xvmWithObjectMessage( symbols + %hu );\n",
|
|
usSym );
|
|
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_vframe )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmVFrame( %hu, %hu );\n",
|
|
pFunc->pCode[ lPCodePos + 1 ], pFunc->pCode[ lPCodePos + 2 ] );
|
|
return 3;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_largeframe )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmFrame( %hu, %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
pFunc->pCode[ lPCodePos + 3 ] );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_largevframe )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmVFrame( %hu, %hu );\n",
|
|
HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ),
|
|
pFunc->pCode[ lPCodePos + 3 ] );
|
|
return 4;
|
|
}
|
|
|
|
static HB_GENC_FUNC( hb_p_pushvparams )
|
|
{
|
|
HB_GENC_LABEL();
|
|
|
|
fprintf( cargo->yyc, "\thb_xvmPushVParams();\n" );
|
|
return 1;
|
|
}
|
|
|
|
|
|
/* NOTE: The order of functions have to match the order of opcodes
|
|
* mnemonics
|
|
*/
|
|
static const HB_GENC_FUNC_PTR s_verbose_table[] = {
|
|
hb_p_and,
|
|
hb_p_arraypush,
|
|
hb_p_arraypop,
|
|
hb_p_arraydim,
|
|
hb_p_arraygen,
|
|
hb_p_equal,
|
|
hb_p_endblock,
|
|
hb_p_endproc,
|
|
hb_p_exactlyequal,
|
|
hb_p_false,
|
|
hb_p_fortest,
|
|
hb_p_function,
|
|
hb_p_functionshort,
|
|
hb_p_frame,
|
|
hb_p_funcptr,
|
|
hb_p_greater,
|
|
hb_p_greaterequal,
|
|
hb_p_dec,
|
|
hb_p_divide,
|
|
hb_p_do,
|
|
hb_p_doshort,
|
|
hb_p_duplicate,
|
|
hb_p_pushtimestamp,
|
|
hb_p_inc,
|
|
hb_p_instring,
|
|
hb_p_jumpnear,
|
|
hb_p_jump,
|
|
hb_p_jumpfar,
|
|
hb_p_jumpfalsenear,
|
|
hb_p_jumpfalse,
|
|
hb_p_jumpfalsefar,
|
|
hb_p_jumptruenear,
|
|
hb_p_jumptrue,
|
|
hb_p_jumptruefar,
|
|
hb_p_lessequal,
|
|
hb_p_less,
|
|
hb_p_line,
|
|
hb_p_localname,
|
|
hb_p_macropop,
|
|
hb_p_macropopaliased,
|
|
hb_p_macropush,
|
|
hb_p_macroarraygen,
|
|
hb_p_macropushlist,
|
|
hb_p_macropushindex,
|
|
hb_p_macropushpare,
|
|
hb_p_macropushaliased,
|
|
hb_p_macrosymbol,
|
|
hb_p_macrotext,
|
|
hb_p_message,
|
|
hb_p_minus,
|
|
hb_p_modulus,
|
|
hb_p_modulename,
|
|
/* start: pcodes generated by macro compiler */
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
/* end: */
|
|
hb_p_mult,
|
|
hb_p_negate,
|
|
hb_p_noop,
|
|
hb_p_not,
|
|
hb_p_notequal,
|
|
hb_p_or,
|
|
hb_p_parameter,
|
|
hb_p_plus,
|
|
hb_p_pop,
|
|
hb_p_popalias,
|
|
hb_p_popaliasedfield,
|
|
hb_p_popaliasedfieldnear,
|
|
hb_p_popaliasedvar,
|
|
hb_p_popfield,
|
|
hb_p_poplocal,
|
|
hb_p_poplocalnear,
|
|
hb_p_popmemvar,
|
|
hb_p_popstatic,
|
|
hb_p_popvariable,
|
|
hb_p_power,
|
|
hb_p_pushalias,
|
|
hb_p_pushaliasedfield,
|
|
hb_p_pushaliasedfieldnear,
|
|
hb_p_pushaliasedvar,
|
|
hb_p_pushblock,
|
|
hb_p_pushblockshort,
|
|
hb_p_pushfield,
|
|
hb_p_pushbyte,
|
|
hb_p_pushint,
|
|
hb_p_pushlocal,
|
|
hb_p_pushlocalnear,
|
|
hb_p_pushlocalref,
|
|
hb_p_pushlong,
|
|
hb_p_pushmemvar,
|
|
hb_p_pushmemvarref,
|
|
hb_p_pushnil,
|
|
hb_p_pushdouble,
|
|
hb_p_pushself,
|
|
hb_p_pushstatic,
|
|
hb_p_pushstaticref,
|
|
hb_p_pushstr,
|
|
hb_p_pushstrshort,
|
|
hb_p_pushsym,
|
|
hb_p_pushsymnear,
|
|
hb_p_pushvariable,
|
|
hb_p_retvalue,
|
|
hb_p_send,
|
|
hb_p_sendshort,
|
|
hb_p_seqbegin,
|
|
hb_p_seqend,
|
|
hb_p_seqrecover,
|
|
hb_p_sframe,
|
|
hb_p_statics,
|
|
hb_p_staticname,
|
|
hb_p_swapalias,
|
|
hb_p_true,
|
|
hb_p_zero,
|
|
hb_p_one,
|
|
hb_p_macrofunc,
|
|
hb_p_macrodo,
|
|
/* start: more pcodes generated by macro compiler */
|
|
hb_p_dummy,
|
|
/* end: */
|
|
hb_p_localnearaddint,
|
|
hb_p_macropushref,
|
|
hb_p_pushlonglong,
|
|
hb_p_enumstart,
|
|
hb_p_enumnext,
|
|
hb_p_enumprev,
|
|
hb_p_enumend,
|
|
hb_p_switch,
|
|
hb_p_pushdate,
|
|
/* optimalization of inlined math operations (+=, -= */
|
|
hb_p_pluseqpop,
|
|
hb_p_minuseqpop,
|
|
hb_p_multeqpop,
|
|
hb_p_diveqpop,
|
|
hb_p_pluseq,
|
|
hb_p_minuseq,
|
|
hb_p_multeq,
|
|
hb_p_diveq,
|
|
hb_p_withobjectstart,
|
|
hb_p_withobjectmessage,
|
|
hb_p_withobjectend,
|
|
hb_p_macrosend,
|
|
hb_p_pushovarref,
|
|
hb_p_arraypushref,
|
|
hb_p_vframe,
|
|
hb_p_largeframe,
|
|
hb_p_largevframe,
|
|
hb_p_pushstrhidden,
|
|
hb_p_localaddint,
|
|
hb_p_modeqpop,
|
|
hb_p_expeqpop,
|
|
hb_p_modeq,
|
|
hb_p_expeq,
|
|
hb_p_duplunref,
|
|
hb_p_dummy,
|
|
hb_p_dummy,
|
|
hb_p_pushblocklarge,
|
|
hb_p_pushstrlarge,
|
|
hb_p_swap,
|
|
hb_p_pushvparams,
|
|
hb_p_pushunref,
|
|
hb_p_seqalways,
|
|
hb_p_alwaysbegin,
|
|
hb_p_alwaysend,
|
|
hb_p_deceqpop,
|
|
hb_p_inceqpop,
|
|
hb_p_deceq,
|
|
hb_p_inceq,
|
|
hb_p_localdec,
|
|
hb_p_localinc,
|
|
hb_p_localincpush,
|
|
hb_p_pushfuncsym,
|
|
hb_p_hashgen,
|
|
hb_p_seqblock,
|
|
hb_p_threadstatics
|
|
};
|
|
|
|
void hb_compGenCRealCode( HB_COMP_DECL, PFUNCTION pFunc, FILE * yyc )
|
|
{
|
|
const HB_GENC_FUNC_PTR * pFuncTable = s_verbose_table;
|
|
HB_LABEL_INFO label_info;
|
|
|
|
/* Make sure that table is correct */
|
|
assert( HB_P_LAST_PCODE == sizeof( s_verbose_table ) / sizeof( HB_GENC_FUNC_PTR ) );
|
|
|
|
label_info.yyc = yyc;
|
|
label_info.fVerbose = ( HB_COMP_PARAM->iGenCOutput == HB_COMPGENC_VERBOSE );
|
|
label_info.fSetSeqBegin = FALSE;
|
|
label_info.fCondJump = FALSE;
|
|
label_info.fEndRequest = FALSE;
|
|
label_info.iNestedBlock = 0;
|
|
if( pFunc->lPCodePos == 0 )
|
|
label_info.pulLabels = NULL;
|
|
else
|
|
{
|
|
label_info.pulLabels = ( ULONG * ) hb_xgrab( pFunc->lPCodePos * sizeof( ULONG ) );
|
|
memset( label_info.pulLabels, 0, pFunc->lPCodePos * sizeof( ULONG ) );
|
|
hb_compGenLabelTable( pFunc, &label_info );
|
|
}
|
|
|
|
fprintf( yyc, "{\n" );
|
|
if( label_info.fCondJump )
|
|
fprintf( yyc, " BOOL fValue;\n" );
|
|
fprintf( yyc, " do {\n" );
|
|
|
|
hb_compPCodeEval( pFunc, ( HB_PCODE_FUNC_PTR * ) pFuncTable, ( void * ) &label_info );
|
|
|
|
fprintf( yyc, " } while( 0 );\n" );
|
|
if( label_info.fEndRequest )
|
|
fprintf( yyc, " hb_xvmExitProc();\n" );
|
|
fprintf( yyc, "}\n" );
|
|
|
|
if( label_info.pulLabels )
|
|
hb_xfree( label_info.pulLabels );
|
|
}
|