summary refs log tree commit diff stats
path: root/compiler/ccgexprs.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/ccgexprs.nim')
-rwxr-xr-xcompiler/ccgexprs.nim15
1 files changed, 14 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 2199f2067..e02a38004 100755
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -458,7 +458,6 @@ proc binaryArith(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
       "($1 <= $2)",           # LeB
       "($1 < $2)",            # LtB
       "($1 == $2)",           # EqRef
-      "($1 == $2)",           # EqProc
       "($1 == $2)",           # EqPtr
       "($1 <= $2)",           # LePtr
       "($1 < $2)",            # LtPtr
@@ -477,6 +476,19 @@ proc binaryArith(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
               ropef(binArithTab[op], [rdLoc(a), rdLoc(b), toRope(s),
                                       getSimpleTypeDesc(p.module, e.typ)]))
 
+proc genEqProc(p: BProc, e: PNode, d: var TLoc) =
+  var a, b: TLoc
+  assert(e.sons[1].typ != nil)
+  assert(e.sons[2].typ != nil)
+  InitLocExpr(p, e.sons[1], a)
+  InitLocExpr(p, e.sons[2], b)
+  if a.t.callConv == ccClosure:
+    putIntoDest(p, d, e.typ, 
+      ropef("($1.ClPrc == $2.ClPrc && $1.ClEnv == $2.ClEnv)", [
+      rdLoc(a), rdLoc(b)]))
+  else:
+    putIntoDest(p, d, e.typ, ropef("($1 == $2)", [rdLoc(a), rdLoc(b)]))
+
 proc unaryArith(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
   const
     unArithTab: array[mNot..mToBiggestInt, string] = ["!($1)", # Not
@@ -1367,6 +1379,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
   of mUnaryMinusI..mAbsI64: unaryArithOverflow(p, e, d, op)
   of mAddF64..mDivF64: binaryFloatArith(p, e, d, op)
   of mShrI..mXor: binaryArith(p, e, d, op)
+  of mEqProc: genEqProc(p, e, d)
   of mAddi..mModi64: binaryArithOverflow(p, e, d, op)
   of mRepr: genRepr(p, e, d)
   of mGetTypeInfo: genGetTypeInfo(p, e, d)