HLSL: use prefix for builtin functions names to avoid namespace collisions

It would have been possible for globally scoped user functions to collide
with builtin method names.  This adds a prefix to avoid polluting the
namespace.

Ideally this would be an invalid character to use in user identifiers, but
as that requires changing the scanner, for the moment it's an unlikely yet
valid prefix.
This commit is contained in:
steve-lunarg
2017-03-19 18:12:37 -06:00
parent 4960baaf66
commit e7d0752a33
4 changed files with 331 additions and 302 deletions

View File

@@ -390,6 +390,12 @@ protected:
TVector<TString> currentTypePrefix;
};
// This is the prefix we use for builtin methods to avoid namespace collisions with
// global scope user functions.
// TODO: this would be better as a nonparseable character, but that would
// require changing the scanner.
#define BUILTIN_PREFIX "__BI_"
} // end namespace glslang
#endif // HLSL_PARSE_INCLUDED_