summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-03-06 10:22:47 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-03-06 10:22:47 +0100
commite4e8ebd4a50bc86b0b08df449d5ff72e365a4c6a (patch)
treec1c003fca6fa3a81a42546db449c2ec9d60fbb65
parent83592af8ed06884fccfe9702c36819b727715936 (diff)
parenteda113889c8a3d6d8020debb2a94f874ab1cde07 (diff)
downloadNim-e4e8ebd4a50bc86b0b08df449d5ff72e365a4c6a.tar.gz
Merge pull request #3943 from oderwat/hara-php-div-fix
Fix for integer division in PHP codegen.
-rw-r--r--compiler/jsgen.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 1b835f353..0cd0281af 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -464,6 +464,14 @@ proc arith(p: PProc, n: PNode, r: var TCompRes, op: TMagic) =
   of mSubU: binaryUintExpr(p, n, r, "-")
   of mMulU: binaryUintExpr(p, n, r, "*")
   of mDivU: binaryUintExpr(p, n, r, "/")
+  of mDivI:
+    if p.target == targetPHP:
+      var x, y: TCompRes
+      gen(p, n.sons[1], x)
+      gen(p, n.sons[2], y)
+      r.res = "intval($1 / $2)" % [x.rdLoc, y.rdLoc]
+    else:
+      arithAux(p, n, r, op, jsOps)
   of mShrI:
     var x, y: TCompRes
     gen(p, n.sons[1], x)