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
fce222a9
Commit
fce222a9
authored
Sep 08, 2010
by
Scott Lawrence
Committed by
Russ Cox
Sep 08, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: implement new slice spec
Fixes #382. R=gri, cw, r, rsc CC=golang-dev
https://golang.org/cl/1957045
parent
89e92318
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
17 deletions
+23
-17
src/cmd/gc/go.y
src/cmd/gc/go.y
+0
-4
src/cmd/gc/typecheck.c
src/cmd/gc/typecheck.c
+6
-8
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+17
-5
No files found.
src/cmd/gc/go.y
View file @
fce222a9
...
...
@@ -845,10 +845,6 @@ pexpr_no_paren:
}
|
pexpr
'['
oexpr
':'
oexpr
']'
{
if
($
3
==
N
)
{
yyerror
(
"missing lower bound in slice expression"
);
$
3
=
nodintconst
(
0
);
}
$$
=
nod
(
OSLICE
,
$
1
,
nod
(
OKEY
,
$
3
,
$
5
));
}
|
pseudocall
...
...
src/cmd/gc/typecheck.c
View file @
fce222a9
...
...
@@ -654,16 +654,14 @@ reswitch:
typecheck
(
&
n
->
left
,
top
);
}
implicitstar
(
&
n
->
left
);
if
(
n
->
right
->
left
==
N
)
{
yyerror
(
"missing slice bounds?"
);
goto
error
;
}
if
(
n
->
right
->
left
!=
N
)
{
if
((
t
=
n
->
right
->
left
->
type
)
==
T
)
goto
error
;
if
(
!
isint
[
t
->
etype
])
{
yyerror
(
"invalid slice index %#N (type %T)"
,
n
->
right
->
left
,
t
);
goto
error
;
}
}
if
(
n
->
right
->
right
!=
N
)
{
if
((
t
=
n
->
right
->
right
->
type
)
==
T
)
goto
error
;
...
...
src/cmd/gc/walk.c
View file @
fce222a9
...
...
@@ -1095,13 +1095,17 @@ walkexpr(Node **np, NodeList **init)
// sliceslice(old []any, lb uint64, hb uint64, width uint64) (ary []any)
// sliceslice1(old []any, lb uint64, width uint64) (ary []any)
t
=
n
->
type
;
if
(
n
->
right
->
left
==
N
)
l
=
nodintconst
(
0
);
else
l
=
conv
(
n
->
right
->
left
,
types
[
TUINT64
]);
if
(
n
->
right
->
right
!=
N
)
{
fn
=
syslook
(
"sliceslice"
,
1
);
argtype
(
fn
,
t
->
type
);
// any-1
argtype
(
fn
,
t
->
type
);
// any-2
n
=
mkcall1
(
fn
,
t
,
init
,
n
->
left
,
conv
(
n
->
right
->
left
,
types
[
TUINT64
])
,
l
,
conv
(
n
->
right
->
right
,
types
[
TUINT64
]),
nodintconst
(
t
->
type
->
width
));
}
else
{
...
...
@@ -1110,7 +1114,7 @@ walkexpr(Node **np, NodeList **init)
argtype
(
fn
,
t
->
type
);
// any-2
n
=
mkcall1
(
fn
,
t
,
init
,
n
->
left
,
conv
(
n
->
right
->
left
,
types
[
TUINT64
])
,
l
,
nodintconst
(
t
->
type
->
width
));
}
goto
ret
;
...
...
@@ -1122,13 +1126,17 @@ walkexpr(Node **np, NodeList **init)
fn
=
syslook
(
"slicearray"
,
1
);
argtype
(
fn
,
n
->
left
->
type
);
// any-1
argtype
(
fn
,
t
->
type
);
// any-2
if
(
n
->
right
->
left
==
N
)
l
=
nodintconst
(
0
);
else
l
=
conv
(
n
->
right
->
left
,
types
[
TUINT64
]);
if
(
n
->
right
->
right
==
N
)
r
=
nodintconst
(
n
->
left
->
type
->
bound
);
else
r
=
conv
(
n
->
right
->
right
,
types
[
TUINT64
]);
n
=
mkcall1
(
fn
,
t
,
init
,
nod
(
OADDR
,
n
->
left
,
N
),
nodintconst
(
n
->
left
->
type
->
bound
),
conv
(
n
->
right
->
left
,
types
[
TUINT64
])
,
l
,
r
,
nodintconst
(
t
->
type
->
width
));
goto
ret
;
...
...
@@ -1213,15 +1221,19 @@ walkexpr(Node **np, NodeList **init)
case
OSLICESTR
:
// sys_slicestring(s, lb, hb)
if
(
n
->
right
->
left
==
N
)
l
=
nodintconst
(
0
);
else
l
=
conv
(
n
->
right
->
left
,
types
[
TINT
]);
if
(
n
->
right
->
right
)
{
n
=
mkcall
(
"slicestring"
,
n
->
type
,
init
,
conv
(
n
->
left
,
types
[
TSTRING
]),
conv
(
n
->
right
->
left
,
types
[
TINT
])
,
l
,
conv
(
n
->
right
->
right
,
types
[
TINT
]));
}
else
{
n
=
mkcall
(
"slicestring1"
,
n
->
type
,
init
,
conv
(
n
->
left
,
types
[
TSTRING
]),
conv
(
n
->
right
->
left
,
types
[
TINT
])
);
l
);
}
goto
ret
;
...
...
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