plib-cvs Mailing List for PLIB (Page 29)
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-07 23:05:08
|
Update of /cvsroot/plib/plib/examples/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv21782/plib/examples/src/psl Modified Files: psl_demo.cxx Log Message: Removed ode_demo. Added better error reporting for psl. Index: psl_demo.cxx =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/psl_demo.cxx,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- psl_demo.cxx 7 Sep 2002 07:00:32 -0000 1.10 +++ psl_demo.cxx 7 Sep 2002 23:05:06 -0000 1.11 @@ -81,14 +81,14 @@ /* Create program 1 and compile it. */ - pslProgram *prog_1 = new pslProgram ( extensions ) ; + pslProgram *prog_1 = new pslProgram ( extensions, "code1" ) ; prog_1 -> compile ( "data/test.psl" ) ; prog_1 -> dump () ; /* Clone program 2 from program 1 */ - pslProgram *prog_2 = new pslProgram ( prog_1 ) ; + pslProgram *prog_2 = new pslProgram ( prog_1, "code2" ) ; /* Make them unique by assigning user data to them */ @@ -100,7 +100,7 @@ while ( 1 ) { if ( prog_1 -> step () == PSL_PROGRAM_END ) break ; -// if ( prog_2 -> step () == PSL_PROGRAM_END ) break ; + if ( prog_2 -> step () == PSL_PROGRAM_END ) break ; } exit ( 0 ) ; |
Update of /cvsroot/plib/plib/demos/ode_demo/opcode In directory usw-pr-cvs1:/tmp/cvs-serv21782/plib/demos/ode_demo/opcode Removed Files: OPC_AABB.cpp OPC_AABB.h OPC_AABBCollider.cpp OPC_AABBCollider.h OPC_AABBTree.cpp OPC_AABBTree.h OPC_BVTCache.h OPC_BoundingSphere.h OPC_BoxBoxOverlap.h OPC_Collider.cpp OPC_Collider.h OPC_Common.cpp OPC_Common.h OPC_Container.cpp OPC_Container.h OPC_FPU.h OPC_HPoint.h OPC_Matrix3x3.cpp OPC_Matrix3x3.h OPC_Matrix4x4.cpp OPC_Matrix4x4.h OPC_MemoryMacros.h OPC_Model.cpp OPC_Model.h OPC_OBB.cpp OPC_OBB.h OPC_OBBCollider.cpp OPC_OBBCollider.h OPC_OptimizedTree.cpp OPC_OptimizedTree.h OPC_Plane.cpp OPC_Plane.h OPC_PlanesAABBOverlap.h OPC_PlanesCollider.cpp OPC_PlanesCollider.h OPC_PlanesTriOverlap.h OPC_Point.cpp OPC_Point.h OPC_Preprocessor.h OPC_Ray.cpp OPC_Ray.h OPC_RayAABBOverlap.h OPC_RayCollider.cpp OPC_RayCollider.h Log Message: Removed ode_demo. Added better error reporting for psl. --- OPC_AABB.cpp DELETED --- --- OPC_AABB.h DELETED --- --- OPC_AABBCollider.cpp DELETED --- --- OPC_AABBCollider.h DELETED --- --- OPC_AABBTree.cpp DELETED --- --- OPC_AABBTree.h DELETED --- --- OPC_BVTCache.h DELETED --- --- OPC_BoundingSphere.h DELETED --- --- OPC_BoxBoxOverlap.h DELETED --- --- OPC_Collider.cpp DELETED --- --- OPC_Collider.h DELETED --- --- OPC_Common.cpp DELETED --- --- OPC_Common.h DELETED --- --- OPC_Container.cpp DELETED --- --- OPC_Container.h DELETED --- --- OPC_FPU.h DELETED --- --- OPC_HPoint.h DELETED --- --- OPC_Matrix3x3.cpp DELETED --- --- OPC_Matrix3x3.h DELETED --- --- OPC_Matrix4x4.cpp DELETED --- --- OPC_Matrix4x4.h DELETED --- --- OPC_MemoryMacros.h DELETED --- --- OPC_Model.cpp DELETED --- --- OPC_Model.h DELETED --- --- OPC_OBB.cpp DELETED --- --- OPC_OBB.h DELETED --- --- OPC_OBBCollider.cpp DELETED --- --- OPC_OBBCollider.h DELETED --- --- OPC_OptimizedTree.cpp DELETED --- --- OPC_OptimizedTree.h DELETED --- --- OPC_Plane.cpp DELETED --- --- OPC_Plane.h DELETED --- --- OPC_PlanesAABBOverlap.h DELETED --- --- OPC_PlanesCollider.cpp DELETED --- --- OPC_PlanesCollider.h DELETED --- --- OPC_PlanesTriOverlap.h DELETED --- --- OPC_Point.cpp DELETED --- --- OPC_Point.h DELETED --- --- OPC_Preprocessor.h DELETED --- --- OPC_Ray.cpp DELETED --- --- OPC_Ray.h DELETED --- --- OPC_RayAABBOverlap.h DELETED --- --- OPC_RayCollider.cpp DELETED --- --- OPC_RayCollider.h DELETED --- |
Update of /cvsroot/plib/plib/demos/ode_demo/ode In directory usw-pr-cvs1:/tmp/cvs-serv21782/plib/demos/ode_demo/ode Removed Files: LICENSE-BSD.TXT LICENSE.TXT README array.cpp array.h common.h config.h contact.h dRay.cpp dRay.h dRay_Box.cpp dRay_CCylinder.cpp dRay_Plane.cpp dRay_Sphere.cpp dTriList.cpp dTriList.h dTriList_Box.cpp dTriList_CCylinder.cpp dTriList_Plane.cpp dTriList_Ray.cpp dTriList_Sphere.cpp dTriList_TriList.cpp dxRay.h dxTriList.h error.cpp error.h fastdot.c fastldlt.c fastlsolve.c fastltsolve.c geom.cpp geom.h geom_internal.h joint.cpp joint.h lcp.cpp lcp.h mass.cpp mass.h mat.cpp mat.h matrix.cpp matrix.h memory.cpp memory.h misc.cpp misc.h objects.h objects_internal.h obstack.cpp obstack.h ode.cpp ode.h odecpp.h odemath.cpp odemath.h rotation.cpp rotation.h space.cpp space.h step.cpp step.h testing.cpp testing.h timer.cpp timer.h Log Message: Removed ode_demo. Added better error reporting for psl. --- LICENSE-BSD.TXT DELETED --- --- LICENSE.TXT DELETED --- --- README DELETED --- --- array.cpp DELETED --- --- array.h DELETED --- --- common.h DELETED --- --- config.h DELETED --- --- contact.h DELETED --- --- dRay.cpp DELETED --- --- dRay.h DELETED --- --- dRay_Box.cpp DELETED --- --- dRay_CCylinder.cpp DELETED --- --- dRay_Plane.cpp DELETED --- --- dRay_Sphere.cpp DELETED --- --- dTriList.cpp DELETED --- --- dTriList.h DELETED --- --- dTriList_Box.cpp DELETED --- --- dTriList_CCylinder.cpp DELETED --- --- dTriList_Plane.cpp DELETED --- --- dTriList_Ray.cpp DELETED --- --- dTriList_Sphere.cpp DELETED --- --- dTriList_TriList.cpp DELETED --- --- dxRay.h DELETED --- --- dxTriList.h DELETED --- --- error.cpp DELETED --- --- error.h DELETED --- --- fastdot.c DELETED --- --- fastldlt.c DELETED --- --- fastlsolve.c DELETED --- --- fastltsolve.c DELETED --- --- geom.cpp DELETED --- --- geom.h DELETED --- --- geom_internal.h DELETED --- --- joint.cpp DELETED --- --- joint.h DELETED --- --- lcp.cpp DELETED --- --- lcp.h DELETED --- --- mass.cpp DELETED --- --- mass.h DELETED --- --- mat.cpp DELETED --- --- mat.h DELETED --- --- matrix.cpp DELETED --- --- matrix.h DELETED --- --- memory.cpp DELETED --- --- memory.h DELETED --- --- misc.cpp DELETED --- --- misc.h DELETED --- --- objects.h DELETED --- --- objects_internal.h DELETED --- --- obstack.cpp DELETED --- --- obstack.h DELETED --- --- ode.cpp DELETED --- --- ode.h DELETED --- --- odecpp.h DELETED --- --- odemath.cpp DELETED --- --- odemath.h DELETED --- --- rotation.cpp DELETED --- --- rotation.h DELETED --- --- space.cpp DELETED --- --- space.h DELETED --- --- step.cpp DELETED --- --- step.h DELETED --- --- testing.cpp DELETED --- --- testing.h DELETED --- --- timer.cpp DELETED --- --- timer.h DELETED --- |
From: Steve B. <sj...@us...> - 2002-09-07 23:05:07
|
Update of /cvsroot/plib/plib/demos/ode_demo/data In directory usw-pr-cvs1:/tmp/cvs-serv21782/plib/demos/ode_demo/data Removed Files: sorority.txf Log Message: Removed ode_demo. Added better error reporting for psl. --- sorority.txf DELETED --- |
From: Steve B. <sj...@us...> - 2002-09-07 23:05:07
|
Update of /cvsroot/plib/plib/demos/ode_demo In directory usw-pr-cvs1:/tmp/cvs-serv21782/plib/demos/ode_demo Removed Files: ode_demo.dsp ode_demo.dsw simple.cpp Log Message: Removed ode_demo. Added better error reporting for psl. --- ode_demo.dsp DELETED --- --- ode_demo.dsw DELETED --- --- simple.cpp DELETED --- |
From: Sebastian U. <ud...@us...> - 2002-09-07 21:57:14
|
Update of /cvsroot/plib/plib/src/js In directory usw-pr-cvs1:/tmp/cvs-serv5414 Modified Files: js.h Log Message: Added alternative method to get joystick name on WIN32 - fixes problems with USB joysticks Index: js.h =================================================================== RCS file: /cvsroot/plib/plib/src/js/js.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- js.h 2 Sep 2002 06:05:43 -0000 1.22 +++ js.h 7 Sep 2002 21:57:10 -0000 1.23 @@ -56,6 +56,7 @@ # define FAR /* */ # endif # include <mmsystem.h> +# include <regstr.h> # include <string.h> #else @@ -136,6 +137,7 @@ int id ; #endif*/ #ifdef WIN32 [...78 lines suppressed...] js . dwFlags = JOY_RETURNALL ; js . dwSize = sizeof ( js ) ; @@ -285,7 +346,15 @@ } else { - strncpy ( name, jsCaps.szPname, sizeof(name) ) ; + // Device name from jsCaps is often "Microsoft PC-joystick driver", + // at least for USB. Try to get the real name from the registry. + if ( ! getOEMProductName ( name, sizeof(name) ) ) + { + ulSetError ( UL_WARNING, + "JS: Failed to read joystick name from registry" ) ; + + strncpy ( name, jsCaps.szPname, sizeof(name) ) ; + } // Windows joystick drivers may provide any combination of // X,Y,Z,R,U,V,POV - not necessarily the first n of these. |
From: Sebastian U. <ud...@us...> - 2002-09-07 11:24:43
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv20437 Modified Files: psl.h pslContext.h Log Message: Again, changes for const-correctness Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- psl.h 7 Sep 2002 07:00:35 -0000 1.9 +++ psl.h 7 Sep 2002 11:24:39 -0000 1.10 @@ -66,17 +66,17 @@ pslNumber () { t = PSL_VOID ; s = NULL ; } - virtual void set ( int ) = 0 ; - virtual void set ( float ) = 0 ; - virtual void set ( const char * ) = 0 ; - virtual void set ( pslNumber * ) = 0 ; + virtual void set ( int ) = 0 ; + virtual void set ( float ) = 0 ; + virtual void set ( const char * ) = 0 ; + virtual void set ( const pslNumber * ) = 0 ; void reset () { t = PSL_VOID ; i = 0 ; delete [] s ; s = NULL ; } - pslType getType () { return t ; } + pslType getType () const { return t ; } void setType ( pslType _type ) { t = _type ; } - int getInt () + int getInt () const { switch ( t ) { @@ -88,7 +88,7 @@ return 0 ; } - float getFloat () + float getFloat () const { switch ( t ) { @@ -100,7 +100,7 @@ return 0.0f ; } - char *getString () + char *getString () const { switch ( t ) { @@ -131,7 +131,7 @@ s = new char [ strlen(v)+1 ] ; strcpy ( s, v ) ; } - virtual void set ( pslNumber *v ) + virtual void set ( const pslNumber *v ) { t = v -> getType () ; @@ -191,7 +191,7 @@ } } - virtual void set ( pslNumber *v ) + virtual void set ( const pslNumber *v ) { switch ( t ) { Index: pslContext.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pslContext.h 7 Sep 2002 07:00:35 -0000 1.3 +++ pslContext.h 7 Sep 2002 11:24:39 -0000 1.4 @@ -46,10 +46,10 @@ ~pslContext () {} ; - void pushInt ( int x ) { stack [ sp++ ] . set ( x ) ; } - void pushFloat ( float x ) { stack [ sp++ ] . set ( x ) ; } - void pushString ( char *x ) { stack [ sp++ ] . set ( x ) ; } - void pushNumber ( pslNumber *x ) { stack [ sp++ ] . set ( x ) ; } + void pushInt ( int x ) { stack [ sp++ ] . set ( x ) ; } + void pushFloat ( float x ) { stack [ sp++ ] . set ( x ) ; } + void pushString ( const char *x ) { stack [ sp++ ] . set ( x ) ; } + void pushNumber ( const pslNumber *x ) { stack [ sp++ ] . set ( x ) ; } void popVoid () { --sp ; } int popInt () { return stack [ --sp ] . getInt () ; } |
From: Sebastian U. <ud...@us...> - 2002-09-07 11:16:13
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv18863 Modified Files: pslOpcodes.h Log Message: Added copyright notices and copying permission statement Index: pslOpcodes.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslOpcodes.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pslOpcodes.h 7 Sep 2002 07:00:36 -0000 1.1 +++ pslOpcodes.h 7 Sep 2002 11:16:09 -0000 1.2 @@ -1,3 +1,27 @@ +/* + PLIB - A Suite of Portable Game Libraries + Copyright (C) 1998,2002 Steve Baker + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For further information visit http://plib.sourceforge.net + + $Id$ +*/ + + /* Code Opcodes */ #define OPCODE_NOOP 0x00 |
From: Sebastian U. <ud...@us...> - 2002-09-07 10:59:31
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv15317 Modified Files: Makefile.am Log Message: Removed 'sg' directory from compiler include path Index: Makefile.am =================================================================== RCS file: /cvsroot/plib/plib/src/psl/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile.am 7 Sep 2002 07:00:34 -0000 1.6 +++ Makefile.am 7 Sep 2002 10:59:29 -0000 1.7 @@ -10,7 +10,7 @@ pslCompiler.cxx pslSymbols.cxx pslToken.cxx \ pslExpression.cxx pslProgram.cxx pslDump.cxx -INCLUDES = -I$(top_srcdir)/src/sg -I$(top_srcdir)/src/util +INCLUDES = -I$(top_srcdir)/src/util endif |
From: Sebastian U. <ud...@us...> - 2002-09-07 10:58:27
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv15016 Modified Files: psl.dsp Log Message: Synced with recent changes to Makefile.am Index: psl.dsp =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- psl.dsp 6 Sep 2002 18:57:29 -0000 1.4 +++ psl.dsp 7 Sep 2002 10:58:23 -0000 1.5 @@ -134,6 +134,10 @@ # End Source File # Begin Source File +SOURCE=.\pslOpcodes.h +# End Source File +# Begin Source File + SOURCE=.\pslProgram.cxx # End Source File # Begin Source File |
From: Steve B. <sj...@us...> - 2002-09-07 07:01:07
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv31278/plib/examples/src/psl/data Modified Files: test.psl Log Message: Added string constants. Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- test.psl 6 Sep 2002 17:50:05 -0000 1.7 +++ test.psl 7 Sep 2002 07:00:34 -0000 1.8 @@ -1,32 +1,39 @@ -float x = 0.0 ; +int x = 0.0 ; -void wibble () +int wibble () { x = x + 1 ; identify () ; + return 123 ; } float y = 987.654 ; +/* + C style Comments... +*/ + +// ...and C++ style both work... + void main () { x = 0 ; - print ( x ) ; + printf ( "X,Y=", x, y ) ; { - float x = 123 ; + int x = wibble(); - print ( x ) ; + printf ( "X=", x ) ; { -/* float x = 456 ; //**/ - print ( x ) ; + int x = 456.0 ; + printf ( "Local X=", x ) ; } - print ( x ) ; + printf ( "X=", x ) ; } } |
From: Steve B. <sj...@us...> - 2002-09-07 07:01:06
|
Update of /cvsroot/plib/plib/examples/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv31278/plib/examples/src/psl Modified Files: psl_demo.cxx Log Message: Added string constants. Index: psl_demo.cxx =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/psl_demo.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- psl_demo.cxx 6 Sep 2002 17:20:56 -0000 1.9 +++ psl_demo.cxx 7 Sep 2002 07:00:32 -0000 1.10 @@ -32,27 +32,37 @@ #include <plib/psl.h> -pslVariable print ( int argc, pslVariable *argv, pslProgram *p ) +pslValue my_printf ( int argc, pslValue *argv, pslProgram *p ) { - for ( int i = 0 ; i < argc ; i++ ) - printf ( "%f ", argv[i].f ) ; + if ( argv[0].getType() != PSL_STRING ) + printf ( "printf: ERROR - First param must be a string!\n" ) ; + else + { + printf ( "%s", argv[0].getString() ) ; + for ( int i = 1 ; i < argc ; i++ ) + { + switch ( argv[i].getType () ) + { + case PSL_INT : printf ( "%d ", argv[i].getInt () ) ; break ; + case PSL_FLOAT : printf ( "%f ", argv[i].getFloat () ) ; break ; + case PSL_STRING : printf ( "%s ", argv[i].getString () ) ; break ; + case PSL_VOID : printf ( "(void) " ) ; break ; + } + } + } printf ( "\n" ) ; - pslVariable ret ; - ret.f = 0.0f ; - + pslValue ret ; return ret ; } -pslVariable identify ( int argc, pslVariable *argv, pslProgram *p ) +pslValue identify ( int argc, pslValue *argv, pslProgram *p ) { printf ( "I am %s.\n", (char *)( p->getUserData ()) ) ; - pslVariable ret ; - ret.f = 0.0f ; - + pslValue ret ; return ret ; } @@ -60,7 +70,7 @@ pslExtension extensions [] = { { "identify", 0, identify }, - { "print", -1, print }, + { "printf", -1, my_printf }, { NULL, 0, NULL } } ; @@ -90,7 +100,7 @@ while ( 1 ) { if ( prog_1 -> step () == PSL_PROGRAM_END ) break ; - if ( prog_2 -> step () == PSL_PROGRAM_END ) break ; +// if ( prog_2 -> step () == PSL_PROGRAM_END ) break ; } exit ( 0 ) ; |
From: Steve B. <sj...@us...> - 2002-09-07 07:00:42
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv31278/plib/src/psl Modified Files: Makefile.am psl.h pslCodeGen.cxx pslCompiler.cxx pslCompiler.h pslContext.cxx pslContext.h pslDump.cxx pslExpression.cxx pslLocal.h pslProgram.cxx pslToken.cxx Added Files: pslOpcodes.h Log Message: Added string constants. --- NEW FILE: pslOpcodes.h --- /* Code Opcodes */ #define OPCODE_NOOP 0x00 #define OPCODE_PUSH_INT_CONSTANT 0x01 #define OPCODE_PUSH_FLOAT_CONSTANT 0x02 #define OPCODE_PUSH_STRING_CONSTANT 0x03 #define OPCODE_CALL 0x04 #define OPCODE_SUB 0x05 #define OPCODE_ADD 0x06 #define OPCODE_DIV 0x07 #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 0x12 #define OPCODE_POP 0x13 #define OPCODE_HALT 0x14 #define OPCODE_CALLEXT 0x15 #define OPCODE_PAUSE 0x16 #define OPCODE_RETURN 0x17 #define OPCODE_PUSH_VARIABLE 0x18 #define OPCODE_POP_VARIABLE 0x19 #define OPCODE_SET_INT_VARIABLE 0x1A #define OPCODE_SET_FLOAT_VARIABLE 0x1B #define OPCODE_SET_STRING_VARIABLE 0x1C Index: Makefile.am =================================================================== RCS file: /cvsroot/plib/plib/src/psl/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile.am 6 Sep 2002 17:20:56 -0000 1.5 +++ Makefile.am 7 Sep 2002 07:00:34 -0000 1.6 @@ -4,7 +4,7 @@ lib_LIBRARIES = libplibpsl.a include_HEADERS = psl.h pslContext.h pslLocal.h \ - pslCompiler.h pslSymbol.h + pslCompiler.h pslSymbol.h pslOpcodes.h libplibpsl_a_SOURCES = psl.cxx pslCodeGen.cxx pslContext.cxx \ pslCompiler.cxx pslSymbols.cxx pslToken.cxx \ Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- psl.h 6 Sep 2002 17:20:56 -0000 1.8 +++ psl.h 7 Sep 2002 07:00:35 -0000 1.9 @@ -37,12 +37,171 @@ class pslCompiler ; class pslProgram ; + +enum pslType +{ + PSL_INT = 0, + PSL_FLOAT = 1, + PSL_STRING = 3, + PSL_VOID = 4 +} ; [...188 lines suppressed...] ~pslProgram () ; pslContext *getContext () const { return context ; } pslOpcode *getCode () const { return code ; } - pslCompiler *getCompiler () const { return compiler ; } + pslCompiler *getCompiler () const { return compiler ; } pslExtension *getExtensions () const { return extensions ; } void *getUserData () const { return userData ; } @@ -83,7 +242,8 @@ int compile ( const char *fname ) ; int compile ( FILE *fd ) ; void reset () ; - pslResult step () ; + pslResult step () ; + pslResult trace () ; } ; Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pslCodeGen.cxx 6 Sep 2002 17:20:56 -0000 1.9 +++ pslCodeGen.cxx 7 Sep 2002 07:00:35 -0000 1.10 @@ -67,28 +67,95 @@ void pslCompiler::pushConstant ( const char *c ) { + int isInteger = TRUE ; + + for ( const char *p = c ; *p != '\0' ; p++ ) + if ( *p == '.' || *p == 'f' || *p == 'F' ) + { + isInteger = FALSE ; + break ; + } [...75 lines suppressed...] } void pslCompiler::pushAssignment ( const char *c ) { int a = getVarSymbol ( c ) ; - pushCodeByte ( OPCODE_POP_VARIABLE | a ) ; + pushCodeByte ( OPCODE_POP_VARIABLE ) ; + pushCodeByte ( a ) ; } @@ -120,6 +187,7 @@ void pslCompiler::pushAdd () { pushCodeByte ( OPCODE_ADD ) ; } void pslCompiler::pushDivide () { pushCodeByte ( OPCODE_DIV ) ; } void pslCompiler::pushMultiply () { pushCodeByte ( OPCODE_MULT ) ; } +void pslCompiler::pushModulo () { pushCodeByte ( OPCODE_MOD ) ; } void pslCompiler::pushNegate () { pushCodeByte ( OPCODE_NEG ) ; } void pslCompiler::pushLess () { pushCodeByte ( OPCODE_LESS ) ; } Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pslCompiler.cxx 6 Sep 2002 17:20:56 -0000 1.9 +++ pslCompiler.cxx 7 Sep 2002 07:00:35 -0000 1.10 @@ -244,8 +244,14 @@ if ( strcmp ( c, "static" ) == 0 ) return pushStaticVariableDeclaration () ; + if ( strcmp ( c, "string" ) == 0 ) + return pushLocalVariableDeclaration ( PSL_STRING ) ; + + if ( strcmp ( c, "int" ) == 0 ) + return pushLocalVariableDeclaration ( PSL_INT ) ; + if ( strcmp ( c, "float" ) == 0 ) - return pushLocalVariableDeclaration () ; [...66 lines suppressed...] + if ( strcmp ( c, "float" ) == 0 ) t = PSL_FLOAT ; else + if ( strcmp ( c, "string" ) == 0 ) t = PSL_STRING ; else + { + ulSetError ( UL_WARNING, + "PSL: Expected declaration of variable or function - but got '%s'", + c ) ; + return FALSE ; + } pslGetToken ( fn ) ; @@ -395,7 +423,7 @@ if ( c[0] == '=' || c[0] == ';' ) { pslUngetToken ( c ) ; - return pushGlobalVariableDeclaration ( fn ) ; + return pushGlobalVariableDeclaration ( fn, t ) ; } ulSetError ( UL_WARNING, Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pslCompiler.h 6 Sep 2002 19:17:23 -0000 1.4 +++ pslCompiler.h 7 Sep 2002 07:00:35 -0000 1.5 @@ -56,6 +56,7 @@ void pushAdd () ; void pushDivide () ; void pushMultiply () ; + void pushModulo () ; void pushNegate () ; void pushLess () ; void pushLessEqual () ; @@ -66,11 +67,21 @@ int pushJumpIfFalse ( int l ) ; int pushJump ( int l ) ; - void pushConstant ( const char *c ) ; - void pushVariable ( const char *c ) ; - void pushAssignment ( const char *c ) ; - void pushCall ( const char *c, int argc ) ; - void pushReturn () ; + void makeIntVariable ( const char *s ) ; + void makeFloatVariable ( const char *s ) ; + void makeStringVariable( const char *s ) ; + + void pushConstant ( const char *s ) ; + void pushIntConstant ( const char *s ) ; + void pushFloatConstant ( const char *s ) ; + void pushStringConstant( const char *s ) ; + + void pushVoidConstant () ; + + void pushVariable ( const char *s ) ; + void pushAssignment ( const char *s ) ; + void pushCall ( const char *s, int argc ) ; + void pushReturn () ; /* Higher level parsers. */ @@ -86,20 +97,20 @@ int pushPauseStatement () ; int pushWhileStatement () ; int pushIfStatement () ; - int pushFunctionCall ( const char *c ) ; - int pushAssignmentStatement ( const char *c ) ; + int pushFunctionCall ( const char *s ) ; + int pushAssignmentStatement ( const char *s ) ; int pushCompoundStatement () ; int pushStatement () ; int pushFunctionDeclaration ( const char *fn ) ; - int pushLocalVariableDeclaration () ; - int pushGlobalVariableDeclaration ( const char *fn ) ; + int pushLocalVariableDeclaration ( pslType t ) ; + int pushGlobalVariableDeclaration ( const char *fn, pslType t ) ; int pushStaticVariableDeclaration () ; int pushGlobalDeclaration () ; void pushProgram () ; - void print_opcode ( FILE *fd, unsigned char op ) const ; + int printOpcode ( FILE *fd, int addr ) const ; pslAddress getVarSymbol ( const char *s ) ; pslAddress setVarSymbol ( const char *s ) ; @@ -128,8 +139,8 @@ pslContext *context ; pslExtension *extensions ; - void fixup ( const char *s, pslAddress v ) ; - void addFwdRef ( const char *s, pslAddress where ) ; + void fixup ( const char *s, pslAddress v ) ; + void addFwdRef ( const char *s, pslAddress where ) ; void checkUnresolvedSymbols () ; void pushLocality () @@ -187,6 +198,8 @@ } pslExtension *getExtensions () const { return extensions ; } + + int printInstruction ( FILE *fd, int addr ) const ; void init () { Index: pslContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.cxx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pslContext.cxx 6 Sep 2002 13:50:51 -0000 1.1 +++ pslContext.cxx 7 Sep 2002 07:00:35 -0000 1.2 @@ -28,15 +28,42 @@ { switch ( code [ pc ] ) { - case OPCODE_PUSH_CONSTANT : + case OPCODE_NOOP : + ulSetError ( UL_FATAL, "PSL: Suspicious opcode 0x00?!", code[pc] ) ; + pc++ ; + return PSL_PROGRAM_CONTINUE ; + + case OPCODE_PUSH_INT_CONSTANT : { [...344 lines suppressed...] + variable [ code[++pc] ] . setType ( PSL_STRING ) ; + pc++ ; + return PSL_PROGRAM_CONTINUE ; + default : - if ( ( code [ pc ] & 0xF0 ) == OPCODE_PUSH_VARIABLE ) - { - pushVariable ( variable [ code[pc] & 0x0F ] ) ; - pc++ ; - } - else - if ( ( code [ pc ] & 0xF0 ) == OPCODE_POP_VARIABLE ) - { - variable [ code[pc] & 0x0F ] = popVariable () ; - pc++ ; - } + ulSetError ( UL_FATAL, "PSL: Suspicious opcode 0x02x?!", code[pc] ) ; return PSL_PROGRAM_CONTINUE ; } } Index: pslContext.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pslContext.h 6 Sep 2002 18:36:21 -0000 1.2 +++ pslContext.h 7 Sep 2002 07:00:35 -0000 1.3 @@ -28,10 +28,10 @@ pslExtension *extensions ; pslProgram *program ; - pslVariable variable [ MAX_VARIABLE ] ; - pslVariable stack [ MAX_STACK ] ; - int sp ; - pslAddress pc ; + pslVariable variable [ MAX_VARIABLE ] ; + pslValue stack [ MAX_STACK ] ; + int sp ; + pslAddress pc ; public: @@ -40,25 +40,38 @@ code = p -> getCode () ; extensions = p -> getExtensions () ; program = p ; + reset () ; } ~pslContext () {} ; - void pushInt ( int x ) { stack [ sp++ ] . i = x ; } - void pushFloat ( float x ) { stack [ sp++ ] . f = x ; } - void pushVariable ( pslVariable x ) { stack [ sp++ ] = x ; } + void pushInt ( int x ) { stack [ sp++ ] . set ( x ) ; } + void pushFloat ( float x ) { stack [ sp++ ] . set ( x ) ; } + void pushString ( char *x ) { stack [ sp++ ] . set ( x ) ; } + void pushNumber ( pslNumber *x ) { stack [ sp++ ] . set ( x ) ; } - void popVoid () { --sp ; } - int popInt () { return stack [ --sp ] . i ; } - float popFloat () { return stack [ --sp ] . f ; } - pslVariable popVariable () { return stack [ --sp ] ; } + void popVoid () { --sp ; } + int popInt () { return stack [ --sp ] . getInt () ; } + float popFloat () { return stack [ --sp ] . getFloat () ; } + char *popString () { return stack [ --sp ] . getString () ; } - pslResult step () ; + void popNumber ( pslNumber *v ) { v -> set ( & stack [ --sp ] ) ; } + + pslResult step () ; + + pslResult trace () + { + program -> getCompiler () -> printInstruction ( stdout, pc ) ; + fflush ( stdout ) ; + return step () ; + } void reset () { - memset ( variable, 0, MAX_VARIABLE * sizeof ( pslVariable ) ) ; + for ( int i = 0 ; i < MAX_VARIABLE ; i++ ) + variable [ i ] . reset () ; + sp = 0 ; pc = 0 ; } Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pslDump.cxx 6 Sep 2002 17:20:56 -0000 1.8 +++ pslDump.cxx 7 Sep 2002 07:00:35 -0000 1.9 @@ -29,50 +29,83 @@ { const char *s ; unsigned char opcode ; + int numArgBytes ; } ; static const OpcodeDecode opcodeDecode [] = { - { "PUSH_CONSTANT", OPCODE_PUSH_CONSTANT }, [...229 lines suppressed...] + fprintf ( fd, "\t\t\t%d,nargs=%d", code[addr+1] + ( code[addr+2] << 8 ), + code[addr+3] ) ; + break ; + + case OPCODE_JUMP_FALSE : + fprintf ( fd, "\t%d", code[addr+1] + ( code[addr+2] << 8 ) ) ; + break ; + + case OPCODE_JUMP : + fprintf ( fd, "\t\t\t%d", code[addr+1] + ( code[addr+2] << 8 ) ) ; + break ; + + default : break ; + } + + fprintf ( fd, "\n" ) ; + return skip ; } Index: pslExpression.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslExpression.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pslExpression.cxx 6 Sep 2002 17:20:56 -0000 1.6 +++ pslExpression.cxx 7 Sep 2002 07:00:35 -0000 1.7 @@ -76,6 +76,12 @@ } } + if ( c [ 0 ] == '"' ) + { + pushStringConstant ( & c [ 1 ] ) ; + return TRUE ; + } + if ( isdigit ( c [ 0 ] ) || c [ 0 ] == '.' ) { pushConstant ( c ) ; @@ -113,7 +119,7 @@ pslGetToken ( c ) ; - if ( c [ 0 ] != '*' && c [ 0 ] != '/' ) + if ( c [ 0 ] != '*' && c [ 0 ] != '/' && c [ 0 ] != '%' ) { pslUngetToken ( c ) ; return TRUE ; @@ -125,7 +131,10 @@ if ( c [ 0 ] == '*' ) pushMultiply () ; else + if ( c [ 0 ] == '/' ) pushDivide () ; + else + pushModulo () ; } } Index: pslLocal.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslLocal.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- pslLocal.h 6 Sep 2002 17:20:56 -0000 1.11 +++ pslLocal.h 7 Sep 2002 07:00:36 -0000 1.12 @@ -40,42 +40,12 @@ #define MAX_ARGS 64 #define MAX_VARIABLE 256 #define MAX_LABEL 256 -#define MAX_TOKEN 256 +#define MAX_TOKEN 1024 #define MAX_CODE 512 #define MAX_STACK 256 #define MAX_NESTING 32 #define MAX_SYMBOL (MAX_VARIABLE + MAX_LABEL) -/* Code Opcodes */ - -/* Low nybble is variable address */ - -#define OPCODE_PUSH_VARIABLE 0xE0 -#define OPCODE_POP_VARIABLE 0xF0 - -/* Remaining opcodes must be in range 0x00 to 0xDF */ - -#define OPCODE_PUSH_CONSTANT 0x00 -#define OPCODE_CALL 0x01 -#define OPCODE_SUB 0x02 -#define OPCODE_ADD 0x03 -#define OPCODE_DIV 0x04 -#define OPCODE_MULT 0x05 -#define OPCODE_NEG 0x06 -#define OPCODE_LESS 0x07 -#define OPCODE_LESSEQUAL 0x08 -#define OPCODE_GREATER 0x09 -#define OPCODE_GREATEREQUAL 0x0A -#define OPCODE_NOTEQUAL 0x0B -#define OPCODE_EQUAL 0x0C -#define OPCODE_JUMP_FALSE 0x0D -#define OPCODE_JUMP 0x0E -#define OPCODE_POP 0x0F -#define OPCODE_HALT 0x10 -#define OPCODE_CALLEXT 0x11 -#define OPCODE_PAUSE 0x12 -#define OPCODE_RETURN 0x13 - /* Token Parser */ @@ -83,21 +53,14 @@ void pslGetToken ( char *c, FILE *fd = NULL ) ; void pslSetDefaultFile ( FILE *fd ) ; -/* - Address/Opcodes are: - - ???? ???? -- 8 bit opcode. - ???? xxxx -- 4 bit opcode with 4 bit variable address. - ???? ???? -- ditto - plus a float constant stored in the next 4 bytes. - ???? ???? -- ditto - plus a code address stored in the next 2 bytes. -*/ typedef unsigned short pslAddress ; extern int _pslInitialised ; +#include "pslOpcodes.h" #include "pslSymbol.h" -#include "pslContext.h" #include "pslCompiler.h" +#include "pslContext.h" Index: pslProgram.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslProgram.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pslProgram.cxx 6 Sep 2002 17:20:56 -0000 1.6 +++ pslProgram.cxx 7 Sep 2002 07:00:36 -0000 1.7 @@ -65,6 +65,7 @@ void pslProgram::dump () const { compiler -> dump () ; } void pslProgram::reset () { context -> reset () ; } pslResult pslProgram::step () { return context -> step () ; } +pslResult pslProgram::trace () { return context -> trace () ; } int pslProgram::compile ( const char *fname ) { Index: pslToken.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslToken.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pslToken.cxx 6 Sep 2002 17:50:06 -0000 1.7 +++ pslToken.cxx 7 Sep 2002 07:00:36 -0000 1.8 @@ -104,6 +104,59 @@ int tp = 0 ; + if ( c == '"' ) + { + int isBkSlash = FALSE ; + + do + { + if ( c == '\\' ) + { + if ( isBkSlash ) + { + isBkSlash = FALSE ; + res [ tp++ ] = c ; + } + else + isBkSlash = TRUE ; + } + else + if ( isBkSlash ) + { + switch ( c ) + { + case '0' : res [ tp++ ] = '\0' ; break ; + case 'r' : res [ tp++ ] = '\r' ; break ; + case 'n' : res [ tp++ ] = '\n' ; break ; + case 'f' : res [ tp++ ] = '\f' ; break ; + case 'b' : res [ tp++ ] = '\b' ; break ; + case 'a' : res [ tp++ ] = '\a' ; break ; + default: res [ tp++ ] = c ; break ; + } + } + else + res [ tp++ ] = c ; + + c = getc ( fd ) ; + + if ( tp >= MAX_TOKEN - 1 ) + { + ulSetError ( UL_WARNING, + "PSL: Input string is bigger than %d characters!", + MAX_TOKEN - 1 ) ; + tp-- ; + } + } while ( ( isBkSlash || c != '"' ) && c != -1 ) ; + + if ( c == -1 ) + ulSetError ( UL_WARNING, + "PSL: Missing \\\" character" ) ; + + /* The trailing quotes character is not included into the string */ + res [ tp ] = '\0' ; + return ; + } + while ( isalnum ( c ) || c == '.' || c == '_' ) { res [ tp++ ] = c ; |
From: Sebastian U. <ud...@us...> - 2002-09-06 19:17:27
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv14012 Modified Files: pslCompiler.h pslSymbol.h Log Message: Replaced some instances of 'delete' with 'delete []' Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pslCompiler.h 6 Sep 2002 18:51:52 -0000 1.3 +++ pslCompiler.h 6 Sep 2002 19:17:23 -0000 1.4 @@ -29,8 +29,7 @@ void set ( const char *s, pslAddress w ) { - symbol = new char [ strlen(s)+1 ] ; - strcpy ( symbol, s ) ; + symbol = ulStrDup ( s ) ; where = w ; } @@ -151,7 +150,7 @@ for ( int i = locality_stack [ locality_sp-1 ] ; i < next_var ; i++ ) { - delete symtab [ i ] . symbol ; + delete [] symtab [ i ] . symbol ; symtab [ i ] . symbol = NULL ; } @@ -181,9 +180,9 @@ { for ( int i = 0 ; i < MAX_SYMBOL ; i++ ) { - delete symtab [ i ] . symbol ; - delete code_symtab [ i ] . symbol ; - delete forward_ref [ i ] . symbol ; + delete [] symtab [ i ] . symbol ; + delete [] code_symtab [ i ] . symbol ; + delete [] forward_ref [ i ] . symbol ; } } @@ -197,9 +196,9 @@ for ( i = 0 ; i < MAX_SYMBOL ; i++ ) { - delete symtab [ i ] . symbol ; symtab [ i ] . symbol = NULL ; - delete code_symtab [ i ] . symbol ; code_symtab [ i ] . symbol = NULL ; - delete forward_ref [ i ] . symbol ; forward_ref [ i ] . symbol = NULL ; + delete [] symtab [ i ] . symbol ; symtab [ i ] . symbol = NULL ; + delete [] code_symtab [ i ] . symbol ; code_symtab [ i ] . symbol = NULL ; + delete [] forward_ref [ i ] . symbol ; forward_ref [ i ] . symbol = NULL ; } locality_sp = 0 ; Index: pslSymbol.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslSymbol.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pslSymbol.h 6 Sep 2002 18:36:21 -0000 1.3 +++ pslSymbol.h 6 Sep 2002 19:17:23 -0000 1.4 @@ -38,13 +38,12 @@ void set ( const char *s, pslAddress v, int loc ) { - symbol = new char [ strlen ( s ) + 1 ] ; - strcpy ( symbol, s ) ; + symbol = ulStrDup ( s ) ; address = v ; locality = loc ; } - ~pslSymbol () { delete symbol ; } + ~pslSymbol () { delete [] symbol ; } } ; |
From: Sebastian U. <ud...@us...> - 2002-09-06 18:57:32
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv5253 Modified Files: psl.dsp Log Message: Removed "..\sg" from compiler include path Index: psl.dsp =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- psl.dsp 6 Sep 2002 18:33:47 -0000 1.3 +++ psl.dsp 6 Sep 2002 18:57:29 -0000 1.4 @@ -41,7 +41,7 @@ # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\sg" /I "..\util" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\util" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -70,7 +70,7 @@ # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I "..\sg" /I "..\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I "..\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" |
From: Sebastian U. <ud...@us...> - 2002-09-06 18:51:56
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv2470 Modified Files: pslCompiler.h pslSymbols.cxx Log Message: Some more changes for const-correctness Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pslCompiler.h 6 Sep 2002 18:36:21 -0000 1.2 +++ pslCompiler.h 6 Sep 2002 18:51:52 -0000 1.3 @@ -34,9 +34,9 @@ where = w ; } - pslAddress getWhere () { return where ; } + pslAddress getWhere () const { return where ; } - int matches ( const char *s ) + int matches ( const char *s ) const { return symbol != NULL && strcmp ( s, symbol ) == 0 ; } @@ -107,7 +107,8 @@ pslAddress getCodeSymbol ( const char *s, pslAddress fixupLoc ) ; void setCodeSymbol ( const char *s, pslAddress v ) ; - int getExtensionSymbol ( const char *s ) ; + + int getExtensionSymbol ( const char *s ) const ; private: Index: pslSymbols.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslSymbols.cxx,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pslSymbols.cxx 6 Sep 2002 17:20:56 -0000 1.10 +++ pslSymbols.cxx 6 Sep 2002 18:51:53 -0000 1.11 @@ -62,7 +62,7 @@ } -int pslCompiler::getExtensionSymbol ( const char *s ) +int pslCompiler::getExtensionSymbol ( const char *s ) const { for ( int i = 0 ; extensions [ i ] . symbol != NULL ; i++ ) if ( strcmp ( s, extensions [ i ] . symbol ) == 0 ) |
From: Sebastian U. <ud...@us...> - 2002-09-06 18:36:24
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv30304 Modified Files: pslCompiler.h pslContext.h pslSymbol.h Log Message: Added copyright notices and copying permission statement Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pslCompiler.h 6 Sep 2002 17:20:56 -0000 1.1 +++ pslCompiler.h 6 Sep 2002 18:36:21 -0000 1.2 @@ -1,3 +1,25 @@ +/* + PLIB - A Suite of Portable Game Libraries + Copyright (C) 1998,2002 Steve Baker + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For further information visit http://plib.sourceforge.net + + $Id$ +*/ struct pslFwdRef Index: pslContext.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslContext.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pslContext.h 6 Sep 2002 13:50:51 -0000 1.1 +++ pslContext.h 6 Sep 2002 18:36:21 -0000 1.2 @@ -1,3 +1,26 @@ +/* + PLIB - A Suite of Portable Game Libraries + Copyright (C) 1998,2002 Steve Baker + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For further information visit http://plib.sourceforge.net + + $Id$ +*/ + class pslContext { Index: pslSymbol.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslSymbol.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pslSymbol.h 6 Sep 2002 16:44:51 -0000 1.2 +++ pslSymbol.h 6 Sep 2002 18:36:21 -0000 1.3 @@ -1,3 +1,26 @@ +/* + PLIB - A Suite of Portable Game Libraries + Copyright (C) 1998,2002 Steve Baker + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For further information visit http://plib.sourceforge.net + + $Id$ +*/ + class pslSymbol { |
From: Sebastian U. <ud...@us...> - 2002-09-06 18:33:50
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv29486 Modified Files: psl.dsp Log Message: Synced with recent changes to Makefile.am Index: psl.dsp =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- psl.dsp 5 Sep 2002 20:59:05 -0000 1.2 +++ psl.dsp 6 Sep 2002 18:33:47 -0000 1.3 @@ -102,6 +102,18 @@ # End Source File # Begin Source File +SOURCE=.\pslCompiler.h +# End Source File +# Begin Source File + +SOURCE=.\pslContext.cxx +# End Source File +# Begin Source File + +SOURCE=.\pslContext.h +# End Source File +# Begin Source File + SOURCE=.\psl.cxx # End Source File # Begin Source File @@ -126,7 +138,7 @@ # End Source File # Begin Source File -SOURCE=.\pslRun.cxx +SOURCE=.\pslSymbol.h # End Source File # Begin Source File |
From: Steve B. <sj...@us...> - 2002-09-06 17:50:10
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv15961/plib/examples/src/psl/data Modified Files: test.psl Log Message: Comments (both C and C++ style) now work. This is **FUN** ! Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test.psl 6 Sep 2002 16:44:50 -0000 1.6 +++ test.psl 6 Sep 2002 17:50:05 -0000 1.7 @@ -22,7 +22,7 @@ print ( x ) ; { - float x = 456 ; +/* float x = 456 ; //**/ print ( x ) ; } |
From: Steve B. <sj...@us...> - 2002-09-06 17:50:10
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv15961/plib/src/psl Modified Files: pslToken.cxx Log Message: Comments (both C and C++ style) now work. This is **FUN** ! Index: pslToken.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslToken.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pslToken.cxx 6 Sep 2002 13:50:51 -0000 1.6 +++ pslToken.cxx 6 Sep 2002 17:50:06 -0000 1.7 @@ -58,6 +58,48 @@ res [ 0 ] = '\0' ; return ; } + + if ( c == '/' ) + { + int d = getc ( fd ) ; + + if ( d == '/' ) /* C++ style comment */ + { + do + { + d = getc ( fd ) ; + } while ( d != '\n' && d != -1 ) ; + + c = ' ' ; + } + else + if ( d == '*' ) /* C style comment */ + { + /* + YUK! This is *so* horrible to get right. + Just think about this case! ==> **/ + + do + { + /* Search for a star or an EOF */ + + do + { + d = getc ( fd ) ; + } while ( d != '*' && d != -1 ) ; + + c = getc ( fd ) ; + + /* If you get two stars in a row - unget the second one */ + + if ( c == '*' ) + ungetc ( '*', fd ) ; + + } while ( c != '/' ) ; + + c = ' ' ; + } + } } while ( isspace ( c ) ) ; int tp = 0 ; |
From: Steve B. <sj...@us...> - 2002-09-06 17:20:59
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv6892/plib/src/psl Modified Files: Makefile.am psl.h pslCodeGen.cxx pslCompiler.cxx pslDump.cxx pslExpression.cxx pslLocal.h pslProgram.cxx pslSymbols.cxx Added Files: pslCompiler.h Removed Files: pslParser.h Log Message: Replaced 'parse' with 'compile' throughout. --- NEW FILE: pslCompiler.h --- struct pslFwdRef { char *symbol ; pslAddress where ; void set ( const char *s, pslAddress w ) { symbol = new char [ strlen(s)+1 ] ; strcpy ( symbol, s ) ; where = w ; } pslAddress getWhere () { return where ; } int matches ( const char *s ) { return symbol != NULL && strcmp ( s, symbol ) == 0 ; [...156 lines suppressed...] { delete symtab [ i ] . symbol ; symtab [ i ] . symbol = NULL ; delete code_symtab [ i ] . symbol ; code_symtab [ i ] . symbol = NULL ; delete forward_ref [ i ] . symbol ; forward_ref [ i ] . symbol = NULL ; } locality_sp = 0 ; next_fwdref = 0 ; next_label = 0 ; next_code_symbol = 0 ; next_code = 0 ; next_var = 0 ; } void dump () const ; int compile ( const char *fname ) ; int compile ( FILE *fd ) ; } ; Index: Makefile.am =================================================================== RCS file: /cvsroot/plib/plib/src/psl/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.am 6 Sep 2002 13:50:51 -0000 1.4 +++ Makefile.am 6 Sep 2002 17:20:56 -0000 1.5 @@ -4,7 +4,7 @@ lib_LIBRARIES = libplibpsl.a include_HEADERS = psl.h pslContext.h pslLocal.h \ - pslParser.h pslSymbol.h + pslCompiler.h pslSymbol.h libplibpsl_a_SOURCES = psl.cxx pslCodeGen.cxx pslContext.cxx \ pslCompiler.cxx pslSymbols.cxx pslToken.cxx \ Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- psl.h 6 Sep 2002 15:07:44 -0000 1.7 +++ psl.h 6 Sep 2002 17:20:56 -0000 1.8 @@ -34,7 +34,7 @@ typedef unsigned char pslOpcode ; class pslContext ; -class pslParser ; +class pslCompiler ; class pslProgram ; @@ -59,7 +59,7 @@ { pslOpcode *code ; pslContext *context ; - pslParser *parser ; + pslCompiler *compiler ; pslExtension *extensions ; void *userData ; @@ -73,15 +73,15 @@ pslContext *getContext () const { return context ; } pslOpcode *getCode () const { return code ; } - pslParser *getParser () const { return parser ; } + pslCompiler *getCompiler () const { return compiler ; } pslExtension *getExtensions () const { return extensions ; } void *getUserData () const { return userData ; } void setUserData ( void *ud ) { userData = ud ; } void dump () const ; - int parse ( const char *fname ) ; - int parse ( FILE *fd ) ; + int compile ( const char *fname ) ; + int compile ( FILE *fd ) ; void reset () ; pslResult step () ; } ; Index: pslCodeGen.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCodeGen.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pslCodeGen.cxx 6 Sep 2002 13:50:51 -0000 1.8 +++ pslCodeGen.cxx 6 Sep 2002 17:20:56 -0000 1.9 @@ -24,7 +24,7 @@ #include "pslLocal.h" -int pslParser::parse ( const char *fname ) +int pslCompiler::compile ( const char *fname ) { init () ; @@ -38,13 +38,13 @@ return FALSE ; } [...98 lines suppressed...] pushCodeByte ( OPCODE_JUMP_FALSE ) ; @@ -140,7 +140,7 @@ return res ; } -int pslParser::pushJump ( int l ) +int pslCompiler::pushJump ( int l ) { pushCodeByte ( OPCODE_JUMP ) ; @@ -152,7 +152,7 @@ } -int pslParser::pushPauseStatement() +int pslCompiler::pushPauseStatement() { pushCodeByte ( OPCODE_PAUSE ) ; return TRUE ; Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pslCompiler.cxx 6 Sep 2002 16:44:51 -0000 1.8 +++ pslCompiler.cxx 6 Sep 2002 17:20:56 -0000 1.9 @@ -25,7 +25,7 @@ #include "pslLocal.h" -int pslParser::pushReturnStatement () +int pslCompiler::pushReturnStatement () { char c [ MAX_TOKEN ] ; @@ -47,7 +47,7 @@ } [...85 lines suppressed...] char c [ MAX_TOKEN ] ; @@ -360,7 +360,7 @@ -int pslParser::pushGlobalDeclaration () +int pslCompiler::pushGlobalDeclaration () { char c [ MAX_TOKEN ] ; char fn [ MAX_TOKEN ] ; @@ -404,7 +404,7 @@ } -int pslParser::pushFunctionDeclaration ( const char *fn ) +int pslCompiler::pushFunctionDeclaration ( const char *fn ) { char c [ MAX_TOKEN ] ; Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pslDump.cxx 6 Sep 2002 16:44:51 -0000 1.7 +++ pslDump.cxx 6 Sep 2002 17:20:56 -0000 1.8 @@ -59,7 +59,7 @@ } ; -void pslParser::print_opcode ( FILE *fd, unsigned char op ) const +void pslCompiler::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 pslParser::dump () const +void pslCompiler::dump () const { int i ; Index: pslExpression.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslExpression.cxx,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pslExpression.cxx 6 Sep 2002 13:50:51 -0000 1.5 +++ pslExpression.cxx 6 Sep 2002 17:20:56 -0000 1.6 @@ -25,7 +25,7 @@ #include "pslLocal.h" -int pslParser::pushPrimitive () +int pslCompiler::pushPrimitive () { char c [ MAX_TOKEN ] ; pslGetToken ( c ) ; @@ -102,7 +102,7 @@ -int pslParser::pushMultExpression () +int pslCompiler::pushMultExpression () { if ( ! pushPrimitive () ) return FALSE ; @@ -132,7 +132,7 @@ -int pslParser::pushAddExpression () +int pslCompiler::pushAddExpression () { if ( ! pushMultExpression () ) return FALSE ; @@ -162,7 +162,7 @@ -int pslParser::pushRelExpression () +int pslCompiler::pushRelExpression () { if ( ! pushAddExpression () ) return FALSE ; @@ -227,7 +227,7 @@ } -int pslParser::pushExpression () +int pslCompiler::pushExpression () { return pushRelExpression () ; } Index: pslLocal.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslLocal.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pslLocal.h 6 Sep 2002 16:44:51 -0000 1.10 +++ pslLocal.h 6 Sep 2002 17:20:56 -0000 1.11 @@ -98,6 +98,6 @@ #include "pslSymbol.h" #include "pslContext.h" -#include "pslParser.h" +#include "pslCompiler.h" Index: pslProgram.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslProgram.cxx,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pslProgram.cxx 6 Sep 2002 15:07:44 -0000 1.5 +++ pslProgram.cxx 6 Sep 2002 17:20:56 -0000 1.6 @@ -34,10 +34,10 @@ extensions = ext ; - parser = new pslParser ( code, ext ) ; + compiler = new pslCompiler ( code, ext ) ; context = new pslContext ( this ) ; - parser -> init () ; + compiler -> init () ; context -> reset () ; } @@ -45,7 +45,7 @@ pslProgram::pslProgram ( pslProgram *src ) { code = src -> getCode () ; - parser = src -> getParser () ; + compiler = src -> getCompiler () ; extensions = src -> getExtensions () ; userData = src -> getUserData () ; @@ -56,23 +56,23 @@ pslProgram::~pslProgram () { - delete parser ; + delete compiler ; delete context ; delete [] code ; } -void pslProgram::dump () const { parser -> dump () ; } +void pslProgram::dump () const { compiler -> dump () ; } void pslProgram::reset () { context -> reset () ; } pslResult pslProgram::step () { return context -> step () ; } -int pslProgram::parse ( const char *fname ) +int pslProgram::compile ( const char *fname ) { - return parser -> parse(fname) ; + return compiler -> compile (fname) ; } -int pslProgram::parse ( FILE *fd ) +int pslProgram::compile ( FILE *fd ) { - return parser -> parse( fd ) ; + return compiler -> compile( fd ) ; } Index: pslSymbols.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslSymbols.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pslSymbols.cxx 6 Sep 2002 16:44:51 -0000 1.9 +++ pslSymbols.cxx 6 Sep 2002 17:20:56 -0000 1.10 @@ -25,7 +25,7 @@ #include "pslLocal.h" -pslAddress pslParser::setVarSymbol ( const char *s ) +pslAddress pslCompiler::setVarSymbol ( const char *s ) { for ( int i = 0 ; i < next_var ; i++ ) if ( strcmp ( s, symtab [ i ] . symbol ) == 0 && @@ -48,7 +48,7 @@ -pslAddress pslParser::getVarSymbol ( const char *s ) +pslAddress pslCompiler::getVarSymbol ( const char *s ) { /* Search Backwards so most local variable shows up first */ @@ -62,7 +62,7 @@ } -int pslParser::getExtensionSymbol ( const char *s ) +int pslCompiler::getExtensionSymbol ( const char *s ) { for ( int i = 0 ; extensions [ i ] . symbol != NULL ; i++ ) if ( strcmp ( s, extensions [ i ] . symbol ) == 0 ) @@ -72,7 +72,7 @@ } -void pslParser::addFwdRef ( const char *s, pslAddress where ) +void pslCompiler::addFwdRef ( const char *s, pslAddress where ) { for ( int i = 0 ; i < next_fwdref ; i++ ) { @@ -94,7 +94,7 @@ -void pslParser::fixup ( const char *s, pslAddress v ) +void pslCompiler::fixup ( const char *s, pslAddress v ) { for ( int i = 0 ; i < next_fwdref ; i++ ) { @@ -113,7 +113,7 @@ -void pslParser::checkUnresolvedSymbols () +void pslCompiler::checkUnresolvedSymbols () { for ( int i = 0 ; i < next_fwdref ; i++ ) { @@ -131,7 +131,7 @@ -pslAddress pslParser::getCodeSymbol ( const char *s, pslAddress where ) +pslAddress pslCompiler::getCodeSymbol ( const char *s, pslAddress where ) { for ( int i = 0 ; i < next_code_symbol ; i++ ) if ( strcmp ( s, code_symtab [ i ] . symbol ) == 0 ) @@ -146,7 +146,7 @@ -void pslParser::setCodeSymbol ( const char *s, pslAddress v ) +void pslCompiler::setCodeSymbol ( const char *s, pslAddress v ) { for ( int i = 0 ; i < next_code_symbol ; i++ ) if ( strcmp ( s, code_symtab [ i ] . symbol ) == 0 ) --- pslParser.h DELETED --- |
From: Steve B. <sj...@us...> - 2002-09-06 17:20:59
|
Update of /cvsroot/plib/plib/examples/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv6892/plib/examples/src/psl Modified Files: psl_demo.cxx Log Message: Replaced 'parse' with 'compile' throughout. Index: psl_demo.cxx =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/psl_demo.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- psl_demo.cxx 6 Sep 2002 15:07:44 -0000 1.8 +++ psl_demo.cxx 6 Sep 2002 17:20:56 -0000 1.9 @@ -73,7 +73,7 @@ pslProgram *prog_1 = new pslProgram ( extensions ) ; - prog_1 -> parse ( "data/test.psl" ) ; + prog_1 -> compile ( "data/test.psl" ) ; prog_1 -> dump () ; /* Clone program 2 from program 1 */ |
From: Steve B. <sj...@us...> - 2002-09-06 16:44:54
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv26424/plib/src/psl Modified Files: pslCompiler.cxx pslDump.cxx pslLocal.h pslParser.h pslSymbol.h pslSymbols.cxx Log Message: Local variables (including nested locals) now works. Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pslCompiler.cxx 6 Sep 2002 15:07:44 -0000 1.7 +++ pslCompiler.cxx 6 Sep 2002 16:44:51 -0000 1.8 @@ -207,22 +207,29 @@ { char c [ MAX_TOKEN ] ; + pushLocality () ; + while ( pushStatement () ) { pslGetToken ( c ) ; if ( c[0] != ';' ) + { + popLocality () ; return FALSE ; + } } pslGetToken ( c ) ; if ( c[0] == '}' ) { + popLocality () ; pslUngetToken ( ";" ) ; return TRUE ; } + popLocality () ; pslUngetToken ( c ) ; return FALSE ; } @@ -295,9 +302,24 @@ int pslParser::pushLocalVariableDeclaration () { - ulSetError ( UL_WARNING, - "PSL: Local Variables are Not Supported Yet." ) ; - return FALSE ; + char c [ MAX_TOKEN ] ; + char s [ MAX_TOKEN ] ; + + pslGetToken ( s ) ; + + setVarSymbol ( s ) ; + + pslGetToken ( c ) ; + + if ( c[0] == '=' ) + { + pslUngetToken ( c ) ; + pushAssignmentStatement ( s ) ; + return TRUE ; + } + + pslUngetToken ( c ) ; + return TRUE ; } Index: pslDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslDump.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pslDump.cxx 6 Sep 2002 13:50:51 -0000 1.6 +++ pslDump.cxx 6 Sep 2002 16:44:51 -0000 1.7 @@ -147,7 +147,7 @@ } printf ( "\n" ) ; - printf ( "Variables:\n" ) ; + printf ( "Global Variables:\n" ) ; for ( i = 0 ; i < MAX_SYMBOL ; i++ ) if ( symtab [ i ] . symbol != NULL ) @@ -162,7 +162,7 @@ } printf ( "\n" ) ; - printf ( "Labels:\n" ) ; + printf ( "Functions:\n" ) ; for ( i = 0 ; i < MAX_SYMBOL ; i++ ) if ( code_symtab [ i ] . symbol != NULL ) Index: pslLocal.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslLocal.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pslLocal.h 6 Sep 2002 15:07:44 -0000 1.9 +++ pslLocal.h 6 Sep 2002 16:44:51 -0000 1.10 @@ -37,12 +37,13 @@ /* Limits */ -#define MAX_ARGS 16 -#define MAX_VARIABLE 16 -#define MAX_LABEL 16 -#define MAX_TOKEN 256 -#define MAX_CODE 512 -#define MAX_STACK 32 +#define MAX_ARGS 64 +#define MAX_VARIABLE 256 +#define MAX_LABEL 256 +#define MAX_TOKEN 256 +#define MAX_CODE 512 +#define MAX_STACK 256 +#define MAX_NESTING 32 #define MAX_SYMBOL (MAX_VARIABLE + MAX_LABEL) /* Code Opcodes */ Index: pslParser.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslParser.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pslParser.h 6 Sep 2002 13:50:51 -0000 1.1 +++ pslParser.h 6 Sep 2002 16:44:51 -0000 1.2 @@ -80,12 +80,12 @@ void print_opcode ( FILE *fd, unsigned char op ) const ; - pslAddress getVarSymbol ( const char *s ) ; - pslAddress setVarSymbol ( const char *s ) ; + pslAddress getVarSymbol ( const char *s ) ; + pslAddress setVarSymbol ( const char *s ) ; - pslAddress getCodeSymbol ( const char *s, pslAddress fixupLoc ) ; - void setCodeSymbol ( const char *s, pslAddress v ) ; - int getExtensionSymbol ( const char *s ) ; + pslAddress getCodeSymbol ( const char *s, pslAddress fixupLoc ) ; + void setCodeSymbol ( const char *s, pslAddress v ) ; + int getExtensionSymbol ( const char *s ) ; private: @@ -99,6 +99,9 @@ pslSymbol code_symtab [ MAX_SYMBOL ] ; pslFwdRef forward_ref [ MAX_SYMBOL ] ; + int locality_stack [ MAX_NESTING ] ; + int locality_sp ; + pslOpcode *code ; pslContext *context ; pslExtension *extensions ; @@ -107,6 +110,33 @@ void addFwdRef ( const char *s, pslAddress where ) ; void checkUnresolvedSymbols () ; + void pushLocality () + { + if ( locality_sp >= MAX_NESTING-1 ) + ulSetError ( UL_WARNING, "PSL: Too many nested {}'s" ) ; + else + locality_stack [ locality_sp++ ] = next_var ; + } + + void popLocality () + { + if ( locality_sp <= 0 ) + ulSetError ( UL_FATAL, "PSL: Locality stack underflow !!" ) ; + + /* Delete any local symbols */ + + for ( int i = locality_stack [ locality_sp-1 ] ; + i < next_var ; i++ ) + { + delete symtab [ i ] . symbol ; + symtab [ i ] . symbol = NULL ; + } + + /* Put the next_var pointer back where it belongs */ + + next_var = locality_stack [ --locality_sp ] ; + } + public: pslParser ( pslOpcode *_code, pslExtension *_extn ) @@ -149,6 +179,7 @@ delete forward_ref [ i ] . symbol ; forward_ref [ i ] . symbol = NULL ; } + locality_sp = 0 ; next_fwdref = 0 ; next_label = 0 ; next_code_symbol = 0 ; Index: pslSymbol.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslSymbol.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pslSymbol.h 6 Sep 2002 13:50:51 -0000 1.1 +++ pslSymbol.h 6 Sep 2002 16:44:51 -0000 1.2 @@ -2,20 +2,23 @@ class pslSymbol { public: - char *symbol ; - pslAddress address ; + char *symbol ; + pslAddress address ; + int locality ; pslSymbol () { - symbol = NULL ; - address = 0 ; + symbol = NULL ; + address = 0 ; + locality = 0 ; } - void set ( const char *s, pslAddress v ) + void set ( const char *s, pslAddress v, int loc ) { - symbol = new char [ strlen ( s ) + 1 ] ; + symbol = new char [ strlen ( s ) + 1 ] ; strcpy ( symbol, s ) ; - address = v ; + address = v ; + locality = loc ; } ~pslSymbol () { delete symbol ; } Index: pslSymbols.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslSymbols.cxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pslSymbols.cxx 6 Sep 2002 13:50:51 -0000 1.8 +++ pslSymbols.cxx 6 Sep 2002 16:44:51 -0000 1.9 @@ -28,7 +28,8 @@ pslAddress pslParser::setVarSymbol ( const char *s ) { for ( int i = 0 ; i < next_var ; i++ ) - if ( strcmp ( s, symtab [ i ] . symbol ) == 0 ) + if ( strcmp ( s, symtab [ i ] . symbol ) == 0 && + symtab [ i ] . locality >= locality_sp ) { ulSetError ( UL_WARNING, "PSL: Multiple definition of '%s'.", s ) ; return symtab [ i ] . address ; @@ -40,7 +41,7 @@ next_var-- ; } - symtab [ next_var ] . set ( s, next_var ) ; + symtab [ next_var ] . set ( s, next_var, locality_sp ) ; return symtab [ next_var++ ] . address ; } @@ -49,7 +50,9 @@ pslAddress pslParser::getVarSymbol ( const char *s ) { - for ( int i = 0 ; i < next_var ; i++ ) + /* Search Backwards so most local variable shows up first */ + + for ( int i = next_var-1 ; i >= 0 ; i-- ) if ( strcmp ( s, symtab [ i ] . symbol ) == 0 ) return symtab [ i ] . address ; @@ -158,7 +161,7 @@ next_code_symbol-- ; } - code_symtab [ next_code_symbol++ ] . set ( s, v ) ; + code_symtab [ next_code_symbol++ ] . set ( s, v, locality_sp ) ; fixup ( s, v ) ; } |
From: Steve B. <sj...@us...> - 2002-09-06 16:44:54
|
Update of /cvsroot/plib/plib/examples/src/psl/data In directory usw-pr-cvs1:/tmp/cvs-serv26424/plib/examples/src/psl/data Modified Files: test.psl Log Message: Local variables (including nested locals) now works. Index: test.psl =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/data/test.psl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- test.psl 6 Sep 2002 15:07:44 -0000 1.5 +++ test.psl 6 Sep 2002 16:44:50 -0000 1.6 @@ -14,12 +14,19 @@ { x = 0 ; - while ( x < 10 ) + print ( x ) ; + { - print ( x, y ) ; - wibble () ; - pause ; + float x = 123 ; + + print ( x ) ; + + { + float x = 456 ; + print ( x ) ; + } + + print ( x ) ; } } - |
From: Steve B. <sj...@us...> - 2002-09-06 15:07:47
|
Update of /cvsroot/plib/plib/examples/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv22280/plib/examples/src/psl Modified Files: psl_demo.cxx Log Message: Global variable initialisations now work. pslInit created and checked for. Index: psl_demo.cxx =================================================================== RCS file: /cvsroot/plib/plib/examples/src/psl/psl_demo.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- psl_demo.cxx 6 Sep 2002 13:50:51 -0000 1.7 +++ psl_demo.cxx 6 Sep 2002 15:07:44 -0000 1.8 @@ -32,7 +32,21 @@ #include <plib/psl.h> -pslVariable hello ( int argc, pslVariable *argv, pslProgram *p ) +pslVariable print ( int argc, pslVariable *argv, pslProgram *p ) +{ + for ( int i = 0 ; i < argc ; i++ ) + printf ( "%f ", argv[i].f ) ; + + printf ( "\n" ) ; + + pslVariable ret ; + ret.f = 0.0f ; + + return ret ; +} + + +pslVariable identify ( int argc, pslVariable *argv, pslProgram *p ) { printf ( "I am %s.\n", (char *)( p->getUserData ()) ) ; @@ -45,13 +59,16 @@ pslExtension extensions [] = { - { "hello", 0, hello }, + { "identify", 0, identify }, + { "print", -1, print }, { NULL, 0, NULL } } ; int main () { + pslInit () ; + /* Create program 1 and compile it. */ pslProgram *prog_1 = new pslProgram ( extensions ) ; |