Initial commit.

This commit is contained in:
Branimir Karadzic
2012-04-03 20:30:07 -07:00
commit dee3fe5266
1432 changed files with 234521 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.build

6
3rdparty/compiler/mingw/alloca.h vendored Normal file
View File

@@ -0,0 +1,6 @@
#ifndef __MINGW32__ALLOCA_H__
#define __MINGW32__ALLOCA_H__
#include <malloc.h>
#endif // __MINGW32__ALLOCA_H__

252
3rdparty/compiler/mingw/sal.h vendored Normal file
View File

@@ -0,0 +1,252 @@
#pragma once
#if __GNUC__ >=3
#pragma GCC system_header
#endif
//#define __null // << Conflicts with GCC internal type __null
#define __notnull
#define __maybenull
#define __readonly
#define __notreadonly
#define __maybereadonly
#define __valid
#define __notvalid
#define __maybevalid
#define __readableTo(extent)
#define __elem_readableTo(size)
#define __byte_readableTo(size)
#define __writableTo(size)
#define __elem_writableTo(size)
#define __byte_writableTo(size)
#define __deref
#define __pre
#define __post
#define __precond(expr)
#define __postcond(expr)
#define __exceptthat
#define __execeptthat
#define __inner_success(expr)
#define __inner_checkReturn
#define __inner_typefix(ctype)
#define __inner_override
#define __inner_callback
#define __inner_blocksOn(resource)
#define __inner_fallthrough_dec
#define __inner_fallthrough
#define __refparam
#define __inner_control_entrypoint(category)
#define __inner_data_entrypoint(category)
#define __ecount(size)
#define __bcount(size)
#define __in
#define __in_ecount(size)
#define __in_bcount(size)
#define __in_z
#define __in_ecount_z(size)
#define __in_bcount_z(size)
#define __in_nz
#define __in_ecount_nz(size)
#define __in_bcount_nz(size)
#define __out
#define __out_ecount(size)
#define __out_bcount(size)
#define __out_ecount_part(size,length)
#define __out_bcount_part(size,length)
#define __out_ecount_full(size)
#define __out_bcount_full(size)
#define __out_z
#define __out_z_opt
#define __out_ecount_z(size)
#define __out_bcount_z(size)
#define __out_ecount_part_z(size,length)
#define __out_bcount_part_z(size,length)
#define __out_ecount_full_z(size)
#define __out_bcount_full_z(size)
#define __out_nz
#define __out_nz_opt
#define __out_ecount_nz(size)
#define __out_bcount_nz(size)
#define __inout
#define __inout_ecount(size)
#define __inout_bcount(size)
#define __inout_ecount_part(size,length)
#define __inout_bcount_part(size,length)
#define __inout_ecount_full(size)
#define __inout_bcount_full(size)
#define __inout_z
#define __inout_ecount_z(size)
#define __inout_bcount_z(size)
#define __inout_nz
#define __inout_ecount_nz(size)
#define __inout_bcount_nz(size)
#define __ecount_opt(size)
#define __bcount_opt(size)
#define __in_opt
#define __in_ecount_opt(size)
#define __in_bcount_opt(size)
#define __in_z_opt
#define __in_ecount_z_opt(size)
#define __in_bcount_z_opt(size)
#define __in_nz_opt
#define __in_ecount_nz_opt(size)
#define __in_bcount_nz_opt(size)
#define __out_opt
#define __out_ecount_opt(size)
#define __out_bcount_opt(size)
#define __out_ecount_part_opt(size,length)
#define __out_bcount_part_opt(size,length)
#define __out_ecount_full_opt(size)
#define __out_bcount_full_opt(size)
#define __out_ecount_z_opt(size)
#define __out_bcount_z_opt(size)
#define __out_ecount_part_z_opt(size,length)
#define __out_bcount_part_z_opt(size,length)
#define __out_ecount_full_z_opt(size)
#define __out_bcount_full_z_opt(size)
#define __out_ecount_nz_opt(size)
#define __out_bcount_nz_opt(size)
#define __inout_opt
#define __inout_ecount_opt(size)
#define __inout_bcount_opt(size)
#define __inout_ecount_part_opt(size,length)
#define __inout_bcount_part_opt(size,length)
#define __inout_ecount_full_opt(size)
#define __inout_bcount_full_opt(size)
#define __inout_z_opt
#define __inout_ecount_z_opt(size)
#define __inout_ecount_z_opt(size)
#define __inout_bcount_z_opt(size)
#define __inout_nz_opt
#define __inout_ecount_nz_opt(size)
#define __inout_bcount_nz_opt(size)
#define __deref_ecount(size)
#define __deref_bcount(size)
#define __deref_out
#define __deref_out_ecount(size)
#define __deref_out_bcount(size)
#define __deref_out_ecount_part(size,length)
#define __deref_out_bcount_part(size,length)
#define __deref_out_ecount_full(size)
#define __deref_out_bcount_full(size)
#define __deref_out_z
#define __deref_out_ecount_z(size)
#define __deref_out_bcount_z(size)
#define __deref_out_nz
#define __deref_out_ecount_nz(size)
#define __deref_out_bcount_nz(size)
#define __deref_inout
#define __deref_inout_z
#define __deref_inout_ecount(size)
#define __deref_inout_bcount(size)
#define __deref_inout_ecount_part(size,length)
#define __deref_inout_bcount_part(size,length)
#define __deref_inout_ecount_full(size)
#define __deref_inout_bcount_full(size)
#define __deref_inout_z
#define __deref_inout_ecount_z(size)
#define __deref_inout_bcount_z(size)
#define __deref_inout_nz
#define __deref_inout_ecount_nz(size)
#define __deref_inout_bcount_nz(size)
#define __deref_ecount_opt(size)
#define __deref_bcount_opt(size)
#define __deref_out_opt
#define __deref_out_ecount_opt(size)
#define __deref_out_bcount_opt(size)
#define __deref_out_ecount_part_opt(size,length)
#define __deref_out_bcount_part_opt(size,length)
#define __deref_out_ecount_full_opt(size)
#define __deref_out_bcount_full_opt(size)
#define __deref_out_z_opt
#define __deref_out_ecount_z_opt(size)
#define __deref_out_bcount_z_opt(size)
#define __deref_out_nz_opt
#define __deref_out_ecount_nz_opt(size)
#define __deref_out_bcount_nz_opt(size)
#define __deref_inout_opt
#define __deref_inout_ecount_opt(size)
#define __deref_inout_bcount_opt(size)
#define __deref_inout_ecount_part_opt(size,length)
#define __deref_inout_bcount_part_opt(size,length)
#define __deref_inout_ecount_full_opt(size)
#define __deref_inout_bcount_full_opt(size)
#define __deref_inout_z_opt
#define __deref_inout_ecount_z_opt(size)
#define __deref_inout_bcount_z_opt(size)
#define __deref_inout_nz_opt
#define __deref_inout_ecount_nz_opt(size)
#define __deref_inout_bcount_nz_opt(size)
#define __deref_opt_ecount(size)
#define __deref_opt_bcount(size)
#define __deref_opt_out
#define __deref_opt_out_z
#define __deref_opt_out_ecount(size)
#define __deref_opt_out_bcount(size)
#define __deref_opt_out_ecount_part(size,length)
#define __deref_opt_out_bcount_part(size,length)
#define __deref_opt_out_ecount_full(size)
#define __deref_opt_out_bcount_full(size)
#define __deref_opt_inout
#define __deref_opt_inout_ecount(size)
#define __deref_opt_inout_bcount(size)
#define __deref_opt_inout_ecount_part(size,length)
#define __deref_opt_inout_bcount_part(size,length)
#define __deref_opt_inout_ecount_full(size)
#define __deref_opt_inout_bcount_full(size)
#define __deref_opt_inout_z
#define __deref_opt_inout_ecount_z(size)
#define __deref_opt_inout_bcount_z(size)
#define __deref_opt_inout_nz
#define __deref_opt_inout_ecount_nz(size)
#define __deref_opt_inout_bcount_nz(size)
#define __deref_opt_ecount_opt(size)
#define __deref_opt_bcount_opt(size)
#define __deref_opt_out_opt
#define __deref_opt_out_ecount_opt(size)
#define __deref_opt_out_bcount_opt(size)
#define __deref_opt_out_ecount_part_opt(size,length)
#define __deref_opt_out_bcount_part_opt(size,length)
#define __deref_opt_out_ecount_full_opt(size)
#define __deref_opt_out_bcount_full_opt(size)
#define __deref_opt_out_z_opt
#define __deref_opt_out_ecount_z_opt(size)
#define __deref_opt_out_bcount_z_opt(size)
#define __deref_opt_out_nz_opt
#define __deref_opt_out_ecount_nz_opt(size)
#define __deref_opt_out_bcount_nz_opt(size)
#define __deref_opt_inout_opt
#define __deref_opt_inout_ecount_opt(size)
#define __deref_opt_inout_bcount_opt(size)
#define __deref_opt_inout_ecount_part_opt(size,length)
#define __deref_opt_inout_bcount_part_opt(size,length)
#define __deref_opt_inout_ecount_full_opt(size)
#define __deref_opt_inout_bcount_full_opt(size)
#define __deref_opt_inout_z_opt
#define __deref_opt_inout_ecount_z_opt(size)
#define __deref_opt_inout_bcount_z_opt(size)
#define __deref_opt_inout_nz_opt
#define __deref_opt_inout_ecount_nz_opt(size)
#define __deref_opt_inout_bcount_nz_opt(size)
#define __success(expr)
#define __nullterminated
#define __nullnullterminated
#define __reserved
#define __checkReturn
#define __typefix(ctype)
#define __override
#define __callback
#define __format_string
#define __blocksOn(resource)
#define __control_entrypoint(category)
#define __data_entrypoint(category)
#ifndef __fallthrough
#define __fallthrough __inner_fallthrough
#endif
#ifndef __analysis_assume
#define __analysis_assume(expr)
#endif

View File

@@ -0,0 +1 @@
#define __reserved

View File

@@ -0,0 +1,2 @@
#undef __reserved

1
3rdparty/compiler/mingw/unordered_map vendored Normal file
View File

@@ -0,0 +1 @@
#include <tr1/unordered_map>

305
3rdparty/compiler/msvc/inttypes.h vendored Normal file
View File

@@ -0,0 +1,305 @@
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. 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.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_INTTYPES_H_ // [
#define _MSC_INTTYPES_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include "stdint.h"
// 7.8 Format conversion of integer types
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
// 7.8.1 Macros for format specifiers
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
// The fprintf macros for signed integers are:
#define PRId8 "d"
#define PRIi8 "i"
#define PRIdLEAST8 "d"
#define PRIiLEAST8 "i"
#define PRIdFAST8 "d"
#define PRIiFAST8 "i"
#define PRId16 "hd"
#define PRIi16 "hi"
#define PRIdLEAST16 "hd"
#define PRIiLEAST16 "hi"
#define PRIdFAST16 "hd"
#define PRIiFAST16 "hi"
#define PRId32 "I32d"
#define PRIi32 "I32i"
#define PRIdLEAST32 "I32d"
#define PRIiLEAST32 "I32i"
#define PRIdFAST32 "I32d"
#define PRIiFAST32 "I32i"
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIdLEAST64 "I64d"
#define PRIiLEAST64 "I64i"
#define PRIdFAST64 "I64d"
#define PRIiFAST64 "I64i"
#define PRIdMAX "I64d"
#define PRIiMAX "I64i"
#define PRIdPTR "Id"
#define PRIiPTR "Ii"
// The fprintf macros for unsigned integers are:
#define PRIo8 "o"
#define PRIu8 "u"
#define PRIx8 "x"
#define PRIX8 "X"
#define PRIoLEAST8 "o"
#define PRIuLEAST8 "u"
#define PRIxLEAST8 "x"
#define PRIXLEAST8 "X"
#define PRIoFAST8 "o"
#define PRIuFAST8 "u"
#define PRIxFAST8 "x"
#define PRIXFAST8 "X"
#define PRIo16 "ho"
#define PRIu16 "hu"
#define PRIx16 "hx"
#define PRIX16 "hX"
#define PRIoLEAST16 "ho"
#define PRIuLEAST16 "hu"
#define PRIxLEAST16 "hx"
#define PRIXLEAST16 "hX"
#define PRIoFAST16 "ho"
#define PRIuFAST16 "hu"
#define PRIxFAST16 "hx"
#define PRIXFAST16 "hX"
#define PRIo32 "I32o"
#define PRIu32 "I32u"
#define PRIx32 "I32x"
#define PRIX32 "I32X"
#define PRIoLEAST32 "I32o"
#define PRIuLEAST32 "I32u"
#define PRIxLEAST32 "I32x"
#define PRIXLEAST32 "I32X"
#define PRIoFAST32 "I32o"
#define PRIuFAST32 "I32u"
#define PRIxFAST32 "I32x"
#define PRIXFAST32 "I32X"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#define PRIoLEAST64 "I64o"
#define PRIuLEAST64 "I64u"
#define PRIxLEAST64 "I64x"
#define PRIXLEAST64 "I64X"
#define PRIoFAST64 "I64o"
#define PRIuFAST64 "I64u"
#define PRIxFAST64 "I64x"
#define PRIXFAST64 "I64X"
#define PRIoMAX "I64o"
#define PRIuMAX "I64u"
#define PRIxMAX "I64x"
#define PRIXMAX "I64X"
#define PRIoPTR "Io"
#define PRIuPTR "Iu"
#define PRIxPTR "Ix"
#define PRIXPTR "IX"
// The fscanf macros for signed integers are:
#define SCNd8 "d"
#define SCNi8 "i"
#define SCNdLEAST8 "d"
#define SCNiLEAST8 "i"
#define SCNdFAST8 "d"
#define SCNiFAST8 "i"
#define SCNd16 "hd"
#define SCNi16 "hi"
#define SCNdLEAST16 "hd"
#define SCNiLEAST16 "hi"
#define SCNdFAST16 "hd"
#define SCNiFAST16 "hi"
#define SCNd32 "ld"
#define SCNi32 "li"
#define SCNdLEAST32 "ld"
#define SCNiLEAST32 "li"
#define SCNdFAST32 "ld"
#define SCNiFAST32 "li"
#define SCNd64 "I64d"
#define SCNi64 "I64i"
#define SCNdLEAST64 "I64d"
#define SCNiLEAST64 "I64i"
#define SCNdFAST64 "I64d"
#define SCNiFAST64 "I64i"
#define SCNdMAX "I64d"
#define SCNiMAX "I64i"
#ifdef _WIN64 // [
# define SCNdPTR "I64d"
# define SCNiPTR "I64i"
#else // _WIN64 ][
# define SCNdPTR "ld"
# define SCNiPTR "li"
#endif // _WIN64 ]
// The fscanf macros for unsigned integers are:
#define SCNo8 "o"
#define SCNu8 "u"
#define SCNx8 "x"
#define SCNX8 "X"
#define SCNoLEAST8 "o"
#define SCNuLEAST8 "u"
#define SCNxLEAST8 "x"
#define SCNXLEAST8 "X"
#define SCNoFAST8 "o"
#define SCNuFAST8 "u"
#define SCNxFAST8 "x"
#define SCNXFAST8 "X"
#define SCNo16 "ho"
#define SCNu16 "hu"
#define SCNx16 "hx"
#define SCNX16 "hX"
#define SCNoLEAST16 "ho"
#define SCNuLEAST16 "hu"
#define SCNxLEAST16 "hx"
#define SCNXLEAST16 "hX"
#define SCNoFAST16 "ho"
#define SCNuFAST16 "hu"
#define SCNxFAST16 "hx"
#define SCNXFAST16 "hX"
#define SCNo32 "lo"
#define SCNu32 "lu"
#define SCNx32 "lx"
#define SCNX32 "lX"
#define SCNoLEAST32 "lo"
#define SCNuLEAST32 "lu"
#define SCNxLEAST32 "lx"
#define SCNXLEAST32 "lX"
#define SCNoFAST32 "lo"
#define SCNuFAST32 "lu"
#define SCNxFAST32 "lx"
#define SCNXFAST32 "lX"
#define SCNo64 "I64o"
#define SCNu64 "I64u"
#define SCNx64 "I64x"
#define SCNX64 "I64X"
#define SCNoLEAST64 "I64o"
#define SCNuLEAST64 "I64u"
#define SCNxLEAST64 "I64x"
#define SCNXLEAST64 "I64X"
#define SCNoFAST64 "I64o"
#define SCNuFAST64 "I64u"
#define SCNxFAST64 "I64x"
#define SCNXFAST64 "I64X"
#define SCNoMAX "I64o"
#define SCNuMAX "I64u"
#define SCNxMAX "I64x"
#define SCNXMAX "I64X"
#ifdef _WIN64 // [
# define SCNoPTR "I64o"
# define SCNuPTR "I64u"
# define SCNxPTR "I64x"
# define SCNXPTR "I64X"
#else // _WIN64 ][
# define SCNoPTR "lo"
# define SCNuPTR "lu"
# define SCNxPTR "lx"
# define SCNXPTR "lX"
#endif // _WIN64 ]
#endif // __STDC_FORMAT_MACROS ]
// 7.8.2 Functions for greatest-width integer types
// 7.8.2.1 The imaxabs function
#define imaxabs _abs64
// 7.8.2.2 The imaxdiv function
// This is modified version of div() function from Microsoft's div.c found
// in %MSVC.NET%\crt\src\div.c
#ifdef STATIC_IMAXDIV // [
static
#else // STATIC_IMAXDIV ][
_inline
#endif // STATIC_IMAXDIV ]
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
{
imaxdiv_t result;
result.quot = numer / denom;
result.rem = numer % denom;
if (numer < 0 && result.rem > 0) {
// did division wrong; must fix up
++result.quot;
result.rem -= denom;
}
return result;
}
// 7.8.2.3 The strtoimax and strtoumax functions
#define strtoimax _strtoi64
#define strtoumax _strtoui64
// 7.8.2.4 The wcstoimax and wcstoumax functions
#define wcstoimax _wcstoi64
#define wcstoumax _wcstoui64
#endif // _MSC_INTTYPES_H_ ]

247
3rdparty/compiler/msvc/stdint.h vendored Normal file
View File

@@ -0,0 +1,247 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. 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.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#ifdef __cplusplus
extern "C" {
#endif
# include <wchar.h>
#ifdef __cplusplus
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 signed int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]

1
3rdparty/compiler/nacl/memory.h vendored Normal file
View File

@@ -0,0 +1 @@
#include <string.h>

3
3rdparty/fcpp/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
fcpp
*.o
*~

38
3rdparty/fcpp/COPYING vendored Normal file
View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 1993-2011 Daniel Stenberg
* 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 the copyright holder nor the names
* of any other 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 OWNER 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.
*/

56
3rdparty/fcpp/FPPBase.h vendored Normal file
View File

@@ -0,0 +1,56 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/FPPBase.h,v $
* $Revision: 1.3 $
* $Date: 1993/12/06 13:51:20 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: FPPBase.h,v $
* Revision 1.3 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
#ifndef FPP_BASE_H
#define FPP_BASE_H
/*
** $Filename: libraries/FPPbase.h $
** $Release: 1.0 $
** $Date: 1993/12/06 13:51:20 $
**
** (C) Copyright 1992, 1993 by FrexxWare
** All Rights Reserved
*/
#include <exec/types.h>
#include <exec/libraries.h>
struct FPPBase {
struct Library LibNode;
UBYTE Flags;
UBYTE pad;
/* long word aligned */
ULONG SysLib;
ULONG DosLib;
ULONG SegList;
};
#define FPPNAME "fpp.library"
#endif

35
3rdparty/fcpp/FPP_protos.h vendored Normal file
View File

@@ -0,0 +1,35 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/FPP_protos.h,v $
* $Revision: 1.3 $
* $Date: 1993/12/06 13:51:20 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: FPP_protos.h,v $
* Revision 1.3 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
/******************************************************
*
* FPP_protos.h
*
*******/
int fppPreProcess(struct fppTag *);

13
3rdparty/fcpp/README vendored Normal file
View File

@@ -0,0 +1,13 @@
Frexx CPP (C Preprocessor)
Copyright (c) by Daniel Stenberg 1993 - 2011
This is a C preprocessor. It is a project based on public domain code, then
forked by Daniel in 1993 and future work has been done under a BSD license.
The C preprocessor is now (mostly?) ANSI C compliant, and some tweaks have
been applied to also make it fairly usable to process other data files, such
as HTML for simple web sites.
WWW: http://daniel.haxx.se/projects/fcpp/
Code: https://github.com/bagder/fcpp

249
3rdparty/fcpp/cpp.h vendored Normal file
View File

@@ -0,0 +1,249 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/cpp.h,v $
* $Revision: 1.3 $
* $Date: 1993/12/06 13:51:20 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: cpp.h,v $
* Revision 1.3 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
/*
* I n t e r n a l D e f i n i t i o n s f o r C P P
*
* In general, definitions in this file should not be changed.
*/
#include <stdlib.h>
#include <string.h>
#ifndef toupper
#define toupper(c) ((c) + ('A' - 'a'))
#endif /* no toupper */
#ifndef tolower
#define tolower(c) ((c) + ('a' - 'A'))
#endif /* no tolower */
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#ifndef EOS
/*
* This is predefined in Decus C
*/
#define EOS '\0' /* End of string */
#endif
#define EOF_CHAR 0 /* Returned by get() on eof */
#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
#define DEF_NOARGS (-1) /* #define foo vs #define foo() */
/*
* The following may need to change if the host system doesn't use ASCII.
*/
#define QUOTE_PARM 0x1C /* Magic quoting operator */
#define DEF_MAGIC 0x1D /* Magic for #defines */
#define TOK_SEP 0x1E /* Token concatenation delim. */
#define COM_SEP 0x1F /* Magic comment separator */
/*
* Note -- in Ascii, the following will map macro formals onto DEL + the
* C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
* be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC
* value is reserved for string substitution.
*/
#define MAC_PARM 0x7F /* Macro formals start here */
#ifndef OS9
#if (PAR_MAC >= 33)
#error "assertion fails -- PAR_MAC isn't less than 33"
#endif
#endif
#define LASTPARM (PAR_MAC - 1)
/*
* Character type codes.
*/
#define INV 0 /* Invalid, must be zero */
#define OP_EOE INV /* End of expression */
#define DIG 1 /* Digit */
#define LET 2 /* Identifier start */
#define FIRST_BINOP OP_ADD
#define OP_ADD 3
#define OP_SUB 4
#define OP_MUL 5
#define OP_DIV 6
#define OP_MOD 7
#define OP_ASL 8
#define OP_ASR 9
#define OP_AND 10 /* &, not && */
#define OP_OR 11 /* |, not || */
#define OP_XOR 12
#define OP_EQ 13
#define OP_NE 14
#define OP_LT 15
#define OP_LE 16
#define OP_GE 17
#define OP_GT 18
#define OP_ANA 19 /* && */
#define OP_ORO 20 /* || */
#define OP_QUE 21 /* ? */
#define OP_COL 22 /* : */
#define OP_CMA 23 /* , (relevant?) */
#define LAST_BINOP OP_CMA /* Last binary operand */
/*
* The following are unary.
*/
#define FIRST_UNOP OP_PLU /* First Unary operand */
#define OP_PLU 24 /* + (draft ANSI standard) */
#define OP_NEG 25 /* - */
#define OP_COM 26 /* ~ */
#define OP_NOT 27 /* ! */
#define LAST_UNOP OP_NOT
#define OP_LPA 28 /* ( */
#define OP_RPA 29 /* ) */
#define OP_END 30 /* End of expression marker */
#define OP_MAX (OP_END + 1) /* Number of operators */
#define OP_FAIL (OP_END + 1) /* For error returns */
/*
* The following are for lexical scanning only.
*/
#define QUO 65 /* Both flavors of quotation */
#define DOT 66 /* . might start a number */
#define SPA 67 /* Space and tab */
#define BSH 68 /* Just a backslash */
#define END 69 /* EOF */
/*
* These bits are set in ifstack[]
*/
#define WAS_COMPILING 1 /* TRUE if compile set at entry */
#define ELSE_SEEN 2 /* TRUE when #else processed */
#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */
/*
* Define bits for the basic types and their adjectives
*/
#define T_CHAR 1
#define T_INT 2
#define T_FLOAT 4
#define T_DOUBLE 8
#define T_SHORT 16
#define T_LONG 32
#define T_SIGNED 64
#define T_UNSIGNED 128
#define T_PTR 256 /* Pointer */
#define T_FPTR 512 /* Pointer to functions */
/*
* The DEFBUF structure stores information about #defined
* macros. Note that the defbuf->repl information is always
* in malloc storage.
*/
typedef struct defbuf {
struct defbuf *link; /* Next define in chain */
char *repl; /* -> replacement */
int hash; /* Symbol table hash */
int nargs; /* For define(args) */
char name[1]; /* #define name */
} DEFBUF;
/*
* The FILEINFO structure stores information about open files
* and macros being expanded.
*/
typedef struct fileinfo {
char *bptr; /* Buffer pointer */
int line; /* for include or macro */
FILE *fp; /* File if non-null */
struct fileinfo *parent; /* Link to includer */
char *filename; /* File/macro name */
char *progname; /* From #line statement */
unsigned int unrecur; /* For macro recursion */
char buffer[1]; /* current input line */
} FILEINFO;
/*
* The SIZES structure is used to store the values for #if sizeof
*/
typedef struct sizes {
short bits; /* If this bit is set, */
short size; /* this is the datum size value */
short psize; /* this is the pointer size */
} SIZES;
/*
* nomacarg is a built-in #define on Decus C.
*/
#ifdef nomacarg
#define cput output /* cput concatenates tokens */
#else
#if COMMENT_INVISIBLE
#define cput(c) { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
#else
#define cput(c) { if (c != TOK_SEP) putchar(c); }
#endif
#endif
#ifndef nomacarg
#define streq(s1, s2) (strcmp(s1, s2) == 0)
#endif
/*
* Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
*/
#ifndef IO_NORMAL
#define IO_NORMAL 0
#endif
#ifndef IO_ERROR
#define IO_ERROR 1
#endif
/*
* Externs
*/
#include "fpp.h" /* structs and defines */
#include "cppadd.h" /* Added prototypes for ANSI complience! */
#ifdef AMIGA
#include <dos.h>
extern int _OSERR;
#endif
extern char type[]; /* Character classifier */
#define compiling global->ifstack[0]
#if DEBUG
extern int debug; /* Debug level */
#endif
extern SIZES size_table[]; /* For #if sizeof sizes */
#define MAX_SPACE_SIZE 512 /* maximum number of whitespaces possible
to remember */

592
3rdparty/fcpp/cpp1.c vendored Normal file
View File

@@ -0,0 +1,592 @@
/******************************************************************************
Copyright (c) 1993 - 2011 Daniel Stenberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
#if defined(AMIGA)
#include <dos.h>
#if defined(SHARED)
int _OSERR=0;
char *_ProgramName="junk";
void __stdargs _XCEXIT(long a) { return; }
#endif
#endif
FILE_LOCAL ReturnCode output(struct Global *, int); /* Output one character */
FILE_LOCAL void sharp(struct Global *);
INLINE FILE_LOCAL ReturnCode cppmain(struct Global *);
int fppPreProcess(struct fppTag *tags)
{
int i=0;
ReturnCode ret; /* cpp return code */
struct Global *global;
global=(struct Global *)malloc(sizeof(struct Global));
if(!global)
return(FPP_OUT_OF_MEMORY);
memset(global, 0, sizeof(struct Global));
global->infile=NULL;
global->line=0;
global->wrongline=0;
global->errors=0;
global->recursion=0;
global->rec_recover=TRUE;
global->instring=FALSE;
global->inmacro=FALSE;
global->workp=NULL;
global->keepcomments = FALSE; /* Write out comments flag */
global->cflag = FALSE; /* -C option (keep comments) */
global->eflag = FALSE; /* -E option (never fail) */
global->nflag = 0; /* -N option (no predefines) */
global->wflag = FALSE; /* -W option (write #defines) */
global->ifstack[0]=TRUE; /* #if information */
global->ifptr = global->ifstack;
global->incend = global->incdir;
/* names defined at cpp start */
global->preset[0]="frexxcpp"; /* This is the Frexx cpp program */
#if defined( amiga )
global->preset[1]="amiga";
global->preset[2]="m68000";
global->preset[3]="amigados";
global->preset[4]= NULL; /* Must be last */
#elif defined( unix )
global->preset[1]="unix";
global->preset[2]= NULL;
#endif
/* Note: order is important */
global->magic[0] = "__LINE__";
global->magic[1] = "__FILE__";
global->magic[2] = "__FUNCTION__";
global->magic[3] = "__FUNC_LINE__";
global->magic[4] = NULL; /* Must be last */
global->funcline = 0;
global->cplusplus=1;
global->sharpfilename=NULL;
global->parmp=NULL;
global->nargs=0;
global->macro=NULL;
global->evalue=0;
global->input=NULL;
global->output=NULL;
global->error=NULL;
global->first_file=NULL;
global->userdata=NULL;
global->linelines=TRUE;
global->warnillegalcpp = FALSE;
global->outputLINE = TRUE;
global->warnnoinclude = TRUE;
global->showversion = TRUE;
global->showincluded = FALSE;
global->showspace = FALSE;
global->nestcomments = FALSE;
global->warnnestcomments = FALSE;
global->outputfile = TRUE;
global->included = 0;
global->comment = FALSE;
global->rightconcat = FALSE;
global->work[0] = '\0';
global->initialfunc = NULL;
memset(global->symtab, 0, SBSIZE * sizeof(DEFBUF *));
ret=initdefines(global); /* O.S. specific def's */
if(ret)
return(ret);
dooptions(global, tags); /* Command line -flags */
ret=addfile(global, stdin, global->work); /* "open" main input file */
global->out = global->outputfile;
if(!ret)
ret=cppmain(global); /* Process main file */
if ((i = (global->ifptr - global->ifstack)) != 0) {
#if OLD_PREPROCESSOR
cwarn(global, ERROR_IFDEF_DEPTH, i);
#else
cerror(global, ERROR_IFDEF_DEPTH, i);
#endif
}
fflush(stdout);
fclose(stdout);
if (global->errors > 0 && !global->eflag)
return(IO_ERROR);
return(IO_NORMAL); /* No errors or -E option set */
}
INLINE FILE_LOCAL
ReturnCode cppmain(struct Global *global)
{
/*
* Main process for cpp -- copies tokens from the current input
* stream (main file, include file, or a macro) to the output
* file.
*/
int c; /* Current character */
int counter; /* newlines and spaces */
ReturnCode ret; /* return code variable type */
long bracelevel = 0;
long parenlevel = 0;
long bracketlevel = 0;
int fake = 0;
#define MAX_FUNC_LENGTH 50
char tempfunc[MAX_FUNC_LENGTH + 1];
char tempfunc2[MAX_FUNC_LENGTH + 1];
char define = 0; /* probability of a function define phase in the program */
char prev = 0; /* previous type */
char go = 0;
char include = 0;
char initfunc = 0;
/* Initialize for reading tokens */
global->tokenbsize = 50;
global->tokenbuf = malloc(global->tokenbsize + 1);
if(!global->tokenbuf)
return(FPP_OUT_OF_MEMORY);
global->functionname = malloc(global->tokenbsize + 1);
if(!global->functionname)
return(FPP_OUT_OF_MEMORY);
global->functionname[0] = '\0';
if(global->showspace) {
global->spacebuf = (char *)malloc(MAX_SPACE_SIZE);
if(!global->spacebuf)
return(FPP_OUT_OF_MEMORY);
}
if(global->showversion)
Error(global, VERSION_TEXT);
/*
* Explicitly output a #line at the start of cpp output so
* that lint (etc.) knows the name of the original source
* file. If we don't do this explicitly, we may get
* the name of the first #include file instead.
*/
if(global->linelines) /* if #line lines are wanted! */
sharp(global);
/*
* This loop is started "from the top" at the beginning of each line
* wrongline is set TRUE in many places if it is necessary to write
* a #line record. (But we don't write them when expanding macros.)
*
* The counter variable has two different uses: at
* the start of a line, it counts the number of blank lines that
* have been skipped over. These are then either output via
* #line records or by outputting explicit blank lines.
* When expanding tokens within a line, the counter remembers
* whether a blank/tab has been output. These are dropped
* at the end of the line, and replaced by a single blank
* within lines.
*/
include = global->included;
while(include--) {
openinclude(global, global->include[include], TRUE);
}
for (;;) {
counter = 0; /* Count empty lines */
for (;;) { /* For each line, ... */
global->comment = FALSE; /* No comment yet! */
global->chpos = 0; /* Count whitespaces */
while (type[(c = get(global))] == SPA) /* Skip leading blanks */
if(global->showspace) {
if(global->chpos<MAX_SPACE_SIZE-1)
/* we still have buffer to store this! */
global->spacebuf[global->chpos++]=(char)c;
}
if (c == '\n') { /* If line's all blank, */
if(global->comment) {
/* A comment was output! */
Putchar(global, '\n');
}
else
++counter; /* Do nothing now */
}
else if (c == '#') { /* Is 1st non-space '#' */
global->keepcomments = FALSE; /* Don't pass comments */
ret = control(global, &counter); /* Yes, do a #command */
if(ret)
return(ret);
global->keepcomments = (global->cflag && compiling);
}
else if (c == EOF_CHAR) /* At end of file? */
break;
else if (!compiling) { /* #ifdef false? */
skipnl(global); /* Skip to newline */
counter++; /* Count it, too. */
} else {
break; /* Actual token */
}
}
if (c == EOF_CHAR) /* Exit process at */
break; /* End of file */
/*
* If the loop didn't terminate because of end of file, we
* know there is a token to compile. First, clean up after
* absorbing newlines. counter has the number we skipped.
*/
if(global->linelines) { /* if #line lines are wanted! */
if ((global->wrongline && global->infile->fp != NULL) || counter > 4)
sharp(global); /* Output # line number */
else { /* If just a few, stuff */
while (--counter >= 0) /* them out ourselves */
Putchar(global, (int)'\n');
}
}
if(global->showspace) {
/* Show all whitespaces! */
global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf);
}
/*
* Process each token on this line.
*/
unget(global); /* Reread the char. */
for (;;) { /* For the whole line, */
do { /* Token concat. loop */
for (global->chpos = counter = 0; (type[(c = get(global))] == SPA);) {
#if COMMENT_INVISIBLE
if (c != COM_SEP)
counter++;
#else
if(global->showspace && global->chpos < MAX_SPACE_SIZE-1) {
global->spacebuf[global->chpos++]=(char)c;
}
counter++; /* Skip over blanks */
#endif
}
if (c == EOF_CHAR || c == '\n')
break; /* Exit line loop */
else if (counter > 0) { /* If we got any spaces */
if(!global->showspace) /* We don't output all spaces */
Putchar(global, (int)' ');/* Output one space */
else {
global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf); /* Output all whitespaces */
}
}
if(ret=macroid(global, &c)) /* Grab the token */
return(ret);
} while (type[c] == LET && catenate(global, &ret) && !ret);
if(ret)
/* If the loop was broken because of a fatal error! */
return(ret);
if (c == EOF_CHAR || c == '\n') /* From macro exp error */
break; /* Exit line loop */
go++;
switch (type[c]) {
case LET:
go =0;
/* Quite ordinary token */
Putstring(global, global->tokenbuf);
if(!define) {
/* Copy the name */
strncpy(tempfunc, global->tokenbuf, MAX_FUNC_LENGTH);
tempfunc[MAX_FUNC_LENGTH]=0;
}
/* fputs(global->tokenbuf, stdout); */
break;
case DIG: /* Output a number */
case DOT: /* Dot may begin floats */
go = 0;
ret=scannumber(global, c, (ReturnCode(*)(struct Global *, int))output);
if(ret)
return(ret);
break;
case QUO: /* char or string const */
go = 0;
/* Copy it to output */
if(!global->webmode) {
ret=scanstring(global, c,
(ReturnCode(*)(struct Global *, int))output);
if(ret)
return(ret);
break;
}
/* FALLTHROUGH */
default: /* Some other character */
define++;
switch(c) {
case '{':
if(! bracelevel++ && define > 2) {
/*
* This is a starting brace. If there is a probability of a
* function defining, we copy the `tempfunc' function name to
* `global->functionname'.
*/
strcpy(global->functionname, tempfunc2);
global->funcline = global->line;
if(global->outputfunctions) {
/*
* Output the discovered function name to stderr!
*/
Error(global, "#> Function defined at line %d: %s <#\n",
global->line,
global->functionname);
}
if(global->initialfunc) {
int a;
for(a=0; a<global->excluded; a++) {
/* check for excluded functions */
if(!strcmp(global->functionname,
global->excludedinit[a]))
break;
}
if(a==global->excluded) {
expstuff(global, "__brace__", "{");
expstuff(global, "__init_func__", global->initialfunc);
initfunc = TRUE;
}
}
}
break;
case '}':
go = 0;
if( (--bracelevel == initfunc) &&
strcmp(global->infile->filename, "__init_func__") ) {
/* we just stepped out of the function! */
global->functionname[0] = '\0';
global->funcline = 0;
define = 1;
if(initfunc) {
Putchar(global, '}');
bracelevel--;
initfunc=0;
}
}
fake = 0;
break;
case ';':
case ',':
if(go == 2) {
define = 1;
fake = 0;
go--;
break;
}
break;
case '(':
if(! parenlevel++ && !bracelevel) {
if(go == 2) {
/* foobar(text) -> "(" is found. This can't be a
function */
go--;
define = 1;
break;
}
if( define < 2 && prev == LET) {
/* This is the first parenthesis on the ground brace
level, and we did previously not have a probable
function name */
strncpy(tempfunc2, global->tokenbuf, MAX_FUNC_LENGTH);
tempfunc2[MAX_FUNC_LENGTH]=0;
define++;
}
else {
/* we have a fake start */
fake++;
}
}
break;
case ')':
if(! --parenlevel && !bracelevel && define>1 && !fake) {
/*
* The starting parentheses level and
* the starting brace level.
* This might be the start of a function defining coming
* up!
*/
define++; /* increase probability */
fake = 0;
go = 1;
}
break;
case '[':
bracketlevel++;
break;
case ']':
bracketlevel--;
break;
}
define--; /* decrease function probability */
Putchar(global, c); /* Just output it */
break;
} /* Switch ends */
prev = type[c];
} /* Line for loop */
if (c == '\n') { /* Compiling at EOL? */
Putchar(global, '\n'); /* Output newline, if */
if (global->infile->fp == NULL) /* Expanding a macro, */
global->wrongline = TRUE; /* Output # line later */
}
} /* Continue until EOF */
if(global->showbalance) {
if(bracketlevel) {
cwarn(global, WARN_BRACKET_DEPTH, bracketlevel);
}
if(parenlevel) {
cwarn(global, WARN_PAREN_DEPTH, parenlevel);
}
if(bracelevel) {
cwarn(global, WARN_BRACE_DEPTH, bracelevel);
}
}
if (global->wflag) {
global->out = TRUE; /* enable output */
outdefines(global); /* Write out #defines */
}
return(FPP_OK);
}
FILE_LOCAL
ReturnCode output(struct Global *global, int c)
{
/*
* Output one character to stdout -- output() is passed as an
* argument to scanstring()
*/
#if COMMENT_INVISIBLE
if (c != TOK_SEP && c != COM_SEP)
#else
if (c != TOK_SEP)
#endif
Putchar(global, c);
return(FPP_OK);
}
void Putchar(struct Global *global, int c)
{
/*
* Output one character to stdout or to output function!
*/
if(!global->out)
return;
#if defined(UNIX)
if(global->output)
global->output(c, global->userdata);
else
putchar(c);
#else /* amiga */
global->output(c, global->userdata);
#endif
}
void Putstring(struct Global *global, char *string)
{
/*
* Output a string! One letter at a time to the Putchar routine!
*/
if(!string)
return;
while(*string)
Putchar(global, *string++);
}
void Putint(struct Global *global, int number)
{
/*
* Output the number as a string.
*/
char buffer[16]; /* an integer can't be that big! */
char *point=buffer;
sprintf(buffer, "%d", number);
while(*point)
Putchar(global, *point++);
}
FILE_LOCAL
void sharp(struct Global *global)
{
/*
* Output a line number line.
*/
char *name;
if (global->keepcomments) /* Make sure # comes on */
Putchar(global, '\n'); /* a fresh, new line. */
/* printf("#%s %d", LINE_PREFIX, global->line); */
Putchar(global, '#');
if(global->outputLINE)
Putstring(global, LINE_PREFIX);
Putchar(global, ' ');
Putint(global, global->line);
if (global->infile->fp != NULL) {
name = (global->infile->progname != NULL)
? global->infile->progname : global->infile->filename;
if (global->sharpfilename == NULL
|| (global->sharpfilename != NULL && !streq(name, global->sharpfilename))) {
if (global->sharpfilename != NULL)
free(global->sharpfilename);
global->sharpfilename = savestring(global, name);
/* printf(" \"%s\"", name); */
Putstring(global, " \"");
Putstring(global, name);
Putchar(global, '\"');
}
}
Putchar(global, '\n');
global->wrongline = FALSE;
return;
}

