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
3473a4b9
Commit
3473a4b9
authored
Aug 06, 2015
by
John Kessenich
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #53 from google/get-string-name-or-num
Add getStringNameOrNum() in TSourceLoc.
parents
30669536
bb63bd5e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
19 deletions
+12
-19
Common.h
glslang/Include/Common.h
+7
-0
InfoSink.h
glslang/Include/InfoSink.h
+2
-6
Pp.cpp
glslang/MachineIndependent/preprocessor/Pp.cpp
+3
-13
No files found.
glslang/Include/Common.h
View file @
3473a4b9
...
@@ -190,6 +190,13 @@ inline const TString String(const int i, const int base = 10)
...
@@ -190,6 +190,13 @@ inline const TString String(const int i, const int base = 10)
struct
TSourceLoc
{
struct
TSourceLoc
{
void
init
()
{
name
=
nullptr
;
string
=
0
;
line
=
0
;
column
=
0
;
}
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
const
char
*
name
;
// descriptive name for this string
int
string
;
int
string
;
int
line
;
int
line
;
...
...
glslang/Include/InfoSink.h
View file @
3473a4b9
...
@@ -98,12 +98,8 @@ public:
...
@@ -98,12 +98,8 @@ public:
void
location
(
const
TSourceLoc
&
loc
)
{
void
location
(
const
TSourceLoc
&
loc
)
{
const
int
maxSize
=
24
;
const
int
maxSize
=
24
;
char
locText
[
maxSize
];
char
locText
[
maxSize
];
if
(
loc
.
name
!=
nullptr
)
{
snprintf
(
locText
,
maxSize
,
":%d"
,
loc
.
line
);
append
(
loc
.
name
);
append
(
loc
.
getStringNameOrNum
(
false
).
c_str
());
snprintf
(
locText
,
maxSize
,
":%d"
,
loc
.
line
);
}
else
{
snprintf
(
locText
,
maxSize
,
"%d:%d"
,
loc
.
string
,
loc
.
line
);
}
append
(
locText
);
append
(
locText
);
append
(
": "
);
append
(
": "
);
}
}
...
...
glslang/MachineIndependent/preprocessor/Pp.cpp
View file @
3473a4b9
...
@@ -620,13 +620,7 @@ int TPpContext::CPPinclude(TPpToken* ppToken)
...
@@ -620,13 +620,7 @@ int TPpContext::CPPinclude(TPpToken* ppToken)
std
::
ostringstream
content
;
std
::
ostringstream
content
;
content
<<
"#line "
<<
forNextLine
<<
" "
<<
"
\"
"
<<
sourceName
<<
"
\"\n
"
;
content
<<
"#line "
<<
forNextLine
<<
" "
<<
"
\"
"
<<
sourceName
<<
"
\"\n
"
;
content
<<
replacement
<<
(
replacement
.
back
()
==
'\n'
?
""
:
"
\n
"
);
content
<<
replacement
<<
(
replacement
.
back
()
==
'\n'
?
""
:
"
\n
"
);
content
<<
"#line "
<<
directiveLoc
.
line
+
forNextLine
<<
" "
;
content
<<
"#line "
<<
directiveLoc
.
line
+
forNextLine
<<
" "
<<
directiveLoc
.
getStringNameOrNum
()
<<
"
\n
"
;
if
(
directiveLoc
.
name
!=
nullptr
)
{
content
<<
"
\"
"
<<
directiveLoc
.
name
<<
"
\"
"
;
}
else
{
content
<<
directiveLoc
.
string
;
}
content
<<
"
\n
"
;
pushInput
(
new
TokenizableString
(
directiveLoc
,
content
.
str
(),
this
));
pushInput
(
new
TokenizableString
(
directiveLoc
,
content
.
str
(),
this
));
}
}
// At EOF, there's no "current" location anymore.
// At EOF, there's no "current" location anymore.
...
@@ -1015,13 +1009,9 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool
...
@@ -1015,13 +1009,9 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool
return
1
;
return
1
;
case
PpAtomFileMacro
:
{
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__"
);
parseContext
.
ppRequireExtensions
(
ppToken
->
loc
,
1
,
&
E_GL_GOOGLE_cpp_style_line_directive
,
"filename-based __FILE__"
);
sprintf
(
ppToken
->
name
,
"
\"
%s
\"
"
,
current_file
);
sprintf
(
ppToken
->
name
,
"%s"
,
ppToken
->
loc
.
getStringNameOrNum
().
c_str
());
}
else
{
ppToken
->
ival
=
parseContext
.
getCurrentLoc
().
string
;
sprintf
(
ppToken
->
name
,
"%d"
,
ppToken
->
ival
);
}
UngetToken
(
PpAtomConstInt
,
ppToken
);
UngetToken
(
PpAtomConstInt
,
ppToken
);
return
1
;
return
1
;
}
}
...
...
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