summaryrefslogtreecommitdiff
path: root/src/runtime/iface.c
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-10-14 15:08:23 -0700
committerKen Thompson <ken@golang.org>2008-10-14 15:08:23 -0700
commita3831168477e03461690c46f7da76ed0f1b38ad7 (patch)
tree763f14f0e3a823f0cb9ab3a6c211f700ba736818 /src/runtime/iface.c
parentb54399e914a7a0f136a363f1fdc5237e3b9ec025 (diff)
downloadgolang-a3831168477e03461690c46f7da76ed0f1b38ad7.tar.gz
interface equality
R=r OCL=17116 CL=17118
Diffstat (limited to 'src/runtime/iface.c')
-rw-r--r--src/runtime/iface.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/runtime/iface.c b/src/runtime/iface.c
index de59172d1..b303e459e 100644
--- a/src/runtime/iface.c
+++ b/src/runtime/iface.c
@@ -261,6 +261,53 @@ sys·ifaceI2I(Sigi *si, Map *im, void *it, Map *retim, void *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
sys·printinter(Map *im, void *it)
{