814
3rdparty/fcpp/cpp2.c vendored Normal file
View File

@@ -0,0 +1,814 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
#ifdef _AMIGA
#include <proto/dos.h>
#endif
FILE_LOCAL void dump_line(struct Global *, int *);
FILE_LOCAL ReturnCode doif(struct Global *, int);
INLINE FILE_LOCAL ReturnCode doinclude(struct Global *);
INLINE FILE_LOCAL int hasdirectory(char *, char *);
/*
* Generate (by hand-inspection) a set of unique values for each control
* operator. Note that this is not guaranteed to work for non-Ascii
* machines. CPP won't compile if there are hash conflicts.
*/
#define L_assert ('a' + ('s' << 1))
#define L_define ('d' + ('f' << 1))
#define L_elif ('e' + ('i' << 1))
#define L_else ('e' + ('s' << 1))
#define L_endif ('e' + ('d' << 1))
#define L_error ('e' + ('r' << 1))
#define L_if ('i' + (EOS << 1))
#define L_ifdef ('i' + ('d' << 1))
#define L_ifndef ('i' + ('n' << 1))
#define L_include ('i' + ('c' << 1))
#define L_line ('l' + ('n' << 1))
#define L_nogood (EOS + (EOS << 1)) /* To catch #i */
#define L_pragma ('p' + ('a' << 1))
#define L_undef ('u' + ('d' << 1))
ReturnCode control( struct Global *global,
int *counter ) /* Pending newline counter */
{
/*
* Process #control lines. Simple commands are processed inline,
* while complex commands have their own subroutines.
*
* The counter is used to force out a newline before #line, and
* #pragma commands. This prevents these commands from ending up at
* the end of the previous line if cpp is invoked with the -C option.
*/
int c;
char *tp;
int hash;
char *ep;
ReturnCode ret;
c = skipws( global );
if( c == '\n' || c == EOF_CHAR )
{
(*counter)++;
return(FPP_OK);
}
if( !isdigit(c) )
scanid( global, c ); /* Get #word to tokenbuf */
else
{
unget( global ); /* Hack -- allow #123 as a */
strcpy( global->tokenbuf, "line" ); /* synonym for #line 123 */
}
hash = (global->tokenbuf[1] == EOS) ? L_nogood : (global->tokenbuf[0] + (global->tokenbuf[2] << 1));
switch( hash )
{
case L_assert:
tp = "assert";
break;
case L_define:
tp = "define";
break;
case L_elif:
tp = "elif";
break;
case L_else:
tp = "else";
break;
case L_endif:
tp = "endif";
break;
case L_error:
tp = "error";
break;
case L_if:
tp = "if";
break;
case L_ifdef:
tp = "ifdef";
break;
case L_ifndef:
tp = "ifndef";
break;
case L_include:
tp = "include";
break;
case L_line:
tp = "line";
break;
case L_pragma:
tp = "pragma";
break;
case L_undef:
tp = "undef";
break;
default:
hash = L_nogood;
case L_nogood:
tp = "";
break;
}
if( !streq( tp, global->tokenbuf ) )
hash = L_nogood;
/*
* hash is set to a unique value corresponding to the
* control keyword (or L_nogood if we think it's nonsense).
*/
if( global->infile->fp == NULL )
cwarn( global, WARN_CONTROL_LINE_IN_MACRO, global->tokenbuf );
if( !compiling )
{ /* Not compiling now */
switch( hash )
{
case L_if: /* These can't turn */
case L_ifdef: /* compilation on, but */
case L_ifndef: /* we must nest #if's */
if( ++global->ifptr >= &global->ifstack[BLK_NEST] )
{
cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS );
}
*global->ifptr = 0; /* !WAS_COMPILING */
case L_line: /* Many */
/*
* Are pragma's always processed?
*/
case L_pragma: /* options */
case L_include: /* are uninteresting */
case L_define: /* if we */
case L_undef: /* aren't */
case L_assert: /* compiling. */
case L_error:
dump_line( global, counter ); /* Ignore rest of line */
return(FPP_OK);
}
}
/*
* Make sure that #line and #pragma are output on a fresh line.
*/
if( *counter > 0 && (hash == L_line || hash == L_pragma) )
{
Putchar( global, '\n' );
(*counter)--;
}
switch( hash )
{
case L_line:
/*
* Parse the line to update the line number and "progname"
* field and line number for the next input line.
* Set wrongline to force it out later.
*/
c = skipws( global );
global->workp = global->work; /* Save name in work */
while( c != '\n' && c != EOF_CHAR )
{
if( ret = save( global, c ) )
return(ret);
c = get( global );
}
unget( global );
if( ret = save( global, EOS ) )
return(ret);
/*
* Split #line argument into <line-number> and <name>
* We subtract 1 as we want the number of the next line.
*/
global->line = atoi(global->work) - 1; /* Reset line number */
for( tp = global->work; isdigit(*tp) || type[*tp] == SPA; tp++)
; /* Skip over digits */
if( *tp != EOS )
{
/* Got a filename, so: */
if( *tp == '"' && (ep = strrchr(tp + 1, '"')) != NULL )
{
tp++; /* Skip over left quote */
*ep = EOS; /* And ignore right one */
}
if( global->infile->progname != NULL )
/* Give up the old name if it's allocated. */
free( global->infile->progname );
global->infile->progname = savestring( global, tp );
}
global->wrongline = TRUE; /* Force output later */
break;
case L_include:
ret = doinclude( global );
if( ret )
return(ret);
break;
case L_define:
ret = dodefine( global );
if( ret )
return(ret);
break;
case L_undef:
doundef( global );
break;
case L_else:
if( global->ifptr == &global->ifstack[0] )
{
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter );
return( FPP_OK );
}
else if( (*global->ifptr & ELSE_SEEN) != 0 )
{
cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
dump_line( global, counter );
return( FPP_OK );
}
*global->ifptr |= ELSE_SEEN;
if( (*global->ifptr & WAS_COMPILING) != 0 )
{
if( compiling || (*global->ifptr & TRUE_SEEN) != 0 )
compiling = FALSE;
else
{
compiling = TRUE;
}
}
break;
case L_elif:
if( global->ifptr == &global->ifstack[0] )
{
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter );
return( FPP_OK );
}
else if( (*global->ifptr & ELSE_SEEN) != 0 )
{
cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
dump_line( global, counter );
return( FPP_OK );
}
if( (*global->ifptr & (WAS_COMPILING | TRUE_SEEN)) != WAS_COMPILING )
{
compiling = FALSE; /* Done compiling stuff */
dump_line( global, counter ); /* Skip this clause */
return( FPP_OK );
}
ret = doif( global, L_if );
if( ret )
return(ret);
break;
case L_error:
cerror(global, ERROR_ERROR);
break;
case L_if:
case L_ifdef:
case L_ifndef:
if( ++global->ifptr < &global->ifstack[BLK_NEST] )
{
*global->ifptr = WAS_COMPILING;
ret = doif( global, hash );
if( ret )
return(ret);
break;
}
cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS );
case L_endif:
if( global->ifptr == &global->ifstack[0] )
{
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter );
return(FPP_OK);
}
if( !compiling && (*global->ifptr & WAS_COMPILING) != 0 )
global->wrongline = TRUE;
compiling = ((*global->ifptr & WAS_COMPILING) != 0);
--global->ifptr;
break;
case L_assert:
{
int result;
ret = eval( global, &result );
if(ret)
return(ret);
if( result == 0 )
cerror( global, ERROR_PREPROC_FAILURE );
}
break;
case L_pragma:
/*
* #pragma is provided to pass "options" to later
* passes of the compiler. cpp doesn't have any yet.
*/
Putstring( global, "#pragma " );
while( (c = get( global ) ) != '\n' && c != EOF_CHAR )
Putchar( global, c );
unget( global );
Putchar( global, '\n' );
break;
default:
/*
* Undefined #control keyword.
* Note: the correct behavior may be to warn and
* pass the line to a subsequent compiler pass.
* This would allow #asm or similar extensions.
*/
if( global->warnillegalcpp )
cwarn( global, WARN_ILLEGAL_COMMAND, global->tokenbuf );
Putchar( global, '#' );
Putstring( global, global->tokenbuf );
Putchar( global, ' ' );
while( (c = get( global ) ) != '\n' && c != EOF_CHAR )
Putchar( global, c );
unget( global );
Putchar( global, '\n' );
break;
}
if( hash != L_include )
{
#if OLD_PREPROCESSOR
/*
* Ignore the rest of the #control line so you can write
* #if foo
* #endif foo
*/
dump_line( global, counter ); /* Take common exit */
return( FPP_OK );
#else
if( skipws( global ) != '\n' )
{
cwarn( global, WARN_UNEXPECTED_TEXT_IGNORED );
skipnl( global );
}
#endif
}
(*counter)++;
return( FPP_OK );
}
FILE_LOCAL
void dump_line(struct Global *global, int *counter)
{
skipnl( global ); /* Ignore rest of line */
(*counter)++;
}
FILE_LOCAL
ReturnCode doif(struct Global *global, int hash)
{
/*
* Process an #if, #ifdef, or #ifndef. The latter two are straightforward,
* while #if needs a subroutine of its own to evaluate the expression.
*
* doif() is called only if compiling is TRUE. If false, compilation
* is always supressed, so we don't need to evaluate anything. This
* supresses unnecessary warnings.
*/
int c;
int found;
ReturnCode ret;
if( (c = skipws( global ) ) == '\n' || c == EOF_CHAR )
{
unget( global );
cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR
skipnl( global ); /* Prevent an extra */
unget( global ); /* Error message */
#endif
return(FPP_OK);
}
if( hash == L_if )
{
unget( global );
ret = eval( global, &found );
if( ret )
return( ret );
found = (found != 0); /* Evaluate expr, != 0 is TRUE */
hash = L_ifdef; /* #if is now like #ifdef */
}
else
{
if( type[c] != LET )
{ /* Next non-blank isn't letter */
/* ... is an error */
cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR
skipnl( global ); /* Prevent an extra */
unget( global ); /* Error message */
#endif
return(FPP_OK);
}
found = ( lookid( global, c ) != NULL ); /* Look for it in symbol table */
}
if( found == (hash == L_ifdef) )
{
compiling = TRUE;
*global->ifptr |= TRUE_SEEN;
}
else
compiling = FALSE;
return(FPP_OK);
}
INLINE FILE_LOCAL
ReturnCode doinclude( struct Global *global )
{
/*
* Process the #include control line.
* There are three variations:
*
* #include "file" search somewhere relative to the
* current source file, if not found,
* treat as #include <file>.
*
* #include <file> Search in an implementation-dependent
* list of places.
*
* #include token Expand the token, it must be one of
* "file" or <file>, process as such.
*
* Note: the November 12 draft forbids '>' in the #include <file> format.
* This restriction is unnecessary and not implemented.
*/
int c;
int delim;
ReturnCode ret;
delim = skipws( global );
if( ret = macroid( global, &delim ) )
return(ret);
if( delim != '<' && delim != '"' )
{
cerror( global, ERROR_INCLUDE_SYNTAX );
return( FPP_OK );
}
if( delim == '<' )
delim = '>';
global->workp = global->work;
while( (c = get(global)) != '\n' && c != EOF_CHAR )
if( ret = save( global, c ) ) /* Put it away. */
return( ret );
unget( global ); /* Force nl after include */
/*
* The draft is unclear if the following should be done.
*/
while( --global->workp >= global->work &&
(*global->workp == ' ' || *global->workp == '\t') )
; /* Trim blanks from filename */
if( *global->workp != delim )
{
cerror( global, ERROR_INCLUDE_SYNTAX );
return(FPP_OK);
}
*global->workp = EOS; /* Terminate filename */
ret = openinclude( global, global->work, (delim == '"') );
if( ret && global->warnnoinclude )
{
/*
* Warn if #include file isn't there.
*/
cwarn( global, WARN_CANNOT_OPEN_INCLUDE, global->work );
}
return( FPP_OK );
}
#ifdef _AMIGA
ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname );
#endif
ReturnCode openinclude( struct Global *global,
char *filename, /* Input file name */
int searchlocal ) /* TRUE if #include "file" */
{
/*
* Actually open an include file. This routine is only called from
* doinclude() above, but was written as a separate subroutine for
* programmer convenience. It searches the list of directories
* and actually opens the file, linking it into the list of
* active files. Returns ReturnCode. No error message is printed.
*/
char **incptr;
char tmpname[NWORK]; /* Filename work area */
int len;
#if HOST == SYS_AMIGADOS
if( strchr (filename, ':') != NULL )
{
if( ! openfile( global, filename ) )
return(FPP_OK);
}
#else
if( filename[0] == '/' )
{
if( ! openfile( global, filename ) )
return(FPP_OK);
}
#endif
if( searchlocal )
{
/*
* Look in local directory first.
* Try to open filename relative to the directory of the current
* source file (as opposed to the current directory). (ARF, SCK).
* Note that the fully qualified pathname is always built by
* discarding the last pathname component of the source file
* name then tacking on the #include argument.
*/
if( hasdirectory( global->infile->filename, tmpname ) )
strcat( tmpname, filename );
else
strcpy( tmpname, filename );
if( ! openfile( global, tmpname ) )
return(FPP_OK);
}
/*
* Look in any directories specified by -I command line
* arguments, then in the builtin search list.
*/
for( incptr = global->incdir; incptr < global->incend; incptr++ )
{
len = strlen(*incptr);
if( len + strlen(filename) >= sizeof(tmpname) )
{
cfatal( global, FATAL_FILENAME_BUFFER_OVERFLOW );
return( FPP_FILENAME_BUFFER_OVERFLOW );
}
else
{
#if HOST == SYS_AMIGADOS
if( (*incptr)[len-1] != '/' && (*incptr)[len-1] != ':' )
sprintf( tmpname, "%s/%s", *incptr, filename );
#else
if( (*incptr)[len-1] != '/' )
sprintf( tmpname, "%s/%s", *incptr, filename );
#endif
else
sprintf( tmpname, "%s%s", *incptr, filename );
#if HOST == SYS_AMIGADOS
//
// amp July 9, 1997
//
// OK, hack in multiassign support for the buitin
// search directories...
//
if( (*incptr)[len-1] == ':' )
{
if( ! MultiAssignLoad( global, *incptr, filename, tmpname ) )
return(FPP_OK);
}
else
#endif
if( !openfile( global, tmpname ) )
return(FPP_OK);
}
}
return( FPP_NO_INCLUDE );
}
INLINE FILE_LOCAL
int hasdirectory( char *source, /* Directory to examine */
char *result ) /* Put directory stuff here */
{
/*
* If a device or directory is found in the source filename string, the
* node/device/directory part of the string is copied to result and
* hasdirectory returns TRUE. Else, nothing is copied and it returns FALSE.
*/
char *tp2;
#if HOST == SYS_AMIGADOS
char *tp1;
if( (tp1 = strrchr( source, ':' ) ) == NULL )
tp1 = source;
if( (tp2 = strrchr( tp1, '/' ) ) == NULL )
tp2 = tp1;
if( tp2 == source )
return (FALSE);
#else
if( (tp2 = strrchr( source, '/' ) ) == NULL )
return(FALSE);
#endif
strncpy( result, source, tp2 - source + 1 );
result[tp2 - source + 1] = EOS;
return( TRUE );
}
#ifdef _AMIGA
//
// amp July 9, 1997
//
// Use the OS Luke...
//
// We do the sneaky version and let the OS do all
// the hard work so we don't have to mess around
// a lot ;)
//
ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname )
{ /* MultiAssignLoad */
struct MsgPort *FSTask;
struct DevProc *DevProc = NULL;
LONG RtnCode = FPP_NO_INCLUDE;
FSTask = GetFileSysTask();
do
{
//
// This should not bring up a requester.
// check to see if cpp does in fact tweek
// the process WindowPtr.
//
DevProc = GetDeviceProc( incptr, DevProc );
if( DevProc )
{
SetFileSysTask( DevProc->dvp_Port );
//
// Normally we would pass the lock and filename
// to the Load() routine, which would CD to the
// directory and Open(filename), but in order to
// satisfy the exisiting openfile() function, we
// bite the bullet and build the complete pathspec
// rather than add the standard Load() routine.
//
if( NameFromLock( DevProc->dvp_Lock, tmpname, NWORK ) )
{
AddPart( tmpname, filename, NWORK );
RtnCode = openfile( global, tmpname );
if( ! RtnCode )
break;
}
}
} while ( RtnCode &&
DevProc &&
(DevProc->dvp_Flags & DVPF_ASSIGN) &&
IoErr() == ERROR_OBJECT_NOT_FOUND); /* repeat if multi-assign */
SetFileSysTask( FSTask );
if( DevProc )
FreeDeviceProc( DevProc );
return RtnCode;
} /* MultiAssignLoad */
#endif //_AMIGA

395
3rdparty/fcpp/cpp3.c vendored Normal file
View File

