From e662043fd1c43e8447fb7c30e97823f7d0a46a83 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 8 May 2024 23:11:46 +0800 Subject: [PATCH] rework `wasMoved`, `move` on the JS backend (#23577) `reset`, `wasMoved` and `move` doesn't support primitive types, which generate `null` for these types. It is now produce `x = default(...)` in the backend. Ideally it should be done by ast2ir in the future --- compiler/ast.nim | 2 +- compiler/ccgcalls.nim | 2 +- compiler/ccgexprs.nim | 9 --------- compiler/jsgen.nim | 15 ++++++++------- compiler/nir/ast2ir.nim | 2 +- compiler/semexprs.nim | 2 +- compiler/vmgen.nim | 7 ------- lib/system/jssys.nim | 31 ------------------------------- tests/stdlib/tsystem.nim | 34 +++++++++++++++++++++++----------- 9 files changed, 35 insertions(+), 69 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index e8fee6c0d1..4de277ba9a 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -504,7 +504,7 @@ type mSwap, mIsNil, mArrToSeq, mOpenArrayToSeq, mNewString, mNewStringOfCap, mParseBiggestFloat, mMove, mEnsureMove, mWasMoved, mDup, mDestroy, mTrace, - mDefault, mUnown, mFinished, mIsolate, mAccessEnv, mAccessTypeField, mReset, + mDefault, mUnown, mFinished, mIsolate, mAccessEnv, mAccessTypeField, mArray, mOpenArray, mRange, mSet, mSeq, mVarargs, mRef, mPtr, mVar, mDistinct, mVoid, mTuple, mOrdinal, mIterableType, diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 1558005824..516bb6fed1 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -357,7 +357,7 @@ proc getPotentialWrites(n: PNode; mutate: bool; result: var seq[PNode]) = of nkCallKinds: case n.getMagic: of mIncl, mExcl, mInc, mDec, mAppendStrCh, mAppendStrStr, mAppendSeqElem, - mAddr, mNew, mNewFinalize, mWasMoved, mDestroy, mReset: + mAddr, mNew, mNewFinalize, mWasMoved, mDestroy: getPotentialWrites(n[1], true, result) for i in 2..