Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
8a2cb59f
Commit
8a2cb59f
authored
Oct 04, 2013
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reflect: Fix calling Interface method on value created by MakeFunc.
From-SVN: r203212
parent
c6d2bfbb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletions
+25
-1
libgo/go/reflect/all_test.go
+24
-0
libgo/go/reflect/makefunc.go
+1
-1
No files found.
libgo/go/reflect/all_test.go
View file @
8a2cb59f
...
...
@@ -1454,6 +1454,30 @@ func TestMakeFunc(t *testing.T) {
}
}
func
TestMakeFuncInterface
(
t
*
testing
.
T
)
{
switch
runtime
.
GOARCH
{
case
"amd64"
,
"386"
:
default
:
t
.
Skip
(
"MakeFunc not implemented for "
+
runtime
.
GOARCH
)
}
fn
:=
func
(
i
int
)
int
{
return
i
}
incr
:=
func
(
in
[]
Value
)
[]
Value
{
return
[]
Value
{
ValueOf
(
int
(
in
[
0
]
.
Int
()
+
1
))}
}
fv
:=
MakeFunc
(
TypeOf
(
fn
),
incr
)
ValueOf
(
&
fn
)
.
Elem
()
.
Set
(
fv
)
if
r
:=
fn
(
2
);
r
!=
3
{
t
.
Errorf
(
"Call returned %d, want 3"
,
r
)
}
if
r
:=
fv
.
Call
([]
Value
{
ValueOf
(
14
)})[
0
]
.
Int
();
r
!=
15
{
t
.
Errorf
(
"Call returned %d, want 15"
,
r
)
}
if
r
:=
fv
.
Interface
()
.
(
func
(
int
)
int
)(
26
);
r
!=
27
{
t
.
Errorf
(
"Call returned %d, want 27"
,
r
)
}
}
type
Point
struct
{
x
,
y
int
}
...
...
libgo/go/reflect/makefunc.go
View file @
8a2cb59f
...
...
@@ -63,7 +63,7 @@ func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value {
impl
:=
&
makeFuncImpl
{
code
:
code
,
typ
:
ftyp
,
fn
:
fn
}
return
Value
{
t
,
unsafe
.
Pointer
(
impl
),
flag
(
Func
)
<<
flagKindShift
}
return
Value
{
t
,
unsafe
.
Pointer
(
&
impl
),
flag
(
Func
<<
flagKindShift
)
|
flagIndir
}
}
// makeFuncStub is an assembly function that is the code half of
...
...
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