ChangeLogTag:Wed May 05 16:29:19 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>

This commit is contained in:
Gonzalo A. Diethelm
1999-05-05 21:24:59 +00:00
parent 5c2659176c
commit 7f173f0389
5 changed files with 94 additions and 26 deletions

View File

@@ -1,3 +1,19 @@
Wed May 05 16:29:19 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
* include/pcode.h:
* source/vm/hvm.c:
* source/compiler/harbour.y:
Replaced _AND and _OR with AND_ and OR_.
Under gcc, these two identifiers are defined out.
Also, got rid of a few warnings.
* source/rtl/files.c:
Implemented a macro trick to allow compilation of
FOPEN, FREAD and FWRITE.
Turned off HAVE_POSIX_IO for gcc; it doesn't seem to work.
Restructured the code so that when HAVE_POSIX_IO is not defined,
there are no warnings.
Wed May 05 15:30:49 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
* source/harbour.y:

View File

@@ -5,7 +5,7 @@
typedef enum
{
_AND, /* peforms the logical AND of two latest stack values, removes them and places result */
AND_, /* peforms the logical AND of two latest stack values, removes them and places result */
_ARRAYAT, /* places on the virtual machine stack an array element */
_ARRAYPUT, /* sets array element, the array and the index are both on the stack */
_EQUAL, /* check if the latest two values on the stack are equal, removing them and leaving there the result */
@@ -39,7 +39,7 @@ typedef enum
_NEGATE, /* numerically negates the latest value on the stack */
_NOT, /* logically negates the latest value on the stack */
_NOTEQUAL, /* checks if the latest two stack values are equal, leaves just the result */
_OR, /* peforms the logical OR of two latest stack values, removes them and places result */
OR_, /* peforms the logical OR of two latest stack values, removes them and places result */
_PLUS, /* adds the latest two values on the stack, removing them and leaving there the result */
_POP, /* removes the latest value from the stack */
_POPDEFSTAT, /* pops a default value to a static variable */

View File

@@ -596,9 +596,9 @@ Operators : Expression '=' Expression { GenPCode1( _EQUAL ); } /* compare
| Expression LE Expression { GenPCode1( _LESSEQUAL ); }
| Expression GE Expression { GenPCode1( _GREATEREQUAL ); }
| Expression AND { if( _iShortCuts ){ Duplicate(); $<iNumber>$ = JumpFalse( 0 ); } }
Expression { GenPCode1( _AND ); if( _iShortCuts ) JumpHere( $<iNumber>3 ); }
Expression { GenPCode1( AND_ ); if( _iShortCuts ) JumpHere( $<iNumber>3 ); }
| Expression OR { if( _iShortCuts ){ Duplicate(); $<iNumber>$ = JumpTrue( 0 ); } }
Expression { GenPCode1( _OR ); if( _iShortCuts ) JumpHere( $<iNumber>3 ); }
Expression { GenPCode1( OR_ ); if( _iShortCuts ) JumpHere( $<iNumber>3 ); }
| Expression EQ Expression { GenPCode1( _EQUAL ); }
| Expression NE1 Expression { GenPCode1( _NOTEQUAL ); }
| Expression NE2 Expression { GenPCode1( _NOTEQUAL ); }
@@ -1476,19 +1476,19 @@ void FunDef( char * szFunName, char cScope ) /* stores a Clipper defined functi
void GenJava( char *szFileName, char *szName )
{
printf( "\ngenerating Java language output...\n" );
printf( "%s -> not implemented yet!\n", szFileName, szName );
printf( "%s -> not implemented yet!\n", szFileName );
}
void GenPascal( char *szFileName, char *szName )
{
printf( "\ngenerating Pascal language output...\n" );
printf( "%s -> not implemented yet!\n", szFileName, szName );
printf( "%s -> not implemented yet!\n", szFileName );
}
void GenRC( char *szFileName, char *szName )
{
printf( "\ngenerating resources output...\n" );
printf( "%s -> not implemented yet!\n", szFileName, szName );
printf( "%s -> not implemented yet!\n", szFileName );
}
void GenCCode( char *szFileName, char *szName ) /* generates the C language output */
@@ -1598,8 +1598,8 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag
{
switch( pFunc->pCode[ lPCodePos ] )
{
case _AND:
fprintf( yyc, " _AND,\n" );
case AND_:
fprintf( yyc, " AND_,\n" );
lPCodePos++;
break;
@@ -1795,8 +1795,8 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag
lPCodePos++;
break;
case _OR:
fprintf( yyc, " _OR,\n" );
case OR_:
fprintf( yyc, " OR_,\n" );
lPCodePos++;
break;

View File

@@ -10,7 +10,9 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#endif
#if defined(__DJGPP__)
#if !defined(HAVE_POSIX_IO)
#define HAVE_POSIX_IO
#endif
@@ -41,8 +43,6 @@ static int last_error = 0;
#define PATH_MAX 256
#endif
static char cwd_buff[PATH_MAX+1];
#define MKLONG(_1,_2,_3,_4) (((long)_4)<<24)|(((long)_3)<<16)|(((long)_2)<<8)|_1
#define MKINT(_1,_2) (((long)_2)<<8)|_1
@@ -76,13 +76,13 @@ extern int rename( const char *, const char * );
// Convert HARBOUR flags to IO subsystem flags
#if defined(HAVE_POSIX_IO)
static int convert_open_flags( int flags )
{
// by default FO_READ+FO_COMPAT is set
int result_flags = 0;
#if defined(HAVE_POSIX_IO)
result_flags |= O_BINARY;
if( flags == 0 )
@@ -111,7 +111,6 @@ static int convert_open_flags( int flags )
if( flags & FO_SHARE )
result_flags |= SH_DENYNO;
#endif
return result_flags;
}
@@ -120,8 +119,6 @@ static int convert_seek_flags( int flags )
// by default FS_SET is set
int result_flags=0;
#if defined(HAVE_POSIX_IO)
result_flags = SEEK_SET;
if( flags & FS_RELATIVE )
@@ -130,8 +127,6 @@ static int convert_seek_flags( int flags )
if( flags & FS_END )
result_flags = SEEK_END;
#endif
return result_flags;
}
@@ -140,8 +135,6 @@ static int convert_create_flags( int flags )
// by default FC_NORMAL is set
int result_flags=S_IWUSR;
#if defined(HAVE_POSIX_IO)
if( flags & FC_READONLY )
result_flags = result_flags & ~(S_IWUSR);
@@ -151,11 +144,12 @@ static int convert_create_flags( int flags )
if( flags & FC_SYSTEM )
result_flags |= 0;
#endif
return result_flags;
}
#endif
// FILESYS.API FUNCTIONS --
// ------------------------
@@ -163,6 +157,8 @@ int _fsOpen( char * name, int flags )
{
#if defined(HAVE_POSIX_IO)
return open(name,convert_open_flags(flags));
#else
return 0;
#endif
}
@@ -170,6 +166,8 @@ int _fsCreate( char * name, int flags )
{
#if defined(HAVE_POSIX_IO)
return creat(name,convert_create_flags(flags));
#else
return 0;
#endif
}
@@ -185,6 +183,8 @@ long _fsRead( int handle, char * buff, long count )
{
#if defined(HAVE_POSIX_IO)
return read(handle,buff,count);
#else
return 0;
#endif
}
@@ -192,6 +192,8 @@ long _fsWrite( int handle, char * buff, long count )
{
#if defined(HAVE_POSIX_IO)
return write(handle,buff,count);
#else
return 0;
#endif
}
@@ -199,6 +201,8 @@ long _fsSeek( int handle, long offset, int flags )
{
#if defined(HAVE_POSIX_IO)
return lseek(handle,offset,convert_seek_flags(flags));
#else
return 0;
#endif
}
@@ -245,6 +249,8 @@ int _fsMkDir( char * name )
{
#if defined(HAVE_POSIX_IO)
return mkdir(name,S_IWUSR|S_IRUSR);
#else
return 0;
#endif
}
@@ -252,6 +258,8 @@ int _fsChDir( char * name )
{
#if defined(HAVE_POSIX_IO)
return chdir(name);
#else
return 0;
#endif
}
@@ -259,14 +267,19 @@ int _fsRmDir( char * name )
{
#if defined(HAVE_POSIX_IO)
return rmdir(name);
#else
return 0;
#endif
}
char * _fsCurDir( int driver )
{
#if defined(HAVE_POSIX_IO)
static char cwd_buff[PATH_MAX+1];
getcwd(cwd_buff,PATH_MAX);
return cwd_buff;
#else
return 0;
#endif
}
@@ -274,6 +287,8 @@ int _fsCurDrv( void )
{
#if defined(HAVE_POSIX_IO)
return 0;
#else
return 0;
#endif
}
@@ -281,6 +296,8 @@ long _fsChDrv( int driver )
{
#if defined(HAVE_POSIX_IO)
return 0;
#else
return 0;
#endif
}
@@ -288,6 +305,8 @@ long _fsIsDrv( int driver )
{
#if defined(HAVE_POSIX_IO)
return 0;
#else
return 0;
#endif
}
@@ -302,7 +321,18 @@ int _fsExtOpen(PBYTE filename, PBYTE defExt, ULONG flags,
// -- HARBOUR FUNCTIONS --
// -----------------------
#ifdef FOPEN
#define HB_FOPEN FOPEN
#undef FOPEN
#endif
HARBOUR FOPEN()
#ifdef HB_FOPEN
#define FOPEN HB_FOPEN
#undef HB_FOPEN
#endif
{
PITEM arg1_it = _param(1,IT_STRING);
PITEM arg2_it = _param(2,IT_NUMBER);
@@ -348,7 +378,18 @@ HARBOUR FCREATE()
return;
}
#ifdef FREAD
#define HB_FREAD FREAD
#undef FREAD
#endif
HARBOUR FREAD()
#ifdef HB_FREAD
#define FREAD HB_FREAD
#undef HB_FREAD
#endif
{
PITEM arg1_it = _param(1,IT_NUMBER);
PITEM arg2_it = _param(2,IT_STRING+IT_BYREF);
@@ -366,7 +407,18 @@ HARBOUR FREAD()
return;
}
#ifdef FWRITE
#define HB_FWRITE FWRITE
#undef FWRITE
#endif
HARBOUR FWRITE()
#ifdef HB_FWRITE
#define FWRITE HB_FWRITE
#undef HB_FWRITE
#endif
{
PITEM arg1_it = _param(1,IT_NUMBER);
PITEM arg2_it = _param(2,IT_STRING);

View File

@@ -206,7 +206,7 @@ void VirtualMachine( PBYTE pCode, PSYMBOL pSymbols )
{
switch( bCode )
{
case _AND:
case AND_:
And();
w++;
break;
@@ -369,7 +369,7 @@ void VirtualMachine( PBYTE pCode, PSYMBOL pSymbols )
w++;
break;
case _OR:
case OR_:
Or();
w++;
break;