Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
f27aaf48
Commit
f27aaf48
authored
Oct 30, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
structure field annotation strings
R=ken OCL=18176 CL=18176
parent
ebf14c62
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
4 deletions
+30
-4
dcl.c
src/cmd/gc/dcl.c
+14
-0
go.h
src/cmd/gc/go.h
+1
-0
go.y
src/cmd/gc/go.y
+9
-1
subr.c
src/cmd/gc/subr.c
+6
-3
No files found.
src/cmd/gc/dcl.c
View file @
f27aaf48
...
...
@@ -450,10 +450,12 @@ stotype(Node *n, Type **t)
Type
*
f
;
Iter
save
;
char
buf
[
100
];
String
*
note
;
n
=
listfirst
(
&
save
,
&
n
);
loop:
note
=
nil
;
if
(
n
==
N
)
{
*
t
=
T
;
return
t
;
...
...
@@ -471,8 +473,20 @@ loop:
if
(
n
->
type
->
etype
==
TARRAY
&&
n
->
type
->
bound
<
0
)
yyerror
(
"type of a structure field cannot be an open array"
);
switch
(
n
->
val
.
ctype
)
{
case
CTSTR
:
note
=
n
->
val
.
u
.
sval
;
break
;
default:
yyerror
(
"structure field annotation must be string"
);
case
CTxxx
:
note
=
nil
;
break
;
}
f
=
typ
(
TFIELD
);
f
->
type
=
n
->
type
;
f
->
note
=
note
;
if
(
n
->
left
!=
N
&&
n
->
left
->
op
==
ONAME
)
{
f
->
nname
=
n
->
left
;
...
...
src/cmd/gc/go.h
View file @
f27aaf48
...
...
@@ -147,6 +147,7 @@ struct Type
// TFIELD
Type
*
down
;
// also used in TMAP
String
*
note
;
// literal string annotation
// TARRAY
int32
bound
;
// negative is dynamic array
...
...
src/cmd/gc/go.y
View file @
f27aaf48
...
...
@@ -72,6 +72,7 @@
%
type
<
type
>
non_name_type
Anon_fn_type
Bnon_fn_type
%
type
<
type
>
Anon_chan_type
Bnon_chan_type
%
type
<
type
>
indcl
fnlitdcl
dotdotdot
%
type
<
val
>
oliteral
%
type
<
val
>
hidden_constant
%
type
<
node
>
hidden_dcl
hidden_structdcl
...
...
@@ -1388,10 +1389,11 @@ structdcl:
$$
=
nod
(
ODCLFIELD
,
$
1
,
N
);
$$
=
nod
(
OLIST
,
$$,
$
3
);
}
|
new_name
type
|
new_name
type
oliteral
{
$$
=
nod
(
ODCLFIELD
,
$
1
,
N
);
$$->
type
=
$
2
;
$$->
val
=
$
3
;
}
|
embed
|
'*'
embed
...
...
@@ -1761,6 +1763,12 @@ oexport:
$$
=
1
;
}
oliteral
:
{
$$.
ctype
=
CTxxx
;
}
|
LLITERAL
/*
*
import
syntax
from
header
of
*
an
output
package
...
...
src/cmd/gc/subr.c
View file @
f27aaf48
...
...
@@ -1078,9 +1078,12 @@ Tpretty(Fmt *fp, Type *t)
if
(
t
->
sym
==
S
||
t
->
embedded
)
{
if
(
exporting
)
fmtprint
(
fp
,
"? "
);
return
fmtprint
(
fp
,
"%T"
,
t
->
type
);
}
return
fmtprint
(
fp
,
"%hS %T"
,
t
->
sym
,
t
->
type
);
fmtprint
(
fp
,
"%T"
,
t
->
type
);
}
else
fmtprint
(
fp
,
"%hS %T"
,
t
->
sym
,
t
->
type
);
if
(
t
->
note
)
fmtprint
(
fp
,
"
\"
%Z
\"
"
,
t
->
note
);
return
0
;
case
TFORW
:
if
(
exporting
)
...
...
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