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
a2b8e387
Commit
a2b8e387
authored
Jul 31, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkpoint; still plenty to clean up
R=ken OCL=32576 CL=32580
parent
9299ae46
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
490 additions
and
1039 deletions
+490
-1039
src/cmd/gc/Makefile
src/cmd/gc/Makefile
+5
-0
src/cmd/gc/builtin.c.boot
src/cmd/gc/builtin.c.boot
+1
-1
src/cmd/gc/dcl.c
src/cmd/gc/dcl.c
+1
-1
src/cmd/gc/go.h
src/cmd/gc/go.h
+69
-40
src/cmd/gc/mkbuiltin
src/cmd/gc/mkbuiltin
+1
-1
src/cmd/gc/mkbuiltin1.c
src/cmd/gc/mkbuiltin1.c
+1
-1
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+4
-124
src/cmd/gc/swt.c
src/cmd/gc/swt.c
+3
-3
src/cmd/gc/sys.go
src/cmd/gc/sys.go
+1
-2
src/cmd/gc/typecheck.c
src/cmd/gc/typecheck.c
+15
-4
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+389
-862
No files found.
src/cmd/gc/Makefile
View file @
a2b8e387
...
...
@@ -52,6 +52,11 @@ builtin.c: sys.go unsafe.go mkbuiltin1.c mkbuiltin
./mkbuiltin
>
builtin.c
||
\
(
echo
'mkbuiltin failed; using bootstrap copy of builtin.c'
;
cp
builtin.c.boot builtin.c
)
subr.$O
:
opnames.h
opnames.h
:
mkopnames go.h
./mkopnames go.h
>
opnames.h
clean
:
rm
-f
$(OFILES)
*
.6 enam.c 6.out a.out y.tab.h y.tab.c
$(LIB)
mkbuiltin1 builtin.c _builtin.c
...
...
src/cmd/gc/builtin.c.boot
View file @
a2b8e387
...
...
@@ -4,7 +4,7 @@ char *sysimport =
"func sys.throwindex ()\n"
"func sys.throwreturn ()\n"
"func sys.throwinit ()\n"
"func sys.panicl (
? int32
)\n"
"func sys.panicl ()\n"
"func sys.printbool (? bool)\n"
"func sys.printfloat (? float64)\n"
"func sys.printint (? int64)\n"
...
...
src/cmd/gc/dcl.c
View file @
a2b8e387
...
...
@@ -1670,7 +1670,7 @@ variter(NodeList *vl, Node *nt, NodeList *el)
v
=
vl
->
n
;
tv
=
t
;
if
(
t
==
T
)
{
gettype
(
&
e
,
&
r
);
typecheck
(
&
e
,
Erv
);
defaultlit
(
&
e
,
T
);
tv
=
e
->
type
;
}
...
...
src/cmd/gc/go.h
View file @
a2b8e387
...
...
@@ -320,43 +320,75 @@ enum
{
OXXX
,
ONAME
,
ONONAME
,
OTYPE
,
OPACK
,
OLITERAL
,
ODCL
,
ODOT
,
ODOTPTR
,
ODOTMETH
,
ODOTINTER
,
ODCLFUNC
,
ODCLFIELD
,
ODCLARG
,
OCMP
,
OPTR
,
OARRAY
,
ORANGE
,
ORETURN
,
OFOR
,
OIF
,
OSWITCH
,
ODEFER
,
OAS
,
OAS2
,
OASOP
,
OCASE
,
OXCASE
,
OFALL
,
OXFALL
,
OGOTO
,
OPROC
,
OMAKE
,
ONEW
,
OEMPTY
,
OSELECT
,
OLEN
,
OCAP
,
OPANIC
,
OPANICN
,
OPRINT
,
OPRINTN
,
OTYPEOF
,
OCLOSE
,
OCLOSED
,
OBLOCK
,
OOROR
,
// names
ONAME
,
ONONAME
,
OTYPE
,
OPACK
,
OLITERAL
,
// exprs
OADD
,
OSUB
,
OOR
,
OXOR
,
OADDR
,
OANDAND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AK
,
OCASE
,
OXCASE
,
OCONTINUE
,
ODEFER
,
OEMPTY
,
OFALL
,
OXFALL
,
OFOR
,
OGOTO
,
OIF
,
OLABEL
,
OPROC
,
ORANGE
,
ORETURN
,
OSELECT
,
OSWITCH
,
OTYPECASE
,
OTYPESW
,
// types
OTCHAN
,
OTMAP
,
OTSTRUCT
,
OTINTER
,
OTFUNC
,
OTARRAY
,
// for back ends
OCMP
,
ODEC
,
OEXTEND
,
OINC
,
OREGISTER
,
OINDREG
,
OEND
,
};
...
...
@@ -936,12 +968,10 @@ Type* pkgtype(Sym*);
/*
* walk.c
*/
void
gettype
(
Node
**
,
NodeList
**
);
void
walk
(
Node
*
);
void
walkstmt
(
Node
**
);
void
walkstmtlist
(
NodeList
*
);
void
walkexpr
(
Node
**
,
int
,
NodeList
**
);
void
walkexprlist
(
NodeList
*
,
int
,
NodeList
**
);
void
walkexprlist
(
NodeList
*
,
NodeList
**
);
void
walkconv
(
Node
**
,
NodeList
**
);
void
walkdottype
(
Node
*
,
NodeList
**
);
void
walkas
(
Node
*
);
...
...
@@ -949,21 +979,20 @@ void walkbool(Node**);
void
walkswitch
(
Node
*
);
void
walkselect
(
Node
*
);
void
walkdot
(
Node
*
,
NodeList
**
);
void
walkexpr
(
Node
**
,
NodeList
**
);
Node
*
ascompatee1
(
int
,
Node
*
,
Node
*
,
NodeList
**
);
NodeList
*
ascompatee
(
int
,
NodeList
*
,
NodeList
*
,
NodeList
**
);
NodeList
*
ascompatet
(
int
,
NodeList
*
,
Type
**
,
int
,
NodeList
**
);
NodeList
*
ascompatte
(
int
,
Type
**
,
NodeList
*
,
int
,
NodeList
**
);
int
ascompat
(
Type
*
,
Type
*
);
Node
*
prcompat
(
NodeList
*
,
int
,
int
);
Node
*
nodpanic
(
int32
);
Node
*
newcompat
(
Node
*
);
Node
*
makecompat
(
Node
*
);
Node
*
stringop
(
Node
*
,
int
,
NodeList
**
);
Node
*
stringop
(
Node
*
,
NodeList
**
);
Type
*
fixmap
(
Type
*
);
Node
*
mapop
(
Node
*
,
int
,
NodeList
**
);
Node
*
mapop
(
Node
*
,
NodeList
**
);
Type
*
fixchan
(
Type
*
);
Node
*
chanop
(
Node
*
,
int
,
NodeList
**
);
Node
*
arrayop
(
Node
*
,
int
);
Node
*
chanop
(
Node
*
,
NodeList
**
);
Node
*
arrayop
(
Node
*
);
Node
*
ifacecvt
(
Type
*
,
Node
*
,
int
);
Node
*
ifaceop
(
Node
*
);
int
ifaceas
(
Type
*
,
Type
*
,
int
);
...
...
src/cmd/gc/mkbuiltin
View file @
a2b8e387
...
...
@@ -16,7 +16,7 @@ rm -f _builtin.c
for
i
in
sys unsafe
do
$GC
-A
$i
.go
./mkbuiltin1
$i
>>
_builtin.c
O
=
$O
./mkbuiltin1
$i
>>
_builtin.c
done
# If _builtin.c has changed vs builtin.c.boot,
...
...
src/cmd/gc/mkbuiltin1.c
View file @
a2b8e387
...
...
@@ -26,7 +26,7 @@ main(int argc, char **argv)
name
=
argv
[
1
];
snprintf
(
initfunc
,
sizeof
(
initfunc
),
"init_%s_function"
,
name
);
snprintf
(
buf
,
sizeof
(
buf
),
"%s.
6"
,
name
);
snprintf
(
buf
,
sizeof
(
buf
),
"%s.
%s"
,
name
,
getenv
(
"O"
)
);
if
((
fin
=
fopen
(
buf
,
"r"
))
==
NULL
)
{
fprintf
(
stderr
,
"open %s: %s
\n
"
,
buf
,
strerror
(
errno
));
exit
(
1
);
...
...
src/cmd/gc/subr.c
View file @
a2b8e387
...
...
@@ -4,6 +4,7 @@
#include "go.h"
#include "y.tab.h"
#include "opnames.h"
void
errorexit
(
void
)
...
...
@@ -612,127 +613,6 @@ dump(char *s, Node *n)
dodump
(
n
,
1
);
}
/*
s%,%,\n%g
s%\n+%\n%g
s%^[ ]*O%%g
s%,.*%%g
s%.+% [O&] = "&",%g
s%^ ........*\]%&~%g
s%~ %%g
|sort
*/
static
char
*
opnames
[]
=
{
[
OADDR
]
=
"ADDR"
,
[
OADD
]
=
"ADD"
,
[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ESW"
,
[
OTYPE
]
=
"TYPE"
,
[
OXCASE
]
=
"XCASE"
,
[
OXFALL
]
=
"XFALL"
,
[
OXOR
]
=
"XOR"
,
[
OXXX
]
=
"XXX"
,
};
static
char
*
goopnames
[]
=
{
...
...
@@ -2395,7 +2275,7 @@ saferef(Node *n, NodeList **init)
*
r
=
*
n
;
r
->
left
=
l
;
typecheck
(
&
r
,
Elv
);
walkexpr
(
&
r
,
Elv
,
init
);
walkexpr
(
&
r
,
init
);
return
r
;
case
OINDEX
:
...
...
@@ -2405,11 +2285,11 @@ saferef(Node *n, NodeList **init)
tempname
(
l
,
ptrto
(
n
->
type
));
a
=
nod
(
OAS
,
l
,
nod
(
OADDR
,
n
,
N
));
typecheck
(
&
a
,
Etop
);
walkexpr
(
&
a
,
Etop
,
init
);
walkexpr
(
&
a
,
init
);
*
init
=
list
(
*
init
,
a
);
r
=
nod
(
OIND
,
l
,
N
);
typecheck
(
&
r
,
Elv
);
walkexpr
(
&
r
,
Elv
,
init
);
walkexpr
(
&
r
,
init
);
return
r
;
}
fatal
(
"saferef %N"
,
n
);
...
...
src/cmd/gc/swt.c
View file @
a2b8e387
...
...
@@ -250,7 +250,7 @@ sw0(Node **cp, Type *place, int arg)
yyerror
(
"expression case in a type switch"
);
return
T
;
}
walkexpr
(
cp
,
Erv
,
nil
);
walkexpr
(
cp
,
nil
);
break
;
case
OTYPESW
:
case
OTYPECASE
:
...
...
@@ -596,7 +596,7 @@ exprswitch(Node *sw)
if
(
sw
->
ntest
->
val
.
u
.
bval
==
0
)
arg
=
Sfalse
;
}
walkexpr
(
&
sw
->
ntest
,
Erv
,
&
sw
->
ninit
);
walkexpr
(
&
sw
->
ntest
,
&
sw
->
ninit
);
/*
* pass 0,1,2,3
...
...
@@ -780,7 +780,7 @@ typeswitch(Node *sw)
yyerror
(
"type switch must have an assignment"
);
return
;
}
walkexpr
(
&
sw
->
ntest
->
right
,
Erv
,
&
sw
->
ninit
);
walkexpr
(
&
sw
->
ntest
->
right
,
&
sw
->
ninit
);
if
(
!
istype
(
sw
->
ntest
->
right
->
type
,
TINTER
))
{
yyerror
(
"type switch must be on an interface"
);
return
;
...
...
src/cmd/gc/sys.go
View file @
a2b8e387
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
PACKAGE
// emitted by compiler, not referred to by go programs
...
...
@@ -11,7 +10,7 @@ func mal(int32) *any;
func
throwindex
();
func
throwreturn
();
func
throwinit
();
func
panicl
(
int32
);
func
panicl
();
func
printbool
(
bool
);
func
printfloat
(
float64
);
...
...
src/cmd/gc/typecheck.c
View file @
a2b8e387
...
...
@@ -315,7 +315,9 @@ reswitch:
* exprs
*/
case
OADDR
:
l
=
typecheck
(
&
n
->
left
,
Elv
);
typecheck
(
&
n
->
left
,
Elv
);
defaultlit
(
&
n
->
left
,
T
);
l
=
n
->
left
;
if
((
t
=
l
->
type
)
==
T
)
goto
error
;
n
->
type
=
ptrto
(
t
);
...
...
@@ -452,6 +454,9 @@ reswitch:
break
;
case
TMAP
:
n
->
etype
=
0
;
if
(
top
&
Elv
)
n
->
etype
=
1
;
// clumsy hack
ok
|=
Erv
|
Elv
;
defaultlit
(
&
n
->
right
,
t
->
down
);
n
->
type
=
t
->
type
;
...
...
@@ -499,6 +504,9 @@ reswitch:
if
((
t
=
r
->
type
)
==
T
)
goto
error
;
// TODO: more aggressive
n
->
etype
=
0
;
if
(
top
&
Erv
)
n
->
etype
=
1
;
// clumsy hack
ok
|=
Etop
|
Erv
;
n
->
type
=
types
[
TBOOL
];
goto
ret
;
...
...
@@ -539,12 +547,15 @@ reswitch:
goto
error
;
case
TARRAY
:
ok
|=
Elv
;
n
=
arrayop
(
n
,
Erv
);
n
->
type
=
typ
(
TARRAY
);
n
->
type
->
type
=
t
;
n
->
type
->
bound
=
-
1
;
n
=
arrayop
(
n
);
break
;
case
TSTRING
:
n
=
stringop
(
n
,
Erv
,
nil
);
n
->
type
=
t
;
n
=
stringop
(
n
,
nil
);
break
;
}
goto
ret
;
...
...
src/cmd/gc/walk.c
View file @
a2b8e387
This diff is collapsed.
Click to expand it.
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