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
32aa5be6
Commit
32aa5be6
authored
Sep 08, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init context for composit literals
R=rsc OCL=34462 CL=34462
parent
506c0080
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletion
+48
-1
src/cmd/gc/go.h
src/cmd/gc/go.h
+1
-0
src/cmd/gc/sinit.c
src/cmd/gc/sinit.c
+1
-1
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+46
-0
No files found.
src/cmd/gc/go.h
View file @
32aa5be6
...
...
@@ -1012,6 +1012,7 @@ NodeList* reorder1(NodeList*);
NodeList
*
reorder3
(
NodeList
*
);
NodeList
*
reorder4
(
NodeList
*
);
void
anylit
(
Node
*
,
Node
*
,
NodeList
**
);
int
oaslit
(
Node
*
,
NodeList
**
);
void
heapmoves
(
void
);
void
walkdeflist
(
NodeList
*
);
void
walkdef
(
Node
*
);
...
...
src/cmd/gc/sinit.c
View file @
32aa5be6
...
...
@@ -51,7 +51,7 @@ init1(Node *n, NodeList **out)
case
OAS
:
if
(
n
->
defn
->
left
!=
n
)
goto
bad
;
n
->
dodata
=
1
;
n
->
d
efn
->
d
odata
=
1
;
init1
(
n
->
defn
->
right
,
out
);
if
(
debug
[
'j'
])
print
(
"%S
\n
"
,
n
->
sym
);
...
...
src/cmd/gc/walk.c
View file @
32aa5be6
...
...
@@ -572,6 +572,8 @@ walkexpr(Node **np, NodeList **init)
*
init
=
concat
(
*
init
,
n
->
ninit
);
n
->
ninit
=
nil
;
walkexpr
(
&
n
->
left
,
init
);
if
(
oaslit
(
n
,
init
))
goto
ret
;
walkexpr
(
&
n
->
right
,
init
);
l
=
n
->
left
;
r
=
n
->
right
;
...
...
@@ -2406,6 +2408,50 @@ anylit(Node *n, Node *var, NodeList **init)
}
}
int
oaslit
(
Node
*
n
,
NodeList
**
init
)
{
Type
*
t
;
if
(
n
->
left
==
N
||
n
->
right
==
N
)
goto
no
;
if
(
!
simplename
(
n
->
left
))
goto
no
;
if
(
n
->
dodata
==
1
)
goto
initctxt
;
no:
// not a special composit literal assignment
return
0
;
initctxt:
switch
(
n
->
right
->
op
)
{
default:
goto
no
;
case
OSTRUCTLIT
:
structlit
(
n
->
right
,
n
->
left
,
3
,
init
);
break
;
case
OARRAYLIT
:
t
=
n
->
right
->
type
;
if
(
t
==
T
)
goto
no
;
if
(
t
->
bound
<
0
)
{
slicelit
(
n
->
right
,
n
->
left
,
init
);
break
;
}
arraylit
(
n
->
right
,
n
->
left
,
3
,
init
);
break
;
case
OMAPLIT
:
maplit
(
n
->
right
,
n
->
left
,
init
);
break
;
}
n
->
op
=
OEMPTY
;
return
1
;
}
/*
* walk through argin parameters.
* generate and return code to allocate
...
...
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