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
7a41f96d
Commit
7a41f96d
authored
Mar 22, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Implement 'this' keyword.
parent
3778979c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
9 deletions
+57
-9
hlsl.this.frag.out
Test/baseResults/hlsl.this.frag.out
+0
-0
hlsl.this.frag
Test/hlsl.this.frag
+29
-0
revision.h
glslang/Include/revision.h
+2
-2
Hlsl.FromFile.cpp
gtests/Hlsl.FromFile.cpp
+1
-0
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+17
-0
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+5
-6
hlslScanContext.cpp
hlsl/hlslScanContext.cpp
+2
-1
hlslTokens.h
hlsl/hlslTokens.h
+1
-0
No files found.
Test/baseResults/hlsl.this.frag.out
0 → 100755
View file @
7a41f96d
This diff is collapsed.
Click to expand it.
Test/hlsl.this.frag
0 → 100755
View file @
7a41f96d
static
float2
var
=
float2
(
1
.
0
,
2
.
0
);
struct
type1
{
int
memFun1
(
int3
var
)
{
return
var
.
z
+
this
.
var
+
var2
;
}
int
memFun2
(
int
a
)
{
int3
var
=
int3
(
1
,
2
,
3
);
return
var
.
z
+
(
int
)
bar
.
y
+
this
.
var2
;
}
float2
bar
;
int
var
;
int
var2
;
};
float4
main
()
:
SV_Target0
{
type1
T
;
T
.
bar
=
var
;
T
.
var
=
7
;
T
.
var2
=
9
;
int
i
=
T
.
memFun1
(
int3
(
10
,
11
,
12
));
i
+=
T
.
memFun2
(
17
);
return
float4
(
i
,
i
,
i
,
i
);
}
glslang/Include/revision.h
View file @
7a41f96d
...
@@ -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.19
29
"
#define GLSLANG_REVISION "Overload400-PrecQual.19
30
"
#define GLSLANG_DATE "2
1
-Mar-2017"
#define GLSLANG_DATE "2
2
-Mar-2017"
gtests/Hlsl.FromFile.cpp
View file @
7a41f96d
...
@@ -235,6 +235,7 @@ INSTANTIATE_TEST_CASE_P(
...
@@ -235,6 +235,7 @@ INSTANTIATE_TEST_CASE_P(
{
"hlsl.structin.vert"
,
"main"
},
{
"hlsl.structin.vert"
,
"main"
},
{
"hlsl.structIoFourWay.frag"
,
"main"
},
{
"hlsl.structIoFourWay.frag"
,
"main"
},
{
"hlsl.structStructName.frag"
,
"main"
},
{
"hlsl.structStructName.frag"
,
"main"
},
{
"hlsl.this.frag"
,
"main"
},
{
"hlsl.intrinsics.vert"
,
"VertexShaderFunction"
},
{
"hlsl.intrinsics.vert"
,
"VertexShaderFunction"
},
{
"hlsl.matType.frag"
,
"PixelShaderFunction"
},
{
"hlsl.matType.frag"
,
"PixelShaderFunction"
},
{
"hlsl.matType.bool.frag"
,
"main"
},
{
"hlsl.matType.bool.frag"
,
"main"
},
...
...
hlsl/hlslGrammar.cpp
View file @
7a41f96d
...
@@ -75,16 +75,33 @@ void HlslGrammar::unimplemented(const char* error)
...
@@ -75,16 +75,33 @@ void HlslGrammar::unimplemented(const char* error)
parseContext
.
error
(
token
.
loc
,
"Unimplemented"
,
error
,
""
);
parseContext
.
error
(
token
.
loc
,
"Unimplemented"
,
error
,
""
);
}
}
// IDENTIFIER
// THIS
// type that can be used as IDENTIFIER
//
// Only process the next token if it is an identifier.
// Only process the next token if it is an identifier.
// Return true if it was an identifier.
// Return true if it was an identifier.
bool
HlslGrammar
::
acceptIdentifier
(
HlslToken
&
idToken
)
bool
HlslGrammar
::
acceptIdentifier
(
HlslToken
&
idToken
)
{
{
// IDENTIFIER
if
(
peekTokenClass
(
EHTokIdentifier
))
{
if
(
peekTokenClass
(
EHTokIdentifier
))
{
idToken
=
token
;
idToken
=
token
;
advanceToken
();
advanceToken
();
return
true
;
return
true
;
}
}
// THIS
// -> maps to the IDENTIFIER spelled with the internal special name for 'this'
if
(
peekTokenClass
(
EHTokThis
))
{
idToken
=
token
;
advanceToken
();
idToken
.
tokenClass
=
EHTokIdentifier
;
idToken
.
string
=
NewPoolTString
(
intermediate
.
implicitThisName
);
return
true
;
}
// type that can be used as IDENTIFIER
// Even though "sample", "bool", "float", etc keywords (for types, interpolation modifiers),
// Even though "sample", "bool", "float", etc keywords (for types, interpolation modifiers),
// they ARE still accepted as identifiers. This is not a dense space: e.g, "void" is not a
// they ARE still accepted as identifiers. This is not a dense space: e.g, "void" is not a
// valid identifier, nor is "linear". This code special cases the known instances of this, so
// valid identifier, nor is "linear". This code special cases the known instances of this, so
...
...
hlsl/hlslParseHelper.cpp
View file @
7a41f96d
...
@@ -1538,15 +1538,14 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
...
@@ -1538,15 +1538,14 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
TVariable
*
variable
=
new
TVariable
(
param
.
name
,
*
param
.
type
);
TVariable
*
variable
=
new
TVariable
(
param
.
name
,
*
param
.
type
);
if
(
i
==
0
&&
function
.
hasImplicitThis
())
{
if
(
i
==
0
&&
function
.
hasImplicitThis
())
{
// 'this' members are already in a symbol-table level,
//
Anonymous
'this' members are already in a symbol-table level,
// and we need to know what function parameter to map them to
// and we need to know what function parameter to map them to
.
symbolTable
.
makeInternalVariable
(
*
variable
);
symbolTable
.
makeInternalVariable
(
*
variable
);
pushImplicitThis
(
variable
);
pushImplicitThis
(
variable
);
}
else
{
// Insert the parameters with name in the symbol table.
if
(
!
symbolTable
.
insert
(
*
variable
))
error
(
loc
,
"redefinition"
,
variable
->
getName
().
c_str
(),
""
);
}
}
// Insert the parameters with name in the symbol table.
if
(
!
symbolTable
.
insert
(
*
variable
))
error
(
loc
,
"redefinition"
,
variable
->
getName
().
c_str
(),
""
);
// Add the parameter to the AST
// Add the parameter to the AST
paramNodes
=
intermediate
.
growAggregate
(
paramNodes
,
paramNodes
=
intermediate
.
growAggregate
(
paramNodes
,
intermediate
.
addSymbol
(
*
variable
,
loc
),
intermediate
.
addSymbol
(
*
variable
,
loc
),
...
...
hlsl/hlslScanContext.cpp
View file @
7a41f96d
...
@@ -333,6 +333,7 @@ void HlslScanContext::fillInKeywordMap()
...
@@ -333,6 +333,7 @@ void HlslScanContext::fillInKeywordMap()
(
*
KeywordMap
)[
"cbuffer"
]
=
EHTokCBuffer
;
(
*
KeywordMap
)[
"cbuffer"
]
=
EHTokCBuffer
;
(
*
KeywordMap
)[
"tbuffer"
]
=
EHTokTBuffer
;
(
*
KeywordMap
)[
"tbuffer"
]
=
EHTokTBuffer
;
(
*
KeywordMap
)[
"typedef"
]
=
EHTokTypedef
;
(
*
KeywordMap
)[
"typedef"
]
=
EHTokTypedef
;
(
*
KeywordMap
)[
"this"
]
=
EHTokThis
;
(
*
KeywordMap
)[
"true"
]
=
EHTokBoolConstant
;
(
*
KeywordMap
)[
"true"
]
=
EHTokBoolConstant
;
(
*
KeywordMap
)[
"false"
]
=
EHTokBoolConstant
;
(
*
KeywordMap
)[
"false"
]
=
EHTokBoolConstant
;
...
@@ -374,7 +375,6 @@ void HlslScanContext::fillInKeywordMap()
...
@@ -374,7 +375,6 @@ void HlslScanContext::fillInKeywordMap()
ReservedSet
->
insert
(
"sizeof"
);
ReservedSet
->
insert
(
"sizeof"
);
ReservedSet
->
insert
(
"static_cast"
);
ReservedSet
->
insert
(
"static_cast"
);
ReservedSet
->
insert
(
"template"
);
ReservedSet
->
insert
(
"template"
);
ReservedSet
->
insert
(
"this"
);
ReservedSet
->
insert
(
"throw"
);
ReservedSet
->
insert
(
"throw"
);
ReservedSet
->
insert
(
"try"
);
ReservedSet
->
insert
(
"try"
);
ReservedSet
->
insert
(
"typename"
);
ReservedSet
->
insert
(
"typename"
);
...
@@ -827,6 +827,7 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
...
@@ -827,6 +827,7 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
case
EHTokTypedef
:
case
EHTokTypedef
:
case
EHTokCBuffer
:
case
EHTokCBuffer
:
case
EHTokTBuffer
:
case
EHTokTBuffer
:
case
EHTokThis
:
return
keyword
;
return
keyword
;
case
EHTokBoolConstant
:
case
EHTokBoolConstant
:
...
...
hlsl/hlslTokens.h
View file @
7a41f96d
...
@@ -273,6 +273,7 @@ enum EHlslTokenClass {
...
@@ -273,6 +273,7 @@ enum EHlslTokenClass {
EHTokCBuffer
,
EHTokCBuffer
,
EHTokTBuffer
,
EHTokTBuffer
,
EHTokTypedef
,
EHTokTypedef
,
EHTokThis
,
// constant
// constant
EHTokFloatConstant
,
EHTokFloatConstant
,
...
...
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