@@ -0,0 +1,395 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <time.h> /*OIS*0.92*/
#include "cppdef.h"
#include "cpp.h"
ReturnCode openfile(struct Global *global, char *filename)
{
/*
* Open a file, add it to the linked list of open files.
* This is called only from openfile() in cpp2.c.
*/
FILE *fp;
ReturnCode ret;
if ((fp = fopen(filename, "r")) == NULL)
ret=FPP_OPEN_ERROR;
else
ret=addfile(global, fp, filename);
if(!ret && global->showincluded) {
/* no error occured! */
Error(global, "cpp: included \"");
Error(global, filename);
Error(global, "\"\n");
}
return(ret);
}
ReturnCode addfile(struct Global *global,
FILE *fp, /* Open file pointer */
char *filename) /* Name of the file */
{
/*
* Initialize tables for this open file. This is called from openfile()
* above (for #include files), and from the entry to cpp to open the main
* input file. It calls a common routine, getfile() to build the FILEINFO
* structure which is used to read characters. (getfile() is also called
* to setup a macro replacement.)
*/
FILEINFO *file;
ReturnCode ret;
ret = getfile(global, NBUFF, filename, &file);
if(ret)
return(ret);
file->fp = fp; /* Better remember FILE * */
file->buffer[0] = EOS; /* Initialize for first read */
global->line = 1; /* Working on line 1 now */
global->wrongline = TRUE; /* Force out initial #line */
return(FPP_OK);
}
int dooptions(struct Global *global, struct fppTag *tags)
{
/*
* dooptions is called to process command line arguments (-Detc).
* It is called only at cpp startup.
*/
DEFBUF *dp;
char end=FALSE; /* end of taglist */
while(tags && !end) {
switch(tags->tag) {
case FPPTAG_END:
end=TRUE;
break;
case FPPTAG_INITFUNC:
global->initialfunc = (char *) tags->data;
break;
case FPPTAG_DISPLAYFUNCTIONS:
global->outputfunctions = tags->data?1:0;
break;
case FPPTAG_RIGHTCONCAT:
global->rightconcat = tags->data?1:0;
break;
case FPPTAG_OUTPUTMAIN:
global->outputfile = tags->data?1:0;
break;
case FPPTAG_NESTED_COMMENTS:
global->nestcomments = tags->data?1:0;
break;
case FPPTAG_WARNMISSINCLUDE:
global->warnnoinclude = tags->data?1:0;
break;
case FPPTAG_WARN_NESTED_COMMENTS:
global->warnnestcomments = tags->data?1:0;
break;
case FPPTAG_OUTPUTSPACE:
global->showspace = tags->data?1:0;
break;
case FPPTAG_OUTPUTBALANCE:
global->showbalance = tags->data?1:0;
break;
case FPPTAG_OUTPUTINCLUDES:
global->showincluded = tags->data?1:0;
break;
case FPPTAG_IGNOREVERSION:
global->showversion = tags->data?1:0;
break;
case FPPTAG_WARNILLEGALCPP:
global->warnillegalcpp = tags->data?1:0;
break;
case FPPTAG_OUTPUTLINE:
global->outputLINE = tags->data?1:0;
break;
case FPPTAG_KEEPCOMMENTS:
if(tags->data) {
global->cflag = TRUE;
global->keepcomments = TRUE;
}
break;
case FPPTAG_DEFINE:
/*
* If the option is just "-Dfoo", make it -Dfoo=1
*/
{
char *symbol=(char *)tags->data;
char *text=symbol;
while (*text != EOS && *text != '=')
text++;
if (*text == EOS)
text = "1";
else
*text++ = EOS;
/*
* Now, save the word and its definition.
*/
dp = defendel(global, symbol, FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = savestring(global, text);
dp->nargs = DEF_NOARGS;
}
break;
case FPPTAG_IGNORE_NONFATAL:
global->eflag = TRUE;
break;
case FPPTAG_INCLUDE_DIR:
if (global->incend >= &global->incdir[NINCLUDE]) {
cfatal(global, FATAL_TOO_MANY_INCLUDE_DIRS);
return(FPP_TOO_MANY_INCLUDE_DIRS);
}
*global->incend++ = (char *)tags->data;
break;
case FPPTAG_INCLUDE_FILE:
case FPPTAG_INCLUDE_MACRO_FILE:
if (global->included >= NINCLUDE) {
cfatal(global, FATAL_TOO_MANY_INCLUDE_FILES);
return(FPP_TOO_MANY_INCLUDE_FILES);
}
global->include[global->included] = (char *)tags->data;
global->includeshow[global->included] =
(tags->tag == FPPTAG_INCLUDE_FILE);
global->included++;
break;
case FPPTAG_BUILTINS:
global->nflag|=(tags->data?NFLAG_BUILTIN:0);
break;
case FPPTAG_PREDEFINES:
global->nflag|=(tags->data?NFLAG_PREDEFINE:0);
break;
case FPPTAG_IGNORE_CPLUSPLUS:
global->cplusplus=!tags->data;
break;
case FPPTAG_SIZEOF_TABLE:
{
SIZES *sizp; /* For -S */
int size; /* For -S */
int isdatum; /* FALSE for -S* */
int endtest; /* For -S */
char *text=(char *)tags->data;
sizp = size_table;
if (isdatum = (*text != '*')) /* If it's just -S, */
endtest = T_FPTR; /* Stop here */
else { /* But if it's -S* */
text++; /* Step over '*' */
endtest = 0; /* Stop at end marker */
}
while (sizp->bits != endtest && *text != EOS) {
if (!isdigit(*text)) { /* Skip to next digit */
text++;
continue;
}
size = 0; /* Compile the value */
while (isdigit(*text)) {
size *= 10;
size += (*text++ - '0');
}
if (isdatum)
sizp->size = size; /* Datum size */
else
sizp->psize = size; /* Pointer size */
sizp++;
}
if (sizp->bits != endtest)
cwarn(global, WARN_TOO_FEW_VALUES_TO_SIZEOF, NULL);
else if (*text != EOS)
cwarn(global, WARN_TOO_MANY_VALUES_TO_SIZEOF, NULL);
}
break;
case FPPTAG_UNDEFINE:
if (defendel(global, (char *)tags->data, TRUE) == NULL)
cwarn(global, WARN_NOT_DEFINED, tags->data);
break;
case FPPTAG_OUTPUT_DEFINES:
global->wflag++;
break;
case FPPTAG_INPUT_NAME:
strcpy(global->work, tags->data); /* Remember input filename */
global->first_file=tags->data;
break;
case FPPTAG_INPUT:
global->input=(char *(*)(char *, int, void *))tags->data;
break;
case FPPTAG_OUTPUT:
global->output=(void (*)(int, void *))tags->data;
break;
case FPPTAG_ERROR:
global->error=(void (*)(void *, char *, va_list))tags->data;
break;
case FPPTAG_USERDATA:
global->userdata=tags->data;
break;
case FPPTAG_LINE:
global->linelines= tags->data?1:0;
break;
case FPPTAG_EXCLFUNC:
global->excludedinit[ global->excluded++ ] = (char *)tags->data;
break;
case FPPTAG_WEBMODE:
global->webmode=(tags->data?1:0);
break;
default:
cwarn(global, WARN_INTERNAL_ERROR, NULL);
break;
}
tags++;
}
return(0);
}
ReturnCode initdefines(struct Global *global)
{
/*
* Initialize the built-in #define's. There are two flavors:
* #define decus 1 (static definitions)
* #define __FILE__ ?? (dynamic, evaluated by magic)
* Called only on cpp startup.
*
* Note: the built-in static definitions are supressed by the -N option.
* __LINE__, __FILE__, __TIME__ and __DATE__ are always present.
*/
char **pp;
char *tp;
DEFBUF *dp;
struct tm *tm;
int i;
time_t tvec;
static char months[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
/*
* Predefine the built-in symbols. Allow the
* implementor to pre-define a symbol as "" to
* eliminate it.
*/
if (!(global->nflag & NFLAG_BUILTIN)) {
for (pp = global->preset; *pp != NULL; pp++) {
if (*pp[0] != EOS) {
dp = defendel(global, *pp, FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = savestring(global, "1");
dp->nargs = DEF_NOARGS;
}
}
}
/*
* The magic pre-defines (__FILE__ and __LINE__ are
* initialized with negative argument counts. expand()
* notices this and calls the appropriate routine.
* DEF_NOARGS is one greater than the first "magic" definition.
*/
if (!(global->nflag & NFLAG_PREDEFINE)) {
for (pp = global->magic, i = DEF_NOARGS; *pp != NULL; pp++) {
dp = defendel(global, *pp, FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->nargs = --i;
}
#if OK_DATE
/*
* Define __DATE__ as today's date.
*/
dp = defendel(global, "__DATE__", FALSE);
tp = malloc(14);
if(!tp || !dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = tp;
dp->nargs = DEF_NOARGS;
time(&tvec);
tm = localtime(&tvec);
sprintf(tp, "\"%3s %2d %4d\"", /* "Aug 20 1988" */
months[tm->tm_mon],
tm->tm_mday,
tm->tm_year + 1900);
/*
* Define __TIME__ as this moment's time.
*/
dp = defendel(global, "__TIME__", FALSE);
tp = malloc(11);
if(!tp || !dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = tp;
dp->nargs = DEF_NOARGS;
sprintf(tp, "\"%2d:%02d:%02d\"", /* "20:42:31" */
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
#endif
}
return(FPP_OK);
}
void deldefines(struct Global *global)
{
/*
* Delete the built-in #define's.
*/
char **pp;
int i;
/*
* Delete the built-in symbols, unless -WW.
*/
if (global->wflag < 2) {
for (pp = global->preset; *pp != NULL; pp++) {
defendel(global, *pp, TRUE);
}
}
/*
* The magic pre-defines __FILE__ and __LINE__
*/
for (pp = global->magic, i = DEF_NOARGS; *pp != NULL; pp++) {
defendel(global, *pp, TRUE);
}
#if OK_DATE
/*
* Undefine __DATE__.
*/
defendel(global, "__DATE__", TRUE);
/*
* Undefine __TIME__.
*/
defendel(global, "__TIME__", TRUE);
#endif
return;
}

633
3rdparty/fcpp/cpp4.c vendored Normal file
View File

@@ -0,0 +1,633 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
INLINE FILE_LOCAL ReturnCode checkparm(struct Global *, int, DEFBUF *, int);
INLINE FILE_LOCAL ReturnCode stparmscan(struct Global *, int);
INLINE FILE_LOCAL ReturnCode textput(struct Global *, char *);
FILE_LOCAL ReturnCode charput(struct Global *, int);
INLINE FILE_LOCAL ReturnCode expcollect(struct Global *);
INLINE FILE_LOCAL char *doquoting(char *, char *);
ReturnCode dodefine(struct Global *global)
{
/*
* Called from control when a #define is scanned. This module
* parses formal parameters and the replacement string. When
* the formal parameter name is encountered in the replacement
* string, it is replaced by a character in the range 128 to
* 128+NPARAM (this allows up to 32 parameters within the
* Dec Multinational range). If cpp is ported to an EBCDIC
* machine, you will have to make other arrangements.
*
* There is some special case code to distinguish
* #define foo bar
* from #define foo() bar
*
* Also, we make sure that
* #define foo foo
* expands to "foo" but doesn't put cpp into an infinite loop.
*
* A warning message is printed if you redefine a symbol to a
* different text. I.e,
* #define foo 123
* #define foo 123
* is ok, but
* #define foo 123
* #define foo +123
* is not.
*
* The following subroutines are called from define():
* checkparm called when a token is scanned. It checks through the
* array of formal parameters. If a match is found, the
* token is replaced by a control byte which will be used
* to locate the parameter when the macro is expanded.
* textput puts a string in the macro work area (parm[]), updating
* parmp to point to the first free byte in parm[].
* textput() tests for work buffer overflow.
* charput puts a single character in the macro work area (parm[])
* in a manner analogous to textput().
*/
int c;
DEFBUF *dp; /* -> new definition */
int isredefine; /* TRUE if redefined */
char *old; /* Remember redefined */
ReturnCode ret;
#if OK_CONCAT
int quoting; /* Remember we saw a # */
#endif
if (type[(c = skipws(global))] != LET) {
cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
isredefine = FALSE; /* Set if redefining */
if ((dp = lookid(global, c)) == NULL) { /* If not known now */
dp = defendel(global, global->tokenbuf, FALSE); /* Save the name */
if(!dp)
return(FPP_OUT_OF_MEMORY);
} else { /* It's known: */
isredefine = TRUE; /* Remember this fact */
old = dp->repl; /* Remember replacement */
dp->repl = NULL; /* No replacement now */
}
global->parlist[0] = global->parmp = global->parm; /* Setup parm buffer */
if ((c = get(global)) == '(') { /* With arguments? */
global->nargs = 0; /* Init formals counter */
do { /* Collect formal parms */
if (global->nargs >= LASTPARM) {
cfatal(global, FATAL_TOO_MANY_ARGUMENTS_MACRO);
return(FPP_TOO_MANY_ARGUMENTS);
} else if ((c = skipws(global)) == ')')
break; /* Got them all */
else if (type[c] != LET) { /* Bad formal syntax */
cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
scanid(global, c); /* Get the formal param */
global->parlist[global->nargs++] = global->parmp; /* Save its start */
ret=textput(global, global->tokenbuf); /* Save text in parm[] */
if(ret)
return(ret);
} while ((c = skipws(global)) == ','); /* Get another argument */
if (c != ')') { /* Must end at ) */
cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
c = ' '; /* Will skip to body */
}
else {
/*
* DEF_NOARGS is needed to distinguish between
* "#define foo" and "#define foo()".
*/
global->nargs = DEF_NOARGS; /* No () parameters */
}
if (type[c] == SPA) /* At whitespace? */
c = skipws(global); /* Not any more. */
global->workp = global->work; /* Replacement put here */
global->inmacro = TRUE; /* Keep \<newline> now */
quoting = 0; /* No # seen yet. */
while (c != EOF_CHAR && c != '\n') { /* Compile macro body */
#if OK_CONCAT
if (c == '#') { /* Token concatenation? */
if ((c = get(global)) != '#') { /* No, not really */
quoting = 1; /* Maybe quoting op. */
continue;
}
while (global->workp > global->work && type[global->workp[-1]] == SPA)
--global->workp; /* Erase leading spaces */
if(ret=save(global, TOK_SEP)) /* Stuff a delimiter */
return(ret);
c = skipws(global); /* Eat whitespace */
continue;
}
#endif
switch (type[c]) {
case LET:
#if OK_CONCAT
ret=checkparm(global, c, dp, quoting); /* Might be a formal */
#else
ret=checkparm(c, dp); /* Might be a formal */
#endif
if(ret)
return(ret);
break;
case DIG: /* Number in mac. body */
case DOT: /* Maybe a float number */
ret=scannumber(global, c, save); /* Scan it off */
if(ret)
return(ret);
break;
case QUO: /* String in mac. body */
ret=stparmscan(global, c);
if(ret)
return(ret);
break;
case BSH: /* Backslash */
ret=save(global, '\\');
if(ret)
return(ret);
if ((c = get(global)) == '\n')
global->wrongline = TRUE;
ret=save(global, c);
if(ret)
return(ret);
break;
case SPA: /* Absorb whitespace */
/*
* Note: the "end of comment" marker is passed on
* to allow comments to separate tokens.
*/
if (global->workp[-1] == ' ') /* Absorb multiple */
break; /* spaces */
else if (c == '\t')
c = ' '; /* Normalize tabs */
/* Fall through to store character */
default: /* Other character */
ret=save(global, c);
if(ret)
return(ret);
break;
}
c = get(global);
quoting = 0; /* Only when immediately*/
/* preceding a formal */
}
global->inmacro = FALSE; /* Stop newline hack */
unget(global); /* For control check */
if (global->workp > global->work && global->workp[-1] == ' ') /* Drop trailing blank */
global->workp--;
*global->workp = EOS; /* Terminate work */
dp->repl = savestring(global, global->work); /* Save the string */
dp->nargs = global->nargs; /* Save arg count */
if (isredefine) { /* Error if redefined */
if ((old != NULL && dp->repl != NULL && !streq(old, dp->repl))
|| (old == NULL && dp->repl != NULL)
|| (old != NULL && dp->repl == NULL)) {
cerror(global, ERROR_REDEFINE, dp->name);
}
if (old != NULL) /* We don't need the */
free(old); /* old definition now. */
}
return(FPP_OK);
}
INLINE FILE_LOCAL
ReturnCode checkparm(struct Global *global,
int c,
DEFBUF *dp,
int quoting) /* Preceded by a # ? */
{
/*
* Replace this param if it's defined. Note that the macro name is a
* possible replacement token. We stuff DEF_MAGIC in front of the token
* which is treated as a LETTER by the token scanner and eaten by
* the output routine. This prevents the macro expander from
* looping if someone writes "#define foo foo".
*/
int i;
char *cp;
ReturnCode ret=FPP_OK;
scanid(global, c); /* Get parm to tokenbuf */
for (i = 0; i < global->nargs; i++) { /* For each argument */
if (streq(global->parlist[i], global->tokenbuf)) { /* If it's known */
#if OK_CONCAT
if (quoting) { /* Special handling of */
ret=save(global, QUOTE_PARM); /* #formal inside defn */
if(ret)
return(ret);
}
#endif
ret=save(global, i + MAC_PARM); /* Save a magic cookie */
return(ret); /* And exit the search */
}
}
if (streq(dp->name, global->tokenbuf)) /* Macro name in body? */
ret=save(global, DEF_MAGIC); /* Save magic marker */
for (cp = global->tokenbuf; *cp != EOS;) /* And save */
ret=save(global, *cp++); /* The token itself */
return(ret);
}
INLINE FILE_LOCAL
ReturnCode stparmscan(struct Global *global, int delim)
{
/*
* Normal string parameter scan.
*/
unsigned char *wp;
int i;
ReturnCode ret;
wp = (unsigned char *)global->workp; /* Here's where it starts */
ret=scanstring(global, delim, save);
if(ret)
return(ret); /* Exit on scanstring error */
global->workp[-1] = EOS; /* Erase trailing quote */
wp++; /* -> first string content byte */
for (i = 0; i < global->nargs; i++) {
if (streq(global->parlist[i], (char *)wp)) {
*wp++ = MAC_PARM + PAR_MAC; /* Stuff a magic marker */
*wp++ = (i + MAC_PARM); /* Make a formal marker */
*wp = wp[-3]; /* Add on closing quote */
global->workp = (char *)wp + 1; /* Reset string end */
return(FPP_OK);
}
}
global->workp[-1] = wp[-1]; /* Nope, reset end quote. */
return(FPP_OK);
}
void doundef(struct Global *global)
/*
* Remove the symbol from the defined list.
* Called from the #control processor.
*/
{
int c;
if (type[(c = skipws(global))] != LET)
cerror(global, ERROR_ILLEGAL_UNDEF);
else {
scanid(global, c); /* Get name to tokenbuf */
(void) defendel(global, global->tokenbuf, TRUE);
}
}
INLINE FILE_LOCAL
ReturnCode textput(struct Global *global, char *text)
{
/*
* Put the string in the parm[] buffer.
*/
int size;
size = strlen(text) + 1;
if ((global->parmp + size) >= &global->parm[NPARMWORK]) {
cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW);
} else {
strcpy(global->parmp, text);
global->parmp += size;
}
return(FPP_OK);
}
FILE_LOCAL
ReturnCode charput(struct Global *global, int c)
{
/*
* Put the byte in the parm[] buffer.
*/
if (global->parmp >= &global->parm[NPARMWORK]) {
cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW);
}
*global->parmp++ = c;
return(FPP_OK);
}
/*
* M a c r o E x p a n s i o n
*/
ReturnCode expand(struct Global *global, DEFBUF *tokenp)
{
/*
* Expand a macro. Called from the cpp mainline routine (via subroutine
* macroid()) when a token is found in the symbol table. It calls
* expcollect() to parse actual parameters, checking for the correct number.
* It then creates a "file" containing a single line containing the
* macro with actual parameters inserted appropriately. This is
* "pushed back" onto the input stream. (When the get() routine runs
* off the end of the macro line, it will dismiss the macro itself.)
*/
int c;
FILEINFO *file;
ReturnCode ret=FPP_OK;
/*
* If no macro is pending, save the name of this macro
* for an eventual error message.
*/
if (global->recursion++ == 0)
global->macro = tokenp;
else if (global->recursion == RECURSION_LIMIT) {
cerror(global, ERROR_RECURSIVE_MACRO, tokenp->name, global->macro->name);
if (global->rec_recover) {
do {
c = get(global);
} while (global->infile != NULL && global->infile->fp == NULL);
unget(global);
global->recursion = 0;
return(FPP_OK);
}
}
/*
* Here's a macro to expand.
*/
global->nargs = 0; /* Formals counter */
global->parmp = global->parm; /* Setup parm buffer */
switch (tokenp->nargs) {
case (-2): /* __LINE__ */
if(global->infile->fp)
/* This is a file */
sprintf(global->work, "%d", global->line);
else
/* This is a macro! Find out the file line number! */
for (file = global->infile; file != NULL; file = file->parent) {
if (file->fp != NULL) {
sprintf(global->work, "%d", file->line);
break;
}
}
ret=ungetstring(global, global->work);
if(ret)
return(ret);
break;
case (-3): /* __FILE__ */
for (file = global->infile; file != NULL; file = file->parent) {
if (file->fp != NULL) {
sprintf(global->work, "\"%s\"", (file->progname != NULL)
? file->progname : file->filename);
ret=ungetstring(global, global->work);
if(ret)
return(ret);
break;
}
}
break;
case (-4): /* __FUNC__ */
sprintf(global->work, "\"%s\"", global->functionname[0]?
global->functionname : "<unknown function>");
ret=ungetstring(global, global->work);
if(ret)
return(ret);
break;
case (-5): /* __FUNC_LINE__ */
sprintf(global->work, "%d", global->funcline);
ret=ungetstring(global, global->work);
if(ret)
return(ret);
break;
default:
/*
* Nothing funny about this macro.
*/
if (tokenp->nargs < 0) {
cfatal(global, FATAL_ILLEGAL_MACRO, tokenp->name);
return(FPP_ILLEGAL_MACRO);
}
while ((c = skipws(global)) == '\n') /* Look for (, skipping */
global->wrongline = TRUE; /* spaces and newlines */
if (c != '(') {
/*
* If the programmer writes
* #define foo() ...
* ...
* foo [no ()]
* just write foo to the output stream.
*/
unget(global);
cwarn(global, WARN_MACRO_NEEDS_ARGUMENTS, tokenp->name);
/* fputs(tokenp->name, stdout); */
Putstring(global, tokenp->name);
return(FPP_OK);
} else if (!(ret=expcollect(global))) { /* Collect arguments */
if (tokenp->nargs != global->nargs) { /* Should be an error? */
cwarn(global, WARN_WRONG_NUMBER_ARGUMENTS, tokenp->name);
}
} else { /* Collect arguments */
return(ret); /* We failed in argument colleting! */
}
case DEF_NOARGS: /* No parameters just stuffs */
ret=expstuff(global, tokenp->name, tokenp->repl); /* expand macro */
} /* nargs switch */
return(ret);
}
INLINE FILE_LOCAL
ReturnCode expcollect(struct Global *global)
{
/*
* Collect the actual parameters for this macro.
*/
int c;
int paren; /* For embedded ()'s */
ReturnCode ret;
for (;;) {
paren = 0; /* Collect next arg. */
while ((c = skipws(global)) == '\n')/* Skip over whitespace */
global->wrongline = TRUE; /* and newlines. */
if (c == ')') { /* At end of all args? */
/*
* Note that there is a guard byte in parm[]
* so we don't have to check for overflow here.
*/
*global->parmp = EOS; /* Make sure terminated */
break; /* Exit collection loop */
}
else if (global->nargs >= LASTPARM) {
cfatal(global, FATAL_TOO_MANY_ARGUMENTS_EXPANSION);
return(FPP_TOO_MANY_ARGUMENTS);
}
global->parlist[global->nargs++] = global->parmp; /* At start of new arg */
for (;; c = cget(global)) { /* Collect arg's bytes */
if (c == EOF_CHAR) {
cerror(global, ERROR_EOF_IN_ARGUMENT);
return(FPP_EOF_IN_MACRO); /* Sorry. */
}
else if (c == '\\') { /* Quote next character */
charput(global, c); /* Save the \ for later */
charput(global, cget(global)); /* Save the next char. */
continue; /* And go get another */
}
else if (type[c] == QUO) { /* Start of string? */
ret=scanstring(global, c, (ReturnCode (*)(struct Global *, int))charput); /* Scan it off */
if(ret)
return(ret);
continue; /* Go get next char */
}
else if (c == '(') /* Worry about balance */
paren++; /* To know about commas */
else if (c == ')') { /* Other side too */
if (paren == 0) { /* At the end? */
unget(global); /* Look at it later */
break; /* Exit arg getter. */
}
paren--; /* More to come. */
}
else if (c == ',' && paren == 0) /* Comma delimits args */
break;
else if (c == '\n') /* Newline inside arg? */
global->wrongline = TRUE; /* We'll need a #line */
charput(global, c); /* Store this one */
} /* Collect an argument */
charput(global, EOS); /* Terminate argument */
} /* Collect all args. */
return(FPP_OK); /* Normal return */
}
#if OK_CONCAT
INLINE FILE_LOCAL
char *doquoting(char *to, char *from)
{
*to++ = '"';
while (*from) {
if (*from == '\\' || *from == '"')
*to++ = '\\';
*to++ = *from++;
}
*to++ = '"';
return to;
}
#endif
ReturnCode expstuff(struct Global *global,
char *MacroName,
char *MacroReplace)
{
/*
* Stuff the macro body, replacing formal parameters by actual parameters.
*/
int c; /* Current character */
char *inp; /* -> repl string */
char *defp; /* -> macro output buff */
int size; /* Actual parm. size */
char *defend; /* -> output buff end */
int string_magic; /* String formal hack */
FILEINFO *file; /* Funny #include */
ReturnCode ret;
#if OK_CONCAT
char quoting; /* Quote macro argument */
#endif
ret = getfile(global, NBUFF, MacroName, &file);
if(ret)
return(ret);
inp = MacroReplace; /* -> macro replacement */
defp = file->buffer; /* -> output buffer */
defend = defp + (NBUFF - 1); /* Note its end */
if (inp != NULL) {
quoting = 0;
while ((c = (*inp++ & 0xFF)) != EOS) {
#if OK_CONCAT
if (c == QUOTE_PARM) { /* Special token for # */
quoting = 1; /* set flag, for later */
continue; /* Get next character */
}
#endif
if (c >= MAC_PARM && c <= (MAC_PARM + PAR_MAC)) {
string_magic = (c == (MAC_PARM + PAR_MAC));
if (string_magic)
c = (*inp++ & 0xFF);
/*
* Replace formal parameter by actual parameter string.
*/
if ((c -= MAC_PARM) < global->nargs) {
size = strlen(global->parlist[c]);
#if OK_CONCAT
if (quoting) {
size++;
size *= 2; /* worst case condition */
}
#endif
if ((defp + size) >= defend) {
cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
}
/*
* Erase the extra set of quotes.
*/
if (string_magic && defp[-1] == global->parlist[c][0]) {
strcpy(defp-1, global->parlist[c]);
defp += (size - 2);
}
#if OK_CONCAT
else if (quoting)
defp = doquoting(defp, global->parlist[c]);
#endif
else {
strcpy(defp, global->parlist[c]);
defp += size;
}
}
}
else if (defp >= defend) {
cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
} else
*defp++ = c;
quoting = 0;
}
}
*defp = EOS;
return(FPP_OK);
}

903
3rdparty/fcpp/cpp5.c vendored Normal file
View File

@@ -0,0 +1,903 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
INLINE FILE_LOCAL ReturnCode evallex(struct Global *, int, int *);
INLINE FILE_LOCAL ReturnCode dosizeof(struct Global *, int *);
INLINE FILE_LOCAL int bittest(int);
INLINE FILE_LOCAL int evalnum(struct Global *, int);
INLINE FILE_LOCAL int evalchar(struct Global *, int);
INLINE FILE_LOCAL int *evaleval(struct Global *, int *, int, int);
/*
* Evaluate an #if expression.
*/
static char *opname[] = { /* For debug and error messages */
"end of expression", "val", "id",
"+", "-", "*", "/", "%",
"<<", ">>", "&", "|", "^",
"==", "!=", "<", "<=", ">=", ">",
"&&", "||", "?", ":", ",",
"unary +", "unary -", "~", "!", "(", ")", "(none)",
};
/*
* opdope[] has the operator precedence:
* Bits
* 7 Unused (so the value is always positive)
* 6-2 Precedence (000x .. 017x)
* 1-0 Binary op. flags:
* 01 The binop flag should be set/cleared when this op is seen.
* 10 The new value of the binop flag.
* Note: Expected, New binop
* constant 0 1 Binop, end, or ) should follow constants
* End of line 1 0 End may not be preceeded by an operator
* binary 1 0 Binary op follows a value, value follows.
* unary 0 0 Unary op doesn't follow a value, value follows
* ( 0 0 Doesn't follow value, value or unop follows
* ) 1 1 Follows value. Op follows.
*/
static char opdope[OP_MAX] = {
0001, /* End of expression */
0002, /* Digit */
0000, /* Letter (identifier) */
0141, 0141, 0151, 0151, 0151, /* ADD, SUB, MUL, DIV, MOD */
0131, 0131, 0101, 0071, 0071, /* ASL, ASR, AND, OR, XOR */
0111, 0111, 0121, 0121, 0121, 0121, /* EQ, NE, LT, LE, GE, GT */
0061, 0051, 0041, 0041, 0031, /* ANA, ORO, QUE, COL, CMA */
/*
* Unary op's follow
*/
0160, 0160, 0160, 0160, /* NEG, PLU, COM, NOT */
0170, 0013, 0023, /* LPA, RPA, END */
};
/*
* OP_QUE and OP_RPA have alternate precedences:
*/
#define OP_RPA_PREC 0013
#define OP_QUE_PREC 0034
/*
* S_ANDOR and S_QUEST signal "short-circuit" boolean evaluation, so that
* #if FOO != 0 && 10 / FOO ...
* doesn't generate an error message. They are stored in optab.skip.
*/
#define S_ANDOR 2
#define S_QUEST 1
typedef struct optab {
char op; /* Operator */
char prec; /* Its precedence */
char skip; /* Short-circuit: TRUE to skip */
} OPTAB;
#ifdef nomacargs
FILE_LOCAL int
isbinary(op)
int op;
{
return (op >= FIRST_BINOP && op <= LAST_BINOP);
}
FILE_LOCAL int
isunary(op)
int op;
{
return (op >= FIRST_UNOP && op <= LAST_UNOP);
}
#else
#define isbinary(op) (op >= FIRST_BINOP && op <= LAST_BINOP)
#define isunary(op) (op >= FIRST_UNOP && op <= LAST_UNOP)
#endif
/*
* The following definitions are used to specify basic variable sizes.
*/
#if OK_SIZEOF
#ifndef S_CHAR
#define S_CHAR (sizeof (char))
#endif
#ifndef S_SINT
#ifdef manx /* Aztec/Manx C does not like "short int" */
#define S_SINT (sizeof (short))
#else
#define S_SINT (sizeof (short int))
#endif
#endif
#ifndef S_INT
#define S_INT (sizeof (int))
#endif
#ifndef S_LINT
#define S_LINT (sizeof (long int))
#endif
#ifndef S_FLOAT
#define S_FLOAT (sizeof (float))
#endif
#ifndef S_DOUBLE
#define S_DOUBLE (sizeof (double))
#endif
#ifndef S_PCHAR
#define S_PCHAR (sizeof (char *))
#endif
#ifndef S_PSINT
#ifdef manx /* Aztec/Manx C does not like "short int" */
#define S_PSINT (sizeof (short *))
#else
#define S_PSINT (sizeof (short int *))
#endif
#endif
#ifndef S_PINT
#define S_PINT (sizeof (int *))
#endif
#ifndef S_PLINT
#define S_PLINT (sizeof (long int *))
#endif
#ifndef S_PFLOAT
#define S_PFLOAT (sizeof (float *))
#endif
#ifndef S_PDOUBLE
#define S_PDOUBLE (sizeof (double *))
#endif
#ifndef S_PFPTR
#define S_PFPTR (sizeof (int (*)()))
#endif
typedef struct types {
short type; /* This is the bit if */
char *name; /* this is the token word */
} TYPES;
static TYPES basic_types[] = {
{ T_CHAR, "char", },
{ T_INT, "int", },
{ T_FLOAT, "float", },
{ T_DOUBLE, "double", },
{ T_SHORT, "short", },
{ T_LONG, "long", },
{ T_SIGNED, "signed", },
{ T_UNSIGNED, "unsigned", },
{ 0, NULL, }, /* Signal end */
};
/*
* Test_table[] is used to test for illegal combinations.
*/
static short test_table[] = {
T_FLOAT | T_DOUBLE | T_LONG | T_SHORT,
T_FLOAT | T_DOUBLE | T_CHAR | T_INT,
T_FLOAT | T_DOUBLE | T_SIGNED | T_UNSIGNED,
T_LONG | T_SHORT | T_CHAR,
0 /* end marker */
};
/*
* The order of this table is important -- it is also referenced by
* the command line processor to allow run-time overriding of the
* built-in size values. The order must not be changed:
* char, short, int, long, float, double (func pointer)
*/
SIZES size_table[] = {
{ T_CHAR, S_CHAR, S_PCHAR }, /* char */
{ T_SHORT, S_SINT, S_PSINT }, /* short int */
{ T_INT, S_INT, S_PINT }, /* int */
{ T_LONG, S_LINT, S_PLINT }, /* long */
{ T_FLOAT, S_FLOAT, S_PFLOAT }, /* float */
{ T_DOUBLE, S_DOUBLE, S_PDOUBLE }, /* double */
{ T_FPTR, 0, S_PFPTR }, /* int (*()) */
{ 0, 0, 0 }, /* End of table */
};
#endif /* OK_SIZEOF */
ReturnCode eval(struct Global *global, int *eval)
{
/*
* Evaluate an expression. Straight-forward operator precedence.
* This is called from control() on encountering an #if statement.
* It calls the following routines:
* evallex Lexical analyser -- returns the type and value of
* the next input token.
* evaleval Evaluate the current operator, given the values on
* the value stack. Returns a pointer to the (new)
* value stack.
* For compatiblity with older cpp's, this return returns 1 (TRUE)
* if a syntax error is detected.
*/
int op; /* Current operator */
int *valp; /* -> value vector */
OPTAB *opp; /* Operator stack */
int prec; /* Op precedence */
int binop; /* Set if binary op. needed */
int op1; /* Operand from stack */
int skip; /* For short-circuit testing */
int value[NEXP]; /* Value stack */
OPTAB opstack[NEXP]; /* Operand stack */
ReturnCode ret;
char again=TRUE;
valp = value;
opp = opstack;
opp->op = OP_END; /* Mark bottom of stack */
opp->prec = opdope[OP_END]; /* And its precedence */
opp->skip = 0; /* Not skipping now */
binop = 0;
while(again) {
ret=evallex(global, opp->skip, &op);
if(ret)
return(ret);
if (op == OP_SUB && binop == 0)
op = OP_NEG; /* Unary minus */
else if (op == OP_ADD && binop == 0)
op = OP_PLU; /* Unary plus */
else if (op == OP_FAIL) {
*eval=1; /* Error in evallex */
return(FPP_OK);
}
if (op == DIG) { /* Value? */
if (binop != 0) {
cerror(global, ERROR_MISPLACED_CONSTANT);
*eval=1;
return(FPP_OK);
} else if (valp >= &value[NEXP-1]) {
cerror(global, ERROR_IF_OVERFLOW);
*eval=1;
return(FPP_OK);
} else {
*valp++ = global->evalue;
binop = 1;
}
again=TRUE;
continue;
} else if (op > OP_END) {
cerror(global, ERROR_ILLEGAL_IF_LINE);
*eval=1;
return(FPP_OK);
}
prec = opdope[op];
if (binop != (prec & 1)) {
cerror(global, ERROR_OPERATOR, opname[op]);
*eval=1;
return(FPP_OK);
}
binop = (prec & 2) >> 1;
do {
if (prec > opp->prec) {
if (op == OP_LPA)
prec = OP_RPA_PREC;
else if (op == OP_QUE)
prec = OP_QUE_PREC;
op1 = opp->skip; /* Save skip for test */
/*
* Push operator onto op. stack.
*/
opp++;
if (opp >= &opstack[NEXP]) {
cerror(global, ERROR_EXPR_OVERFLOW, opname[op]);
*eval=1;
return(FPP_OK);
}
opp->op = op;
opp->prec = prec;
skip = (valp[-1] != 0); /* Short-circuit tester */
/*
* Do the short-circuit stuff here. Short-circuiting
* stops automagically when operators are evaluated.
*/
if ((op == OP_ANA && !skip)
|| (op == OP_ORO && skip))
opp->skip = S_ANDOR; /* And/or skip starts */
else if (op == OP_QUE) /* Start of ?: operator */
opp->skip = (op1 & S_ANDOR) | ((!skip) ? S_QUEST : 0);
else if (op == OP_COL) { /* : inverts S_QUEST */
opp->skip = (op1 & S_ANDOR)
| (((op1 & S_QUEST) != 0) ? 0 : S_QUEST);
}
else { /* Other ops leave */
opp->skip = op1; /* skipping unchanged. */
}
again=TRUE;
continue;
}
/*
* Pop operator from op. stack and evaluate it.
* End of stack and '(' are specials.
*/
skip = opp->skip; /* Remember skip value */
switch ((op1 = opp->op)) { /* Look at stacked op */
case OP_END: /* Stack end marker */
if (op == OP_EOE) {
*eval=valp[-1]; /* Finished ok. */
return(FPP_OK);
}
/* Read another op. */
again=TRUE;
continue;
case OP_LPA: /* ( on stack */
if (op != OP_RPA) { /* Matches ) on input */
cerror(global, ERROR_UNBALANCED_PARENS, opname[op]);
*eval=1;
return(FPP_OK);
}
opp--; /* Unstack it */
/* -- Fall through */
case OP_QUE:
/* Evaluate true expr. */
again=TRUE;
continue;
case OP_COL: /* : on stack. */
opp--; /* Unstack : */
if (opp->op != OP_QUE) { /* Matches ? on stack? */
cerror(global, ERROR_MISPLACED, opname[opp->op]);
*eval=1;
return(FPP_OK);
}
/*
* Evaluate op1.
*/
default: /* Others: */
opp--; /* Unstack the operator */
valp = evaleval(global, valp, op1, skip);
again=FALSE;
} /* op1 switch end */
} while (!again); /* Stack unwind loop */
}
return(FPP_OK);
}
INLINE FILE_LOCAL
ReturnCode evallex(struct Global *global,
int skip, /* TRUE if short-circuit evaluation */
int *op)
{
/*
* Set *op to next eval operator or value. Called from eval(). It
* calls a special-purpose routines for 'char' strings and
* numeric values:
* evalchar called to evaluate 'x'
* evalnum called to evaluate numbers.
*/
int c, c1, t;
ReturnCode ret;
char loop;
do { /* while(loop); */
/* again: */
loop=FALSE;
do { /* Collect the token */
c = skipws(global);
if(ret=macroid(global, &c))
return(ret);
if (c == EOF_CHAR || c == '\n') {
unget(global);
*op=OP_EOE; /* End of expression */
return(FPP_OK);
}
} while ((t = type[c]) == LET && catenate(global, &ret) && !ret);
if(ret)
/* If the loop was broken because of a fatal error! */
return(ret);
if (t == INV) { /* Total nonsense */
if (!skip) {
if (isascii(c) && isprint(c))
cerror(global, ERROR_ILLEGAL_CHARACTER, c);
else
cerror(global, ERROR_ILLEGAL_CHARACTER2, c);
}
return(FPP_ILLEGAL_CHARACTER);
} else if (t == QUO) { /* ' or " */
if (c == '\'') { /* Character constant */
global->evalue = evalchar(global, skip); /* Somewhat messy */
*op=DIG; /* Return a value */
return(FPP_OK);
}
cerror(global, ERROR_STRING_IN_IF);
return(FPP_CANT_USE_STRING_IN_IF);
} else if (t == LET) { /* ID must be a macro */
if (streq(global->tokenbuf, "defined")) { /* Or defined name */
c1 = c = skipws(global);
if (c == '(') /* Allow defined(name) */
c = skipws(global);
if (type[c] == LET) {
global->evalue = (lookid(global, c) != NULL);
if (c1 != '(' /* Need to balance */
|| skipws(global) == ')') { /* Did we balance? */
*op=DIG;
return(FPP_OK); /* Parsed ok */
}
}
cerror(global, ERROR_DEFINED_SYNTAX);
return(FPP_BAD_IF_DEFINED_SYNTAX);
}
#if OK_SIZEOF
else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
ret=dosizeof(global, op); /* Gets own routine */
return(ret);
}
#endif
global->evalue = 0;
*op=DIG;
return(FPP_OK);
}
else if (t == DIG) { /* Numbers are harder */
global->evalue = evalnum(global, c);
}
else if (strchr("!=<>&|\\", c) != NULL) {
/*
* Process a possible multi-byte lexeme.
*/
c1 = cget(global); /* Peek at next char */
switch (c) {
case '!':
if (c1 == '=') {
*op=OP_NE;
return(FPP_OK);
}
break;
case '=':
if (c1 != '=') { /* Can't say a=b in #if */
unget(global);
cerror(global, ERROR_ILLEGAL_ASSIGN);
return (FPP_IF_ERROR);
}
*op=OP_EQ;
return(FPP_OK);
case '>':
case '<':
if (c1 == c) {
*op= ((c == '<') ? OP_ASL : OP_ASR);
return(FPP_OK);
} else if (c1 == '=') {
*op= ((c == '<') ? OP_LE : OP_GE);
return(FPP_OK);
}
break;
case '|':
case '&':
if (c1 == c) {
*op= ((c == '|') ? OP_ORO : OP_ANA);
return(FPP_OK);
}
break;
case '\\':
if (c1 == '\n') { /* Multi-line if */
loop=TRUE;
break;
}
cerror(global, ERROR_ILLEGAL_BACKSLASH);
return(FPP_IF_ERROR);
}
if(!loop)
unget(global);
}
} while(loop);
*op=t;
return(FPP_OK);
}
#if OK_SIZEOF
INLINE FILE_LOCAL
ReturnCode dosizeof(struct Global *global, int *result)
{
/*
* Process the sizeof (basic type) operation in an #if string.
* Sets evalue to the size and returns
* DIG success
* OP_FAIL bad parse or something.
*/
int c;
TYPES *tp;
SIZES *sizp;
short *testp;
short typecode;
ReturnCode ret;
if ((c = skipws(global)) != '(') {
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
/*
* Scan off the tokens.
*/
typecode = 0;
while ((c = skipws(global))) {
if(ret=macroid(global, &c))
return(ret);
/* (I) return on fail! */
if (c == EOF_CHAR || c == '\n') {
/* End of line is a bug */
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
} else if (c == '(') { /* thing (*)() func ptr */
if (skipws(global) == '*'
&& skipws(global) == ')') { /* We found (*) */
if (skipws(global) != '(') /* Let () be optional */
unget(global);
else if (skipws(global) != ')') {
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
typecode |= T_FPTR; /* Function pointer */
} else { /* Junk is a bug */
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
}
else if (type[c] != LET) /* Exit if not a type */
break;
else if (!catenate(global, &ret) && !ret) { /* Maybe combine tokens */
/*
* Look for this unexpandable token in basic_types.
* The code accepts "int long" as well as "long int"
* which is a minor bug as bugs go (and one shared with
* a lot of C compilers).
*/
for (tp = basic_types; tp->name != NULLST; tp++) {
if (streq(global->tokenbuf, tp->name))
break;
}
if (tp->name == NULLST) {
cerror(global, ERROR_SIZEOF_UNKNOWN, global->tokenbuf);
return(FPP_SIZEOF_ERROR);
}
typecode |= tp->type; /* Or in the type bit */
} else if(ret)
return(ret);
}
/*
* We are at the end of the type scan. Chew off '*' if necessary.
*/
if (c == '*') {
typecode |= T_PTR;
c = skipws(global);
}
if (c == ')') { /* Last syntax check */
for (testp = test_table; *testp != 0; testp++) {
if (!bittest(typecode & *testp)) {
cerror(global, ERROR_SIZEOF_ILLEGAL_TYPE);
return(FPP_SIZEOF_ERROR);
}
}
/*
* We assume that all function pointers are the same size:
* sizeof (int (*)()) == sizeof (float (*)())
* We assume that signed and unsigned don't change the size:
* sizeof (signed int) == (sizeof unsigned int)
*/
if ((typecode & T_FPTR) != 0) /* Function pointer */
typecode = T_FPTR | T_PTR;
else { /* Var or var * datum */
typecode &= ~(T_SIGNED | T_UNSIGNED);
if ((typecode & (T_SHORT | T_LONG)) != 0)
typecode &= ~T_INT;
}
if ((typecode & ~T_PTR) == 0) {
cerror(global, ERROR_SIZEOF_NO_TYPE);
return(FPP_SIZEOF_ERROR);
}
/*
* Exactly one bit (and possibly T_PTR) may be set.
*/
for (sizp = size_table; sizp->bits != 0; sizp++) {
if ((typecode & ~T_PTR) == sizp->bits) {
global->evalue = ((typecode & T_PTR) != 0)
? sizp->psize : sizp->size;
*result=DIG;
return(FPP_OK);
}
} /* We shouldn't fail */
cerror(global, ERROR_SIZEOF_BUG, typecode);
return(FPP_SIZEOF_ERROR);
}
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
INLINE FILE_LOCAL
int bittest(int value)
{
/*
* TRUE if value is zero or exactly one bit is set in value.
*/
#if (4096 & ~(-4096)) == 0
return ((value & ~(-value)) == 0);
#else
/*
* Do it the hard way (for non 2's complement machines)
*/
return (value == 0 || value ^ (value - 1) == (value * 2 - 1));
#endif
}
#endif /* OK_SIZEOF */
INLINE FILE_LOCAL
int evalnum(struct Global *global, int c)
{
/*
* Expand number for #if lexical analysis. Note: evalnum recognizes
* the unsigned suffix, but only returns a signed int value.
*/
int value;
int base;
int c1;
if (c != '0')
base = 10;
else if ((c = cget(global)) == 'x' || c == 'X') {
base = 16;
c = cget(global);
}
else base = 8;
value = 0;
for (;;) {
c1 = c;
if (isascii(c) && isupper(c1))
c1 = tolower(c1);
if (c1 >= 'a')
c1 -= ('a' - 10);
else c1 -= '0';
if (c1 < 0 || c1 >= base)
break;
value *= base;
value += c1;
c = cget(global);
}
if (c == 'u' || c == 'U') /* Unsigned nonsense */
c = cget(global);
unget(global);
return (value);
}
INLINE FILE_LOCAL
int evalchar(struct Global *global,
int skip) /* TRUE if short-circuit evaluation */
/*
* Get a character constant
*/
{
int c;
int value;
int count;
global->instring = TRUE;
if ((c = cget(global)) == '\\') {
switch ((c = cget(global))) {
case 'a': /* New in Standard */
#if ('a' == '\a' || '\a' == ALERT)
value = ALERT; /* Use predefined value */
#else
value = '\a'; /* Use compiler's value */
#endif
break;
case 'b':
value = '\b';
break;
case 'f':
value = '\f';
break;
case 'n':
value = '\n';
break;
case 'r':
value = '\r';
break;
case 't':
value = '\t';
break;
case 'v': /* New in Standard */
#if ('v' == '\v' || '\v' == VT)
value = VT; /* Use predefined value */
#else
value = '\v'; /* Use compiler's value */
#endif
break;
case 'x': /* '\xFF' */
count = 3;
value = 0;
while ((((c = get(global)) >= '0' && c <= '9')
|| (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F'))
&& (--count >= 0)) {
value *= 16;
value += (c <= '9') ? (c - '0') : ((c & 0xF) + 9);
}
unget(global);
break;
default:
if (c >= '0' && c <= '7') {
count = 3;
value = 0;
while (c >= '0' && c <= '7' && --count >= 0) {
value *= 8;
value += (c - '0');
c = get(global);
}
unget(global);
} else
value = c;
break;
}
} else if (c == '\'')
value = 0;
else value = c;
/*
* We warn on multi-byte constants and try to hack
* (big|little)endian machines.
*/
#if BIG_ENDIAN
count = 0;
#endif
while ((c = get(global)) != '\'' && c != EOF_CHAR && c != '\n') {
if (!skip)
cwarn(global, WARN_MULTIBYTE_NOT_PORTABLE, c);
#if BIG_ENDIAN
count += BITS_CHAR;
value += (c << count);
#else
value <<= BITS_CHAR;
value += c;
#endif
}
global->instring = FALSE;
return (value);
}
INLINE FILE_LOCAL
int *evaleval(struct Global *global,
int *valp,
int op,
int skip) /* TRUE if short-circuit evaluation */
{
/*
* Apply the argument operator to the data on the value stack.
* One or two values are popped from the value stack and the result
* is pushed onto the value stack.
*
* OP_COL is a special case.
*
* evaleval() returns the new pointer to the top of the value stack.
*/
int v1, v2;
if (isbinary(op))
v2 = *--valp;
v1 = *--valp;
switch (op) {
case OP_EOE:
break;
case OP_ADD:
v1 += v2;
break;
case OP_SUB:
v1 -= v2;
break;
case OP_MUL:
v1 *= v2;
break;
case OP_DIV:
case OP_MOD:
if (v2 == 0) {
if (!skip) {
cwarn(global, WARN_DIVISION_BY_ZERO,
(op == OP_DIV) ? "divide" : "mod");
}
v1 = 0;
}
else if (op == OP_DIV)
v1 /= v2;
else
v1 %= v2;
break;
case OP_ASL:
v1 <<= v2;
break;
case OP_ASR:
v1 >>= v2;
break;
case OP_AND:
v1 &= v2;
break;
case OP_OR:
v1 |= v2;
break;
case OP_XOR:
v1 ^= v2;
break;
case OP_EQ:
v1 = (v1 == v2);
break;
case OP_NE:
v1 = (v1 != v2);
break;
case OP_LT:
v1 = (v1 < v2);
break;
case OP_LE:
v1 = (v1 <= v2);
break;
case OP_GE:
v1 = (v1 >= v2);
break;
case OP_GT:
v1 = (v1 > v2);
break;
case OP_ANA:
v1 = (v1 && v2);
break;
case OP_ORO:
v1 = (v1 || v2);
break;
case OP_COL:
/*
* v1 has the "true" value, v2 the "false" value.
* The top of the value stack has the test.
*/
v1 = (*--valp) ? v1 : v2;
break;
case OP_NEG:
v1 = (-v1);
break;
case OP_PLU:
break;
case OP_COM:
v1 = ~v1;
break;
case OP_NOT:
v1 = !v1;
break;
default:
cerror(global, ERROR_IF_OPERAND, op);
v1 = 0;
}
*valp++ = v1;
return (valp);
}

1141
3rdparty/fcpp/cpp6.c vendored Normal file

File diff suppressed because it is too large Load Diff

411
3rdparty/fcpp/cppadd.h vendored Normal file
View File

@@ -0,0 +1,411 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/cppadd.h,v $
* $Revision: 1.5 $
* $Date: 1994/01/24 09:38:12 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: cppadd.h,v $
* Revision 1.5 1994/01/24 09:38:12 start
* Added the 'rightconcat' in the global structure.
*
* Revision 1.4 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.3 1993/11/29 14:01:13 start
* New features added
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
/**********************************************************************
*
* cppadd.h
*
* Prototypes and structures added by Daniel Stenberg.
*
*******/
#include <stdarg.h>
#include "memory.h"
struct Global {
/*
* Commonly used global variables:
* line is the current input line number.
* wrongline is set in many places when the actual output
* line is out of sync with the numbering, e.g,
* when expanding a macro with an embedded newline.
*
* tokenbuf holds the last identifier scanned (which might
* be a candidate for macro expansion).
* errors is the running cpp error counter.
* infile is the head of a linked list of input files (extended by
* #include and macros being expanded). infile always points
* to the current file/macro. infile->parent to the includer,
* etc. infile->fd is NULL if this input stream is a macro.
*/
int line; /* Current line number */
int wrongline; /* Force #line to compiler */
char *tokenbuf; /* Buffer for current input token */
char *functionname; /* Buffer for current function */
int funcline; /* Line number of current function */
int tokenbsize; /* Allocated size of tokenbuf, */
/* not counting zero at end. */
int errors; /* cpp error counter */
FILEINFO *infile; /* Current input file */
#if DEBUG
int debug; /* TRUE if debugging now */
#endif
/*
* This counter is incremented when a macro expansion is initiated.
* If it exceeds a built-in value, the expansion stops -- this tests
* for a runaway condition:
* #define X Y
* #define Y X
* X
* This can be disabled by falsifying rec_recover. (Nothing does this
* currently: it is a hook for an eventual invocation flag.)
*/
int recursion; /* Infinite recursion counter */
int rec_recover; /* Unwind recursive macros */
/*
* instring is set TRUE when a string is scanned. It modifies the
* behavior of the "get next character" routine, causing all characters
* to be passed to the caller (except <DEF_MAGIC>). Note especially that
* comments and \<newline> are not removed from the source. (This
* prevents cpp output lines from being arbitrarily long).
*
* inmacro is set by #define -- it absorbs comments and converts
* form-feed and vertical-tab to space, but returns \<newline>
* to the caller. Strictly speaking, this is a bug as \<newline>
* shouldn't delimit tokens, but we'll worry about that some other
* time -- it is more important to prevent infinitly long output lines.
*
* instring and inmarcor are parameters to the get() routine which
* were made global for speed.
*/
int instring; /* TRUE if scanning string */
int inmacro; /* TRUE if #defining a macro */
/*
* work[] and workp are used to store one piece of text in a temporay
* buffer. To initialize storage, set workp = work. To store one
* character, call save(c); (This will fatally exit if there isn't
* room.) To terminate the string, call save(EOS). Note that
* the work buffer is used by several subroutines -- be sure your
* data won't be overwritten. The extra byte in the allocation is
* needed for string formal replacement.
*/
char work[NWORK + 1]; /* Work buffer */
char *workp; /* Work buffer pointer */
/*
* keepcomments is set TRUE by the -C option. If TRUE, comments
* are written directly to the output stream. This is needed if
* the output from cpp is to be passed to lint (which uses commands
* embedded in comments). cflag contains the permanent state of the
* -C flag. keepcomments is always falsified when processing #control
* commands and when compilation is supressed by a false #if
*
* If eflag is set, CPP returns "success" even if non-fatal errors
* were detected.
*
* If nflag is non-zero, no symbols are predefined except __LINE__.
* __FILE__, and __DATE__. If nflag > 1, absolutely no symbols
* are predefined.
*/
char keepcomments; /* Write out comments flag */
char cflag; /* -C option (keep comments) */
char eflag; /* -E option (never fail) */
char nflag; /* -N option (no predefines) */
char wflag; /* -W option (write #defines) */
/*
* ifstack[] holds information about nested #if's. It is always
* accessed via *ifptr. The information is as follows:
* WAS_COMPILING state of compiling flag at outer level.
* ELSE_SEEN set TRUE when #else seen to prevent 2nd #else.
* TRUE_SEEN set TRUE when #if or #elif succeeds
* ifstack[0] holds the compiling flag. It is TRUE if compilation
* is currently enabled. Note that this must be initialized TRUE.
*/
char ifstack[BLK_NEST]; /* #if information */
char *ifptr; /* -> current ifstack[] */
/*
* incdir[] stores the -i directories (and the system-specific
* #include <...> directories.
*/
char *incdir[NINCLUDE]; /* -i directories */
char **incend; /* -> free space in incdir[] */
/*
* include[] stores the -X and -x files.
*/
char *include[NINCLUDE];
char includeshow[NINCLUDE]; /* show it or not! */
char included;
/*
* This is the table used to predefine target machine and operating
* system designators. It may need hacking for specific circumstances.
* Note: it is not clear that this is part of the Ansi Standard.
* The -B option supresses preset definitions.
*/
char *preset[5]; /* names defined at cpp start */
/*
* The value of these predefined symbols must be recomputed whenever
* they are evaluated. The order must not be changed.
*/
char *magic[5]; /* Note: order is important */
/*
* This is the variable saying if Cpp should remove C++ style comments from
* the output. Default is... TRUE, yes, pronto, do it!!!
*/
char cplusplus;
char *sharpfilename;
/*
* parm[], parmp, and parlist[] are used to store #define() argument
* lists. nargs contains the actual number of parameters stored.
*/
char parm[NPARMWORK + 1]; /* define param work buffer */
char *parmp; /* Free space in parm */
char *parlist[LASTPARM]; /* -> start of each parameter */
int nargs; /* Parameters for this macro */
DEFBUF *macro; /* Catches start of infinite macro */
DEFBUF *symtab[SBSIZE]; /* Symbol table queue headers */
int evalue; /* Current value from evallex() */
char *(*input)(char *, int, void *); /* Input function */
char *first_file; /* Preprocessed file. */
void *userdata; /* Data sent to input function */
void (*output)(int, void *); /* output function */
void (*error)(void *, char *, va_list); /* error function */
char linelines;
char warnillegalcpp; /* warn for illegal preprocessor instructions? */
char outputLINE; /* output 'line' in #line instructions */
char showversion; /* display version */
char showincluded; /* display included files */
char showbalance; /* display paren balance */
char showspace; /* display all whitespaces as they are */
char comment; /* TRUE if a comment just has been written to output */
char *spacebuf; /* Buffer to store whitespaces in if -H */
long chpos; /* Number of whitespaces in buffer */
char nestcomments; /* Allow nested comments */
char warnnestcomments; /* Warn at nested comments */
char warnnoinclude; /* Warn at missing include file */
char outputfile; /* output the main file */
char out; /* should we output anything now? */
char rightconcat; /* should the right part of a concatenation be avaluated
before the concat (TRUE) or after (FALSE) */
char *initialfunc; /* file to include first in all functions */
char *excludedinit[20]; /* functions (names) excluded from the initfunc */
int excluded;
char outputfunctions; /* output all discovered functions to stderr! */
char webmode; /* WWW process mode */
};
typedef enum {
ERROR_STRING_MUST_BE_IF,
ERROR_STRING_MAY_NOT_FOLLOW_ELSE,
ERROR_ERROR,
ERROR_PREPROC_FAILURE,
ERROR_MISSING_ARGUMENT,
ERROR_INCLUDE_SYNTAX,
ERROR_DEFINE_SYNTAX,
ERROR_REDEFINE,
ERROR_ILLEGAL_UNDEF,
ERROR_RECURSIVE_MACRO,
ERROR_EOF_IN_ARGUMENT,
ERROR_MISPLACED_CONSTANT,
ERROR_IF_OVERFLOW,
ERROR_ILLEGAL_IF_LINE,
ERROR_OPERATOR,
ERROR_EXPR_OVERFLOW,
ERROR_UNBALANCED_PARENS,
ERROR_MISPLACED,
ERROR_STRING_IN_IF,
ERROR_DEFINED_SYNTAX,
ERROR_ILLEGAL_ASSIGN,
ERROR_ILLEGAL_BACKSLASH,
ERROR_SIZEOF_SYNTAX,
ERROR_SIZEOF_UNKNOWN,
ERROR_SIZEOF_ILLEGAL_TYPE,
ERROR_SIZEOF_NO_TYPE,
ERROR_UNTERMINATED_STRING,
ERROR_EOF_IN_COMMENT,
ERROR_IFDEF_DEPTH,
ERROR_ILLEGAL_CHARACTER,
ERROR_ILLEGAL_CHARACTER2,
ERROR_SIZEOF_BUG,
ERROR_IF_OPERAND,
ERROR_STRANG_CHARACTER,
ERROR_STRANG_CHARACTER2,
BORDER_ERROR_WARN, /* below this number: errors, above: warnings */
WARN_CONTROL_LINE_IN_MACRO,
WARN_ILLEGAL_COMMAND,
WARN_UNEXPECTED_TEXT_IGNORED,
WARN_TOO_FEW_VALUES_TO_SIZEOF,
WARN_TOO_MANY_VALUES_TO_SIZEOF,
WARN_NOT_DEFINED,
WARN_INTERNAL_ERROR,
WARN_MACRO_NEEDS_ARGUMENTS,
WARN_WRONG_NUMBER_ARGUMENTS,
WARN_DIVISION_BY_ZERO,
WARN_ILLEGAL_OCTAL,
WARN_MULTIBYTE_NOT_PORTABLE,
WARN_CANNOT_OPEN_INCLUDE,
WARN_BRACKET_DEPTH,
WARN_PAREN_DEPTH,
WARN_BRACE_DEPTH,
WARN_NESTED_COMMENT,
BORDER_WARN_FATAL, /* below this number: warnings, above: fatals */
FATAL_TOO_MANY_NESTINGS,
FATAL_FILENAME_BUFFER_OVERFLOW,
FATAL_TOO_MANY_INCLUDE_DIRS,
FATAL_TOO_MANY_INCLUDE_FILES,
FATAL_TOO_MANY_ARGUMENTS_MACRO,
FATAL_MACRO_AREA_OVERFLOW,
FATAL_ILLEGAL_MACRO,
FATAL_TOO_MANY_ARGUMENTS_EXPANSION,
FATAL_OUT_OF_SPACE_IN_ARGUMENT,
FATAL_WORK_AREA_OVERFLOW,
FATAL_WORK_BUFFER_OVERFLOW,
FATAL_OUT_OF_MEMORY,
FATAL_TOO_MUCH_PUSHBACK
} ErrorCode;
/**********************************************************************
* RETURN CODES:
*********************************************************************/
typedef enum {
FPP_OK,
FPP_OUT_OF_MEMORY,
FPP_TOO_MANY_NESTED_STATEMENTS,
FPP_FILENAME_BUFFER_OVERFLOW,
FPP_NO_INCLUDE,
FPP_OPEN_ERROR,
FPP_TOO_MANY_ARGUMENTS,
FPP_WORK_AREA_OVERFLOW,
FPP_ILLEGAL_MACRO,
FPP_EOF_IN_MACRO,
FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION,
FPP_ILLEGAL_CHARACTER,
FPP_CANT_USE_STRING_IN_IF,
FPP_BAD_IF_DEFINED_SYNTAX,
FPP_IF_ERROR,
FPP_SIZEOF_ERROR,
FPP_UNTERMINATED_STRING,
FPP_TOO_MANY_INCLUDE_DIRS,
FPP_TOO_MANY_INCLUDE_FILES,
FPP_INTERNAL_ERROR,
FPP_LAST_ERROR
} ReturnCode;
/* Nasty defines to make them appear as three different functions! */
#define cwarn cerror
#define cfatal cerror
/**********************************************************************
* PROTOTYPES:
*********************************************************************/
int PREFIX fppPreProcess(REG(a0) struct fppTag *);
void Freemem(void *);
void Error(struct Global *, char *, ...);
void Putchar(struct Global *, int);
void Putstring(struct Global *, char *);
void Putint(struct Global *, int);
char *savestring(struct Global *, char *);
ReturnCode addfile(struct Global *, FILE *, char *);
int catenate(struct Global *, ReturnCode *);
void cerror(struct Global *, ErrorCode, ...);
ReturnCode control(struct Global *, int *);
ReturnCode dodefine(struct Global *);
int dooptions(struct Global *, struct fppTag *);
void doundef(struct Global *);
void dumpparm(char *);
ReturnCode expand(struct Global *, DEFBUF *);
int get(struct Global *);
ReturnCode initdefines(struct Global *);
void outdefines(struct Global *);
ReturnCode save(struct Global *, int);
void scanid(struct Global *, int);
ReturnCode scannumber(struct Global *, int, ReturnCode(*)(struct Global *, int));
ReturnCode scanstring(struct Global *, int, ReturnCode(*)(struct Global *, int));
void unget(struct Global *);
ReturnCode ungetstring(struct Global *, char *);
ReturnCode eval(struct Global *, int *);
#ifdef DEBUG_EVAL
void dumpstack(OPTAB[NEXP], register OPTAB *, int [NEXP], register int *);
#endif
void skipnl(struct Global *);
int skipws(struct Global *);
ReturnCode macroid(struct Global *, int *);
ReturnCode getfile(struct Global *, int, char *, FILEINFO **);
DEFBUF *lookid(struct Global *, int );
DEFBUF *defendel(struct Global *, char *, int);
#if DEBUG
void dumpdef(char *);
void dumpadef(char *, register DEFBUF *);
#endif
ReturnCode openfile(struct Global *,char *);
int cget(struct Global *);
void deldefines(struct Global *);
char *Getmem(struct Global *, int);
ReturnCode openinclude(struct Global *, char *, int);
ReturnCode expstuff(struct Global *, char *, char *);

383
3rdparty/fcpp/cppdef.h vendored Normal file
View File

@@ -0,0 +1,383 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/cppdef.h,v $
* $Revision: 1.4 $
* $Date: 1993/12/06 13:51:20 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: cppdef.h,v $
* Revision 1.4 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.3 1993/11/29 14:01:13 start
* New features added
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
#ifdef EMACS
/* Use the Emacs config file to find out what type of machine */
#define NO_SHORTNAMES
/* Convert Emacs's conventions for BIG_ENDIAN to cpp's convention. */
#ifdef BIG_ENDIAN
#undef BIG_ENDIAN
#define BIG_ENDIAN TRUE
#else /* not BIG_ENDIAN */
#define BIG_ENDIAN FALSE
#endif /* BIG_ENDIAN */
/* Emacs uses the names index and rindex and defines them as str(r)chr if nec;
cpp uses the opposite convention. Here we flush the macro definitions for
Emacs and add the ones cpp wants. */
#ifdef index
#undef index
#undef rindex
#else /* index is not defined as a macro */
#define strchr index
#define strrchr rindex
#endif /* index is not defined as a macro */
#define NBUFF 2048
#define NWORK 2048
#endif /* EMACS */
/*
* S y s t e m D e p e n d e n t
* D e f i n i t i o n s f o r C P P
*
* Definitions in this file may be edited to configure CPP for particular
* host operating systems and target configurations.
*
* NOTE: cpp assumes it is compiled by a compiler that supports macros
* with arguments. If this is not the case (as for Decus C), #define
* nomacarg -- and provide function equivalents for all macros.
*
* cpp also assumes the host and target implement the Ascii character set.
* If this is not the case, you will have to do some editing here and there.
*/
/*
* This redundant definition of TRUE and FALSE works around
* a limitation of Decus C.
*/
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
/*
* Define the HOST operating system. This is needed so that
* cpp can use appropriate filename conventions.
*/
#define SYS_UNKNOWN 0
#define SYS_UNIX 1
#define SYS_VMS 2
#define SYS_RSX 3
#define SYS_RT11 4
#define SYS_LATTICE 5
#define SYS_ONYX 6
#define SYS_68000 7
#define SYS_AMIGADOS 8
#ifndef HOST
#ifdef unix
#define HOST SYS_UNIX
#else
#ifdef amiga
#define HOST SYS_AMIGADOS
#endif
#endif
#endif
/*
* We assume that the target is the same as the host system
*/
#ifndef TARGET
#define TARGET HOST
#endif
/*
* In order to predefine machine-dependent constants,
* several strings are defined here:
*
* MACHINE defines the target cpu (by name)
* SYSTEM defines the target operating system
* COMPILER defines the target compiler
*
* The above may be #defined as "" if they are not wanted.
* They should not be #defined as NULL.
*
* LINE_PREFIX defines the # output line prefix, if not "line"
* This should be defined as "" if cpp is to replace
* the "standard" C pre-processor.
*/
#define LINE_PREFIX "line"
/*
* FILE_LOCAL marks functions which are referenced only in the
* file they reside. Some C compilers allow these
* to be marked "static" even though they are referenced
* by "extern" statements elsewhere.
*
* OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character
* in identifiers (default), or zero if $ is invalid.
* Default is TRUE.
*
* OK_CONCAT Should be set TRUE if # may be used to concatenate
* tokens in macros (per the Ansi Draft Standard) or
* FALSE for old-style # processing (needed if cpp is
* to process assembler source code).
*/
#define OK_CONCAT TRUE
/*
* OK_DATE Predefines the compilation date if set TRUE.
* Not permitted by the Nov. 12, 1984 Draft Standard.
*/
#define OK_DATE TRUE
/*
*
* OK_SIZEOF Permits sizeof in #if preprocessor expressions.
* According to K&R V2 (page 232), this is not allowed.
*/
#define OK_SIZEOF TRUE
/*
* S_CHAR etc. Define the sizeof the basic TARGET machine word types.
* By default, sizes are set to the values for the HOST
* computer. If this is inappropriate, see the code in
* cpp3.c for details on what to change. Also, if you
* have a machine where sizeof (signed int) differs from
* sizeof (unsigned int), you will have to edit code and
* tables in cpp3.c (and extend the -S option definition.)
*
* CPP_LIBRARY May be defined if you have a site-specific include directory
* which is to be searched *before* the operating-system
* specific directories.
*/
#define MACHINE "amiga", "m68000"
#define SYSTEM "amigados"
/*
* defaults
*/
#ifndef MSG_PREFIX
#define MSG_PREFIX "cpp: "
#endif
/*
* OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT,
* COMMENT_INVISIBLE to values appropriate for
* an old-style preprocessor.
*/
#if OLD_PREPROCESSOR
#define OK_DOLLAR FALSE
#define OK_CONCAT FALSE
#define COMMENT_INVISIBLE TRUE
#endif
/*
* RECURSION_LIMIT may be set to -1 to disable the macro recursion test.
*/
#ifndef RECURSION_LIMIT
#define RECURSION_LIMIT 1000
#endif
/*
* BITS_CHAR may be defined to set the number of bits per character.
* it is needed only for multi-byte character constants.
*/
#ifndef BITS_CHAR
#define BITS_CHAR 8
#endif
/*
* BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series)
* where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
* It is set FALSE on machines (such as the PDP-11 and Vax-11)
* where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
* (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
* [I *seems* to be the other way around, according to the code /OIS]
*/
#ifndef BIG_ENDIAN
#define BIG_ENDIAN FALSE
#endif
/*
* COMMENT_INVISIBLE may be defined to allow "old-style" comment
* processing, whereby the comment becomes a zero-length token
* delimiter. This permitted tokens to be concatenated in macro
* expansions. This was removed from the Draft Ansi Standard.
*/
#ifndef COMMENT_INVISIBLE
#define COMMENT_INVISIBLE FALSE
#endif
/*
* OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
* This is a permitted extension to the Ansi Standard and is required
* for e.g., VMS, RSX-11M, etc. It should be set FALSE if cpp is
* used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR
* sets OK_DOLLAR FALSE for that reason.
*/
#ifndef OK_DOLLAR
#define OK_DOLLAR TRUE
#endif
/*
* OK_CONCAT enables (one possible implementation of) token concatenation.
* If cpp is used to preprocess Unix assembler source, this should be
* set FALSE as the concatenation character, #, is used by the assembler.
*/
#ifndef OK_CONCAT
#define OK_CONCAT TRUE
#endif
/*
* OK_DATE may be enabled to predefine today's date as a string
* at the start of each compilation. This is apparently not permitted
* by the Draft Ansi Standard.
*/
#ifndef OK_DATE
#define OK_DATE TRUE
#endif
/*
* OK_SIZEOF may be defined to allow sizeof(type) in #if expressions.
* Actually, it is none of the preprocessors business how large these
* things are, as they might be different with different compiler
* options. Also, according to K&R V2, page 232, it is nonstandard.
* This option was added in the PDC process, under no. *OIS*0.92*.
*/
#ifndef OK_SIZEOF
#define OK_SIZEOF FALSE
#endif
/*
* Some common definitions.
*/
#ifndef DEBUG
#define DEBUG FALSE
#endif
/*
* The following definitions are used to allocate memory for
* work buffers. In general, they should not be modified
* by implementors.
*
* PAR_MAC The maximum number of #define parameters (31 per Standard)
* Note: we need another one for strings.
* NBUFF Input buffer size
* NWORK Work buffer size -- the longest macro
* must fit here after expansion.
* NEXP The nesting depth of #if expressions
* NINCLUDE The number of directories that may be specified
* on a per-system basis, or by the -I option.
* BLK_NEST The number of nested #if's permitted.
*/
#ifndef PAR_MAC
#define PAR_MAC (31 + 1)
#endif
#ifndef NBUFF
#define NBUFF 512
#endif
#ifndef NWORK
#define NWORK 512
#endif
#ifndef NEXP
#define NEXP 128
#endif
#ifndef NINCLUDE
#define NINCLUDE 20
#endif
#ifndef NPARMWORK
#define NPARMWORK (NWORK * 2)
#endif
#ifndef BLK_NEST
#define BLK_NEST 32
#endif
/*
* Some special constants. These may need to be changed if cpp
* is ported to a wierd machine.
*
* NOTE: if cpp is run on a non-ascii machine, ALERT and VT may
* need to be changed. They are used to implement the proposed
* ANSI standard C control characters '\a' and '\v' only.
* DEL is used to tag macro tokens to prevent #define foo foo
* from looping. Note that we don't try to prevent more elaborate
* #define loops from occurring.
*/
#ifndef ALERT
#define ALERT '\007' /* '\a' is "Bell" */
#endif
#ifndef VT
#define VT '\013' /* Vertical Tab CTRL/K */
#endif
/*
* Functions can be declared/defined static to only become in the
* scope for functions of the same source file.
*/
#ifndef FILE_LOCAL
#define FILE_LOCAL static /* file-unique globals */
#endif
/*
* For compilers supporting inlining, the INLINE macro has been added to
* functions called from only one place. There might still be some
* functions that should have this macro.
*/
#ifdef AMIGA
#define INLINE __inline /* Amiga compiler SAS/C 6.x supports this! */
#else
#define INLINE /* don't support that kind of stuff */
#endif
#if defined(AMIGA) && defined(SHARED)
#define PREFIX __asm __saveds
#define REG(x) register __ ## x
#else
#define PREFIX
#define REG(x)
#endif
/*
* SBSIZE defines the number of hash-table slots for the symbol table.
*/
#ifndef SBSIZE
#define SBSIZE 64
#endif
#define VERSION_TEXT "Frexx C Preprocessor v1.5.1 " \
"Copyright (C) by FrexxWare 1993 - 2002.\n" \
"Compiled " __DATE__ "\n"

2
3rdparty/fcpp/fpp.exp vendored Normal file
View File

@@ -0,0 +1,2 @@
#!
fppPreProcess

4
3rdparty/fcpp/fpp.fd vendored Normal file
View File

@@ -0,0 +1,4 @@
##base _FPPBase
##bias 30
fppPreProcess(a)(A0)
##end

159
3rdparty/fcpp/fpp.h vendored Normal file
View File

@@ -0,0 +1,159 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/fpp.h,v $
* $Revision: 1.5 $
* $Date: 1994/01/24 09:38:45 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: fpp.h,v $
* Revision 1.5 1994/01/24 09:38:45 start
* Added FPPTAG_RIGHTCONCAT.
*
* Revision 1.4 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.3 1993/11/29 14:01:13 start
* New features added
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
/**********************************************************************
*
* fpp.h
*
*/
struct fppTag {
int tag;
void *data;
};
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define NFLAG_BUILTIN 1
#define NFLAG_PREDEFINE 2
/* end of taglist: */
#define FPPTAG_END 0
/* To make the preprocessed output keep the comments: */
#define FPPTAG_KEEPCOMMENTS 1 /* data is TRUE or FALSE */
/* To define symbols to the preprocessor: */
#define FPPTAG_DEFINE 2 /* data is the string "symbol" or "symbol=<value>" */
/* To make the preprocessor ignore all non-fatal errors: */
#define FPPTAG_IGNORE_NONFATAL 3 /* data is TRUE or FALSE */
/* To add an include directory to the include directory list: */
#define FPPTAG_INCLUDE_DIR 4 /* data is directory name ending with a '/' (on
amiga a ':' is also valid) */
/* To define all machine specific built-in #defines, default is TRUE: */
#define FPPTAG_BUILTINS 5 /* data is TRUE or FALSE */
/* To define predefines like __LINE__, __DATE__, etc. default is TRUE: */
#define FPPTAG_PREDEFINES 6 /* data is TRUE or FALSE */
/* To make fpp leave C++ comments in the output: */
#define FPPTAG_IGNORE_CPLUSPLUS 7 /* data is TRUE or FALSE */
/* To define new sizes to #if sizeof: */
#define FPPTAG_SIZEOF_TABLE 8 /* data is sizeof table string */
/* To undefine symbols: */
#define FPPTAG_UNDEFINE 9 /* data is symbol name */
/* Output all #defines: */
#define FPPTAG_OUTPUT_DEFINES 10 /* data is TRUE or FALSE */
/* Initial input file name: */
#define FPPTAG_INPUT_NAME 11 /* data is string */
/* Input function: */
#define FPPTAG_INPUT 12 /* data is an input funtion */
/* Output function: */
#define FPPTAG_OUTPUT 13 /* data is an output function */
/* User data, sent in the last argument to the input function: */
#define FPPTAG_USERDATA 14 /* data is user data */
/* Whether to exclude #line instructions in the output, default is FALSE */
#define FPPTAG_LINE 15 /* data is TRUE or FALSE */
/* Error function. This is called when FPP finds any warning/error/fatal: */
#define FPPTAG_ERROR 16 /* data is function pointer to a
"void (*)(void *, char *, va_list)" */
/* Whether to warn for illegal cpp instructions */
#define FPPTAG_WARNILLEGALCPP 17 /* data is boolean, default is FALSE */
/* Output the 'line' keyword on #line-lines? */
#define FPPTAG_OUTPUTLINE 18 /* data is boolean, default is TRUE */
/* Do not output the version information string */
#define FPPTAG_IGNOREVERSION 19 /* data is boolean, default is FALSE */
/* Output all included file names to stderr */
#define FPPTAG_OUTPUTINCLUDES 20 /* data is boolean, default is FALSE */
/* Display warning if there is any brace, bracket or parentheses unbalance */
#define FPPTAG_OUTPUTBALANCE 21 /* data is boolean, default is FALSE */
/* Display all whitespaces in the source */
#define FPPTAG_OUTPUTSPACE 22 /* data is boolean, default is FALSE */
/* Allow nested comments */
#define FPPTAG_NESTED_COMMENTS 23 /* data is boolean, default is FALSE */
/* Enable warnings at nested comments */
#define FPPTAG_WARN_NESTED_COMMENTS 24 /* data is boolean, default is FALSE */
/* Enable warnings at missing includes */
#define FPPTAG_WARNMISSINCLUDE 25 /* data is boolean, default is TRUE */
/* Output the main file */
#define FPPTAG_OUTPUTMAIN 26 /* data is boolean, default is TRUE */
/* Include file */
#define FPPTAG_INCLUDE_FILE 27 /* data is char pointer */
/* Include macro file */
#define FPPTAG_INCLUDE_MACRO_FILE 28 /* data is char pointer */
/* Evaluate the right part of a concatenate before the concat */
#define FPPTAG_RIGHTCONCAT 29 /* data is boolean, default is FALSE */
/* Include the specified file at the beginning of each function */
#define FPPTAG_INITFUNC 30 /* data is char pointer or NULL */
/* Define function to be excluded from the "beginning-function-addings" */
#define FPPTAG_EXCLFUNC 31 /* data is char pointer */
/* Enable output of all function names defined in the source */
#define FPPTAG_DISPLAYFUNCTIONS 32
/* Switch on WWW-mode */
#define FPPTAG_WEBMODE 33
int fppPreProcess(struct fppTag *);

20
3rdparty/fcpp/fpp_pragmas.h vendored Normal file
View File

@@ -0,0 +1,20 @@
#ifdef RCS
static char rcsid[]="$Id$";
#endif
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source$
* $Revision$
* $Date$
* $Author$
* $State$
* $Locker$
*
* ----------------------------------------------------------------------------
* $Log$
*
*****************************************************************************/
#pragma libcall FPPBase fppPreProcess 1E 801

86
3rdparty/fcpp/makefile vendored Normal file
View File

@@ -0,0 +1,86 @@
##############################################################################
## FREXXWARE
##############################################################################
##
## Project: Frexx C Preprocessor
## $Source: /home/user/start/cpp/RCS/makefile,v $
## $Revision: 1.3 $
## $Date: 1994/06/02 09:11:24 $
## $Author: start $
## $State: Exp $
## $Locker: $
##
##############################################################################
## $Log: makefile,v $
# Revision 1.3 1994/06/02 09:11:24 start
# Now uses 'gcc' and -O!
#
# Revision 1.2 1993/11/11 07:16:39 start
# New stuff
#
# Revision 1.1 1993/11/03 09:19:28 start
# Initial revision
#
##
##############################################################################
# Frexx PreProcessor Makefile
#HOST =-tp -B/home/danne/code/cpp/ -Wp\,-Q\,-Dunix\,-Ddpc\,-DAIX
#DEFINES = -Dunix -Dpdc -DAIX -DUNIX -DDEBUG
DEFINES = -Dunix -Dpdc -DUNIX -DDEBUG
DEBUGFLAG = -g
LD = ld
LDFLAGS =
LIB = libfpp.a
CPP = fpp
FILECPP = fcpp
TEMP = templib.o
EXPORT = fpp.exp
CC = gcc
CFLAGS = $(DEBUGFLAG) $(DEFINES)
AR = ar
ARFLAGS = rv
.SUFFIXES: .o .c .c~ .h .h~ .a .i
OBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
FILEOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o usecpp.o
# ** compile cpp
#
#all: $(LIB) $(CPP)
all: $(FILECPP)
$(LIB) : $(OBJS) $(EXPORT)
$(LD) $(OBJS) -o $(TEMP) -bE:$(EXPORT) -bM:SRE -T512 -H512 -lc
rm -f $(LIB)
$(AR) $(ARFLAGS) $(LIB) $(TEMP)
rm $(TEMP)
$(CPP) : usecpp.c
$(CC) $(CFLAGS) -o $(CPP) usecpp.c -L. -lfpp
$(FILECPP) : $(FILEOBJS)
$(CC) $(FILEOBJS) -o $(FILECPP)
.c.o:
$(CC) $(CFLAGS) -c $<
cpp1.o:cpp1.c
cpp2.o:cpp2.c
cpp3.o:cpp3.c
cpp4.o:cpp4.c
cpp5.o:cpp5.c
cpp6.o:cpp6.c
memory.o:memory.c
usecpp.o:usecpp.c
clean :
rm -f *.o $(FILECPP)
tgz:
rm -f makefile*~
(dir=`pwd`;name=`basename $$dir`;echo Creates $$name.tar.gz; cd .. ; \
tar -cf $$name.tar `ls $$name/*.[ch] $$name/*.exp $$name/*.fd $$name/makefile*` ; \
gzip $$name.tar ; chmod a+r $$name.tar.gz ; mv $$name.tar.gz $$name/)

602
3rdparty/fcpp/usecpp.c vendored Normal file
View File

@@ -0,0 +1,602 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/usecpp.c,v $
* $Revision: 1.6 $
* $Date: 1994/06/02 09:11:01 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: usecpp.c,v $
* Revision 1.6 1994/06/02 09:11:01 start
* Added the '-n' option!
*
* Revision 1.5 1994/06/02 08:51:49 start
* Added three more command line parameters
* Made -h invokes exit nice
*
* Revision 1.4 1994/01/24 09:37:17 start
* Major difference.
*
* Revision 1.3 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:13:08 start
* Initial revision
*
*
*****************************************************************************/
/**********************************************************************
*
* usecpp.c
*
* This is a routine that is should be used to call functions in the
* fpp.library. We supply the own_input() and own_output() functions to
* the preprocessor to remain flexible.
*/
#include <stdlib.h>
#ifdef AMIGA
#include <proto/exec.h>
#include <exec/types.h>
#if defined(SHARED)
#include <exec/libraries.h>
#include <libraries/dos.h>
#include "fpp_pragmas.h"
#include "fpp_protos.h"
#include "FPPBase.h"
struct Library *FPPBase=NULL;
#define PREFIX __saveds
#define REG(x) register __ ## x
#else
#define PREFIX
#define REG(x)
#endif
#elif defined(UNIX)
#if defined(OS9)
#include <types.h>
#else
#include <sys/types.h>
#ifdef BSD
#include <sys/unistd.h> /* for BSD systems (SUN OS at least) */
#endif
#endif
#define PREFIX
#define REG(x)
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#ifndef OS9
#include <stdarg.h>
#else
#define va_list void *
#endif
#include "fpp.h"
#define MAX_TAGS 40 /* maximum number of tags allowed! */
#define FILE_LOCAL static
#define CPP_PREFS_FILE "cpp.prefs"
#ifdef AMIGA
#define DEFAULT_CPP_PREFS_FILE "s:cpp.prefs"
#else
#define DEFAULT_CPP_PREFS_FILE "$HOME/cpp.prefs"
#endif
FILE_LOCAL char PREFIX *own_input(char *, int, void *);
FILE_LOCAL void PREFIX own_output(int, void *);
FILE_LOCAL void PREFIX own_error(void *, char *, va_list);
FILE_LOCAL int SetOptions(int, char **, struct fppTag **);
FILE_LOCAL char GetPrefs(struct fppTag **, char **);
FILE_LOCAL char DoString(struct fppTag **, char *);
#ifdef AMIGA
extern long __stack=8000;
#endif
FILE_LOCAL char ignore=FALSE; /* if we should ignore strange flags! */
FILE_LOCAL char display=FALSE; /* display all options in use! */
FILE_LOCAL char dontreadprefs; /* set if only the command line is valid */
int main(int argc, char **argv)
{
struct fppTag tags[MAX_TAGS];
int i;
struct fppTag *tagptr = tags;
char *dealloc;
/*
* Append system-specific directories to the include directory list.
* The include directories will be searched through in the same order
* as you add them in the taglist!
* The directory _must_ end with a proper directory speparator!
*/
tagptr->tag=FPPTAG_INCLUDE_DIR;
#if defined (AMIGA)
tagptr->data = "INCLUDE:";
#elif defined (OS9)
tagptr->data = "/dd/defs/";
#else
tagptr->data = "/usr/include/";
#endif
tagptr++;
if(GetPrefs(&tagptr, &dealloc))
return(0);
if( !(i = SetOptions(argc, argv, &tagptr)))
return(0);
if (argc - i >2) {
printf("Too many file arguments. Usage: cpp [options] [input [output]]\n");
return(-1);
}
tagptr->tag=FPPTAG_INPUT;
tagptr->data=(void *)own_input;
tagptr++;
if(i<argc) {
/*
* Open input file, "-" means use stdin.
*/
if (strcmp(argv[i], "-")) {
if (freopen(argv[i], "r", stdin) == NULL) {
perror(argv[i]);
fprintf(stderr, "Can't open input file \"%s\"", argv[i]);
return(-2);
}
tagptr->tag=FPPTAG_INPUT_NAME;
tagptr->data=argv[i];
tagptr++;
if(display)
fprintf(stderr, "cpp: input: %s\n", argv[i]);
} else /* Else, just get stdin */
if(display)
fprintf(stderr, "cpp: input: [stdin]\n");
i++;
} else
if(display)
fprintf(stderr, "cpp: input: [stdin]\n");
if(i<argc) {
/*
* Get output file, "-" means use stdout.
*/
if (strcmp(argv[i], "-")) {
if (freopen(argv[i], "w", stdout) == NULL) {
perror(argv[i]);
fprintf(stderr, "Can't open output file \"%s\"", argv[i]);
return(-1);
}
if(display)
fprintf(stderr, "cpp: output: %s\n", argv[i]);
} else
if(display)
fprintf(stderr, "cpp: output: [stdout]\n");
} else
if(display)
fprintf(stderr, "cpp: output: [stdout]\n");
tagptr->tag=FPPTAG_OUTPUT;
tagptr->data=(void *)own_output;
tagptr++;
tagptr->tag=FPPTAG_ERROR;
tagptr->data=(void *)own_error;
tagptr++;
/* The LAST tag: */
tagptr->tag=FPPTAG_END;
tagptr->data=0;
tagptr++;
#if defined(SHARED) && defined(AMIGA)
if(!(FPPBase=OpenLibrary(FPPNAME, 1))) {
printf("Error opening %s!\n", FPPNAME);
return(-1);
}
#endif
fppPreProcess(tags);
#if defined(SHARED) && defined(AMIGA)
CloseLibrary((struct Library *)FPPBase);
#endif
/*
* Preprocess ready!
*/
if( dealloc )
free( dealloc );
return(0);
}
FILE_LOCAL
char PREFIX *own_input(char *buffer, int size, void *userdata)
{
return(fgets(buffer, size, stdin));
}
FILE_LOCAL
void PREFIX own_output(int c, void *userdata)
{
putchar(c);
}
FILE_LOCAL
void PREFIX own_error(void *userdata, char *format, va_list arg)
{
vfprintf(stderr, format, arg);
}
FILE_LOCAL
char GetPrefs(struct fppTag **tagptr, char **string)
{
FILE *PrefsFile_PF;
unsigned Length_U;
char *PrefsBuffer_PC;
char ret= 0;
char *environ;
*string = NULL;
/* Open prefs file for read */
if ( (PrefsFile_PF = fopen(CPP_PREFS_FILE, "r")) ||
(PrefsFile_PF = fopen(DEFAULT_CPP_PREFS_FILE, "r"))) {
fseek(PrefsFile_PF, 0 , SEEK_END);
Length_U = ftell(PrefsFile_PF);
fseek(PrefsFile_PF, 0, SEEK_SET);
if (*string = (char *)malloc(Length_U+1)) {
fread(*string, 1, Length_U, PrefsFile_PF);
(*string)[Length_U] = '\0';
ret = !DoString(tagptr, *string);
}
fclose(PrefsFile_PF);
if(ret) {
free( *string );
return ret;
}
}
if(environ = getenv("CPP_PREFS")) {
ret= !DoString(tagptr, environ);
if(ret && *string)
free( *string );
}
return ret;
}
FILE_LOCAL
char DoString(struct fppTag **tagptr, char *string)
{
char *argv[MAX_TAGS];
int argc=1;
do {
while(*string && *string != '-')
string++;
if(!*string)
break;
argv[argc]=string;
do {
string++;
if(*string=='\"') {
do
string++;
while(*string != '\"');
string++;
}
} while(*string && *string!=' ' && *string != '\n' && *string != '\t');
argc++;
if(*string) {
*string='\0';
string++;
} else
break;
} while(1);
return (SetOptions(argc, argv, tagptr));
}
FILE_LOCAL
int SetOptions(int argc, char **argv, struct fppTag **tagptr)
{
int i;
char *ap;
for (i = 1; i < argc; i++) {
ap = argv[i];
if (*ap++ != '-' || *ap == '\0')
break;
else {
char c = *ap++;
if(display)
fprintf(stderr, "cpp: option: %s\n", ap-2);
switch (c) { /* Command character */
case 'Q': /* ignore unknown flags but */
ignore=1; /* output them on stderr */
break;
case 'q': /* ignore unknown flags */
ignore=2;
break;
case 'H': /* display all whitespaces */
(*tagptr)->tag = FPPTAG_OUTPUTSPACE;
(*tagptr)->data= (void *)TRUE;
(*tagptr)++;
break;
case 'b': /* display unbalance */
(*tagptr)->tag = FPPTAG_OUTPUTBALANCE;
(*tagptr)->data= (void *)TRUE;
(*tagptr)++;
break;
case 'f': /* output all defined functions! */
(*tagptr)->tag = FPPTAG_DISPLAYFUNCTIONS;
(*tagptr)->data= (void *)TRUE;
(*tagptr)++;
break;
case 'F': /* output all included files! */
(*tagptr)->tag = FPPTAG_OUTPUTINCLUDES;
(*tagptr)->data= (void *)TRUE;
(*tagptr)++;
break;
case 'V': /* do not output version */
(*tagptr)->tag = FPPTAG_IGNOREVERSION;
(*tagptr)->data= (void *)FALSE;
(*tagptr)++;
break;
case 'C': /* Keep comments */
(*tagptr)->tag = FPPTAG_KEEPCOMMENTS;
(*tagptr)->data= (void *)TRUE;
(*tagptr)++;
break;
case 'D': /* Define symbol */
(*tagptr)->tag=FPPTAG_DEFINE;
(*tagptr)->data=argv[i]+2;
(*tagptr)++;
break;
case 'd': /* Display all options */
fprintf(stderr, "FOUND -d flag!\n");
display = TRUE;
break;
case 'E': /* Ignore non-fatal errors */
(*tagptr)->tag=FPPTAG_IGNORE_NONFATAL;
(*tagptr)->data=(void *)TRUE;
(*tagptr)++;
break;
case 'I': /* Include directory */
(*tagptr)->tag=FPPTAG_INCLUDE_DIR;
(*tagptr)->data=ap;
(*tagptr)++;
break;
case 'J': /* Allow nested comments */
(*tagptr)->tag=FPPTAG_NESTED_COMMENTS;
(*tagptr)->data=ap;
(*tagptr)++;
break;
case 'j': /* Warn at nested comments */
(*tagptr)->tag=FPPTAG_WARN_NESTED_COMMENTS;
(*tagptr)->data=ap;
(*tagptr)++;
break;
case 'L':
if(*ap == 'L') { /* Do not output #line */
(*tagptr)->tag=FPPTAG_LINE;
} else {
/* Do not output the 'line' keyword */
(*tagptr)->tag=FPPTAG_OUTPUTLINE;
}
(*tagptr)->data=(void *)FALSE;
(*tagptr)++;
break;
case 'M': /* Do not warn at missing includes */
(*tagptr)->tag=FPPTAG_WARNMISSINCLUDE;
(*tagptr)->data=(void *)FALSE;
(*tagptr)++;
break;
case 'n':
dontreadprefs^=1; /* toggle prefsreading, default is read prefs */
/*
* This flag should reset all previously added tags!
*/
break;
case 'N': /* No machine specific built-ins */
(*tagptr)->tag=FPPTAG_BUILTINS;
(*tagptr)->data=(void *)FALSE;
(*tagptr)++;
break;
case 'B': /* No predefines like __LINE__, etc. */
(*tagptr)->tag=FPPTAG_PREDEFINES;
(*tagptr)->data=(void *)FALSE;
(*tagptr)++;
break;
case 'P': /* No C++ comments */
(*tagptr)->tag=FPPTAG_IGNORE_CPLUSPLUS;
(*tagptr)->data=(void *)TRUE;
(*tagptr)++;
break;
case 'p': /* warn about illegal # - instructions */
(*tagptr)->tag = FPPTAG_WARNILLEGALCPP;
(*tagptr)->data= (void *)TRUE;
(*tagptr)++;
break;
case 'R':
(*tagptr)->tag = FPPTAG_RIGHTCONCAT;
(*tagptr)->data= (void *)TRUE;
(*tagptr)++;
break;
case 's': /* sizeof table */
(*tagptr)->tag=FPPTAG_INITFUNC;
(*tagptr)->data=ap;
(*tagptr)++;
break;
case 't': /* excluded functions */
(*tagptr)->tag=FPPTAG_EXCLFUNC;
(*tagptr)->data=ap;
(*tagptr)++;
break;
case 'S': /* sizeof table */
(*tagptr)->tag=FPPTAG_SIZEOF_TABLE;
(*tagptr)->data=ap;
(*tagptr)++;
break;
case 'U': /* Undefine symbol */
(*tagptr)->tag=FPPTAG_UNDEFINE;
(*tagptr)->data=ap;
(*tagptr)++;
break;
case 'w': /* Output all #defines but not the
main file */
(*tagptr)->tag=FPPTAG_OUTPUTMAIN;
(*tagptr)->data=(void *)FALSE;
(*tagptr)++;
case 'W': /* Output all #defines */
if(!strncmp(ap, "WW", 2)) {
(*tagptr)->tag=FPPTAG_WEBMODE;
(*tagptr)->data=(void *)TRUE;
(*tagptr)++;
}
else {
(*tagptr)->tag=FPPTAG_OUTPUT_DEFINES;
(*tagptr)->data=(void *)TRUE;
(*tagptr)++;
}
break;
case 'X':
(*tagptr)->tag=FPPTAG_INCLUDE_FILE;
(*tagptr)->data=ap;
(*tagptr)++;
break;
/*
case 'x':
tags[tag]->tag=FPPTAG_INCLUDE_MACRO_FILE;
tags[tag++]->data=ap;
break;
*/
case 'h':
case '?': /* if a question mark is possible to specify! */
default: /* What is this one? */
if( ignore < 2 && c != 'h') {
fprintf(stderr, "cpp: unknown option: -%s\n", ap-1);
}
if(!ignore || c == 'h') {
fprintf(stderr,
"Usage: cpp [options] [infile [outfile] ]\n\n"
"The following options are valid:\n"
" -B\tNo mahcine specific built-in symbols\n"
" -b\tOutput any parentheses, brace or bracket unbalance\n"
" -C\tWrite source file comments to output\n"
" -D\tDefine a symbol with the given (optional) value \"symbol[=value]\"\n"
" -d\tDisplay all specified options\n"
" -E\tIgnore non-fatal errors\n"
" -F\tOutput all included file names on stderr\n"
" -f\tOutput all defined functions' names on stderr\n"
" -H\tOutput all whitespaces from the source file\n"
" -h\tOutput this help text\n"
" -I\tAdd directory to the #include search list\n"
" -J\tAllow nested comments\n"
" -j\tEnable warnings for nested comments\n"
" -LL\tDon't output #line instructions\n"
" -L\tDon't output the 'line' keyword in \"#line\" instructions\n"
" -M\tDon't warn for missing include files\n"
" -N\tDon't predefine target-specific names\n"
" -n\tToggle prefs usage\n"
" -P\tDon't recognize C++ comment style\n"
" -p\tEnable warnings on non ANSI preprocessor instructions\n"
" -Q\tIgnore but visualize undefined flags\n"
" -q\tIgnore all undefined flags\n"
" -R\tEvaluate the right part first in symbol concatenations\n"
" -s\tInclude the following string at the top of each function\n"
" -S\tSpecify sizes for #if sizeof\n"
" -t\tThis function should not get an initial function\n"
" -U\tUndefine symbol\n"
" -V\tDon't output version information\n"
" -W\tOutput all #defines\n"
" -WWW\tWeb mode preprocessing\n"
" -w\tOnly output #defines\n"
" -X\tInclude file\n");
return(0);
} /* if (!ignore) */
} /* Switch on all options */
} /* If it's a -option */
} /* For all arguments */
return i;
} /* end of function */

10
3rdparty/glsl-optimizer/.emacs-dirvars vendored Normal file
View File

@@ -0,0 +1,10 @@
;; -*- emacs-lisp -*-
;;
;; This file is processed by the dirvars emacs package. Each variable
;; setting below is performed when this dirvars file is loaded.
;;
indent-tabs-mode: nil
tab-width: 8
c-basic-offset: 3
kde-emacs-after-parent-string: ""
evaluate: (c-set-offset 'inline-open '0)

View File

@@ -0,0 +1,4 @@
*.dsp -crlf
*.dsw -crlf
*.sln -crlf
*.vcproj -crlf

57
3rdparty/glsl-optimizer/.gitignore vendored Normal file
View File

@@ -0,0 +1,57 @@
*.a
*.dll
*.exe
*.ilk
*.o
*.obj
*.os
*.pc
*.pdb
*.pyc
*.pyo
*.so
*.sw[a-z]
*.tar
*.tar.bz2
*.tar.gz
*.zip
*~
depend
depend.bak
lib
lib64
configure
autom4te.cache
aclocal.m4
config.log
config.status
cscope*
.scon*
config.py
build
manifest.txt
.dir-locals.el
*.pbxuser
*.perspectivev3
*.mode1v3
.svn
*.ncb
*.user
*.suo
*.dSYM
xcuserdata
*.xcworkspace
cmake_install.cmake
Makefile
CMakeFiles/
CMakeCache.txt
.project
.cproject
glsl_main
glsl_test
glcpp
glslopt
glsl_compiler
.settings/
.pydevproject

45
3rdparty/glsl-optimizer/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 2.8)
include_directories(include)
include_directories(src/mesa)
include_directories(src/mapi)
include_directories(src/glsl)
option (DEBUG "Enable debugging" FALSE)
if(${DEBUG} MATCHES "on")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -DNDEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -DNDEBUG")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s")
endif()
file(GLOB glcpp-library_sources src/glsl/glcpp/*.c)
file(GLOB glcpp-library_sources_remove src/glsl/glcpp/glcpp.c)
list(REMOVE_ITEM glcpp-library_sources ${glcpp-library_sources_remove})
add_library(glcpp-library ${glcpp-library_sources})
file(GLOB mesa_sources src/mesa/program/*.c)
add_library(mesa ${mesa_sources})
file(GLOB glsl_sources src/glsl/*.cpp src/glsl/*.c)
file(GLOB glsl_sources_remove src/glsl/main.cpp src/glsl/builtin_stubs.cpp)
list(REMOVE_ITEM glsl_sources ${glsl_sources_remove})
add_library(glsl_optimizer ${glsl_sources})
target_link_libraries(glsl_optimizer glcpp-library mesa)
add_executable(glsl_compiler src/glsl/main.cpp)
target_link_libraries(glsl_compiler glsl_optimizer)
file(GLOB glsl_test_sources tests/*.cpp)
add_executable(glsl_test ${glsl_test_sources})
target_link_libraries(glsl_test glsl_optimizer)
file(GLOB glslopt_sources contrib/glslopt/*.cpp)
add_executable(glslopt ${glslopt_sources})
target_link_libraries(glslopt glsl_optimizer)
add_executable(glcpp src/glsl/glcpp/glcpp.c)
target_link_libraries(glcpp glsl_optimizer)

50
3rdparty/glsl-optimizer/README.md vendored Normal file
View File

@@ -0,0 +1,50 @@
GLSL optimizer
==============
A C++ library that takes GLSL shaders, does some GPU-independent optimizations on them
and outputs GLSL back. Optimizations are function inlining, dead code removal, copy propagation,
constant folding, constant propagation, arithmetic optimizations and so on.
Apparently quite a few mobile platforms are pretty bad at optimizing GLSL shaders; and
unfortunately they *also* lack offline shader compilers. So using a GLSL optimizer offline
before can make the shader run much faster on a platform like that. See performance numbers
in [this blog post](http://aras-p.info/blog/2010/09/29/glsl-optimizer/).
Almost all actual code is [Mesa 3D's GLSL2](http://cgit.freedesktop.org/mesa/mesa/log/?h=glsl2)
compiler; all this library does is spits out optimized GLSL back.
This GLSL optimizer is made for [Unity's](http://unity3d.com/) purposes and is built-in
in [Unity 3.0](http://unity3d.com/unity/whats-new/unity-3).
GLSL Optimizer is licensed according to the terms of the MIT license.
Usage
-----
Visual Studio 2008 (Windows, x86) and Xcode 3.2 (Mac, i386) project files for a static
library are provided in `src/glsl/msvc/mesaglsl2.vcproj` and `src/glsl/xcode/mesaglsl2`
respectively.
For Linux you can use cmake. Just type "cmake . && make" in the root directory.
This will build the optimizer library and some executable binaries.
Interface for the library is `src/glsl/glsl_optimizer.h`. General usage is:
ctx = glslopt_initialize();
for (lots of shaders) {
shader = glslopt_optimize (ctx, shaderType, shaderSource, options);
if (glslopt_get_status (shader)) {
newSource = glslopt_get_output (shader);
} else {
errorLog = glslopt_get_log (shader);
}
glslopt_shader_delete (shader);
}
glslopt_cleanup (ctx);
Notes
-----
* I haven't checked if/how it works with higher GLSL versions than the
default (1.10?).

18
3rdparty/glsl-optimizer/autogen.sh vendored Normal file
View File

@@ -0,0 +1,18 @@
#! /bin/sh
srcdir=`dirname "$0"`
test -z "$srcdir" && srcdir=.
SRCDIR=`(cd "$srcdir" && pwd)`
ORIGDIR=`pwd`
if test "x$SRCDIR" != "x$ORIGDIR"; then
echo "Mesa cannot be built when srcdir != builddir" 1>&2
exit 1
fi
MAKEFLAGS=""
autoreconf -v --install || exit 1
"$srcdir"/configure "$@"

View File

@@ -0,0 +1,90 @@
../../../../src/mesa/program/hash_table.c
../../../../src/mesa/program/hash_table.h
../../../../src/mesa/program/symbol_table.c
../../../../src/mesa/program/symbol_table.h
../../../../src/talloc/talloc.c
../../../../src/talloc/talloc.h
../../../../src/glsl/ast.h
../../../../src/glsl/ast_expr.cpp
../../../../src/glsl/ast_function.cpp
../../../../src/glsl/ast_to_hir.cpp
../../../../src/glsl/ast_type.cpp
../../../../src/glsl/builtin_function.cpp
../../../../src/glsl/builtin_types.h
../../../../src/glsl/builtin_variables.h
../../../../src/glsl/glsl_lexer.cpp
../../../../src/glsl/glsl_lexer.lpp
../../../../src/glsl/glsl_optimizer.cpp
../../../../src/glsl/glsl_optimizer.h
# ../../../../src/glsl/glsl_optimizer_main.cpp
../../../../src/glsl/glsl_parser.cpp
../../../../src/glsl/glsl_parser.h
../../../../src/glsl/glsl_parser.ypp
../../../../src/glsl/glsl_parser_extras.cpp
../../../../src/glsl/glsl_parser_extras.h
../../../../src/glsl/glsl_symbol_table.h
../../../../src/glsl/glsl_types.cpp
../../../../src/glsl/glsl_types.h
../../../../src/glsl/hir_field_selection.cpp
../../../../src/glsl/ir.cpp
../../../../src/glsl/ir.h
../../../../src/glsl/ir_algebraic.cpp
../../../../src/glsl/ir_basic_block.cpp
../../../../src/glsl/ir_basic_block.h
../../../../src/glsl/ir_clone.cpp
../../../../src/glsl/ir_constant_expression.cpp
../../../../src/glsl/ir_constant_folding.cpp
../../../../src/glsl/ir_constant_propagation.cpp
../../../../src/glsl/ir_constant_variable.cpp
../../../../src/glsl/ir_copy_propagation.cpp
../../../../src/glsl/ir_dead_code.cpp
../../../../src/glsl/ir_dead_code_local.cpp
../../../../src/glsl/ir_dead_functions.cpp
../../../../src/glsl/ir_div_to_mul_rcp.cpp
../../../../src/glsl/ir_expression_flattening.cpp
../../../../src/glsl/ir_expression_flattening.h
../../../../src/glsl/ir_function.cpp
../../../../src/glsl/ir_function_can_inline.cpp
../../../../src/glsl/ir_function_inlining.cpp
../../../../src/glsl/ir_function_inlining.h
../../../../src/glsl/ir_hierarchical_visitor.cpp
../../../../src/glsl/ir_hierarchical_visitor.h
../../../../src/glsl/ir_hv_accept.cpp
../../../../src/glsl/ir_if_return.cpp
../../../../src/glsl/ir_if_simplification.cpp
../../../../src/glsl/ir_if_to_cond_assign.cpp
../../../../src/glsl/ir_import_prototypes.cpp
../../../../src/glsl/ir_mat_op_to_vec.cpp
../../../../src/glsl/ir_mod_to_fract.cpp
../../../../src/glsl/ir_noop_swizzle.cpp
../../../../src/glsl/ir_optimization.h
../../../../src/glsl/ir_print_glsl_visitor.cpp
../../../../src/glsl/ir_print_glsl_visitor.h
../../../../src/glsl/ir_print_visitor.cpp
../../../../src/glsl/ir_print_visitor.h
../../../../src/glsl/ir_reader.cpp
../../../../src/glsl/ir_reader.h
../../../../src/glsl/ir_rvalue_visitor.cpp
../../../../src/glsl/ir_rvalue_visitor.h
../../../../src/glsl/ir_structure_splitting.cpp
../../../../src/glsl/ir_sub_to_add_neg.cpp
../../../../src/glsl/ir_swizzle_swizzle.cpp
../../../../src/glsl/ir_tree_grafting.cpp
../../../../src/glsl/ir_unused_structs.cpp
../../../../src/glsl/ir_unused_structs.h
../../../../src/glsl/ir_validate.cpp
../../../../src/glsl/ir_variable.cpp
../../../../src/glsl/ir_variable_refcount.cpp
../../../../src/glsl/ir_variable_refcount.h
../../../../src/glsl/ir_vec_index_to_cond_assign.cpp
../../../../src/glsl/ir_vec_index_to_swizzle.cpp
../../../../src/glsl/ir_visitor.h
../../../../src/glsl/link_functions.cpp
../../../../src/glsl/linker.cpp
../../../../src/glsl/linker.h
../../../../src/glsl/list.h
# ../../../../src/glsl/main.cpp
../../../../src/glsl/program.h
../../../../src/glsl/s_expression.cpp
../../../../src/glsl/s_expression.h
../../../../src/glsl/msvc/msvccompat.h

View File

@@ -0,0 +1,9 @@
[General]
Type = StaticLibrary
SourceFiles = SourceFiles
Platform = Tool
[Project]
IncludePaths=../../../../src/talloc;../../../../include;../../../../src/mesa;../../../../src/mapi;../../../../src/glsl/msvc;../../../../src/glsl
Defines=snprintf=_snprintf;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE
DisabledVcWarnings=4291;4996;4800;4099;4244;4018;4245

View File

@@ -0,0 +1,829 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="glsloptlib"
ProjectGUID="{793576AD-FB15-5AA1-F2F5-488372B23341}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ProjectDir)$(ConfigurationName)"
IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
ConfigurationType="4"
UseOfMFC="0"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalOptions=""
AdditionalIncludeDirectories=";../../../../src/talloc;../../../../include;../../../../src/mesa;../../../../src/mapi;../../../../src/glsl/msvc;../../../../src/glsl;../../../../../../../Shared;../../../../../../../Tools/Shared;../../../../../freetype-2.1.10/include;../../../../../Lua/include;../../../../../FreeImage;../../../../../../Include;../../../../.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;snprintf=_snprintf;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;AURORA_TOOL;AURORA_DEBUGG"
StringPooling="false"
MinimalRebuild="false"
ExceptionHandling="2"
BasicRuntimeChecks="3"
SmallerTypeCheck="true"
RuntimeLibrary="3"
StructMemberAlignment="3"
BufferSecurityCheck="true"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="0"
FloatingPointExceptions="false"
DisableLanguageExtensions="false"
DefaultCharIsUnsigned="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
OpenMP="false"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="PreCompiled.h"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CallingConvention="0"
CompileAs="0"
DisableSpecificWarnings="4512;4127;4996;4291;4291;4996;4800;4099;4244;4018;4245"
UseFullPaths="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
LinkLibraryDependencies="false"
AdditionalDependencies=" "
AdditionalLibraryDirectories="../../../../../freetype-2.1.10/lib;../../../../../Lua/lib;../../../../../FreeImage;../../../../../../Lib "
OutputFile="$(OutDir)\$(ProjectName).lib"
SuppressStartupBanner="true"
AdditionalOptions="/IGNORE:4221 /IGNORE:4006"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description=""
CommandLine=""
ExcludedFromBuild="false"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ProjectDir)$(ConfigurationName)"
IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
UseOfMFC="0"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="3"
AdditionalOptions=""
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
OmitFramePointers="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=";../../../../src/talloc;../../../../include;../../../../src/mesa;../../../../src/mapi;../../../../src/glsl/msvc;../../../../src/glsl;../../../../../../../Shared;../../../../../../../Tools/Shared;../../../../../freetype-2.1.10/include;../../../../../Lua/include;../../../../../FreeImage;../../../../../../Include;../../../../.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;snprintf=_snprintf;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;AURORA_TOOL;AURORA_RELEASE"
StringPooling="false"
MinimalRebuild="false"
ExceptionHandling="2"
BasicRuntimeChecks="0"
SmallerTypeCheck="false"
RuntimeLibrary="2"
StructMemberAlignment="3"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="2"
FloatingPointExceptions="false"
DisableLanguageExtensions="false"
DefaultCharIsUnsigned="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
OpenMP="false"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="PreCompiled.h"
AssemblerOutput="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CallingConvention="0"
CompileAs="0"
DisableSpecificWarnings="4512;4127;4996;4291;4291;4996;4800;4099;4244;4018;4245"
UseFullPaths="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
LinkLibraryDependencies="false"
AdditionalDependencies=" "
AdditionalLibraryDirectories="../../../../../freetype-2.1.10/lib;../../../../../Lua/lib;../../../../../FreeImage;../../../../../../Lib "
OutputFile="$(OutDir)\$(ProjectName).lib"
SuppressStartupBanner="true"
AdditionalOptions="/IGNORE:4221 /IGNORE:4006"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description=""
CommandLine=""
ExcludedFromBuild="false"
/>
</Configuration>
<Configuration
Name="Profile|Win32"
OutputDirectory="$(ProjectDir)$(ConfigurationName)"
IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
UseOfMFC="0"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="3"
AdditionalOptions=""
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
OmitFramePointers="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=";../../../../src/talloc;../../../../include;../../../../src/mesa;../../../../src/mapi;../../../../src/glsl/msvc;../../../../src/glsl;../../../../../../../Shared;../../../../../../../Tools/Shared;../../../../../freetype-2.1.10/include;../../../../../Lua/include;../../../../../FreeImage;../../../../../../Include;../../../../.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;snprintf=_snprintf;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;AURORA_TOOL;AURORA_PROFILE"
StringPooling="false"
MinimalRebuild="false"
ExceptionHandling="2"
BasicRuntimeChecks="0"
SmallerTypeCheck="false"
RuntimeLibrary="2"
StructMemberAlignment="3"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="false"
EnableEnhancedInstructionSet="2"
FloatingPointExceptions="false"
DisableLanguageExtensions="false"
DefaultCharIsUnsigned="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
OpenMP="false"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="PreCompiled.h"
AssemblerOutput="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CallingConvention="0"
CompileAs="0"
DisableSpecificWarnings="4512;4127;4996;4291;4291;4996;4800;4099;4244;4018;4245"
UseFullPaths="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
LinkLibraryDependencies="false"
AdditionalDependencies=" "
AdditionalLibraryDirectories="../../../../../freetype-2.1.10/lib;../../../../../Lua/lib;../../../../../FreeImage;../../../../../../Lib "
OutputFile="$(OutDir)\$(ProjectName).lib"
SuppressStartupBanner="true"
AdditionalOptions="/IGNORE:4221 /IGNORE:4006"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description=""
CommandLine=""
ExcludedFromBuild="false"
/>
</Configuration>
<Configuration
Name="Final|Win32"
OutputDirectory="$(ProjectDir)$(ConfigurationName)"
IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
UseOfMFC="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="3"
AdditionalOptions=""
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
OmitFramePointers="false"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=";../../../../src/talloc;../../../../include;../../../../src/mesa;../../../../src/mapi;../../../../src/glsl/msvc;../../../../src/glsl;../../../../../../../Shared;../../../../../../../Tools/Shared;../../../../../freetype-2.1.10/include;../../../../../Lua/include;../../../../../FreeImage;../../../../../../Include;../../../../.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;snprintf=_snprintf;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;AURORA_TOOL;AURORA_FINAL;AURORA_RETAIL"
StringPooling="false"
MinimalRebuild="false"
ExceptionHandling="2"
BasicRuntimeChecks="0"
SmallerTypeCheck="false"
RuntimeLibrary="2"
StructMemberAlignment="3"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="false"
EnableEnhancedInstructionSet="2"
FloatingPointExceptions="false"
DisableLanguageExtensions="false"
DefaultCharIsUnsigned="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
OpenMP="false"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="PreCompiled.h"
AssemblerOutput="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CallingConvention="0"
CompileAs="0"
DisableSpecificWarnings="4512;4127;4996;4291;4291;4996;4800;4099;4244;4018;4245"
UseFullPaths="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
LinkLibraryDependencies="false"
AdditionalDependencies=" "
AdditionalLibraryDirectories="../../../../../freetype-2.1.10/lib;../../../../../Lua/lib;../../../../../FreeImage;../../../../../../Lib "
OutputFile="$(OutDir)\$(ProjectName).lib"
SuppressStartupBanner="true"
AdditionalOptions="/IGNORE:4221 /IGNORE:4006"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description=""
CommandLine=""
ExcludedFromBuild="false"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="src"
>
<Filter
Name="mesa"
>
<Filter
Name="program"
>
<File
RelativePath="..\..\..\..\src\mesa\program\hash_table.c"
>
</File>
<File
RelativePath="..\..\..\..\src\mesa\program\hash_table.h"
>
</File>
<File
RelativePath="..\..\..\..\src\mesa\program\symbol_table.c"
>
</File>
<File
RelativePath="..\..\..\..\src\mesa\program\symbol_table.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="talloc"
>
<File
RelativePath="..\..\..\..\src\talloc\talloc.c"
>
</File>
<File
RelativePath="..\..\..\..\src\talloc\talloc.h"
>
</File>
</Filter>
<Filter
Name="glsl"
>
<File
RelativePath="..\..\..\..\src\glsl\ast.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ast_expr.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ast_function.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ast_to_hir.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ast_type.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\builtin_function.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\builtin_types.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\builtin_variables.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_lexer.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_lexer.lpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_optimizer.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_optimizer.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_parser.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_parser.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_parser.ypp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_parser_extras.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_parser_extras.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_symbol_table.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_types.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\glsl_types.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\hir_field_selection.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_algebraic.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_basic_block.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_basic_block.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_clone.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_constant_expression.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_constant_folding.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_constant_propagation.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_constant_variable.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_copy_propagation.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_dead_code.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_dead_code_local.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_dead_functions.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_div_to_mul_rcp.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_expression_flattening.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_expression_flattening.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_function.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_function_can_inline.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_function_inlining.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_function_inlining.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_hierarchical_visitor.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_hierarchical_visitor.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_hv_accept.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_if_return.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_if_simplification.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_if_to_cond_assign.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_import_prototypes.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_mat_op_to_vec.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_mod_to_fract.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_noop_swizzle.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_optimization.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_print_glsl_visitor.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_print_glsl_visitor.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_print_visitor.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_print_visitor.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_reader.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_reader.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_rvalue_visitor.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_rvalue_visitor.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_structure_splitting.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_sub_to_add_neg.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_swizzle_swizzle.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_tree_grafting.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_unused_structs.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_unused_structs.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_validate.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_variable.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_variable_refcount.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_variable_refcount.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_vec_index_to_cond_assign.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_vec_index_to_swizzle.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\ir_visitor.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\link_functions.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\linker.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\linker.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\list.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\program.h"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\s_expression.cpp"
>
</File>
<File
RelativePath="..\..\..\..\src\glsl\s_expression.h"
>
</File>
<Filter
Name="msvc"
>
<File
RelativePath="..\..\..\..\src\glsl\msvc\msvccompat.h"
>
</File>
</Filter>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,5 @@
#! /bin/sh
flex --nounistd -osrc/glsl/glcpp/glcpp-lex.c src/glsl/glcpp/glcpp-lex.l
flex --nounistd -osrc/glsl/glsl_lexer.cpp src/glsl/glsl_lexer.ll
bison -v -o "src/glsl/glcpp/glcpp-parse.c" --defines=src/glsl/glcpp/glcpp-parse.h src/glsl/glcpp/glcpp-parse.y
bison -v -o "src/glsl/glsl_parser.cpp" -p "_mesa_glsl_" --defines=src/glsl/glsl_parser.h src/glsl/glsl_parser.yy

2241
3rdparty/glsl-optimizer/include/GL/gl.h vendored Normal file

File diff suppressed because it is too large Load Diff

11488
3rdparty/glsl-optimizer/include/GL/glext.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,305 @@
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. 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.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_INTTYPES_H_ // [
#define _MSC_INTTYPES_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include "stdint.h"
// 7.8 Format conversion of integer types
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
// 7.8.1 Macros for format specifiers
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
// The fprintf macros for signed integers are:
#define PRId8 "d"
#define PRIi8 "i"
#define PRIdLEAST8 "d"
#define PRIiLEAST8 "i"
#define PRIdFAST8 "d"
#define PRIiFAST8 "i"
#define PRId16 "hd"
#define PRIi16 "hi"
#define PRIdLEAST16 "hd"
#define PRIiLEAST16 "hi"
#define PRIdFAST16 "hd"
#define PRIiFAST16 "hi"
#define PRId32 "I32d"
#define PRIi32 "I32i"
#define PRIdLEAST32 "I32d"
#define PRIiLEAST32 "I32i"
#define PRIdFAST32 "I32d"
#define PRIiFAST32 "I32i"
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIdLEAST64 "I64d"
#define PRIiLEAST64 "I64i"
#define PRIdFAST64 "I64d"
#define PRIiFAST64 "I64i"
#define PRIdMAX "I64d"
#define PRIiMAX "I64i"
#define PRIdPTR "Id"
#define PRIiPTR "Ii"
// The fprintf macros for unsigned integers are:
#define PRIo8 "o"
#define PRIu8 "u"
#define PRIx8 "x"
#define PRIX8 "X"
#define PRIoLEAST8 "o"
#define PRIuLEAST8 "u"
#define PRIxLEAST8 "x"
#define PRIXLEAST8 "X"
#define PRIoFAST8 "o"
#define PRIuFAST8 "u"
#define PRIxFAST8 "x"
#define PRIXFAST8 "X"
#define PRIo16 "ho"
#define PRIu16 "hu"
#define PRIx16 "hx"
#define PRIX16 "hX"
#define PRIoLEAST16 "ho"
#define PRIuLEAST16 "hu"
#define PRIxLEAST16 "hx"
#define PRIXLEAST16 "hX"
#define PRIoFAST16 "ho"
#define PRIuFAST16 "hu"
#define PRIxFAST16 "hx"
#define PRIXFAST16 "hX"
#define PRIo32 "I32o"
#define PRIu32 "I32u"
#define PRIx32 "I32x"
#define PRIX32 "I32X"
#define PRIoLEAST32 "I32o"
#define PRIuLEAST32 "I32u"
#define PRIxLEAST32 "I32x"
#define PRIXLEAST32 "I32X"
#define PRIoFAST32 "I32o"
#define PRIuFAST32 "I32u"
#define PRIxFAST32 "I32x"
#define PRIXFAST32 "I32X"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#define PRIoLEAST64 "I64o"
#define PRIuLEAST64 "I64u"
#define PRIxLEAST64 "I64x"
#define PRIXLEAST64 "I64X"
#define PRIoFAST64 "I64o"
#define PRIuFAST64 "I64u"
#define PRIxFAST64 "I64x"
#define PRIXFAST64 "I64X"
#define PRIoMAX "I64o"
#define PRIuMAX "I64u"
#define PRIxMAX "I64x"
#define PRIXMAX "I64X"
#define PRIoPTR "Io"
#define PRIuPTR "Iu"
#define PRIxPTR "Ix"
#define PRIXPTR "IX"
// The fscanf macros for signed integers are:
#define SCNd8 "d"
#define SCNi8 "i"
#define SCNdLEAST8 "d"
#define SCNiLEAST8 "i"
#define SCNdFAST8 "d"
#define SCNiFAST8 "i"
#define SCNd16 "hd"
#define SCNi16 "hi"
#define SCNdLEAST16 "hd"
#define SCNiLEAST16 "hi"
#define SCNdFAST16 "hd"
#define SCNiFAST16 "hi"
#define SCNd32 "ld"
#define SCNi32 "li"
#define SCNdLEAST32 "ld"
#define SCNiLEAST32 "li"
#define SCNdFAST32 "ld"
#define SCNiFAST32 "li"
#define SCNd64 "I64d"
#define SCNi64 "I64i"
#define SCNdLEAST64 "I64d"
#define SCNiLEAST64 "I64i"
#define SCNdFAST64 "I64d"
#define SCNiFAST64 "I64i"
#define SCNdMAX "I64d"
#define SCNiMAX "I64i"
#ifdef _WIN64 // [
# define SCNdPTR "I64d"
# define SCNiPTR "I64i"
#else // _WIN64 ][
# define SCNdPTR "ld"
# define SCNiPTR "li"
#endif // _WIN64 ]
// The fscanf macros for unsigned integers are:
#define SCNo8 "o"
#define SCNu8 "u"
#define SCNx8 "x"
#define SCNX8 "X"
#define SCNoLEAST8 "o"
#define SCNuLEAST8 "u"
#define SCNxLEAST8 "x"
#define SCNXLEAST8 "X"
#define SCNoFAST8 "o"
#define SCNuFAST8 "u"
#define SCNxFAST8 "x"
#define SCNXFAST8 "X"
#define SCNo16 "ho"
#define SCNu16 "hu"
#define SCNx16 "hx"
#define SCNX16 "hX"
#define SCNoLEAST16 "ho"
#define SCNuLEAST16 "hu"
#define SCNxLEAST16 "hx"
#define SCNXLEAST16 "hX"
#define SCNoFAST16 "ho"
#define SCNuFAST16 "hu"
#define SCNxFAST16 "hx"
#define SCNXFAST16 "hX"
#define SCNo32 "lo"
#define SCNu32 "lu"
#define SCNx32 "lx"
#define SCNX32 "lX"
#define SCNoLEAST32 "lo"
#define SCNuLEAST32 "lu"
#define SCNxLEAST32 "lx"
#define SCNXLEAST32 "lX"
#define SCNoFAST32 "lo"
#define SCNuFAST32 "lu"
#define SCNxFAST32 "lx"
#define SCNXFAST32 "lX"
#define SCNo64 "I64o"
#define SCNu64 "I64u"
#define SCNx64 "I64x"
#define SCNX64 "I64X"
#define SCNoLEAST64 "I64o"
#define SCNuLEAST64 "I64u"
#define SCNxLEAST64 "I64x"
#define SCNXLEAST64 "I64X"
#define SCNoFAST64 "I64o"
#define SCNuFAST64 "I64u"
#define SCNxFAST64 "I64x"
#define SCNXFAST64 "I64X"
#define SCNoMAX "I64o"
#define SCNuMAX "I64u"
#define SCNxMAX "I64x"
#define SCNXMAX "I64X"
#ifdef _WIN64 // [
# define SCNoPTR "I64o"
# define SCNuPTR "I64u"
# define SCNxPTR "I64x"
# define SCNXPTR "I64X"
#else // _WIN64 ][
# define SCNoPTR "lo"
# define SCNuPTR "lu"
# define SCNxPTR "lx"
# define SCNXPTR "lX"
#endif // _WIN64 ]
#endif // __STDC_FORMAT_MACROS ]
// 7.8.2 Functions for greatest-width integer types
// 7.8.2.1 The imaxabs function
#define imaxabs _abs64
// 7.8.2.2 The imaxdiv function
// This is modified version of div() function from Microsoft's div.c found
// in %MSVC.NET%\crt\src\div.c
#ifdef STATIC_IMAXDIV // [
static
#else // STATIC_IMAXDIV ][
_inline
#endif // STATIC_IMAXDIV ]
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
{
imaxdiv_t result;
result.quot = numer / denom;
result.rem = numer % denom;
if (numer < 0 && result.rem > 0) {
// did division wrong; must fix up
++result.quot;
result.rem -= denom;
}
return result;
}
// 7.8.2.3 The strtoimax and strtoumax functions
#define strtoimax _strtoi64
#define strtoumax _strtoui64
// 7.8.2.4 The wcstoimax and wcstoumax functions
#define wcstoimax _wcstoi64
#define wcstoumax _wcstoui64
#endif // _MSC_INTTYPES_H_ ]

View File

@@ -0,0 +1,46 @@
/**************************************************************************
*
* Copyright 2007-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
#ifndef _STDBOOL_H_
#define _STDBOOL_H_
#ifndef __cplusplus
#define false 0
#define true 1
#define bool _Bool
/* For compilers that don't have the builtin _Bool type. */
#if (defined(_MSC_VER) || (__STDC_VERSION__ < 199901L && __GNUC__ < 3)) && !defined(_lint)
typedef unsigned char _Bool;
#endif
#endif /* !__cplusplus */
#define __bool_true_false_are_defined 1
#endif /* !_STDBOOL_H_ */

View File

@@ -0,0 +1,247 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. 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.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#ifdef __cplusplus
extern "C" {
#endif
# include <wchar.h>
#ifdef __cplusplus
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 signed int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]

21
3rdparty/glsl-optimizer/license.txt vendored Normal file
View File

@@ -0,0 +1,21 @@
GLSL Optimizer is licensed according to the terms of the MIT license:
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Copyright (C) 2010-2011 Unity Technologies All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,5 @@
#! /bin/sh
git rm -rf docs
git rm -rf src/mesa/drivers
git rm -rf src/gallium
git rm -rf $(git status --porcelain | awk '/^DU/ {print $NF}')

View File

@@ -0,0 +1,15 @@
Import('*')
if not env['msvc']:
Return()
env = env.Clone()
env.Prepend(CPPPATH = ['.'])
getopt = env.ConvenienceLibrary(
target = 'getopt',
source = ['getopt_long.c'],
)
Export('getopt')

View File

@@ -0,0 +1,82 @@
/* $OpenBSD: getopt.h,v 1.2 2008/06/26 05:42:04 ray Exp $ */
/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#ifndef _GETOPT_H_
#define _GETOPT_H_
/*
* GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
*/
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#ifdef __cplusplus
extern "C" {
#endif
struct option {
/* name of long option */
const char *name;
/*
* one of no_argument, required_argument, and optional_argument:
* whether option takes an argument
*/
int has_arg;
/* if not NULL, set *flag to val when option found */
int *flag;
/* if flag not NULL, value to set *flag to; else return value */
int val;
};
int getopt_long(int, char * const *, const char *,
const struct option *, int *);
int getopt_long_only(int, char * const *, const char *,
const struct option *, int *);
#ifndef _GETOPT_DEFINED_
#define _GETOPT_DEFINED_
int getopt(int, char * const *, const char *);
int getsubopt(char **, char * const *, char **);
extern char *optarg; /* getopt(3) external variables */
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
extern char *suboptarg; /* getsubopt(3) external variable */
#endif
#ifdef __cplusplus
}
#endif
#endif /* !_GETOPT_H_ */

View File

@@ -0,0 +1,511 @@
/* $OpenBSD: getopt_long.c,v 1.24 2010/07/22 19:31:53 blambert Exp $ */
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
/*
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define PRINT_ERROR ((opterr) && (*options != ':'))
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
/* return values */
#define BADCH (int)'?'
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#define EMSG ""
static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int);
static int parse_long_options(char * const *, const char *,
const struct option *, int *, int);
static int gcd(int, int);
static void permute_args(int, int, int, char * const *);
static char *place = EMSG; /* option letter processing */
/* XXX: set optreset to 1 rather than these two */
static int nonopt_start = -1; /* first non option argument (for permute) */
static int nonopt_end = -1; /* first option after non options (for permute) */
/* Error messages */
static const char recargchar[] = "option requires an argument -- %c";
static const char recargstring[] = "option requires an argument -- %s";
static const char ambig[] = "ambiguous option -- %.*s";
static const char noarg[] = "option doesn't take an argument -- %.*s";
static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
/*
* Compute the greatest common divisor of a and b.
*/
static int
gcd(int a, int b)
{
int c;
c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return (b);
}
/*
* Exchange the block from nonopt_start to nonopt_end with the block
* from nonopt_end to opt_end (keeping the same order of arguments
* in each block).
*/
static void
permute_args(int panonopt_start, int panonopt_end, int opt_end,
char * const *nargv)
{
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
char *swap;
/*
* compute lengths of blocks and number and size of cycles
*/
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts, nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end+i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
/* LINTED const cast */
((char **) nargv)[pos] = nargv[cstart];
/* LINTED const cast */
((char **)nargv)[cstart] = swap;
}
}
}
/*
* parse_long_options --
* Parse long options in argc/argv argument vector.
* Returns -1 if short_too is set and the option does not match long_options.
*/
static int
parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
size_t current_argv_len;
int i, match;
current_argv = place;
match = -1;
optind++;
if ((has_equal = strchr(current_argv, '=')) != NULL) {
/* argument found (--option=arg) */
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
if (strncmp(current_argv, long_options[i].name,
current_argv_len))
continue;
if (strlen(long_options[i].name) == current_argv_len) {
/* exact match */
match = i;
break;
}
/*
* If this is a known short option, don't allow
* a partial match of a single character.
*/
if (short_too && current_argv_len == 1)
continue;
if (match == -1) /* partial match */
match = i;
else {
/* ambiguous abbreviation */
if (PRINT_ERROR)
fprintf(stderr, ambig, (int)current_argv_len,
current_argv);
optopt = 0;
return (BADCH);
}
}
if (match != -1) { /* option found */
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
fprintf(stderr, noarg, (int)current_argv_len,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
return (BADARG);
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
if (has_equal)
optarg = has_equal;
else if (long_options[match].has_arg ==
required_argument) {
/*
* optional argument doesn't use next nargv
*/
optarg = nargv[optind++];
}
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
/*
* Missing argument; leading ':' indicates no error
* should be generated.
*/
if (PRINT_ERROR)
fprintf(stderr, recargstring,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
--optind;
return (BADARG);
}
} else { /* unknown option */
if (short_too) {
--optind;
return (-1);
}
if (PRINT_ERROR)
fprintf(stderr, illoptstring, current_argv);
optopt = 0;
return (BADCH);
}
if (idx)
*idx = match;
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
return (0);
} else
return (long_options[match].val);
}
/*
* getopt_internal --
* Parse argc/argv argument vector. Called by user level routines.
*/
static int
getopt_internal(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx, int flags)
{
char *oli; /* option letter list index */
int optchar, short_too;
static int posixly_correct = -1;
if (options == NULL)
return (-1);
/*
* Disable GNU extensions if POSIXLY_CORRECT is set or options
* string begins with a '+'.
*/
if (posixly_correct == -1)
posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
if (posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
else if (*options == '-')
flags |= FLAG_ALLARGS;
if (*options == '+' || *options == '-')
options++;
/*
* XXX Some GNU programs (like cvs) set optind to 0 instead of
* XXX using optreset. Work around this braindamage.
*/
if (optind == 0)
optind = optreset = 1;
optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
start:
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc) { /* end of argument vector */
place = EMSG;
if (nonopt_end != -1) {
/* do permutation, if we have to */
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
else if (nonopt_start != -1) {
/*
* If we skipped non-options, set optind
* to the first of them.
*/
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
if (*(place = nargv[optind]) != '-' ||
(place[1] == '\0' && strchr(options, '-') == NULL)) {
place = EMSG; /* found non-option */
if (flags & FLAG_ALLARGS) {
/*
* GNU extension:
* return non-option as argument to option 1
*/
optarg = nargv[optind++];
return (INORDER);
}
if (!(flags & FLAG_PERMUTE)) {
/*
* If no permutation wanted, stop parsing
* at first non-option.
*/
return (-1);
}
/* do permutation */
if (nonopt_start == -1)
nonopt_start = optind;
else if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
nonopt_start = optind -
(nonopt_end - nonopt_start);
nonopt_end = -1;
}
optind++;
/* process next argument */
goto start;
}
if (nonopt_start != -1 && nonopt_end == -1)
nonopt_end = optind;
/*
* If we have "-" do nothing, if "--" we are done.
*/
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
optind++;
place = EMSG;
/*
* We found an option (--), so if we skipped
* non-options, we have to permute.
*/
if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
}
/*
* Check long options if:
* 1) we were passed some
* 2) the arg is not just "-"
* 3) either the arg starts with -- we are getopt_long_only()
*/
if (long_options != NULL && place != nargv[optind] &&
(*place == '-' || (flags & FLAG_LONGONLY))) {
short_too = 0;
if (*place == '-')
place++; /* --foo long option */
else if (*place != ':' && strchr(options, *place) != NULL)
short_too = 1; /* could be short option too */
optchar = parse_long_options(nargv, options, long_options,
idx, short_too);
if (optchar != -1) {
place = EMSG;
return (optchar);
}
}
if ((optchar = (int)*place++) == (int)':' ||
(optchar == (int)'-' && *place != '\0') ||
(oli = strchr(options, optchar)) == NULL) {
/*
* If the user specified "-" and '-' isn't listed in
* options, return -1 (non-option) as per POSIX.
* Otherwise, it is an unknown option character (or ':').
*/
if (optchar == (int)'-' && *place == '\0')
return (-1);
if (!*place)
++optind;
if (PRINT_ERROR)
fprintf(stderr, illoptchar, optchar);
optopt = optchar;
return (BADCH);
}
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
/* -W long-option */
if (*place) /* no space */
/* NOTHING */;
else if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
fprintf(stderr, recargchar, optchar);
optopt = optchar;
return (BADARG);
} else /* white space */
place = nargv[optind];
optchar = parse_long_options(nargv, options, long_options,
idx, 0);
place = EMSG;
return (optchar);
}
if (*++oli != ':') { /* doesn't take argument */
if (!*place)
++optind;
} else { /* takes (optional) argument */
optarg = NULL;
if (*place) /* no white space */
optarg = place;
else if (oli[1] != ':') { /* arg not optional */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
fprintf(stderr, recargchar, optchar);
optopt = optchar;
return (BADARG);
} else
optarg = nargv[optind];
}
place = EMSG;
++optind;
}
/* dump back option letter */
return (optchar);
}
/*
* getopt --
* Parse argc/argv argument vector.
*
* [eventually this will replace the BSD getopt]
*/
int
getopt(int nargc, char * const *nargv, const char *options)
{
/*
* We don't pass FLAG_PERMUTE to getopt_internal() since
* the BSD getopt(3) (unlike GNU) has never done this.
*
* Furthermore, since many privileged programs call getopt()
* before dropping privileges it makes sense to keep things
* as simple (and bug-free) as possible.
*/
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
}
/*
* getopt_long --
* Parse argc/argv argument vector.
*/
int
getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE));
}
/*
* getopt_long_only --
* Parse argc/argv argument vector.
*/
int
getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE|FLAG_LONGONLY));
}

