Infrastructure: Move nesting counters, etc., to base class.

This lets all languages share the same definitions.
This commit is contained in:
John Kessenich 2017-06-06 19:19:45 -06:00
parent b4d46627cb
commit 9b2531ba23
6 changed files with 33 additions and 32 deletions

View file

@ -57,10 +57,7 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
const TString sourceEntryPointName,
bool forwardCompatible, EShMessages messages) :
TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
contextPragma(true, false),
loopNestingLevel(0), annotationNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0),
postEntryPointReturn(false),
limits(resources.limits),
annotationNestingLevel(0),
inputPatch(nullptr),
builtInIoIndex(nullptr),
builtInIoBase(nullptr),
@ -520,6 +517,9 @@ TIntermTyped* HlslParseContext::handleSamplerLvalue(const TSourceLoc& loc, const
return node;
}
if (controlFlowNestingLevel > 0)
error(loc, "can't alias sampler in control flow", op, "");
// Best is if we are aliasing a flattened struct member "S.s1 = s2",
// in which case we want to update the flattening information with the alias,
// making everything else work seamlessly.

View file

@ -314,17 +314,7 @@ protected:
TIntermSymbol* findLinkageSymbol(TBuiltInVariable biType) const;
// Current state of parsing
struct TPragma contextPragma;
int loopNestingLevel; // 0 if outside all loops
int annotationNestingLevel; // 0 if outside all annotations
int structNestingLevel; // 0 if outside blocks and structures
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
bool postEntryPointReturn; // if inside a function, true if the function is the entry point and this is after a return statement
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
TBuiltInResource resources;
TLimits& limits;
HlslParseContext(HlslParseContext&);
HlslParseContext& operator=(HlslParseContext&);