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
b0f627a6
Commit
b0f627a6
authored
Jan 06, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
closed arrays including [...]
R=r OCL=22182 CL=22182
parent
af065a0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
src/cmd/gc/go.y
src/cmd/gc/go.y
+6
-0
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+20
-9
src/run.bash
src/run.bash
+1
-1
No files found.
src/cmd/gc/go.y
View file @
b0f627a6
...
...
@@ -1021,6 +1021,12 @@ convtype:
//
array
literal
$$
=
aindex
($
2
,
$
4
);
}
|
'['
LDDD
']'
type
{
//
array
literal
of
nelem
$$
=
aindex
(
N
,
$
4
);
$$->
bound
=
-
100
;
}
|
LMAP
'['
type
']'
type
{
//
map
literal
...
...
src/cmd/gc/walk.c
View file @
b0f627a6
...
...
@@ -3556,23 +3556,24 @@ arraylit(Node *n)
Iter
saver
;
Type
*
t
;
Node
*
var
,
*
r
,
*
a
,
*
nas
,
*
nnew
;
int
idx
;
int
idx
,
b
;
t
=
n
->
type
;
if
(
t
->
etype
!=
TARRAY
)
fatal
(
"arraylit: not array"
);
if
(
t
->
bound
>=
0
)
fatal
(
"arraylit: literal fixed arrays not implemented"
);
var
=
nod
(
OXXX
,
N
,
N
);
tempname
(
var
,
t
);
nnew
=
nod
(
OMAKE
,
N
,
N
);
nnew
->
type
=
t
;
b
=
t
->
bound
;
if
(
b
<
0
&&
b
!=
-
100
)
{
// slice
nnew
=
nod
(
OMAKE
,
N
,
N
);
nnew
->
type
=
t
;
nas
=
nod
(
OAS
,
var
,
nnew
);
addtop
=
list
(
addtop
,
nas
);
nas
=
nod
(
OAS
,
var
,
nnew
);
addtop
=
list
(
addtop
,
nas
);
}
idx
=
0
;
r
=
listfirst
(
&
saver
,
&
n
->
left
);
...
...
@@ -3580,6 +3581,10 @@ arraylit(Node *n)
r
=
N
;
while
(
r
!=
N
)
{
// build list of var[c] = expr
if
(
b
>=
0
&&
idx
>=
b
)
{
yyerror
(
"literal array initializer out of bounds"
);
break
;
}
a
=
nodintconst
(
idx
);
a
=
nod
(
OINDEX
,
var
,
a
);
a
=
nod
(
OAS
,
a
,
r
);
...
...
@@ -3587,7 +3592,13 @@ arraylit(Node *n)
idx
++
;
r
=
listnext
(
&
saver
);
}
nnew
->
left
=
nodintconst
(
idx
);
if
(
b
==
-
100
)
{
// compiler counted closed array
b
=
idx
;
t
->
bound
=
b
;
}
if
(
b
<
0
)
nnew
->
left
=
nodintconst
(
idx
);
return
var
;
}
...
...
src/run.bash
View file @
b0f627a6
...
...
@@ -59,7 +59,7 @@ time make
)
||
exit
$?
(
xcd ../doc/progs
time
run
time
./
run
)
||
exit
$?
(
xcd ../test
...
...
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