Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
387c1bc3
Commit
387c1bc3
authored
Sep 30, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pretty types; use 6g -t to disable
R=ken OCL=16240 CL=16242
parent
5ed04d71
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
5 deletions
+102
-5
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+102
-5
No files found.
src/cmd/gc/subr.c
View file @
387c1bc3
...
...
@@ -933,18 +933,119 @@ out:
return
fmtstrcpy
(
fp
,
buf
);
}
static
char
*
basicnames
[]
=
{
[
TINT8
]
"int8"
,
[
TUINT8
]
"uint8"
,
[
TINT16
]
"int16"
,
[
TUINT16
]
"uint16"
,
[
TINT32
]
"int32"
,
[
TUINT32
]
"uint32"
,
[
TINT64
]
"int64"
,
[
TUINT64
]
"uint64"
,
[
TFLOAT32
]
"float32"
,
[
TFLOAT64
]
"float64"
,
[
TFLOAT80
]
"float80"
,
[
TBOOL
]
"bool"
,
[
TSTRING
]
"string"
};
int
Tpretty
(
Fmt
*
fp
,
Type
*
t
)
{
Type
*
t1
;
if
(
t
->
etype
!=
TFIELD
&&
t
->
sym
!=
S
&&
t
->
sym
->
name
[
0
]
!=
'_'
)
return
fmtprint
(
fp
,
"%S"
,
t
->
sym
);
if
(
t
->
etype
<
nelem
(
basicnames
)
&&
basicnames
[
t
->
etype
]
!=
nil
)
return
fmtprint
(
fp
,
"%s"
,
basicnames
[
t
->
etype
]);
switch
(
t
->
etype
)
{
case
TPTR32
:
case
TPTR64
:
return
fmtprint
(
fp
,
"*%T"
,
t
->
type
);
case
TFUNC
:
fmtprint
(
fp
,
"("
);
for
(
t1
=
t
->
type
->
down
->
down
->
type
;
t1
;
t1
=
t1
->
down
)
{
fmtprint
(
fp
,
"%T"
,
t1
);
if
(
t1
->
down
)
fmtprint
(
fp
,
", "
);
}
fmtprint
(
fp
,
")"
);
t1
=
t
->
type
->
down
->
type
;
if
(
t1
!=
T
)
{
if
(
t1
->
down
==
T
&&
t1
->
etype
!=
TFIELD
)
fmtprint
(
fp
,
" %T"
,
t1
);
else
{
fmtprint
(
fp
,
" ("
);
for
(;
t1
;
t1
=
t1
->
down
)
{
fmtprint
(
fp
,
"%T"
,
t1
);
if
(
t1
->
down
)
fmtprint
(
fp
,
", "
);
}
fmtprint
(
fp
,
")"
);
}
}
return
0
;
case
TARRAY
:
if
(
t
->
bound
>=
0
)
return
fmtprint
(
fp
,
"[%d]%T"
,
(
int
)
t
->
bound
,
t
->
type
);
return
fmtprint
(
fp
,
"[]%T"
,
t
->
type
);
case
TCHAN
:
return
fmtprint
(
fp
,
"chan %T"
,
t
->
type
);
case
TMAP
:
return
fmtprint
(
fp
,
"map[%T] %T"
,
t
->
down
,
t
->
type
);
case
TINTER
:
fmtprint
(
fp
,
"interface {"
);
for
(
t1
=
t
->
type
;
t1
!=
T
;
t1
=
t1
->
down
)
{
fmtprint
(
fp
,
" %S %T;"
,
t1
->
sym
,
t1
);
}
return
fmtprint
(
fp
,
" }"
);
case
TSTRUCT
:
fmtprint
(
fp
,
"struct {"
);
for
(
t1
=
t
->
type
;
t1
!=
T
;
t1
=
t1
->
down
)
{
fmtprint
(
fp
,
" %T;"
,
t1
);
}
return
fmtprint
(
fp
,
" }"
);
case
TFIELD
:
if
(
t
->
sym
==
S
||
t
->
sym
->
name
[
0
]
==
'_'
)
return
fmtprint
(
fp
,
"%T"
,
t
->
type
);
return
fmtprint
(
fp
,
"%S %T"
,
t
->
sym
,
t
->
type
);
}
// Don't know how to handle - fall back to detailed prints.
return
-
1
;
}
int
Tconv
(
Fmt
*
fp
)
{
char
buf
[
500
],
buf1
[
500
];
Type
*
t
,
*
t1
;
int
et
;
t
=
va_arg
(
fp
->
args
,
Type
*
);
if
(
t
==
T
)
return
fmtstrcpy
(
fp
,
"<T>"
);
t
->
trecur
++
;
if
(
t
->
trecur
>
5
)
{
strncat
(
buf
,
"..."
,
sizeof
(
buf
));
goto
out
;
}
if
(
!
debug
[
't'
]
&&
Tpretty
(
fp
,
t
)
>=
0
)
{
t
->
trecur
--
;
return
0
;
}
et
=
t
->
etype
;
strcpy
(
buf
,
""
);
...
...
@@ -952,10 +1053,6 @@ Tconv(Fmt *fp)
if
(
t
->
sym
->
name
[
0
]
!=
'_'
)
snprint
(
buf
,
sizeof
(
buf
),
"<%S>"
,
t
->
sym
);
}
if
(
t
->
trecur
>
5
)
{
strncat
(
buf
,
"..."
,
sizeof
(
buf
));
goto
out
;
}
switch
(
et
)
{
default:
...
...
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