Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
b49bb2ca
Commit
b49bb2ca
authored
Feb 10, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PP, nonfunctional: Remove crufty bit-twiddling of tokens.
parent
8e711b84
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
51 deletions
+52
-51
badChars.frag.out
Test/baseResults/badChars.frag.out
+1
-1
revision.h
glslang/Include/revision.h
+1
-1
Pp.cpp
glslang/MachineIndependent/preprocessor/Pp.cpp
+6
-6
PpContext.h
glslang/MachineIndependent/preprocessor/PpContext.h
+3
-3
PpScanner.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp
+2
-0
PpTokens.cpp
glslang/MachineIndependent/preprocessor/PpTokens.cpp
+34
-39
PpTokens.h
glslang/MachineIndependent/preprocessor/PpTokens.h
+5
-1
No files found.
Test/baseResults/badChars.frag.out
View file @
b49bb2ca
...
...
@@ -4,7 +4,7 @@ ERROR: 0:1: '#if' : unexpected tokens following directive
ERROR: 0:3: '#error' : A <bad token> B
ERROR: 0:4: 'preprocessor evaluation' : bad expression
ERROR: 0:4: '#if' : unexpected tokens following directive
ERROR: 0:6: 'ÿ' : unexpected token
ERROR: 0:6: '€' : unexpected token
ERROR: 0:7: '' : syntax error
ERROR: 7 compilation errors. No code generated.
...
...
glslang/Include/revision.h
View file @
b49bb2ca
...
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.182
0
"
#define GLSLANG_REVISION "Overload400-PrecQual.182
5
"
#define GLSLANG_DATE "10-Feb-2017"
glslang/MachineIndependent/preprocessor/Pp.cpp
View file @
b49bb2ca
...
...
@@ -1076,16 +1076,16 @@ bool TPpContext::tMacroInput::peekMacPasting()
size_t
savePos
=
mac
->
body
.
current
;
// skip white-space
int
l
token
;
int
sub
token
;
do
{
ltoken
=
pp
->
lReadByte
(
mac
->
body
);
}
while
(
l
token
==
' '
);
subtoken
=
pp
->
getSubtoken
(
mac
->
body
);
}
while
(
sub
token
==
' '
);
// check for ##
bool
pasting
=
false
;
if
(
l
token
==
'#'
)
{
ltoken
=
pp
->
lReadByte
(
mac
->
body
);
if
(
l
token
==
'#'
)
if
(
sub
token
==
'#'
)
{
subtoken
=
pp
->
getSubtoken
(
mac
->
body
);
if
(
sub
token
==
'#'
)
pasting
=
true
;
}
...
...
glslang/MachineIndependent/preprocessor/PpContext.h
View file @
b49bb2ca
...
...
@@ -375,9 +375,9 @@ protected:
//
// From PpTokens.cpp
//
void
lAddByte
(
TokenStream
&
,
unsigned
char
fVal
);
int
lReadByte
(
TokenStream
&
);
void
lUnreadByte
(
TokenStream
&
);
void
putSubtoken
(
TokenStream
&
,
int
fVal
);
int
getSubtoken
(
TokenStream
&
);
void
ungetSubtoken
(
TokenStream
&
);
void
RecordToken
(
TokenStream
&
,
int
token
,
TPpToken
*
ppToken
);
void
RewindTokenStream
(
TokenStream
&
);
int
ReadToken
(
TokenStream
&
,
TPpToken
*
);
...
...
glslang/MachineIndependent/preprocessor/PpScanner.cpp
View file @
b49bb2ca
...
...
@@ -232,6 +232,8 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
switch
(
ch
)
{
default
:
// Single character token, including EndOfInput, '#' and '\' (escaped newlines are handled at a lower level, so this is just a '\' token)
if
(
ch
>
PpAtomMaxSingle
)
ch
=
PpAtomBadToken
;
return
ch
;
case
'A'
:
case
'B'
:
case
'C'
:
case
'D'
:
case
'E'
:
...
...
glslang/MachineIndependent/preprocessor/PpTokens.cpp
View file @
b49bb2ca
...
...
@@ -95,26 +95,27 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace
glslang
{
void
TPpContext
::
lAddByte
(
TokenStream
&
fTok
,
unsigned
char
fVal
)
// push onto back of stream
void
TPpContext
::
putSubtoken
(
TokenStream
&
stream
,
int
subtoken
)
{
fTok
.
data
.
push_back
(
fVal
);
assert
((
subtoken
&
~
0xff
)
==
0
);
stream
.
data
.
push_back
(
static_cast
<
unsigned
char
>
(
subtoken
));
}
/*
* Get the next byte from a stream.
*/
int
TPpContext
::
lReadByte
(
TokenStream
&
pTok
)
// get the next token in stream
int
TPpContext
::
getSubtoken
(
TokenStream
&
stream
)
{
if
(
pTok
.
current
<
pTok
.
data
.
size
())
return
pTok
.
data
[
pTok
.
current
++
];
if
(
stream
.
current
<
stream
.
data
.
size
())
return
stream
.
data
[
stream
.
current
++
];
else
return
EndOfInput
;
}
void
TPpContext
::
lUnreadByte
(
TokenStream
&
pTok
)
// back up one position in the stream
void
TPpContext
::
ungetSubtoken
(
TokenStream
&
stream
)
{
if
(
pTok
.
current
>
0
)
--
pTok
.
current
;
if
(
stream
.
current
>
0
)
--
stream
.
current
;
}
/*
...
...
@@ -125,18 +126,15 @@ void TPpContext::RecordToken(TokenStream& pTok, int token, TPpToken* ppToken)
const
char
*
s
;
char
*
str
=
NULL
;
if
(
token
>
PpAtomMaxSingle
)
lAddByte
(
pTok
,
(
unsigned
char
)((
token
&
0x7f
)
+
0x80
));
else
lAddByte
(
pTok
,
(
unsigned
char
)(
token
&
0x7f
));
putSubtoken
(
pTok
,
token
);
switch
(
token
)
{
case
PpAtomIdentifier
:
case
PpAtomConstString
:
s
=
ppToken
->
name
;
while
(
*
s
)
lAddByte
(
pTok
,
(
unsigned
char
)
*
s
++
);
lAddByte
(
pTok
,
0
);
putSubtoken
(
pTok
,
*
s
++
);
putSubtoken
(
pTok
,
0
);
break
;
case
PpAtomConstInt
:
case
PpAtomConstUint
:
...
...
@@ -149,10 +147,10 @@ void TPpContext::RecordToken(TokenStream& pTok, int token, TPpToken* ppToken)
#endif
str
=
ppToken
->
name
;
while
(
*
str
)
{
lAddByte
(
pTok
,
(
unsigned
char
)
*
str
);
putSubtoken
(
pTok
,
*
str
);
str
++
;
}
lAddByte
(
pTok
,
0
);
putSubtoken
(
pTok
,
0
);
break
;
default
:
break
;
...
...
@@ -172,23 +170,21 @@ void TPpContext::RewindTokenStream(TokenStream& pTok)
*/
int
TPpContext
::
ReadToken
(
TokenStream
&
pTok
,
TPpToken
*
ppToken
)
{
int
l
token
,
l
en
;
int
len
;
int
ch
;
ltoken
=
lReadByte
(
pTok
);
int
subtoken
=
getSubtoken
(
pTok
);
ppToken
->
loc
=
parseContext
.
getCurrentLoc
();
if
(
ltoken
>
127
)
ltoken
+=
128
;
switch
(
ltoken
)
{
switch
(
subtoken
)
{
case
'#'
:
// Check for ##, unless the current # is the last character
if
(
pTok
.
current
<
pTok
.
data
.
size
())
{
if
(
lReadByte
(
pTok
)
==
'#'
)
{
if
(
getSubtoken
(
pTok
)
==
'#'
)
{
parseContext
.
requireProfile
(
ppToken
->
loc
,
~
EEsProfile
,
"token pasting (##)"
);
parseContext
.
profileRequires
(
ppToken
->
loc
,
~
EEsProfile
,
130
,
0
,
"token pasting (##)"
);
l
token
=
PpAtomPaste
;
sub
token
=
PpAtomPaste
;
}
else
lUnreadByte
(
pTok
);
ungetSubtoken
(
pTok
);
}
break
;
case
PpAtomConstString
:
...
...
@@ -203,12 +199,12 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
case
PpAtomConstInt64
:
case
PpAtomConstUint64
:
len
=
0
;
ch
=
lReadByte
(
pTok
);
ch
=
getSubtoken
(
pTok
);
while
(
ch
!=
0
&&
ch
!=
EndOfInput
)
{
if
(
len
<
MaxTokenLength
)
{
ppToken
->
name
[
len
]
=
(
char
)
ch
;
len
++
;
ch
=
lReadByte
(
pTok
);
ch
=
getSubtoken
(
pTok
);
}
else
{
parseContext
.
error
(
ppToken
->
loc
,
"token too long"
,
""
,
""
);
break
;
...
...
@@ -216,7 +212,7 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
}
ppToken
->
name
[
len
]
=
0
;
switch
(
l
token
)
{
switch
(
sub
token
)
{
case
PpAtomIdentifier
:
break
;
case
PpAtomConstString
:
...
...
@@ -267,7 +263,7 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
}
}
return
l
token
;
return
sub
token
;
}
int
TPpContext
::
tTokenInput
::
scan
(
TPpToken
*
ppToken
)
...
...
@@ -285,14 +281,13 @@ bool TPpContext::tTokenInput::peekPasting()
// 1. preceding ##?
size_t
savePos
=
tokens
->
current
;
int
byte
;
int
subtoken
;
// skip white space
do
{
byte
=
pp
->
lReadByte
(
*
tokens
);
}
while
(
byte
==
' '
);
bool
pasting
=
(
byte
==
((
PpAtomPaste
&
0x7f
)
+
0x80
));
subtoken
=
pp
->
getSubtoken
(
*
tokens
);
}
while
(
subtoken
==
' '
);
tokens
->
current
=
savePos
;
if
(
pasting
)
if
(
subtoken
==
PpAtomPaste
)
return
true
;
// 2. last token and we've been told after this there will be a ##
...
...
@@ -305,10 +300,10 @@ bool TPpContext::tTokenInput::peekPasting()
savePos
=
tokens
->
current
;
bool
moreTokens
=
false
;
do
{
byte
=
pp
->
lReadByte
(
*
tokens
);
if
(
byte
==
EndOfInput
)
subtoken
=
pp
->
getSubtoken
(
*
tokens
);
if
(
subtoken
==
EndOfInput
)
break
;
if
(
byte
!=
' '
)
{
if
(
subtoken
!=
' '
)
{
moreTokens
=
true
;
break
;
}
...
...
glslang/MachineIndependent/preprocessor/PpTokens.h
View file @
b49bb2ca
...
...
@@ -82,7 +82,11 @@ namespace glslang {
// Multi-character tokens
enum
EFixedAtoms
{
PpAtomMaxSingle
=
256
,
// single character tokens get their own char value as their token, skip them
// single character tokens get their own char value as their token; start here for multi-character tokens
PpAtomMaxSingle
=
127
,
// replace bad character tokens with this, to avoid accidental aliasing with the below
PpAtomBadToken
,
// Operators
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment