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
7ed8fc61
Commit
7ed8fc61
authored
Oct 23, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
embedded types
auto & on methods R=r OCL=17682 CL=17682
parent
ad48706a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
24 deletions
+51
-24
go.h
src/cmd/gc/go.h
+2
-0
subr.c
src/cmd/gc/subr.c
+45
-0
walk.c
src/cmd/gc/walk.c
+4
-24
No files found.
src/cmd/gc/go.h
View file @
7ed8fc61
...
...
@@ -584,6 +584,8 @@ int isinter(Type*);
int
isnilinter
(
Type
*
);
Sym
*
globalsig
(
Type
*
);
Type
*
ismethod
(
Type
*
);
Type
*
methtype
(
Type
*
);
int
needaddr
(
Type
*
);
Sym
*
signame
(
Type
*
,
int
);
int
bytearraysz
(
Type
*
);
int
eqtype
(
Type
*
,
Type
*
,
int
);
...
...
src/cmd/gc/subr.c
View file @
7ed8fc61
...
...
@@ -1518,6 +1518,51 @@ out:
return
t
;
}
/*
* this is ismethod() without side effects
*/
Type
*
methtype
(
Type
*
t
)
{
Sym
*
s
;
if
(
t
==
T
)
return
T
;
if
(
t
->
etype
==
TINTER
||
(
t
->
etype
==
tptr
&&
t
->
type
->
etype
==
TINTER
))
return
T
;
s
=
t
->
sym
;
if
(
s
!=
S
)
return
t
;
if
(
!
isptr
[
t
->
etype
])
return
T
;
t
=
t
->
type
;
if
(
t
==
T
)
return
T
;
s
=
t
->
sym
;
if
(
s
!=
S
)
return
t
;
return
T
;
}
/*
* this is another ismethod()
* returns 1 if t=T and method wants *T
*/
int
needaddr
(
Type
*
t
)
{
Sym
*
s
;
if
(
t
==
T
)
return
0
;
if
(
t
->
etype
==
TINTER
||
(
t
->
etype
==
tptr
&&
t
->
type
->
etype
==
TINTER
))
return
0
;
s
=
t
->
sym
;
if
(
s
!=
S
&&
t
->
methptr
==
2
)
return
1
;
return
0
;
}
int
iscomposite
(
Type
*
t
)
{
...
...
src/cmd/gc/walk.c
View file @
7ed8fc61
...
...
@@ -1422,30 +1422,6 @@ walkselect(Node *sel)
lineno
=
lno
;
}
Type
*
methtype
(
Type
*
t
)
{
Sym
*
s
;
// this is ismethod() without diagnostics
if
(
t
==
T
)
return
T
;
if
(
t
->
etype
==
TINTER
||
(
t
->
etype
==
tptr
&&
t
->
type
->
etype
==
TINTER
))
return
T
;
s
=
t
->
sym
;
if
(
s
!=
S
&&
s
->
name
[
0
]
!=
'_'
)
return
t
;
if
(
!
isptr
[
t
->
etype
])
return
T
;
t
=
t
->
type
;
if
(
t
==
T
)
return
T
;
s
=
t
->
sym
;
if
(
s
!=
S
&&
s
->
name
[
0
]
!=
'_'
)
return
t
;
return
T
;
}
Type
*
lookdot1
(
Node
*
n
,
Type
*
f
)
{
...
...
@@ -1495,6 +1471,10 @@ lookdot(Node *n, Type *t)
}
if
(
f2
!=
T
)
{
if
(
needaddr
(
n
->
left
->
type
))
{
n
->
left
=
nod
(
OADDR
,
n
->
left
,
N
);
n
->
left
->
type
=
ptrto
(
n
->
left
->
left
->
type
);
}
n
->
right
=
methodname
(
n
->
right
,
ismethod
(
n
->
left
->
type
));
n
->
xoffset
=
f2
->
width
;
n
->
type
=
f2
->
type
;
...
...
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