mirror of
https://github.com/RPCS3/glslang.git
synced 2024-11-27 13:10:37 +00:00
PP: Support operator creation with token pasting.
This commit is contained in:
parent
0c4b7c931a
commit
224b1f733b
@ -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:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123451234' (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:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123451234' (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)
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.1719"
|
||||
#define GLSLANG_REVISION "Overload400-PrecQual.1720"
|
||||
#define GLSLANG_DATE "21-Dec-2016"
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user