Non-functional: Sweep through the stack for consistent with "main" and entry point.

Partially addresses issue #513.
This commit is contained in:
John Kessenich 2016-09-19 16:01:41 -06:00
parent 142785f324
commit 6fccb3cd75
26 changed files with 52 additions and 52 deletions

View file

@ -1058,8 +1058,8 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
if (function.getParamCount() > 0)
error(loc, "function cannot take any parameter(s)", function.getName().c_str(), "");
if (function.getType().getBasicType() != EbtVoid)
error(loc, "", function.getType().getBasicTypeString().c_str(), "main function cannot return a value");
intermediate.addMainCount();
error(loc, "", function.getType().getBasicTypeString().c_str(), "entry point cannot return a value");
intermediate.incrementEntryPointCount();
inMain = true;
} else
inMain = false;

View file

@ -35,7 +35,7 @@
//
//
// Symbol table for parsing. Most functionaliy and main ideas
// Symbol table for parsing. Most functionality and main ideas
// are documented in the header file.
//

View file

@ -81,7 +81,7 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
else
entryPoint = unit.entryPoint;
}
numMains += unit.numMains;
numEntryPoints += unit.numEntryPoints;
numErrors += unit.numErrors;
numPushConstants += unit.numPushConstants;
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
@ -370,8 +370,8 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
//
void TIntermediate::finalCheck(TInfoSink& infoSink)
{
if (source == EShSourceGlsl && numMains < 1)
error(infoSink, "Missing entry point: Each stage requires one \"void main()\" entry point");
if (source == EShSourceGlsl && numEntryPoints < 1)
error(infoSink, "Missing entry point: Each stage requires one entry point");
if (numPushConstants > 1)
error(infoSink, "Only one push_constant block is allowed per stage");

View file

@ -137,7 +137,7 @@ class TIntermediate {
public:
explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
source(EShSourceNone), language(l), profile(p), version(v), treeRoot(0),
numMains(0), numErrors(0), numPushConstants(0), recursive(false),
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet), inputPrimitive(ElgNone), outputPrimitive(ElgNone),
pixelCenterInteger(false), originUpperLeft(false),
vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), depthReplacing(false), blendEquations(0),
@ -173,8 +173,8 @@ public:
void setTreeRoot(TIntermNode* r) { treeRoot = r; }
TIntermNode* getTreeRoot() const { return treeRoot; }
void addMainCount() { ++numMains; }
int getNumMains() const { return numMains; }
void incrementEntryPointCount() { ++numEntryPoints; }
int getNumEntryPoints() const { return numEntryPoints; }
int getNumErrors() const { return numErrors; }
void addPushConstantCount() { ++numPushConstants; }
bool isRecursive() const { return recursive; }
@ -370,7 +370,7 @@ protected:
TIntermNode* treeRoot;
std::set<std::string> requestedExtensions; // cumulation of all enabled or required extensions; not connected to what subset of the shader used them
TBuiltInResource resources;
int numMains;
int numEntryPoints;
int numErrors;
int numPushConstants;
bool recursive;

View file

@ -696,7 +696,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
}
//
// The main functional entry-point into the preprocessor, which will
// The main functional entry point into the preprocessor, which will
// scan the source strings to figure out and return the next processing token.
//
// Return string pointer to next token.

View file

@ -48,7 +48,7 @@
//
// High-level algorithm for one stage:
//
// 1. Put main() on list of live functions.
// 1. Put the entry point on the list of live functions.
//
// 2. Traverse any live function, while skipping if-tests with a compile-time constant
// condition of false, and while adding any encountered function calls to the live
@ -59,7 +59,7 @@
// 3. Add any encountered uniform variables and blocks to the reflection database.
//
// Can be attempted with a failed link, but will return false if recursion had been detected, or
// there wasn't exactly one main.
// there wasn't exactly one entry point.
//
namespace glslang {
@ -83,7 +83,7 @@ public:
virtual void visitSymbol(TIntermSymbol* base);
virtual bool visitSelection(TVisit, TIntermSelection* node);
// Track live funtions as well as uniforms, so that we don't visit dead functions
// Track live functions as well as uniforms, so that we don't visit dead functions
// and only visit each function once.
void addFunctionCall(TIntermAggregate* call)
{
@ -717,12 +717,12 @@ bool TLiveTraverser::visitSelection(TVisit /* visit */, TIntermSelection* node)
// Returns false if the input is too malformed to do this.
bool TReflection::addStage(EShLanguage, const TIntermediate& intermediate)
{
if (intermediate.getNumMains() != 1 || intermediate.isRecursive())
if (intermediate.getNumEntryPoints() != 1 || intermediate.isRecursive())
return false;
TLiveTraverser it(intermediate, *this);
// put main() on functions to process
// put the entry point on functions to process
it.pushFunction("main(");
// process all the functions