[Plib-cvs] plib/src/psl psl.h,1.4,1.5 pslCodeGen.cxx,1.5,1.6 pslCompiler.cxx,1.3,1.4 pslDump.cxx,1.4
Brought to you by:
sjbaker
From: Sebastian U. <ud...@us...> - 2002-09-05 23:24:05
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv3919 Modified Files: psl.h pslCodeGen.cxx pslCompiler.cxx pslDump.cxx pslLocal.h pslProgram.cxx pslSymbols.cxx Log Message: Made PSL const-correct Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- psl.h 5 Sep 2002 22:22:38 -0000 1.4 +++ psl.h 5 Sep 2002 23:23:59 -0000 1.5 @@ -48,7 +48,7 @@ class PSL_Extension { public: - char *symbol ; + const char *symbol ; int argc ; PSL_Variable (*func) ( int, PSL_Variable *, PSL_Program *p ) ; } ; @@ -71,17 +71,17 @@ ~PSL_Program () ; - PSL_Context *getContext () { return context ; } - PSL_Opcode *getCode () { return code ; } - PSL_Parser *getParser () { return parser ; } - PSL_Extension *getExtensions () { return extensions ; } + PSL_Context *getContext () const { return context ; } + PSL_Opcode *getCode () const { return code ; } + PSL_Parser *getParser () const { return parser ; } + PSL_Extension *getExtensions () const { return extensions ; } - void *getUserData () { return userData ; } + void *getUserData () const { return userData ; } void setUserData ( void *ud ) { userData = ud ; } - void dump () ; - int parse ( char *fname ) ; - int parse ( FILE *fd ) ; + void dump () const ; + int parse ( const char *fname ) ; + int parse ( FILE *fd ) ; void reset () ; PSL_Result step () ; } ; Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pslCodeGen.cxx 5 Sep 2002 22:38:22 -0000 1.5 +++ pslCodeGen.cxx 5 Sep 2002 23:23:59 -0000 1.6 @@ -24,7 +24,7 @@ #include "pslLocal.h" -int PSL_Parser::parse ( char *fname ) +int PSL_Parser::parse ( const char *fname ) { init () ; @@ -77,14 +77,14 @@ pushCodeByte ( ff [ 3 ] ) ; } -void PSL_Parser::pushVariable ( char *c ) +void PSL_Parser::pushVariable ( const char *c ) { int a = getVarSymbol ( c ) ; pushCodeByte ( OPCODE_PUSH_VARIABLE | a ) ; } -void PSL_Parser::pushAssignment ( char *c ) +void PSL_Parser::pushAssignment ( const char *c ) { int a = getVarSymbol ( c ) ; @@ -92,7 +92,7 @@ } -void PSL_Parser::pushCall ( char *c, int argc ) +void PSL_Parser::pushCall ( const char *c, int argc ) { int ext = getExtensionSymbol ( c ) ; Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pslCompiler.cxx 5 Sep 2002 22:22:38 -0000 1.3 +++ pslCompiler.cxx 5 Sep 2002 23:23:59 -0000 1.4 @@ -132,7 +132,7 @@ } -int PSL_Parser::pushFunctionCall ( char *var ) +int PSL_Parser::pushFunctionCall ( const char *var ) { char c [ MAX_TOKEN ] ; @@ -179,7 +179,7 @@ } -int PSL_Parser::pushAssignmentStatement ( char *var ) +int PSL_Parser::pushAssignmentStatement ( const char *var ) { char c [ MAX_TOKEN ] ; @@ -317,7 +317,7 @@ -int PSL_Parser::pushGlobalVariableDeclaration ( char *s ) +int PSL_Parser::pushGlobalVariableDeclaration ( const char *s ) { char c [ MAX_TOKEN ] ; @@ -388,7 +388,7 @@ } -int PSL_Parser::pushFunctionDeclaration ( char *fn ) +int PSL_Parser::pushFunctionDeclaration ( const char *fn ) { char c [ MAX_TOKEN ] ; Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pslDump.cxx 5 Sep 2002 22:38:22 -0000 1.4 +++ pslDump.cxx 5 Sep 2002 23:23:59 -0000 1.5 @@ -33,7 +33,7 @@ -OpcodeDecode opcodeDecode [] = +static const OpcodeDecode opcodeDecode [] = { { "PUSH_CONSTANT", OPCODE_PUSH_CONSTANT }, { "CALL", OPCODE_CALL }, @@ -59,7 +59,7 @@ } ; -void PSL_Parser::print_opcode ( FILE *fd, unsigned char op ) +void PSL_Parser::print_opcode ( FILE *fd, unsigned char op ) const { if ( ( op & 0xF0 ) == OPCODE_PUSH_VARIABLE ) fprintf ( fd, " PUSH_VAR\t%s", symtab [ op & 0x0F ] . symbol ) ; @@ -76,7 +76,7 @@ } -void PSL_Parser::dump () +void PSL_Parser::dump () const { int i ; Index: pslLocal.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslLocal.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pslLocal.h 5 Sep 2002 22:38:22 -0000 1.5 +++ pslLocal.h 5 Sep 2002 23:23:59 -0000 1.6 @@ -184,9 +184,9 @@ int pushJump ( int l ) ; void pushConstant ( const char *c ) ; - void pushVariable ( char *c ) ; - void pushAssignment ( char *c ) ; - void pushCall ( char *c, int argc ) ; + void pushVariable ( const char *c ) ; + void pushAssignment ( const char *c ) ; + void pushCall ( const char *c, int argc ) ; void pushReturn () ; /* Higher level parsers. */ @@ -203,27 +203,27 @@ int pushPauseStatement () ; int pushWhileStatement () ; int pushIfStatement () ; - int pushFunctionCall ( char *c ) ; - int pushAssignmentStatement ( char *c ) ; + int pushFunctionCall ( const char *c ) ; + int pushAssignmentStatement ( const char *c ) ; int pushCompoundStatement () ; int pushStatement () ; - int pushFunctionDeclaration ( char *fn ) ; + int pushFunctionDeclaration ( const char *fn ) ; int pushLocalVariableDeclaration () ; - int pushGlobalVariableDeclaration ( char *fn ) ; + int pushGlobalVariableDeclaration ( const char *fn ) ; int pushStaticVariableDeclaration () ; int pushGlobalDeclaration () ; void pushProgram () ; - void print_opcode ( FILE *fd, unsigned char op ) ; + void print_opcode ( FILE *fd, unsigned char op ) const ; - PSL_Address getVarSymbol ( char *s ) ; - PSL_Address setVarSymbol ( char *s ) ; + PSL_Address getVarSymbol ( const char *s ) ; + PSL_Address setVarSymbol ( const char *s ) ; PSL_Address getCodeSymbol ( const char *s ) ; void setCodeSymbol ( const char *s, PSL_Address v ) ; - int getExtensionSymbol ( char *s ) ; + int getExtensionSymbol ( const char *s ) ; private: @@ -264,7 +264,7 @@ } } - PSL_Extension *getExtensions () { return extensions ; } + PSL_Extension *getExtensions () const { return extensions ; } void init () { @@ -282,8 +282,8 @@ next_var = 0 ; } - void dump () ; - int parse ( char *fname ) ; + void dump () const ; + int parse ( const char *fname ) ; int parse ( FILE *fd ) ; } ; Index: pslProgram.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslProgram.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pslProgram.cxx 5 Sep 2002 22:22:38 -0000 1.2 +++ pslProgram.cxx 5 Sep 2002 23:24:00 -0000 1.3 @@ -58,10 +58,17 @@ } -void PSL_Program::dump () { parser -> dump () ; } -int PSL_Program::parse ( char *fname ){ return parser -> parse(fname) ; } -int PSL_Program::parse ( FILE *fd ) { return parser -> parse( fd ) ; } +void PSL_Program::dump () const { parser -> dump () ; } +void PSL_Program::reset () { context -> reset () ; } +PSL_Result PSL_Program::step () { return context -> step () ; } -void PSL_Program::reset () { context -> reset () ; } -PSL_Result PSL_Program::step () { return context -> step () ; } +int PSL_Program::parse ( const char *fname ) +{ + return parser -> parse(fname) ; +} + +int PSL_Program::parse ( FILE *fd ) +{ + return parser -> parse( fd ) ; +} Index: pslSymbols.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslSymbols.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pslSymbols.cxx 5 Sep 2002 22:38:22 -0000 1.6 +++ pslSymbols.cxx 5 Sep 2002 23:24:00 -0000 1.7 @@ -25,7 +25,7 @@ #include "pslLocal.h" -PSL_Address PSL_Parser::setVarSymbol ( char *s ) +PSL_Address PSL_Parser::setVarSymbol ( const char *s ) { for ( int i = 0 ; i < next_var ; i++ ) if ( strcmp ( s, symtab [ i ] . symbol ) == 0 ) @@ -47,7 +47,7 @@ -PSL_Address PSL_Parser::getVarSymbol ( char *s ) +PSL_Address PSL_Parser::getVarSymbol ( const char *s ) { for ( int i = 0 ; i < next_var ; i++ ) if ( strcmp ( s, symtab [ i ] . symbol ) == 0 ) @@ -59,7 +59,7 @@ } -int PSL_Parser::getExtensionSymbol ( char *s ) +int PSL_Parser::getExtensionSymbol ( const char *s ) { for ( int i = 0 ; extensions [ i ] . symbol != NULL ; i++ ) if ( strcmp ( s, extensions [ i ] . symbol ) == 0 ) |