Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glslang
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
deqp-deps
glslang
Commits
bb63bd5e
Commit
bb63bd5e
authored
9 years ago
by
Lei Zhang
Browse files
Options
Downloads
Patches
Plain Diff
Create a new method to return string name or number to DRY code.
parent
0718e45c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
glslang/Include/Common.h
+7
-0
7 additions, 0 deletions
glslang/Include/Common.h
glslang/Include/InfoSink.h
+2
-6
2 additions, 6 deletions
glslang/Include/InfoSink.h
glslang/MachineIndependent/preprocessor/Pp.cpp
+3
-13
3 additions, 13 deletions
glslang/MachineIndependent/preprocessor/Pp.cpp
with
12 additions
and
19 deletions
glslang/Include/Common.h
+
7
−
0
View file @
bb63bd5e
...
...
@@ -190,6 +190,13 @@ inline const TString String(const int i, const int base = 10)
struct
TSourceLoc
{
void
init
()
{
name
=
nullptr
;
string
=
0
;
line
=
0
;
column
=
0
;
}
// Returns the name if it exists. Otherwise, returns the string number.
std
::
string
getStringNameOrNum
(
bool
quoteStringName
=
true
)
const
{
if
(
name
!=
nullptr
)
return
quoteStringName
?
(
"
\"
"
+
std
::
string
(
name
)
+
"
\"
"
)
:
name
;
return
std
::
to_string
(
string
);
}
const
char
*
name
;
// descriptive name for this string
int
string
;
int
line
;
...
...
This diff is collapsed.
Click to expand it.
glslang/Include/InfoSink.h
+
2
−
6
View file @
bb63bd5e
...
...
@@ -98,12 +98,8 @@ public:
void
location
(
const
TSourceLoc
&
loc
)
{
const
int
maxSize
=
24
;
char
locText
[
maxSize
];
if
(
loc
.
name
!=
nullptr
)
{
append
(
loc
.
name
);
snprintf
(
locText
,
maxSize
,
":%d"
,
loc
.
line
);
}
else
{
snprintf
(
locText
,
maxSize
,
"%d:%d"
,
loc
.
string
,
loc
.
line
);
}
snprintf
(
locText
,
maxSize
,
":%d"
,
loc
.
line
);
append
(
loc
.
getStringNameOrNum
(
false
).
c_str
());
append
(
locText
);
append
(
": "
);
}
...
...
This diff is collapsed.
Click to expand it.
glslang/MachineIndependent/preprocessor/Pp.cpp
+
3
−
13
View file @
bb63bd5e
...
...
@@ -620,13 +620,7 @@ int TPpContext::CPPinclude(TPpToken* ppToken)
std
::
ostringstream
content
;
content
<<
"#line "
<<
forNextLine
<<
" "
<<
"
\"
"
<<
sourceName
<<
"
\"\n
"
;
content
<<
replacement
<<
(
replacement
.
back
()
==
'\n'
?
""
:
"
\n
"
);
content
<<
"#line "
<<
directiveLoc
.
line
+
forNextLine
<<
" "
;
if
(
directiveLoc
.
name
!=
nullptr
)
{
content
<<
"
\"
"
<<
directiveLoc
.
name
<<
"
\"
"
;
}
else
{
content
<<
directiveLoc
.
string
;
}
content
<<
"
\n
"
;
content
<<
"#line "
<<
directiveLoc
.
line
+
forNextLine
<<
" "
<<
directiveLoc
.
getStringNameOrNum
()
<<
"
\n
"
;
pushInput
(
new
TokenizableString
(
directiveLoc
,
content
.
str
(),
this
));
}
// At EOF, there's no "current" location anymore.
...
...
@@ -1015,13 +1009,9 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool
return
1
;
case
PpAtomFileMacro
:
{
if
(
const
char
*
current_file
=
parseContext
.
getCurrentLoc
().
name
)
{
if
(
parseContext
.
getCurrentLoc
().
name
)
parseContext
.
ppRequireExtensions
(
ppToken
->
loc
,
1
,
&
E_GL_GOOGLE_cpp_style_line_directive
,
"filename-based __FILE__"
);
sprintf
(
ppToken
->
name
,
"
\"
%s
\"
"
,
current_file
);
}
else
{
ppToken
->
ival
=
parseContext
.
getCurrentLoc
().
string
;
sprintf
(
ppToken
->
name
,
"%d"
,
ppToken
->
ival
);
}
sprintf
(
ppToken
->
name
,
"%s"
,
ppToken
->
loc
.
getStringNameOrNum
().
c_str
());
UngetToken
(
PpAtomConstInt
,
ppToken
);
return
1
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment