mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-15 04:30:29 +01:00
fix // comments
This commit is contained in:
parent
092af29ea1
commit
955190fbad
17 changed files with 4834 additions and 4834 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,96 +1,96 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// atom.h
|
||||
//
|
||||
|
||||
#if !defined(__ATOM_H)
|
||||
#define __ATOM_H 1
|
||||
|
||||
typedef struct AtomTable_Rec AtomTable;
|
||||
|
||||
extern AtomTable *atable;
|
||||
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
void FreeAtomTable(AtomTable *atable);
|
||||
int AddAtom(AtomTable *atable, const char *s);
|
||||
void PrintAtomTable(AtomTable *atable);
|
||||
int LookUpAddString(AtomTable *atable, const char *s);
|
||||
const char *GetAtomString(AtomTable *atable, int atom);
|
||||
int GetReversedAtom(AtomTable *atable, int atom);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
#endif // !defined(__ATOM_H)
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// atom.h
|
||||
*/
|
||||
|
||||
#if !defined(__ATOM_H)
|
||||
#define __ATOM_H 1
|
||||
|
||||
typedef struct AtomTable_Rec AtomTable;
|
||||
|
||||
extern AtomTable *atable;
|
||||
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
void FreeAtomTable(AtomTable *atable);
|
||||
int AddAtom(AtomTable *atable, const char *s);
|
||||
void PrintAtomTable(AtomTable *atable);
|
||||
int LookUpAddString(AtomTable *atable, const char *s);
|
||||
const char *GetAtomString(AtomTable *atable, int atom);
|
||||
int GetReversedAtom(AtomTable *atable, int atom);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
#endif /* !defined(__ATOM_H) */
|
||||
|
|
|
|||
|
|
@ -1,131 +1,131 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// compile.h
|
||||
//
|
||||
|
||||
#if !defined(__COMPILE_H)
|
||||
#define __COMPILE_H 1
|
||||
|
||||
int InitCPPStruct(void);
|
||||
|
||||
typedef struct Options_Rec{
|
||||
const char *profileString;
|
||||
int ErrorMode;
|
||||
int Quiet;
|
||||
|
||||
// Debug The Compiler options:
|
||||
int DumpAtomTable;
|
||||
} Options;
|
||||
|
||||
struct CPPStruct_Rec {
|
||||
// Public members
|
||||
SourceLoc *pLastSourceLoc; // Set at the start of each statement by the tree walkers
|
||||
Options options; // Compile options and parameters
|
||||
|
||||
// Private members
|
||||
SourceLoc lastSourceLoc;
|
||||
|
||||
// Scanner data:
|
||||
|
||||
SourceLoc *tokenLoc; // Source location of most recent token seen by the scanner
|
||||
int mostRecentToken; // Most recent token seen by the scanner
|
||||
InputSrc *currentInput;
|
||||
int previous_token;
|
||||
int notAVersionToken; // used to make sure that #version is the first token seen in the file, if present
|
||||
|
||||
void *pC; // storing the parseContext of the compile object in cpp.
|
||||
|
||||
// Private members:
|
||||
SourceLoc ltokenLoc;
|
||||
int ifdepth; //current #if-#else-#endif nesting in the cpp.c file (pre-processor)
|
||||
int elsedepth[64]; //Keep a track of #if depth..Max allowed is 64.
|
||||
int elsetracker; //#if-#else and #endif constructs...Counter.
|
||||
const char *ErrMsg;
|
||||
int CompileError; //Indicate compile error when #error, #else,#elif mismatch.
|
||||
|
||||
//
|
||||
// Globals used to communicate between PaParseStrings() and yy_input()and
|
||||
// also across the files.(gen_glslang.cpp and scanner.c)
|
||||
//
|
||||
int PaWhichStr; // which string we're parsing
|
||||
int* PaStrLen; // array of lengths of the PaArgv strings
|
||||
int PaArgc; // count of strings in the array
|
||||
char** PaArgv; // our array of strings to parse
|
||||
};
|
||||
|
||||
#endif // !defined(__COMPILE_H)
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// compile.h
|
||||
*/
|
||||
|
||||
#if !defined(__COMPILE_H)
|
||||
#define __COMPILE_H 1
|
||||
|
||||
int InitCPPStruct(void);
|
||||
|
||||
typedef struct Options_Rec{
|
||||
const char *profileString;
|
||||
int ErrorMode;
|
||||
int Quiet;
|
||||
|
||||
/* Debug The Compiler options: */
|
||||
int DumpAtomTable;
|
||||
} Options;
|
||||
|
||||
struct CPPStruct_Rec {
|
||||
/* Public members */
|
||||
SourceLoc *pLastSourceLoc; /* Set at the start of each statement by the tree walkers */
|
||||
Options options; /* Compile options and parameters */
|
||||
|
||||
/* Private members */
|
||||
SourceLoc lastSourceLoc;
|
||||
|
||||
/* Scanner data: */
|
||||
|
||||
SourceLoc *tokenLoc; /* Source location of most recent token seen by the scanner */
|
||||
int mostRecentToken; /* Most recent token seen by the scanner */
|
||||
InputSrc *currentInput;
|
||||
int previous_token;
|
||||
int notAVersionToken; /* used to make sure that #version is the first token seen in the file, if present */
|
||||
|
||||
void *pC; /* storing the parseContext of the compile object in cpp. */
|
||||
|
||||
/* Private members: */
|
||||
SourceLoc ltokenLoc;
|
||||
int ifdepth; /* current #if-#else-#endif nesting in the cpp.c file (pre-processor) */
|
||||
int elsedepth[64]; /* Keep a track of #if depth..Max allowed is 64. */
|
||||
int elsetracker; /* #if-#else and #endif constructs...Counter. */
|
||||
const char *ErrMsg;
|
||||
int CompileError; /* Indicate compile error when #error, #else,#elif mismatch. */
|
||||
|
||||
/*
|
||||
// Globals used to communicate between PaParseStrings() and yy_input()and
|
||||
// also across the files.(gen_glslang.cpp and scanner.c)
|
||||
*/
|
||||
int PaWhichStr; /* which string we're parsing */
|
||||
int* PaStrLen; /* array of lengths of the PaArgv strings */
|
||||
int PaArgc; /* count of strings in the array */
|
||||
char** PaArgv; /* our array of strings to parse */
|
||||
};
|
||||
|
||||
#endif /* !defined(__COMPILE_H) */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,118 +1,118 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// cpp.h
|
||||
//
|
||||
|
||||
#if !defined(__CPP_H)
|
||||
#define __CPP_H 1
|
||||
|
||||
#include "parser.h"
|
||||
#include "tokens.h"
|
||||
|
||||
int InitCPP(void);
|
||||
int FinalCPP(void);
|
||||
int readCPPline(yystypepp * yylvalpp);
|
||||
int MacroExpand(int atom, yystypepp * yylvalpp);
|
||||
int ChkCorrectElseNesting(void);
|
||||
|
||||
typedef struct MacroSymbol {
|
||||
int argc;
|
||||
int *args;
|
||||
TokenStream *body;
|
||||
unsigned busy:1;
|
||||
unsigned undef:1;
|
||||
} MacroSymbol;
|
||||
|
||||
void FreeMacro(MacroSymbol *);
|
||||
int PredefineMacro(char *);
|
||||
|
||||
void CPPDebugLogMsg(const char *msg); // Prints information into debug log
|
||||
void CPPShInfoLogMsg(const char*); // Store cpp Err Msg into Sh.Info.Log
|
||||
void MapStrings(const char*,const char*); // #pragma directive container.
|
||||
void ResetTString(void); // #error Message as TString.
|
||||
void CPPErrorToInfoLog(char*); // Stick all cpp errors into Sh.Info.log .
|
||||
void StoreStr(char*); // Store the TString in Parse Context.
|
||||
void SetLineNumber(int); // Set line number.
|
||||
void SetStringNumber(int); // Set string number.
|
||||
int GetLineNumber(void); // Get the current String Number.
|
||||
int GetStringNumber(void); // Get the current String Number.
|
||||
const char* GetStrfromTStr(void); // Convert TString to String.
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior);
|
||||
int FreeCPP(void);
|
||||
|
||||
#endif // !(defined(__CPP_H)
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// cpp.h
|
||||
*/
|
||||
|
||||
#if !defined(__CPP_H)
|
||||
#define __CPP_H 1
|
||||
|
||||
#include "parser.h"
|
||||
#include "tokens.h"
|
||||
|
||||
int InitCPP(void);
|
||||
int FinalCPP(void);
|
||||
int readCPPline(yystypepp * yylvalpp);
|
||||
int MacroExpand(int atom, yystypepp * yylvalpp);
|
||||
int ChkCorrectElseNesting(void);
|
||||
|
||||
typedef struct MacroSymbol {
|
||||
int argc;
|
||||
int *args;
|
||||
TokenStream *body;
|
||||
unsigned busy:1;
|
||||
unsigned undef:1;
|
||||
} MacroSymbol;
|
||||
|
||||
void FreeMacro(MacroSymbol *);
|
||||
int PredefineMacro(char *);
|
||||
|
||||
void CPPDebugLogMsg(const char *msg); /* Prints information into debug log */
|
||||
void CPPShInfoLogMsg(const char*); /* Store cpp Err Msg into Sh.Info.Log */
|
||||
void MapStrings(const char*,const char*); /* #pragma directive container. */
|
||||
void ResetTString(void); /* #error Message as TString. */
|
||||
void CPPErrorToInfoLog(char*); /* Stick all cpp errors into Sh.Info.log */
|
||||
void StoreStr(char*); /* Store the TString in Parse Context. */
|
||||
void SetLineNumber(int); /* Set line number. */
|
||||
void SetStringNumber(int); /* Set string number. */
|
||||
int GetLineNumber(void); /* Get the current String Number. */
|
||||
int GetStringNumber(void); /* Get the current String Number. */
|
||||
const char* GetStrfromTStr(void); /* Convert TString to String. */
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior);
|
||||
int FreeCPP(void);
|
||||
|
||||
#endif /* !(defined(__CPP_H) */
|
||||
|
|
|
|||
|
|
@ -1,184 +1,184 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// cppstruct.c
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
CPPStruct *cpp = NULL;
|
||||
static int refCount = 0;
|
||||
|
||||
int InitPreprocessor(void);
|
||||
int ResetPreprocessor(void);
|
||||
int FreeCPPStruct(void);
|
||||
int FinalizePreprocessor(void);
|
||||
|
||||
/*
|
||||
* InitCPPStruct() - Initilaize the CPP structure.
|
||||
*
|
||||
*/
|
||||
|
||||
int InitCPPStruct(void)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
||||
if (cpp == NULL)
|
||||
return 0;
|
||||
|
||||
refCount++;
|
||||
|
||||
// Initialize public members:
|
||||
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
||||
|
||||
p = (char *) &cpp->options;
|
||||
len = sizeof(cpp->options);
|
||||
while (--len >= 0)
|
||||
p[len] = 0;
|
||||
|
||||
ResetPreprocessor();
|
||||
return 1;
|
||||
} // InitCPPStruct
|
||||
|
||||
int ResetPreprocessor(void)
|
||||
{
|
||||
// Initialize private members:
|
||||
|
||||
cpp->lastSourceLoc.file = 0;
|
||||
cpp->lastSourceLoc.line = 0;
|
||||
cpp->pC=0;
|
||||
cpp->CompileError=0;
|
||||
cpp->ifdepth=0;
|
||||
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
||||
cpp->elsedepth[cpp->elsetracker]=0;
|
||||
cpp->elsetracker=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Intializing the Preprocessor.
|
||||
|
||||
int InitPreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeCPPStruct();
|
||||
InitCPPStruct();
|
||||
cpp->options.Quiet = 1;
|
||||
cpp->options.profileString = "generic";
|
||||
if (!InitAtomTable(atable, 0))
|
||||
return 1;
|
||||
if (!InitScanner(cpp))
|
||||
return 1;
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
//FreeCPPStruct() - Free the CPP structure.
|
||||
|
||||
int FreeCPPStruct(void)
|
||||
{
|
||||
if (refCount)
|
||||
{
|
||||
free(cpp);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Finalizing the Preprocessor.
|
||||
|
||||
int FinalizePreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeAtomTable(atable);
|
||||
FreeCPPStruct();
|
||||
FreeScanner();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// cppstruct.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
CPPStruct *cpp = NULL;
|
||||
static int refCount = 0;
|
||||
|
||||
int InitPreprocessor(void);
|
||||
int ResetPreprocessor(void);
|
||||
int FreeCPPStruct(void);
|
||||
int FinalizePreprocessor(void);
|
||||
|
||||
/*
|
||||
* InitCPPStruct() - Initilaize the CPP structure.
|
||||
*
|
||||
*/
|
||||
|
||||
int InitCPPStruct(void)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
|
||||
if (cpp == NULL)
|
||||
return 0;
|
||||
|
||||
refCount++;
|
||||
|
||||
/* Initialize public members: */
|
||||
cpp->pLastSourceLoc = &cpp->lastSourceLoc;
|
||||
|
||||
p = (char *) &cpp->options;
|
||||
len = sizeof(cpp->options);
|
||||
while (--len >= 0)
|
||||
p[len] = 0;
|
||||
|
||||
ResetPreprocessor();
|
||||
return 1;
|
||||
} /* InitCPPStruct */
|
||||
|
||||
int ResetPreprocessor(void)
|
||||
{
|
||||
/* Initialize private members: */
|
||||
|
||||
cpp->lastSourceLoc.file = 0;
|
||||
cpp->lastSourceLoc.line = 0;
|
||||
cpp->pC=0;
|
||||
cpp->CompileError=0;
|
||||
cpp->ifdepth=0;
|
||||
for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
|
||||
cpp->elsedepth[cpp->elsetracker]=0;
|
||||
cpp->elsetracker=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*Intializing the Preprocessor. */
|
||||
|
||||
int InitPreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeCPPStruct();
|
||||
InitCPPStruct();
|
||||
cpp->options.Quiet = 1;
|
||||
cpp->options.profileString = "generic";
|
||||
if (!InitAtomTable(atable, 0))
|
||||
return 1;
|
||||
if (!InitScanner(cpp))
|
||||
return 1;
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FreeCPPStruct() - Free the CPP structure. */
|
||||
|
||||
int FreeCPPStruct(void)
|
||||
{
|
||||
if (refCount)
|
||||
{
|
||||
free(cpp);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Finalizing the Preprocessor. */
|
||||
|
||||
int FinalizePreprocessor(void)
|
||||
{
|
||||
# define CPP_STUFF true
|
||||
# ifdef CPP_STUFF
|
||||
FreeAtomTable(atable);
|
||||
FreeCPPStruct();
|
||||
FreeScanner();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
|
|
|||
|
|
@ -1,191 +1,191 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __STDC99__
|
||||
#include <stdint.h>
|
||||
#elif defined (_WIN64)
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
// default alignment and chunksize, if called with 0 arguments
|
||||
#define CHUNKSIZE (64*1024)
|
||||
#define ALIGN 8
|
||||
|
||||
// we need to call the `real' malloc and free, not our replacements
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
struct chunk {
|
||||
struct chunk *next;
|
||||
};
|
||||
|
||||
struct cleanup {
|
||||
struct cleanup *next;
|
||||
void (*fn)(void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct MemoryPool_rec {
|
||||
struct chunk *next;
|
||||
uintptr_t free, end;
|
||||
size_t chunksize;
|
||||
uintptr_t alignmask;
|
||||
struct cleanup *cleanup;
|
||||
};
|
||||
|
||||
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
||||
{
|
||||
MemoryPool *pool;
|
||||
|
||||
if (align == 0) align = ALIGN;
|
||||
if (chunksize == 0) chunksize = CHUNKSIZE;
|
||||
if (align & (align-1)) return 0;
|
||||
if (chunksize < sizeof(MemoryPool)) return 0;
|
||||
if (chunksize & (align-1)) return 0;
|
||||
if (!(pool = malloc(chunksize))) return 0;
|
||||
pool->next = 0;
|
||||
pool->chunksize = chunksize;
|
||||
pool->alignmask = (uintptr_t)(align)-1;
|
||||
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
||||
pool->end = (uintptr_t)pool + chunksize;
|
||||
pool->cleanup = 0;
|
||||
return pool;
|
||||
}
|
||||
|
||||
void mem_FreePool(MemoryPool *pool)
|
||||
{
|
||||
struct cleanup *cleanup;
|
||||
struct chunk *p, *next;
|
||||
|
||||
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
||||
cleanup->fn(cleanup->arg);
|
||||
}
|
||||
for (p = (struct chunk *)pool; p; p = next) {
|
||||
next = p->next;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *mem_Alloc(MemoryPool *pool, size_t size)
|
||||
{
|
||||
struct chunk *ch;
|
||||
void *rv = (void *)pool->free;
|
||||
size = (size + pool->alignmask) & ~pool->alignmask;
|
||||
if (size <= 0) size = pool->alignmask;
|
||||
pool->free += size;
|
||||
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
||||
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
||||
& ~pool->alignmask;
|
||||
pool->free = (uintptr_t)rv;
|
||||
if (minreq >= pool->chunksize) {
|
||||
// request size is too big for the chunksize, so allocate it as
|
||||
// a single chunk of the right size
|
||||
ch = malloc(minreq);
|
||||
if (!ch) return 0;
|
||||
} else {
|
||||
ch = malloc(pool->chunksize);
|
||||
if (!ch) return 0;
|
||||
pool->free = (uintptr_t)ch + minreq;
|
||||
pool->end = (uintptr_t)ch + pool->chunksize;
|
||||
}
|
||||
ch->next = pool->next;
|
||||
pool->next = ch;
|
||||
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
||||
struct cleanup *cleanup;
|
||||
|
||||
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
||||
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
||||
if (!cleanup) return -1;
|
||||
cleanup->next = pool->cleanup;
|
||||
cleanup->fn = fn;
|
||||
cleanup->arg = arg;
|
||||
pool->cleanup = cleanup;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __STDC99__
|
||||
#include <stdint.h>
|
||||
#elif defined (_WIN64)
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
/* default alignment and chunksize, if called with 0 arguments */
|
||||
#define CHUNKSIZE (64*1024)
|
||||
#define ALIGN 8
|
||||
|
||||
/* we need to call the `real' malloc and free, not our replacements */
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
struct chunk {
|
||||
struct chunk *next;
|
||||
};
|
||||
|
||||
struct cleanup {
|
||||
struct cleanup *next;
|
||||
void (*fn)(void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct MemoryPool_rec {
|
||||
struct chunk *next;
|
||||
uintptr_t free, end;
|
||||
size_t chunksize;
|
||||
uintptr_t alignmask;
|
||||
struct cleanup *cleanup;
|
||||
};
|
||||
|
||||
MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
|
||||
{
|
||||
MemoryPool *pool;
|
||||
|
||||
if (align == 0) align = ALIGN;
|
||||
if (chunksize == 0) chunksize = CHUNKSIZE;
|
||||
if (align & (align-1)) return 0;
|
||||
if (chunksize < sizeof(MemoryPool)) return 0;
|
||||
if (chunksize & (align-1)) return 0;
|
||||
if (!(pool = malloc(chunksize))) return 0;
|
||||
pool->next = 0;
|
||||
pool->chunksize = chunksize;
|
||||
pool->alignmask = (uintptr_t)(align)-1;
|
||||
pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
|
||||
pool->end = (uintptr_t)pool + chunksize;
|
||||
pool->cleanup = 0;
|
||||
return pool;
|
||||
}
|
||||
|
||||
void mem_FreePool(MemoryPool *pool)
|
||||
{
|
||||
struct cleanup *cleanup;
|
||||
struct chunk *p, *next;
|
||||
|
||||
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
|
||||
cleanup->fn(cleanup->arg);
|
||||
}
|
||||
for (p = (struct chunk *)pool; p; p = next) {
|
||||
next = p->next;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *mem_Alloc(MemoryPool *pool, size_t size)
|
||||
{
|
||||
struct chunk *ch;
|
||||
void *rv = (void *)pool->free;
|
||||
size = (size + pool->alignmask) & ~pool->alignmask;
|
||||
if (size <= 0) size = pool->alignmask;
|
||||
pool->free += size;
|
||||
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
|
||||
size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
|
||||
& ~pool->alignmask;
|
||||
pool->free = (uintptr_t)rv;
|
||||
if (minreq >= pool->chunksize) {
|
||||
/* request size is too big for the chunksize, so allocate it as
|
||||
// a single chunk of the right size */
|
||||
ch = malloc(minreq);
|
||||
if (!ch) return 0;
|
||||
} else {
|
||||
ch = malloc(pool->chunksize);
|
||||
if (!ch) return 0;
|
||||
pool->free = (uintptr_t)ch + minreq;
|
||||
pool->end = (uintptr_t)ch + pool->chunksize;
|
||||
}
|
||||
ch->next = pool->next;
|
||||
pool->next = ch;
|
||||
rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
|
||||
struct cleanup *cleanup;
|
||||
|
||||
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
|
||||
cleanup = mem_Alloc(pool, sizeof(struct cleanup));
|
||||
if (!cleanup) return -1;
|
||||
cleanup->next = pool->cleanup;
|
||||
cleanup->fn = fn;
|
||||
cleanup->arg = arg;
|
||||
pool->cleanup = cleanup;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,89 +1,89 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
#ifndef __MEMORY_H
|
||||
#define __MEMORY_H
|
||||
|
||||
typedef struct MemoryPool_rec MemoryPool;
|
||||
|
||||
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
||||
extern void mem_FreePool(MemoryPool *);
|
||||
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
||||
extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
|
||||
extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
|
||||
|
||||
#endif /* __MEMORY_H */
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef __MEMORY_H
|
||||
#define __MEMORY_H
|
||||
|
||||
typedef struct MemoryPool_rec MemoryPool;
|
||||
|
||||
extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
|
||||
extern void mem_FreePool(MemoryPool *);
|
||||
extern void *mem_Alloc(MemoryPool *p, size_t size);
|
||||
extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
|
||||
extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
|
||||
|
||||
#endif /* __MEMORY_H */
|
||||
|
|
|
|||
|
|
@ -1,126 +1,126 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef BISON_PARSER_H
|
||||
# define BISON_PARSER_H
|
||||
|
||||
#ifndef yystypepp
|
||||
typedef struct {
|
||||
int sc_int;
|
||||
float sc_fval;
|
||||
int sc_ident;
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
||||
} yystypepp;
|
||||
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
# define CPP_AND_OP 257
|
||||
# define CPP_SUB_ASSIGN 259
|
||||
# define CPP_MOD_ASSIGN 260
|
||||
# define CPP_ADD_ASSIGN 261
|
||||
# define CPP_DIV_ASSIGN 262
|
||||
# define CPP_MUL_ASSIGN 263
|
||||
# define CPP_EQ_OP 264
|
||||
# define CPP_XOR_OP 265
|
||||
# define ERROR_SY 266
|
||||
# define CPP_FLOATCONSTANT 267
|
||||
# define CPP_GE_OP 268
|
||||
# define CPP_RIGHT_OP 269
|
||||
# define CPP_IDENTIFIER 270
|
||||
# define CPP_INTCONSTANT 271
|
||||
# define CPP_LE_OP 272
|
||||
# define CPP_LEFT_OP 273
|
||||
# define CPP_DEC_OP 274
|
||||
# define CPP_NE_OP 275
|
||||
# define CPP_OR_OP 276
|
||||
# define CPP_INC_OP 277
|
||||
# define CPP_STRCONSTANT 278
|
||||
# define CPP_TYPEIDENTIFIER 279
|
||||
|
||||
# define FIRST_USER_TOKEN_SY 289
|
||||
|
||||
# define CPP_RIGHT_ASSIGN 280
|
||||
# define CPP_LEFT_ASSIGN 281
|
||||
# define CPP_AND_ASSIGN 282
|
||||
# define CPP_OR_ASSIGN 283
|
||||
# define CPP_XOR_ASSIGN 284
|
||||
# define CPP_LEFT_BRACKET 285
|
||||
# define CPP_RIGHT_BRACKET 286
|
||||
# define CPP_LEFT_BRACE 287
|
||||
# define CPP_RIGHT_BRACE 288
|
||||
|
||||
#endif /* not BISON_PARSER_H */
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
#ifndef BISON_PARSER_H
|
||||
# define BISON_PARSER_H
|
||||
|
||||
#ifndef yystypepp
|
||||
typedef struct {
|
||||
int sc_int;
|
||||
float sc_fval;
|
||||
int sc_ident;
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN+1];
|
||||
} yystypepp;
|
||||
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
# define CPP_AND_OP 257
|
||||
# define CPP_SUB_ASSIGN 259
|
||||
# define CPP_MOD_ASSIGN 260
|
||||
# define CPP_ADD_ASSIGN 261
|
||||
# define CPP_DIV_ASSIGN 262
|
||||
# define CPP_MUL_ASSIGN 263
|
||||
# define CPP_EQ_OP 264
|
||||
# define CPP_XOR_OP 265
|
||||
# define ERROR_SY 266
|
||||
# define CPP_FLOATCONSTANT 267
|
||||
# define CPP_GE_OP 268
|
||||
# define CPP_RIGHT_OP 269
|
||||
# define CPP_IDENTIFIER 270
|
||||
# define CPP_INTCONSTANT 271
|
||||
# define CPP_LE_OP 272
|
||||
# define CPP_LEFT_OP 273
|
||||
# define CPP_DEC_OP 274
|
||||
# define CPP_NE_OP 275
|
||||
# define CPP_OR_OP 276
|
||||
# define CPP_INC_OP 277
|
||||
# define CPP_STRCONSTANT 278
|
||||
# define CPP_TYPEIDENTIFIER 279
|
||||
|
||||
# define FIRST_USER_TOKEN_SY 289
|
||||
|
||||
# define CPP_RIGHT_ASSIGN 280
|
||||
# define CPP_LEFT_ASSIGN 281
|
||||
# define CPP_AND_ASSIGN 282
|
||||
# define CPP_OR_ASSIGN 283
|
||||
# define CPP_XOR_ASSIGN 284
|
||||
# define CPP_LEFT_BRACKET 285
|
||||
# define CPP_RIGHT_BRACKET 286
|
||||
# define CPP_LEFT_BRACE 287
|
||||
# define CPP_RIGHT_BRACE 288
|
||||
|
||||
#endif /* not BISON_PARSER_H */
|
||||
|
|
|
|||
|
|
@ -1,84 +1,84 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
# include "slglobals.h"
|
||||
extern CPPStruct *cpp;
|
||||
int InitCPPStruct(void);
|
||||
int InitScanner(CPPStruct *cpp);
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
int ScanFromString(char *s);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
|
||||
# include "slglobals.h"
|
||||
extern CPPStruct *cpp;
|
||||
int InitCPPStruct(void);
|
||||
int InitScanner(CPPStruct *cpp);
|
||||
int InitAtomTable(AtomTable *atable, int htsize);
|
||||
int ScanFromString(char *s);
|
||||
char* GetStringOfAtom(AtomTable *atable, int atom);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,118 +1,118 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// scanner.h
|
||||
//
|
||||
|
||||
#if !defined(__SCANNER_H)
|
||||
#define __SCANNER_H 1
|
||||
|
||||
#define MAX_SYMBOL_NAME_LEN 128
|
||||
#define MAX_STRING_LEN 512
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
// Not really atom table stuff but needed first...
|
||||
|
||||
typedef struct SourceLoc_Rec {
|
||||
unsigned short file, line;
|
||||
} SourceLoc;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
int yylex_CPP(char* buf, int maxSize);
|
||||
|
||||
typedef struct InputSrc {
|
||||
struct InputSrc *prev;
|
||||
int (*scan)(struct InputSrc *, yystypepp *);
|
||||
int (*getch)(struct InputSrc *, yystypepp *);
|
||||
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
||||
int name; /* atom */
|
||||
int line;
|
||||
} InputSrc;
|
||||
|
||||
int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner.
|
||||
int ScanFromString(char *); // Start scanning the input from the string mentioned.
|
||||
int check_EOF(int); // check if we hit a EOF abruptly
|
||||
void CPPErrorToInfoLog(char *); // sticking the msg,line into the Shader's.Info.log
|
||||
void SetLineNumber(int);
|
||||
void SetStringNumber(int);
|
||||
void IncLineNumber(void);
|
||||
void DecLineNumber(void);
|
||||
int FreeScanner(void); // Free the cpp scanner
|
||||
#endif // !(defined(__SCANNER_H)
|
||||
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// scanner.h
|
||||
*/
|
||||
|
||||
#if !defined(__SCANNER_H)
|
||||
#define __SCANNER_H 1
|
||||
|
||||
#define MAX_SYMBOL_NAME_LEN 128
|
||||
#define MAX_STRING_LEN 512
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
/* Not really atom table stuff but needed first... */
|
||||
|
||||
typedef struct SourceLoc_Rec {
|
||||
unsigned short file, line;
|
||||
} SourceLoc;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
int yylex_CPP(char* buf, int maxSize);
|
||||
|
||||
typedef struct InputSrc {
|
||||
struct InputSrc *prev;
|
||||
int (*scan)(struct InputSrc *, yystypepp *);
|
||||
int (*getch)(struct InputSrc *, yystypepp *);
|
||||
void (*ungetch)(struct InputSrc *, int, yystypepp *);
|
||||
int name; /* atom */
|
||||
int line;
|
||||
} InputSrc;
|
||||
|
||||
int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
|
||||
int ScanFromString(char *); /* Start scanning the input from the string mentioned. */
|
||||
int check_EOF(int); /* check if we hit a EOF abruptly */
|
||||
void CPPErrorToInfoLog(char *); /* sticking the msg,line into the Shader's.Info.log */
|
||||
void SetLineNumber(int);
|
||||
void SetStringNumber(int);
|
||||
void IncLineNumber(void);
|
||||
void DecLineNumber(void);
|
||||
int FreeScanner(void); /* Free the cpp scanner */
|
||||
#endif /* !(defined(__SCANNER_H) */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,115 +1,115 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// slglobals.h
|
||||
//
|
||||
|
||||
#if !defined(__SLGLOBALS_H)
|
||||
#define __SLGLOBALS_H 1
|
||||
|
||||
typedef struct CPPStruct_Rec CPPStruct;
|
||||
|
||||
extern CPPStruct *cpp;
|
||||
|
||||
#undef CPPC_DEBUG_THE_COMPILER
|
||||
#if defined(_DEBUG)
|
||||
#define CPPC_DEBUG_THE_COMPILER 1
|
||||
#endif
|
||||
|
||||
#undef CPPC_ENABLE_TOOLS
|
||||
#define CPPC_ENABLE_TOOLS 1
|
||||
|
||||
#include "memory.h"
|
||||
#include "atom.h"
|
||||
#include "scanner.h"
|
||||
#include "cpp.h"
|
||||
#include "tokens.h"
|
||||
#include "symbols.h"
|
||||
#include "compile.h"
|
||||
#if !defined(NO_PARSER)
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif // !(defined(__SLGLOBALS_H)
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// slglobals.h
|
||||
*/
|
||||
|
||||
#if !defined(__SLGLOBALS_H)
|
||||
#define __SLGLOBALS_H 1
|
||||
|
||||
typedef struct CPPStruct_Rec CPPStruct;
|
||||
|
||||
extern CPPStruct *cpp;
|
||||
|
||||
#undef CPPC_DEBUG_THE_COMPILER
|
||||
#if defined(_DEBUG)
|
||||
#define CPPC_DEBUG_THE_COMPILER 1
|
||||
#endif
|
||||
|
||||
#undef CPPC_ENABLE_TOOLS
|
||||
#define CPPC_ENABLE_TOOLS 1
|
||||
|
||||
#include "memory.h"
|
||||
#include "atom.h"
|
||||
#include "scanner.h"
|
||||
#include "cpp.h"
|
||||
#include "tokens.h"
|
||||
#include "symbols.h"
|
||||
#include "compile.h"
|
||||
#if !defined(NO_PARSER)
|
||||
#include "parser.h"
|
||||
#endif
|
||||
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* !(defined(__SLGLOBALS_H) */
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,318 +1,318 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// symbols.c
|
||||
//
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Scope *ScopeList = NULL;
|
||||
Scope *CurrentScope = NULL;
|
||||
Scope *GlobalScope = NULL;
|
||||
|
||||
static void unlinkScope(void *_scope) {
|
||||
Scope *scope = _scope;
|
||||
|
||||
if (scope->next)
|
||||
scope->next->prev = scope->prev;
|
||||
if (scope->prev)
|
||||
scope->prev->next = scope->next;
|
||||
else
|
||||
ScopeList = scope->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* NewScope()
|
||||
*
|
||||
*/
|
||||
Scope *NewScopeInPool(MemoryPool *pool)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = mem_Alloc(pool, sizeof(Scope));
|
||||
lScope->pool = pool;
|
||||
lScope->parent = NULL;
|
||||
lScope->funScope = NULL;
|
||||
lScope->symbols = NULL;
|
||||
|
||||
lScope->level = 0;
|
||||
|
||||
lScope->programs = NULL;
|
||||
if ((lScope->next = ScopeList))
|
||||
ScopeList->prev = lScope;
|
||||
lScope->prev = 0;
|
||||
ScopeList = lScope;
|
||||
mem_AddCleanup(pool, unlinkScope, lScope);
|
||||
return lScope;
|
||||
} // NewScope
|
||||
|
||||
/*
|
||||
* PushScope()
|
||||
*
|
||||
*/
|
||||
|
||||
void PushScope(Scope *fScope)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
if (CurrentScope) {
|
||||
fScope->level = CurrentScope->level + 1;
|
||||
if (fScope->level == 1) {
|
||||
if (!GlobalScope) {
|
||||
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
||||
* defining a function in the superglobal scope. Things
|
||||
* will break if we leave the level as 1, so we arbitrarily
|
||||
* set it to 2 */
|
||||
fScope->level = 2;
|
||||
}
|
||||
}
|
||||
if (fScope->level >= 2) {
|
||||
lScope = fScope;
|
||||
while (lScope->level > 2)
|
||||
lScope = lScope->next;
|
||||
fScope->funScope = lScope;
|
||||
}
|
||||
} else {
|
||||
fScope->level = 0;
|
||||
}
|
||||
fScope->parent = CurrentScope;
|
||||
CurrentScope = fScope;
|
||||
} // PushScope
|
||||
|
||||
/*
|
||||
* PopScope()
|
||||
*
|
||||
*/
|
||||
|
||||
Scope *PopScope(void)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = CurrentScope;
|
||||
if (CurrentScope)
|
||||
CurrentScope = CurrentScope->parent;
|
||||
return lScope;
|
||||
} // PopScope
|
||||
|
||||
/*
|
||||
* NewSymbol() - Allocate a new symbol node;
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
char *pch;
|
||||
int ii;
|
||||
|
||||
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
||||
lSymb->left = NULL;
|
||||
lSymb->right = NULL;
|
||||
lSymb->next = NULL;
|
||||
lSymb->name = name;
|
||||
lSymb->loc = *loc;
|
||||
lSymb->kind = kind;
|
||||
|
||||
// Clear union area:
|
||||
|
||||
pch = (char *) &lSymb->details;
|
||||
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
||||
*pch++ = 0;
|
||||
return lSymb;
|
||||
} // NewSymbol
|
||||
|
||||
/*
|
||||
* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
|
||||
* are generated in order. We'll fix this later (by reversing the bit pattern).
|
||||
*/
|
||||
|
||||
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int lrev, frev;
|
||||
|
||||
lSymb = *fSymbols;
|
||||
if (lSymb) {
|
||||
frev = GetReversedAtom(atable, fSymb->name);
|
||||
while (lSymb) {
|
||||
lrev = GetReversedAtom(atable, lSymb->name);
|
||||
if (lrev == frev) {
|
||||
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
||||
break;
|
||||
} else {
|
||||
if (lrev > frev) {
|
||||
if (lSymb->left) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb->left = fSymb;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (lSymb->right) {
|
||||
lSymb = lSymb->right;
|
||||
} else {
|
||||
lSymb->right = fSymb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*fSymbols = fSymb;
|
||||
}
|
||||
} // lAddToTree
|
||||
|
||||
|
||||
/*
|
||||
* AddSymbol() - Add a variable, type, or function name to a scope.
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = NewSymbol(loc, fScope, atom, kind);
|
||||
lAddToTree(&fScope->symbols, lSymb);
|
||||
return lSymb;
|
||||
} // AddSymbol
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
/************************************ Symbol Semantic Functions ******************************/
|
||||
/*********************************************************************************************/
|
||||
|
||||
/*
|
||||
* LookUpLocalSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int rname, ratom;
|
||||
|
||||
ratom = GetReversedAtom(atable, atom);
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = fScope->symbols;
|
||||
while (lSymb) {
|
||||
rname = GetReversedAtom(atable, lSymb->name);
|
||||
if (rname == ratom) {
|
||||
return lSymb;
|
||||
} else {
|
||||
if (rname > ratom) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb = lSymb->right;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} // LookUpLocalSymbol
|
||||
|
||||
/*
|
||||
* LookUpSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
while (fScope) {
|
||||
lSymb = LookUpLocalSymbol(fScope, atom);
|
||||
if (lSymb)
|
||||
return lSymb;
|
||||
fScope = fScope->parent;
|
||||
}
|
||||
return NULL;
|
||||
} // LookUpSymbol
|
||||
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// symbols.c
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
Scope *ScopeList = NULL;
|
||||
Scope *CurrentScope = NULL;
|
||||
Scope *GlobalScope = NULL;
|
||||
|
||||
static void unlinkScope(void *_scope) {
|
||||
Scope *scope = _scope;
|
||||
|
||||
if (scope->next)
|
||||
scope->next->prev = scope->prev;
|
||||
if (scope->prev)
|
||||
scope->prev->next = scope->next;
|
||||
else
|
||||
ScopeList = scope->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* NewScope()
|
||||
*
|
||||
*/
|
||||
Scope *NewScopeInPool(MemoryPool *pool)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = mem_Alloc(pool, sizeof(Scope));
|
||||
lScope->pool = pool;
|
||||
lScope->parent = NULL;
|
||||
lScope->funScope = NULL;
|
||||
lScope->symbols = NULL;
|
||||
|
||||
lScope->level = 0;
|
||||
|
||||
lScope->programs = NULL;
|
||||
if ((lScope->next = ScopeList))
|
||||
ScopeList->prev = lScope;
|
||||
lScope->prev = 0;
|
||||
ScopeList = lScope;
|
||||
mem_AddCleanup(pool, unlinkScope, lScope);
|
||||
return lScope;
|
||||
} /* NewScope */
|
||||
|
||||
/*
|
||||
* PushScope()
|
||||
*
|
||||
*/
|
||||
|
||||
void PushScope(Scope *fScope)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
if (CurrentScope) {
|
||||
fScope->level = CurrentScope->level + 1;
|
||||
if (fScope->level == 1) {
|
||||
if (!GlobalScope) {
|
||||
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
|
||||
* defining a function in the superglobal scope. Things
|
||||
* will break if we leave the level as 1, so we arbitrarily
|
||||
* set it to 2 */
|
||||
fScope->level = 2;
|
||||
}
|
||||
}
|
||||
if (fScope->level >= 2) {
|
||||
lScope = fScope;
|
||||
while (lScope->level > 2)
|
||||
lScope = lScope->next;
|
||||
fScope->funScope = lScope;
|
||||
}
|
||||
} else {
|
||||
fScope->level = 0;
|
||||
}
|
||||
fScope->parent = CurrentScope;
|
||||
CurrentScope = fScope;
|
||||
} /* PushScope */
|
||||
|
||||
/*
|
||||
* PopScope()
|
||||
*
|
||||
*/
|
||||
|
||||
Scope *PopScope(void)
|
||||
{
|
||||
Scope *lScope;
|
||||
|
||||
lScope = CurrentScope;
|
||||
if (CurrentScope)
|
||||
CurrentScope = CurrentScope->parent;
|
||||
return lScope;
|
||||
} /* PopScope */
|
||||
|
||||
/*
|
||||
* NewSymbol() - Allocate a new symbol node;
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
char *pch;
|
||||
int ii;
|
||||
|
||||
lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
|
||||
lSymb->left = NULL;
|
||||
lSymb->right = NULL;
|
||||
lSymb->next = NULL;
|
||||
lSymb->name = name;
|
||||
lSymb->loc = *loc;
|
||||
lSymb->kind = kind;
|
||||
|
||||
/* Clear union area: */
|
||||
|
||||
pch = (char *) &lSymb->details;
|
||||
for (ii = 0; ii < sizeof(lSymb->details); ii++)
|
||||
*pch++ = 0;
|
||||
return lSymb;
|
||||
} /* NewSymbol */
|
||||
|
||||
/*
|
||||
* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
|
||||
* are generated in order. We'll fix this later (by reversing the bit pattern).
|
||||
*/
|
||||
|
||||
static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int lrev, frev;
|
||||
|
||||
lSymb = *fSymbols;
|
||||
if (lSymb) {
|
||||
frev = GetReversedAtom(atable, fSymb->name);
|
||||
while (lSymb) {
|
||||
lrev = GetReversedAtom(atable, lSymb->name);
|
||||
if (lrev == frev) {
|
||||
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
|
||||
break;
|
||||
} else {
|
||||
if (lrev > frev) {
|
||||
if (lSymb->left) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb->left = fSymb;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (lSymb->right) {
|
||||
lSymb = lSymb->right;
|
||||
} else {
|
||||
lSymb->right = fSymb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*fSymbols = fSymb;
|
||||
}
|
||||
} /* lAddToTree */
|
||||
|
||||
|
||||
/*
|
||||
* AddSymbol() - Add a variable, type, or function name to a scope.
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = NewSymbol(loc, fScope, atom, kind);
|
||||
lAddToTree(&fScope->symbols, lSymb);
|
||||
return lSymb;
|
||||
} /* AddSymbol */
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
/************************************ Symbol Semantic Functions ******************************/
|
||||
/*********************************************************************************************/
|
||||
|
||||
/*
|
||||
* LookUpLocalSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
int rname, ratom;
|
||||
|
||||
ratom = GetReversedAtom(atable, atom);
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
lSymb = fScope->symbols;
|
||||
while (lSymb) {
|
||||
rname = GetReversedAtom(atable, lSymb->name);
|
||||
if (rname == ratom) {
|
||||
return lSymb;
|
||||
} else {
|
||||
if (rname > ratom) {
|
||||
lSymb = lSymb->left;
|
||||
} else {
|
||||
lSymb = lSymb->right;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* LookUpLocalSymbol */
|
||||
|
||||
/*
|
||||
* LookUpSymbol()
|
||||
*
|
||||
*/
|
||||
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom)
|
||||
{
|
||||
Symbol *lSymb;
|
||||
|
||||
if (!fScope)
|
||||
fScope = CurrentScope;
|
||||
while (fScope) {
|
||||
lSymb = LookUpLocalSymbol(fScope, atom);
|
||||
if (lSymb)
|
||||
return lSymb;
|
||||
fScope = fScope->parent;
|
||||
}
|
||||
return NULL;
|
||||
} /* LookUpSymbol */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,145 +1,145 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// symbols.h
|
||||
//
|
||||
|
||||
#if !defined(__SYMBOLS_H)
|
||||
#define __SYMBOLS_H 1
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
typedef enum symbolkind {
|
||||
MACRO_S
|
||||
} symbolkind;
|
||||
|
||||
// Typedefs for things defined here in "symbols.h":
|
||||
|
||||
typedef struct Scope_Rec Scope;
|
||||
typedef struct Symbol_Rec Symbol;
|
||||
|
||||
typedef struct SymbolList_Rec {
|
||||
struct SymbolList_Rec *next;
|
||||
Symbol *symb;
|
||||
} SymbolList;
|
||||
|
||||
struct Scope_Rec {
|
||||
Scope *next, *prev; // doubly-linked list of all scopes
|
||||
Scope *parent;
|
||||
Scope *funScope; // Points to base scope of enclosing function
|
||||
MemoryPool *pool; // pool used for allocation in this scope
|
||||
Symbol *symbols;
|
||||
|
||||
int level; // 0 = super globals, 1 = globals, etc.
|
||||
|
||||
// Only used at global scope (level 1):
|
||||
SymbolList *programs; // List of programs for this compilation.
|
||||
};
|
||||
|
||||
|
||||
// Symbol table is a simple binary tree.
|
||||
|
||||
#include "cpp.h" // to get MacroSymbol def
|
||||
|
||||
struct Symbol_Rec {
|
||||
Symbol *left, *right;
|
||||
Symbol *next;
|
||||
int name; // Name atom
|
||||
SourceLoc loc;
|
||||
symbolkind kind;
|
||||
union {
|
||||
MacroSymbol mac;
|
||||
} details;
|
||||
};
|
||||
|
||||
extern Scope *CurrentScope;
|
||||
extern Scope *GlobalScope;
|
||||
extern Scope *ScopeList;
|
||||
|
||||
Scope *NewScopeInPool(MemoryPool *);
|
||||
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
||||
void PushScope(Scope *fScope);
|
||||
Scope *PopScope(void);
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
||||
void CPPErrorToInfoLog(char *);
|
||||
|
||||
|
||||
#endif // !defined(__SYMBOLS_H)
|
||||
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// symbols.h
|
||||
*/
|
||||
|
||||
#if !defined(__SYMBOLS_H)
|
||||
#define __SYMBOLS_H 1
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
typedef enum symbolkind {
|
||||
MACRO_S
|
||||
} symbolkind;
|
||||
|
||||
/* Typedefs for things defined here in "symbols.h": */
|
||||
|
||||
typedef struct Scope_Rec Scope;
|
||||
typedef struct Symbol_Rec Symbol;
|
||||
|
||||
typedef struct SymbolList_Rec {
|
||||
struct SymbolList_Rec *next;
|
||||
Symbol *symb;
|
||||
} SymbolList;
|
||||
|
||||
struct Scope_Rec {
|
||||
Scope *next, *prev; /* doubly-linked list of all scopes */
|
||||
Scope *parent;
|
||||
Scope *funScope; /* Points to base scope of enclosing function */
|
||||
MemoryPool *pool; /* pool used for allocation in this scope */
|
||||
Symbol *symbols;
|
||||
|
||||
int level; /* 0 = super globals, 1 = globals, etc. */
|
||||
|
||||
/* Only used at global scope (level 1): */
|
||||
SymbolList *programs; /* List of programs for this compilation. */
|
||||
};
|
||||
|
||||
|
||||
/* Symbol table is a simple binary tree. */
|
||||
|
||||
#include "cpp.h" /* to get MacroSymbol def */
|
||||
|
||||
struct Symbol_Rec {
|
||||
Symbol *left, *right;
|
||||
Symbol *next;
|
||||
int name; /* Name atom */
|
||||
SourceLoc loc;
|
||||
symbolkind kind;
|
||||
union {
|
||||
MacroSymbol mac;
|
||||
} details;
|
||||
};
|
||||
|
||||
extern Scope *CurrentScope;
|
||||
extern Scope *GlobalScope;
|
||||
extern Scope *ScopeList;
|
||||
|
||||
Scope *NewScopeInPool(MemoryPool *);
|
||||
#define NewScope() NewScopeInPool(CurrentScope->pool)
|
||||
void PushScope(Scope *fScope);
|
||||
Scope *PopScope(void);
|
||||
Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
|
||||
Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
|
||||
Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
|
||||
Symbol *LookUpSymbol(Scope *fScope, int atom);
|
||||
void CPPErrorToInfoLog(char *);
|
||||
|
||||
|
||||
#endif /* !defined(__SYMBOLS_H) */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,464 +1,464 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// tokens.c
|
||||
//
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
#include "slang_mesa.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* idstr()
|
||||
* Copy a string to a malloc'ed block and convert it into something suitable
|
||||
* for an ID
|
||||
*
|
||||
*/
|
||||
|
||||
static char *idstr(const char *fstr)
|
||||
{
|
||||
size_t len;
|
||||
char *str, *t;
|
||||
const char *f;
|
||||
|
||||
len = strlen(fstr);
|
||||
str = (char *) malloc(len + 1);
|
||||
for (f=fstr, t=str; *f; f++) {
|
||||
if (_mesa_isalnum(*f)) *t++ = *f;
|
||||
else if (*f == '.' || *f == '/') *t++ = '_';
|
||||
}
|
||||
*t = 0;
|
||||
return str;
|
||||
} // idstr
|
||||
|
||||
|
||||
/*
|
||||
* lNewBlock()
|
||||
*
|
||||
*/
|
||||
|
||||
static TokenBlock *lNewBlock(TokenStream *fTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
|
||||
lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
|
||||
lBlock->count = 0;
|
||||
lBlock->current = 0;
|
||||
lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
|
||||
lBlock->max = 256;
|
||||
lBlock->next = NULL;
|
||||
if (fTok->head) {
|
||||
fTok->current->next = lBlock;
|
||||
} else {
|
||||
fTok->head = lBlock;
|
||||
}
|
||||
fTok->current = lBlock;
|
||||
return lBlock;
|
||||
} // lNewBlock
|
||||
|
||||
/*
|
||||
* lAddByte()
|
||||
*
|
||||
*/
|
||||
|
||||
static void lAddByte(TokenStream *fTok, unsigned char fVal)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
lBlock = fTok->current;
|
||||
if (lBlock->count >= lBlock->max)
|
||||
lBlock = lNewBlock(fTok);
|
||||
lBlock->data[lBlock->count++] = fVal;
|
||||
} // lAddByte
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* lReadByte() - Get the next byte from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
static int lReadByte(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
int lval = -1;
|
||||
|
||||
lBlock = pTok->current;
|
||||
if (lBlock) {
|
||||
if (lBlock->current >= lBlock->count) {
|
||||
lBlock = lBlock->next;
|
||||
if (lBlock)
|
||||
lBlock->current = 0;
|
||||
pTok->current = lBlock;
|
||||
}
|
||||
if (lBlock)
|
||||
lval = lBlock->data[lBlock->current++];
|
||||
}
|
||||
return lval;
|
||||
} // lReadByte
|
||||
|
||||
/////////////////////////////////////// Global Functions://////////////////////////////////////
|
||||
|
||||
/*
|
||||
* NewTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
TokenStream *NewTokenStream(const char *name)
|
||||
{
|
||||
TokenStream *pTok;
|
||||
|
||||
pTok = (TokenStream *) malloc(sizeof(TokenStream));
|
||||
pTok->next = NULL;
|
||||
pTok->name = idstr(name);
|
||||
pTok->head = NULL;
|
||||
pTok->current = NULL;
|
||||
lNewBlock(pTok);
|
||||
return pTok;
|
||||
} // NewTokenStream
|
||||
|
||||
/*
|
||||
* DeleteTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
void DeleteTokenStream(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *pBlock, *nBlock;
|
||||
|
||||
if (pTok) {
|
||||
pBlock = pTok->head;
|
||||
while (pBlock) {
|
||||
nBlock = pBlock->next;
|
||||
free(pBlock);
|
||||
pBlock = nBlock;
|
||||
}
|
||||
if (pTok->name)
|
||||
free(pTok->name);
|
||||
free(pTok);
|
||||
}
|
||||
} // DeleteTokenStream
|
||||
|
||||
/*
|
||||
* RecordToken() - Add a token to the end of a list for later playback or printout.
|
||||
*
|
||||
*/
|
||||
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
|
||||
{
|
||||
const char *s;
|
||||
unsigned char *str=NULL;
|
||||
|
||||
if (token > 256)
|
||||
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
|
||||
else
|
||||
lAddByte(pTok, (unsigned char)(token & 0x7f));
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
case CPP_STRCONSTANT:
|
||||
s = GetAtomString(atable, yylvalpp->sc_ident);
|
||||
while (*s)
|
||||
lAddByte(pTok, (unsigned char) *s++);
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
case CPP_INTCONSTANT:
|
||||
str=yylvalpp->symbol_name;
|
||||
while (*str){
|
||||
lAddByte(pTok,(unsigned char) *str);
|
||||
*str++;
|
||||
}
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case '(':
|
||||
lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} // RecordToken
|
||||
|
||||
/*
|
||||
* RewindTokenStream() - Reset a token stream in preperation for reading.
|
||||
*
|
||||
*/
|
||||
|
||||
void RewindTokenStream(TokenStream *pTok)
|
||||
{
|
||||
if (pTok->head) {
|
||||
pTok->current = pTok->head;
|
||||
pTok->current->current = 0;
|
||||
}
|
||||
} // RewindTokenStream
|
||||
|
||||
/*
|
||||
* ReadToken() - Read the next token from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
|
||||
{
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
|
||||
char string_val[MAX_STRING_LEN + 1];
|
||||
int ltoken, len;
|
||||
char ch;
|
||||
|
||||
ltoken = lReadByte(pTok);
|
||||
if (ltoken >= 0) {
|
||||
if (ltoken > 127)
|
||||
ltoken += 128;
|
||||
switch (ltoken) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9') ||
|
||||
ch == '_')
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
|
||||
return CPP_IDENTIFIER;
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
len = 0;
|
||||
while ((ch = lReadByte(pTok)) != 0)
|
||||
if (len < MAX_STRING_LEN)
|
||||
string_val[len++] = ch;
|
||||
string_val[len] = 0;
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
|
||||
break;
|
||||
case '(':
|
||||
yylvalpp->sc_int = lReadByte(pTok);
|
||||
break;
|
||||
}
|
||||
return ltoken;
|
||||
}
|
||||
return EOF_SY;
|
||||
} // ReadToken
|
||||
|
||||
typedef struct TokenInputSrc {
|
||||
InputSrc base;
|
||||
TokenStream *tokens;
|
||||
int (*final)(CPPStruct *);
|
||||
} TokenInputSrc;
|
||||
|
||||
static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = ReadToken(in->tokens, yylvalpp);
|
||||
int (*final)(CPPStruct *);
|
||||
cpp->tokenLoc->file = cpp->currentInput->name;
|
||||
cpp->tokenLoc->line = cpp->currentInput->line;
|
||||
if (token == '\n') {
|
||||
in->base.line++;
|
||||
return token;
|
||||
}
|
||||
if (token > 0) return token;
|
||||
cpp->currentInput = in->base.prev;
|
||||
final = in->final;
|
||||
free(in);
|
||||
if (final && !final(cpp)) return -1;
|
||||
return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
}
|
||||
|
||||
int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
|
||||
{
|
||||
TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
|
||||
memset(in, 0, sizeof(TokenInputSrc));
|
||||
in->base.name = name;
|
||||
in->base.prev = cpp->currentInput;
|
||||
in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
|
||||
in->base.line = 1;
|
||||
in->tokens = ts;
|
||||
in->final = final;
|
||||
RewindTokenStream(ts);
|
||||
cpp->currentInput = &in->base;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct UngotToken {
|
||||
InputSrc base;
|
||||
int token;
|
||||
yystypepp lval;
|
||||
} UngotToken;
|
||||
|
||||
static int reget_token(UngotToken *t, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = t->token;
|
||||
*yylvalpp = t->lval;
|
||||
cpp->currentInput = t->base.prev;
|
||||
free(t);
|
||||
return token;
|
||||
}
|
||||
|
||||
void UngetToken(int token, yystypepp * yylvalpp) {
|
||||
UngotToken *t = malloc(sizeof(UngotToken));
|
||||
memset(t, 0, sizeof(UngotToken));
|
||||
t->token = token;
|
||||
t->lval = *yylvalpp;
|
||||
t->base.scan = (void *)reget_token;
|
||||
t->base.prev = cpp->currentInput;
|
||||
t->base.name = cpp->currentInput->name;
|
||||
t->base.line = cpp->currentInput->line;
|
||||
cpp->currentInput = &t->base;
|
||||
}
|
||||
|
||||
|
||||
void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
|
||||
int token;
|
||||
char str[100];
|
||||
|
||||
if (fp == 0) fp = stdout;
|
||||
RewindTokenStream(s);
|
||||
while ((token = ReadToken(s, yylvalpp)) > 0) {
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
//printf("%g9.6 ", yylvalpp->sc_fval);
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
//printf("%d ", yylvalpp->sc_int);
|
||||
break;
|
||||
default:
|
||||
if (token >= 127)
|
||||
sprintf(str, "%s ", GetAtomString(atable, token));
|
||||
else
|
||||
sprintf(str, "%c", token);
|
||||
break;
|
||||
}
|
||||
CPPDebugLogMsg(str);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// tokens.c
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "slglobals.h"
|
||||
|
||||
#include "slang_mesa.h"
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
/*
|
||||
* idstr()
|
||||
* Copy a string to a malloc'ed block and convert it into something suitable
|
||||
* for an ID
|
||||
*
|
||||
*/
|
||||
|
||||
static char *idstr(const char *fstr)
|
||||
{
|
||||
size_t len;
|
||||
char *str, *t;
|
||||
const char *f;
|
||||
|
||||
len = strlen(fstr);
|
||||
str = (char *) malloc(len + 1);
|
||||
for (f=fstr, t=str; *f; f++) {
|
||||
if (_mesa_isalnum(*f)) *t++ = *f;
|
||||
else if (*f == '.' || *f == '/') *t++ = '_';
|
||||
}
|
||||
*t = 0;
|
||||
return str;
|
||||
} /* idstr */
|
||||
|
||||
|
||||
/*
|
||||
* lNewBlock()
|
||||
*
|
||||
*/
|
||||
|
||||
static TokenBlock *lNewBlock(TokenStream *fTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
|
||||
lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
|
||||
lBlock->count = 0;
|
||||
lBlock->current = 0;
|
||||
lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
|
||||
lBlock->max = 256;
|
||||
lBlock->next = NULL;
|
||||
if (fTok->head) {
|
||||
fTok->current->next = lBlock;
|
||||
} else {
|
||||
fTok->head = lBlock;
|
||||
}
|
||||
fTok->current = lBlock;
|
||||
return lBlock;
|
||||
} /* lNewBlock */
|
||||
|
||||
/*
|
||||
* lAddByte()
|
||||
*
|
||||
*/
|
||||
|
||||
static void lAddByte(TokenStream *fTok, unsigned char fVal)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
lBlock = fTok->current;
|
||||
if (lBlock->count >= lBlock->max)
|
||||
lBlock = lNewBlock(fTok);
|
||||
lBlock->data[lBlock->count++] = fVal;
|
||||
} /* lAddByte */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* lReadByte() - Get the next byte from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
static int lReadByte(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *lBlock;
|
||||
int lval = -1;
|
||||
|
||||
lBlock = pTok->current;
|
||||
if (lBlock) {
|
||||
if (lBlock->current >= lBlock->count) {
|
||||
lBlock = lBlock->next;
|
||||
if (lBlock)
|
||||
lBlock->current = 0;
|
||||
pTok->current = lBlock;
|
||||
}
|
||||
if (lBlock)
|
||||
lval = lBlock->data[lBlock->current++];
|
||||
}
|
||||
return lval;
|
||||
} /* lReadByte */
|
||||
|
||||
/*///////////////////////////////////// Global Functions:////////////////////////////////////*/
|
||||
|
||||
/*
|
||||
* NewTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
TokenStream *NewTokenStream(const char *name)
|
||||
{
|
||||
TokenStream *pTok;
|
||||
|
||||
pTok = (TokenStream *) malloc(sizeof(TokenStream));
|
||||
pTok->next = NULL;
|
||||
pTok->name = idstr(name);
|
||||
pTok->head = NULL;
|
||||
pTok->current = NULL;
|
||||
lNewBlock(pTok);
|
||||
return pTok;
|
||||
} /* NewTokenStream */
|
||||
|
||||
/*
|
||||
* DeleteTokenStream()
|
||||
*
|
||||
*/
|
||||
|
||||
void DeleteTokenStream(TokenStream *pTok)
|
||||
{
|
||||
TokenBlock *pBlock, *nBlock;
|
||||
|
||||
if (pTok) {
|
||||
pBlock = pTok->head;
|
||||
while (pBlock) {
|
||||
nBlock = pBlock->next;
|
||||
free(pBlock);
|
||||
pBlock = nBlock;
|
||||
}
|
||||
if (pTok->name)
|
||||
free(pTok->name);
|
||||
free(pTok);
|
||||
}
|
||||
} /* DeleteTokenStream */
|
||||
|
||||
/*
|
||||
* RecordToken() - Add a token to the end of a list for later playback or printout.
|
||||
*
|
||||
*/
|
||||
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
|
||||
{
|
||||
const char *s;
|
||||
unsigned char *str=NULL;
|
||||
|
||||
if (token > 256)
|
||||
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
|
||||
else
|
||||
lAddByte(pTok, (unsigned char)(token & 0x7f));
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
case CPP_STRCONSTANT:
|
||||
s = GetAtomString(atable, yylvalpp->sc_ident);
|
||||
while (*s)
|
||||
lAddByte(pTok, (unsigned char) *s++);
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
case CPP_INTCONSTANT:
|
||||
str=yylvalpp->symbol_name;
|
||||
while (*str){
|
||||
lAddByte(pTok,(unsigned char) *str);
|
||||
*str++;
|
||||
}
|
||||
lAddByte(pTok, 0);
|
||||
break;
|
||||
case '(':
|
||||
lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} /* RecordToken */
|
||||
|
||||
/*
|
||||
* RewindTokenStream() - Reset a token stream in preperation for reading.
|
||||
*
|
||||
*/
|
||||
|
||||
void RewindTokenStream(TokenStream *pTok)
|
||||
{
|
||||
if (pTok->head) {
|
||||
pTok->current = pTok->head;
|
||||
pTok->current->current = 0;
|
||||
}
|
||||
} /* RewindTokenStream */
|
||||
|
||||
/*
|
||||
* ReadToken() - Read the next token from a stream.
|
||||
*
|
||||
*/
|
||||
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
|
||||
{
|
||||
char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
|
||||
char string_val[MAX_STRING_LEN + 1];
|
||||
int ltoken, len;
|
||||
char ch;
|
||||
|
||||
ltoken = lReadByte(pTok);
|
||||
if (ltoken >= 0) {
|
||||
if (ltoken > 127)
|
||||
ltoken += 128;
|
||||
switch (ltoken) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9') ||
|
||||
ch == '_')
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
|
||||
return CPP_IDENTIFIER;
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
len = 0;
|
||||
while ((ch = lReadByte(pTok)) != 0)
|
||||
if (len < MAX_STRING_LEN)
|
||||
string_val[len++] = ch;
|
||||
string_val[len] = 0;
|
||||
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
len = 0;
|
||||
ch = lReadByte(pTok);
|
||||
while ((ch >= '0' && ch <= '9'))
|
||||
{
|
||||
if (len < MAX_SYMBOL_NAME_LEN) {
|
||||
symbol_name[len] = ch;
|
||||
len++;
|
||||
ch = lReadByte(pTok);
|
||||
}
|
||||
}
|
||||
symbol_name[len] = '\0';
|
||||
assert(ch == '\0');
|
||||
strcpy(yylvalpp->symbol_name,symbol_name);
|
||||
yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
|
||||
break;
|
||||
case '(':
|
||||
yylvalpp->sc_int = lReadByte(pTok);
|
||||
break;
|
||||
}
|
||||
return ltoken;
|
||||
}
|
||||
return EOF_SY;
|
||||
} /* ReadToken */
|
||||
|
||||
typedef struct TokenInputSrc {
|
||||
InputSrc base;
|
||||
TokenStream *tokens;
|
||||
int (*final)(CPPStruct *);
|
||||
} TokenInputSrc;
|
||||
|
||||
static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = ReadToken(in->tokens, yylvalpp);
|
||||
int (*final)(CPPStruct *);
|
||||
cpp->tokenLoc->file = cpp->currentInput->name;
|
||||
cpp->tokenLoc->line = cpp->currentInput->line;
|
||||
if (token == '\n') {
|
||||
in->base.line++;
|
||||
return token;
|
||||
}
|
||||
if (token > 0) return token;
|
||||
cpp->currentInput = in->base.prev;
|
||||
final = in->final;
|
||||
free(in);
|
||||
if (final && !final(cpp)) return -1;
|
||||
return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
}
|
||||
|
||||
int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
|
||||
{
|
||||
TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
|
||||
memset(in, 0, sizeof(TokenInputSrc));
|
||||
in->base.name = name;
|
||||
in->base.prev = cpp->currentInput;
|
||||
in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
|
||||
in->base.line = 1;
|
||||
in->tokens = ts;
|
||||
in->final = final;
|
||||
RewindTokenStream(ts);
|
||||
cpp->currentInput = &in->base;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct UngotToken {
|
||||
InputSrc base;
|
||||
int token;
|
||||
yystypepp lval;
|
||||
} UngotToken;
|
||||
|
||||
static int reget_token(UngotToken *t, yystypepp * yylvalpp)
|
||||
{
|
||||
int token = t->token;
|
||||
*yylvalpp = t->lval;
|
||||
cpp->currentInput = t->base.prev;
|
||||
free(t);
|
||||
return token;
|
||||
}
|
||||
|
||||
void UngetToken(int token, yystypepp * yylvalpp) {
|
||||
UngotToken *t = malloc(sizeof(UngotToken));
|
||||
memset(t, 0, sizeof(UngotToken));
|
||||
t->token = token;
|
||||
t->lval = *yylvalpp;
|
||||
t->base.scan = (void *)reget_token;
|
||||
t->base.prev = cpp->currentInput;
|
||||
t->base.name = cpp->currentInput->name;
|
||||
t->base.line = cpp->currentInput->line;
|
||||
cpp->currentInput = &t->base;
|
||||
}
|
||||
|
||||
|
||||
void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
|
||||
int token;
|
||||
char str[100];
|
||||
|
||||
if (fp == 0) fp = stdout;
|
||||
RewindTokenStream(s);
|
||||
while ((token = ReadToken(s, yylvalpp)) > 0) {
|
||||
switch (token) {
|
||||
case CPP_IDENTIFIER:
|
||||
case CPP_TYPEIDENTIFIER:
|
||||
sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_STRCONSTANT:
|
||||
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
|
||||
break;
|
||||
case CPP_FLOATCONSTANT:
|
||||
/*printf("%g9.6 ", yylvalpp->sc_fval);*/
|
||||
break;
|
||||
case CPP_INTCONSTANT:
|
||||
/*printf("%d ", yylvalpp->sc_int);*/
|
||||
break;
|
||||
default:
|
||||
if (token >= 127)
|
||||
sprintf(str, "%s ", GetAtomString(atable, token));
|
||||
else
|
||||
sprintf(str, "%c", token);
|
||||
break;
|
||||
}
|
||||
CPPDebugLogMsg(str);
|
||||
}
|
||||
}
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
|
|
|||
|
|
@ -1,122 +1,122 @@
|
|||
//
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
//
|
||||
// tokens.h
|
||||
//
|
||||
|
||||
#if !defined(__TOKENS_H)
|
||||
#define __TOKENS_H 1
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#define EOF_SY (-1)
|
||||
|
||||
typedef struct TokenBlock_Rec TokenBlock;
|
||||
|
||||
typedef struct TokenStream_Rec {
|
||||
struct TokenStream_Rec *next;
|
||||
char *name;
|
||||
TokenBlock *head;
|
||||
TokenBlock *current;
|
||||
} TokenStream;
|
||||
|
||||
struct TokenBlock_Rec {
|
||||
TokenBlock *next;
|
||||
int current;
|
||||
int count;
|
||||
int max;
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
extern TokenStream stdlib_cpp_stream;
|
||||
|
||||
|
||||
TokenStream *NewTokenStream(const char *name);
|
||||
void DeleteTokenStream(TokenStream *pTok);
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
||||
void RewindTokenStream(TokenStream *pTok);
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
||||
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
||||
void UngetToken(int, yystypepp * yylvalpp);
|
||||
|
||||
#if defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
||||
|
||||
#endif // defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
#endif // !defined(__TOKENS_H)
|
||||
/*
|
||||
//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
|
||||
//All rights reserved.
|
||||
//
|
||||
//Redistribution and use in source and binary forms, with or without
|
||||
//modification, are permitted provided that the following conditions
|
||||
//are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/****************************************************************************\
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
\****************************************************************************/
|
||||
/*
|
||||
// tokens.h
|
||||
*/
|
||||
|
||||
#if !defined(__TOKENS_H)
|
||||
#define __TOKENS_H 1
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#define EOF_SY (-1)
|
||||
|
||||
typedef struct TokenBlock_Rec TokenBlock;
|
||||
|
||||
typedef struct TokenStream_Rec {
|
||||
struct TokenStream_Rec *next;
|
||||
char *name;
|
||||
TokenBlock *head;
|
||||
TokenBlock *current;
|
||||
} TokenStream;
|
||||
|
||||
struct TokenBlock_Rec {
|
||||
TokenBlock *next;
|
||||
int current;
|
||||
int count;
|
||||
int max;
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
extern TokenStream stdlib_cpp_stream;
|
||||
|
||||
|
||||
TokenStream *NewTokenStream(const char *name);
|
||||
void DeleteTokenStream(TokenStream *pTok);
|
||||
void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
|
||||
void RewindTokenStream(TokenStream *pTok);
|
||||
int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
|
||||
int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
|
||||
void UngetToken(int, yystypepp * yylvalpp);
|
||||
|
||||
#if defined(CPPC_ENABLE_TOOLS)
|
||||
|
||||
void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
|
||||
|
||||
#endif /* defined(CPPC_ENABLE_TOOLS) */
|
||||
|
||||
#endif /* !defined(__TOKENS_H) */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue