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
6fecb76e
Commit
6fecb76e
authored
Oct 23, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
embedded types
R=r OCL=17676 CL=17676
parent
5d30161c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
12 deletions
+36
-12
go.y
src/cmd/gc/go.y
+5
-1
walk.c
src/cmd/gc/walk.c
+31
-11
No files found.
src/cmd/gc/go.y
View file @
6fecb76e
...
@@ -1855,7 +1855,11 @@ hidden_structdcl:
...
@@ -1855,7 +1855,11 @@ hidden_structdcl:
}
}
| '
?
' hidden_type
| '
?
' hidden_type
{
{
$$ = embedded($2->sym);
if(isptr[$2->etype]) {
$$ = embedded($2->type->sym);
$$->type = ptrto($$->type);
} else
$$ = embedded($2->sym);
}
}
hidden_interfacedcl:
hidden_interfacedcl:
...
...
src/cmd/gc/walk.c
View file @
6fecb76e
...
@@ -3224,6 +3224,8 @@ loop:
...
@@ -3224,6 +3224,8 @@ loop:
goto
loop
;
goto
loop
;
}
}
static
int
prdot
=
0
;
int
int
lookdot0
(
Sym
*
s
,
Type
*
t
)
lookdot0
(
Sym
*
s
,
Type
*
t
)
{
{
...
@@ -3240,11 +3242,21 @@ lookdot0(Sym *s, Type *t)
...
@@ -3240,11 +3242,21 @@ lookdot0(Sym *s, Type *t)
if
(
f
->
sym
==
s
)
if
(
f
->
sym
==
s
)
c
++
;
c
++
;
}
}
//BOTCH need method
u
=
methtype
(
t
);
if
(
u
!=
T
)
{
for
(
f
=
u
->
method
;
f
!=
T
;
f
=
f
->
down
)
if
(
f
->
sym
==
s
)
{
if
(
prdot
)
print
(
"found method %S
\n
"
,
s
);
c
++
;
}
}
return
c
;
return
c
;
}
}
static
Node
*
dotlist
;
enum
{
maxembed
=
10
};
// max depth search for embedded types
static
Sym
*
dotlist
[
maxembed
+
1
];
// maxembed..1
int
int
adddot1
(
Sym
*
s
,
Type
*
t
,
int
d
)
adddot1
(
Sym
*
s
,
Type
*
t
,
int
d
)
...
@@ -3268,10 +3280,8 @@ adddot1(Sym *s, Type *t, int d)
...
@@ -3268,10 +3280,8 @@ adddot1(Sym *s, Type *t, int d)
if
(
f
->
sym
==
S
)
if
(
f
->
sym
==
S
)
continue
;
continue
;
a
=
adddot1
(
s
,
f
->
type
,
d
-
1
);
a
=
adddot1
(
s
,
f
->
type
,
d
-
1
);
if
(
a
!=
0
&&
c
==
0
)
{
if
(
a
!=
0
&&
c
==
0
)
dotlist
=
nod
(
ODOT
,
dotlist
,
N
);
dotlist
[
d
]
=
f
->
sym
;
dotlist
->
type
=
f
;
}
c
+=
a
;
c
+=
a
;
}
}
return
c
;
return
c
;
...
@@ -3296,23 +3306,33 @@ adddot(Node *n)
...
@@ -3296,23 +3306,33 @@ adddot(Node *n)
if
(
s
==
S
)
if
(
s
==
S
)
return
n
;
return
n
;
dotlist
=
N
;
for
(
d
=
0
;
d
<
maxembed
;
d
++
)
{
for
(
d
=
0
;
d
<
5
;
d
++
)
{
c
=
adddot1
(
s
,
t
,
d
);
c
=
adddot1
(
s
,
t
,
d
);
if
(
c
>
0
)
if
(
c
>
0
)
goto
out
;
goto
out
;
}
}
if
(
prdot
)
{
print
(
"missed"
);
dump
(
""
,
n
);
}
return
n
;
return
n
;
out:
out:
if
(
c
>
1
)
if
(
c
>
1
)
yyerror
(
"ambiguous DOT reference %S"
,
s
);
yyerror
(
"ambiguous DOT reference %S"
,
s
);
if
(
prdot
)
if
(
d
>
0
)
print
(
"add dots:"
);
// rebuild elided dots
// rebuild elided dots
for
(
l
=
dotlist
;
l
!=
N
;
l
=
l
->
left
)
{
for
(
c
=
d
;
c
>
0
;
c
--
)
{
n
=
nod
(
ODOT
,
n
,
n
->
right
);
n
=
nod
(
ODOT
,
n
,
n
->
right
);
n
->
left
->
right
=
newname
(
l
->
type
->
sym
);
n
->
left
->
right
=
newname
(
dotlist
[
c
]);
if
(
prdot
)
print
(
" %S"
,
dotlist
[
c
]);
}
}
if
(
prdot
)
if
(
d
>
0
)
print
(
"
\n
"
);
return
n
;
return
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