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
2254a8ee
Commit
2254a8ee
authored
Jun 11, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import/export
SVN=122309
parent
2694a85a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
105 additions
and
49 deletions
+105
-49
src/cmd/6g/gen.c
src/cmd/6g/gen.c
+3
-3
src/cmd/6g/gg.h
src/cmd/6g/gg.h
+0
-2
src/cmd/6g/gsubr.c
src/cmd/6g/gsubr.c
+6
-0
src/cmd/gc/dcl.c
src/cmd/gc/dcl.c
+21
-9
src/cmd/gc/export.c
src/cmd/gc/export.c
+29
-22
src/cmd/gc/go.h
src/cmd/gc/go.h
+4
-0
src/cmd/gc/go.y
src/cmd/gc/go.y
+7
-3
src/cmd/gc/lex.c
src/cmd/gc/lex.c
+3
-1
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+32
-9
No files found.
src/cmd/6g/gen.c
View file @
2254a8ee
...
...
@@ -36,9 +36,6 @@ compile(Node *fn)
if
(
debug
[
'w'
])
dump
(
"--- pre walk ---"
,
curfn
->
nbody
);
maxarg
=
0
;
stksize
=
0
;
walk
(
curfn
);
if
(
nerrors
!=
0
)
return
;
...
...
@@ -592,6 +589,8 @@ cgen_callmeth(Node *n)
// (p.f)(...) goes to (f)(p,...)
l
=
n
->
left
;
if
(
l
->
op
!=
ODOTMETH
)
fatal
(
"cgen_callmeth: not dotmethod: %N"
);
n
->
op
=
OCALL
;
n
->
left
=
n
->
left
->
right
;
...
...
@@ -647,6 +646,7 @@ cgen_call(Node *n)
}
// call direct
n
->
left
->
method
=
1
;
gins
(
ACALL
,
N
,
n
->
left
);
}
...
...
src/cmd/6g/gg.h
View file @
2254a8ee
...
...
@@ -92,8 +92,6 @@ EXTERN uchar reg[D_NONE];
EXTERN
ushort
txt
[
NTYPE
*
NTYPE
];
EXTERN
long
maxround
;
EXTERN
long
widthptr
;
EXTERN
long
maxarg
;
EXTERN
long
stksize
;
EXTERN
Sym
*
symstringo
;
// string objects
EXTERN
long
stringo
;
// size of string objects
EXTERN
long
pcloc
;
// instruction counter
...
...
src/cmd/6g/gsubr.c
View file @
2254a8ee
...
...
@@ -1047,6 +1047,12 @@ naddr(Node *n, Addr *a)
a
->
sym
=
n
->
sym
;
if
(
a
->
sym
==
S
)
a
->
sym
=
lookup
(
".noname"
);
if
(
n
->
method
)
{
if
(
n
->
type
!=
T
)
if
(
n
->
type
->
sym
!=
S
)
if
(
n
->
type
->
sym
->
opackage
!=
nil
)
a
->
sym
=
pkglookup
(
a
->
sym
->
name
,
n
->
type
->
sym
->
opackage
);
}
switch
(
n
->
class
)
{
default:
...
...
src/cmd/gc/dcl.c
View file @
2254a8ee
...
...
@@ -5,6 +5,18 @@
#include "go.h"
#include "y.tab.h"
int
dflag
(
void
)
{
if
(
!
debug
[
'd'
])
return
0
;
if
(
debug
[
'y'
])
return
1
;
if
(
inimportsys
)
return
0
;
return
1
;
}
void
dodclvar
(
Node
*
n
,
Type
*
t
)
{
...
...
@@ -70,7 +82,7 @@ loop:
r
->
back
->
forw
=
d
;
r
->
back
=
d
;
if
(
d
ebug
[
'd'
]
)
if
(
d
flag
()
)
print
(
"const-dcl %S %N
\n
"
,
n
->
sym
,
n
->
sym
->
oconst
);
}
...
...
@@ -321,7 +333,7 @@ funchdr(Node *n)
n
->
type
=
on
->
type
;
n
->
class
=
on
->
class
;
n
->
sym
=
s
;
if
(
d
ebug
[
'd'
]
)
if
(
d
flag
()
)
print
(
"forew var-dcl %S %T
\n
"
,
n
->
sym
,
n
->
type
);
}
...
...
@@ -497,14 +509,14 @@ popdcl(char *why)
{
Sym
*
d
,
*
s
;
// if(d
ebug['d']
)
// if(d
flag()
)
// print("revert\n");
for
(
d
=
dclstack
;
d
!=
S
;
d
=
d
->
link
)
{
if
(
d
->
name
==
nil
)
break
;
s
=
pkglookup
(
d
->
name
,
d
->
package
);
dcopy
(
s
,
d
);
if
(
d
ebug
[
'd'
]
)
if
(
d
flag
()
)
print
(
"
\t
%ld pop %S
\n
"
,
curio
.
lineno
,
s
);
}
if
(
d
==
S
)
...
...
@@ -524,7 +536,7 @@ poptodcl(void)
break
;
s
=
pkglookup
(
d
->
name
,
d
->
package
);
dcopy
(
s
,
d
);
if
(
d
ebug
[
'd'
]
)
if
(
d
flag
()
)
print
(
"
\t
%ld pop %S
\n
"
,
curio
.
lineno
,
s
);
}
if
(
d
==
S
)
...
...
@@ -539,7 +551,7 @@ markdcl(char *why)
d
=
push
();
d
->
name
=
nil
;
// used as a mark in fifo
d
->
package
=
why
;
// diagnostic for unmatched
// if(d
ebug['d']
)
// if(d
flag()
)
// print("markdcl\n");
}
...
...
@@ -639,7 +651,7 @@ addvar(Node *n, Type *t, int ctxt)
r
->
back
->
forw
=
d
;
r
->
back
=
d
;
if
(
d
ebug
[
'd'
]
)
{
if
(
d
flag
()
)
{
if
(
ctxt
==
PEXTERN
)
print
(
"extern var-dcl %S G%ld %T
\n
"
,
s
,
s
->
vargen
,
t
);
else
...
...
@@ -666,7 +678,7 @@ addtyp(Type *n, Type *t, int ctxt)
// allow nil interface to be
// redeclared as an interface
if
(
ot
->
etype
==
TINTER
&&
ot
->
type
==
T
&&
t
->
etype
==
TINTER
)
{
if
(
d
ebug
[
'd'
]
)
if
(
d
flag
()
)
print
(
"forew typ-dcl %S G%ld %T
\n
"
,
s
,
s
->
vargen
,
t
);
s
->
otype
=
t
;
return
;
...
...
@@ -710,7 +722,7 @@ addtyp(Type *n, Type *t, int ctxt)
r
->
back
->
forw
=
d
;
r
->
back
=
d
;
if
(
d
ebug
[
'd'
]
)
{
if
(
d
flag
()
)
{
if
(
ctxt
==
PEXTERN
)
print
(
"extern typ-dcl %S G%ld %T
\n
"
,
s
,
s
->
vargen
,
t
);
else
...
...
src/cmd/gc/export.c
View file @
2254a8ee
...
...
@@ -266,18 +266,34 @@ dumpexport(void)
/*
* ******* import *******
*/
Sym
*
getimportsym
(
Node
*
ss
)
{
char
*
pkg
;
Sym
*
s
;
if
(
ss
->
op
!=
OIMPORT
)
fatal
(
"getimportsym: oops1 %N
\n
"
,
ss
);
pkg
=
ss
->
psym
->
name
;
if
(
pkgmyname
!=
S
)
pkg
=
pkgmyname
->
name
;
s
=
pkglookup
(
ss
->
sym
->
name
,
pkg
);
/* botch - need some diagnostic checking for the following assignment */
s
->
opackage
=
ss
->
osym
->
name
;
return
s
;
}
Type
*
importlooktype
(
Node
*
n
)
{
Sym
*
s
;
if
(
n
->
op
!=
OIMPORT
)
fatal
(
"importlooktype: oops1 %N
\n
"
,
n
);
s
=
pkglookup
(
n
->
sym
->
name
,
n
->
psym
->
name
);
s
=
getimportsym
(
n
);
if
(
s
->
otype
==
T
)
fatal
(
"importlooktype: oops2 %S
\n
"
,
s
);
return
s
->
otype
;
}
...
...
@@ -367,31 +383,22 @@ importfuncnam(Type *t)
}
}
Sym
*
getimportsym
(
Node
*
ss
)
{
char
*
pkg
;
Sym
*
s
;
pkg
=
ss
->
psym
->
name
;
if
(
pkgmyname
!=
S
)
pkg
=
pkgmyname
->
name
;
s
=
pkglookup
(
ss
->
sym
->
name
,
pkg
);
/* botch - need some diagnostic checking for the following assignment */
s
->
opackage
=
ss
->
osym
->
name
;
return
s
;
}
void
importaddtyp
(
Node
*
ss
,
Type
*
t
)
{
Sym
*
s
;
s
=
getimportsym
(
ss
);
if
(
s
->
otype
==
T
||
!
eqtype
(
t
,
s
->
otype
,
0
)
)
{
if
(
s
->
otype
==
T
)
{
addtyp
(
newtype
(
s
),
t
,
PEXTERN
);
return
;
}
if
(
!
eqtype
(
t
,
s
->
otype
,
0
))
{
print
(
"redeclaring %S %lT => %lT
\n
"
,
s
,
s
->
otype
,
t
);
addtyp
(
newtype
(
s
),
t
,
PEXTERN
);
return
;
}
print
(
"sametype %S %lT => %lT
\n
"
,
s
,
s
->
otype
,
t
);
}
/*
...
...
src/cmd/gc/go.h
View file @
2254a8ee
...
...
@@ -137,6 +137,7 @@ struct Node
uchar
trecur
;
// to detect loops
uchar
etype
;
// op for OASOP, etype for OTYPE, exclam for export
uchar
class
;
// PPARAM, PAUTO, PEXTERN, PSTATIC
uchar
method
;
// OCALLMETH name
long
vargen
;
// unique name for OTYPE/ONAME
ulong
lineno
;
vlong
xoffset
;
...
...
@@ -353,12 +354,15 @@ EXTERN Dcl* externdcl;
EXTERN
Dcl
*
exportlist
;
EXTERN
int
dclcontext
;
// PEXTERN/PAUTO
EXTERN
int
importflag
;
EXTERN
int
inimportsys
;
EXTERN
Node
*
booltrue
;
EXTERN
Node
*
boolfalse
;
EXTERN
ulong
iota
;
EXTERN
long
vargen
;
EXTERN
long
exportgen
;
EXTERN
long
maxarg
;
EXTERN
long
stksize
;
EXTERN
Node
*
retnil
;
EXTERN
Node
*
fskel
;
...
...
src/cmd/gc/go.y
View file @
2254a8ee
...
...
@@ -829,10 +829,14 @@ keyval:
*
all
in
one
place
to
show
how
crappy
it
all
is
*/
xfndcl
:
LFUNC
fndcl
fnbody
LFUNC
{
$$
=
$
2
;
$$->
nbody
=
$
3
;
maxarg
=
0
;
stksize
=
0
;
}
fndcl
fnbody
{
$$
=
$
3
;
$$->
nbody
=
$
4
;
funcbody
($$);
}
...
...
src/cmd/gc/lex.c
View file @
2254a8ee
...
...
@@ -111,7 +111,7 @@ importfile(Val *f)
return
;
}
// BOTCH need to get .8 from backend
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%Z.
8
"
,
f
->
sval
);
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%Z.
6
"
,
f
->
sval
);
imp
=
Bopen
(
namebuf
,
OREAD
);
if
(
imp
==
nil
)
{
...
...
@@ -154,6 +154,7 @@ unimportfile(void)
}
curio
=
pushedio
;
pushedio
.
bin
=
nil
;
inimportsys
=
0
;
}
void
...
...
@@ -166,6 +167,7 @@ cannedimports(void)
curio
.
infile
=
"internal sys.go"
;
curio
.
cp
=
sysimport
;
pkgmyname
=
S
;
inimportsys
=
1
;
}
long
...
...
src/cmd/gc/walk.c
View file @
2254a8ee
...
...
@@ -1301,7 +1301,7 @@ Node*
reorder1
(
Node
*
n
)
{
Iter
save
;
Node
*
l
,
*
r
,
*
f
;
Node
*
l
,
*
r
,
*
f
,
*
a
,
*
g
;
int
c
,
t
;
/*
...
...
@@ -1321,10 +1321,6 @@ loop1:
if
(
l
==
N
)
{
if
(
c
==
0
||
t
==
1
)
return
n
;
if
(
c
>
1
)
{
yyerror
(
"reorder1: too many function calls evaluating parameters"
);
return
n
;
}
goto
pass2
;
}
if
(
l
->
op
==
OLIST
)
...
...
@@ -1338,23 +1334,50 @@ loop1:
pass2:
l
=
listfirst
(
&
save
,
&
n
);
r
=
N
;
// rest
f
=
N
;
// fncall
g
=
N
;
// fncalls assigned to tempnames
f
=
N
;
// one fncall assigned to stack
r
=
N
;
// non fncalls and tempnames assigned to stack
loop2:
if
(
l
==
N
)
{
r
=
nod
(
OLIST
,
f
,
r
);
r
=
rev
(
r
);
g
=
rev
(
g
);
if
(
g
!=
N
)
f
=
nod
(
OLIST
,
g
,
f
);
r
=
nod
(
OLIST
,
f
,
r
);
return
r
;
}
if
(
l
->
ullman
>=
UINF
)
if
(
l
->
ullman
<
UINF
)
{
if
(
r
==
N
)
r
=
l
;
else
r
=
nod
(
OLIST
,
l
,
r
);
goto
more
;
}
if
(
f
==
N
)
{
f
=
l
;
goto
more
;
}
// make assignment of fncall to tempname
a
=
nod
(
OXXX
,
N
,
N
);
tempname
(
a
,
l
->
right
->
type
);
a
=
nod
(
OAS
,
a
,
l
->
right
);
if
(
g
==
N
)
g
=
a
;
else
g
=
nod
(
OLIST
,
a
,
g
);
// put normal arg assignment on list
// with fncall replaced by tempname
l
->
right
=
a
->
left
;
if
(
r
==
N
)
r
=
l
;
else
r
=
nod
(
OLIST
,
l
,
r
);
more:
l
=
listnext
(
&
save
);
goto
loop2
;
}
...
...
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