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
28b97027
Commit
28b97027
authored
Sep 13, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct signal name thru package rename
R=r OCL=15312 CL=15312
parent
bb3269fb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
166 deletions
+133
-166
src/cmd/6g/gsubr.c
src/cmd/6g/gsubr.c
+1
-1
src/cmd/gc/dcl.c
src/cmd/gc/dcl.c
+56
-44
src/cmd/gc/go.h
src/cmd/gc/go.h
+8
-5
src/cmd/gc/go.y
src/cmd/gc/go.y
+2
-2
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+62
-111
src/runtime/print.c
src/runtime/print.c
+4
-3
No files found.
src/cmd/6g/gsubr.c
View file @
28b97027
...
@@ -329,7 +329,7 @@ loop:
...
@@ -329,7 +329,7 @@ loop:
s
->
local
=
2
;
s
->
local
=
2
;
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%s_%s"
,
e
,
s
->
name
);
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%s_%s"
,
e
,
s
->
name
);
s
=
pkglookup
(
namebuf
,
s
->
package
);
s
=
pkglookup
(
namebuf
,
s
->
o
package
);
return
s
;
return
s
;
}
}
...
...
src/cmd/gc/dcl.c
View file @
28b97027
...
@@ -219,6 +219,11 @@ methodname(Node *n, Type *t)
...
@@ -219,6 +219,11 @@ methodname(Node *n, Type *t)
{
{
Sym
*
s
;
Sym
*
s
;
print
(
"methodname: n=%N t=%lT
\n
"
,
n
,
t
);
if
(
t
==
T
)
goto
bad
;
// method receiver must be typename or *typename
s
=
S
;
s
=
S
;
if
(
t
->
sym
!=
S
)
if
(
t
->
sym
!=
S
)
s
=
t
->
sym
;
s
=
t
->
sym
;
...
@@ -226,12 +231,9 @@ methodname(Node *n, Type *t)
...
@@ -226,12 +231,9 @@ methodname(Node *n, Type *t)
t
=
t
->
type
;
t
=
t
->
type
;
if
(
t
->
sym
!=
S
)
if
(
t
->
sym
!=
S
)
s
=
t
->
sym
;
s
=
t
->
sym
;
// if(t->etype != TSTRUCT)
// goto bad;
if
(
s
==
S
)
if
(
s
==
S
)
goto
bad
;
goto
bad
;
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%s_%s"
,
s
->
name
,
n
->
sym
->
name
);
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%s_%s"
,
s
->
name
,
n
->
sym
->
name
);
return
newname
(
lookup
(
namebuf
));
return
newname
(
lookup
(
namebuf
));
...
@@ -242,69 +244,84 @@ bad:
...
@@ -242,69 +244,84 @@ bad:
/*
/*
* add a method, declared as a function,
* add a method, declared as a function,
*
into the structur
e
*
n is fieldname, pa is base type, t is function typ
e
*/
*/
void
void
addmethod
(
Node
*
n
,
Type
*
pa
,
Type
*
t
)
addmethod
(
Node
*
n
,
Type
*
t
)
{
{
Type
*
f
,
*
d
,
*
p
;
Type
*
f
,
*
d
,
*
pa
;
Sym
*
s
;
Sym
*
st
,
*
sf
;
int
ptr
;
// get field sym
if
(
n
==
N
)
goto
bad
;
if
(
n
->
op
!=
ONAME
)
if
(
n
->
op
!=
ONAME
)
goto
bad
;
goto
bad
;
s
=
n
->
sym
;
s
f
=
n
->
sym
;
if
(
s
==
S
)
if
(
s
f
==
S
)
goto
bad
;
goto
bad
;
// get parent type sym
pa
=
*
getthis
(
t
);
// ptr to this structure
if
(
pa
==
T
)
if
(
pa
==
T
)
goto
bad
;
goto
bad
;
if
(
!
isptr
[
pa
->
etype
])
pa
=
pa
->
type
;
// ptr to this field
if
(
pa
==
T
)
goto
bad
;
goto
bad
;
p
=
pa
->
type
;
p
a
=
pa
->
type
;
// ptr to this type
if
(
p
==
T
)
if
(
p
a
==
T
)
goto
bad
;
goto
bad
;
if
(
p
->
etype
!=
TSTRUCT
)
// optionally rip off ptr to type
ptr
=
0
;
if
(
pa
->
sym
==
S
&&
isptr
[
pa
->
etype
])
{
ptr
=
1
;
pa
=
pa
->
type
;
if
(
pa
==
T
)
goto
bad
;
goto
bad
;
if
(
p
->
sym
==
S
)
}
if
(
pa
->
etype
==
TINTER
)
yyerror
(
"no methods on interfaces"
);
// and finally the receiver sym
st
=
pa
->
sym
;
if
(
st
==
S
)
goto
bad
;
goto
bad
;
if
(
!
st
->
local
)
{
yyerror
(
"method receiver type must be locally defined: %S"
,
st
);
return
;
}
if
(
p
->
type
==
T
)
{
print
(
"addmethod: n=%N t=%lT sf=%S st=%S
\n
"
,
n
=
nod
(
ODCLFIELD
,
newname
(
s
),
N
);
n
,
t
,
sf
,
st
);
n
=
nod
(
ODCLFIELD
,
newname
(
sf
),
N
);
n
->
type
=
t
;
n
->
type
=
t
;
stotype
(
n
,
&
p
->
type
);
if
(
pa
->
method
==
T
)
{
pa
->
methptr
=
ptr
;
stotype
(
n
,
&
pa
->
method
);
return
;
return
;
}
}
if
(
pa
->
methptr
!=
ptr
)
yyerror
(
"combination of direct and ptr receivers of: %S"
,
st
);
d
=
T
;
// last found
d
=
T
;
// last found
for
(
f
=
p
->
type
;
f
!=
T
;
f
=
f
->
down
)
{
for
(
f
=
p
a
->
method
;
f
!=
T
;
f
=
f
->
down
)
{
if
(
f
->
etype
!=
TFIELD
)
if
(
f
->
etype
!=
TFIELD
)
fatal
(
"addmethod: not TFIELD: %N"
,
f
);
fatal
(
"addmethod: not TFIELD: %N"
,
f
);
if
(
strcmp
(
s
->
name
,
f
->
sym
->
name
)
!=
0
)
{
if
(
strcmp
(
s
f
->
name
,
f
->
sym
->
name
)
!=
0
)
{
d
=
f
;
d
=
f
;
continue
;
continue
;
}
}
// if a field matches a non-this function
// then delete it and let it be redeclared
if
(
methcmp
(
t
,
f
->
type
))
{
if
(
d
==
T
)
{
p
->
type
=
f
->
down
;
continue
;
}
d
->
down
=
f
->
down
;
continue
;
}
if
(
!
eqtype
(
t
,
f
->
type
,
0
))
if
(
!
eqtype
(
t
,
f
->
type
,
0
))
yyerror
(
"field redeclared as method: %S"
,
s
);
yyerror
(
"method redeclared: %S of type %S"
,
sf
,
st
);
return
;
}
}
n
=
nod
(
ODCLFIELD
,
newname
(
s
),
N
);
n
->
type
=
t
;
if
(
d
==
T
)
if
(
d
==
T
)
stotype
(
n
,
&
p
->
type
);
stotype
(
n
,
&
p
a
->
method
);
else
else
stotype
(
n
,
&
d
->
down
);
stotype
(
n
,
&
d
->
down
);
return
;
return
;
...
@@ -393,11 +410,6 @@ funchdr(Node *n)
...
@@ -393,11 +410,6 @@ funchdr(Node *n)
markdcl
();
markdcl
();
funcargs
(
n
->
type
);
funcargs
(
n
->
type
);
if
(
n
->
type
->
thistuple
>
0
)
{
Type
*
t
;
t
=
*
getthis
(
n
->
type
);
addmethod
(
n
->
nname
,
t
->
type
->
type
,
n
->
type
);
}
}
}
void
void
...
...
src/cmd/gc/go.h
View file @
28b97027
...
@@ -115,6 +115,7 @@ struct Type
...
@@ -115,6 +115,7 @@ struct Type
uchar
chan
;
uchar
chan
;
uchar
recur
;
// to detect loops
uchar
recur
;
// to detect loops
uchar
trecur
;
// to detect loops
uchar
trecur
;
// to detect loops
uchar
methptr
;
// all methods are pointers to this type
// TFUNCT
// TFUNCT
uchar
thistuple
;
uchar
thistuple
;
...
@@ -122,9 +123,14 @@ struct Type
...
@@ -122,9 +123,14 @@ struct Type
uchar
intuple
;
uchar
intuple
;
uchar
outnamed
;
uchar
outnamed
;
Type
*
method
;
Sym
*
sym
;
Sym
*
sym
;
int32
vargen
;
// unique name for OTYPE/ONAME
int32
vargen
;
// unique name for OTYPE/ONAME
Node
*
nname
;
vlong
argwid
;
// most nodes
// most nodes
Type
*
type
;
Type
*
type
;
vlong
width
;
// offset in TFIELD, width in all others
vlong
width
;
// offset in TFIELD, width in all others
...
@@ -135,10 +141,6 @@ struct Type
...
@@ -135,10 +141,6 @@ struct Type
// TPTR
// TPTR
Type
*
nforw
;
Type
*
nforw
;
// TFUNCT
Node
*
nname
;
vlong
argwid
;
// TARRAY
// TARRAY
int32
bound
;
// negative is dynamic array
int32
bound
;
// negative is dynamic array
};
};
...
@@ -609,6 +611,7 @@ void dodcltype(Type*, Type*);
...
@@ -609,6 +611,7 @@ void dodcltype(Type*, Type*);
void
dodclconst
(
Node
*
,
Node
*
);
void
dodclconst
(
Node
*
,
Node
*
);
void
defaultlit
(
Node
*
);
void
defaultlit
(
Node
*
);
int
listcount
(
Node
*
);
int
listcount
(
Node
*
);
void
addmethod
(
Node
*
,
Type
*
);
Node
*
methodname
(
Node
*
,
Type
*
);
Node
*
methodname
(
Node
*
,
Type
*
);
Type
*
functype
(
Node
*
,
Node
*
,
Node
*
);
Type
*
functype
(
Node
*
,
Node
*
,
Node
*
);
char
*
thistypenam
(
Node
*
);
char
*
thistypenam
(
Node
*
);
...
@@ -671,7 +674,7 @@ Type* walkswitch(Node*, Type*(*)(Node*, Type*));
...
@@ -671,7 +674,7 @@ Type* walkswitch(Node*, Type*(*)(Node*, Type*));
int
casebody
(
Node
*
);
int
casebody
(
Node
*
);
void
walkselect
(
Node
*
);
void
walkselect
(
Node
*
);
int
whatis
(
Node
*
);
int
whatis
(
Node
*
);
void
walkdot
(
Node
*
,
int
);
void
walkdot
(
Node
*
);
Node
*
ascompatee
(
int
,
Node
**
,
Node
**
);
Node
*
ascompatee
(
int
,
Node
**
,
Node
**
);
Node
*
ascompatet
(
int
,
Node
**
,
Type
**
,
int
);
Node
*
ascompatet
(
int
,
Node
**
,
Type
**
,
int
);
Node
*
ascompatte
(
int
,
Type
**
,
Node
**
,
int
);
Node
*
ascompatte
(
int
,
Type
**
,
Node
**
,
int
);
...
...
src/cmd/gc/go.y
View file @
28b97027
...
@@ -1057,12 +1057,12 @@ fndcl:
...
@@ -1057,12 +1057,12 @@ fndcl:
|
'('
oarg_type_list
')'
new_name
'('
oarg_type_list
')'
fnres
|
'('
oarg_type_list
')'
new_name
'('
oarg_type_list
')'
fnres
{
{
b0stack
=
dclstack
;
//
mark
base
for
fn
literals
b0stack
=
dclstack
;
//
mark
base
for
fn
literals
if
($
2
==
N
||
$
2
->
op
==
OLIST
)
yyerror
(
"syntax error in method receiver"
);
$$
=
nod
(
ODCLFUNC
,
N
,
N
);
$$
=
nod
(
ODCLFUNC
,
N
,
N
);
$$->
nname
=
methodname
($
4
,
$
2
->
type
);
$$->
nname
=
methodname
($
4
,
$
2
->
type
);
$$->
type
=
functype
($
2
,
$
6
,
$
8
);
$$->
type
=
functype
($
2
,
$
6
,
$
8
);
funchdr
($$);
funchdr
($$);
addmethod
($
4
,
$$->
type
);
}
}
fntype
:
fntype
:
...
...
src/cmd/gc/walk.c
View file @
28b97027
...
@@ -17,8 +17,7 @@ int
...
@@ -17,8 +17,7 @@ int
walkret
(
Node
*
n
)
walkret
(
Node
*
n
)
{
{
// until gri gets rid
// bugs on this
// of the bugs on this
return
0
;
return
0
;
loop:
loop:
...
@@ -866,7 +865,7 @@ loop:
...
@@ -866,7 +865,7 @@ loop:
case
ODOTINTER
:
case
ODOTINTER
:
if
(
top
==
Etop
)
if
(
top
==
Etop
)
goto
nottop
;
goto
nottop
;
walkdot
(
n
,
top
);
walkdot
(
n
);
goto
ret
;
goto
ret
;
case
OADDR
:
case
OADDR
:
...
@@ -1323,19 +1322,18 @@ walkselect(Node *sel)
...
@@ -1323,19 +1322,18 @@ walkselect(Node *sel)
* normal binary operations.
* normal binary operations.
*/
*/
Type
*
Type
*
lookdot
(
Node
*
n
,
Type
*
t
,
int
d
)
lookdot
(
Node
*
n
,
Type
*
f
)
{
{
Type
*
f
,
*
r
,
*
c
;
Type
*
r
,
*
c
;
Sym
*
s
;
Sym
*
s
;
r
=
T
;
r
=
T
;
s
=
n
->
sym
;
s
=
n
->
sym
;
if
(
d
>
0
)
goto
deep
;
for
(
f
=
t
->
type
;
f
!=
T
;
f
=
f
->
down
)
{
for
(;
f
!=
T
;
f
=
f
->
down
)
{
if
(
f
->
sym
==
S
)
if
(
f
->
sym
==
S
)
continue
;
continue
;
print
(
"looking for %S in %S
\n
"
,
s
,
f
->
sym
);
if
(
f
->
sym
!=
s
)
if
(
f
->
sym
!=
s
)
continue
;
continue
;
if
(
r
!=
T
)
{
if
(
r
!=
T
)
{
...
@@ -1345,35 +1343,13 @@ lookdot(Node *n, Type *t, int d)
...
@@ -1345,35 +1343,13 @@ lookdot(Node *n, Type *t, int d)
r
=
f
;
r
=
f
;
}
}
return
r
;
return
r
;
deep:
/* deeper look after shallow failed */
for
(
f
=
t
->
type
;
f
!=
T
;
f
=
f
->
down
)
{
// only look at unnamed sub-structures
// BOTCH no such thing -- all are assigned temp names
if
(
f
->
sym
!=
S
)
continue
;
c
=
f
->
type
;
if
(
c
->
etype
!=
TSTRUCT
)
continue
;
c
=
lookdot
(
n
,
c
,
d
-
1
);
if
(
c
==
T
)
continue
;
if
(
r
!=
T
)
{
yyerror
(
"ambiguous unnamed DOT reference %s"
,
s
->
name
);
break
;
}
r
=
c
;
}
return
r
;
}
}
void
void
walkdot
(
Node
*
n
,
int
top
)
walkdot
(
Node
*
n
)
{
{
Node
*
mn
;
Node
*
mn
;
Type
*
t
,
*
f
;
Type
*
t
,
*
f
;
int
i
;
if
(
n
->
left
==
N
||
n
->
right
==
N
)
if
(
n
->
left
==
N
||
n
->
right
==
N
)
return
;
return
;
...
@@ -1395,41 +1371,26 @@ walkdot(Node *n, int top)
...
@@ -1395,41 +1371,26 @@ walkdot(Node *n, int top)
n
->
op
=
ODOTPTR
;
n
->
op
=
ODOTPTR
;
}
}
if
(
n
->
right
->
op
!=
ONAME
)
// as a structure field
fatal
(
"walkdot: not name %O"
,
n
->
right
->
op
);
if
(
t
->
etype
==
TSTRUCT
||
t
->
etype
==
TINTER
)
{
f
=
lookdot
(
n
->
right
,
t
->
type
);
switch
(
t
->
etype
)
{
default:
badtype
(
ODOT
,
t
,
T
);
return
;
case
TSTRUCT
:
case
TINTER
:
for
(
i
=
0
;
i
<
5
;
i
++
)
{
f
=
lookdot
(
n
->
right
,
t
,
i
);
if
(
f
!=
T
)
if
(
f
!=
T
)
break
;
return
;
}
// look up the field as TYPE_name
// for a mothod. botch this should
// be done better.
if
(
f
==
T
&&
t
->
etype
==
TSTRUCT
)
{
mn
=
methodname
(
n
->
right
,
t
);
for
(
i
=
0
;
i
<
5
;
i
++
)
{
f
=
lookdot
(
mn
,
t
,
i
);
if
(
f
!=
T
)
break
;
}
}
}
f
=
lookdot
(
n
->
right
,
t
->
method
);
if
(
f
==
T
)
{
if
(
f
==
T
)
{
yyerror
(
"undefined DOT reference %N"
,
n
->
right
);
yyerror
(
"undefined DOT reference %N"
,
n
->
right
);
break
;
return
;
}
}
print
(
"
\n
found method %lT
\n
"
,
f
);
dump
(
"before"
,
n
);
mn
=
methodname
(
n
->
right
,
t
);
dump
(
"mn"
,
mn
);
n
->
xoffset
=
f
->
width
;
n
->
xoffset
=
f
->
width
;
n
->
right
=
f
->
nname
;
// substitute real name
n
->
right
=
mn
;
// substitute real name
n
->
type
=
f
->
type
;
n
->
type
=
f
->
type
;
if
(
n
->
type
->
etype
==
TFUNC
)
{
if
(
n
->
type
->
etype
==
TFUNC
)
{
n
->
op
=
ODOTMETH
;
n
->
op
=
ODOTMETH
;
...
@@ -1437,8 +1398,7 @@ walkdot(Node *n, int top)
...
@@ -1437,8 +1398,7 @@ walkdot(Node *n, int top)
n
->
op
=
ODOTINTER
;
n
->
op
=
ODOTINTER
;
}
}
}
}
break
;
dump
(
"after"
,
n
);
}
}
}
Node
*
Node
*
...
@@ -1841,25 +1801,21 @@ fixmap(Type *tm)
...
@@ -1841,25 +1801,21 @@ fixmap(Type *tm)
Type
*
t
;
Type
*
t
;
t
=
tm
->
type
;
t
=
tm
->
type
;
if
(
t
==
T
)
{
if
(
t
==
T
)
fatal
(
"fixmap: t nil"
);
goto
bad
;
return
T
;
if
(
t
->
etype
!=
TMAP
)
}
goto
bad
;
if
(
t
->
down
==
T
||
t
->
type
==
T
)
if
(
t
->
etype
!=
TMAP
)
{
goto
bad
;
fatal
(
"fixmap: %lT not map"
,
tm
);
return
T
;
}
if
(
t
->
down
==
T
||
t
->
type
==
T
)
{
fatal
(
"fixmap: map key/value types are nil"
);
return
T
;
}
dowidth
(
t
->
down
);
dowidth
(
t
->
down
);
dowidth
(
t
->
type
);
dowidth
(
t
->
type
);
return
t
;
return
t
;
bad:
yyerror
(
"not a map: %lT"
,
tm
);
return
T
;
}
}
Type
*
Type
*
...
@@ -1867,25 +1823,23 @@ fixchan(Type *tm)
...
@@ -1867,25 +1823,23 @@ fixchan(Type *tm)
{
{
Type
*
t
;
Type
*
t
;
if
(
tm
==
T
)
goto
bad
;
t
=
tm
->
type
;
t
=
tm
->
type
;
if
(
t
==
T
)
{
if
(
t
==
T
)
fatal
(
"fixchan: t nil"
);
goto
bad
;
return
T
;
if
(
t
->
etype
!=
TCHAN
)
}
goto
bad
;
if
(
t
->
type
==
T
)
if
(
t
->
etype
!=
TCHAN
)
{
goto
bad
;
fatal
(
"fixchan: %lT not chan"
,
tm
);
return
T
;
}
if
(
t
->
type
==
T
)
{
fatal
(
"fixchan: chan element type is nil"
);
return
T
;
}
dowidth
(
t
->
type
);
dowidth
(
t
->
type
);
return
t
;
return
t
;
bad:
yyerror
(
"not a channel: %lT"
,
tm
);
return
T
;
}
}
static
int
static
int
...
@@ -2288,24 +2242,21 @@ fixarray(Type *tm)
...
@@ -2288,24 +2242,21 @@ fixarray(Type *tm)
Type
*
t
;
Type
*
t
;
t
=
tm
->
type
;
t
=
tm
->
type
;
if
(
t
==
T
)
{
if
(
t
==
T
)
fatal
(
"fixarray: t nil"
);
goto
bad
;
return
T
;
if
(
t
->
etype
!=
TARRAY
)
}
goto
bad
;
if
(
t
->
type
==
T
)
if
(
t
->
etype
!=
TARRAY
)
{
goto
bad
;
fatal
(
"fixarray: %lT not array"
,
tm
);
return
T
;
}
if
(
t
->
type
==
T
)
{
fatal
(
"fixarray: array element type is nil"
);
return
T
;
}
dowidth
(
t
->
type
);
dowidth
(
t
->
type
);
return
t
;
return
t
;
bad:
yyerror
(
"not an array: %lT"
,
tm
);
return
T
;
}
}
Node
*
Node
*
...
...
src/runtime/print.c
View file @
28b97027
...
@@ -96,12 +96,13 @@ sys·printfloat(float64 v)
...
@@ -96,12 +96,13 @@ sys·printfloat(float64 v)
buf
[
1
]
=
buf
[
2
];
buf
[
1
]
=
buf
[
2
];
buf
[
2
]
=
'.'
;
buf
[
2
]
=
'.'
;
buf
[
n
+
2
]
=
'+'
;
buf
[
n
+
2
]
=
'e'
;
buf
[
n
+
3
]
=
'+'
;
if
(
e
<
0
)
{
if
(
e
<
0
)
{
e
=
-
e
;
e
=
-
e
;
buf
[
n
+
2
]
=
'-'
;
buf
[
n
+
3
]
=
'-'
;
}
}
buf
[
n
+
3
]
=
'e'
;
buf
[
n
+
4
]
=
(
e
/
10
)
+
'0'
;
buf
[
n
+
4
]
=
(
e
/
10
)
+
'0'
;
buf
[
n
+
5
]
=
(
e
%
10
)
+
'0'
;
buf
[
n
+
5
]
=
(
e
%
10
)
+
'0'
;
sys
·
write
(
1
,
buf
,
n
+
6
);
sys
·
write
(
1
,
buf
,
n
+
6
);
...
...
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