Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
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
lvzhengyang
riscv-gcc-1
Commits
221b3e6c
Commit
221b3e6c
authored
Jul 12, 2016
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
escape: Add escape notes to export data.
Reviewed-on:
https://go-review.googlesource.com/22375
From-SVN: r238266
parent
1a58b548
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
5 deletions
+75
-5
gcc/go/gofrontend/MERGE
+1
-1
gcc/go/gofrontend/export.cc
+15
-0
gcc/go/gofrontend/export.h
+5
-0
gcc/go/gofrontend/gogo.cc
+14
-4
gcc/go/gofrontend/import.cc
+36
-0
gcc/go/gofrontend/import.h
+4
-0
No files found.
gcc/go/gofrontend/MERGE
View file @
221b3e6c
c8fdad389ce6f439a02fb654d231053b47ff4e02
5ea5c078829ae83bccb598772fff7c1a04e23e65
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
gcc/go/gofrontend/export.cc
View file @
221b3e6c
...
...
@@ -436,6 +436,21 @@ Export::write_type(const Type* type)
this
->
type_refs_
[
type
]
=
index
;
}
// Export escape note.
void
Export
::
write_escape
(
std
::
string
*
note
)
{
if
(
note
!=
NULL
&&
*
note
!=
"esc:0x0"
)
{
this
->
write_c_string
(
" "
);
char
buf
[
50
];
go_assert
(
note
->
find
(
"esc:"
)
!=
std
::
string
::
npos
);
snprintf
(
buf
,
sizeof
buf
,
"<%s>"
,
note
->
c_str
());
this
->
write_c_string
(
buf
);
}
}
// Add the builtin types to the export table.
void
...
...
gcc/go/gofrontend/export.h
View file @
221b3e6c
...
...
@@ -161,6 +161,11 @@ class Export : public String_dump
void
write_type
(
const
Type
*
);
// Write the escape note to the export stream. If NOTE is NULL, write
// nothing.
void
write_escape
(
std
::
string
*
note
);
private
:
Export
(
const
Export
&
);
Export
&
operator
=
(
const
Export
&
);
...
...
gcc/go/gofrontend/gogo.cc
View file @
221b3e6c
...
...
@@ -4794,6 +4794,7 @@ Function::export_func_with_type(Export* exp, const std::string& name,
exp
->
write_c_string
(
"("
);
const
Typed_identifier
*
receiver
=
fntype
->
receiver
();
exp
->
write_name
(
receiver
->
name
());
exp
->
write_escape
(
receiver
->
note
());
exp
->
write_c_string
(
" "
);
exp
->
write_type
(
receiver
->
type
());
exp
->
write_c_string
(
") "
);
...
...
@@ -4817,6 +4818,7 @@ Function::export_func_with_type(Export* exp, const std::string& name,
else
exp
->
write_c_string
(
", "
);
exp
->
write_name
(
p
->
name
());
exp
->
write_escape
(
p
->
note
());
exp
->
write_c_string
(
" "
);
if
(
!
is_varargs
||
p
+
1
!=
parameters
->
end
())
exp
->
write_type
(
p
->
type
());
...
...
@@ -4850,6 +4852,7 @@ Function::export_func_with_type(Export* exp, const std::string& name,
else
exp
->
write_c_string
(
", "
);
exp
->
write_name
(
p
->
name
());
exp
->
write_escape
(
p
->
note
());
exp
->
write_c_string
(
" "
);
exp
->
write_type
(
p
->
type
());
}
...
...
@@ -4875,9 +4878,11 @@ Function::import_func(Import* imp, std::string* pname,
{
imp
->
require_c_string
(
"("
);
std
::
string
name
=
imp
->
read_name
();
std
::
string
escape_note
=
imp
->
read_escape
();
imp
->
require_c_string
(
" "
);
Type
*
rtype
=
imp
->
read_type
();
*
preceiver
=
new
Typed_identifier
(
name
,
rtype
,
imp
->
location
());
(
*
preceiver
)
->
set_note
(
escape_note
);
imp
->
require_c_string
(
") "
);
}
...
...
@@ -4894,6 +4899,7 @@ Function::import_func(Import* imp, std::string* pname,
while
(
true
)
{
std
::
string
name
=
imp
->
read_name
();
std
::
string
escape_note
=
imp
->
read_escape
();
imp
->
require_c_string
(
" "
);
if
(
imp
->
match_c_string
(
"..."
))
...
...
@@ -4905,8 +4911,9 @@ Function::import_func(Import* imp, std::string* pname,
Type
*
ptype
=
imp
->
read_type
();
if
(
*
is_varargs
)
ptype
=
Type
::
make_array_type
(
ptype
,
NULL
);
parameters
->
push_back
(
Typed_identifier
(
name
,
ptype
,
imp
->
location
()));
Typed_identifier
t
=
Typed_identifier
(
name
,
ptype
,
imp
->
location
());
t
.
set_note
(
escape_note
);
parameters
->
push_back
(
t
);
if
(
imp
->
peek_char
()
!=
','
)
break
;
go_assert
(
!*
is_varargs
);
...
...
@@ -4934,10 +4941,13 @@ Function::import_func(Import* imp, std::string* pname,
while
(
true
)
{
std
::
string
name
=
imp
->
read_name
();
std
::
string
note
=
imp
->
read_escape
();
imp
->
require_c_string
(
" "
);
Type
*
rtype
=
imp
->
read_type
();
results
->
push_back
(
Typed_identifier
(
name
,
rtype
,
imp
->
location
()));
Typed_identifier
t
=
Typed_identifier
(
name
,
rtype
,
imp
->
location
());
t
.
set_note
(
note
);
results
->
push_back
(
t
);
if
(
imp
->
peek_char
()
!=
','
)
break
;
imp
->
require_c_string
(
", "
);
...
...
gcc/go/gofrontend/import.cc
View file @
221b3e6c
...
...
@@ -762,6 +762,42 @@ Import::read_type()
return
type
;
}
// Read an escape note.
std
::
string
Import
::
read_escape
()
{
if
(
this
->
match_c_string
(
" <esc:"
))
{
Stream
*
stream
=
this
->
stream_
;
this
->
require_c_string
(
" <esc:"
);
std
::
string
escape
=
"esc:"
;
int
c
;
while
(
true
)
{
c
=
stream
->
get_char
();
if
(
c
!=
'x'
&&
!
ISXDIGIT
(
c
))
break
;
escape
+=
c
;
}
if
(
c
!=
'>'
)
{
error_at
(
this
->
location
(),
"error in import data at %d: expect %< %> or %<>%>, got %c"
,
stream
->
pos
(),
c
);
stream
->
set_saw_error
();
stream
->
advance
(
1
);
escape
=
Escape_note
::
make_tag
(
Node
::
ESCAPE_UNKNOWN
);
}
return
escape
;
}
else
return
Escape_note
::
make_tag
(
Node
::
ESCAPE_UNKNOWN
);
}
// Register the builtin types.
void
...
...
gcc/go/gofrontend/import.h
View file @
221b3e6c
...
...
@@ -197,6 +197,10 @@ class Import
Type
*
read_type
();
// Read an escape note.
std
::
string
read_escape
();
private
:
static
Stream
*
try_package_in_directory
(
const
std
::
string
&
,
Location
);
...
...
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