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
c242b53d
Commit
c242b53d
authored
Jun 18, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more maps
more semi-colons type assignment of constants SVN=123278
parent
c5bb50c9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
23 deletions
+60
-23
const.c
src/cmd/gc/const.c
+11
-1
go.h
src/cmd/gc/go.h
+1
-0
go.y
src/cmd/gc/go.y
+26
-19
subr.c
src/cmd/gc/subr.c
+10
-0
walk.c
src/cmd/gc/walk.c
+12
-3
No files found.
src/cmd/gc/const.c
View file @
c242b53d
...
...
@@ -20,7 +20,17 @@ convlit(Node *n, Type *t)
goto
bad1
;
case
Wlitnil
:
if
(
isptr
[
et
]
||
et
=
TINTER
)
if
(
isptr
[
et
]
||
et
==
TINTER
)
break
;
goto
bad1
;
case
Wlitstr
:
if
(
isptrto
(
t
,
TSTRING
))
break
;
goto
bad1
;
case
Wlitbool
:
if
(
et
==
TBOOL
)
break
;
goto
bad1
;
...
...
src/cmd/gc/go.h
View file @
c242b53d
...
...
@@ -446,6 +446,7 @@ void warn(char*, ...);
void
fatal
(
char
*
,
...);
void
linehist
(
char
*
,
long
);
Node
*
nod
(
int
,
Node
*
,
Node
*
);
Node
*
list
(
Node
*
,
Node
*
);
Type
*
typ
(
int
);
Dcl
*
dcl
(
void
);
Node
*
rev
(
Node
*
);
...
...
src/cmd/gc/go.y
View file @
c242b53d
...
...
@@ -30,7 +30,7 @@
%
type
<
lint
>
chandir
%
type
<
node
>
xdcl
xdcl_list_r
oxdcl_list
common_dcl
%
type
<
node
>
oarg_type_list
arg_type_list_r
arg_type
%
type
<
node
>
else_stmt1
else_stmt2
%
type
<
node
>
else_stmt1
else_stmt2
inc_stmt
noninc_stmt
%
type
<
node
>
complex_stmt
compound_stmt
ostmt_list
%
type
<
node
>
stmt_list_r
Astmt_list_r
Bstmt_list_r
%
type
<
node
>
Astmt
Bstmt
Cstmt
Dstmt
...
...
@@ -232,20 +232,14 @@ else_stmt2:
}
simple_stmt
:
inc_stmt
|
noninc_stmt
noninc_stmt
:
expr
{
$$
=
$
1
;
}
|
expr
LINC
{
$$
=
nod
(
OASOP
,
$
1
,
literal
(
1
));
$$->
etype
=
OADD
;
}
|
expr
LDEC
{
$$
=
nod
(
OASOP
,
$
1
,
literal
(
1
));
$$->
etype
=
OSUB
;
}
|
expr
LASOP
expr
{
$$
=
nod
(
OASOP
,
$
1
,
$
3
);
...
...
@@ -264,6 +258,18 @@ simple_stmt:
$$
=
nod
(
OAS
,
$
1
,
$
3
);
}
inc_stmt
:
expr
LINC
{
$$
=
nod
(
OASOP
,
$
1
,
literal
(
1
));
$$->
etype
=
OADD
;
}
|
expr
LDEC
{
$$
=
nod
(
OASOP
,
$
1
,
literal
(
1
));
$$->
etype
=
OSUB
;
}
complex_stmt
:
LFOR
for_stmt
{
...
...
@@ -1094,14 +1100,15 @@ Bstmt:
*
need
semi
in
back
YES
*/
Cstmt
:
simple
_stmt
noninc
_stmt
/*
*
need
semi
in
front
YES
*
need
semi
in
back
NO
*/
Dstmt
:
new_name
':'
inc_stmt
|
new_name
':'
{
$$
=
nod
(
OLABEL
,
$
1
,
N
);
}
...
...
@@ -1114,15 +1121,15 @@ Astmt_list_r:
|
Dstmt
|
Astmt_list_r
Astmt
{
$$
=
nod
(
OLIST
,
$
1
,
$
2
);
$$
=
list
(
$
1
,
$
2
);
}
|
Astmt_list_r
Dstmt
{
$$
=
nod
(
OLIST
,
$
1
,
$
2
);
$$
=
list
(
$
1
,
$
2
);
}
|
Bstmt_list_r
Astmt
{
$$
=
nod
(
OLIST
,
$
1
,
$
2
);
$$
=
list
(
$
1
,
$
2
);
}
/*
...
...
@@ -1133,15 +1140,15 @@ Bstmt_list_r:
|
Cstmt
|
Astmt_list_r
Bstmt
{
$$
=
nod
(
OLIST
,
$
1
,
$
2
);
$$
=
list
(
$
1
,
$
2
);
}
|
Astmt_list_r
Cstmt
{
$$
=
nod
(
OLIST
,
$
1
,
$
2
);
$$
=
list
(
$
1
,
$
2
);
}
|
Bstmt_list_r
Bstmt
{
$$
=
nod
(
OLIST
,
$
1
,
$
2
);
$$
=
list
(
$
1
,
$
2
);
}
stmt_list_r
:
...
...
src/cmd/gc/subr.c
View file @
c242b53d
...
...
@@ -254,6 +254,16 @@ nod(int op, Node *nleft, Node *nright)
return
n
;
}
Node
*
list
(
Node
*
a
,
Node
*
b
)
{
if
(
a
==
N
)
return
b
;
if
(
b
==
N
)
return
a
;
return
nod
(
OLIST
,
a
,
b
);
}
Type
*
typ
(
int
et
)
{
...
...
src/cmd/gc/walk.c
View file @
c242b53d
...
...
@@ -12,8 +12,12 @@ static Node* curfn;
void
walk
(
Node
*
fn
)
{
if
(
debug
[
'W'
])
dump
(
"fn-before"
,
fn
->
nbody
);
curfn
=
fn
;
walktype
(
fn
->
nbody
,
Etop
);
if
(
debug
[
'W'
])
dump
(
"fn"
,
fn
->
nbody
);
}
void
...
...
@@ -458,6 +462,9 @@ loop:
goto
badt
;
case
TMAP
:
print
(
"top=%d type %lT"
,
top
,
t
);
dump
(
"index"
,
n
);
// right side must map type
if
(
n
->
right
->
type
==
T
)
{
convlit
(
n
->
right
,
t
->
down
);
...
...
@@ -470,6 +477,8 @@ loop:
goto
badt
;
n
->
op
=
OINDEX
;
n
->
type
=
t
->
type
;
if
(
top
==
Erv
)
*
n
=
*
mapop
(
n
,
top
);
break
;
case
TSTRING
:
...
...
@@ -710,7 +719,6 @@ walkswitch(Node *sw, Type*(*call)(Node*, Type*))
{
Node
*
n
,
*
c
;
Type
*
place
;
place
=
call
(
sw
->
ntest
,
T
);
n
=
sw
->
nbody
;
...
...
@@ -1372,10 +1380,10 @@ mapop(Node *n, int top)
r
->
type
=
n
->
type
;
break
;
case
OINDEX
PTR
:
case
OINDEX
:
if
(
top
!=
Erv
)
goto
nottop
;
dump
(
"access start"
,
n
);
// mapaccess1(hmap *map[any]any, key any) (val any);
t
=
fixmap
(
n
->
left
->
type
);
...
...
@@ -1408,6 +1416,7 @@ mapop(Node *n, int top)
r
=
nod
(
OCALL
,
on
,
r
);
walktype
(
r
,
Erv
);
r
->
type
=
t
->
type
;
dump
(
"access finish"
,
r
);
break
;
// mapaccess2(hmap *map[any]any, key any) (val any, pres bool);
...
...
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