View File

@@ -0,0 +1,4 @@
glsl_compiler
glsl_parser.output
builtin_compiler
glsl_test

View File

@@ -0,0 +1,50 @@
# src/glsl/Makefile.template
# Template makefile for glsl libraries.
#
# Usage:
# The minimum that the including makefile needs to define
# is TOP, LIBNAME and one of of the *_SOURCES.
#
# Optional defines:
# LIBRARY_INCLUDES are appended to the list of includes directories.
# LIBRARY_DEFINES is not used for makedepend, but for compilation.
### Basic defines ###
OBJECTS = $(C_SOURCES:.c=.o)
INCLUDES = \
-I. \
$(LIBRARY_INCLUDES)
##### TARGETS #####
default: depend lib$(LIBNAME).a
lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template
$(MKLIB) -o $(LIBNAME) -static $(OBJECTS)
depend: $(C_SOURCES)
rm -f depend
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) 2> /dev/null
# Remove .o and backup files
clean:
rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak
# Dummy target
install:
@echo -n ""
##### RULES #####
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
-include depend

229
3rdparty/glsl-optimizer/src/glsl/README vendored Normal file
View File

@@ -0,0 +1,229 @@
Welcome to Mesa's GLSL compiler. A brief overview of how things flow:
1) lex and yacc-based preprocessor takes the incoming shader string
and produces a new string containing the preprocessed shader. This
takes care of things like #if, #ifdef, #define, and preprocessor macro
invocations. Note that #version, #extension, and some others are
passed straight through. See glcpp/*
2) lex and yacc-based parser takes the preprocessed string and
generates the AST (abstract syntax tree). Almost no checking is
performed in this stage. See glsl_lexer.lpp and glsl_parser.ypp.
3) The AST is converted to "HIR". This is the intermediate
representation of the compiler. Constructors are generated, function
calls are resolved to particular function signatures, and all the
semantic checking is performed. See ast_*.cpp for the conversion, and
ir.h for the IR structures.
4) The driver (Mesa, or main.cpp for the standalone binary) performs
optimizations. These include copy propagation, dead code elimination,
constant folding, and others. Generally the driver will call
optimizations in a loop, as each may open up opportunities for other
optimizations to do additional work. See most files called ir_*.cpp
5) linking is performed. This does checking to ensure that the
outputs of the vertex shader match the inputs of the fragment shader,
and assigns locations to uniforms, attributes, and varyings. See
linker.cpp.
6) The driver may perform additional optimization at this point, as
for example dead code elimination previously couldn't remove functions
or global variable usage when we didn't know what other code would be
linked in.
7) The driver performs code generation out of the IR, taking a linked
shader program and producing a compiled program for each stage. See
ir_to_mesa.cpp for Mesa IR code generation.
FAQ:
Q: What is HIR versus IR versus LIR?
A: The idea behind the naming was that ast_to_hir would produce a
high-level IR ("HIR"), with things like matrix operations, structure
assignments, etc., present. A series of lowering passes would occur
that do things like break matrix multiplication into a series of dot
products/MADs, make structure assignment be a series of assignment of
components, flatten if statements into conditional moves, and such,
producing a low level IR ("LIR").
However, it now appears that each driver will have different
requirements from a LIR. A 915-generation chipset wants all functions
inlined, all loops unrolled, all ifs flattened, no variable array
accesses, and matrix multiplication broken down. The Mesa IR backend
for swrast would like matrices and structure assignment broken down,
but it can support function calls and dynamic branching. A 965 vertex
shader IR backend could potentially even handle some matrix operations
without breaking them down, but the 965 fragment shader IR backend
would want to break to have (almost) all operations down channel-wise
and perform optimization on that. As a result, there's no single
low-level IR that will make everyone happy. So that usage has fallen
out of favor, and each driver will perform a series of lowering passes
to take the HIR down to whatever restrictions it wants to impose
before doing codegen.
Q: How is the IR structured?
A: The best way to get started seeing it would be to run the
standalone compiler against a shader:
./glsl_compiler --dump-lir \
~/src/piglit/tests/shaders/glsl-orangebook-ch06-bump.frag
So for example one of the ir_instructions in main() contains:
(assign (constant bool (1)) (var_ref litColor) (expression vec3 * (var_ref Surf
aceColor) (var_ref __retval) ) )
Or more visually:
(assign)
/ | \
(var_ref) (expression *) (constant bool 1)
/ / \
(litColor) (var_ref) (var_ref)
/ \
(SurfaceColor) (__retval)
which came from:
litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0);
(the max call is not represented in this expression tree, as it was a
function call that got inlined but not brought into this expression
tree)
Each of those nodes is a subclass of ir_instruction. A particular
ir_instruction instance may only appear once in the whole IR tree with
the exception of ir_variables, which appear once as variable
declarations:
(declare () vec3 normDelta)
and multiple times as the targets of variable dereferences:
...
(assign (constant bool (1)) (var_ref __retval) (expression float dot
(var_ref normDelta) (var_ref LightDir) ) )
...
(assign (constant bool (1)) (var_ref __retval) (expression vec3 -
(var_ref LightDir) (expression vec3 * (constant float (2.000000))
(expression vec3 * (expression float dot (var_ref normDelta) (var_ref
LightDir) ) (var_ref normDelta) ) ) ) )
...
Each node has a type. Expressions may involve several different types:
(declare (uniform ) mat4 gl_ModelViewMatrix)
((assign (constant bool (1)) (var_ref constructor_tmp) (expression
vec4 * (var_ref gl_ModelViewMatrix) (var_ref gl_Vertex) ) )
An expression tree can be arbitrarily deep, and the compiler tries to
keep them structured like that so that things like algebraic
optimizations ((color * 1.0 == color) and ((mat1 * mat2) * vec == mat1
* (mat2 * vec))) or recognizing operation patterns for code generation
(vec1 * vec2 + vec3 == mad(vec1, vec2, vec3)) are easier. This comes
at the expense of additional trickery in implementing some
optimizations like CSE where one must navigate an expression tree.
Q: Why no SSA representation?
A: Converting an IR tree to SSA form makes dead code elmimination,
common subexpression elimination, and many other optimizations much
easier. However, in our primarily vector-based language, there's some
major questions as to how it would work. Do we do SSA on the scalar
or vector level? If we do it at the vector level, we're going to end
up with many different versions of the variable when encountering code
like:
(assign (constant bool (1)) (swiz x (var_ref __retval) ) (var_ref a) )
(assign (constant bool (1)) (swiz y (var_ref __retval) ) (var_ref b) )
(assign (constant bool (1)) (swiz z (var_ref __retval) ) (var_ref c) )
If every masked update of a component relies on the previous value of
the variable, then we're probably going to be quite limited in our
dead code elimination wins, and recognizing common expressions may
just not happen. On the other hand, if we operate channel-wise, then
we'll be prone to optimizing the operation on one of the channels at
the expense of making its instruction flow different from the other
channels, and a vector-based GPU would end up with worse code than if
we didn't optimize operations on that channel!
Once again, it appears that our optimization requirements are driven
significantly by the target architecture. For now, targeting the Mesa
IR backend, SSA does not appear to be that important to producing
excellent code, but we do expect to do some SSA-based optimizations
for the 965 fragment shader backend when that is developed.
Q: How should I expand instructions that take multiple backend instructions?
Sometimes you'll have to do the expansion in your code generation --
see, for example, ir_to_mesa.cpp's handling of ir_unop_sqrt. However,
in many cases you'll want to do a pass over the IR to convert
non-native instructions to a series of native instructions. For
example, for the Mesa backend we have ir_div_to_mul_rcp.cpp because
Mesa IR (and many hardware backends) only have a reciprocal
instruction, not a divide. Implementing non-native instructions this
way gives the chance for constant folding to occur, so (a / 2.0)
becomes (a * 0.5) after codegen instead of (a * (1.0 / 2.0))
Q: How shoud I handle my special hardware instructions with respect to IR?
Our current theory is that if multiple targets have an instruction for
some operation, then we should probably be able to represent that in
the IR. Generally this is in the form of an ir_{bin,un}op expression
type. For example, we initially implemented fract() using (a -
floor(a)), but both 945 and 965 have instructions to give that result,
and it would also simplify the implementation of mod(), so
ir_unop_fract was added. The following areas need updating to add a
new expression type:
ir.h (new enum)
ir.cpp:get_num_operands() (used for ir_reader)
ir.cpp:operator_strs (used for ir_reader)
ir_constant_expression.cpp (you probably want to be able to constant fold)
ir_validate.cpp (check users have the right types)
You may also need to update the backends if they will see the new expr type:
../mesa/shaders/ir_to_mesa.cpp
You can then use the new expression from builtins (if all backends
would rather see it), or scan the IR and convert to use your new
expression type (see ir_mod_to_fract, for example).
Q: How is memory management handled in the compiler?
The hierarchical memory allocator "talloc" developed for the Samba
project is used, so that things like optimization passes don't have to
worry about their garbage collection so much. It has a few nice
features, including low performance overhead and good debugging
support that's trivially available.
Generally, each stage of the compile creates a talloc context and
allocates its memory out of that or children of it. At the end of the
stage, the pieces still live are stolen to a new context and the old
one freed, or the whole context is kept for use by the next stage.
For IR transformations, a temporary context is used, then at the end
of all transformations, reparent_ir reparents all live nodes under the
shader's IR list, and the old context full of dead nodes is freed.
When developing a single IR transformation pass, this means that you
want to allocate instruction nodes out of the temporary context, so if
it becomes dead it doesn't live on as the child of a live node. At
the moment, optimization passes aren't passed that temporary context,
so they find it by calling talloc_parent() on a nearby IR node. The
talloc_parent() call is expensive, so many passes will cache the
result of the first talloc_parent(). Cleaning up all the optimization
passes to take a context argument and not call talloc_parent() is left
as an exercise.
Q: What is the file naming convention in this directory?
Initially, there really wasn't one. We have since adopted one:
- Files that implement code lowering passes should be named lower_*
(e.g., lower_noise.cpp).
- Files that implement optimization passes should be named opt_*.
- Files that implement a class that is used throught the code should
take the name of that class (e.g., ir_hierarchical_visitor.cpp).
- Files that contain code not fitting in one of the previous
categories should have a sensible name (e.g., glsl_parser.ypp).

View File

@@ -0,0 +1,183 @@
import common
Import('*')
from sys import executable as python_cmd
env = env.Clone()
env.Prepend(CPPPATH = [
'#include',
'#src/mapi',
'#src/mesa',
'#src/glsl',
'#src/glsl/glcpp',
])
# Make glcpp/glcpp-parse.h and glsl_parser.h reacheable from the include path
env.Append(CPPPATH = [Dir('.').abspath])
env.Append(YACCFLAGS = '-d')
parser_env = env.Clone()
parser_env.Append(YACCFLAGS = [
'--defines=%s' % File('glsl_parser.h').abspath,
'-p', '_mesa_glsl_',
])
glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l')
glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y')
glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll')
glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy')
glsl_sources = [
glcpp_lexer,
glcpp_parser[0],
'glcpp/pp.c',
'ast_expr.cpp',
'ast_function.cpp',
'ast_to_hir.cpp',
'ast_type.cpp',
glsl_lexer,
glsl_parser[0],
'glsl_parser_extras.cpp',
'glsl_types.cpp',
'glsl_symbol_table.cpp',
'hir_field_selection.cpp',
'ir_basic_block.cpp',
'ir_clone.cpp',
'ir_constant_expression.cpp',
'ir.cpp',
'ir_expression_flattening.cpp',
'ir_function_can_inline.cpp',
'ir_function_detect_recursion.cpp',
'ir_function.cpp',
'ir_hierarchical_visitor.cpp',
'ir_hv_accept.cpp',
'ir_import_prototypes.cpp',
'ir_print_visitor.cpp',
'ir_reader.cpp',
'ir_rvalue_visitor.cpp',
'ir_set_program_inouts.cpp',
'ir_validate.cpp',
'ir_variable.cpp',
'ir_variable_refcount.cpp',
'linker.cpp',
'link_functions.cpp',
'loop_analysis.cpp',
'loop_controls.cpp',
'loop_unroll.cpp',
'lower_discard.cpp',
'lower_if_to_cond_assign.cpp',
'lower_instructions.cpp',
'lower_jumps.cpp',
'lower_mat_op_to_vec.cpp',
'lower_noise.cpp',
'lower_variable_index_to_cond_assign.cpp',
'lower_vec_index_to_cond_assign.cpp',
'lower_vec_index_to_swizzle.cpp',
'lower_vector.cpp',
'opt_algebraic.cpp',
'opt_constant_folding.cpp',
'opt_constant_propagation.cpp',
'opt_constant_variable.cpp',
'opt_copy_propagation.cpp',
'opt_copy_propagation_elements.cpp',
'opt_dead_code.cpp',
'opt_dead_code_local.cpp',
'opt_dead_functions.cpp',
'opt_discard_simplification.cpp',
'opt_function_inlining.cpp',
'opt_if_simplification.cpp',
'opt_noop_swizzle.cpp',
'opt_redundant_jumps.cpp',
'opt_structure_splitting.cpp',
'opt_swizzle_swizzle.cpp',
'opt_tree_grafting.cpp',
'ralloc.c',
's_expression.cpp',
'standalone_scaffolding.cpp',
'strtod.c',
]
if env['msvc']:
env.Prepend(CPPPATH = ['#/src/getopt'])
env.PrependUnique(LIBS = [getopt])
if env['crosscompile'] and not env['embedded']:
Import('builtin_glsl_function')
else:
# Copy these files to avoid generation object files into src/mesa/program
env.Prepend(CPPPATH = ['#src/mesa/program'])
env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE'))
env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
main_obj = env.StaticObject('main.cpp')
mesa_objs = env.StaticObject([
'hash_table.c',
'symbol_table.c',
])
builtin_compiler = env.Program(
target = 'builtin_compiler',
source = main_obj + glsl_sources + ['builtin_stubs.cpp'] + mesa_objs,
)
# SCons builtin dependency scanner doesn't detect that glsl_lexer.ll
# depends on glsl_parser.h
env.Depends(builtin_compiler, glsl_parser)
builtin_glsl_function = env.CodeGenerate(
target = 'builtin_function.cpp',
script = 'builtins/tools/generate_builtins.py',
source = builtin_compiler,
command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
)
env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
Export('builtin_glsl_function')
if env['hostonly']:
Return()
glsl_sources += builtin_glsl_function
glsl = env.ConvenienceLibrary(
target = 'glsl',
source = glsl_sources,
)
# SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
# glsl_parser.h
env.Depends(glsl, glsl_parser)
Export('glsl')
# Skip building these programs as they will cause SCons error "Two environments
# with different actions were specified for the same target"
if env['crosscompile'] or env['embedded']:
Return()
env = env.Clone()
if env['platform'] == 'windows':
env.PrependUnique(LIBS = [
'user32',
])
env.Prepend(LIBS = [glsl])
glsl2 = env.Program(
target = 'glsl2',
source = main_obj + mesa_objs,
)
env.Alias('glsl2', glsl2)
glcpp = env.Program(
target = 'glcpp/glcpp',
source = ['glcpp/glcpp.c'] + mesa_objs,
)
env.Alias('glcpp', glcpp)

27
3rdparty/glsl-optimizer/src/glsl/TODO vendored Normal file
View File

@@ -0,0 +1,27 @@
- Detect code paths in non-void functions that don't reach a return statement
- Improve handling of constants and their initializers. Constant initializers
should never generate any code. This is trival for scalar constants. It is
also trivial for arrays, matrices, and vectors that are accessed with
constant index values. For others it is more complicated. Perhaps these
cases should be silently converted to uniforms?
- Implement support for ir_binop_dot in ir_algebraic.cpp. Perform
transformations such as "dot(v, vec3(0.0, 1.0, 0.0))" -> v.y.
- Track source locations throughout the IR. There are currently several
places where we cannot emit line numbers for errors (and currently emit 0:0)
because we've "lost" the line number information. This is particularly
noticeable at link time.
1.30 features:
- Implement AST-to-HIR conversion of switch-statements
- switch
- case
- Update break to correcly handle mixed nexting of switch-statements
and loops.
- Implement support for gl_ClipDistance. This is non-trivial because
gl_ClipDistance is exposed as a float[8], but all hardware actually
implements it as vec4[2].

744
3rdparty/glsl-optimizer/src/glsl/ast.h vendored Normal file
View File

@@ -0,0 +1,744 @@
/* -*- c++ -*- */
/*
* Copyright © 2009 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#ifndef AST_H
#define AST_H
#include "list.h"
#include "glsl_parser_extras.h"
struct _mesa_glsl_parse_state;
struct YYLTYPE;
/**
* \defgroup AST Abstract syntax tree node definitions
*
* An abstract syntax tree is generated by the parser. This is a fairly
* direct representation of the gramma derivation for the source program.
* No symantic checking is done during the generation of the AST. Only
* syntactic checking is done. Symantic checking is performed by a later
* stage that converts the AST to a more generic intermediate representation.
*
*@{
*/
/**
* Base class of all abstract syntax tree nodes
*/
class ast_node {
public:
/* Callers of this ralloc-based new need not call delete. It's
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
static void* operator new(size_t size, void *ctx)
{
void *node;
node = rzalloc_size(ctx, size);
assert(node != NULL);
return node;
}
/* If the user *does* call delete, that's OK, we will just
* ralloc_free in that case. */
static void operator delete(void *table)
{
ralloc_free(table);
}
/**
* Print an AST node in something approximating the original GLSL code
*/
virtual void print(void) const;
/**
* Convert the AST node to the high-level intermediate representation
*/
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
/**
* Retrieve the source location of an AST node
*
* This function is primarily used to get the source position of an AST node
* into a form that can be passed to \c _mesa_glsl_error.
*
* \sa _mesa_glsl_error, ast_node::set_location
*/
struct YYLTYPE get_location(void) const
{
struct YYLTYPE locp;
locp.source = this->location.source;
locp.first_line = this->location.line;
locp.first_column = this->location.column;
locp.last_line = locp.first_line;
locp.last_column = locp.first_column;
return locp;
}
/**
* Set the source location of an AST node from a parser location
*
* \sa ast_node::get_location
*/
void set_location(const struct YYLTYPE &locp)
{
this->location.source = locp.source;
this->location.line = locp.first_line;
this->location.column = locp.first_column;
}
/**
* Source location of the AST node.
*/
struct {
unsigned source; /**< GLSL source number. */
unsigned line; /**< Line number within the source string. */
unsigned column; /**< Column in the line. */
} location;
exec_node link;
protected:
/**
* The only constructor is protected so that only derived class objects can
* be created.
*/
ast_node(void);
};
/**
* Operators for AST expression nodes.
*/
enum ast_operators {
ast_assign,
ast_plus, /**< Unary + operator. */
ast_neg,
ast_add,
ast_sub,
ast_mul,
ast_div,
ast_mod,
ast_lshift,
ast_rshift,
ast_less,
ast_greater,
ast_lequal,
ast_gequal,
ast_equal,
ast_nequal,
ast_bit_and,
ast_bit_xor,
ast_bit_or,
ast_bit_not,
ast_logic_and,
ast_logic_xor,
ast_logic_or,
ast_logic_not,
ast_mul_assign,
ast_div_assign,
ast_mod_assign,
ast_add_assign,
ast_sub_assign,
ast_ls_assign,
ast_rs_assign,
ast_and_assign,
ast_xor_assign,
ast_or_assign,
ast_conditional,
ast_pre_inc,
ast_pre_dec,
ast_post_inc,
ast_post_dec,
ast_field_selection,
ast_array_index,
ast_function_call,
ast_identifier,
ast_int_constant,
ast_uint_constant,
ast_float_constant,
ast_bool_constant,
ast_sequence
};
/**
* Representation of any sort of expression.
*/
class ast_expression : public ast_node {
public:
ast_expression(int oper, ast_expression *,
ast_expression *, ast_expression *);
ast_expression(const char *identifier) :
oper(ast_identifier)
{
subexpressions[0] = NULL;
subexpressions[1] = NULL;
subexpressions[2] = NULL;
primary_expression.identifier = (char *) identifier;
}
static const char *operator_string(enum ast_operators op);
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
virtual void print(void) const;
enum ast_operators oper;
ast_expression *subexpressions[3];
union {
char *identifier;
int int_constant;
float float_constant;
unsigned uint_constant;
int bool_constant;
} primary_expression;
/**
* List of expressions for an \c ast_sequence or parameters for an
* \c ast_function_call
*/
exec_list expressions;
};
class ast_expression_bin : public ast_expression {
public:
ast_expression_bin(int oper, ast_expression *, ast_expression *);
virtual void print(void) const;
};
/**
* Subclass of expressions for function calls
*/
class ast_function_expression : public ast_expression {
public:
ast_function_expression(ast_expression *callee)
: ast_expression(ast_function_call, callee,
NULL, NULL),
cons(false)
{
/* empty */
}
ast_function_expression(class ast_type_specifier *type)
: ast_expression(ast_function_call, (ast_expression *) type,
NULL, NULL),
cons(true)
{
/* empty */
}
bool is_constructor() const
{
return cons;
}
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
private:
/**
* Is this function call actually a constructor?
*/
bool cons;
};
/**
* Number of possible operators for an ast_expression
*
* This is done as a define instead of as an additional value in the enum so
* that the compiler won't generate spurious messages like "warning:
* enumeration value ast_num_operators not handled in switch"
*/
#define AST_NUM_OPERATORS (ast_sequence + 1)
class ast_compound_statement : public ast_node {
public:
ast_compound_statement(int new_scope, ast_node *statements);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
int new_scope;
exec_list statements;
};
class ast_declaration : public ast_node {
public:
ast_declaration(char *identifier, int is_array, ast_expression *array_size,
ast_expression *initializer);
virtual void print(void) const;
char *identifier;
int is_array;
ast_expression *array_size;
ast_expression *initializer;
};
enum {
ast_precision_high = 0,
ast_precision_medium,
ast_precision_low,
ast_precision_none, /**< Absence of precision qualifier. */
};
struct ast_type_qualifier {
union {
struct {
unsigned invariant:1;
unsigned constant:1;
unsigned attribute:1;
unsigned varying:1;
unsigned in:1;
unsigned out:1;
unsigned centroid:1;
unsigned uniform:1;
unsigned smooth:1;
unsigned flat:1;
unsigned noperspective:1;
/** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */
/*@{*/
unsigned origin_upper_left:1;
unsigned pixel_center_integer:1;
/*@}*/
/**
* Flag set if GL_ARB_explicit_attrib_location "location" layout
* qualifier is used.
*/
unsigned explicit_location:1;
/** \name Layout qualifiers for GL_AMD_conservative_depth */
/** \{ */
unsigned depth_any:1;
unsigned depth_greater:1;
unsigned depth_less:1;
unsigned depth_unchanged:1;
/** \} */
}
/** \brief Set of flags, accessed by name. */
q;
/** \brief Set of flags, accessed as a bitmask. */
unsigned i;
} flags;
/**
* Location specified via GL_ARB_explicit_attrib_location layout
*
* \note
* This field is only valid if \c explicit_location is set.
*/
unsigned location;
/**
* Return true if and only if an interpolation qualifier is present.
*/
bool has_interpolation() const;
/**
* \brief Return string representation of interpolation qualifier.
*
* If an interpolation qualifier is present, then return that qualifier's
* string representation. Otherwise, return null. For example, if the
* noperspective bit is set, then this returns "noperspective".
*
* If multiple interpolation qualifiers are somehow present, then the
* returned string is undefined but not null.
*/
const char *interpolation_string() const;
};
class ast_struct_specifier : public ast_node {
public:
ast_struct_specifier(char *identifier, ast_node *declarator_list);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
char *name;
exec_list declarations;
};
enum ast_types {
ast_void,
ast_float,
ast_int,
ast_uint,
ast_bool,
ast_vec2,
ast_vec3,
ast_vec4,
ast_bvec2,
ast_bvec3,
ast_bvec4,
ast_ivec2,
ast_ivec3,
ast_ivec4,
ast_uvec2,
ast_uvec3,
ast_uvec4,
ast_mat2,
ast_mat2x3,
ast_mat2x4,
ast_mat3x2,
ast_mat3,
ast_mat3x4,
ast_mat4x2,
ast_mat4x3,
ast_mat4,
ast_sampler1d,
ast_sampler2d,
ast_sampler2drect,
ast_sampler3d,
ast_samplercube,
ast_sampler1dshadow,
ast_sampler2dshadow,
ast_sampler2drectshadow,
ast_samplercubeshadow,
ast_sampler1darray,
ast_sampler2darray,
ast_sampler1darrayshadow,
ast_sampler2darrayshadow,
ast_isampler1d,
ast_isampler2d,
ast_isampler3d,
ast_isamplercube,
ast_isampler1darray,
ast_isampler2darray,
ast_usampler1d,
ast_usampler2d,
ast_usampler3d,
ast_usamplercube,
ast_usampler1darray,
ast_usampler2darray,
ast_struct,
ast_type_name
};
class ast_type_specifier : public ast_node {
public:
ast_type_specifier(int specifier);
/** Construct a type specifier from a type name */
ast_type_specifier(const char *name)
: type_specifier(ast_type_name), type_name(name), structure(NULL),
is_array(false), array_size(NULL), precision(ast_precision_none),
is_precision_statement(false)
{
/* empty */
}
/** Construct a type specifier from a structure definition */
ast_type_specifier(ast_struct_specifier *s)
: type_specifier(ast_struct), type_name(s->name), structure(s),
is_array(false), array_size(NULL), precision(ast_precision_none),
is_precision_statement(false)
{
/* empty */
}
const struct glsl_type *glsl_type(const char **name,
struct _mesa_glsl_parse_state *state)
const;
virtual void print(void) const;
ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
enum ast_types type_specifier;
const char *type_name;
ast_struct_specifier *structure;
int is_array;
ast_expression *array_size;
unsigned precision:2;
bool is_precision_statement;
};
class ast_fully_specified_type : public ast_node {
public:
ast_fully_specified_type ()
{
union {
ast_type_qualifier q;
unsigned i;
} q;
q.i = 0;
qualifier = q.q;
}
virtual void print(void) const;
bool has_qualifiers() const;
ast_type_qualifier qualifier;
ast_type_specifier *specifier;
};
class ast_declarator_list : public ast_node {
public:
ast_declarator_list(ast_fully_specified_type *);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
ast_fully_specified_type *type;
exec_list declarations;
/**
* Special flag for vertex shader "invariant" declarations.
*
* Vertex shaders can contain "invariant" variable redeclarations that do
* not include a type. For example, "invariant gl_Position;". This flag
* is used to note these cases when no type is specified.
*/
int invariant;
};
class ast_parameter_declarator : public ast_node {
public:
ast_parameter_declarator()
{
this->identifier = NULL;
this->is_array = false;
this->array_size = 0;
}
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
ast_fully_specified_type *type;
char *identifier;
int is_array;
ast_expression *array_size;
static void parameters_to_hir(exec_list *ast_parameters,
bool formal, exec_list *ir_parameters,
struct _mesa_glsl_parse_state *state);
private:
/** Is this parameter declaration part of a formal parameter list? */
bool formal_parameter;
/**
* Is this parameter 'void' type?
*
* This field is set by \c ::hir.
*/
bool is_void;
};
class ast_function : public ast_node {
public:
ast_function(void);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
ast_fully_specified_type *return_type;
char *identifier;
exec_list parameters;
private:
/**
* Is this prototype part of the function definition?
*
* Used by ast_function_definition::hir to process the parameters, etc.
* of the function.
*
* \sa ::hir
*/
bool is_definition;
/**
* Function signature corresponding to this function prototype instance
*
* Used by ast_function_definition::hir to process the parameters, etc.
* of the function.
*
* \sa ::hir
*/
class ir_function_signature *signature;
friend class ast_function_definition;
};
class ast_expression_statement : public ast_node {
public:
ast_expression_statement(ast_expression *);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
ast_expression *expression;
};
class ast_case_label : public ast_node {
public:
/**
* An expression of NULL means 'default'.
*/
ast_expression *expression;
};
class ast_selection_statement : public ast_node {
public:
ast_selection_statement(ast_expression *condition,
ast_node *then_statement,
ast_node *else_statement);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
ast_expression *condition;
ast_node *then_statement;
ast_node *else_statement;
};
class ast_switch_statement : public ast_node {
public:
ast_expression *expression;
exec_list statements;
};
class ast_iteration_statement : public ast_node {
public:
ast_iteration_statement(int mode, ast_node *init, ast_node *condition,
ast_expression *rest_expression, ast_node *body);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
enum ast_iteration_modes {
ast_for,
ast_while,
ast_do_while
} mode;
ast_node *init_statement;
ast_node *condition;
ast_expression *rest_expression;
ast_node *body;
private:
/**
* Generate IR from the condition of a loop
*
* This is factored out of ::hir because some loops have the condition
* test at the top (for and while), and others have it at the end (do-while).
*/
void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *);
};
class ast_jump_statement : public ast_node {
public:
ast_jump_statement(int mode, ast_expression *return_value);
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
enum ast_jump_modes {
ast_continue,
ast_break,
ast_return,
ast_discard
} mode;
ast_expression *opt_return_value;
};
class ast_function_definition : public ast_node {
public:
virtual void print(void) const;
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
ast_function *prototype;
ast_compound_statement *body;
};
/*@}*/
extern void
_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state);
extern ir_rvalue *
_mesa_ast_field_selection_to_hir(const ast_expression *expr,
exec_list *instructions,
struct _mesa_glsl_parse_state *state);
void
emit_function(_mesa_glsl_parse_state *state, ir_function *f);
#endif /* AST_H */

