Add support for pre and post HLSL qualifier validation
The change makes it possible to define a const variable after the marked type. Example "float const"
This commit is contained in:
parent
051f18c0cc
commit
4ae01c5f41
6 changed files with 300 additions and 229 deletions
|
|
@ -1,6 +1,7 @@
|
|||
//
|
||||
// Copyright (C) 2016-2018 Google, Inc.
|
||||
// Copyright (C) 2016 LunarG, Inc.
|
||||
// Copyright (C) 2023 Mobica Limited
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -594,6 +595,7 @@ bool HlslGrammar::acceptControlDeclaration(TIntermNode*& node)
|
|||
// fully_specified_type
|
||||
// : type_specifier
|
||||
// | type_qualifier type_specifier
|
||||
// | type_specifier type_qualifier
|
||||
//
|
||||
bool HlslGrammar::acceptFullySpecifiedType(TType& type, const TAttributes& attributes)
|
||||
{
|
||||
|
|
@ -605,7 +607,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList,
|
|||
// type_qualifier
|
||||
TQualifier qualifier;
|
||||
qualifier.clear();
|
||||
if (! acceptQualifier(qualifier))
|
||||
if (! acceptPreQualifier(qualifier))
|
||||
return false;
|
||||
TSourceLoc loc = token.loc;
|
||||
|
||||
|
|
@ -620,6 +622,10 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList,
|
|||
return false;
|
||||
}
|
||||
|
||||
// type_qualifier
|
||||
if (! acceptPostQualifier(qualifier))
|
||||
return false;
|
||||
|
||||
if (type.getBasicType() == EbtBlock) {
|
||||
// the type was a block, which set some parts of the qualifier
|
||||
parseContext.mergeQualifiers(type.getQualifier(), qualifier);
|
||||
|
|
@ -634,7 +640,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList,
|
|||
parseContext.declareBlock(loc, type);
|
||||
} else {
|
||||
// Some qualifiers are set when parsing the type. Merge those with
|
||||
// whatever comes from acceptQualifier.
|
||||
// whatever comes from acceptPreQualifier and acceptPostQualifier.
|
||||
assert(qualifier.layoutFormat == ElfNone);
|
||||
|
||||
qualifier.layoutFormat = type.getQualifier().layoutFormat;
|
||||
|
|
@ -660,7 +666,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type, TIntermNode*& nodeList,
|
|||
//
|
||||
// Zero or more of these, so this can't return false.
|
||||
//
|
||||
bool HlslGrammar::acceptQualifier(TQualifier& qualifier)
|
||||
bool HlslGrammar::acceptPreQualifier(TQualifier& qualifier)
|
||||
{
|
||||
do {
|
||||
switch (peek()) {
|
||||
|
|
@ -766,6 +772,25 @@ bool HlslGrammar::acceptQualifier(TQualifier& qualifier)
|
|||
} while (true);
|
||||
}
|
||||
|
||||
// type_qualifier
|
||||
// : qualifier qualifier ...
|
||||
//
|
||||
// Zero or more of these, so this can't return false.
|
||||
//
|
||||
bool HlslGrammar::acceptPostQualifier(TQualifier& qualifier)
|
||||
{
|
||||
do {
|
||||
switch (peek()) {
|
||||
case EHTokConst:
|
||||
qualifier.storage = EvqConst;
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
advanceToken();
|
||||
} while (true);
|
||||
}
|
||||
|
||||
// layout_qualifier_list
|
||||
// : LAYOUT LEFT_PAREN layout_qualifier COMMA layout_qualifier ... RIGHT_PAREN
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue