[Plib-cvs] plib/src/psl psl.cxx,1.3,1.4 psl.h,1.6,1.7 pslCompiler.cxx,1.6,1.7 pslLocal.h,1.8,1.9 psl
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2002-09-06 15:07:47
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv22280/plib/src/psl Modified Files: psl.cxx psl.h pslCompiler.cxx pslLocal.h pslProgram.cxx Log Message: Global variable initialisations now work. pslInit created and checked for. Index: psl.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.cxx,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- psl.cxx 5 Sep 2002 22:22:38 -0000 1.3 +++ psl.cxx 6 Sep 2002 15:07:44 -0000 1.4 @@ -24,4 +24,8 @@ #include "pslLocal.h" +int _pslInitialised = FALSE ; + +void pslInit () { _pslInitialised = TRUE ; } + Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- psl.h 6 Sep 2002 13:50:51 -0000 1.6 +++ psl.h 6 Sep 2002 15:07:44 -0000 1.7 @@ -87,4 +87,5 @@ } ; +void pslInit () ; Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pslCompiler.cxx 6 Sep 2002 13:50:51 -0000 1.6 +++ pslCompiler.cxx 6 Sep 2002 15:07:44 -0000 1.7 @@ -267,16 +267,6 @@ { char c [ MAX_TOKEN ] ; - /* Have the program call 'main' and then halt */ - - pushCodeByte ( OPCODE_CALL ) ; - - int main_fixup = next_code ; - - pushCodeAddr ( getCodeSymbol ( "main", next_code ) ) ; - pushCodeByte ( 0 ) ; /* Argc */ - pushCodeByte ( OPCODE_HALT ) ; - /* Compile the program */ while ( TRUE ) @@ -291,6 +281,13 @@ pushGlobalDeclaration () ; } + /* Have the program call 'main' and then halt */ + + pushCodeByte ( OPCODE_CALL ) ; + pushCodeAddr ( getCodeSymbol ( "main", next_code ) ) ; + pushCodeByte ( 0 ) ; /* Argc */ + pushCodeByte ( OPCODE_HALT ) ; + checkUnresolvedSymbols () ; } @@ -389,6 +386,8 @@ { char c [ MAX_TOKEN ] ; + pslAddress jump_target = pushJump ( 0 ) ; + setCodeSymbol ( fn, next_code ) ; pslGetToken ( c ) ; @@ -425,6 +424,10 @@ pushConstant ( "0.0" ) ; pushReturn () ; + + code [ jump_target ] = next_code & 0xFF ; + code [ jump_target+1 ] = (next_code >> 8) & 0xFF ; + return TRUE ; } Index: pslLocal.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslLocal.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pslLocal.h 6 Sep 2002 13:50:51 -0000 1.8 +++ pslLocal.h 6 Sep 2002 15:07:44 -0000 1.9 @@ -93,6 +93,8 @@ typedef unsigned short pslAddress ; +extern int _pslInitialised ; + #include "pslSymbol.h" #include "pslContext.h" #include "pslParser.h" Index: pslProgram.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslProgram.cxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pslProgram.cxx 6 Sep 2002 13:50:51 -0000 1.4 +++ pslProgram.cxx 6 Sep 2002 15:07:44 -0000 1.5 @@ -26,6 +26,10 @@ pslProgram::pslProgram ( pslExtension *ext ) { + if ( ! _pslInitialised ) + ulSetError ( UL_FATAL, + "PSL: You didn't call pslInit() before using PSL functions." ) ; + code = new pslOpcode [ MAX_CODE ] ; extensions = ext ; |