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
...
@@ -4,7 +4,7 @@ ERROR: 0:1: '#if' : unexpected tokens following directive
ERROR: 0:3: '#error' : A <bad token> B
ERROR: 0:3: '#error' : A <bad token> B
ERROR: 0:4: 'preprocessor evaluation' : bad expression
ERROR: 0:4: 'preprocessor evaluation' : bad expression
ERROR: 0:4: '#if' : unexpected tokens following directive
ERROR: 0:4: '#if' : unexpected tokens following directive
ERROR: 0:6: 'ÿ' : unexpected token
ERROR: 0:6: '€' : unexpected token
ERROR: 0:7: '' : syntax error
ERROR: 0:7: '' : syntax error
ERROR: 7 compilation errors. No code generated.
ERROR: 7 compilation errors. No code generated.
...
...
glslang/Include/revision.h
View file @
b49bb2ca
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// 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).
// 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"
#define GLSLANG_DATE "10-Feb-2017"
glslang/MachineIndependent/preprocessor/Pp.cpp
View file @
b49bb2ca
...
@@ -1076,16 +1076,16 @@ bool TPpContext::tMacroInput::peekMacPasting()
...
@@ -1076,16 +1076,16 @@ bool TPpContext::tMacroInput::peekMacPasting()
size_t
savePos
=
mac
->
body
.
current
;
size_t
savePos
=
mac
->
body
.
current
;
// skip white-space
// skip white-space
int
l
token
;
int
sub
token
;
do
{
do
{
ltoken
=
pp
->
lReadByte
(
mac
->
body
);
subtoken
=
pp
->
getSubtoken
(
mac
->
body
);
}
while
(
l
token
==
' '
);
}
while
(
sub
token
==
' '
);
// check for ##
// check for ##
bool
pasting
=
false
;
bool
pasting
=
false
;
if
(
l
token
==
'#'
)
{
if
(
sub
token
==
'#'
)
{
ltoken
=
pp
->
lReadByte
(
mac
->
body
);
subtoken
=
pp
->
getSubtoken
(
mac
->
body
);
if
(
l
token
==
'#'
)
if
(
sub
token
==
'#'
)
pasting
=
true
;
pasting
=
true
;
}
}
...
...
glslang/MachineIndependent/preprocessor/PpContext.h
View file @
b49bb2ca
...
@@ -375,9 +375,9 @@ protected:
...
@@ -375,9 +375,9 @@ protected:
//
//
// From PpTokens.cpp
// From PpTokens.cpp
//
//
void
lAddByte
(
TokenStream
&
,
unsigned
char
fVal
);
void
putSubtoken
(
TokenStream
&
,
int
fVal
);
int
lReadByte
(
TokenStream
&
);
int
getSubtoken
(
TokenStream
&
);
void
lUnreadByte
(
TokenStream
&
);
void
ungetSubtoken
(
TokenStream
&
);
void
RecordToken
(
TokenStream
&
,
int
token
,
TPpToken
*
ppToken
);
void
RecordToken
(
TokenStream
&
,
int
token
,
TPpToken
*
ppToken
);
void
RewindTokenStream
(
TokenStream
&
);
void
RewindTokenStream
(
TokenStream
&
);
int
ReadToken
(
TokenStream
&
,
TPpToken
*
);
int
ReadToken
(
TokenStream
&
,
TPpToken
*
);
...
...
glslang/MachineIndependent/preprocessor/PpScanner.cpp
View file @
b49bb2ca
...
@@ -232,6 +232,8 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
...
@@ -232,6 +232,8 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
switch
(
ch
)
{
switch
(
ch
)
{
default
:
default
:
// Single character token, including EndOfInput, '#' and '\' (escaped newlines are handled at a lower level, so this is just a '\' token)
// 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
;
return
ch
;
case
'A'
:
case
'B'
:
case
'C'
:
case
'D'
:
case
'E'
:
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.
...
@@ -95,26 +95,27 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace
glslang
{
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 token in stream
* Get the next byte from a stream.
int
TPpContext
::
getSubtoken
(
TokenStream
&
stream
)
*/
int
TPpContext
::
lReadByte
(
TokenStream
&
pTok
)
{
{
if
(
pTok
.
current
<
pTok
.
data
.
size
())
if
(
stream
.
current
<
stream
.
data
.
size
())
return
pTok
.
data
[
pTok
.
current
++
];
return
stream
.
data
[
stream
.
current
++
];
else
else
return
EndOfInput
;
return
EndOfInput
;
}
}
void
TPpContext
::
lUnreadByte
(
TokenStream
&
pTok
)
// back up one position in the stream
void
TPpContext
::
ungetSubtoken
(
TokenStream
&
stream
)
{
{
if
(
pTok
.
current
>
0
)
if
(
stream
.
current
>
0
)
--
pTok
.
current
;
--
stream
.
current
;
}
}
/*
/*
...
@@ -125,18 +126,15 @@ void TPpContext::RecordToken(TokenStream& pTok, int token, TPpToken* ppToken)
...
@@ -125,18 +126,15 @@ void TPpContext::RecordToken(TokenStream& pTok, int token, TPpToken* ppToken)
const
char
*
s
;
const
char
*
s
;
char
*
str
=
NULL
;
char
*
str
=
NULL
;
if
(
token
>
PpAtomMaxSingle
)
putSubtoken
(
pTok
,
token
);
lAddByte
(
pTok
,
(
unsigned
char
)((
token
&
0x7f
)
+
0x80
));
else
lAddByte
(
pTok
,
(
unsigned
char
)(
token
&
0x7f
));
switch
(
token
)
{
switch
(
token
)
{
case
PpAtomIdentifier
:
case
PpAtomIdentifier
:
case
PpAtomConstString
:
case
PpAtomConstString
:
s
=
ppToken
->
name
;
s
=
ppToken
->
name
;
while
(
*
s
)
while
(
*
s
)
lAddByte
(
pTok
,
(
unsigned
char
)
*
s
++
);
putSubtoken
(
pTok
,
*
s
++
);
lAddByte
(
pTok
,
0
);
putSubtoken
(
pTok
,
0
);
break
;
break
;
case
PpAtomConstInt
:
case
PpAtomConstInt
:
case
PpAtomConstUint
:
case
PpAtomConstUint
:
...
@@ -149,10 +147,10 @@ void TPpContext::RecordToken(TokenStream& pTok, int token, TPpToken* ppToken)
...
@@ -149,10 +147,10 @@ void TPpContext::RecordToken(TokenStream& pTok, int token, TPpToken* ppToken)
#endif
#endif
str
=
ppToken
->
name
;
str
=
ppToken
->
name
;
while
(
*
str
)
{
while
(
*
str
)
{
lAddByte
(
pTok
,
(
unsigned
char
)
*
str
);
putSubtoken
(
pTok
,
*
str
);
str
++
;
str
++
;
}
}
lAddByte
(
pTok
,
0
);
putSubtoken
(
pTok
,
0
);
break
;
break
;
default
:
default
:
break
;
break
;
...
@@ -172,23 +170,21 @@ void TPpContext::RewindTokenStream(TokenStream& pTok)
...
@@ -172,23 +170,21 @@ void TPpContext::RewindTokenStream(TokenStream& pTok)
*/
*/
int
TPpContext
::
ReadToken
(
TokenStream
&
pTok
,
TPpToken
*
ppToken
)
int
TPpContext
::
ReadToken
(
TokenStream
&
pTok
,
TPpToken
*
ppToken
)
{
{
int
l
token
,
l
en
;
int
len
;
int
ch
;
int
ch
;
ltoken
=
lReadByte
(
pTok
);
int
subtoken
=
getSubtoken
(
pTok
);
ppToken
->
loc
=
parseContext
.
getCurrentLoc
();
ppToken
->
loc
=
parseContext
.
getCurrentLoc
();
if
(
ltoken
>
127
)
switch
(
subtoken
)
{
ltoken
+=
128
;
switch
(
ltoken
)
{
case
'#'
:
case
'#'
:
// Check for ##, unless the current # is the last character
// Check for ##, unless the current # is the last character
if
(
pTok
.
current
<
pTok
.
data
.
size
())
{
if
(
pTok
.
current
<
pTok
.
data
.
size
())
{
if
(
lReadByte
(
pTok
)
==
'#'
)
{
if
(
getSubtoken
(
pTok
)
==
'#'
)
{
parseContext
.
requireProfile
(
ppToken
->
loc
,
~
EEsProfile
,
"token pasting (##)"
);
parseContext
.
requireProfile
(
ppToken
->
loc
,
~
EEsProfile
,
"token pasting (##)"
);
parseContext
.
profileRequires
(
ppToken
->
loc
,
~
EEsProfile
,
130
,
0
,
"token pasting (##)"
);
parseContext
.
profileRequires
(
ppToken
->
loc
,
~
EEsProfile
,
130
,
0
,
"token pasting (##)"
);
l
token
=
PpAtomPaste
;
sub
token
=
PpAtomPaste
;
}
else
}
else
lUnreadByte
(
pTok
);
ungetSubtoken
(
pTok
);
}
}
break
;
break
;
case
PpAtomConstString
:
case
PpAtomConstString
:
...
@@ -203,12 +199,12 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
...
@@ -203,12 +199,12 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
case
PpAtomConstInt64
:
case
PpAtomConstInt64
:
case
PpAtomConstUint64
:
case
PpAtomConstUint64
:
len
=
0
;
len
=
0
;
ch
=
lReadByte
(
pTok
);
ch
=
getSubtoken
(
pTok
);
while
(
ch
!=
0
&&
ch
!=
EndOfInput
)
{
while
(
ch
!=
0
&&
ch
!=
EndOfInput
)
{
if
(
len
<
MaxTokenLength
)
{
if
(
len
<
MaxTokenLength
)
{
ppToken
->
name
[
len
]
=
(
char
)
ch
;
ppToken
->
name
[
len
]
=
(
char
)
ch
;
len
++
;
len
++
;
ch
=
lReadByte
(
pTok
);
ch
=
getSubtoken
(
pTok
);
}
else
{
}
else
{
parseContext
.
error
(
ppToken
->
loc
,
"token too long"
,
""
,
""
);
parseContext
.
error
(
ppToken
->
loc
,
"token too long"
,
""
,
""
);
break
;
break
;
...
@@ -216,7 +212,7 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
...
@@ -216,7 +212,7 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
}
}
ppToken
->
name
[
len
]
=
0
;
ppToken
->
name
[
len
]
=
0
;
switch
(
l
token
)
{
switch
(
sub
token
)
{
case
PpAtomIdentifier
:
case
PpAtomIdentifier
:
break
;
break
;
case
PpAtomConstString
:
case
PpAtomConstString
:
...
@@ -267,7 +263,7 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
...
@@ -267,7 +263,7 @@ int TPpContext::ReadToken(TokenStream& pTok, TPpToken *ppToken)
}
}
}
}
return
l
token
;
return
sub
token
;
}
}
int
TPpContext
::
tTokenInput
::
scan
(
TPpToken
*
ppToken
)
int
TPpContext
::
tTokenInput
::
scan
(
TPpToken
*
ppToken
)
...
@@ -285,14 +281,13 @@ bool TPpContext::tTokenInput::peekPasting()
...
@@ -285,14 +281,13 @@ bool TPpContext::tTokenInput::peekPasting()
// 1. preceding ##?
// 1. preceding ##?
size_t
savePos
=
tokens
->
current
;
size_t
savePos
=
tokens
->
current
;
int
byte
;
int
subtoken
;
// skip white space
// skip white space
do
{
do
{
byte
=
pp
->
lReadByte
(
*
tokens
);
subtoken
=
pp
->
getSubtoken
(
*
tokens
);
}
while
(
byte
==
' '
);
}
while
(
subtoken
==
' '
);
bool
pasting
=
(
byte
==
((
PpAtomPaste
&
0x7f
)
+
0x80
));
tokens
->
current
=
savePos
;
tokens
->
current
=
savePos
;
if
(
pasting
)
if
(
subtoken
==
PpAtomPaste
)
return
true
;
return
true
;
// 2. last token and we've been told after this there will be a ##
// 2. last token and we've been told after this there will be a ##
...
@@ -305,10 +300,10 @@ bool TPpContext::tTokenInput::peekPasting()
...
@@ -305,10 +300,10 @@ bool TPpContext::tTokenInput::peekPasting()
savePos
=
tokens
->
current
;
savePos
=
tokens
->
current
;
bool
moreTokens
=
false
;
bool
moreTokens
=
false
;
do
{
do
{
byte
=
pp
->
lReadByte
(
*
tokens
);
subtoken
=
pp
->
getSubtoken
(
*
tokens
);
if
(
byte
==
EndOfInput
)
if
(
subtoken
==
EndOfInput
)
break
;
break
;
if
(
byte
!=
' '
)
{
if
(
subtoken
!=
' '
)
{
moreTokens
=
true
;
moreTokens
=
true
;
break
;
break
;
}
}
...
...
glslang/MachineIndependent/preprocessor/PpTokens.h
View file @
b49bb2ca
...
@@ -82,7 +82,11 @@ namespace glslang {
...
@@ -82,7 +82,11 @@ namespace glslang {
// Multi-character tokens
// Multi-character tokens
enum
EFixedAtoms
{
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
// 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