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
224b1f73
Commit
224b1f73
authored
Dec 21, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PP: Support operator creation with token pasting.
parent
0c4b7c93
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
8 deletions
+118
-8
tokenPaste.vert.out
Test/baseResults/tokenPaste.vert.out
+56
-4
tokenPaste.vert
Test/tokenPaste.vert
+18
-0
revision.h
glslang/Include/revision.h
+1
-1
PpScanner.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp
+43
-3
No files found.
Test/baseResults/tokenPaste.vert.out
View file @
224b1f73
...
...
@@ -3,8 +3,9 @@ Warning, version 450 is not yet complete; most version-specific features are pre
ERROR: 0:38: '##' : unexpected location
ERROR: 0:40: '##' : unexpected location; end of replacement list
ERROR: 0:49: '##' : combined tokens are too long
ERROR: 0:52: '##' : only supported for preprocessing identifiers
ERROR: 4 compilation errors. No code generated.
ERROR: 0:52: '##' : not supported for these tokens
ERROR: 0:69: '##' : combined token is invalid
ERROR: 5 compilation errors. No code generated.
Shader version: 450
...
...
@@ -14,6 +15,35 @@ ERROR: node is still EOpNull!
0:52 'a' (global int)
0:52 Constant:
0:52 11 (const int)
0:58 Sequence
0:58 move second child to first child (temp int)
0:58 'cop' (global int)
0:58 Constant:
0:58 160 (const int)
0:59 Sequence
0:59 move second child to first child (temp bool)
0:59 'dop' (global bool)
0:59 Constant:
0:59 true (const bool)
0:63 Function Definition: ShouldntExpandToThis( (global void)
0:63 Function Parameters:
0:65 Sequence
0:65 Sequence
0:65 move second child to first child (temp int)
0:65 'e' (temp int)
0:65 Constant:
0:65 16 (const int)
0:66 right shift second child into first child (temp int)
0:66 'e' (temp int)
0:66 Constant:
0:66 2 (const int)
0:69 Sequence
0:69 move second child to first child (temp bool)
0:69 'f' (temp bool)
0:69 Compare Greater Than (temp bool)
0:69 'e' (temp int)
0:69 Constant:
0:69 5 (const int)
0:? Linker Objects
0:? 'SecondExpansion' (global int)
0:? 'PostPasteExpansion' (global int)
...
...
@@ -25,8 +55,14 @@ ERROR: node is still EOpNull!
0:? 'dc1' (global float)
0:? 'dc2' (global float)
0:? 'foo875' (uniform float)
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345
1234
' (global float)
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345' (global float)
0:? 'a' (global int)
0:? 'aop' (const int)
0:? 10 (const int)
0:? 'bop' (const int)
0:? 4 (const int)
0:? 'cop' (global int)
0:? 'dop' (global bool)
0:? 'gl_VertexID' (gl_VertexId int VertexId)
0:? 'gl_InstanceID' (gl_InstanceId int InstanceId)
...
...
@@ -42,6 +78,16 @@ ERROR: node is still EOpNull!
0:52 'a' (global int)
0:52 Constant:
0:52 11 (const int)
0:58 Sequence
0:58 move second child to first child (temp int)
0:58 'cop' (global int)
0:58 Constant:
0:58 160 (const int)
0:59 Sequence
0:59 move second child to first child (temp bool)
0:59 'dop' (global bool)
0:59 Constant:
0:59 true (const bool)
0:? Linker Objects
0:? 'SecondExpansion' (global int)
0:? 'PostPasteExpansion' (global int)
...
...
@@ -53,8 +99,14 @@ ERROR: node is still EOpNull!
0:? 'dc1' (global float)
0:? 'dc2' (global float)
0:? 'foo875' (uniform float)
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345
1234
' (global float)
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345' (global float)
0:? 'a' (global int)
0:? 'aop' (const int)
0:? 10 (const int)
0:? 'bop' (const int)
0:? 4 (const int)
0:? 'cop' (global int)
0:? 'dop' (global bool)
0:? 'gl_VertexID' (gl_VertexId int VertexId)
0:? 'gl_InstanceID' (gl_InstanceId int InstanceId)
Test/tokenPaste.vert
View file @
224b1f73
...
...
@@ -50,3 +50,21 @@ float simplePaste(ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF01234567
// non-identifiers
int
a
=
simplePaste
(
11
,
12
);
// operators
#define MAKE_OP(L, R) L ## R
const
int
aop
=
10
;
const
int
bop
=
4
;
int
cop
=
aop
MAKE_OP
(
<
,
<
)
bop
;
bool
dop
=
aop
MAKE_OP
(
!
,
=
)
bop
;
#define MAKE_OP3(L, M, R) L ## M ## R
void
foo
()
{
int
e
=
16
;
e
MAKE_OP3
(
>
,
>
,
=
)
2
;
// recovery from bad op
bool
f
=
e
MAKE_OP
(
>
,
!
)
5
;
}
glslang/Include/revision.h
View file @
224b1f73
...
...
@@ -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.17
19
"
#define GLSLANG_REVISION "Overload400-PrecQual.17
20
"
#define GLSLANG_DATE "21-Dec-2016"
glslang/MachineIndependent/preprocessor/PpScanner.cpp
View file @
224b1f73
...
...
@@ -813,12 +813,52 @@ int TPpContext::tokenPaste(int token, TPpToken& ppToken)
// get the token after the ##
token
=
scanToken
(
&
pastedPpToken
);
// get the token text
switch
(
resultToken
)
{
case
PpAtomIdentifier
:
// already have the correct text in token.names
break
;
case
'='
:
case
'!'
:
case
'-'
:
case
'~'
:
case
'+'
:
case
'*'
:
case
'/'
:
case
'%'
:
case
'<'
:
case
'>'
:
case
'|'
:
case
'^'
:
case
'&'
:
case
PpAtomRight
:
case
PpAtomLeft
:
case
PpAtomAnd
:
case
PpAtomOr
:
case
PpAtomXor
:
strcpy
(
ppToken
.
name
,
GetAtomString
(
resultToken
));
strcpy
(
pastedPpToken
.
name
,
GetAtomString
(
token
));
break
;
default
:
parseContext
.
ppError
(
ppToken
.
loc
,
"not supported for these tokens"
,
"##"
,
""
);
return
resultToken
;
}
// combine the tokens
if
(
resultToken
!=
PpAtomIdentifier
)
parseContext
.
ppError
(
ppToken
.
loc
,
"only supported for preprocessing identifiers"
,
"##"
,
""
);
if
(
strlen
(
ppToken
.
name
)
+
strlen
(
pastedPpToken
.
name
)
>
MaxTokenLength
)
if
(
strlen
(
ppToken
.
name
)
+
strlen
(
pastedPpToken
.
name
)
>
MaxTokenLength
)
{
parseContext
.
ppError
(
ppToken
.
loc
,
"combined tokens are too long"
,
"##"
,
""
);
return
resultToken
;
}
strncat
(
ppToken
.
name
,
pastedPpToken
.
name
,
MaxTokenLength
-
strlen
(
ppToken
.
name
));
// correct the kind of token we are making, if needed (identifiers stay identifiers)
if
(
resultToken
!=
PpAtomIdentifier
)
{
int
newToken
=
LookUpString
(
ppToken
.
name
);
if
(
newToken
>
0
)
resultToken
=
newToken
;
else
parseContext
.
ppError
(
ppToken
.
loc
,
"combined token is invalid"
,
"##"
,
""
);
}
}
return
resultToken
;
...
...
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