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
80038494
Commit
80038494
authored
Jul 17, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parameter declartions in func literals
SVN=127678
parent
0e67654f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
7 deletions
+32
-7
gen.c
src/cmd/6g/gen.c
+4
-3
dcl.c
src/cmd/gc/dcl.c
+26
-0
go.h
src/cmd/gc/go.h
+2
-0
go.y
src/cmd/gc/go.y
+0
-4
No files found.
src/cmd/6g/gen.c
View file @
80038494
...
@@ -102,11 +102,12 @@ allocparams(void)
...
@@ -102,11 +102,12 @@ allocparams(void)
* parameters, is the offset in the
* parameters, is the offset in the
* parameter list.
* parameter list.
*/
*/
d
=
autodcl
;
d
=
paramdcl
->
forw
;
;
t
=
funcfirst
(
&
list
,
curfn
->
type
);
t
=
funcfirst
(
&
list
,
curfn
->
type
);
while
(
t
!=
T
)
{
while
(
t
!=
T
)
{
if
(
d
==
D
)
if
(
d
==
D
)
fatal
(
"allocparams: this & in nil"
);
fatal
(
"allocparams: this & in nil"
);
if
(
d
->
op
!=
ONAME
)
{
if
(
d
->
op
!=
ONAME
)
{
d
=
d
->
forw
;
d
=
d
->
forw
;
continue
;
continue
;
...
@@ -114,7 +115,7 @@ allocparams(void)
...
@@ -114,7 +115,7 @@ allocparams(void)
n
=
d
->
dnode
;
n
=
d
->
dnode
;
if
(
n
->
class
!=
PPARAM
)
if
(
n
->
class
!=
PPARAM
)
fatal
(
"allocparams: this & in class
"
);
fatal
(
"allocparams: this & in class
%N %d"
,
n
,
n
->
class
);
n
->
xoffset
=
t
->
width
;
n
->
xoffset
=
t
->
width
;
d
=
d
->
forw
;
d
=
d
->
forw
;
...
@@ -133,7 +134,7 @@ allocparams(void)
...
@@ -133,7 +134,7 @@ allocparams(void)
n
=
d
->
dnode
;
n
=
d
->
dnode
;
if
(
n
->
class
!=
PPARAM
)
if
(
n
->
class
!=
PPARAM
)
fatal
(
"allocparams: out class
"
);
fatal
(
"allocparams: out class
%N %d"
,
n
,
n
->
class
);
n
->
xoffset
=
t
->
width
;
n
->
xoffset
=
t
->
width
;
d
=
d
->
forw
;
d
=
d
->
forw
;
...
...
src/cmd/gc/dcl.c
View file @
80038494
...
@@ -370,6 +370,8 @@ funcargs(Type *t)
...
@@ -370,6 +370,8 @@ funcargs(Type *t)
Iter
save
;
Iter
save
;
int
all
;
int
all
;
paramdcl
=
autodcl
->
back
;
// base of arguments - see allocparams in gen.c
// declare the this/in arguments
// declare the this/in arguments
n1
=
funcfirst
(
&
save
,
t
);
n1
=
funcfirst
(
&
save
,
t
);
while
(
n1
!=
T
)
{
while
(
n1
!=
T
)
{
...
@@ -601,6 +603,30 @@ markdclstack(void)
...
@@ -601,6 +603,30 @@ markdclstack(void)
}
}
}
}
void
dumpdcl
(
char
*
st
)
{
Sym
*
s
,
*
d
;
int
i
;
print
(
"
\n
dumpdcl: %s %p
\n
"
,
st
,
b0stack
);
i
=
0
;
for
(
d
=
dclstack
;
d
!=
S
;
d
=
d
->
link
)
{
i
++
;
print
(
" %.2d %p"
,
i
,
d
);
if
(
d
==
b0stack
)
print
(
" (b0)"
);
if
(
d
->
name
==
nil
)
{
print
(
"
\n
"
);
continue
;
}
print
(
" '%s'"
,
d
->
name
);
s
=
pkglookup
(
d
->
name
,
d
->
package
);
print
(
" %lS
\n
"
,
s
);
}
}
void
void
testdclstack
(
void
)
testdclstack
(
void
)
{
{
...
...
src/cmd/gc/go.h
View file @
80038494
...
@@ -385,6 +385,7 @@ EXTERN vlong minintval[NTYPE];
...
@@ -385,6 +385,7 @@ EXTERN vlong minintval[NTYPE];
EXTERN
vlong
maxintval
[
NTYPE
];
EXTERN
vlong
maxintval
[
NTYPE
];
EXTERN
Dcl
*
autodcl
;
EXTERN
Dcl
*
autodcl
;
EXTERN
Dcl
*
paramdcl
;
EXTERN
Dcl
*
externdcl
;
EXTERN
Dcl
*
externdcl
;
EXTERN
Dcl
*
exportlist
;
EXTERN
Dcl
*
exportlist
;
EXTERN
int
dclcontext
;
// PEXTERN/PAUTO
EXTERN
int
dclcontext
;
// PEXTERN/PAUTO
...
@@ -529,6 +530,7 @@ Type* sortinter(Type*);
...
@@ -529,6 +530,7 @@ Type* sortinter(Type*);
void
markdcl
(
void
);
void
markdcl
(
void
);
void
popdcl
(
void
);
void
popdcl
(
void
);
void
poptodcl
(
void
);
void
poptodcl
(
void
);
void
dumpdcl
(
char
*
);
void
markdclstack
(
void
);
void
markdclstack
(
void
);
void
testdclstack
(
void
);
void
testdclstack
(
void
);
Sym
*
pushdcl
(
Sym
*
);
Sym
*
pushdcl
(
Sym
*
);
...
...
src/cmd/gc/go.y
View file @
80038494
...
@@ -1024,7 +1024,6 @@ fnliteral:
...
@@ -1024,7 +1024,6 @@ fnliteral:
$$
=
newname
(
lookup
(
namebuf
));
$$
=
newname
(
lookup
(
namebuf
));
addvar
($$,
$
1
,
PEXTERN
);
addvar
($$,
$
1
,
PEXTERN
);
dump
(
"lit1"
,
$$);
{
{
Node
*
n
;
Node
*
n
;
...
@@ -1035,13 +1034,10 @@ dump("lit1", $$);
...
@@ -1035,13 +1034,10 @@ dump("lit1", $$);
n
->
nbody
=
$
3
;
n
->
nbody
=
$
3
;
if
(
n
->
nbody
==
N
)
if
(
n
->
nbody
==
N
)
n
->
nbody
=
nod
(
ORETURN
,
N
,
N
);
n
->
nbody
=
nod
(
ORETURN
,
N
,
N
);
dump
(
"comp1"
,
n
);
compile
(
n
);
compile
(
n
);
dump
(
"comp2"
,
n
);
}
}
$$
=
nod
(
OADDR
,
$$,
N
);
$$
=
nod
(
OADDR
,
$$,
N
);
dump
(
"lit2"
,
$$);
}
}
fnbody
:
fnbody
:
...
...
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