View File

@@ -0,0 +1,95 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <assert.h>
#include "ast.h"
const char *
ast_expression::operator_string(enum ast_operators op)
{
static const char *const operators[] = {
"=",
"+",
"-",
"+",
"-",
"*",
"/",
"%",
"<<",
">>",
"<",
">",
"<=",
">=",
"==",
"!=",
"&",
"^",
"|",
"~",
"&&",
"^^",
"||",
"!",
"*=",
"/=",
"%=",
"+=",
"-=",
"<<=",
">>=",
"&=",
"^=",
"|=",
"?:",
"++",
"--",
"++",
"--",
".",
};
assert((unsigned int)op < sizeof(operators) / sizeof(operators[0]));
return operators[op];
}
ast_expression_bin::ast_expression_bin(int oper, ast_expression *ex0,
ast_expression *ex1) :
ast_expression(oper, ex0, ex1, NULL)
{
assert((oper >= ast_plus) && (oper <= ast_logic_not));
}
void
ast_expression_bin::print(void) const
{
subexpressions[0]->print();
printf("%s ", operator_string(oper));
subexpressions[1]->print();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,138 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "ast.h"
extern "C" {
#include "program/symbol_table.h"
}
void
ast_type_specifier::print(void) const
{
if (type_specifier == ast_struct) {
structure->print();
} else {
printf("%s ", type_name);
}
if (is_array) {
printf("[ ");
if (array_size) {
array_size->print();
}
printf("] ");
}
}
ast_type_specifier::ast_type_specifier(int specifier)
: type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL),
is_array(false), array_size(NULL), precision(ast_precision_none),
is_precision_statement(false)
{
static const char *const names[] = {
"void",
"float",
"int",
"uint",
"bool",
"vec2",
"vec3",
"vec4",
"bvec2",
"bvec3",
"bvec4",
"ivec2",
"ivec3",
"ivec4",
"uvec2",
"uvec3",
"uvec4",
"mat2",
"mat2x3",
"mat2x4",
"mat3x2",
"mat3",
"mat3x4",
"mat4x2",
"mat4x3",
"mat4",
"sampler1D",
"sampler2D",
"sampler2DRect",
"sampler3D",
"samplerCube",
"sampler1DShadow",
"sampler2DShadow",
"sampler2DRectShadow",
"samplerCubeShadow",
"sampler1DArray",
"sampler2DArray",
"sampler1DArrayShadow",
"sampler2DArrayShadow",
"isampler1D",
"isampler2D",
"isampler3D",
"isamplerCube",
"isampler1DArray",
"isampler2DArray",
"usampler1D",
"usampler2D",
"usampler3D",
"usamplerCube",
"usampler1DArray",
"usampler2DArray",
NULL, /* ast_struct */
NULL /* ast_type_name */
};
type_name = names[specifier];
}
bool
ast_fully_specified_type::has_qualifiers() const
{
return this->qualifier.flags.i != 0;
}
bool ast_type_qualifier::has_interpolation() const
{
return this->flags.q.smooth
|| this->flags.q.flat
|| this->flags.q.noperspective;
}
const char*
ast_type_qualifier::interpolation_string() const
{
if (this->flags.q.smooth)
return "smooth";
else if (this->flags.q.flat)
return "flat";
else if (this->flags.q.noperspective)
return "noperspective";
else
return NULL;
}

