[Plib-cvs] plib/src/psl psl.h,1.13,1.14 pslCodeGen.cxx,1.14,1.15 pslCompiler.cxx,1.16,1.17 pslCompil
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2002-09-13 17:37:30
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv31108/plib/src/psl Modified Files: psl.h pslCodeGen.cxx pslCompiler.cxx pslCompiler.h pslContext.cxx pslContext.h pslError.cxx Log Message: Added documentation for PSL Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- psl.h 11 Sep 2002 21:42:32 -0000 1.13 +++ psl.h 13 Sep 2002 17:37:26 -0000 1.14 @@ -261,6 +261,6 @@ void pslInit () ; -void pslSetErrorCallback ( void (*CB) ( int, char *, int, char * ) ) ; +void pslSetErrorCallback ( void (*CB) ( pslProgram *, int, char *, int, char * ) ) ; Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- pslCodeGen.cxx 11 Sep 2002 21:42:32 -0000 1.14 +++ pslCodeGen.cxx 13 Sep 2002 17:37:26 -0000 1.15 @@ -67,9 +67,8 @@ } -void pslCompiler::pushIntConstant ( const char *c ) +void pslCompiler::pushIntConstant ( int i ) { - int i = atoi ( c ) ; char *ii = (char *) & i ; pushCodeByte ( OPCODE_PUSH_INT_CONSTANT ) ; @@ -79,6 +78,12 @@ pushCodeByte ( ii [ 3 ] ) ; } +void pslCompiler::pushIntConstant ( const char *c ) +{ + int i = atoi ( c ) ; + pushIntConstant ( i ) ; +} + void pslCompiler::pushFloatConstant ( const char *c ) { float f = (float) atof ( c ) ; @@ -138,6 +143,7 @@ if ( ext < 0 ) { + pushIntConstant ( argc ) ; pushCodeByte ( OPCODE_CALL ) ; int a = getCodeSymbol ( c, next_code ) ; Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pslCompiler.cxx 10 Sep 2002 23:02:06 -0000 1.16 +++ pslCompiler.cxx 13 Sep 2002 17:37:27 -0000 1.17 @@ -591,6 +591,8 @@ /* Have the program call 'main' and then halt */ + pushIntConstant ( 0 ) ; /* No arguments to main *YET* */ + pushCodeByte ( OPCODE_CALL ) ; pushCodeAddr ( getCodeSymbol ( "main", next_code ) ) ; pushCodeByte ( 0 ) ; /* Argc */ Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pslCompiler.h 12 Sep 2002 12:10:26 -0000 1.16 +++ pslCompiler.h 13 Sep 2002 17:37:27 -0000 1.17 @@ -98,6 +98,7 @@ void pushIntConstant ( const char *s ) ; void pushFloatConstant ( const char *s ) ; void pushStringConstant( const char *s ) ; + void pushIntConstant ( int i ) ; void pushVoidConstant () ; Index: pslContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.cxx,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pslContext.cxx 8 Sep 2002 18:56:29 -0000 1.5 +++ pslContext.cxx 13 Sep 2002 17:37:27 -0000 1.6 @@ -107,9 +107,13 @@ case OPCODE_RETURN : { + int nargs ; pslValue result ; + popNumber ( &result ) ; pc = popInt () ; + nargs = popInt () ; + popVoid ( nargs ) ; pushNumber ( &result ) ; } return PSL_PROGRAM_CONTINUE ; Index: pslContext.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pslContext.h 8 Sep 2002 22:17:32 -0000 1.7 +++ pslContext.h 13 Sep 2002 17:37:27 -0000 1.8 @@ -62,7 +62,7 @@ void pushString ( const char *x ) { stack [ sp++ ] . set ( x ) ; } void pushNumber ( const pslNumber *x ) { stack [ sp++ ] . set ( x ) ; } - void popVoid () { --sp ; } + void popVoid ( int n = 1 ) { sp -= n ; } int popInt () { return stack [ --sp ] . getInt () ; } float popFloat () { return stack [ --sp ] . getFloat () ; } char *popString () { return stack [ --sp ] . getString () ; } Index: pslError.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslError.cxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pslError.cxx 10 Sep 2002 23:02:07 -0000 1.4 +++ pslError.cxx 13 Sep 2002 17:37:27 -0000 1.5 @@ -28,11 +28,12 @@ static char _pslErrorBuffer [ 1024 ] = { '\0' } ; -void (*_pslErrorCB) ( int severity, const char *progname, int line_no, - const char *message ) = NULL ; +void (*_pslErrorCB) ( pslProgram *p, int severity, const char *progname, + int line_no , const char *message ) = NULL ; -void pslSetErrorCallback ( void (*CB) ( int, const char *, int, const char * ) ) +void pslSetErrorCallback ( void (*CB) ( pslProgram *, int, const char *, + int, const char * ) ) { _pslErrorCB = CB ; } @@ -47,7 +48,7 @@ va_end ( argp ) ; if ( _pslErrorCB != NULL ) - (*_pslErrorCB)( PSL_COMPILETIME_WARNING, _pslGetFname(), _pslGetLineNo(), + (*_pslErrorCB)( this, PSL_COMPILETIME_WARNING, _pslGetFname(), _pslGetLineNo(), _pslErrorBuffer ) ; else fprintf ( stderr, "PSL: \"%s\" line %3d: WARNING - %s\n", @@ -68,7 +69,7 @@ va_end ( argp ) ; if ( _pslErrorCB != NULL ) - (*_pslErrorCB)( PSL_COMPILETIME_ERROR, _pslGetFname(), _pslGetLineNo(), + (*_pslErrorCB)( this, PSL_COMPILETIME_ERROR, _pslGetFname(), _pslGetLineNo(), _pslErrorBuffer ) ; else fprintf ( stderr, "PSL: \"%s\" line %3d: *ERROR* - %s\n", @@ -89,7 +90,7 @@ va_end ( argp ) ; if ( _pslErrorCB != NULL ) - (*_pslErrorCB)( PSL_RUNTIME_WARNING, getProgName(), pc, _pslErrorBuffer ) ; + (*_pslErrorCB)( program, PSL_RUNTIME_WARNING, getProgName(), pc, _pslErrorBuffer ) ; else fprintf ( stderr, "PSL: \"%s\" PC=%d: WARNING - %s\n", getProgName(), pc, _pslErrorBuffer ) ; @@ -107,7 +108,7 @@ va_end ( argp ) ; if ( _pslErrorCB != NULL ) - (*_pslErrorCB)( PSL_RUNTIME_ERROR, getProgName(), pc, _pslErrorBuffer ) ; + (*_pslErrorCB)( program, PPSL_RUNTIME_ERROR, getProgName(), pc, _pslErrorBuffer ) ; else fprintf ( stderr, "PSL: \"%s\" PC=%d: *ERROR* - %s\n", getProgName(), pc, _pslErrorBuffer ) ; |