Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
5a839069
Commit
5a839069
authored
Mar 19, 2017
by
John Kessenich
Committed by
GitHub
Mar 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #782 from steve-lunarg/builtin-methods-prefix
HLSL: use prefix for builtin functions names to avoid namespace colli…
parents
1dd65ca3
e7d0752a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
5 deletions
+16
-5
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+5
-3
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+5
-2
hlslParseHelper.h
hlsl/hlslParseHelper.h
+6
-0
hlslParseables.cpp
hlsl/hlslParseables.cpp
+0
-0
No files found.
hlsl/hlslGrammar.cpp
View file @
5a839069
...
@@ -2792,11 +2792,13 @@ bool HlslGrammar::acceptFunctionCall(HlslToken callToken, TIntermTyped*& node, T
...
@@ -2792,11 +2792,13 @@ bool HlslGrammar::acceptFunctionCall(HlslToken callToken, TIntermTyped*& node, T
{
{
// name
// name
TString
*
functionName
=
nullptr
;
TString
*
functionName
=
nullptr
;
if
((
baseObject
==
nullptr
&&
scope
==
nullptr
)
||
if
((
baseObject
==
nullptr
&&
scope
==
nullptr
))
{
parseContext
.
isBuiltInMethod
(
callToken
.
loc
,
baseObject
,
*
callToken
.
string
))
{
functionName
=
callToken
.
string
;
}
else
if
(
parseContext
.
isBuiltInMethod
(
callToken
.
loc
,
baseObject
,
*
callToken
.
string
))
{
// Built-in methods are not in the symbol table as methods, but as global functions
// Built-in methods are not in the symbol table as methods, but as global functions
// taking an explicit 'this' as the first argument.
// taking an explicit 'this' as the first argument.
functionName
=
callToken
.
string
;
functionName
=
NewPoolTString
(
BUILTIN_PREFIX
);
functionName
->
append
(
*
callToken
.
string
);
}
else
{
}
else
{
functionName
=
NewPoolTString
(
""
);
functionName
=
NewPoolTString
(
""
);
if
(
baseObject
!=
nullptr
)
if
(
baseObject
!=
nullptr
)
...
...
hlsl/hlslParseHelper.cpp
View file @
5a839069
...
@@ -956,7 +956,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
...
@@ -956,7 +956,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
// Return true if the field should be treated as a built-in method.
// Return true if the field should be treated as a built-in method.
// Return false otherwise.
// Return false otherwise.
//
//
bool
HlslParseContext
::
isBuiltInMethod
(
const
TSourceLoc
&
loc
,
TIntermTyped
*
base
,
const
TString
&
field
)
bool
HlslParseContext
::
isBuiltInMethod
(
const
TSourceLoc
&
,
TIntermTyped
*
base
,
const
TString
&
field
)
{
{
if
(
base
==
nullptr
)
if
(
base
==
nullptr
)
return
false
;
return
false
;
...
@@ -3734,7 +3734,10 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
...
@@ -3734,7 +3734,10 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
// It will have false positives, since it doesn't check arg counts or types.
// It will have false positives, since it doesn't check arg counts or types.
if
(
arguments
&&
arguments
->
getAsAggregate
())
{
if
(
arguments
&&
arguments
->
getAsAggregate
())
{
if
(
isStructBufferType
(
arguments
->
getAsAggregate
()
->
getSequence
()[
0
]
->
getAsTyped
()
->
getType
()))
{
if
(
isStructBufferType
(
arguments
->
getAsAggregate
()
->
getSequence
()[
0
]
->
getAsTyped
()
->
getType
()))
{
if
(
isStructBufferMethod
(
function
->
getName
()))
{
static
const
int
methodPrefixSize
=
sizeof
(
BUILTIN_PREFIX
)
-
1
;
if
(
function
->
getName
().
length
()
>
methodPrefixSize
&&
isStructBufferMethod
(
function
->
getName
().
substr
(
methodPrefixSize
)))
{
const
TString
mangle
=
function
->
getName
()
+
"("
;
const
TString
mangle
=
function
->
getName
()
+
"("
;
TSymbol
*
symbol
=
symbolTable
.
find
(
mangle
,
&
builtIn
);
TSymbol
*
symbol
=
symbolTable
.
find
(
mangle
,
&
builtIn
);
...
...
hlsl/hlslParseHelper.h
View file @
5a839069
...
@@ -390,6 +390,12 @@ protected:
...
@@ -390,6 +390,12 @@ protected:
TVector
<
TString
>
currentTypePrefix
;
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
}
// end namespace glslang
#endif // HLSL_PARSE_INCLUDED_
#endif // HLSL_PARSE_INCLUDED_
hlsl/hlslParseables.cpp
View file @
5a839069
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment