undo some changes

This commit is contained in:
Andrii Riabushenko 2018-12-07 21:59:43 +00:00
commit 4799589fb3
4 changed files with 16 additions and 3 deletions

View file

@ -627,7 +627,7 @@ type
mIsPartOf, mAstToStr, mParallel, mIsPartOf, mAstToStr, mParallel,
mSwap, mIsNil, mArrToSeq, mCopyStr, mCopyStrLast, mSwap, mIsNil, mArrToSeq, mCopyStr, mCopyStrLast,
mNewString, mNewStringOfCap, mParseBiggestFloat, mNewString, mNewStringOfCap, mParseBiggestFloat,
mMove, mDestroy, mMove, mWasMoved, mDestroy,
mReset, mReset,
mArray, mOpenArray, mRange, mSet, mSeq, mOpt, mVarargs, mArray, mOpenArray, mRange, mSet, mSeq, mOpt, mVarargs,
mRef, mPtr, mVar, mDistinct, mVoid, mTuple, mRef, mPtr, mVar, mDistinct, mVoid, mTuple,

View file

@ -1901,6 +1901,13 @@ proc binaryFloatArith(p: BProc, e: PNode, d: var TLoc, m: TMagic) =
proc skipAddr(n: PNode): PNode = proc skipAddr(n: PNode): PNode =
result = if n.kind in {nkAddr, nkHiddenAddr}: n[0] else: n result = if n.kind in {nkAddr, nkHiddenAddr}: n[0] else: n
proc genWasMoved(p: BProc; n: PNode) =
var a: TLoc
initLocExpr(p, n[1].skipAddr, a)
resetLoc(p, a)
#linefmt(p, cpsStmts, "#nimZeroMem((void*)$1, sizeof($2));$n",
# addrLoc(p.config, a), getTypeDesc(p.module, a.t))
proc genMove(p: BProc; n: PNode; d: var TLoc) = proc genMove(p: BProc; n: PNode; d: var TLoc) =
if d.k == locNone: getTemp(p, n.typ, d) if d.k == locNone: getTemp(p, n.typ, d)
var a: TLoc var a: TLoc

View file

@ -614,7 +614,8 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
const const
FakeVarParams = {mNew, mNewFinalize, mInc, ast.mDec, mIncl, mExcl, FakeVarParams = {mNew, mNewFinalize, mInc, ast.mDec, mIncl, mExcl,
mSetLengthStr, mSetLengthSeq, mAppendStrCh, mAppendStrStr, mSwap, mSetLengthStr, mSetLengthSeq, mAppendStrCh, mAppendStrStr, mSwap,
mAppendSeqElem, mNewSeq, mReset, mShallowCopy, mDeepCopy, mMove} mAppendSeqElem, mNewSeq, mReset, mShallowCopy, mDeepCopy, mMove,
mWasMoved}
# get the real type of the callee # get the real type of the callee
# it may be a proc var with a generic alias type, so we skip over them # it may be a proc var with a generic alias type, so we skip over them

View file

@ -221,10 +221,15 @@ proc reset*[T](obj: var T) {.magic: "Reset", noSideEffect.}
## be called before any possible `object branch transition`:idx:. ## be called before any possible `object branch transition`:idx:.
when defined(nimNewRuntime): when defined(nimNewRuntime):
proc wasMoved*[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
## resets an object `obj` to its initial (binary zero) value to signify
## it was "moved" and to signify its destructor should do nothing and
## ideally be optimized away.
discard
proc move*[T](x: var T): T {.magic: "Move", noSideEffect.} = proc move*[T](x: var T): T {.magic: "Move", noSideEffect.} =
result = x result = x
reset(x) wasMoved(x)
type type
range*{.magic: "Range".}[T] ## Generic type to construct range types. range*{.magic: "Range".}[T] ## Generic type to construct range types.