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
edb1412c
Commit
edb1412c
authored
Oct 14, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interface equality
R=r OCL=17116 CL=17118
parent
18365415
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
1 deletion
+77
-1
lex.c
src/cmd/gc/lex.c
+1
-0
sys.go
src/cmd/gc/sys.go
+1
-0
sysimport.c
src/cmd/gc/sysimport.c
+1
-0
walk.c
src/cmd/gc/walk.c
+27
-1
iface.c
src/runtime/iface.c
+47
-0
No files found.
src/cmd/gc/lex.c
View file @
edb1412c
...
@@ -1063,6 +1063,7 @@ lexinit(void)
...
@@ -1063,6 +1063,7 @@ lexinit(void)
case
TPTR32
:
case
TPTR32
:
case
TPTR64
:
case
TPTR64
:
case
TINTER
:
okforeq
[
i
]
=
1
;
okforeq
[
i
]
=
1
;
break
;
break
;
}
}
...
...
src/cmd/gc/sys.go
View file @
edb1412c
...
@@ -31,6 +31,7 @@ export func arraystring(*[]byte) string;
...
@@ -31,6 +31,7 @@ export func arraystring(*[]byte) string;
export
func
ifaceT2I
(
sigi
*
byte
,
sigt
*
byte
,
elem
any
)
(
ret
any
);
export
func
ifaceT2I
(
sigi
*
byte
,
sigt
*
byte
,
elem
any
)
(
ret
any
);
export
func
ifaceI2T
(
sigt
*
byte
,
iface
any
)
(
ret
any
);
export
func
ifaceI2T
(
sigt
*
byte
,
iface
any
)
(
ret
any
);
export
func
ifaceI2I
(
sigi
*
byte
,
iface
any
)
(
ret
any
);
export
func
ifaceI2I
(
sigi
*
byte
,
iface
any
)
(
ret
any
);
export
func
ifaceeq
(
i1
any
,
i2
any
)
(
ret
bool
);
export
func
argc
()
int32
;
export
func
argc
()
int32
;
export
func
envc
()
int32
;
export
func
envc
()
int32
;
...
...
src/cmd/gc/sysimport.c
View file @
edb1412c
...
@@ -31,6 +31,7 @@ char *sysimport =
...
@@ -31,6 +31,7 @@ char *sysimport =
"export func sys.ifaceT2I (sigi *sys.uint8, sigt *sys.uint8, elem sys.any) (ret sys.any)
\n
"
"export func sys.ifaceT2I (sigi *sys.uint8, sigt *sys.uint8, elem sys.any) (ret sys.any)
\n
"
"export func sys.ifaceI2T (sigt *sys.uint8, iface sys.any) (ret sys.any)
\n
"
"export func sys.ifaceI2T (sigt *sys.uint8, iface sys.any) (ret sys.any)
\n
"
"export func sys.ifaceI2I (sigi *sys.uint8, iface sys.any) (ret sys.any)
\n
"
"export func sys.ifaceI2I (sigi *sys.uint8, iface sys.any) (ret sys.any)
\n
"
"export func sys.ifaceeq (i1 sys.any, i2 sys.any) (ret sys.bool)
\n
"
"export func sys.argc () (? sys.int32)
\n
"
"export func sys.argc () (? sys.int32)
\n
"
"export func sys.envc () (? sys.int32)
\n
"
"export func sys.envc () (? sys.int32)
\n
"
"export func sys.argv (? sys.int32) (? sys.string)
\n
"
"export func sys.argv (? sys.int32) (? sys.string)
\n
"
...
...
src/cmd/gc/walk.c
View file @
edb1412c
...
@@ -681,7 +681,7 @@ loop:
...
@@ -681,7 +681,7 @@ loop:
convlit
(
n
->
right
,
n
->
left
->
type
);
convlit
(
n
->
right
,
n
->
left
->
type
);
if
(
n
->
left
->
type
==
T
||
n
->
right
->
type
==
T
)
if
(
n
->
left
->
type
==
T
||
n
->
right
->
type
==
T
)
goto
ret
;
goto
ret
;
if
(
!
ascompat
(
n
->
left
->
type
,
n
->
right
->
type
))
if
(
!
eqtype
(
n
->
left
->
type
,
n
->
right
->
type
,
0
))
goto
badt
;
goto
badt
;
switch
(
n
->
op
)
{
switch
(
n
->
op
)
{
...
@@ -952,6 +952,10 @@ loop:
...
@@ -952,6 +952,10 @@ loop:
et
=
n
->
left
->
type
->
etype
;
et
=
n
->
left
->
type
->
etype
;
if
(
!
okforeq
[
et
])
if
(
!
okforeq
[
et
])
goto
badt
;
goto
badt
;
if
(
isinter
(
n
->
left
->
type
))
{
indir
(
n
,
ifaceop
(
T
,
n
,
n
->
op
));
goto
ret
;
}
t
=
types
[
TBOOL
];
t
=
types
[
TBOOL
];
break
;
break
;
...
@@ -2550,6 +2554,28 @@ ifaceop(Type *tl, Node *n, int op)
...
@@ -2550,6 +2554,28 @@ ifaceop(Type *tl, Node *n, int op)
argtype
(
on
,
tr
);
argtype
(
on
,
tr
);
argtype
(
on
,
tl
);
argtype
(
on
,
tl
);
break
;
break
;
case
OEQ
:
case
ONE
:
// ifaceeq(i1 any-1, i2 any-2) (ret bool);
a
=
n
->
right
;
// i2
r
=
a
;
a
=
n
->
left
;
// i1
r
=
list
(
a
,
r
);
on
=
syslook
(
"ifaceeq"
,
1
);
argtype
(
on
,
n
->
right
->
type
);
argtype
(
on
,
n
->
left
->
type
);
r
=
nod
(
OCALL
,
on
,
r
);
if
(
op
==
ONE
)
r
=
nod
(
ONOT
,
r
,
N
);
dump
(
"bef"
,
r
);
walktype
(
r
,
Erv
);
dump
(
"aft"
,
r
);
return
r
;
}
}
r
=
nod
(
OCALL
,
on
,
r
);
r
=
nod
(
OCALL
,
on
,
r
);
...
...
src/runtime/iface.c
View file @
edb1412c
...
@@ -261,6 +261,53 @@ sys·ifaceI2I(Sigi *si, Map *im, void *it, Map *retim, void *retit)
...
@@ -261,6 +261,53 @@ sys·ifaceI2I(Sigi *si, Map *im, void *it, Map *retim, void *retit)
FLUSH
(
&
retit
);
FLUSH
(
&
retit
);
}
}
// ifaceeq(i1 any, i2 any) (ret bool);
void
sys
·
ifaceeq
(
Map
*
im1
,
void
*
it1
,
Map
*
im2
,
void
*
it2
,
byte
ret
)
{
if
(
debug
)
{
prints
(
"Ieq i1="
);
printiface
(
im1
,
it1
);
prints
(
" i2="
);
printiface
(
im2
,
it2
);
prints
(
"
\n
"
);
}
ret
=
false
;
// are they both nil
if
(
im1
==
nil
)
{
if
(
im2
==
nil
)
goto
yes
;
goto
no
;
}
if
(
im2
==
nil
)
goto
no
;
// values
if
(
it1
!=
it2
)
goto
no
;
// types
if
(
im1
==
im2
)
goto
yes
;
if
(
im1
->
sigt
==
im2
->
sigt
)
goto
yes
;
if
(
im1
->
sigt
->
hash
!=
im2
->
sigt
->
hash
)
goto
no
;
yes
:
ret
=
true
;
no
:
if
(
debug
)
{
prints
(
"Ieq ret="
);
sys
·
printbool
(
ret
);
prints
(
"
\n
"
);
}
FLUSH
(
&
ret
);
}
void
void
sys
·
printinter
(
Map
*
im
,
void
*
it
)
sys
·
printinter
(
Map
*
im
,
void
*
it
)
{
{
...
...
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