HLSL: Move to correct parsing of annotations, improving all annotations and recent string grammar.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
string s = "string1";
|
string s = "string1";
|
||||||
string e = "";
|
string e = "";
|
||||||
string bracket < string a = "nested" ; > ;
|
string bracket < string a = "nested" ; > ;
|
||||||
string brackets < string b = "nest1" ; string c = "nest2" ; string d = "nest3" ; > ;
|
string brackets < string b = "nest1" ; string c = "nest2" ; float test [ 4 ] = { 1.0 , 1.0 , 1.0 , 1.0 } ; vector<float, 3> a = float3(2.0); > ;
|
||||||
string brackete1 < > ;
|
string brackete1 < > ;
|
||||||
string brackete2 < ; > ;
|
string brackete2 < ; > ;
|
||||||
string brackete3 < ; ; > ;
|
string brackete3 < ; ; > ;
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
// For the version, it uses the latest git tag followed by the number of commits.
|
// 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).
|
// For the date, it uses the current date (when then script is run).
|
||||||
|
|
||||||
#define GLSLANG_REVISION "Overload400-PrecQual.1502"
|
#define GLSLANG_REVISION "Overload400-PrecQual.1503"
|
||||||
#define GLSLANG_DATE "19-Sep-2016"
|
#define GLSLANG_DATE "20-Sep-2016"
|
||||||
|
|||||||
@@ -721,36 +721,16 @@ bool HlslGrammar::acceptMatrixTemplateType(TType& type)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// string_template_type
|
// annotations
|
||||||
// : STRING
|
// : LEFT_ANGLE declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
|
||||||
// | STRING identifier LEFT_ANGLE declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
|
|
||||||
//
|
//
|
||||||
bool HlslGrammar::acceptStringTemplateType(TType& type)
|
bool HlslGrammar::acceptAnnotations(TQualifier&)
|
||||||
{
|
{
|
||||||
// STRING
|
if (! acceptTokenClass(EHTokLeftAngle))
|
||||||
if (! acceptTokenClass(EHTokString))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// no matter what happens next, we recognized a string type
|
// note that we are nesting a name space
|
||||||
new(&type) TType(EbtString);
|
parseContext.nestAnnotations();
|
||||||
|
|
||||||
// identifier LEFT_ANGLE, or not?
|
|
||||||
if (! acceptTokenClass(EHTokIdentifier)) {
|
|
||||||
expected("identifier following 'string'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! peekTokenClass(EHTokLeftAngle)) {
|
|
||||||
// then it must be the non-template version, back up and let
|
|
||||||
// normal declaration code handle it
|
|
||||||
|
|
||||||
// recede the identifier
|
|
||||||
recedeToken();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// move past the LEFT_ANGLE
|
|
||||||
advanceToken();
|
|
||||||
|
|
||||||
// declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
|
// declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
|
||||||
do {
|
do {
|
||||||
@@ -759,15 +739,18 @@ bool HlslGrammar::acceptStringTemplateType(TType& type)
|
|||||||
;
|
;
|
||||||
|
|
||||||
if (acceptTokenClass(EHTokRightAngle))
|
if (acceptTokenClass(EHTokRightAngle))
|
||||||
return true;
|
break;
|
||||||
|
|
||||||
// declaration
|
// declaration
|
||||||
TIntermNode* node;
|
TIntermNode* node;
|
||||||
if (! acceptDeclaration(node)) {
|
if (! acceptDeclaration(node)) {
|
||||||
expected("declaration in string list");
|
expected("declaration in annotation");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
|
parseContext.unnestAnnotations();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sampler_type
|
// sampler_type
|
||||||
@@ -942,10 +925,6 @@ bool HlslGrammar::acceptType(TType& type)
|
|||||||
return acceptMatrixTemplateType(type);
|
return acceptMatrixTemplateType(type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EHTokString:
|
|
||||||
return acceptStringTemplateType(type);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EHTokSampler: // fall through
|
case EHTokSampler: // fall through
|
||||||
case EHTokSampler1d: // ...
|
case EHTokSampler1d: // ...
|
||||||
case EHTokSampler2d: // ...
|
case EHTokSampler2d: // ...
|
||||||
@@ -991,6 +970,10 @@ bool HlslGrammar::acceptType(TType& type)
|
|||||||
new(&type) TType(EbtVoid);
|
new(&type) TType(EbtVoid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EHTokString:
|
||||||
|
new(&type) TType(EbtString);
|
||||||
|
break;
|
||||||
|
|
||||||
case EHTokFloat:
|
case EHTokFloat:
|
||||||
new(&type) TType(EbtFloat);
|
new(&type) TType(EbtFloat);
|
||||||
break;
|
break;
|
||||||
@@ -2740,16 +2723,9 @@ void HlslGrammar::acceptPostDecls(TQualifier& qualifier)
|
|||||||
// semantic, in idToken.string
|
// semantic, in idToken.string
|
||||||
parseContext.handleSemantic(idToken.loc, qualifier, *idToken.string);
|
parseContext.handleSemantic(idToken.loc, qualifier, *idToken.string);
|
||||||
}
|
}
|
||||||
} else if (acceptTokenClass(EHTokLeftAngle)) {
|
} else if (peekTokenClass(EHTokLeftAngle))
|
||||||
// TODO: process annotations, just accepting them for now
|
acceptAnnotations(qualifier);
|
||||||
do {
|
else
|
||||||
if (peekTokenClass(EHTokNone))
|
|
||||||
return;
|
|
||||||
if (acceptTokenClass(EHTokRightAngle))
|
|
||||||
break;
|
|
||||||
advanceToken();
|
|
||||||
} while (true);
|
|
||||||
} else
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace glslang {
|
|||||||
bool acceptTemplateType(TBasicType&);
|
bool acceptTemplateType(TBasicType&);
|
||||||
bool acceptVectorTemplateType(TType&);
|
bool acceptVectorTemplateType(TType&);
|
||||||
bool acceptMatrixTemplateType(TType&);
|
bool acceptMatrixTemplateType(TType&);
|
||||||
bool acceptStringTemplateType(TType&);
|
bool acceptAnnotations(TQualifier&);
|
||||||
bool acceptSamplerType(TType&);
|
bool acceptSamplerType(TType&);
|
||||||
bool acceptTextureType(TType&);
|
bool acceptTextureType(TType&);
|
||||||
bool acceptStruct(TType&);
|
bool acceptStruct(TType&);
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
|
|||||||
int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
|
int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
|
||||||
bool forwardCompatible, EShMessages messages) :
|
bool forwardCompatible, EShMessages messages) :
|
||||||
TParseContextBase(symbolTable, interm, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
|
TParseContextBase(symbolTable, interm, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
|
||||||
contextPragma(true, false), loopNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0),
|
contextPragma(true, false),
|
||||||
|
loopNestingLevel(0), annotationNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0),
|
||||||
postMainReturn(false),
|
postMainReturn(false),
|
||||||
limits(resources.limits),
|
limits(resources.limits),
|
||||||
entryPointOutput(nullptr),
|
entryPointOutput(nullptr),
|
||||||
@@ -4059,8 +4060,12 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
|
|||||||
//
|
//
|
||||||
TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, const TType& parseType, TArraySizes* arraySizes, TIntermTyped* initializer)
|
TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, const TType& parseType, TArraySizes* arraySizes, TIntermTyped* initializer)
|
||||||
{
|
{
|
||||||
// string identifiers can nest inside < ... >, apparently with their own namespace,
|
// TODO: things scoped within an annotation need their own name space;
|
||||||
// which is not implemented
|
// haven't done that yet
|
||||||
|
if (annotationNestingLevel > 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
// TODO: strings are not yet handled
|
||||||
if (parseType.getBasicType() == EbtString)
|
if (parseType.getBasicType() == EbtString)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,8 @@ public:
|
|||||||
|
|
||||||
void nestLooping() { ++loopNestingLevel; }
|
void nestLooping() { ++loopNestingLevel; }
|
||||||
void unnestLooping() { --loopNestingLevel; }
|
void unnestLooping() { --loopNestingLevel; }
|
||||||
|
void nestAnnotations() { ++annotationNestingLevel; }
|
||||||
|
void unnestAnnotations() { --annotationNestingLevel; }
|
||||||
void pushScope() { symbolTable.push(); }
|
void pushScope() { symbolTable.push(); }
|
||||||
void popScope() { symbolTable.pop(0); }
|
void popScope() { symbolTable.pop(0); }
|
||||||
|
|
||||||
@@ -182,6 +184,7 @@ protected:
|
|||||||
// Current state of parsing
|
// Current state of parsing
|
||||||
struct TPragma contextPragma;
|
struct TPragma contextPragma;
|
||||||
int loopNestingLevel; // 0 if outside all loops
|
int loopNestingLevel; // 0 if outside all loops
|
||||||
|
int annotationNestingLevel; // 0 if outside all annotations
|
||||||
int structNestingLevel; // 0 if outside blocks and structures
|
int structNestingLevel; // 0 if outside blocks and structures
|
||||||
int controlFlowNestingLevel; // 0 if outside all flow control
|
int controlFlowNestingLevel; // 0 if outside all flow control
|
||||||
TList<TIntermSequence*> switchSequenceStack; // case, node, case, case, node, ...; ensure only one node between cases; stack of them for nesting
|
TList<TIntermSequence*> switchSequenceStack; // case, node, case, case, node, ...; ensure only one node between cases; stack of them for nesting
|
||||||
|
|||||||
@@ -122,9 +122,9 @@ void HlslScanContext::fillInKeywordMap()
|
|||||||
(*KeywordMap)["Buffer"] = EHTokBuffer;
|
(*KeywordMap)["Buffer"] = EHTokBuffer;
|
||||||
(*KeywordMap)["vector"] = EHTokVector;
|
(*KeywordMap)["vector"] = EHTokVector;
|
||||||
(*KeywordMap)["matrix"] = EHTokMatrix;
|
(*KeywordMap)["matrix"] = EHTokMatrix;
|
||||||
(*KeywordMap)["string"] = EHTokString;
|
|
||||||
|
|
||||||
(*KeywordMap)["void"] = EHTokVoid;
|
(*KeywordMap)["void"] = EHTokVoid;
|
||||||
|
(*KeywordMap)["string"] = EHTokString;
|
||||||
(*KeywordMap)["bool"] = EHTokBool;
|
(*KeywordMap)["bool"] = EHTokBool;
|
||||||
(*KeywordMap)["int"] = EHTokInt;
|
(*KeywordMap)["int"] = EHTokInt;
|
||||||
(*KeywordMap)["uint"] = EHTokUint;
|
(*KeywordMap)["uint"] = EHTokUint;
|
||||||
@@ -472,11 +472,11 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
|
|||||||
case EHTokBuffer:
|
case EHTokBuffer:
|
||||||
case EHTokVector:
|
case EHTokVector:
|
||||||
case EHTokMatrix:
|
case EHTokMatrix:
|
||||||
case EHTokString:
|
|
||||||
return keyword;
|
return keyword;
|
||||||
|
|
||||||
// scalar types
|
// scalar types
|
||||||
case EHTokVoid:
|
case EHTokVoid:
|
||||||
|
case EHTokString:
|
||||||
case EHTokBool:
|
case EHTokBool:
|
||||||
case EHTokInt:
|
case EHTokInt:
|
||||||
case EHTokUint:
|
case EHTokUint:
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ enum EHlslTokenClass {
|
|||||||
EHTokBuffer,
|
EHTokBuffer,
|
||||||
EHTokVector,
|
EHTokVector,
|
||||||
EHTokMatrix,
|
EHTokMatrix,
|
||||||
EHTokString,
|
|
||||||
|
|
||||||
// scalar types
|
// scalar types
|
||||||
EHTokVoid,
|
EHTokVoid,
|
||||||
|
EHTokString,
|
||||||
EHTokBool,
|
EHTokBool,
|
||||||
EHTokInt,
|
EHTokInt,
|
||||||
EHTokUint,
|
EHTokUint,
|
||||||
|
|||||||
Reference in New Issue
Block a user