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
e5d9a5c9
Commit
e5d9a5c9
authored
Nov 04, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime support for interface ok,
whatever the final syntax ends up being. R=ken OCL=18414 CL=18414
parent
47caf642
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
8 deletions
+75
-8
sys.go
src/cmd/gc/sys.go
+2
-0
sysimport.c
src/cmd/gc/sysimport.c
+2
-0
iface.c
src/runtime/iface.c
+71
-8
No files found.
src/cmd/gc/sys.go
View file @
e5d9a5c9
...
...
@@ -30,7 +30,9 @@ export func arraystring(*[]byte) string;
export
func
ifaceT2I
(
sigi
*
byte
,
sigt
*
byte
,
elem
any
)
(
ret
any
);
export
func
ifaceI2T
(
sigt
*
byte
,
iface
any
)
(
ret
any
);
export
func
ifaceI2T2
(
sigt
*
byte
,
iface
any
)
(
ret
any
,
ok
bool
);
export
func
ifaceI2I
(
sigi
*
byte
,
iface
any
)
(
ret
any
);
export
func
ifaceI2I2
(
sigi
*
byte
,
iface
any
)
(
ret
any
,
ok
bool
);
export
func
ifaceeq
(
i1
any
,
i2
any
)
(
ret
bool
);
export
func
reflect
(
i
interface
{
})
(
uint64
,
string
);
export
func
unreflect
(
uint64
,
string
)
(
ret
interface
{
});
...
...
src/cmd/gc/sysimport.c
View file @
e5d9a5c9
...
...
@@ -22,7 +22,9 @@ char *sysimport =
"export func sys.arraystring (? *[]uint8) (? string)
\n
"
"export func sys.ifaceT2I (sigi *uint8, sigt *uint8, elem any) (ret any)
\n
"
"export func sys.ifaceI2T (sigt *uint8, iface any) (ret any)
\n
"
"export func sys.ifaceI2T2 (sigt *uint8, iface any) (ret any, ok bool)
\n
"
"export func sys.ifaceI2I (sigi *uint8, iface any) (ret any)
\n
"
"export func sys.ifaceI2I2 (sigi *uint8, iface any) (ret any, ok bool)
\n
"
"export func sys.ifaceeq (i1 any, i2 any) (ret bool)
\n
"
"export func sys.reflect (i interface { }) (? uint64, ? string)
\n
"
"export func sys.unreflect (? uint64, ? string) (ret interface { })
\n
"
...
...
src/runtime/iface.c
View file @
e5d9a5c9
...
...
@@ -238,8 +238,6 @@ sys·ifaceT2I(Sigi *si, Sigt *st, void *elem, Map *retim, void *retit)
void
sys
·
ifaceI2T
(
Sigt
*
st
,
Map
*
im
,
void
*
it
,
void
*
ret
)
{
// int32 alg, wid;
if
(
debug
)
{
prints
(
"I2T sigt="
);
printsigt
(
st
);
...
...
@@ -250,22 +248,44 @@ sys·ifaceI2T(Sigt *st, Map *im, void *it, void *ret)
if
(
im
==
nil
)
throw
(
"ifaceI2T: nil map"
);
if
(
im
->
sigt
!=
st
)
throw
(
"ifaceI2T: wrong type"
);
// alg = st->hash;
// wid = st->offset;
// algarray[alg].copy(wid, &ret, &it);
ret
=
it
;
if
(
debug
)
{
prints
(
"I2T ret="
);
sys
·
printpointer
(
ret
);
prints
(
"
\n
"
);
}
FLUSH
(
&
ret
);
}
// ifaceI2T2(sigt *byte, iface any) (ret any, ok bool);
void
sys
·
ifaceI2T2
(
Sigt
*
st
,
Map
*
im
,
void
*
it
,
void
*
ret
,
bool
ok
)
{
if
(
debug
)
{
prints
(
"I2T2 sigt="
);
printsigt
(
st
);
prints
(
" iface="
);
printiface
(
im
,
it
);
prints
(
"
\n
"
);
}
if
(
im
==
nil
||
im
->
sigt
!=
st
)
{
ret
=
0
;
ok
=
0
;
}
else
{
ret
=
it
;
ok
=
1
;
}
if
(
debug
)
{
prints
(
"I2T2 ret="
);
sys
·
printpointer
(
ret
);
sys
·
printbool
(
ok
);
prints
(
"
\n
"
);
}
FLUSH
(
&
ret
);
FLUSH
(
&
ok
);
}
// ifaceI2I(sigi *byte, iface any) (ret any);
...
...
@@ -302,6 +322,49 @@ sys·ifaceI2I(Sigi *si, Map *im, void *it, Map *retim, void *retit)
FLUSH
(
&
retit
);
}
// ifaceI2I2(sigi *byte, iface any) (ret any, ok bool);
void
sys
·
ifaceI2I2
(
Sigi
*
si
,
Map
*
im
,
void
*
it
,
Map
*
retim
,
void
*
retit
,
bool
ok
)
{
if
(
debug
)
{
prints
(
"I2I2 sigi="
);
printsigi
(
si
);
prints
(
" iface="
);
printiface
(
im
,
it
);
prints
(
"
\n
"
);
}
if
(
im
==
nil
)
{
// If incoming interface is uninitialized (zeroed)
// make the outgoing interface zeroed as well.
retim
=
nil
;
retit
=
nil
;
ok
=
1
;
}
else
{
retit
=
it
;
retim
=
im
;
ok
=
1
;
if
(
im
->
sigi
!=
si
)
{
retim
=
hashmap
(
si
,
im
->
sigt
,
1
);
if
(
retim
==
nil
)
{
retit
=
nil
;
retim
=
nil
;
ok
=
0
;
}
}
}
if
(
debug
)
{
prints
(
"I2I ret="
);
printiface
(
retim
,
retit
);
prints
(
"
\n
"
);
}
FLUSH
(
&
retim
);
FLUSH
(
&
retit
);
FLUSH
(
&
ok
);
}
// ifaceeq(i1 any, i2 any) (ret bool);
void
sys
·
ifaceeq
(
Map
*
im1
,
void
*
it1
,
Map
*
im2
,
void
*
it2
,
byte
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