diff options
author | Hans Raaf <hara@oderwat.de> | 2016-02-07 00:08:10 +0100 |
---|---|---|
committer | Hans Raaf <hara@oderwat.de> | 2016-02-07 00:08:10 +0100 |
commit | 77235947c15f66fd3a933a6832eecabe1991e93a (patch) | |
tree | 5004db9ef8cbcedf0087013936e8ee03a5e9207f /compiler | |
parent | 8ec7c0af2046e66fc4f3d3d8b04c06ddfc2b566d (diff) | |
download | Nim-77235947c15f66fd3a933a6832eecabe1991e93a.tar.gz |
Fix for shr with PHP (using >>)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/jsgen.nim | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 7a927f41e..5da61e382 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -452,11 +452,17 @@ proc arith(p: PProc, n: PNode, r: var TCompRes, op: TMagic) = of mMulU: binaryUintExpr(p, n, r, "*") of mDivU: binaryUintExpr(p, n, r, "/") of mShrI: - var x, y: TCompRes - gen(p, n.sons[1], x) - gen(p, n.sons[2], y) - let trimmer = unsignedTrimmer(n[1].typ.skipTypes(abstractRange).size) - r.res = "(($1 $2) >>> $3)" % [x.rdLoc, trimmer, y.rdLoc] + if p.target == targetPHP: + var x, y: TCompRes + gen(p, n.sons[1], x) + gen(p, n.sons[2], y) + r.res = "$1 >> $2" % [x.rdLoc, y.rdLoc] + else: + var x, y: TCompRes + gen(p, n.sons[1], x) + gen(p, n.sons[2], y) + let trimmer = unsignedTrimmer(n[1].typ.skipTypes(abstractRange).size) + r.res = "(($1 $2) >> $3)" % [x.rdLoc, trimmer, y.rdLoc] of mCharToStr, mBoolToStr, mIntToStr, mInt64ToStr, mFloatToStr, mCStrToStr, mStrToStr, mEnumToStr: if p.target == targetPHP: |