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
088d52ba
Commit
088d52ba
authored
Mar 11, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Non-functional: consolidate function declarator information.
parent
c04c6a40
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
33 deletions
+43
-33
revision.h
glslang/Include/revision.h
+1
-1
hlslAttributes.h
hlsl/hlslAttributes.h
+8
-0
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+28
-21
hlslGrammar.h
hlsl/hlslGrammar.h
+4
-2
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+1
-8
hlslParseHelper.h
hlsl/hlslParseHelper.h
+1
-1
No files found.
glslang/Include/revision.h
View file @
088d52ba
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1
899
"
#define GLSLANG_REVISION "Overload400-PrecQual.1
901
"
#define GLSLANG_DATE "11-Mar-2017"
#define GLSLANG_DATE "11-Mar-2017"
hlsl/hlslAttributes.h
View file @
088d52ba
...
@@ -92,6 +92,14 @@ namespace glslang {
...
@@ -92,6 +92,14 @@ namespace glslang {
std
::
unordered_map
<
TAttributeType
,
TIntermAggregate
*>
attributes
;
std
::
unordered_map
<
TAttributeType
,
TIntermAggregate
*>
attributes
;
};
};
class
TFunctionDeclarator
{
public
:
TSourceLoc
loc
;
TFunction
*
function
;
TAttributeMap
attributes
;
};
}
// end namespace glslang
}
// end namespace glslang
...
...
hlsl/hlslGrammar.cpp
View file @
088d52ba
...
@@ -301,8 +301,8 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
...
@@ -301,8 +301,8 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
bool
declarator_list
=
false
;
// true when processing comma separation
bool
declarator_list
=
false
;
// true when processing comma separation
// attributes
// attributes
T
AttributeMap
attributes
;
T
FunctionDeclarator
declarator
;
acceptAttributes
(
attributes
);
acceptAttributes
(
declarator
.
attributes
);
// typedef
// typedef
bool
typedefDecl
=
acceptTokenClass
(
EHTokTypedef
);
bool
typedefDecl
=
acceptTokenClass
(
EHTokTypedef
);
...
@@ -334,26 +334,27 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
...
@@ -334,26 +334,27 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
parseContext
.
renameShaderFunction
(
fnName
);
parseContext
.
renameShaderFunction
(
fnName
);
// function_parameters
// function_parameters
TFunction
&
function
=
*
new
TFunction
(
fnName
,
declaredType
);
declarator
.
function
=
new
TFunction
(
fnName
,
declaredType
);
if
(
!
acceptFunctionParameters
(
function
))
{
if
(
!
acceptFunctionParameters
(
*
declarator
.
function
))
{
expected
(
"function parameter list"
);
expected
(
"function parameter list"
);
return
false
;
return
false
;
}
}
// post_decls
// post_decls
acceptPostDecls
(
function
.
getWritableType
().
getQualifier
());
acceptPostDecls
(
declarator
.
function
->
getWritableType
().
getQualifier
());
// compound_statement (function body definition) or just a prototype?
// compound_statement (function body definition) or just a prototype?
declarator
.
loc
=
token
.
loc
;
if
(
peekTokenClass
(
EHTokLeftBrace
))
{
if
(
peekTokenClass
(
EHTokLeftBrace
))
{
if
(
declarator_list
)
if
(
declarator_list
)
parseContext
.
error
(
idToken
.
loc
,
"function body can't be in a declarator list"
,
"{"
,
""
);
parseContext
.
error
(
idToken
.
loc
,
"function body can't be in a declarator list"
,
"{"
,
""
);
if
(
typedefDecl
)
if
(
typedefDecl
)
parseContext
.
error
(
idToken
.
loc
,
"function body can't be in a typedef"
,
"{"
,
""
);
parseContext
.
error
(
idToken
.
loc
,
"function body can't be in a typedef"
,
"{"
,
""
);
return
acceptFunctionDefinition
(
function
,
nodeList
,
attributes
);
return
acceptFunctionDefinition
(
declarator
,
nodeList
);
}
else
{
}
else
{
if
(
typedefDecl
)
if
(
typedefDecl
)
parseContext
.
error
(
idToken
.
loc
,
"function typedefs not implemented"
,
"{"
,
""
);
parseContext
.
error
(
idToken
.
loc
,
"function typedefs not implemented"
,
"{"
,
""
);
parseContext
.
handleFunctionDeclarator
(
idToken
.
loc
,
function
,
true
);
parseContext
.
handleFunctionDeclarator
(
declarator
.
loc
,
*
declarator
.
function
,
true
);
}
}
}
else
{
}
else
{
// A variable declaration. Fix the storage qualifier if it's a global.
// A variable declaration. Fix the storage qualifier if it's a global.
...
@@ -1962,7 +1963,8 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList, TIntermNode*
...
@@ -1962,7 +1963,8 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList, TIntermNode*
if
(
peekTokenClass
(
EHTokLeftParen
))
{
if
(
peekTokenClass
(
EHTokLeftParen
))
{
// function_parameters
// function_parameters
if
(
!
declarator_list
)
{
if
(
!
declarator_list
)
{
functionDefinitionAccepted
=
acceptMemberFunctionDefinition
(
nodeList
,
typeName
,
memberType
,
*
idToken
.
string
);
functionDefinitionAccepted
=
acceptMemberFunctionDefinition
(
nodeList
,
typeName
,
memberType
,
*
idToken
.
string
);
if
(
functionDefinitionAccepted
)
if
(
functionDefinitionAccepted
)
break
;
break
;
}
}
...
@@ -2029,22 +2031,23 @@ bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const T
...
@@ -2029,22 +2031,23 @@ bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const T
bool
accepted
=
false
;
bool
accepted
=
false
;
TString
*
functionName
=
parseContext
.
getFullMemberFunctionName
(
memberName
,
type
.
getQualifier
().
storage
==
EvqGlobal
);
TString
*
functionName
=
parseContext
.
getFullMemberFunctionName
(
memberName
,
type
.
getQualifier
().
storage
==
EvqGlobal
);
TFunction
&
function
=
*
new
TFunction
(
functionName
,
type
);
TFunctionDeclarator
declarator
;
declarator
.
function
=
new
TFunction
(
functionName
,
type
);
// function_parameters
// function_parameters
if
(
acceptFunctionParameters
(
function
))
{
if
(
acceptFunctionParameters
(
*
declarator
.
function
))
{
// post_decls
// post_decls
acceptPostDecls
(
function
.
getWritableType
().
getQualifier
());
acceptPostDecls
(
declarator
.
function
->
getWritableType
().
getQualifier
());
// compound_statement (function body definition)
// compound_statement (function body definition)
if
(
peekTokenClass
(
EHTokLeftBrace
))
{
if
(
peekTokenClass
(
EHTokLeftBrace
))
{
if
(
function
.
getType
().
getQualifier
().
storage
!=
EvqGlobal
)
{
if
(
declarator
.
function
->
getType
().
getQualifier
().
storage
!=
EvqGlobal
)
{
expected
(
"only static member functions are accepted"
);
expected
(
"only static member functions are accepted"
);
return
false
;
return
false
;
}
}
TAttributeMap
attributes
;
declarator
.
loc
=
token
.
loc
;
accepted
=
acceptFunctionDefinition
(
function
,
nodeList
,
attributes
);
accepted
=
acceptFunctionDefinition
(
declarator
,
nodeList
);
}
}
}
else
}
else
expected
(
"function parameter list"
);
expected
(
"function parameter list"
);
...
@@ -2180,17 +2183,21 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function)
...
@@ -2180,17 +2183,21 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function)
// Do the work to create the function definition in addition to
// Do the work to create the function definition in addition to
// parsing the body (compound_statement).
// parsing the body (compound_statement).
bool
HlslGrammar
::
acceptFunctionDefinition
(
TFunction
&
function
,
TIntermNode
*&
nodeList
,
const
TAttributeMap
&
attributes
)
bool
HlslGrammar
::
acceptFunctionDefinition
(
TFunction
Declarator
&
declarator
,
TIntermNode
*&
nodeList
)
{
{
TFunction
&
functionDeclarator
=
parseContext
.
handleFunctionDeclarator
(
token
.
loc
,
function
,
false
/* not prototype */
);
parseContext
.
handleFunctionDeclarator
(
declarator
.
loc
,
*
declarator
.
function
,
false
/* not prototype */
);
TSourceLoc
loc
=
token
.
loc
;
// we might get back and entry-point
return
acceptFunctionBody
(
declarator
,
nodeList
);
}
bool
HlslGrammar
::
acceptFunctionBody
(
TFunctionDeclarator
&
declarator
,
TIntermNode
*&
nodeList
)
{
// we might get back an entry-point
TIntermNode
*
entryPointNode
=
nullptr
;
TIntermNode
*
entryPointNode
=
nullptr
;
// This does a pushScope()
// This does a pushScope()
TIntermNode
*
functionNode
=
parseContext
.
handleFunctionDefinition
(
loc
,
functionDeclarator
,
attributes
,
TIntermNode
*
functionNode
=
parseContext
.
handleFunctionDefinition
(
declarator
.
loc
,
*
declarator
.
function
,
entryPointNode
);
declarator
.
attributes
,
entryPointNode
);
// compound_statement
// compound_statement
TIntermNode
*
functionBody
=
nullptr
;
TIntermNode
*
functionBody
=
nullptr
;
...
@@ -2198,7 +2205,7 @@ bool HlslGrammar::acceptFunctionDefinition(TFunction& function, TIntermNode*& no
...
@@ -2198,7 +2205,7 @@ bool HlslGrammar::acceptFunctionDefinition(TFunction& function, TIntermNode*& no
return
false
;
return
false
;
// this does a popScope()
// this does a popScope()
parseContext
.
handleFunctionBody
(
loc
,
functionDeclarator
,
functionBody
,
functionNode
);
parseContext
.
handleFunctionBody
(
declarator
.
loc
,
*
declarator
.
function
,
functionBody
,
functionNode
);
// Hook up the 1 or 2 function definitions.
// Hook up the 1 or 2 function definitions.
nodeList
=
intermediate
.
growAggregate
(
nodeList
,
functionNode
);
nodeList
=
intermediate
.
growAggregate
(
nodeList
,
functionNode
);
...
...
hlsl/hlslGrammar.h
View file @
088d52ba
...
@@ -43,7 +43,8 @@
...
@@ -43,7 +43,8 @@
namespace
glslang
{
namespace
glslang
{
class
TAttributeMap
;
// forward declare
class
TAttributeMap
;
class
TFunctionDeclarator
;
// Should just be the grammar aspect of HLSL.
// Should just be the grammar aspect of HLSL.
// Described in more detail in hlslGrammar.cpp.
// Described in more detail in hlslGrammar.cpp.
...
@@ -91,7 +92,8 @@ namespace glslang {
...
@@ -91,7 +92,8 @@ namespace glslang {
const
TType
&
,
const
TString
&
memberName
);
const
TType
&
,
const
TString
&
memberName
);
bool
acceptFunctionParameters
(
TFunction
&
);
bool
acceptFunctionParameters
(
TFunction
&
);
bool
acceptParameterDeclaration
(
TFunction
&
);
bool
acceptParameterDeclaration
(
TFunction
&
);
bool
acceptFunctionDefinition
(
TFunction
&
,
TIntermNode
*&
nodeList
,
const
TAttributeMap
&
);
bool
acceptFunctionDefinition
(
TFunctionDeclarator
&
,
TIntermNode
*&
nodeList
);
bool
acceptFunctionBody
(
TFunctionDeclarator
&
declarator
,
TIntermNode
*&
nodeList
);
bool
acceptParenExpression
(
TIntermTyped
*&
);
bool
acceptParenExpression
(
TIntermTyped
*&
);
bool
acceptExpression
(
TIntermTyped
*&
);
bool
acceptExpression
(
TIntermTyped
*&
);
bool
acceptInitializer
(
TIntermTyped
*&
);
bool
acceptInitializer
(
TIntermTyped
*&
);
...
...
hlsl/hlslParseHelper.cpp
View file @
088d52ba
...
@@ -1414,7 +1414,7 @@ void HlslParseContext::assignLocations(TVariable& variable)
...
@@ -1414,7 +1414,7 @@ void HlslParseContext::assignLocations(TVariable& variable)
// Handle seeing a function declarator in the grammar. This is the precursor
// Handle seeing a function declarator in the grammar. This is the precursor
// to recognizing a function prototype or function definition.
// to recognizing a function prototype or function definition.
//
//
TFunction
&
HlslParseContext
::
handleFunctionDeclarator
(
const
TSourceLoc
&
loc
,
TFunction
&
function
,
bool
prototype
)
void
HlslParseContext
::
handleFunctionDeclarator
(
const
TSourceLoc
&
loc
,
TFunction
&
function
,
bool
prototype
)
{
{
//
//
// Multiple declarations of the same function name are allowed.
// Multiple declarations of the same function name are allowed.
...
@@ -1442,13 +1442,6 @@ TFunction& HlslParseContext::handleFunctionDeclarator(const TSourceLoc& loc, TFu
...
@@ -1442,13 +1442,6 @@ TFunction& HlslParseContext::handleFunctionDeclarator(const TSourceLoc& loc, TFu
// other forms of name collisions.
// other forms of name collisions.
if
(
!
symbolTable
.
insert
(
function
))
if
(
!
symbolTable
.
insert
(
function
))
error
(
loc
,
"function name is redeclaration of existing name"
,
function
.
getName
().
c_str
(),
""
);
error
(
loc
,
"function name is redeclaration of existing name"
,
function
.
getName
().
c_str
(),
""
);
//
// If this is a redeclaration, it could also be a definition,
// in which case, we need to use the parameter names from this one, and not the one that's
// being redeclared. So, pass back this declaration, not the one in the symbol table.
//
return
function
;
}
}
// Add interstage IO variables to the linkage in canonical order.
// Add interstage IO variables to the linkage in canonical order.
...
...
hlsl/hlslParseHelper.h
View file @
088d52ba
...
@@ -72,7 +72,7 @@ public:
...
@@ -72,7 +72,7 @@ public:
TIntermTyped
*
handleDotDereference
(
const
TSourceLoc
&
,
TIntermTyped
*
base
,
const
TString
&
field
);
TIntermTyped
*
handleDotDereference
(
const
TSourceLoc
&
,
TIntermTyped
*
base
,
const
TString
&
field
);
bool
isBuiltInMethod
(
const
TSourceLoc
&
,
TIntermTyped
*
base
,
const
TString
&
field
);
bool
isBuiltInMethod
(
const
TSourceLoc
&
,
TIntermTyped
*
base
,
const
TString
&
field
);
void
assignLocations
(
TVariable
&
variable
);
void
assignLocations
(
TVariable
&
variable
);
TFunction
&
handleFunctionDeclarator
(
const
TSourceLoc
&
,
TFunction
&
function
,
bool
prototype
);
void
handleFunctionDeclarator
(
const
TSourceLoc
&
,
TFunction
&
function
,
bool
prototype
);
TIntermAggregate
*
handleFunctionDefinition
(
const
TSourceLoc
&
,
TFunction
&
,
const
TAttributeMap
&
,
TIntermNode
*&
entryPointTree
);
TIntermAggregate
*
handleFunctionDefinition
(
const
TSourceLoc
&
,
TFunction
&
,
const
TAttributeMap
&
,
TIntermNode
*&
entryPointTree
);
TIntermNode
*
transformEntryPoint
(
const
TSourceLoc
&
,
TFunction
&
,
const
TAttributeMap
&
);
TIntermNode
*
transformEntryPoint
(
const
TSourceLoc
&
,
TFunction
&
,
const
TAttributeMap
&
);
void
handleFunctionBody
(
const
TSourceLoc
&
,
TFunction
&
,
TIntermNode
*
functionBody
,
TIntermNode
*&
node
);
void
handleFunctionBody
(
const
TSourceLoc
&
,
TFunction
&
,
TIntermNode
*
functionBody
,
TIntermNode
*&
node
);
...
...
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