plib-cvs Mailing List for PLIB (Page 26)
Brought to you by:
sjbaker
You can subscribe to this list here.
2002 |
Jan
(25) |
Feb
(10) |
Mar
(60) |
Apr
(49) |
May
(54) |
Jun
(94) |
Jul
(82) |
Aug
(251) |
Sep
(366) |
Oct
(17) |
Nov
(20) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(12) |
Feb
(8) |
Mar
(2) |
Apr
(4) |
May
(5) |
Jun
(8) |
Jul
(23) |
Aug
(8) |
Sep
(7) |
Oct
(5) |
Nov
(20) |
Dec
(20) |
2004 |
Jan
(19) |
Feb
(70) |
Mar
(108) |
Apr
(24) |
May
(6) |
Jun
(5) |
Jul
|
Aug
(8) |
Sep
(18) |
Oct
(27) |
Nov
|
Dec
(13) |
2005 |
Jan
(19) |
Feb
(13) |
Mar
(1) |
Apr
|
May
(10) |
Jun
(1) |
Jul
(10) |
Aug
(5) |
Sep
(2) |
Oct
(2) |
Nov
(6) |
Dec
(4) |
2006 |
Jan
(9) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Steve B. <sj...@us...> - 2002-09-14 20:52:45
|
Update of /cvsroot/plib/plib/demos/simon/src In directory usw-pr-cvs1:/tmp/cvs-serv22648/plib/demos/simon/src Modified Files: Makefile simon.cxx Added Files: simon_api.cxx Log Message: Fixed bug in PSL expression handler. --- NEW FILE: simon_api.cxx --- #include "simon.h" #include <plib/js.h> class siEntity ; static int siNextModel = 0 ; static bool siInitialised = false ; static ssgRoot *siScene = NULL ; static siEntity *siModels [ SI_MAX_MODELS ] ; class siEntity { protected: int handle ; char *name ; sgCoord pos ; sgCoord vel ; [...302 lines suppressed...] int siLoad ( char *filename ) { if ( ! siInitialised ) siInit () ; siModel *m = new siModel ( filename ) ; return m -> getHandle () ; } void siRun () { if ( ! siInitialised ) siInit () ; glutMainLoop () ; } Index: Makefile =================================================================== RCS file: /cvsroot/plib/plib/demos/simon/src/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile 14 Sep 2002 19:50:29 -0000 1.1 +++ Makefile 14 Sep 2002 20:52:42 -0000 1.2 @@ -1,21 +1,28 @@ -SIMON = libsimon.a +SIMON = libsimon.a simon +LIBS = -lplibpsl -lplibssg -lplibsg -lplibul -lglut -lGLU -lGL -lpthread -L/usr/X11/lib -lX11 -lm all: ${SIMON} +simon : libsimon.a simon.o /usr/lib/libplibpsl.a + g++ -o simon simon.o libsimon.a ${LIBS} + simon.o : simon.cxx simon.h - g++ -o simon.o -c simon.cxx + g++ -I. -o simon.o -c simon.cxx -libsimon.a : simon.o - ar cru libsimon.a simon.o +simon_api.o : simon_api.cxx simon.h + g++ -o simon_api.o -c simon_api.cxx + +libsimon.a : simon_api.o + ar cru libsimon.a simon_api.o -install: libsimon.a simon.h +install: libsimon.a simon.h simon mkdir -p /usr/local/simon - cp libsimon.a simon.h /usr/local/simon + cp simon libsimon.a simon.h /usr/local/simon uninstall: rm -r /usr/local/simon clean: - rm -f libsimon.a *.o + rm -f simon libsimon.a *.o Index: simon.cxx =================================================================== RCS file: /cvsroot/plib/plib/demos/simon/src/simon.cxx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- simon.cxx 14 Sep 2002 19:50:29 -0000 1.1 +++ simon.cxx 14 Sep 2002 20:52:42 -0000 1.2 @@ -1,341 +1,90 @@ -#include "simon.h" -#include <plib/js.h> - -class siEntity ; - -static int siNextModel = 0 ; -static bool siInitialised = false ; -static ssgRoot *siScene = NULL ; -static siEntity *siModels [ SI_MAX_MODELS ] ; - [...361 lines suppressed...] - return m -> getHandle () ; -} + pslResult res ; + do + { + res = prog -> step () ; -void siRun () -{ - if ( ! siInitialised ) - siInit () ; + } while ( res == PSL_PROGRAM_CONTINUE ) ; - glutMainLoop () ; + if ( res == PSL_PROGRAM_END ) + exit ( 0 ) ; } + |
From: Steve B. <sj...@us...> - 2002-09-14 19:50:32
|
Update of /cvsroot/plib/plib/demos/simon/src In directory usw-pr-cvs1:/tmp/cvs-serv6726/plib/demos/simon/src Added Files: Makefile simon.cxx simon.h Log Message: Added SIMON - a *very* simple 3D programming framework. --- NEW FILE: Makefile --- SIMON = libsimon.a all: ${SIMON} simon.o : simon.cxx simon.h g++ -o simon.o -c simon.cxx libsimon.a : simon.o ar cru libsimon.a simon.o install: libsimon.a simon.h mkdir -p /usr/local/simon cp libsimon.a simon.h /usr/local/simon uninstall: rm -r /usr/local/simon clean: rm -f libsimon.a *.o --- NEW FILE: simon.cxx --- #include "simon.h" #include <plib/js.h> class siEntity ; static int siNextModel = 0 ; static bool siInitialised = false ; static ssgRoot *siScene = NULL ; static siEntity *siModels [ SI_MAX_MODELS ] ; class siEntity { protected: int handle ; char *name ; sgCoord pos ; sgCoord vel ; [...302 lines suppressed...] int siLoad ( char *filename ) { if ( ! siInitialised ) siInit () ; siModel *m = new siModel ( filename ) ; return m -> getHandle () ; } void siRun () { if ( ! siInitialised ) siInit () ; glutMainLoop () ; } --- NEW FILE: simon.h --- #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #ifdef WIN32 #include <windows.h> #else #include <unistd.h> #endif #include <math.h> #include <plib/ssg.h> #include <GL/glut.h> #define SI_MAX_MODELS 500 void siUpdate () ; void siRun () ; int siLoad ( char *filename ) ; void siPosition ( int hh, float x, float y, float z = 0.0f, float h = 0.0f, float p = 0.0f, float r = 0.0f ) ; void siSpeedAndDirection ( int hh, float s, float h, float p = 0.0f ) ; void siVelocity ( int hh, float x, float y, float z = 0.0f, float h = 0.0f, float p = 0.0f, float r = 0.0f ) ; float siGetPositionX ( int h ) ; float siGetPositionY ( int h ) ; float siGetPositionZ ( int h ) ; float siGetPositionH ( int h ) ; float siGetPositionP ( int h ) ; float siGetPositionR ( int h ) ; float siJoystickLR () ; float siJoystickUD () ; bool siJoystickA () ; bool siJoystickB () ; bool siJoystickC () ; bool siJoystickD () ; bool siJoystickL () ; bool siJoystickR () ; |
From: Steve B. <sj...@us...> - 2002-09-14 19:50:32
|
Update of /cvsroot/plib/plib/demos/simon/doc In directory usw-pr-cvs1:/tmp/cvs-serv6726/plib/demos/simon/doc Added Files: index.html Log Message: Added SIMON - a *very* simple 3D programming framework. --- NEW FILE: index.html --- <TITLE>WELCOME TO S.I.M.O.N</TITLE> <H1>WELCOME TO S.I.M.O.N</H1> <center>by Steve Baker</center> SIMON stands for: <pre> Simple Interface for Making Oliver's programs Nice. </pre> This is a simple set of functions that hide much of the nastiness of 3D programming to make it possible for someone with only the very minimum of programming experience to write simple 3D applications. <p> [...209 lines suppressed...] TARGETS = test1 #======================== DON'T CHANGE THIS PART ============================= # SIMONDIR = /usr/local/simon SIMON = -I${SIMONDIR} -L${SIMONDIR} LIBS = -lsimon -lplibssg -lplibsg -lglut -lGLU -lGL -L/usr/X11/lib -lX11 -lm all: ${TARGETS} #============================================================================= # # Copy this for every program you want to write - changing 'test1' # to whatever your program is called. # test1 : test1.cxx ; g++ ${SIMON} -o test1 test1.cxx ${LIBS} </pre> |
From: Steve B. <sj...@us...> - 2002-09-14 19:50:32
|
Update of /cvsroot/plib/plib/demos/simon In directory usw-pr-cvs1:/tmp/cvs-serv6726/plib/demos/simon Added Files: Makefile README Log Message: Added SIMON - a *very* simple 3D programming framework. --- NEW FILE: Makefile --- all: (cd src ; make) install: (cd src ; make install) uninstall: (cd src ; make uninstall) clean: (cd src ; make clean) --- NEW FILE: README --- WELCOME TO S.I.M.O.N ==================== Which stands for: Simple Interface for Making Oliver's programs Nice. This is a simple set of functions that hide much of the nastiness of 3D programming to make it possible for someone with only the very minimum of programming experience to write simple 3D applications. Right now, you build SIMON by running 'make' and install it by running 'make install' as root. You must already have PLIB installed. |
From: Steve B. <sj...@us...> - 2002-09-14 19:49:09
|
Update of /cvsroot/plib/plib/demos/simon/src In directory usw-pr-cvs1:/tmp/cvs-serv6542/src Log Message: Directory /cvsroot/plib/plib/demos/simon/src added to the repository |
From: Steve B. <sj...@us...> - 2002-09-14 19:49:09
|
Update of /cvsroot/plib/plib/demos/simon/doc In directory usw-pr-cvs1:/tmp/cvs-serv6542/doc Log Message: Directory /cvsroot/plib/plib/demos/simon/doc added to the repository |
From: Steve B. <sj...@us...> - 2002-09-14 19:48:51
|
Update of /cvsroot/plib/plib/demos/simon In directory usw-pr-cvs1:/tmp/cvs-serv6444/simon Log Message: Directory /cvsroot/plib/plib/demos/simon added to the repository |
From: Sebastian U. <ud...@us...> - 2002-09-14 15:47:37
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv2657 Modified Files: psl.h pslCodeGen.cxx Log Message: Fixed some compiler warnings with ICC Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- psl.h 14 Sep 2002 06:23:27 -0000 1.15 +++ psl.h 14 Sep 2002 15:47:33 -0000 1.16 @@ -87,7 +87,7 @@ { case PSL_INT : return i ; case PSL_FLOAT : return (int) f ; - case PSL_STRING : return strtol(s,NULL,0) ; + case PSL_STRING : return (int) strtol(s,NULL,0) ; case PSL_VOID : return 0 ; } return 0 ; @@ -185,7 +185,7 @@ { switch ( t ) { - case PSL_INT : i = strtol ( v, NULL, 0 ) ; return ; + case PSL_INT : i = (int) strtol ( v, NULL, 0 ) ; return ; case PSL_FLOAT : f = (float) atof ( v ) ; return ; case PSL_STRING : delete [] s ; s = ulStrDup ( v ) ; Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- pslCodeGen.cxx 14 Sep 2002 06:23:27 -0000 1.22 +++ pslCodeGen.cxx 14 Sep 2002 15:47:33 -0000 1.23 @@ -80,7 +80,7 @@ void pslCompiler::pushIntConstant ( const char *c ) { - int i = strtol ( c, NULL, 0 ) ; + int i = (int) strtol ( c, NULL, 0 ) ; pushIntConstant ( i ) ; } |
From: Steve B. <sj...@us...> - 2002-09-14 06:23:30
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv9092/plib/examples/src/psl/data Modified Files: test.psl Log Message: Added Hex & Octal constants Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- test.psl 14 Sep 2002 06:12:32 -0000 1.23 +++ test.psl 14 Sep 2002 06:23:27 -0000 1.24 @@ -2,10 +2,7 @@ void main () { - for ( int i = 0 ; i < 10 ; i++ ) + for ( int i = 0 ; i < 0x10 ; i++ ) printf ( "Hello ", i, "\n" ) ; - - for ( int i = 0 ; i < 10 ; i++ ) - printf ( "Hello Again", i, "\n" ) ; } |
From: Steve B. <sj...@us...> - 2002-09-14 06:23:30
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv9092/plib/src/psl Modified Files: psl.h pslCodeGen.cxx Log Message: Added Hex & Octal constants Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- psl.h 13 Sep 2002 17:37:26 -0000 1.14 +++ psl.h 14 Sep 2002 06:23:27 -0000 1.15 @@ -87,7 +87,7 @@ { case PSL_INT : return i ; case PSL_FLOAT : return (int) f ; - case PSL_STRING : return atoi(s) ; + case PSL_STRING : return strtol(s,NULL,0) ; case PSL_VOID : return 0 ; } return 0 ; @@ -185,7 +185,7 @@ { switch ( t ) { - case PSL_INT : i = atoi ( v ) ; return ; + case PSL_INT : i = strtol ( v, NULL, 0 ) ; return ; case PSL_FLOAT : f = (float) atof ( v ) ; return ; case PSL_STRING : delete [] s ; s = ulStrDup ( v ) ; Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- pslCodeGen.cxx 14 Sep 2002 06:12:32 -0000 1.21 +++ pslCodeGen.cxx 14 Sep 2002 06:23:27 -0000 1.22 @@ -80,7 +80,7 @@ void pslCompiler::pushIntConstant ( const char *c ) { - int i = atoi ( c ) ; + int i = strtol ( c, NULL, 0 ) ; pushIntConstant ( i ) ; } |
From: Steve B. <sj...@us...> - 2002-09-14 06:23:30
|
Update of /cvsroot/plib/plib/doc/psl In directory usw-pr-cvs1:/tmp/cvs-serv9092/plib/doc/psl Modified Files: prog_guide.html Log Message: Added Hex & Octal constants Index: prog_guide.html =================================================================== RCS file: /cvsroot/plib/plib/doc/psl/prog_guide.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- prog_guide.html 14 Sep 2002 04:59:32 -0000 1.7 +++ prog_guide.html 14 Sep 2002 06:23:27 -0000 1.8 @@ -100,7 +100,6 @@ <li> C++ style '//' comments. <li> C++ style local variable declarations. </ul> - Some features of C are NOT IMPLEMENTED in PSL: <ul> <li> Pointers. @@ -125,9 +124,7 @@ hopefully arrive soon: <ul> <li> Logic operators "&&", "||". - <li> "++" and "--" <li> Character constants. - <li> Hex and octal constants. <li> Arrays & Structs. <li> Operations on "string" variables. <li> String concatenation. @@ -137,6 +134,24 @@ <li> Many of C's standard library functions are needed. </ul> +<H1> Compatibility Notes: </H1> +<H3> C++ style local variables. </H3> +With PSL's C++ style locals, you can say things like this: +<pre> + + for ( int i = 0 ; i < 10 ; i++ ) /* Do something */ ; + +</pre> +In standard C++, the scope of the variable 'i' is from it's +declaration to the end of the 'for' loop. However, Microsoft's +Visual C++ uses an obsolete version of the C++ standard that +allows the scope of 'i' to continue to the end of the block +that contains the for loop. So: +<p> +WINDOWS USERS BEWARE: PSL IMPLEMENTS THIS CORRECTLY - *NOT* LIKE +MSVC. + +<H3>Hard Limits</H3> Currently there are hard limits in many places - the number of variables, the size of the program, the depth of nesting, etc. These limits will gradually be removed as PSL is developed. |
From: Steve B. <sj...@us...> - 2002-09-14 06:12:37
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv6107/plib/src/psl Modified Files: pslCodeGen.cxx pslCompiler.cxx pslCompiler.h pslContext.cxx pslDump.cxx pslExpression.cxx pslOpcodes.h Log Message: Implemented ++ and -- Fixed locality of variables declared in 'for' loop scope. Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- pslCodeGen.cxx 14 Sep 2002 05:32:16 -0000 1.20 +++ pslCodeGen.cxx 14 Sep 2002 06:12:32 -0000 1.21 @@ -103,6 +103,22 @@ pushCodeByte ( argpos ) ; } +void pslCompiler::pushIncrement ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_INCREMENT ) ; + pushCodeByte ( a ) ; +} + +void pslCompiler::pushDecrement ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_DECREMENT ) ; + pushCodeByte ( a ) ; +} + void pslCompiler::makeIntVariable ( const char *c ) { int a = getVarSymbol ( c ) ; Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- pslCompiler.cxx 14 Sep 2002 05:32:16 -0000 1.20 +++ pslCompiler.cxx 14 Sep 2002 06:12:32 -0000 1.21 @@ -290,21 +290,31 @@ { char c [ MAX_TOKEN ] ; + pushLocality () ; pushBreakToLabel () ; int ct_lab = pushContinueToLabel () ; getToken ( c ) ; /* The initial '(' of the action */ if ( c [ 0 ] != '(' ) + { [...72 lines suppressed...] @@ -499,7 +522,9 @@ strcmp ( c, ">>=" ) != 0 ) { ungetToken ( c ) ; - pushFunctionCall ( var ) ; + ungetToken ( var ) ; + // pushFunctionCall ( var ) ; + pushExpression () ; pushPop () ; return TRUE ; } @@ -576,6 +601,8 @@ if ( strcmp ( c, "switch" ) == 0 ) return pushSwitchStatement () ; if ( strcmp ( c, "while" ) == 0 ) return pushWhileStatement () ; if ( strcmp ( c, "if" ) == 0 ) return pushIfStatement () ; + if ( strcmp ( c, "++" ) == 0 ) return pushAssignmentStatement ( c ) ; + if ( strcmp ( c, "--" ) == 0 ) return pushAssignmentStatement ( c ) ; if ( isalnum ( c [ 0 ] ) ) return pushAssignmentStatement ( c ) ; if ( c [ 0 ] == '{' ) return pushCompoundStatement () ; Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- pslCompiler.h 14 Sep 2002 05:32:16 -0000 1.22 +++ pslCompiler.h 14 Sep 2002 06:12:32 -0000 1.23 @@ -104,6 +104,9 @@ void pushGetParameter ( pslAddress var, int argpos ) ; + void pushIncrement ( const char *s ) ; + void pushDecrement ( const char *s ) ; + void makeIntVariable ( const char *s ) ; void makeFloatVariable ( const char *s ) ; void makeStringVariable( const char *s ) ; Index: pslContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.cxx,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- pslContext.cxx 14 Sep 2002 05:32:16 -0000 1.11 +++ pslContext.cxx 14 Sep 2002 06:12:32 -0000 1.12 @@ -607,6 +607,32 @@ return PSL_PROGRAM_CONTINUE ; + case OPCODE_DECREMENT : + { + pslVariable *v = & ( variable [ code[++pc] ] ) ; + + if ( v -> getType () == PSL_INT ) + v -> set ( v -> getInt () - 1 ) ; + else + v -> set ( v -> getFloat () - 1 ) ; + + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_INCREMENT : + { + pslVariable *v = & ( variable [ code[++pc] ] ) ; + + if ( v -> getType () == PSL_INT ) + v -> set ( v -> getInt () + 1 ) ; + else + v -> set ( v -> getFloat () + 1 ) ; + + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + case OPCODE_SET_INT_VARIABLE : variable [ code[++pc] ] . setType ( PSL_INT ) ; pc++ ; Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- pslDump.cxx 14 Sep 2002 05:32:16 -0000 1.17 +++ pslDump.cxx 14 Sep 2002 06:12:32 -0000 1.18 @@ -57,6 +57,9 @@ { "SET_STRING_VARIABLE", OPCODE_SET_STRING_VARIABLE, 1 }, { "GET_PARAMETER" , OPCODE_GET_PARAMETER , 2 }, + { "INC" , OPCODE_INCREMENT , 1 }, + { "DEC" , OPCODE_DECREMENT , 1 }, + /* Flow Control */ { "CALLEXT", OPCODE_CALLEXT , 2 }, @@ -221,6 +224,8 @@ case OPCODE_POP_SHL_VARIABLE : case OPCODE_POP_SHR_VARIABLE : case OPCODE_POP_VARIABLE : + case OPCODE_INCREMENT : + case OPCODE_DECREMENT : fprintf ( fd, "\t[%d]", code [ addr+1 ] ) ; break ; Index: pslExpression.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslExpression.cxx,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- pslExpression.cxx 14 Sep 2002 01:30:05 -0000 1.11 +++ pslExpression.cxx 14 Sep 2002 06:12:32 -0000 1.12 @@ -114,6 +114,21 @@ return TRUE ; } + int preInc = FALSE ; + int preDec = FALSE ; + + if ( strcmp ( c, "++" ) == 0 ) + { + preInc = TRUE ; + getToken ( c ) ; + } + else + if ( strcmp ( c, "--" ) == 0 ) + { + preDec = TRUE ; + getToken ( c ) ; + } + if ( isalpha ( c [ 0 ] ) || c [ 0 ] == '_' ) { char n [ MAX_TOKEN ] ; @@ -121,9 +136,25 @@ ungetToken ( n ) ; if ( n[0] == '(' ) + { + if ( preInc || preDec ) + error ( "You can't apply '++' or '--' to a function call!" ) ; + pushFunctionCall ( c ) ; + } else + { + if ( preInc ) pushIncrement ( c ) ; + if ( preDec ) pushDecrement ( c ) ; + pushVariable ( c ) ; + + getToken ( n ) ; + + if ( strcmp ( n, "++" ) == 0 ) pushIncrement ( c ) ; else + if ( strcmp ( n, "--" ) == 0 ) pushDecrement ( c ) ; else + ungetToken ( n ) ; + } return TRUE ; } Index: pslOpcodes.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslOpcodes.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pslOpcodes.h 14 Sep 2002 05:32:16 -0000 1.9 +++ pslOpcodes.h 14 Sep 2002 06:12:33 -0000 1.10 @@ -67,6 +67,8 @@ #define OPCODE_SET_STRING_VARIABLE 0x26 #define OPCODE_STACK_DUPLICATE 0x27 #define OPCODE_GET_PARAMETER 0x28 +#define OPCODE_INCREMENT 0x29 +#define OPCODE_DECREMENT 0x2A #define OPCODE_POP_ADD_VARIABLE 0x30 #define OPCODE_POP_SUB_VARIABLE 0x31 |
From: Steve B. <sj...@us...> - 2002-09-14 06:12:37
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv6107/plib/examples/src/psl/data Modified Files: test.psl Log Message: Implemented ++ and -- Fixed locality of variables declared in 'for' loop scope. Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- test.psl 14 Sep 2002 05:32:16 -0000 1.22 +++ test.psl 14 Sep 2002 06:12:32 -0000 1.23 @@ -2,12 +2,10 @@ void main () { - int x = 1 ; + for ( int i = 0 ; i < 10 ; i++ ) + printf ( "Hello ", i, "\n" ) ; - x += 11 ; printf ( "12 ", x ) ; - x %= 0 ; printf ( "24 ", x ) ; - x /= 6 ; printf ( "4 ", x ) ; - x <<= 1 ; printf ( "8 ", x ) ; - x >>= 1 ; printf ( "4 ", x ) ; + for ( int i = 0 ; i < 10 ; i++ ) + printf ( "Hello Again", i, "\n" ) ; } |
From: Steve B. <sj...@us...> - 2002-09-14 05:32:19
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv30751/plib/examples/src/psl/data Modified Files: test.psl Log Message: Added missing '%=' assignment operator. Added error checks for '/= 0' or '%= 0' or floating point '%='. Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- test.psl 14 Sep 2002 04:45:54 -0000 1.21 +++ test.psl 14 Sep 2002 05:32:16 -0000 1.22 @@ -5,7 +5,7 @@ int x = 1 ; x += 11 ; printf ( "12 ", x ) ; - x *= 2 ; printf ( "24 ", x ) ; + x %= 0 ; printf ( "24 ", x ) ; x /= 6 ; printf ( "4 ", x ) ; x <<= 1 ; printf ( "8 ", x ) ; x >>= 1 ; printf ( "4 ", x ) ; |
From: Steve B. <sj...@us...> - 2002-09-14 05:32:19
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv30751/plib/src/psl Modified Files: pslCodeGen.cxx pslCompiler.cxx pslCompiler.h pslContext.cxx pslDump.cxx pslOpcodes.h Log Message: Added missing '%=' assignment operator. Added error checks for '/= 0' or '%= 0' or floating point '%='. Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- pslCodeGen.cxx 14 Sep 2002 04:45:54 -0000 1.19 +++ pslCodeGen.cxx 14 Sep 2002 05:32:16 -0000 1.20 @@ -170,6 +170,15 @@ } +void pslCompiler::pushModAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_MOD_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + void pslCompiler::pushDivAssignment ( const char *c ) { int a = getVarSymbol ( c ) ; Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- pslCompiler.cxx 14 Sep 2002 04:45:55 -0000 1.19 +++ pslCompiler.cxx 14 Sep 2002 05:32:16 -0000 1.20 @@ -491,15 +491,11 @@ getToken ( c ) ; - if ( strcmp ( c, "=" ) != 0 && - strcmp ( c, "+=" ) != 0 && - strcmp ( c, "-=" ) != 0 && - strcmp ( c, "/=" ) != 0 && - strcmp ( c, "*=" ) != 0 && - strcmp ( c, "&=" ) != 0 && - strcmp ( c, "|=" ) != 0 && - strcmp ( c, "^=" ) != 0 && - strcmp ( c, "<<=" ) != 0 && + if ( strcmp ( c, "=" ) != 0 && strcmp ( c, "+=" ) != 0 && + strcmp ( c, "-=" ) != 0 && strcmp ( c, "/=" ) != 0 && + strcmp ( c, "*=" ) != 0 && strcmp ( c, "%=" ) != 0 && + strcmp ( c, "&=" ) != 0 && strcmp ( c, "|=" ) != 0 && + strcmp ( c, "^=" ) != 0 && strcmp ( c, "<<=" ) != 0 && strcmp ( c, ">>=" ) != 0 ) { ungetToken ( c ) ; @@ -514,6 +510,7 @@ if ( strcmp ( c, "+=" ) == 0 ) pushAddAssignment ( var ) ; else if ( strcmp ( c, "-=" ) == 0 ) pushSubAssignment ( var ) ; else if ( strcmp ( c, "*=" ) == 0 ) pushMulAssignment ( var ) ; else + if ( strcmp ( c, "%=" ) == 0 ) pushModAssignment ( var ) ; else if ( strcmp ( c, "/=" ) == 0 ) pushDivAssignment ( var ) ; else if ( strcmp ( c, "&=" ) == 0 ) pushAndAssignment ( var ) ; else if ( strcmp ( c, "|=" ) == 0 ) pushOrAssignment ( var ) ; else Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- pslCompiler.h 14 Sep 2002 04:45:55 -0000 1.21 +++ pslCompiler.h 14 Sep 2002 05:32:16 -0000 1.22 @@ -121,6 +121,7 @@ void pushAddAssignment ( const char *s ) ; void pushSubAssignment ( const char *s ) ; void pushMulAssignment ( const char *s ) ; + void pushModAssignment ( const char *s ) ; void pushDivAssignment ( const char *s ) ; void pushAndAssignment ( const char *s ) ; void pushOrAssignment ( const char *s ) ; Index: pslContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.cxx,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pslContext.cxx 14 Sep 2002 04:45:55 -0000 1.10 +++ pslContext.cxx 14 Sep 2002 05:32:16 -0000 1.11 @@ -506,14 +506,46 @@ return PSL_PROGRAM_CONTINUE ; + case OPCODE_POP_MOD_VARIABLE : + { + pslVariable *v = & ( variable [ code[++pc] ] ) ; + pslValue *vv = & stack[--sp] ; + + if ( v -> getType () == PSL_INT ) + { + if ( vv -> getInt () != 0 ) + v -> set ( v -> getInt() % vv->getInt()) ; + else + warning ( "Integer Modulo by Zero!" ) ; + } + else + warning ( "Floating Point Modulo!" ) ; + + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + + case OPCODE_POP_DIV_VARIABLE : { pslVariable *v = & ( variable [ code[++pc] ] ) ; + pslValue *vv = & stack[--sp] ; if ( v -> getType () == PSL_INT ) - v -> set ( v -> getInt() / stack[--sp].getInt()) ; + { + if ( vv -> getInt () != 0 ) + v -> set ( v -> getInt() / vv->getInt()) ; + else + warning ( "Integer Divide by Zero!" ) ; + } else - v -> set ( v -> getFloat() / stack[--sp].getFloat()) ; + { + if ( vv -> getFloat () != 0.0f ) + v -> set ( v -> getFloat() / vv->getFloat()) ; + else + warning ( "Floating Point Divide by Zero!" ) ; + } pc++ ; } return PSL_PROGRAM_CONTINUE ; Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pslDump.cxx 14 Sep 2002 04:45:55 -0000 1.16 +++ pslDump.cxx 14 Sep 2002 05:32:16 -0000 1.17 @@ -103,6 +103,7 @@ { "POP_ADD_VARIABLE", OPCODE_POP_ADD_VARIABLE, 1 }, { "POP_SUB_VARIABLE", OPCODE_POP_SUB_VARIABLE, 1 }, { "POP_MUL_VARIABLE", OPCODE_POP_MUL_VARIABLE, 1 }, + { "POP_MOD_VARIABLE", OPCODE_POP_MOD_VARIABLE, 1 }, { "POP_DIV_VARIABLE", OPCODE_POP_DIV_VARIABLE, 1 }, { "POP_AND_VARIABLE", OPCODE_POP_AND_VARIABLE, 1 }, { "POP_OR_VARIABLE" , OPCODE_POP_OR_VARIABLE , 1 }, Index: pslOpcodes.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslOpcodes.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pslOpcodes.h 14 Sep 2002 04:45:55 -0000 1.8 +++ pslOpcodes.h 14 Sep 2002 05:32:16 -0000 1.9 @@ -71,10 +71,11 @@ #define OPCODE_POP_ADD_VARIABLE 0x30 #define OPCODE_POP_SUB_VARIABLE 0x31 #define OPCODE_POP_MUL_VARIABLE 0x32 -#define OPCODE_POP_DIV_VARIABLE 0x33 -#define OPCODE_POP_AND_VARIABLE 0x34 -#define OPCODE_POP_OR_VARIABLE 0x35 -#define OPCODE_POP_XOR_VARIABLE 0x36 -#define OPCODE_POP_SHL_VARIABLE 0x37 -#define OPCODE_POP_SHR_VARIABLE 0x38 +#define OPCODE_POP_MOD_VARIABLE 0x33 +#define OPCODE_POP_DIV_VARIABLE 0x34 +#define OPCODE_POP_AND_VARIABLE 0x35 +#define OPCODE_POP_OR_VARIABLE 0x36 +#define OPCODE_POP_XOR_VARIABLE 0x37 +#define OPCODE_POP_SHL_VARIABLE 0x38 +#define OPCODE_POP_SHR_VARIABLE 0x39 |
From: Steve B. <sj...@us...> - 2002-09-14 04:59:35
|
Update of /cvsroot/plib/plib/doc/psl In directory usw-pr-cvs1:/tmp/cvs-serv20971/plib/doc/psl Modified Files: prog_guide.html Log Message: Fixed a couple of errors. Index: prog_guide.html =================================================================== RCS file: /cvsroot/plib/plib/doc/psl/prog_guide.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- prog_guide.html 14 Sep 2002 04:45:54 -0000 1.6 +++ prog_guide.html 14 Sep 2002 04:59:32 -0000 1.7 @@ -107,7 +107,7 @@ <li> Casts. <li> Dynamic Memory Allocation. <li> ',' and '?:' operators in expressions. - <li> "static", "automatic". + <li> "static", "auto" and "register" storage class reserved words. <li> "char", "short", "unsigned", "signed", "long", "double". <li> "typedef" <li> "enum", "union", bitfields. |
From: Steve B. <sj...@us...> - 2002-09-14 04:45:58
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv18820/plib/examples/src/psl/data Modified Files: test.psl Log Message: Added +=, -=, *=, /=, &=, |=, %=, <<= and >>= Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- test.psl 14 Sep 2002 01:30:05 -0000 1.20 +++ test.psl 14 Sep 2002 04:45:54 -0000 1.21 @@ -1,15 +1,13 @@ -void xxx ( int a, float b, string c ) -{ - printf ( "Hello", a, b, c, "\n" ) ; - printf ( " ", 2 << 2 | 1 ) ; - printf ( " ", 2 << 2 + 1 ) ; -} - void main () { - xxx ( 1234, 567.89, "Weee!!!" ) ; - xxx ( 9876, 543.21, "AGAIN!!!" ) ; + int x = 1 ; + + x += 11 ; printf ( "12 ", x ) ; + x *= 2 ; printf ( "24 ", x ) ; + x /= 6 ; printf ( "4 ", x ) ; + x <<= 1 ; printf ( "8 ", x ) ; + x >>= 1 ; printf ( "4 ", x ) ; } |
From: Steve B. <sj...@us...> - 2002-09-14 04:45:58
|
Update of /cvsroot/plib/plib/doc/psl In directory usw-pr-cvs1:/tmp/cvs-serv18820/plib/doc/psl Modified Files: prog_guide.html Log Message: Added +=, -=, *=, /=, &=, |=, %=, <<= and >>= Index: prog_guide.html =================================================================== RCS file: /cvsroot/plib/plib/doc/psl/prog_guide.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- prog_guide.html 13 Sep 2002 23:51:28 -0000 1.5 +++ prog_guide.html 14 Sep 2002 04:45:54 -0000 1.6 @@ -121,13 +121,11 @@ preceded with whitespace. </ul> -The following feature are "NOT IMPLEMENTED YET" - but will +The following features are "NOT IMPLEMENTED YET" - but will hopefully arrive soon: <ul> - <li> Assignment operators "+=", "-=", etc. <li> Logic operators "&&", "||". <li> "++" and "--" - <li> ">>" and "<<" <li> Character constants. <li> Hex and octal constants. <li> Arrays & Structs. |
From: Steve B. <sj...@us...> - 2002-09-14 04:45:58
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv18820/plib/src/psl Modified Files: pslCodeGen.cxx pslCompiler.cxx pslCompiler.h pslContext.cxx pslDump.cxx pslOpcodes.h pslToken.cxx Log Message: Added +=, -=, *=, /=, &=, |=, %=, <<= and >>= Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- pslCodeGen.cxx 14 Sep 2002 01:30:05 -0000 1.18 +++ pslCodeGen.cxx 14 Sep 2002 04:45:54 -0000 1.19 @@ -143,6 +143,86 @@ pushCodeByte ( a ) ; } +void pslCompiler::pushAddAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_ADD_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushSubAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_SUB_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushMulAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_MUL_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushDivAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_DIV_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushAndAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_AND_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushOrAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_OR_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushXorAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_XOR_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushSHLAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_SHL_VARIABLE ) ; + pushCodeByte ( a ) ; +} + + +void pslCompiler::pushSHRAssignment ( const char *c ) +{ + int a = getVarSymbol ( c ) ; + + pushCodeByte ( OPCODE_POP_SHR_VARIABLE ) ; + pushCodeByte ( a ) ; +} + void pslCompiler::pushCall ( const char *c, int argc ) { Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- pslCompiler.cxx 13 Sep 2002 22:32:15 -0000 1.18 +++ pslCompiler.cxx 14 Sep 2002 04:45:55 -0000 1.19 @@ -491,7 +491,16 @@ getToken ( c ) ; - if ( c [ 0 ] != '=' ) + if ( strcmp ( c, "=" ) != 0 && + strcmp ( c, "+=" ) != 0 && + strcmp ( c, "-=" ) != 0 && + strcmp ( c, "/=" ) != 0 && + strcmp ( c, "*=" ) != 0 && + strcmp ( c, "&=" ) != 0 && + strcmp ( c, "|=" ) != 0 && + strcmp ( c, "^=" ) != 0 && + strcmp ( c, "<<=" ) != 0 && + strcmp ( c, ">>=" ) != 0 ) { ungetToken ( c ) ; pushFunctionCall ( var ) ; @@ -501,7 +510,17 @@ if ( pushExpression () ) { - pushAssignment ( var ) ; + if ( strcmp ( c, "=" ) == 0 ) pushAssignment ( var ) ; else + if ( strcmp ( c, "+=" ) == 0 ) pushAddAssignment ( var ) ; else + if ( strcmp ( c, "-=" ) == 0 ) pushSubAssignment ( var ) ; else + if ( strcmp ( c, "*=" ) == 0 ) pushMulAssignment ( var ) ; else + if ( strcmp ( c, "/=" ) == 0 ) pushDivAssignment ( var ) ; else + if ( strcmp ( c, "&=" ) == 0 ) pushAndAssignment ( var ) ; else + if ( strcmp ( c, "|=" ) == 0 ) pushOrAssignment ( var ) ; else + if ( strcmp ( c, "^=" ) == 0 ) pushXorAssignment ( var ) ; else + if ( strcmp ( c, "<<=" ) == 0 ) pushSHLAssignment ( var ) ; else + if ( strcmp ( c, ">>=" ) == 0 ) pushSHRAssignment ( var ) ; + return TRUE ; } @@ -560,7 +579,7 @@ if ( strcmp ( c, "switch" ) == 0 ) return pushSwitchStatement () ; if ( strcmp ( c, "while" ) == 0 ) return pushWhileStatement () ; if ( strcmp ( c, "if" ) == 0 ) return pushIfStatement () ; - if ( isalnum ( c [ 0 ] ) ) return pushAssignmentStatement(c); + if ( isalnum ( c [ 0 ] ) ) return pushAssignmentStatement ( c ) ; if ( c [ 0 ] == '{' ) return pushCompoundStatement () ; if ( strcmp ( c, "case" ) == 0 || strcmp ( c, "default" ) == 0 ) @@ -622,7 +641,7 @@ getToken ( c ) ; - if ( c[0] == '=' ) + if ( strcmp ( c, "=" ) == 0 ) { ungetToken ( c ) ; pushAssignmentStatement ( s ) ; Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- pslCompiler.h 14 Sep 2002 01:30:05 -0000 1.20 +++ pslCompiler.h 14 Sep 2002 04:45:55 -0000 1.21 @@ -118,6 +118,16 @@ void pushVariable ( const char *s ) ; void pushAssignment ( const char *s ) ; + void pushAddAssignment ( const char *s ) ; + void pushSubAssignment ( const char *s ) ; + void pushMulAssignment ( const char *s ) ; + void pushDivAssignment ( const char *s ) ; + void pushAndAssignment ( const char *s ) ; + void pushOrAssignment ( const char *s ) ; + void pushXorAssignment ( const char *s ) ; + void pushSHLAssignment ( const char *s ) ; + void pushSHRAssignment ( const char *s ) ; + void pushCall ( const char *s, int argc ) ; void pushReturn () ; Index: pslContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pslContext.cxx 14 Sep 2002 01:30:05 -0000 1.9 +++ pslContext.cxx 14 Sep 2002 04:45:55 -0000 1.10 @@ -466,10 +466,114 @@ pc++ ; return PSL_PROGRAM_CONTINUE ; + + case OPCODE_POP_ADD_VARIABLE : + { + pslVariable *v = & ( variable [ code[++pc] ] ) ; + + if ( v -> getType () == PSL_INT ) + v -> set ( v -> getInt() + stack[--sp].getInt()) ; + else [...83 lines suppressed...] + + + case OPCODE_POP_SHR_VARIABLE : + { + pslVariable *v = & ( variable [ code[++pc] ] ) ; + + v -> set ( v -> getInt() >> stack[--sp].getInt()) ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_POP_VARIABLE : popNumber ( & variable [ code[++pc] ] ) ; pc++ ; return PSL_PROGRAM_CONTINUE ; + case OPCODE_SET_INT_VARIABLE : variable [ code[++pc] ] . setType ( PSL_INT ) ; Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- pslDump.cxx 14 Sep 2002 01:30:05 -0000 1.15 +++ pslDump.cxx 14 Sep 2002 04:45:55 -0000 1.16 @@ -100,6 +100,16 @@ { "NOTEQUAL", OPCODE_NOTEQUAL , 0 }, { "EQUAL", OPCODE_EQUAL , 0 }, + { "POP_ADD_VARIABLE", OPCODE_POP_ADD_VARIABLE, 1 }, + { "POP_SUB_VARIABLE", OPCODE_POP_SUB_VARIABLE, 1 }, + { "POP_MUL_VARIABLE", OPCODE_POP_MUL_VARIABLE, 1 }, + { "POP_DIV_VARIABLE", OPCODE_POP_DIV_VARIABLE, 1 }, + { "POP_AND_VARIABLE", OPCODE_POP_AND_VARIABLE, 1 }, + { "POP_OR_VARIABLE" , OPCODE_POP_OR_VARIABLE , 1 }, + { "POP_XOR_VARIABLE", OPCODE_POP_XOR_VARIABLE, 1 }, + { "POP_SHL_VARIABLE", OPCODE_POP_SHL_VARIABLE, 1 }, + { "POP_SHR_VARIABLE", OPCODE_POP_SHR_VARIABLE, 1 }, + { NULL, 0, 0 } } ; @@ -200,6 +210,15 @@ fprintf ( fd, "\t\t[%d],off=%d", code [ addr+1 ], code [ addr+2 ] ) ; break ; + case OPCODE_POP_ADD_VARIABLE : + case OPCODE_POP_SUB_VARIABLE : + case OPCODE_POP_MUL_VARIABLE : + case OPCODE_POP_DIV_VARIABLE : + case OPCODE_POP_AND_VARIABLE : + case OPCODE_POP_OR_VARIABLE : + case OPCODE_POP_XOR_VARIABLE : + case OPCODE_POP_SHL_VARIABLE : + case OPCODE_POP_SHR_VARIABLE : case OPCODE_POP_VARIABLE : fprintf ( fd, "\t[%d]", code [ addr+1 ] ) ; break ; Index: pslOpcodes.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslOpcodes.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pslOpcodes.h 14 Sep 2002 01:30:05 -0000 1.7 +++ pslOpcodes.h 14 Sep 2002 04:45:55 -0000 1.8 @@ -68,4 +68,13 @@ #define OPCODE_STACK_DUPLICATE 0x27 #define OPCODE_GET_PARAMETER 0x28 +#define OPCODE_POP_ADD_VARIABLE 0x30 +#define OPCODE_POP_SUB_VARIABLE 0x31 +#define OPCODE_POP_MUL_VARIABLE 0x32 +#define OPCODE_POP_DIV_VARIABLE 0x33 +#define OPCODE_POP_AND_VARIABLE 0x34 +#define OPCODE_POP_OR_VARIABLE 0x35 +#define OPCODE_POP_XOR_VARIABLE 0x36 +#define OPCODE_POP_SHL_VARIABLE 0x37 +#define OPCODE_POP_SHR_VARIABLE 0x38 Index: pslToken.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslToken.cxx,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- pslToken.cxx 14 Sep 2002 01:30:05 -0000 1.18 +++ pslToken.cxx 14 Sep 2002 04:45:55 -0000 1.19 @@ -405,6 +405,8 @@ c = ' ' ; } + else + _pslUnGetChar ( d ) ; } } while ( isspace ( c ) ) ; |
From: Steve B. <sj...@us...> - 2002-09-14 01:30:08
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv9724/plib/src/psl Modified Files: pslCodeGen.cxx pslCompiler.h pslContext.cxx pslDump.cxx pslExpression.cxx pslOpcodes.h pslToken.cxx Log Message: Changed token parser to handle digraph operators. Added '<<' and '>>'. Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- pslCodeGen.cxx 13 Sep 2002 23:51:29 -0000 1.17 +++ pslCodeGen.cxx 14 Sep 2002 01:30:05 -0000 1.18 @@ -182,6 +182,8 @@ void pslCompiler::pushOr () { pushCodeByte ( OPCODE_OR ) ; } void pslCompiler::pushAnd () { pushCodeByte ( OPCODE_AND ) ; } void pslCompiler::pushXor () { pushCodeByte ( OPCODE_XOR ) ; } +void pslCompiler::pushShiftLeft () { pushCodeByte ( OPCODE_SHIFTLEFT ) ; } +void pslCompiler::pushShiftRight () { pushCodeByte ( OPCODE_SHIFTRIGHT ) ; } void pslCompiler::pushLess () { pushCodeByte ( OPCODE_LESS ) ; } void pslCompiler::pushLessEqual () { pushCodeByte ( OPCODE_LESSEQUAL ) ; } Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- pslCompiler.h 13 Sep 2002 23:51:30 -0000 1.19 +++ pslCompiler.h 14 Sep 2002 01:30:05 -0000 1.20 @@ -90,6 +90,8 @@ void pushOr () ; void pushAnd () ; void pushXor () ; + void pushShiftLeft () ; + void pushShiftRight () ; void pushLess () ; void pushLessEqual () ; void pushGreater () ; @@ -126,6 +128,7 @@ int pushMultExpression () ; int pushAddExpression () ; int pushRelExpression () ; + int pushShiftExpression () ; int pushExpression () ; /* Statement-level parsers & code generators. */ Index: pslContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pslContext.cxx 13 Sep 2002 23:51:30 -0000 1.8 +++ pslContext.cxx 14 Sep 2002 01:30:05 -0000 1.9 @@ -152,6 +152,30 @@ } return PSL_PROGRAM_CONTINUE ; + case OPCODE_SHIFTLEFT : + { + pslValue *v1 = & stack [ sp - 1 ] ; + pslValue *v2 = & stack [ sp - 2 ] ; + + v2 -> set ( v2 -> getInt () << v1 -> getInt () ) ; + + popVoid () ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_SHIFTRIGHT : + { + pslValue *v1 = & stack [ sp - 1 ] ; + pslValue *v2 = & stack [ sp - 2 ] ; + + v2 -> set ( v2 -> getInt () >> v1 -> getInt () ) ; + + popVoid () ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + case OPCODE_ADD : { pslValue *v1 = & stack [ sp - 1 ] ; Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- pslDump.cxx 13 Sep 2002 23:51:30 -0000 1.14 +++ pslDump.cxx 14 Sep 2002 01:30:05 -0000 1.15 @@ -89,6 +89,8 @@ { "AND", OPCODE_AND , 0 }, { "XOR", OPCODE_XOR , 0 }, + { "SHIFT_LEFT", OPCODE_SHIFTLEFT , 0 }, + { "SHIFT_RIGHT", OPCODE_SHIFTRIGHT , 0 }, /* Boolean operators */ { "LESS", OPCODE_LESS , 0 }, Index: pslExpression.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslExpression.cxx,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pslExpression.cxx 13 Sep 2002 23:51:30 -0000 1.10 +++ pslExpression.cxx 14 Sep 2002 01:30:05 -0000 1.11 @@ -30,7 +30,7 @@ char c [ MAX_TOKEN ] ; getToken ( c ) ; - if ( c [ 0 ] == '(' ) + if ( strcmp ( c, "(" ) == 0 ) { if ( ! pushExpression () ) { @@ -40,7 +40,7 @@ getToken ( c ) ; [...211 lines suppressed...] - { - if ( c [ 1 ] == '=' ) - pushGreaterEqual () ; - else - pushGreater () ; - } - else - if ( c [ 0 ] == '!' ) - pushNotEqual () ; - else - pushEqual () ; + if ( strcmp ( c, "<" ) == 0 ) pushLess () ; else + if ( strcmp ( c, ">" ) == 0 ) pushGreater () ; else + if ( strcmp ( c, "<=" ) == 0 ) pushLessEqual () ; else + if ( strcmp ( c, ">=" ) == 0 ) pushGreaterEqual () ; else + if ( strcmp ( c, "!=" ) == 0 ) pushNotEqual () ; else + if ( strcmp ( c, "==" ) == 0 ) pushEqual () ; } } Index: pslOpcodes.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslOpcodes.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pslOpcodes.h 13 Sep 2002 23:51:30 -0000 1.6 +++ pslOpcodes.h 14 Sep 2002 01:30:05 -0000 1.7 @@ -39,32 +39,33 @@ #define OPCODE_TWIDDLE 0x0C #define OPCODE_OROR 0x0D #define OPCODE_ANDAND 0x0E -#define OPCODE_XORXOR 0x0F /* Unused! */ +#define OPCODE_SHIFTLEFT 0x0F -#define OPCODE_OR 0x10 -#define OPCODE_AND 0x11 -#define OPCODE_XOR 0x12 -#define OPCODE_LESS 0x13 -#define OPCODE_LESSEQUAL 0x14 -#define OPCODE_GREATER 0x15 -#define OPCODE_GREATEREQUAL 0x16 -#define OPCODE_NOTEQUAL 0x17 -#define OPCODE_EQUAL 0x18 -#define OPCODE_JUMP_FALSE 0x19 -#define OPCODE_JUMP_TRUE 0x1A -#define OPCODE_JUMP 0x1B -#define OPCODE_POP 0x1C -#define OPCODE_HALT 0x1D -#define OPCODE_CALLEXT 0x1E -#define OPCODE_PAUSE 0x1F +#define OPCODE_SHIFTRIGHT 0x10 +#define OPCODE_OR 0x11 +#define OPCODE_AND 0x12 +#define OPCODE_XOR 0x13 +#define OPCODE_LESS 0x14 +#define OPCODE_LESSEQUAL 0x15 +#define OPCODE_GREATER 0x16 +#define OPCODE_GREATEREQUAL 0x17 +#define OPCODE_NOTEQUAL 0x18 +#define OPCODE_EQUAL 0x19 +#define OPCODE_JUMP_FALSE 0x1A +#define OPCODE_JUMP_TRUE 0x1B +#define OPCODE_JUMP 0x1C +#define OPCODE_POP 0x1D +#define OPCODE_HALT 0x1E +#define OPCODE_CALLEXT 0x1F -#define OPCODE_RETURN 0x20 -#define OPCODE_PUSH_VARIABLE 0x21 -#define OPCODE_POP_VARIABLE 0x22 -#define OPCODE_SET_INT_VARIABLE 0x23 -#define OPCODE_SET_FLOAT_VARIABLE 0x24 -#define OPCODE_SET_STRING_VARIABLE 0x25 -#define OPCODE_STACK_DUPLICATE 0x26 -#define OPCODE_GET_PARAMETER 0x27 +#define OPCODE_PAUSE 0x20 +#define OPCODE_RETURN 0x21 +#define OPCODE_PUSH_VARIABLE 0x22 +#define OPCODE_POP_VARIABLE 0x23 +#define OPCODE_SET_INT_VARIABLE 0x24 +#define OPCODE_SET_FLOAT_VARIABLE 0x25 +#define OPCODE_SET_STRING_VARIABLE 0x26 +#define OPCODE_STACK_DUPLICATE 0x27 +#define OPCODE_GET_PARAMETER 0x28 Index: pslToken.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslToken.cxx,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- pslToken.cxx 12 Sep 2002 04:39:26 -0000 1.17 +++ pslToken.cxx 14 Sep 2002 01:30:05 -0000 1.18 @@ -464,29 +464,70 @@ return ; } - while ( isalnum ( c ) || c == '.' || c == '_' ) + if ( isalnum ( c ) || c == '.' || c == '_' ) /* variables and numbers */ { - res [ tp++ ] = c ; - c = getChar () ; - - if ( tp >= MAX_TOKEN - 1 ) + while ( isalnum ( c ) || c == '.' || c == '_' ) { - error ( "Input string is bigger than %d characters!", + res [ tp++ ] = c ; + c = getChar () ; + + if ( tp >= MAX_TOKEN - 1 ) + { + error ( "Input string is bigger than %d characters!", MAX_TOKEN - 1 ) ; - tp-- ; + tp-- ; + } } + + _pslUnGetChar ( c ) ; } + else - if ( tp > 0 ) + /* Deal with: + <<, >>, <<=, >>=, + /=, +=, -=, *=, %=, &=, |=, + <=, >=, ==, !=, ++, -- + */ + + if ( c == '*' || c == '/' || c == '%' || + c == '<' || c == '>' || c == '=' || + c == '!' || c == '&' || c == '|' || + c == '+' || c == '-' ) { - _pslUnGetChar ( c ) ; - res [ tp ] = '\0' ; + res [ tp++ ] = c ; + + int c2 = getChar () ; + + if ( c2 == '=' || ( c == '>' && c2 == '>' ) || + ( c == '<' && c2 == '<' ) || + ( c == '&' && c2 == '&' ) || + ( c == '|' && c2 == '|' ) || + ( c == '+' && c2 == '+' ) || + ( c == '-' && c2 == '-' ) ) + { + res [ tp++ ] = c2 ; + + if ( ( c == '<' && c2 == '<' ) || + ( c == '>' && c2 == '>' ) ) + { + int c3 = getChar () ; + + if ( c3 == '=' ) + res [ tp++ ] = c3 ; + else + _pslUnGetChar ( c3 ) ; + } + } + else + _pslUnGetChar ( c2 ) ; } else { res [ 0 ] = c ; - res [ 1 ] = '\0' ; + tp = 1 ; } + + res [ tp ] = '\0' ; /* Don't do define substituting if told not to |
From: Steve B. <sj...@us...> - 2002-09-14 01:30:08
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv9724/plib/examples/src/psl/data Modified Files: test.psl Log Message: Changed token parser to handle digraph operators. Added '<<' and '>>'. Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test.psl 13 Sep 2002 23:51:29 -0000 1.19 +++ test.psl 14 Sep 2002 01:30:05 -0000 1.20 @@ -2,7 +2,8 @@ void xxx ( int a, float b, string c ) { printf ( "Hello", a, b, c, "\n" ) ; - printf ( " ", 2 * 2 | 1 ) ; + printf ( " ", 2 << 2 | 1 ) ; + printf ( " ", 2 << 2 + 1 ) ; } |
From: Sebastian U. <ud...@us...> - 2002-09-13 23:51:43
|
Update of /cvsroot/plib/plib/doc/psl In directory usw-pr-cvs1:/tmp/cvs-serv23312 Modified Files: appl_guide.html Log Message: Corrected some of the member-function prototypes referred to in the document Index: appl_guide.html =================================================================== RCS file: /cvsroot/plib/plib/doc/psl/appl_guide.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- appl_guide.html 13 Sep 2002 22:45:06 -0000 1.4 +++ appl_guide.html 13 Sep 2002 23:51:39 -0000 1.5 @@ -84,23 +84,25 @@ class pslProgram { - pslProgram ( pslExtension *extns, char *name ) ; + public: - pslProgram ( pslProgram *prog, char *name ) ; + pslProgram ( pslExtension *extns, const char *name ) ; + + pslProgram ( pslProgram *prog, const char *name ) ; void setUserData ( void *data ) ; - void *getUserData () ; + void *getUserData () const ; - void setProgName ( char *name ) ; - char *getProgName () ; + void setProgName ( const char *name ) ; + char *getProgName () const ; - void dump () ; + void dump () const ; void reset () ; pslResult step () ; pslResult trace () ; - int compile ( char *fname ) ; + int compile ( const char *fname ) ; int compile ( FILE *fd ) ; } ; @@ -203,6 +205,8 @@ class pslExtension { + public: + const char *symbol ; int argc ; pslValue (*func) ( int, pslValue *, pslProgram *p ) ; @@ -265,7 +269,7 @@ } pslValue ret ; - ret.set ( 123.456 ) ; + ret.set ( 123.456f ) ; return ret ; } @@ -300,17 +304,19 @@ class pslValue { - pslType getType () ; + public: - int getInt () ; - float getFloat () ; - char *getString () ; + pslType getType () const ; - void set () ; - void set ( int v ) ; - void set ( float v ) ; - void set ( char *v ) ; - void set ( pslNumber *v ) ; + int getInt () const ; + float getFloat () const ; + char *getString () const ; + + void set () ; + void set ( int v ) ; + void set ( float v ) ; + void set ( const char *v ) ; + void set ( const pslNumber *v ) ; } ; </pre> |
From: Steve B. <sj...@us...> - 2002-09-13 23:51:33
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv23216/plib/src/psl Modified Files: pslCodeGen.cxx pslCompiler.h pslContext.cxx pslDump.cxx pslExpression.cxx pslOpcodes.h Log Message: Added bitwise operators ^,&,|,!, ~ Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pslCodeGen.cxx 13 Sep 2002 22:32:15 -0000 1.16 +++ pslCodeGen.cxx 13 Sep 2002 23:51:29 -0000 1.17 @@ -175,6 +175,13 @@ void pslCompiler::pushMultiply () { pushCodeByte ( OPCODE_MULT ) ; } void pslCompiler::pushModulo () { pushCodeByte ( OPCODE_MOD ) ; } void pslCompiler::pushNegate () { pushCodeByte ( OPCODE_NEG ) ; } +void pslCompiler::pushNot () { pushCodeByte ( OPCODE_NOT ) ; } +void pslCompiler::pushTwiddle () { pushCodeByte ( OPCODE_TWIDDLE); } +void pslCompiler::pushOrOr () { pushCodeByte ( OPCODE_OROR ) ; } +void pslCompiler::pushAndAnd () { pushCodeByte ( OPCODE_ANDAND) ; } +void pslCompiler::pushOr () { pushCodeByte ( OPCODE_OR ) ; } +void pslCompiler::pushAnd () { pushCodeByte ( OPCODE_AND ) ; } +void pslCompiler::pushXor () { pushCodeByte ( OPCODE_XOR ) ; } void pslCompiler::pushLess () { pushCodeByte ( OPCODE_LESS ) ; } void pslCompiler::pushLessEqual () { pushCodeByte ( OPCODE_LESSEQUAL ) ; } Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- pslCompiler.h 13 Sep 2002 22:32:15 -0000 1.18 +++ pslCompiler.h 13 Sep 2002 23:51:30 -0000 1.19 @@ -83,6 +83,13 @@ void pushMultiply () ; void pushModulo () ; void pushNegate () ; + void pushNot () ; + void pushTwiddle () ; + void pushOrOr () ; + void pushAndAnd () ; + void pushOr () ; + void pushAnd () ; + void pushXor () ; void pushLess () ; void pushLessEqual () ; void pushGreater () ; @@ -114,17 +121,17 @@ /* Expression parsers & code generators. */ - int pushPrimitive () ; - int pushMultExpression () ; - int pushAddExpression () ; - int pushRelExpression () ; - int pushExpression () ; + int pushPrimitive () ; + int pushBitwiseExpression () ; + int pushMultExpression () ; + int pushAddExpression () ; + int pushRelExpression () ; + int pushExpression () ; /* Statement-level parsers & code generators. */ int pushBreakStatement () ; int pushContinueStatement () ; - int pushReturnStatement () ; int pushPauseStatement () ; int pushSwitchStatement () ; Index: pslContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pslContext.cxx 13 Sep 2002 22:32:15 -0000 1.7 +++ pslContext.cxx 13 Sep 2002 23:51:30 -0000 1.8 @@ -167,6 +167,87 @@ } return PSL_PROGRAM_CONTINUE ; + case OPCODE_NOT : + { + pslValue *v1 = & stack [ sp - 1 ] ; + + v1 -> set ( ! v1 -> getInt () ) ; + + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_TWIDDLE : + { + pslValue *v1 = & stack [ sp - 1 ] ; + + v1 -> set ( ~ v1 -> getInt () ) ; + + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_OROR : + { + pslValue *v1 = & stack [ sp - 1 ] ; + pslValue *v2 = & stack [ sp - 2 ] ; + + v2 -> set ( v2 -> getInt () || v1 -> getInt () ) ; + + popVoid () ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_ANDAND : + { + pslValue *v1 = & stack [ sp - 1 ] ; + pslValue *v2 = & stack [ sp - 2 ] ; + + v2 -> set ( v2 -> getInt () && v1 -> getInt () ) ; + + popVoid () ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_OR : + { + pslValue *v1 = & stack [ sp - 1 ] ; + pslValue *v2 = & stack [ sp - 2 ] ; + + v2 -> set ( v2 -> getInt () | v1 -> getInt () ) ; + + popVoid () ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_AND : + { + pslValue *v1 = & stack [ sp - 1 ] ; + pslValue *v2 = & stack [ sp - 2 ] ; + + v2 -> set ( v2 -> getInt () & v1 -> getInt () ) ; + + popVoid () ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_XOR : + { + pslValue *v1 = & stack [ sp - 1 ] ; + pslValue *v2 = & stack [ sp - 2 ] ; + + v2 -> set ( v2 -> getInt () ^ v1 -> getInt () ) ; + + popVoid () ; + pc++ ; + } + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_DIV : { pslValue *v1 = & stack [ sp - 1 ] ; Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- pslDump.cxx 13 Sep 2002 22:32:15 -0000 1.13 +++ pslDump.cxx 13 Sep 2002 23:51:30 -0000 1.14 @@ -77,6 +77,18 @@ { "MOD", OPCODE_MOD , 0 }, { "NEG", OPCODE_NEG , 0 }, + /* Bitwise operators */ + + { "NOT", OPCODE_NOT , 0 }, + { "TWIDDLE", OPCODE_TWIDDLE , 0 }, + + { "OROR", OPCODE_OROR , 0 }, + { "ANDAND", OPCODE_ANDAND , 0 }, + + { "OR", OPCODE_OR , 0 }, + { "AND", OPCODE_AND , 0 }, + { "XOR", OPCODE_XOR , 0 }, + /* Boolean operators */ { "LESS", OPCODE_LESS , 0 }, Index: pslExpression.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslExpression.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pslExpression.cxx 8 Sep 2002 18:56:29 -0000 1.9 +++ pslExpression.cxx 13 Sep 2002 23:51:30 -0000 1.10 @@ -60,6 +60,34 @@ } } + if ( c [ 0 ] == '!' ) /* Unary NOT */ + { + if ( pushPrimitive () ) + { + pushNot () ; + return TRUE ; + } + else + { + ungetToken ( c ) ; + return FALSE ; + } + } + + if ( c [ 0 ] == '~' ) /* Unary Twiddle */ + { + if ( pushPrimitive () ) + { + pushTwiddle () ; + return TRUE ; + } + else + { + ungetToken ( c ) ; + return FALSE ; + } + } + if ( c [ 0 ] == '-' ) /* Unary minus */ { if ( pushPrimitive () ) @@ -168,10 +196,42 @@ +int pslCompiler::pushBitwiseExpression () +{ + if ( ! pushAddExpression () ) + return FALSE ; + + while ( TRUE ) + { + char c [ MAX_TOKEN ] ; + + getToken ( c ) ; + + if ( c [ 0 ] != '|' && c [ 0 ] != '&' && c [ 0 ] != '^' ) + { + ungetToken ( c ) ; + return TRUE ; + } + + if ( ! pushAddExpression () ) + return FALSE ; + + if ( c [ 0 ] == '|' ) + pushOr () ; + else + if ( c [ 0 ] == '&' ) + pushAnd () ; + else + pushXor () ; + } +} + + + int pslCompiler::pushRelExpression () { - if ( ! pushAddExpression () ) + if ( ! pushBitwiseExpression () ) return FALSE ; while ( TRUE ) Index: pslOpcodes.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslOpcodes.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pslOpcodes.h 13 Sep 2002 22:32:15 -0000 1.5 +++ pslOpcodes.h 13 Sep 2002 23:51:30 -0000 1.6 @@ -35,26 +35,36 @@ #define OPCODE_MULT 0x08 #define OPCODE_MOD 0x09 #define OPCODE_NEG 0x0A -#define OPCODE_LESS 0x0B -#define OPCODE_LESSEQUAL 0x0C -#define OPCODE_GREATER 0x0D -#define OPCODE_GREATEREQUAL 0x0E -#define OPCODE_NOTEQUAL 0x0F -#define OPCODE_EQUAL 0x10 -#define OPCODE_JUMP_FALSE 0x11 -#define OPCODE_JUMP_TRUE 0x12 -#define OPCODE_JUMP 0x13 -#define OPCODE_POP 0x14 -#define OPCODE_HALT 0x15 -#define OPCODE_CALLEXT 0x16 -#define OPCODE_PAUSE 0x17 -#define OPCODE_RETURN 0x18 -#define OPCODE_PUSH_VARIABLE 0x19 -#define OPCODE_POP_VARIABLE 0x1A -#define OPCODE_SET_INT_VARIABLE 0x1B -#define OPCODE_SET_FLOAT_VARIABLE 0x1C -#define OPCODE_SET_STRING_VARIABLE 0x1D -#define OPCODE_STACK_DUPLICATE 0x1E -#define OPCODE_GET_PARAMETER 0x1F +#define OPCODE_NOT 0x0B +#define OPCODE_TWIDDLE 0x0C +#define OPCODE_OROR 0x0D +#define OPCODE_ANDAND 0x0E +#define OPCODE_XORXOR 0x0F /* Unused! */ + +#define OPCODE_OR 0x10 +#define OPCODE_AND 0x11 +#define OPCODE_XOR 0x12 +#define OPCODE_LESS 0x13 +#define OPCODE_LESSEQUAL 0x14 +#define OPCODE_GREATER 0x15 +#define OPCODE_GREATEREQUAL 0x16 +#define OPCODE_NOTEQUAL 0x17 +#define OPCODE_EQUAL 0x18 +#define OPCODE_JUMP_FALSE 0x19 +#define OPCODE_JUMP_TRUE 0x1A +#define OPCODE_JUMP 0x1B +#define OPCODE_POP 0x1C +#define OPCODE_HALT 0x1D +#define OPCODE_CALLEXT 0x1E +#define OPCODE_PAUSE 0x1F + +#define OPCODE_RETURN 0x20 +#define OPCODE_PUSH_VARIABLE 0x21 +#define OPCODE_POP_VARIABLE 0x22 +#define OPCODE_SET_INT_VARIABLE 0x23 +#define OPCODE_SET_FLOAT_VARIABLE 0x24 +#define OPCODE_SET_STRING_VARIABLE 0x25 +#define OPCODE_STACK_DUPLICATE 0x26 +#define OPCODE_GET_PARAMETER 0x27 |
From: Steve B. <sj...@us...> - 2002-09-13 23:51:32
|
Update of /cvsroot/plib/plib/doc/psl In directory usw-pr-cvs1:/tmp/cvs-serv23216/plib/doc/psl Modified Files: prog_guide.html Log Message: Added bitwise operators ^,&,|,!, ~ Index: prog_guide.html =================================================================== RCS file: /cvsroot/plib/plib/doc/psl/prog_guide.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- prog_guide.html 13 Sep 2002 22:45:07 -0000 1.4 +++ prog_guide.html 13 Sep 2002 23:51:28 -0000 1.5 @@ -125,7 +125,7 @@ hopefully arrive soon: <ul> <li> Assignment operators "+=", "-=", etc. - <li> Logic operators "!", "~", "&", "|", "^" "&&", "||", ^^". + <li> Logic operators "&&", "||". <li> "++" and "--" <li> ">>" and "<<" <li> Character constants. |
From: Steve B. <sj...@us...> - 2002-09-13 23:51:32
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv23216/plib/examples/src/psl/data Modified Files: test.psl Log Message: Added bitwise operators ^,&,|,!, ~ Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- test.psl 13 Sep 2002 22:32:15 -0000 1.18 +++ test.psl 13 Sep 2002 23:51:29 -0000 1.19 @@ -2,6 +2,7 @@ void xxx ( int a, float b, string c ) { printf ( "Hello", a, b, c, "\n" ) ; + printf ( " ", 2 * 2 | 1 ) ; } |