Generalize "main" to a settable entry point name.

This commit is contained in:
John Kessenich 2016-03-12 18:17:47 -07:00
parent 6cc7674b6d
commit 4d65ee31a6
8 changed files with 38 additions and 8 deletions

View file

@ -975,7 +975,7 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
//
// Raise error message if main function takes any parameters or returns anything other than void
//
if (function.getName() == "main") {
if (function.getName() == intermediate.getEntryPoint()) {
if (function.getParamCount() > 0)
error(loc, "function cannot take any parameter(s)", function.getName().c_str(), "");
if (function.getType().getBasicType() != EbtVoid)

View file

@ -588,6 +588,7 @@ bool ProcessDeferred(
// Now we can process the full shader under proper symbols and rules.
//
intermediate.setEntryPoint("main");
TParseContext parseContext(symbolTable, intermediate, false, version, profile, spv, vulkan, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
glslang::TScanContext scanContext(parseContext);
TPpContext ppContext(parseContext, includer);
@ -1355,6 +1356,11 @@ void TShader::setStringsWithLengthsAndNames(
stringNames = names;
}
void TShader::setEntryPoint(const char* entryPoint)
{
intermediate->setEntryPoint(entryPoint);
}
//
// Turn the shader strings into a parse tree in the TIntermediate.
//

View file

@ -145,6 +145,8 @@ public:
void output(TInfoSink&, bool tree);
void removeTree();
void setEntryPoint(const char* ep) { entryPoint = ep; }
const TString& getEntryPoint() const { return entryPoint; }
void setVersion(int v) { version = v; }
int getVersion() const { return version; }
void setProfile(EProfile p) { profile = p; }
@ -338,6 +340,7 @@ protected:
static int getBaseAlignmentScalar(const TType&, int& size);
const EShLanguage language;
TString entryPoint;
TIntermNode* treeRoot;
EProfile profile;
int version;