View File

@@ -0,0 +1,12 @@
#! /bin/sh
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?
$srcdir/configure --enable-maintainer-mode "$@"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include "glsl_parser_extras.h"
/* A dummy file. When compiling prototypes, we don't care about builtins.
* We really don't want to half-compile builtin_functions.cpp and fail, though.
*/
void
_mesa_glsl_release_functions(void)
{
}
void
_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state)
{
}

View File

@@ -0,0 +1,302 @@
/*
* Copyright © 2009 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
const glsl_type glsl_type::_error_type =
glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, "");
const glsl_type glsl_type::_void_type =
glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void");
const glsl_type glsl_type::_sampler3D_type =
glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
"sampler3D");
const glsl_type *const glsl_type::error_type = & glsl_type::_error_type;
const glsl_type *const glsl_type::void_type = & glsl_type::_void_type;
/** \name Core built-in types
*
* These types exist in all versions of GLSL.
*/
/*@{*/
const glsl_type glsl_type::builtin_core_types[] = {
glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"),
glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"),
glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"),
glsl_type(GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1, "bvec4"),
glsl_type(GL_INT, GLSL_TYPE_INT, 1, 1, "int"),
glsl_type(GL_INT_VEC2, GLSL_TYPE_INT, 2, 1, "ivec2"),
glsl_type(GL_INT_VEC3, GLSL_TYPE_INT, 3, 1, "ivec3"),
glsl_type(GL_INT_VEC4, GLSL_TYPE_INT, 4, 1, "ivec4"),
glsl_type(GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1, "float"),
glsl_type(GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1, "vec2"),
glsl_type(GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1, "vec3"),
glsl_type(GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1, "vec4"),
glsl_type(GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2, "mat2"),
glsl_type(GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3, "mat3"),
glsl_type(GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4, "mat4"),
glsl_type(GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT,
"sampler2D"),
glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT,
"samplerCube"),
};
const glsl_type *const glsl_type::bool_type = & builtin_core_types[0];
const glsl_type *const glsl_type::int_type = & builtin_core_types[4];
const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7];
const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10];
const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11];
const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12];
const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13];
const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14];
/*@}*/
/** \name GLSL structures that have not been deprecated.
*/
/*@{*/
static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
{ glsl_type::float_type, "near" },
{ glsl_type::float_type, "far" },
{ glsl_type::float_type, "diff" },
};
const glsl_type glsl_type::builtin_structure_types[] = {
glsl_type(gl_DepthRangeParameters_fields,
Elements(gl_DepthRangeParameters_fields),
"gl_DepthRangeParameters"),
};
/*@}*/
/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30
*/
/*@{*/
static const struct glsl_struct_field gl_PointParameters_fields[] = {
{ glsl_type::float_type, "size" },
{ glsl_type::float_type, "sizeMin" },
{ glsl_type::float_type, "sizeMax" },
{ glsl_type::float_type, "fadeThresholdSize" },
{ glsl_type::float_type, "distanceConstantAttenuation" },
{ glsl_type::float_type, "distanceLinearAttenuation" },
{ glsl_type::float_type, "distanceQuadraticAttenuation" },
};
static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
{ glsl_type::vec4_type, "emission" },
{ glsl_type::vec4_type, "ambient" },
{ glsl_type::vec4_type, "diffuse" },
{ glsl_type::vec4_type, "specular" },
{ glsl_type::float_type, "shininess" },
};
static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
{ glsl_type::vec4_type, "ambient" },
{ glsl_type::vec4_type, "diffuse" },
{ glsl_type::vec4_type, "specular" },
{ glsl_type::vec4_type, "position" },
{ glsl_type::vec4_type, "halfVector" },
{ glsl_type::vec3_type, "spotDirection" },
{ glsl_type::float_type, "spotExponent" },
{ glsl_type::float_type, "spotCutoff" },
{ glsl_type::float_type, "spotCosCutoff" },
{ glsl_type::float_type, "constantAttenuation" },
{ glsl_type::float_type, "linearAttenuation" },
{ glsl_type::float_type, "quadraticAttenuation" },
};
static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
{ glsl_type::vec4_type, "ambient" },
};
static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
{ glsl_type::vec4_type, "sceneColor" },
};
static const struct glsl_struct_field gl_LightProducts_fields[] = {
{ glsl_type::vec4_type, "ambient" },
{ glsl_type::vec4_type, "diffuse" },
{ glsl_type::vec4_type, "specular" },
};
static const struct glsl_struct_field gl_FogParameters_fields[] = {
{ glsl_type::vec4_type, "color" },
{ glsl_type::float_type, "density" },
{ glsl_type::float_type, "start" },
{ glsl_type::float_type, "end" },
{ glsl_type::float_type, "scale" },
};
const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = {
glsl_type(gl_PointParameters_fields,
Elements(gl_PointParameters_fields),
"gl_PointParameters"),
glsl_type(gl_MaterialParameters_fields,
Elements(gl_MaterialParameters_fields),
"gl_MaterialParameters"),
glsl_type(gl_LightSourceParameters_fields,
Elements(gl_LightSourceParameters_fields),
"gl_LightSourceParameters"),
glsl_type(gl_LightModelParameters_fields,
Elements(gl_LightModelParameters_fields),
"gl_LightModelParameters"),
glsl_type(gl_LightModelProducts_fields,
Elements(gl_LightModelProducts_fields),
"gl_LightModelProducts"),
glsl_type(gl_LightProducts_fields,
Elements(gl_LightProducts_fields),
"gl_LightProducts"),
glsl_type(gl_FogParameters_fields,
Elements(gl_FogParameters_fields),
"gl_FogParameters"),
};
/*@}*/
/** \name Types in GLSL 1.10 (but not GLSL ES 1.00)
*/
/*@{*/
const glsl_type glsl_type::builtin_110_types[] = {
glsl_type(GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT,
"sampler1D"),
glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT,
"sampler1DShadow"),
glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT,
"sampler2DShadow"),
};
/*@}*/
/** \name Types added in GLSL 1.20
*/
/*@{*/
const glsl_type glsl_type::builtin_120_types[] = {
glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"),
glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"),
glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"),
glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"),
glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"),
glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"),
};
const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0];
const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1];
const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2];
const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3];
const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4];
const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5];
/*@}*/
/** \name Types added in GLSL 1.30
*/
/*@{*/
const glsl_type glsl_type::builtin_130_types[] = {
glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"),
glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"),
glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"),
glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"),
/* 1D and 2D texture arrays - several of these are included only in
* builtin_EXT_texture_array_types.
*/
glsl_type(GL_INT_SAMPLER_1D_ARRAY,
GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"),
glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY,
GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"),
glsl_type(GL_INT_SAMPLER_2D_ARRAY,
GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"),
glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY,
GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"),
/* cube shadow samplers */
glsl_type(GL_SAMPLER_CUBE_SHADOW,
GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"),
/* signed and unsigned integer samplers */
glsl_type(GL_INT_SAMPLER_1D,
GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"),
glsl_type(GL_UNSIGNED_INT_SAMPLER_1D,
GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"),
glsl_type(GL_INT_SAMPLER_2D,
GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"),
glsl_type(GL_UNSIGNED_INT_SAMPLER_2D,
GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"),
glsl_type(GL_INT_SAMPLER_3D,
GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"),
glsl_type(GL_UNSIGNED_INT_SAMPLER_3D,
GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"),
glsl_type(GL_INT_SAMPLER_CUBE,
GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"),
glsl_type(GL_INT_SAMPLER_CUBE,
GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"),
};
const glsl_type *const glsl_type::uint_type = & builtin_130_types[0];
const glsl_type *const glsl_type::uvec2_type = & builtin_130_types[1];
const glsl_type *const glsl_type::uvec3_type = & builtin_130_types[2];
const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3];
/*@}*/
/** \name Sampler types added by GL_ARB_texture_rectangle
*/
/*@{*/
const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = {
glsl_type(GL_SAMPLER_2D_RECT,
GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"),
glsl_type(GL_SAMPLER_2D_RECT_SHADOW,
GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"),
};
/*@}*/
/** \name Sampler types added by GL_EXT_texture_array
*/
/*@{*/
const glsl_type glsl_type::builtin_EXT_texture_array_types[] = {
glsl_type(GL_SAMPLER_1D_ARRAY,
GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
glsl_type(GL_SAMPLER_2D_ARRAY,
GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW,
GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW,
GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),
};
/*@}*/
/** \name Sampler types added by GL_EXT_texture_buffer_object
*/
/*@{*/
const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = {
glsl_type(GL_SAMPLER_BUFFER,
GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"),
glsl_type(GL_INT_SAMPLER_BUFFER,
GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"),
glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER,
GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"),
};
/*@}*/

View File

@@ -0,0 +1,110 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "main/core.h" /* for slot numbers */
struct builtin_variable {
enum ir_variable_mode mode;
int slot;
const char *type;
const char *name;
};
static const builtin_variable builtin_core_vs_variables[] = {
{ ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" },
{ ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" },
};
static const builtin_variable builtin_core_fs_variables[] = {
{ ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" },
{ ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" },
{ ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" },
};
static const builtin_variable builtin_100ES_fs_variables[] = {
{ ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" },
};
static const builtin_variable builtin_110_fs_variables[] = {
{ ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" },
};
static const builtin_variable builtin_110_deprecated_fs_variables[] = {
{ ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" },
{ ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" },
{ ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" },
};
static const builtin_variable builtin_110_deprecated_vs_variables[] = {
{ ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" },
{ ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" },
{ ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" },
{ ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" },
{ ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" },
{ ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" },
{ ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" },
{ ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" },
{ ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" },
{ ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" },
{ ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" },
{ ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" },
{ ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" },
{ ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_ClipVertex" },
{ ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" },
{ ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" },
{ ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" },
{ ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" },
{ ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" },
};
static const builtin_variable builtin_120_fs_variables[] = {
{ ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" },
};
static const builtin_variable builtin_130_vs_variables[] = {
{ ir_var_in, -1, "int", "gl_VertexID" },
};
static const builtin_variable builtin_110_deprecated_uniforms[] = {
{ ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" },
{ ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" },
{ ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" },
{ ir_var_uniform, -1, "mat3", "gl_NormalMatrix" },
{ ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" },
{ ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" },
{ ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" },
{ ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" },
{ ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" },
{ ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" },
{ ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" },
{ ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" },
{ ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" },
{ ir_var_uniform, -1, "float", "gl_NormalScale" },
{ ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"},
/* Mesa-internal ATI_envmap_bumpmap state. */
{ ir_var_uniform, -1, "vec2", "gl_MESABumpRotMatrix0"},
{ ir_var_uniform, -1, "vec2", "gl_MESABumpRotMatrix1"},
{ ir_var_uniform, -1, "vec4", "gl_MESAFogParamsOptimized"},
};

View File

@@ -0,0 +1,41 @@
((function abs
(signature float
(parameters
(declare (in) float arg0))
((return (expression float abs (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 abs (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 abs (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 abs (var_ref arg0)))))
(signature int
(parameters
(declare (in) int arg0))
((return (expression int abs (var_ref arg0)))))
(signature ivec2
(parameters
(declare (in) ivec2 arg0))
((return (expression ivec2 abs (var_ref arg0)))))
(signature ivec3
(parameters
(declare (in) ivec3 arg0))
((return (expression ivec3 abs (var_ref arg0)))))
(signature ivec4
(parameters
(declare (in) ivec4 arg0))
((return (expression ivec4 abs (var_ref arg0)))))
))

View File

@@ -0,0 +1,22 @@
((function acos
(signature float
(parameters
(declare (in) float x))
((return (expression float - (constant float (1.5707963))
(call asin ((var_ref x)))))))
(signature vec2
(parameters
(declare (in) vec2 x))
((return (expression vec2 - (constant float (1.5707963))
(call asin ((var_ref x)))))))
(signature vec3
(parameters
(declare (in) vec3 x))
((return (expression vec3 - (constant float (1.5707963))
(call asin ((var_ref x)))))))
(signature vec4
(parameters
(declare (in) vec4 x))
((return (expression vec4 - (constant float (1.5707963))
(call asin ((var_ref x)))))))
))

View File

@@ -0,0 +1,21 @@
((function acosh
(signature float
(parameters
(declare (in) float x))
((return (expression float log (expression float + (var_ref x) (expression float sqrt (expression float - (expression float * (var_ref x) (var_ref x)) (constant float (1)))))))))
(signature vec2
(parameters
(declare (in) vec2 x))
((return (expression vec2 log (expression vec2 + (var_ref x) (expression vec2 sqrt (expression vec2 - (expression vec2 * (var_ref x) (var_ref x)) (constant vec2 (1)))))))))
(signature vec3
(parameters
(declare (in) vec3 x))
((return (expression vec3 log (expression vec3 + (var_ref x) (expression vec3 sqrt (expression vec3 - (expression vec3 * (var_ref x) (var_ref x)) (constant vec3 (1)))))))))
(signature vec4
(parameters
(declare (in) vec4 x))
((return (expression vec4 log (expression vec4 + (var_ref x) (expression vec4 sqrt (expression vec4 - (expression vec4 * (var_ref x) (var_ref x)) (constant vec4 (1)))))))))
))

View File

@@ -0,0 +1,16 @@
((function all
(signature bool
(parameters
(declare (in) bvec2 arg0))
((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))
(signature bool
(parameters
(declare (in) bvec3 arg0))
((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))
(signature bool
(parameters
(declare (in) bvec4 arg0))
((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))
))

View File

@@ -0,0 +1,16 @@
((function any
(signature bool
(parameters
(declare (in) bvec2 arg0))
((return (expression bool any (var_ref arg0)))))
(signature bool
(parameters
(declare (in) bvec3 arg0))
((return (expression bool any (var_ref arg0)))))
(signature bool
(parameters
(declare (in) bvec4 arg0))
((return (expression bool any (var_ref arg0)))))
))

View File

@@ -0,0 +1,109 @@
((function asin
(signature float
(parameters
(declare (in) float x))
((return (expression float *
(expression float sign (var_ref x))
(expression float -
(constant float (1.5707964))
(expression float *
(expression float sqrt
(expression float -
(constant float (1.0))
(expression float abs (var_ref x))))
(expression float +
(constant float (1.5707964))
(expression float *
(expression float abs (var_ref x))
(expression float +
(constant float (-0.21460183))
(expression float *
(expression float abs (var_ref x))
(expression float +
(constant float (0.086566724))
(expression float *
(expression float abs (var_ref x))
(constant float (-0.03102955))
))))))))))))
(signature vec2
(parameters
(declare (in) vec2 x))
((return (expression vec2 *
(expression vec2 sign (var_ref x))
(expression vec2 -
(constant float (1.5707964))
(expression vec2 *
(expression vec2 sqrt
(expression vec2 -
(constant float (1.0))
(expression vec2 abs (var_ref x))))
(expression vec2 +
(constant float (1.5707964))
(expression vec2 *
(expression vec2 abs (var_ref x))
(expression vec2 +
(constant float (-0.21460183))
(expression vec2 *
(expression vec2 abs (var_ref x))
(expression vec2 +
(constant float (0.086566724))
(expression vec2 *
(expression vec2 abs (var_ref x))
(constant float (-0.03102955))
))))))))))))
(signature vec3
(parameters
(declare (in) vec3 x))
((return (expression vec3 *
(expression vec3 sign (var_ref x))
(expression vec3 -
(constant float (1.5707964))
(expression vec3 *
(expression vec3 sqrt
(expression vec3 -
(constant float (1.0))
(expression vec3 abs (var_ref x))))
(expression vec3 +
(constant float (1.5707964))
(expression vec3 *
(expression vec3 abs (var_ref x))
(expression vec3 +
(constant float (-0.21460183))
(expression vec3 *
(expression vec3 abs (var_ref x))
(expression vec3 +
(constant float (0.086566724))
(expression vec3 *
(expression vec3 abs (var_ref x))
(constant float (-0.03102955))
))))))))))))
(signature vec4
(parameters
(declare (in) vec4 x))
((return (expression vec4 *
(expression vec4 sign (var_ref x))
(expression vec4 -
(constant float (1.5707964))
(expression vec4 *
(expression vec4 sqrt
(expression vec4 -
(constant float (1.0))
(expression vec4 abs (var_ref x))))
(expression vec4 +
(constant float (1.5707964))
(expression vec4 *
(expression vec4 abs (var_ref x))
(expression vec4 +
(constant float (-0.21460183))
(expression vec4 *
(expression vec4 abs (var_ref x))
(expression vec4 +
(constant float (0.086566724))
(expression vec4 *
(expression vec4 abs (var_ref x))
(constant float (-0.03102955))
))))))))))))
))

View File

@@ -0,0 +1,21 @@
((function asinh
(signature float
(parameters
(declare (in) float x))
((return (expression float log (expression float + (var_ref x) (expression float sqrt (expression float + (expression float * (var_ref x) (var_ref x)) (constant float (1)))))))))
(signature vec2
(parameters
(declare (in) vec2 x))
((return (expression vec2 log (expression vec2 + (var_ref x) (expression vec2 sqrt (expression vec2 + (expression vec2 * (var_ref x) (var_ref x)) (constant vec2 (1)))))))))
(signature vec3
(parameters
(declare (in) vec3 x))
((return (expression vec3 log (expression vec3 + (var_ref x) (expression vec3 sqrt (expression vec3 + (expression vec3 * (var_ref x) (var_ref x)) (constant vec3 (1)))))))))
(signature vec4
(parameters
(declare (in) vec4 x))
((return (expression vec4 log (expression vec4 + (var_ref x) (expression vec4 sqrt (expression vec4 + (expression vec4 * (var_ref x) (var_ref x)) (constant vec4 (1)))))))))
))

View File

@@ -0,0 +1,128 @@
((function atan
(signature float
(parameters
(declare (in) float y_over_x))
((return (call asin ((expression float *
(var_ref y_over_x)
(expression float rsq
(expression float +
(expression float *
(var_ref y_over_x)
(var_ref y_over_x))
(constant float (1.0))))))))))
(signature vec2
(parameters
(declare (in) vec2 y_over_x))
((return (call asin ((expression vec2 *
(var_ref y_over_x)
(expression vec2 rsq
(expression vec2 +
(expression vec2 *
(var_ref y_over_x)
(var_ref y_over_x))
(constant float (1.0))))))))))
(signature vec3
(parameters
(declare (in) vec3 y_over_x))
((return (call asin ((expression vec3 *
(var_ref y_over_x)
(expression vec3 rsq
(expression vec3 +
(expression vec3 *
(var_ref y_over_x)
(var_ref y_over_x))
(constant float (1.0))))))))))
(signature vec4
(parameters
(declare (in) vec4 y_over_x))
((return (call asin ((expression vec4 *
(var_ref y_over_x)
(expression vec4 rsq
(expression vec4 +
(expression vec4 *
(var_ref y_over_x)
(var_ref y_over_x))
(constant float (1.0))))))))))
(signature float
(parameters
(declare (in ) float y)
(declare (in ) float x)
)
(
(declare () float r)
(if (expression bool >
(expression float abs (var_ref x))
(expression float * (constant float (1.0e-8)) (expression float abs (var_ref y)))) (
(assign (x) (var_ref r) (call atan ((expression float / (var_ref y) (var_ref x)))))
(if (expression bool < (var_ref x) (constant float (0.000000)) ) (
(if (expression bool >= (var_ref y) (constant float (0.000000)) )
((assign (x) (var_ref r) (expression float + (var_ref r) (constant float (3.141593)))))
((assign (x) (var_ref r) (expression float - (var_ref r) (constant float (3.141593))))))
)
(
))
)
(
(declare () float sgn)
(assign (x) (var_ref sgn) (expression float sign (var_ref y)))
(assign (x) (var_ref r) (expression float * (var_ref sgn) (constant float (1.5707965))))
))
(return (var_ref r) )
))
(signature vec2
(parameters
(declare (in) vec2 y)
(declare (in) vec2 x))
((declare () vec2 r)
(assign (x) (var_ref r)
(call atan ((swiz x (var_ref y))
(swiz x (var_ref x)))))
(assign (y) (var_ref r)
(call atan ((swiz y (var_ref y))
(swiz y (var_ref x)))))
(return (var_ref r))))
(signature vec3
(parameters
(declare (in) vec3 y)
(declare (in) vec3 x))
((declare () vec3 r)
(assign (x) (var_ref r)
(call atan ((swiz x (var_ref y))
(swiz x (var_ref x)))))
(assign (y) (var_ref r)
(call atan ((swiz y (var_ref y))
(swiz y (var_ref x)))))
(assign (z) (var_ref r)
(call atan ((swiz z (var_ref y))
(swiz z (var_ref x)))))
(return (var_ref r))))
(signature vec4
(parameters
(declare (in) vec4 y)
(declare (in) vec4 x))
((declare () vec4 r)
(assign (x) (var_ref r)
(call atan ((swiz x (var_ref y))
(swiz x (var_ref x)))))
(assign (y) (var_ref r)
(call atan ((swiz y (var_ref y))
(swiz y (var_ref x)))))
(assign (z) (var_ref r)
(call atan ((swiz z (var_ref y))
(swiz z (var_ref x)))))
(assign (w) (var_ref r)
(call atan ((swiz w (var_ref y))
(swiz w (var_ref x)))))
(return (var_ref r)))))
))

View File

@@ -0,0 +1,37 @@
((function atanh
(signature float
(parameters
(declare (in) float x))
((return (expression float * (constant float (0.5))
(expression float log
(expression float /
(expression float + (constant float (1)) (var_ref x))
(expression float - (constant float (1)) (var_ref x))))))))
(signature vec2
(parameters
(declare (in) vec2 x))
((return (expression vec2 * (constant vec2 (0.5))
(expression vec2 log
(expression vec2 /
(expression vec2 + (constant vec2 (1)) (var_ref x))
(expression vec2 - (constant vec2 (1)) (var_ref x))))))))
(signature vec3
(parameters
(declare (in) vec3 x))
((return (expression vec3 * (constant vec3 (0.5))
(expression vec3 log
(expression vec3 /
(expression vec3 + (constant vec3 (1)) (var_ref x))
(expression vec3 - (constant vec3 (1)) (var_ref x))))))))
(signature vec4
(parameters
(declare (in) vec4 x))
((return (expression vec4 * (constant vec4 (0.5))
(expression vec4 log
(expression vec4 /
(expression vec4 + (constant vec4 (1)) (var_ref x))
(expression vec4 - (constant vec4 (1)) (var_ref x))))))))
))

View File

@@ -0,0 +1,21 @@
((function ceil
(signature float
(parameters
(declare (in) float arg0))
((return (expression float ceil (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 ceil (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 ceil (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 ceil (var_ref arg0)))))
))

View File

@@ -0,0 +1,148 @@
((function clamp
(signature float
(parameters
(declare (in) float arg0)
(declare (in) float arg1)
(declare (in) float arg2))
((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature vec2
(parameters
(declare (in) vec2 arg0)
(declare (in) vec2 arg1)
(declare (in) vec2 arg2))
((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature vec3
(parameters
(declare (in) vec3 arg0)
(declare (in) vec3 arg1)
(declare (in) vec3 arg2))
((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature vec4
(parameters
(declare (in) vec4 arg0)
(declare (in) vec4 arg1)
(declare (in) vec4 arg2))
((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature vec2
(parameters
(declare (in) vec2 arg0)
(declare (in) float arg1)
(declare (in) float arg2))
((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature vec3
(parameters
(declare (in) vec3 arg0)
(declare (in) float arg1)
(declare (in) float arg2))
((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature vec4
(parameters
(declare (in) vec4 arg0)
(declare (in) float arg1)
(declare (in) float arg2))
((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature int
(parameters
(declare (in) int arg0)
(declare (in) int arg1)
(declare (in) int arg2))
((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature ivec2
(parameters
(declare (in) ivec2 arg0)
(declare (in) ivec2 arg1)
(declare (in) ivec2 arg2))
((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature ivec3
(parameters
(declare (in) ivec3 arg0)
(declare (in) ivec3 arg1)
(declare (in) ivec3 arg2))
((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature ivec4
(parameters
(declare (in) ivec4 arg0)
(declare (in) ivec4 arg1)
(declare (in) ivec4 arg2))
((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature ivec2
(parameters
(declare (in) ivec2 arg0)
(declare (in) int arg1)
(declare (in) int arg2))
((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature ivec3
(parameters
(declare (in) ivec3 arg0)
(declare (in) int arg1)
(declare (in) int arg2))
((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature ivec4
(parameters
(declare (in) ivec4 arg0)
(declare (in) int arg1)
(declare (in) int arg2))
((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature uint
(parameters
(declare (in) uint arg0)
(declare (in) uint arg1)
(declare (in) uint arg2))
((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature uvec2
(parameters
(declare (in) uvec2 arg0)
(declare (in) uvec2 arg1)
(declare (in) uvec2 arg2))
((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature uvec3
(parameters
(declare (in) uvec3 arg0)
(declare (in) uvec3 arg1)
(declare (in) uvec3 arg2))
((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature uvec4
(parameters
(declare (in) uvec4 arg0)
(declare (in) uvec4 arg1)
(declare (in) uvec4 arg2))
((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature uvec2
(parameters
(declare (in) uvec2 arg0)
(declare (in) uint arg1)
(declare (in) uint arg2))
((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature uvec3
(parameters
(declare (in) uvec3 arg0)
(declare (in) uint arg1)
(declare (in) uint arg2))
((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
(signature uvec4
(parameters
(declare (in) uvec4 arg0)
(declare (in) uint arg1)
(declare (in) uint arg2))
((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
))

View File

@@ -0,0 +1,21 @@
((function cos
(signature float
(parameters
(declare (in) float angle))
((return (expression float cos (var_ref angle)))))
(signature vec2
(parameters
(declare (in) vec2 angle))
((return (expression vec2 cos (var_ref angle)))))
(signature vec3
(parameters
(declare (in) vec3 angle))
((return (expression vec3 cos (var_ref angle)))))
(signature vec4
(parameters
(declare (in) vec4 angle))
((return (expression vec4 cos (var_ref angle)))))
))

View File

@@ -0,0 +1,30 @@
((function cosh
(signature float
(parameters
(declare (in) float x))
((return (expression float * (constant float (0.5))
(expression float +
(expression float exp (var_ref x))
(expression float exp (expression float neg (var_ref x))))))))
(signature vec2
(parameters
(declare (in) vec2 x))
((return (expression vec2 * (constant vec2 (0.5))
(expression vec2 +
(expression vec2 exp (var_ref x))
(expression vec2 exp (expression vec2 neg (var_ref x))))))))
(signature vec3
(parameters
(declare (in) vec3 x))
((return (expression vec3 * (constant vec3 (0.5))
(expression vec3 +
(expression vec3 exp (var_ref x))
(expression vec3 exp (expression vec3 neg (var_ref x))))))))
(signature vec4
(parameters
(declare (in) vec4 x))
((return (expression vec4 * (constant vec4 (0.5))
(expression vec4 +
(expression vec4 exp (var_ref x))
(expression vec4 exp (expression vec4 neg (var_ref x))))))))
))

View File

@@ -0,0 +1,9 @@
((function cross
(signature vec3
(parameters
(declare (in) vec3 a)
(declare (in) vec3 b))
((return (expression vec3 -
(expression vec3 * (swiz yzx (var_ref a)) (swiz zxy (var_ref b)))
(expression vec3 * (swiz zxy (var_ref a)) (swiz yzx (var_ref b)))))))
))

View File

@@ -0,0 +1,21 @@
((function dFdx
(signature float
(parameters
(declare (in) float p))
((return (expression float dFdx (var_ref p)))))
(signature vec2
(parameters
(declare (in) vec2 p))
((return (expression vec2 dFdx (var_ref p)))))
(signature vec3
(parameters
(declare (in) vec3 p))
((return (expression vec3 dFdx (var_ref p)))))
(signature vec4
(parameters
(declare (in) vec4 p))
((return (expression vec4 dFdx (var_ref p)))))
))

View File

@@ -0,0 +1,21 @@
((function dFdy
(signature float
(parameters
(declare (in) float p))
((return (expression float dFdy (var_ref p)))))
(signature vec2
(parameters
(declare (in) vec2 p))
((return (expression vec2 dFdy (var_ref p)))))
(signature vec3
(parameters
(declare (in) vec3 p))
((return (expression vec3 dFdy (var_ref p)))))
(signature vec4
(parameters
(declare (in) vec4 p))
((return (expression vec4 dFdy (var_ref p)))))
))

View File

@@ -0,0 +1,21 @@
((function degrees
(signature float
(parameters
(declare (in) float arg0))
((return (expression float * (var_ref arg0) (constant float (57.295780))))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))
))

View File

@@ -0,0 +1,31 @@
((function distance
(signature float
(parameters
(declare (in) float p0)
(declare (in) float p1))
((return (expression float abs (expression float - (var_ref p0) (var_ref p1))))))
(signature float
(parameters
(declare (in) vec2 p0)
(declare (in) vec2 p1))
((declare () vec2 p)
(assign (xy) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))
(return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
(signature float
(parameters
(declare (in) vec3 p0)
(declare (in) vec3 p1))
((declare () vec3 p)
(assign (xyz) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))
(return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
(signature float
(parameters
(declare (in) vec4 p0)
(declare (in) vec4 p1))
((declare () vec4 p)
(assign (xyzw) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))
(return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
))

View File

@@ -0,0 +1,25 @@
((function dot
(signature float
(parameters
(declare (in) float arg0)
(declare (in) float arg1))
((return (expression float * (var_ref arg0) (var_ref arg1)))))
(signature float
(parameters
(declare (in) vec2 arg0)
(declare (in) vec2 arg1))
((return (expression float dot (var_ref arg0) (var_ref arg1)))))
(signature float
(parameters
(declare (in) vec3 arg0)
(declare (in) vec3 arg1))
((return (expression float dot (var_ref arg0) (var_ref arg1)))))
(signature float
(parameters
(declare (in) vec4 arg0)
(declare (in) vec4 arg1))
((return (expression float dot (var_ref arg0) (var_ref arg1)))))
))

View File

@@ -0,0 +1,73 @@
((function equal
(signature bvec2
(parameters
(declare (in) vec2 arg0)
(declare (in) vec2 arg1))
((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) vec3 arg0)
(declare (in) vec3 arg1))
((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) vec4 arg0)
(declare (in) vec4 arg1))
((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) bvec2 arg0)
(declare (in) bvec2 arg1))
((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) bvec3 arg0)
(declare (in) bvec3 arg1))
((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) bvec4 arg0)
(declare (in) bvec4 arg1))
((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) ivec2 arg0)
(declare (in) ivec2 arg1))
((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) ivec3 arg0)
(declare (in) ivec3 arg1))
((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) ivec4 arg0)
(declare (in) ivec4 arg1))
((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) uvec2 arg0)
(declare (in) uvec2 arg1))
((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) uvec3 arg0)
(declare (in) uvec3 arg1))
((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) uvec4 arg0)
(declare (in) uvec4 arg1))
((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))
))

View File

@@ -0,0 +1,21 @@
((function exp
(signature float
(parameters
(declare (in) float arg0))
((return (expression float exp (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 exp (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 exp (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 exp (var_ref arg0)))))
))

View File

@@ -0,0 +1,21 @@
((function exp2
(signature float
(parameters
(declare (in) float arg0))
((return (expression float exp2 (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 exp2 (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 exp2 (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 exp2 (var_ref arg0)))))
))

View File

@@ -0,0 +1,37 @@
((function faceforward
(signature float
(parameters
(declare (in) float N)
(declare (in) float I)
(declare (in) float Nref))
((if (expression bool < (expression float * (var_ref Nref) (var_ref I)) (constant float (0)))
((return (var_ref N)))
((return (expression float neg (var_ref N)))))))
(signature vec2
(parameters
(declare (in) vec2 N)
(declare (in) vec2 I)
(declare (in) vec2 Nref))
((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))
((return (var_ref N)))
((return (expression vec2 neg (var_ref N)))))))
(signature vec3
(parameters
(declare (in) vec3 N)
(declare (in) vec3 I)
(declare (in) vec3 Nref))
((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))
((return (var_ref N)))
((return (expression vec3 neg (var_ref N)))))))
(signature vec4
(parameters
(declare (in) vec4 N)
(declare (in) vec4 I)
(declare (in) vec4 Nref))
((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))
((return (var_ref N)))
((return (expression vec4 neg (var_ref N)))))))
))

View File

@@ -0,0 +1,21 @@
((function floor
(signature float
(parameters
(declare (in) float arg0))
((return (expression float floor (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 floor (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 floor (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 floor (var_ref arg0)))))
))

View File

@@ -0,0 +1,22 @@
((function fract
(signature float
(parameters
(declare (in) float x))
((return (expression float fract (var_ref x)))))
(signature vec2
(parameters
(declare (in) vec2 x))
((return (expression vec2 fract (var_ref x)))))
(signature vec3
(parameters
(declare (in) vec3 x))
((return (expression vec3 fract (var_ref x)))))
(signature vec4
(parameters
(declare (in) vec4 x))
((return (expression vec4 fract (var_ref x)))))
))

View File

@@ -0,0 +1,9 @@
((declare (uniform) mat4 gl_ModelViewProjectionMatrix)
(declare (in) vec4 gl_Vertex)
(function ftransform
(signature vec4
(parameters)
((return (expression vec4 *
(var_ref gl_ModelViewProjectionMatrix)
(var_ref gl_Vertex)))))
))

View File

@@ -0,0 +1,29 @@
((function fwidth
(signature float
(parameters
(declare (in) float p))
((return (expression float +
(expression float abs (expression float dFdx (var_ref p)))
(expression float abs (expression float dFdy (var_ref p)))))))
(signature vec2
(parameters
(declare (in) vec2 p))
((return (expression vec2 +
(expression vec2 abs (expression vec2 dFdx (var_ref p)))
(expression vec2 abs (expression vec2 dFdy (var_ref p)))))))
(signature vec3
(parameters
(declare (in) vec3 p))
((return (expression vec3 +
(expression vec3 abs (expression vec3 dFdx (var_ref p)))
(expression vec3 abs (expression vec3 dFdy (var_ref p)))))))
(signature vec4
(parameters
(declare (in) vec4 p))
((return (expression vec4 +
(expression vec4 abs (expression vec4 dFdx (var_ref p)))
(expression vec4 abs (expression vec4 dFdy (var_ref p)))))))
))

View File

@@ -0,0 +1,55 @@
((function greaterThan
(signature bvec2
(parameters
(declare (in) vec2 arg0)
(declare (in) vec2 arg1))
((return (expression bvec2 > (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) vec3 arg0)
(declare (in) vec3 arg1))
((return (expression bvec3 > (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) vec4 arg0)
(declare (in) vec4 arg1))
((return (expression bvec4 > (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) ivec2 arg0)
(declare (in) ivec2 arg1))
((return (expression bvec2 > (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) ivec3 arg0)
(declare (in) ivec3 arg1))
((return (expression bvec3 > (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) ivec4 arg0)
(declare (in) ivec4 arg1))
((return (expression bvec4 > (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) uvec2 arg0)
(declare (in) uvec2 arg1))
((return (expression bvec2 > (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) uvec3 arg0)
(declare (in) uvec3 arg1))
((return (expression bvec3 > (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) uvec4 arg0)
(declare (in) uvec4 arg1))
((return (expression bvec4 > (var_ref arg0) (var_ref arg1)))))
))

View File

@@ -0,0 +1,55 @@
((function greaterThanEqual
(signature bvec2
(parameters
(declare (in) vec2 arg0)
(declare (in) vec2 arg1))
((return (expression bvec2 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) vec3 arg0)
(declare (in) vec3 arg1))
((return (expression bvec3 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) vec4 arg0)
(declare (in) vec4 arg1))
((return (expression bvec4 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) ivec2 arg0)
(declare (in) ivec2 arg1))
((return (expression bvec2 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) ivec3 arg0)
(declare (in) ivec3 arg1))
((return (expression bvec3 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) ivec4 arg0)
(declare (in) ivec4 arg1))
((return (expression bvec4 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) uvec2 arg0)
(declare (in) uvec2 arg1))
((return (expression bvec2 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) uvec3 arg0)
(declare (in) uvec3 arg1))
((return (expression bvec3 >= (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) uvec4 arg0)
(declare (in) uvec4 arg1))
((return (expression bvec4 >= (var_ref arg0) (var_ref arg1)))))
))

View File

@@ -0,0 +1,21 @@
((function inversesqrt
(signature float
(parameters
(declare (in) float arg0))
((return (expression float rsq (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 rsq (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 rsq (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 rsq (var_ref arg0)))))
))

View File

@@ -0,0 +1,21 @@
((function length
(signature float
(parameters
(declare (in) float arg0))
((return (expression float abs (var_ref arg0)))))
(signature float
(parameters
(declare (in) vec2 arg0))
((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))
(signature float
(parameters
(declare (in) vec3 arg0))
((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))
(signature float
(parameters
(declare (in) vec4 arg0))
((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))
))

View File

@@ -0,0 +1,55 @@
((function lessThan
(signature bvec2
(parameters
(declare (in) vec2 arg0)
(declare (in) vec2 arg1))
((return (expression bvec2 < (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) vec3 arg0)
(declare (in) vec3 arg1))
((return (expression bvec3 < (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) vec4 arg0)
(declare (in) vec4 arg1))
((return (expression bvec4 < (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) ivec2 arg0)
(declare (in) ivec2 arg1))
((return (expression bvec2 < (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) ivec3 arg0)
(declare (in) ivec3 arg1))
((return (expression bvec3 < (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) ivec4 arg0)
(declare (in) ivec4 arg1))
((return (expression bvec4 < (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) uvec2 arg0)
(declare (in) uvec2 arg1))
((return (expression bvec2 < (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) uvec3 arg0)
(declare (in) uvec3 arg1))
((return (expression bvec3 < (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) uvec4 arg0)
(declare (in) uvec4 arg1))
((return (expression bvec4 < (var_ref arg0) (var_ref arg1)))))
))

View File

@@ -0,0 +1,55 @@
((function lessThanEqual
(signature bvec2
(parameters
(declare (in) vec2 arg0)
(declare (in) vec2 arg1))
((return (expression bvec2 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) vec3 arg0)
(declare (in) vec3 arg1))
((return (expression bvec3 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) vec4 arg0)
(declare (in) vec4 arg1))
((return (expression bvec4 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) ivec2 arg0)
(declare (in) ivec2 arg1))
((return (expression bvec2 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) ivec3 arg0)
(declare (in) ivec3 arg1))
((return (expression bvec3 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) ivec4 arg0)
(declare (in) ivec4 arg1))
((return (expression bvec4 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec2
(parameters
(declare (in) uvec2 arg0)
(declare (in) uvec2 arg1))
((return (expression bvec2 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec3
(parameters
(declare (in) uvec3 arg0)
(declare (in) uvec3 arg1))
((return (expression bvec3 <= (var_ref arg0) (var_ref arg1)))))
(signature bvec4
(parameters
(declare (in) uvec4 arg0)
(declare (in) uvec4 arg1))
((return (expression bvec4 <= (var_ref arg0) (var_ref arg1)))))
))

View File

@@ -0,0 +1,21 @@
((function log
(signature float
(parameters
(declare (in) float arg0))
((return (expression float log (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 log (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 log (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 log (var_ref arg0)))))
))

View File

@@ -0,0 +1,21 @@
((function log2
(signature float
(parameters
(declare (in) float arg0))
((return (expression float log2 (var_ref arg0)))))
(signature vec2
(parameters
(declare (in) vec2 arg0))
((return (expression vec2 log2 (var_ref arg0)))))
(signature vec3
(parameters
(declare (in) vec3 arg0))
((return (expression vec3 log2 (var_ref arg0)))))
(signature vec4
(parameters
(declare (in) vec4 arg0))
((return (expression vec4 log2 (var_ref arg0)))))
))

View File

@@ -0,0 +1,91 @@
((function matrixCompMult
(signature mat2
(parameters
(declare (in) mat2 x)
(declare (in) mat2 y))
((declare () mat2 z)
(assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(return (var_ref z))))
(signature mat3
(parameters
(declare (in) mat3 x)
(declare (in) mat3 y))
((declare () mat3 z)
(assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(return (var_ref z))))
(signature mat4
(parameters
(declare (in) mat4 x)
(declare (in) mat4 y))
((declare () mat4 z)
(assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(assign (xyzw) (array_ref (var_ref z) (constant int (3))) (expression vec4 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
(return (var_ref z))))
(signature mat2x3
(parameters
(declare (in) mat2x3 x)
(declare (in) mat2x3 y))
((declare () mat2x3 z)
(assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(return (var_ref z))))
(signature mat3x2
(parameters
(declare (in) mat3x2 x)
(declare (in) mat3x2 y))
((declare () mat3x2 z)
(assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(return (var_ref z))))
(signature mat2x4
(parameters
(declare (in) mat2x4 x)
(declare (in) mat2x4 y))
((declare () mat2x4 z)
(assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(return (var_ref z))))
(signature mat4x2
(parameters
(declare (in) mat4x2 x)
(declare (in) mat4x2 y))
((declare () mat4x2 z)
(assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(assign (xy) (array_ref (var_ref z) (constant int (3))) (expression vec2 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
(return (var_ref z))))
(signature mat3x4
(parameters
(declare (in) mat3x4 x)
(declare (in) mat3x4 y))
((declare () mat3x4 z)
(assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(return (var_ref z))))
(signature mat4x3
(parameters
(declare (in) mat4x3 x)
(declare (in) mat4x3 y))
((declare () mat4x3 z)
(assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
(assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(assign (xyz) (array_ref (var_ref z) (constant int (3))) (expression vec3 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
(return (var_ref z))))
))

Some files were not shown because too many files have changed in this diff Show More