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
b642cf8c
Commit
b642cf8c
authored
Oct 25, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
embedded methods
R=r OCL=17851 CL=17851
parent
22a67479
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
30 deletions
+71
-30
obj.c
src/cmd/6g/obj.c
+67
-16
go.h
src/cmd/gc/go.h
+1
-3
subr.c
src/cmd/gc/subr.c
+3
-11
No files found.
src/cmd/6g/obj.c
View file @
b642cf8c
...
...
@@ -513,7 +513,9 @@ void
gentramp
(
Type
*
t
,
Sig
*
b
)
{
Sym
*
e
;
int
c
,
d
;
int
c
,
d
,
o
;
Prog
*
p
;
Type
*
f
;
e
=
lookup
(
b
->
name
);
for
(
d
=
0
;
d
<
nelem
(
dotlist
);
d
++
)
{
...
...
@@ -524,25 +526,74 @@ gentramp(Type *t, Sig *b)
fatal
(
"gentramp"
);
out:
print
(
"gentramp %d
\n
"
,
d
);
print
(
" t = %lT
\n
"
,
t
);
print
(
" name = %s
\n
"
,
b
->
name
);
print
(
" sym = %S
\n
"
,
b
->
sym
);
print
(
" hash = 0x%ux
\n
"
,
b
->
hash
);
// print("gentramp %d\n", d);
// print(" t = %lT\n", t);
// print(" name = %s\n", b->name);
// print(" sym = %S\n", b->sym);
// print(" hash = 0x%ux\n", b->hash);
//TEXT main·S_test2(SB),7,$0
p
=
pc
;
gins
(
ATEXT
,
N
,
N
);
p
->
from
.
type
=
D_EXTERN
;
p
->
from
.
sym
=
b
->
sym
;
p
->
to
.
type
=
D_CONST
;
p
->
to
.
offset
=
0
;
p
->
from
.
scale
=
7
;
//print("1. %P\n", p);
//MOVQ 8(SP), AX
p
=
pc
;
gins
(
AMOVQ
,
N
,
N
);
p
->
from
.
type
=
D_INDIR
+
D_SP
;
p
->
from
.
offset
=
8
;
p
->
to
.
type
=
D_AX
;
//print("2. %P\n", p);
o
=
0
;
for
(
c
=
d
-
1
;
c
>=
0
;
c
--
)
{
print
(
" %d %d %S
\n
"
,
dotlist
[
c
].
ptr
,
dotlist
[
c
].
offset
,
dotlist
[
c
].
sym
);
f
=
dotlist
[
c
].
field
;
o
+=
f
->
width
;
if
(
!
isptr
[
f
->
type
->
etype
])
continue
;
//MOVQ o(AX), AX
p
=
pc
;
gins
(
AMOVQ
,
N
,
N
);
p
->
from
.
type
=
D_INDIR
+
D_AX
;
p
->
from
.
offset
=
o
;
p
->
to
.
type
=
D_AX
;
//print("3. %P\n", p);
o
=
0
;
}
if
(
o
!=
0
)
{
//ADDQ $XX, AX
p
=
pc
;
gins
(
AADDQ
,
N
,
N
);
p
->
from
.
type
=
D_CONST
;
p
->
from
.
offset
=
o
;
p
->
to
.
type
=
D_AX
;
//print("4. %P\n", p);
}
//TEXT main·S_test2(SB),7,$0
// MOVQ 8(SP), AX
// MOVQ XX(AX), AX
// ADDQ $XX, AX
// MOVQ AX, 8(SP)
// JMP main·Sub_test2(SB)
//MOVQ AX, 8(SP)
p
=
pc
;
gins
(
AMOVQ
,
N
,
N
);
p
->
from
.
type
=
D_AX
;
p
->
to
.
type
=
D_INDIR
+
D_SP
;
p
->
to
.
offset
=
8
;
//print("5. %P\n", p);
f
=
dotlist
[
0
].
field
;
//JMP main·Sub_test2(SB)
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%s_%s"
,
f
->
sym
->
name
,
b
->
name
);
if
(
isptr
[
f
->
type
->
etype
])
f
=
f
->
type
;
p
=
pc
;
gins
(
AJMP
,
N
,
N
);
p
->
to
.
type
=
D_EXTERN
;
p
->
to
.
sym
=
pkglookup
(
namebuf
,
f
->
type
->
sym
->
opackage
);
//print("6. %P\n", p);
}
void
...
...
src/cmd/gc/go.h
View file @
b642cf8c
...
...
@@ -402,9 +402,7 @@ struct Io
typedef
struct
Dlist
Dlist
;
struct
Dlist
{
Sym
*
sym
;
uchar
ptr
;
int
offset
;
Type
*
field
;
};
EXTERN
Dlist
dotlist
[
10
];
// size is max depth of embeddeds
...
...
src/cmd/gc/subr.c
View file @
b642cf8c
...
...
@@ -2445,13 +2445,8 @@ adddot1(Sym *s, Type *t, int d)
if
(
f
->
sym
==
S
)
continue
;
a
=
adddot1
(
s
,
f
->
type
,
d
);
if
(
a
!=
0
&&
c
==
0
)
{
dotlist
[
d
].
sym
=
f
->
sym
;
dotlist
[
d
].
offset
=
f
->
width
;
dotlist
[
d
].
ptr
=
0
;
if
(
isptr
[
f
->
type
->
etype
])
dotlist
[
d
].
ptr
=
1
;
}
if
(
a
!=
0
&&
c
==
0
)
dotlist
[
d
].
field
=
f
;
c
+=
a
;
}
...
...
@@ -2497,7 +2492,7 @@ out:
// rebuild elided dots
for
(
c
=
d
-
1
;
c
>=
0
;
c
--
)
{
n
=
nod
(
ODOT
,
n
,
n
->
right
);
n
->
left
->
right
=
newname
(
dotlist
[
c
].
sym
);
n
->
left
->
right
=
newname
(
dotlist
[
c
].
field
->
sym
);
}
return
n
;
}
...
...
@@ -2609,7 +2604,6 @@ expandmeth(Sym *s, Type *t)
}
}
//print("expand %S: %lT", s, t);
for
(
sl
=
slist
;
sl
!=
nil
;
sl
=
sl
->
link
)
{
if
(
sl
->
good
)
{
// add it to the base type method list
...
...
@@ -2620,8 +2614,6 @@ expandmeth(Sym *s, Type *t)
f
->
down
=
t
->
method
;
t
->
method
=
f
;
//print(" %T", f);
}
}
//print("\n");
}
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