Merge pull request #637 from KhronosGroup/token-paste
PP: Implement token pasting for PP identifiers.
This commit is contained in:
@@ -77,9 +77,8 @@ ERROR: 0:192: 'gl_ClipDistance' : left of '[' is not of type array, matrix, or
|
||||
ERROR: 0:192: 'assign' : l-value required (can't modify a const)
|
||||
ERROR: 0:195: 'gl_ModelViewMatrix' : identifiers starting with "gl_" are reserved
|
||||
ERROR: 0:200: 'token pasting (##)' : not supported for this version or the enabled extensions
|
||||
ERROR: 0:200: '##' : token pasting not implemented (internal error)
|
||||
ERROR: 0:200: '' : syntax error
|
||||
ERROR: 80 compilation errors. No code generated.
|
||||
ERROR: 0:203: 'token pasting (##)' : not supported for this version or the enabled extensions
|
||||
ERROR: 79 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 120
|
||||
@@ -427,7 +426,8 @@ ERROR: node is still EOpNull!
|
||||
0:? 'c2D' (in 2-component vector of float)
|
||||
0:? 'c3D' (in 3-component vector of float)
|
||||
0:? 'v4' (uniform 4-component vector of float)
|
||||
0:? 'abc' (global int)
|
||||
0:? 'abcdef' (global int)
|
||||
0:? 'qrstuv' (global int)
|
||||
|
||||
|
||||
Linked vertex stage:
|
||||
@@ -499,5 +499,6 @@ ERROR: node is still EOpNull!
|
||||
0:? 'c2D' (in 2-component vector of float)
|
||||
0:? 'c3D' (in 3-component vector of float)
|
||||
0:? 'v4' (uniform 4-component vector of float)
|
||||
0:? 'abc' (global int)
|
||||
0:? 'abcdef' (global int)
|
||||
0:? 'qrstuv' (global int)
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@ ERROR: 0:59: 'gl_InstanceID' : undeclared identifier
|
||||
ERROR: 0:59: '=' : cannot convert from 'temp float' to 'temp int'
|
||||
ERROR: 0:61: 'texelFetch' : no matching overloaded function found
|
||||
ERROR: 0:61: 'assign' : cannot convert from 'const float' to 'temp int'
|
||||
ERROR: 0:75: '##' : token pasting not implemented (internal error)
|
||||
ERROR: 0:75: '' : syntax error
|
||||
ERROR: 6 compilation errors. No code generated.
|
||||
ERROR: 4 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 130
|
||||
@@ -149,7 +147,8 @@ ERROR: node is still EOpNull!
|
||||
0:? 'v4' (uniform 4-component vector of float)
|
||||
0:? 'gl_ClipDistance' (smooth out implicitly-sized array of float ClipDistance)
|
||||
0:? 'gl_TexCoord' (smooth out implicitly-sized array of 4-component vector of float TexCoord)
|
||||
0:? 'abc' (global int)
|
||||
0:? 'abcdef' (global int)
|
||||
0:? 'qrstuv' (global int)
|
||||
0:? 'gl_VertexID' (gl_VertexId int VertexId)
|
||||
|
||||
|
||||
@@ -281,6 +280,7 @@ ERROR: node is still EOpNull!
|
||||
0:? 'v4' (uniform 4-component vector of float)
|
||||
0:? 'gl_ClipDistance' (smooth out 2-element array of float ClipDistance)
|
||||
0:? 'gl_TexCoord' (smooth out 1-element array of 4-component vector of float TexCoord)
|
||||
0:? 'abc' (global int)
|
||||
0:? 'abcdef' (global int)
|
||||
0:? 'qrstuv' (global int)
|
||||
0:? 'gl_VertexID' (gl_VertexId int VertexId)
|
||||
|
||||
|
||||
60
Test/baseResults/tokenPaste.vert.out
Executable file
60
Test/baseResults/tokenPaste.vert.out
Executable file
@@ -0,0 +1,60 @@
|
||||
tokenPaste.vert
|
||||
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
|
||||
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.
|
||||
|
||||
|
||||
Shader version: 450
|
||||
ERROR: node is still EOpNull!
|
||||
0:52 Sequence
|
||||
0:52 move second child to first child (temp int)
|
||||
0:52 'a' (global int)
|
||||
0:52 Constant:
|
||||
0:52 11 (const int)
|
||||
0:? Linker Objects
|
||||
0:? 'SecondExpansion' (global int)
|
||||
0:? 'PostPasteExpansion' (global int)
|
||||
0:? 'foo27' (global float)
|
||||
0:? 'foo155' (uniform float)
|
||||
0:? 'foo719' (global float)
|
||||
0:? 'barfoo' (uniform float)
|
||||
0:? 'argless' (global float)
|
||||
0:? 'dc1' (global float)
|
||||
0:? 'dc2' (global float)
|
||||
0:? 'foo875' (uniform float)
|
||||
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123451234' (global float)
|
||||
0:? 'a' (global int)
|
||||
0:? 'gl_VertexID' (gl_VertexId int VertexId)
|
||||
0:? 'gl_InstanceID' (gl_InstanceId int InstanceId)
|
||||
|
||||
|
||||
Linked vertex stage:
|
||||
|
||||
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
|
||||
|
||||
Shader version: 450
|
||||
ERROR: node is still EOpNull!
|
||||
0:52 Sequence
|
||||
0:52 move second child to first child (temp int)
|
||||
0:52 'a' (global int)
|
||||
0:52 Constant:
|
||||
0:52 11 (const int)
|
||||
0:? Linker Objects
|
||||
0:? 'SecondExpansion' (global int)
|
||||
0:? 'PostPasteExpansion' (global int)
|
||||
0:? 'foo27' (global float)
|
||||
0:? 'foo155' (uniform float)
|
||||
0:? 'foo719' (global float)
|
||||
0:? 'barfoo' (uniform float)
|
||||
0:? 'argless' (global float)
|
||||
0:? 'dc1' (global float)
|
||||
0:? 'dc2' (global float)
|
||||
0:? 'foo875' (uniform float)
|
||||
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123451234' (global float)
|
||||
0:? 'a' (global int)
|
||||
0:? 'gl_VertexID' (gl_VertexId int VertexId)
|
||||
0:? 'gl_InstanceID' (gl_InstanceId int InstanceId)
|
||||
|
||||
52
Test/tokenPaste.vert
Normal file
52
Test/tokenPaste.vert
Normal file
@@ -0,0 +1,52 @@
|
||||
#version 450
|
||||
|
||||
// side test verifies multiple rounds of argument expansion
|
||||
#define bear SecondExpansion
|
||||
#define mmmB bear
|
||||
#define mmmA(a) a
|
||||
int mmmA(mmmB); // mmmB -> bear, and then in mmmA(), bear -> SecondExpansion
|
||||
|
||||
// pasting skips the first round of expansion
|
||||
#define mmcatmmdog PostPasteExpansion
|
||||
#define mmcat cat
|
||||
#define mmdog dog
|
||||
#define mmp(a,b) a## b
|
||||
int mmp(mmcat, mmdog); // mmcat/mmdog not expanded, mmcatmmdog -> PostPasteExpansion
|
||||
|
||||
// multi-token pre
|
||||
#define mmtokpastepre(a) a##27
|
||||
mmtokpastepre(float foo); // should declare "float foo27;"
|
||||
|
||||
// multi-token post
|
||||
#define mmtokpastepost(a) uni ##a
|
||||
mmtokpastepost(form float foo155); // should declare "uniform float foo155;"
|
||||
|
||||
// non-first argument
|
||||
#define foo ShouldntExpandToThis
|
||||
#define semi ;
|
||||
#define bothpaste(a,b) a##b
|
||||
float bothpaste(foo, 719); // should declare "float foo719;"
|
||||
#define secpaste(a,b) a bar ## b
|
||||
secpaste(uniform float, foo semi) // should declare "uniform float barfoo;"
|
||||
|
||||
// no args
|
||||
#define noArg fl##oat
|
||||
noArg argless;
|
||||
|
||||
// bad location
|
||||
#define bad1 ## float
|
||||
bad1 dc1;
|
||||
#define bad2 float ##
|
||||
bad2 dc2;
|
||||
|
||||
// multiple ##
|
||||
#define multiPaste(a, b, c) a##or##b flo##at foo##c
|
||||
multiPaste(unif, m, 875);
|
||||
|
||||
// too long
|
||||
#define simplePaste(a,b) a##b
|
||||
// 1020 + 5 characters
|
||||
float simplePaste(ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345, 12345);
|
||||
|
||||
// non-identifiers
|
||||
int a = simplePaste(11,12);
|
||||
Reference in New Issue
Block a user