parent
9e41635d74
commit
d5f3ad6c9a
10 changed files with 745 additions and 252 deletions
|
|
@ -3,6 +3,7 @@
|
|||
// Copyright (C) 2013 LunarG, Inc.
|
||||
// Copyright (C) 2017 ARM Limited.
|
||||
// Copyright (C) 2015-2018 Google, Inc.
|
||||
// Copyright (c) 2023, Mobica Limited
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -549,7 +550,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||
|
||||
ival = 0;
|
||||
do {
|
||||
if (len < MaxTokenLength && ival <= 0x0fffffffffffffffull) {
|
||||
if (len < MaxTokenLength && ival <= 0x7fffffffffffffffull) {
|
||||
ppToken->name[len++] = (char)ch;
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
ii = ch - '0';
|
||||
|
|
@ -639,6 +640,110 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||
ppToken->ival = (int)ival;
|
||||
return isUnsigned ? PpAtomConstUint : PpAtomConstInt;
|
||||
}
|
||||
} else if ((ch == 'b' || ch == 'B') && pp->parseContext.intermediate.getSource() == EShSourceHlsl) {
|
||||
// must be binary
|
||||
bool isUnsigned = false;
|
||||
bool isInt64 = false;
|
||||
bool isInt16 = false;
|
||||
ppToken->name[len++] = (char)ch;
|
||||
ch = getch();
|
||||
|
||||
// Check value
|
||||
if ((ch == '0' || ch == '1'))
|
||||
{
|
||||
ival = 0;
|
||||
do {
|
||||
if (len < MaxTokenLength && ival <= 0x7fffffffffffffffull) {
|
||||
ppToken->name[len++] = (char)ch;
|
||||
if (ch == '0' || ch == '1') {
|
||||
ii = ch - '0';
|
||||
} else {
|
||||
pp->parseContext.ppError(ppToken->loc, "bad digit in binary literal", "", "");
|
||||
}
|
||||
ival = (ival << 1) | ii;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! AlreadyComplained) {
|
||||
if(len < MaxTokenLength)
|
||||
pp->parseContext.ppError(ppToken->loc, "binary literal too big", "", "");
|
||||
else
|
||||
pp->parseContext.ppError(ppToken->loc, "binary literal too long", "", "");
|
||||
AlreadyComplained = 1;
|
||||
}
|
||||
ival = 0xffffffffffffffffull;
|
||||
}
|
||||
ch = getch();
|
||||
} while (ch == '0' || ch == '1');
|
||||
}
|
||||
else
|
||||
{
|
||||
pp->parseContext.ppError(ppToken->loc, "bad digit in binary literal", "", "");
|
||||
}
|
||||
|
||||
// check type
|
||||
if (ch == 'u' || ch == 'U') {
|
||||
if (len < MaxTokenLength)
|
||||
ppToken->name[len++] = (char)ch;
|
||||
isUnsigned = true;
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
int nextCh = getch();
|
||||
if (nextCh == 'l' || nextCh == 'L') {
|
||||
if (len < MaxTokenLength)
|
||||
ppToken->name[len++] = (char)nextCh;
|
||||
isInt64 = true;
|
||||
} else
|
||||
ungetch();
|
||||
|
||||
nextCh = getch();
|
||||
if ((nextCh == 's' || nextCh == 'S') &&
|
||||
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||
if (len < MaxTokenLength)
|
||||
ppToken->name[len++] = (char)nextCh;
|
||||
isInt16 = true;
|
||||
} else
|
||||
ungetch();
|
||||
} else if (ch == 'l' || ch == 'L') {
|
||||
if (len < MaxTokenLength)
|
||||
ppToken->name[len++] = (char)ch;
|
||||
isInt64 = true;
|
||||
} else if ((ch == 's' || ch == 'S') &&
|
||||
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||
if (len < MaxTokenLength)
|
||||
ppToken->name[len++] = (char)ch;
|
||||
isInt16 = true;
|
||||
#endif
|
||||
} else {
|
||||
ungetch();
|
||||
}
|
||||
ppToken->name[len] = '\0';
|
||||
|
||||
// Assign value
|
||||
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||
if (pp->ifdepth == 0) {
|
||||
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
||||
"64-bit binary literal");
|
||||
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
|
||||
Num_Int64_Extensions, Int64_Extensions, "64-bit binary literal");
|
||||
}
|
||||
ppToken->i64val = ival;
|
||||
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
|
||||
} else if (isInt16) {
|
||||
if (pp->ifdepth == 0) {
|
||||
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
||||
"16-bit binary literal");
|
||||
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0,
|
||||
Num_Int16_Extensions, Int16_Extensions, "16-bit binary literal");
|
||||
}
|
||||
}
|
||||
ppToken->ival = (int)ival;
|
||||
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
|
||||
} else {
|
||||
ppToken->ival = (int)ival;
|
||||
return isUnsigned ? PpAtomConstUint : PpAtomConstInt;
|
||||
}
|
||||
} else {
|
||||
// could be octal integer or floating point, speculative pursue octal until it must be floating point
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue