Remove dead magics (#13551)
This commit is contained in:
parent
31332bca45
commit
eb42f38088
14 changed files with 44 additions and 140 deletions
|
|
@ -599,12 +599,11 @@ type
|
||||||
mDefined, mDefinedInScope, mCompiles, mArrGet, mArrPut, mAsgn,
|
mDefined, mDefinedInScope, mCompiles, mArrGet, mArrPut, mAsgn,
|
||||||
mLow, mHigh, mSizeOf, mAlignOf, mOffsetOf, mTypeTrait,
|
mLow, mHigh, mSizeOf, mAlignOf, mOffsetOf, mTypeTrait,
|
||||||
mIs, mOf, mAddr, mType, mTypeOf,
|
mIs, mOf, mAddr, mType, mTypeOf,
|
||||||
mRoof, mPlugin, mEcho, mShallowCopy, mSlurp, mStaticExec, mStatic,
|
mPlugin, mEcho, mShallowCopy, mSlurp, mStaticExec, mStatic,
|
||||||
mParseExprToAst, mParseStmtToAst, mExpandToAst, mQuoteAst,
|
mParseExprToAst, mParseStmtToAst, mExpandToAst, mQuoteAst,
|
||||||
mUnaryLt, mInc, mDec, mOrd,
|
mInc, mDec, mOrd,
|
||||||
mNew, mNewFinalize, mNewSeq, mNewSeqOfCap,
|
mNew, mNewFinalize, mNewSeq, mNewSeqOfCap,
|
||||||
mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq,
|
mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq,
|
||||||
mXLenStr, mXLenSeq,
|
|
||||||
mIncl, mExcl, mCard, mChr,
|
mIncl, mExcl, mCard, mChr,
|
||||||
mGCref, mGCunref,
|
mGCref, mGCunref,
|
||||||
mAddI, mSubI, mMulI, mDivI, mModI,
|
mAddI, mSubI, mMulI, mDivI, mModI,
|
||||||
|
|
@ -620,7 +619,7 @@ type
|
||||||
mEqEnum, mLeEnum, mLtEnum,
|
mEqEnum, mLeEnum, mLtEnum,
|
||||||
mEqCh, mLeCh, mLtCh,
|
mEqCh, mLeCh, mLtCh,
|
||||||
mEqB, mLeB, mLtB,
|
mEqB, mLeB, mLtB,
|
||||||
mEqRef, mEqUntracedRef, mLePtr, mLtPtr,
|
mEqRef, mLePtr, mLtPtr,
|
||||||
mXor, mEqCString, mEqProc,
|
mXor, mEqCString, mEqProc,
|
||||||
mUnaryMinusI, mUnaryMinusI64, mAbsI, mNot,
|
mUnaryMinusI, mUnaryMinusI64, mAbsI, mNot,
|
||||||
mUnaryPlusI, mBitnotI,
|
mUnaryPlusI, mBitnotI,
|
||||||
|
|
@ -629,18 +628,18 @@ type
|
||||||
mStrToStr, mEnumToStr,
|
mStrToStr, mEnumToStr,
|
||||||
mAnd, mOr,
|
mAnd, mOr,
|
||||||
mEqStr, mLeStr, mLtStr,
|
mEqStr, mLeStr, mLtStr,
|
||||||
mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet, mSymDiffSet,
|
mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet,
|
||||||
mConStrStr, mSlice,
|
mConStrStr, mSlice,
|
||||||
mDotDot, # this one is only necessary to give nice compile time warnings
|
mDotDot, # this one is only necessary to give nice compile time warnings
|
||||||
mFields, mFieldPairs, mOmpParFor,
|
mFields, mFieldPairs, mOmpParFor,
|
||||||
mAppendStrCh, mAppendStrStr, mAppendSeqElem,
|
mAppendStrCh, mAppendStrStr, mAppendSeqElem,
|
||||||
mInRange, mInSet, mRepr, mExit,
|
mInSet, mRepr, mExit,
|
||||||
mSetLengthStr, mSetLengthSeq,
|
mSetLengthStr, mSetLengthSeq,
|
||||||
mIsPartOf, mAstToStr, mParallel,
|
mIsPartOf, mAstToStr, mParallel,
|
||||||
mSwap, mIsNil, mArrToSeq, mCopyStr, mCopyStrLast,
|
mSwap, mIsNil, mArrToSeq,
|
||||||
mNewString, mNewStringOfCap, mParseBiggestFloat,
|
mNewString, mNewStringOfCap, mParseBiggestFloat,
|
||||||
mMove, mWasMoved, mDestroy,
|
mMove, mWasMoved, mDestroy,
|
||||||
mDefault, mUnown, mAccessEnv, mAccessTypeInfo, mReset,
|
mDefault, mUnown, mAccessEnv, 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,
|
||||||
mOrdinal,
|
mOrdinal,
|
||||||
|
|
@ -648,8 +647,8 @@ type
|
||||||
mUInt, mUInt8, mUInt16, mUInt32, mUInt64,
|
mUInt, mUInt8, mUInt16, mUInt32, mUInt64,
|
||||||
mFloat, mFloat32, mFloat64, mFloat128,
|
mFloat, mFloat32, mFloat64, mFloat128,
|
||||||
mBool, mChar, mString, mCstring,
|
mBool, mChar, mString, mCstring,
|
||||||
mPointer, mEmptySet, mIntSetBaseType, mNil, mExpr, mStmt, mTypeDesc,
|
mPointer, mNil, mExpr, mStmt, mTypeDesc,
|
||||||
mVoidType, mPNimrodNode, mShared, mGuarded, mLock, mSpawn, mDeepCopy,
|
mVoidType, mPNimrodNode, mSpawn, mDeepCopy,
|
||||||
mIsMainModule, mCompileDate, mCompileTime, mProcCall,
|
mIsMainModule, mCompileDate, mCompileTime, mProcCall,
|
||||||
mCpuEndian, mHostOS, mHostCPU, mBuildOS, mBuildCPU, mAppType,
|
mCpuEndian, mHostOS, mHostCPU, mBuildOS, mBuildCPU, mAppType,
|
||||||
mCompileOption, mCompileOptionArg,
|
mCompileOption, mCompileOptionArg,
|
||||||
|
|
@ -662,7 +661,7 @@ type
|
||||||
mNIntVal, mNFloatVal, mNSymbol, mNIdent, mNGetType, mNStrVal, mNSetIntVal,
|
mNIntVal, mNFloatVal, mNSymbol, mNIdent, mNGetType, mNStrVal, mNSetIntVal,
|
||||||
mNSetFloatVal, mNSetSymbol, mNSetIdent, mNSetType, mNSetStrVal, mNLineInfo,
|
mNSetFloatVal, mNSetSymbol, mNSetIdent, mNSetType, mNSetStrVal, mNLineInfo,
|
||||||
mNNewNimNode, mNCopyNimNode, mNCopyNimTree, mStrToIdent, mNSigHash, mNSizeOf,
|
mNNewNimNode, mNCopyNimNode, mNCopyNimTree, mStrToIdent, mNSigHash, mNSizeOf,
|
||||||
mNBindSym, mLocals, mNCallSite,
|
mNBindSym, mNCallSite,
|
||||||
mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl, mNGenSym,
|
mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl, mNGenSym,
|
||||||
mNHint, mNWarning, mNError,
|
mNHint, mNWarning, mNError,
|
||||||
mInstantiationInfo, mGetTypeInfo,
|
mInstantiationInfo, mGetTypeInfo,
|
||||||
|
|
@ -673,9 +672,9 @@ type
|
||||||
|
|
||||||
# things that we can evaluate safely at compile time, even if not asked for it:
|
# things that we can evaluate safely at compile time, even if not asked for it:
|
||||||
const
|
const
|
||||||
ctfeWhitelist* = {mNone, mUnaryLt, mSucc,
|
ctfeWhitelist* = {mNone, mSucc,
|
||||||
mPred, mInc, mDec, mOrd, mLengthOpenArray,
|
mPred, mInc, mDec, mOrd, mLengthOpenArray,
|
||||||
mLengthStr, mLengthArray, mLengthSeq, mXLenStr, mXLenSeq,
|
mLengthStr, mLengthArray, mLengthSeq,
|
||||||
mArrGet, mArrPut, mAsgn, mDestroy,
|
mArrGet, mArrPut, mAsgn, mDestroy,
|
||||||
mIncl, mExcl, mCard, mChr,
|
mIncl, mExcl, mCard, mChr,
|
||||||
mAddI, mSubI, mMulI, mDivI, mModI,
|
mAddI, mSubI, mMulI, mDivI, mModI,
|
||||||
|
|
@ -690,17 +689,16 @@ const
|
||||||
mEqEnum, mLeEnum, mLtEnum,
|
mEqEnum, mLeEnum, mLtEnum,
|
||||||
mEqCh, mLeCh, mLtCh,
|
mEqCh, mLeCh, mLtCh,
|
||||||
mEqB, mLeB, mLtB,
|
mEqB, mLeB, mLtB,
|
||||||
mEqRef, mEqProc, mEqUntracedRef, mLePtr, mLtPtr, mEqCString, mXor,
|
mEqRef, mEqProc, mLePtr, mLtPtr, mEqCString, mXor,
|
||||||
mUnaryMinusI, mUnaryMinusI64, mAbsI, mNot, mUnaryPlusI, mBitnotI,
|
mUnaryMinusI, mUnaryMinusI64, mAbsI, mNot, mUnaryPlusI, mBitnotI,
|
||||||
mUnaryPlusF64, mUnaryMinusF64,
|
mUnaryPlusF64, mUnaryMinusF64,
|
||||||
mCharToStr, mBoolToStr, mIntToStr, mInt64ToStr, mFloatToStr, mCStrToStr,
|
mCharToStr, mBoolToStr, mIntToStr, mInt64ToStr, mFloatToStr, mCStrToStr,
|
||||||
mStrToStr, mEnumToStr,
|
mStrToStr, mEnumToStr,
|
||||||
mAnd, mOr,
|
mAnd, mOr,
|
||||||
mEqStr, mLeStr, mLtStr,
|
mEqStr, mLeStr, mLtStr,
|
||||||
mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet, mSymDiffSet,
|
mEqSet, mLeSet, mLtSet, mMulSet, mPlusSet, mMinusSet,
|
||||||
mConStrStr, mAppendStrCh, mAppendStrStr, mAppendSeqElem,
|
mConStrStr, mAppendStrCh, mAppendStrStr, mAppendSeqElem,
|
||||||
mInRange, mInSet, mRepr,
|
mInSet, mRepr}
|
||||||
mCopyStr, mCopyStrLast}
|
|
||||||
|
|
||||||
type
|
type
|
||||||
PNode* = ref TNode
|
PNode* = ref TNode
|
||||||
|
|
|
||||||
|
|
@ -617,7 +617,6 @@ proc binaryArith(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mLeB: applyFormat("($1 <= $2)")
|
of mLeB: applyFormat("($1 <= $2)")
|
||||||
of mLtB: applyFormat("($1 < $2)")
|
of mLtB: applyFormat("($1 < $2)")
|
||||||
of mEqRef: applyFormat("($1 == $2)")
|
of mEqRef: applyFormat("($1 == $2)")
|
||||||
of mEqUntracedRef: applyFormat("($1 == $2)")
|
|
||||||
of mLePtr: applyFormat("($1 <= $2)")
|
of mLePtr: applyFormat("($1 <= $2)")
|
||||||
of mLtPtr: applyFormat("($1 < $2)")
|
of mLtPtr: applyFormat("($1 < $2)")
|
||||||
of mXor: applyFormat("($1 != $2)")
|
of mXor: applyFormat("($1 != $2)")
|
||||||
|
|
@ -1797,7 +1796,7 @@ proc genInOp(p: BProc, e: PNode, d: var TLoc) =
|
||||||
|
|
||||||
proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
const
|
const
|
||||||
lookupOpr: array[mLeSet..mSymDiffSet, string] = [
|
lookupOpr: array[mLeSet..mMinusSet, string] = [
|
||||||
"for ($1 = 0; $1 < $2; $1++) { $n" &
|
"for ($1 = 0; $1 < $2; $1++) { $n" &
|
||||||
" $3 = (($4[$1] & ~ $5[$1]) == 0);$n" &
|
" $3 = (($4[$1] & ~ $5[$1]) == 0);$n" &
|
||||||
" if (!$3) break;}$n",
|
" if (!$3) break;}$n",
|
||||||
|
|
@ -1807,8 +1806,7 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
"if ($3) $3 = (#nimCmpMem($4, $5, $2) != 0);$n",
|
"if ($3) $3 = (#nimCmpMem($4, $5, $2) != 0);$n",
|
||||||
"&",
|
"&",
|
||||||
"|",
|
"|",
|
||||||
"& ~",
|
"& ~"]
|
||||||
"^"]
|
|
||||||
var a, b, i: TLoc
|
var a, b, i: TLoc
|
||||||
var setType = skipTypes(e[1].typ, abstractVar)
|
var setType = skipTypes(e[1].typ, abstractVar)
|
||||||
var size = int(getSize(p.config, setType))
|
var size = int(getSize(p.config, setType))
|
||||||
|
|
@ -1838,7 +1836,6 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mMulSet: binaryExpr(p, e, d, "($1 & $2)")
|
of mMulSet: binaryExpr(p, e, d, "($1 & $2)")
|
||||||
of mPlusSet: binaryExpr(p, e, d, "($1 | $2)")
|
of mPlusSet: binaryExpr(p, e, d, "($1 | $2)")
|
||||||
of mMinusSet: binaryExpr(p, e, d, "($1 & ~ $2)")
|
of mMinusSet: binaryExpr(p, e, d, "($1 & ~ $2)")
|
||||||
of mSymDiffSet: binaryExpr(p, e, d, "($1 ^ $2)")
|
|
||||||
of mInSet:
|
of mInSet:
|
||||||
genInOp(p, e, d)
|
genInOp(p, e, d)
|
||||||
else: internalError(p.config, e.info, "genSetOp()")
|
else: internalError(p.config, e.info, "genSetOp()")
|
||||||
|
|
@ -1868,7 +1865,7 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
initLocExpr(p, e[1], a)
|
initLocExpr(p, e[1], a)
|
||||||
initLocExpr(p, e[2], b)
|
initLocExpr(p, e[2], b)
|
||||||
putIntoDest(p, d, e, ropecg(p.module, "(#nimCmpMem($1, $2, $3)==0)", [a.rdCharLoc, b.rdCharLoc, size]))
|
putIntoDest(p, d, e, ropecg(p.module, "(#nimCmpMem($1, $2, $3)==0)", [a.rdCharLoc, b.rdCharLoc, size]))
|
||||||
of mMulSet, mPlusSet, mMinusSet, mSymDiffSet:
|
of mMulSet, mPlusSet, mMinusSet:
|
||||||
# we inline the simple for loop for better code generation:
|
# we inline the simple for loop for better code generation:
|
||||||
getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyInt), i) # our counter
|
getTemp(p, getSysType(p.module.g.graph, unknownLineInfo, tyInt), i) # our counter
|
||||||
initLocExpr(p, e[1], a)
|
initLocExpr(p, e[1], a)
|
||||||
|
|
@ -2118,9 +2115,6 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mRepr: genRepr(p, e, d)
|
of mRepr: genRepr(p, e, d)
|
||||||
of mGetTypeInfo: genGetTypeInfo(p, e, d)
|
of mGetTypeInfo: genGetTypeInfo(p, e, d)
|
||||||
of mSwap: genSwap(p, e, d)
|
of mSwap: genSwap(p, e, d)
|
||||||
of mUnaryLt:
|
|
||||||
if optOverflowCheck notin p.options: unaryExpr(p, e, d, "($1 - 1)")
|
|
||||||
else: unaryExpr(p, e, d, "#subInt($1, 1)")
|
|
||||||
of mInc, mDec:
|
of mInc, mDec:
|
||||||
const opr: array[mInc..mDec, string] = ["+=", "-="]
|
const opr: array[mInc..mDec, string] = ["+=", "-="]
|
||||||
const fun64: array[mInc..mDec, string] = ["addInt64",
|
const fun64: array[mInc..mDec, string] = ["addInt64",
|
||||||
|
|
@ -2218,21 +2212,6 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mOrd: genOrd(p, e, d)
|
of mOrd: genOrd(p, e, d)
|
||||||
of mLengthArray, mHigh, mLengthStr, mLengthSeq, mLengthOpenArray:
|
of mLengthArray, mHigh, mLengthStr, mLengthSeq, mLengthOpenArray:
|
||||||
genArrayLen(p, e, d, op)
|
genArrayLen(p, e, d, op)
|
||||||
of mXLenStr:
|
|
||||||
if not p.module.compileToCpp:
|
|
||||||
unaryExpr(p, e, d, "($1->Sup.len)")
|
|
||||||
else:
|
|
||||||
unaryExpr(p, e, d, "$1->len")
|
|
||||||
of mXLenSeq:
|
|
||||||
# see 'taddhigh.nim' for why we need to use a temporary here:
|
|
||||||
var a, tmp: TLoc
|
|
||||||
initLocExpr(p, e[1], a)
|
|
||||||
getIntTemp(p, tmp)
|
|
||||||
if not p.module.compileToCpp:
|
|
||||||
lineCg(p, cpsStmts, "$1 = $2->Sup.len;$n", [tmp.r, rdLoc(a)])
|
|
||||||
else:
|
|
||||||
lineCg(p, cpsStmts, "$1 = $2->len;$n", [tmp.r, rdLoc(a)])
|
|
||||||
putIntoDest(p, d, e, tmp.r)
|
|
||||||
of mGCref: unaryStmt(p, e, d, "if ($1) { #nimGCref($1); }$n")
|
of mGCref: unaryStmt(p, e, d, "if ($1) { #nimGCref($1); }$n")
|
||||||
of mGCunref: unaryStmt(p, e, d, "if ($1) { #nimGCunref($1); }$n")
|
of mGCunref: unaryStmt(p, e, d, "if ($1) { #nimGCunref($1); }$n")
|
||||||
of mSetLengthStr: genSetLengthStr(p, e, d)
|
of mSetLengthStr: genSetLengthStr(p, e, d)
|
||||||
|
|
@ -2240,8 +2219,6 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mIncl, mExcl, mCard, mLtSet, mLeSet, mEqSet, mMulSet, mPlusSet, mMinusSet,
|
of mIncl, mExcl, mCard, mLtSet, mLeSet, mEqSet, mMulSet, mPlusSet, mMinusSet,
|
||||||
mInSet:
|
mInSet:
|
||||||
genSetOp(p, e, d, op)
|
genSetOp(p, e, d, op)
|
||||||
of mCopyStr, mCopyStrLast:
|
|
||||||
genCall(p, e, d)
|
|
||||||
of mNewString, mNewStringOfCap, mExit, mParseBiggestFloat:
|
of mNewString, mNewStringOfCap, mExit, mParseBiggestFloat:
|
||||||
var opr = e[0].sym
|
var opr = e[0].sym
|
||||||
# Why would anyone want to set nodecl to one of these hardcoded magics?
|
# Why would anyone want to set nodecl to one of these hardcoded magics?
|
||||||
|
|
@ -2296,11 +2273,6 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mMove: genMove(p, e, d)
|
of mMove: genMove(p, e, d)
|
||||||
of mDestroy: genDestroy(p, e)
|
of mDestroy: genDestroy(p, e)
|
||||||
of mAccessEnv: unaryExpr(p, e, d, "$1.ClE_0")
|
of mAccessEnv: unaryExpr(p, e, d, "$1.ClE_0")
|
||||||
of mAccessTypeInfo:
|
|
||||||
var a: TLoc
|
|
||||||
var dummy: Rope
|
|
||||||
initLocExpr(p, e[1], a)
|
|
||||||
putIntoDest(p, d, e, rdMType(p, a, dummy))
|
|
||||||
of mSlice:
|
of mSlice:
|
||||||
localError(p.config, e.info, "invalid context for 'toOpenArray'; " &
|
localError(p.config, e.info, "invalid context for 'toOpenArray'; " &
|
||||||
"'toOpenArray' is only valid within a call expression")
|
"'toOpenArray' is only valid within a call expression")
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import ast, astalgo
|
||||||
|
|
||||||
const
|
const
|
||||||
someCmp = {mEqI, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc,
|
someCmp = {mEqI, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc,
|
||||||
mEqUntracedRef, mLeI, mLeF64, mLeU, mLeU64, mLeEnum,
|
mLeI, mLeF64, mLeU, mLeU64, mLeEnum,
|
||||||
mLeCh, mLeB, mLePtr, mLtI, mLtF64, mLtU, mLtU64, mLtEnum,
|
mLeCh, mLeB, mLePtr, mLtI, mLtF64, mLtU, mLtU64, mLtEnum,
|
||||||
mLtCh, mLtB, mLtPtr}
|
mLtCh, mLtB, mLtPtr}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import ast, astalgo, msgs, magicsys, nimsets, trees, types, renderer, idents,
|
||||||
|
|
||||||
const
|
const
|
||||||
someEq = {mEqI, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc,
|
someEq = {mEqI, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc,
|
||||||
mEqUntracedRef, mEqStr, mEqSet, mEqCString}
|
mEqStr, mEqSet, mEqCString}
|
||||||
|
|
||||||
# set excluded here as the semantics are vastly different:
|
# set excluded here as the semantics are vastly different:
|
||||||
someLe = {mLeI, mLeF64, mLeU, mLeU64, mLeEnum,
|
someLe = {mLeI, mLeF64, mLeU, mLeU64, mLeEnum,
|
||||||
|
|
@ -22,10 +22,9 @@ const
|
||||||
someLt = {mLtI, mLtF64, mLtU, mLtU64, mLtEnum,
|
someLt = {mLtI, mLtF64, mLtU, mLtU64, mLtEnum,
|
||||||
mLtCh, mLtB, mLtPtr, mLtStr}
|
mLtCh, mLtB, mLtPtr, mLtStr}
|
||||||
|
|
||||||
someLen = {mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq,
|
someLen = {mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq}
|
||||||
mXLenStr, mXLenSeq}
|
|
||||||
|
|
||||||
someIn = {mInRange, mInSet}
|
someIn = {mInSet}
|
||||||
|
|
||||||
someHigh = {mHigh}
|
someHigh = {mHigh}
|
||||||
# we don't list unsigned here because wrap around semantics suck for
|
# we don't list unsigned here because wrap around semantics suck for
|
||||||
|
|
@ -258,7 +257,7 @@ proc canon*(n: PNode; o: Operators): PNode =
|
||||||
result[i] = canon(n[i], o)
|
result[i] = canon(n[i], o)
|
||||||
elif n.kind == nkSym and n.sym.kind == skLet and
|
elif n.kind == nkSym and n.sym.kind == skLet and
|
||||||
n.sym.astdef.getMagic in (someEq + someAdd + someMul + someMin +
|
n.sym.astdef.getMagic in (someEq + someAdd + someMul + someMin +
|
||||||
someMax + someHigh + {mUnaryLt} + someSub + someLen + someDiv):
|
someMax + someHigh + someSub + someLen + someDiv):
|
||||||
result = n.sym.astdef.copyTree
|
result = n.sym.astdef.copyTree
|
||||||
else:
|
else:
|
||||||
result = n
|
result = n
|
||||||
|
|
@ -271,8 +270,6 @@ proc canon*(n: PNode; o: Operators): PNode =
|
||||||
of someHigh:
|
of someHigh:
|
||||||
# high == len+(-1)
|
# high == len+(-1)
|
||||||
result = o.opAdd.buildCall(o.opLen.buildCall(result[1]), minusOne())
|
result = o.opAdd.buildCall(o.opLen.buildCall(result[1]), minusOne())
|
||||||
of mUnaryLt:
|
|
||||||
result = buildCall(o.opAdd, result[1], minusOne())
|
|
||||||
of someSub:
|
of someSub:
|
||||||
# x - 4 --> x + (-4)
|
# x - 4 --> x + (-4)
|
||||||
result = negate(result[1], result[2], result, o)
|
result = negate(result[1], result[2], result, o)
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ type
|
||||||
|
|
||||||
const # magic checked op; magic unchecked op;
|
const # magic checked op; magic unchecked op;
|
||||||
jsMagics: TMagicOps = [
|
jsMagics: TMagicOps = [
|
||||||
["addInt", ""], # AddI
|
mAddI: ["addInt", ""],
|
||||||
["subInt", ""], # SubI
|
["subInt", ""], # SubI
|
||||||
["mulInt", ""], # MulI
|
["mulInt", ""], # MulI
|
||||||
["divInt", ""], # DivI
|
["divInt", ""], # DivI
|
||||||
|
|
@ -414,7 +414,6 @@ const # magic checked op; magic unchecked op;
|
||||||
["", ""], # LeB
|
["", ""], # LeB
|
||||||
["", ""], # LtB
|
["", ""], # LtB
|
||||||
["", ""], # EqRef
|
["", ""], # EqRef
|
||||||
["", ""], # EqUntracedRef
|
|
||||||
["", ""], # LePtr
|
["", ""], # LePtr
|
||||||
["", ""], # LtPtr
|
["", ""], # LtPtr
|
||||||
["", ""], # Xor
|
["", ""], # Xor
|
||||||
|
|
@ -588,7 +587,6 @@ proc arithAux(p: PProc, n: PNode, r: var TCompRes, op: TMagic) =
|
||||||
of mLeB: applyFormat("($1 <= $2)", "($1 <= $2)")
|
of mLeB: applyFormat("($1 <= $2)", "($1 <= $2)")
|
||||||
of mLtB: applyFormat("($1 < $2)", "($1 < $2)")
|
of mLtB: applyFormat("($1 < $2)", "($1 < $2)")
|
||||||
of mEqRef: applyFormat("($1 == $2)", "($1 == $2)")
|
of mEqRef: applyFormat("($1 == $2)", "($1 == $2)")
|
||||||
of mEqUntracedRef: applyFormat("($1 == $2)", "($1 == $2)")
|
|
||||||
of mLePtr: applyFormat("($1 <= $2)", "($1 <= $2)")
|
of mLePtr: applyFormat("($1 <= $2)", "($1 <= $2)")
|
||||||
of mLtPtr: applyFormat("($1 < $2)", "($1 < $2)")
|
of mLtPtr: applyFormat("($1 < $2)", "($1 < $2)")
|
||||||
of mXor: applyFormat("($1 != $2)", "($1 != $2)")
|
of mXor: applyFormat("($1 != $2)", "($1 != $2)")
|
||||||
|
|
@ -631,7 +629,7 @@ proc arith(p: PProc, n: PNode, r: var TCompRes, op: TMagic) =
|
||||||
of mCharToStr, mBoolToStr, mIntToStr, mInt64ToStr, mFloatToStr,
|
of mCharToStr, mBoolToStr, mIntToStr, mInt64ToStr, mFloatToStr,
|
||||||
mCStrToStr, mStrToStr, mEnumToStr:
|
mCStrToStr, mStrToStr, mEnumToStr:
|
||||||
arithAux(p, n, r, op)
|
arithAux(p, n, r, op)
|
||||||
of mEqRef, mEqUntracedRef:
|
of mEqRef:
|
||||||
if mapType(n[1].typ) != etyBaseIndex:
|
if mapType(n[1].typ) != etyBaseIndex:
|
||||||
arithAux(p, n, r, op)
|
arithAux(p, n, r, op)
|
||||||
else:
|
else:
|
||||||
|
|
@ -1890,10 +1888,6 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
of mAddI..mStrToStr: arith(p, n, r, op)
|
of mAddI..mStrToStr: arith(p, n, r, op)
|
||||||
of mRepr: genRepr(p, n, r)
|
of mRepr: genRepr(p, n, r)
|
||||||
of mSwap: genSwap(p, n)
|
of mSwap: genSwap(p, n)
|
||||||
of mUnaryLt:
|
|
||||||
# XXX: range checking?
|
|
||||||
if not (optOverflowCheck in p.options): unaryExpr(p, n, r, "", "$1 - 1")
|
|
||||||
else: unaryExpr(p, n, r, "subInt", "subInt($1, 1)")
|
|
||||||
of mAppendStrCh:
|
of mAppendStrCh:
|
||||||
binaryExpr(p, n, r, "addChar",
|
binaryExpr(p, n, r, "addChar",
|
||||||
"if ($1 != null) { addChar($3, $2); } else { $3 = [$2]; }")
|
"if ($1 != null) { addChar($3, $2); } else { $3 = [$2]; }")
|
||||||
|
|
@ -1959,8 +1953,6 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
of mOrd: genOrd(p, n, r)
|
of mOrd: genOrd(p, n, r)
|
||||||
of mLengthStr, mLengthSeq, mLengthOpenArray, mLengthArray:
|
of mLengthStr, mLengthSeq, mLengthOpenArray, mLengthArray:
|
||||||
unaryExpr(p, n, r, "", "($1 != null ? $2.length : 0)")
|
unaryExpr(p, n, r, "", "($1 != null ? $2.length : 0)")
|
||||||
of mXLenStr, mXLenSeq:
|
|
||||||
unaryExpr(p, n, r, "", "$1.length")
|
|
||||||
of mHigh:
|
of mHigh:
|
||||||
unaryExpr(p, n, r, "", "($1 != null ? ($2.length-1) : -1)")
|
unaryExpr(p, n, r, "", "($1 != null ? ($2.length-1) : -1)")
|
||||||
of mInc:
|
of mInc:
|
||||||
|
|
@ -2007,8 +1999,6 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
of mEcho: genEcho(p, n, r)
|
of mEcho: genEcho(p, n, r)
|
||||||
of mNLen..mNError, mSlurp, mStaticExec:
|
of mNLen..mNError, mSlurp, mStaticExec:
|
||||||
localError(p.config, n.info, errXMustBeCompileTime % n[0].sym.name.s)
|
localError(p.config, n.info, errXMustBeCompileTime % n[0].sym.name.s)
|
||||||
of mCopyStr:
|
|
||||||
binaryExpr(p, n, r, "", "($1.slice($2))")
|
|
||||||
of mNewString: unaryExpr(p, n, r, "mnewString", "mnewString($1)")
|
of mNewString: unaryExpr(p, n, r, "mnewString", "mnewString($1)")
|
||||||
of mNewStringOfCap:
|
of mNewStringOfCap:
|
||||||
unaryExpr(p, n, r, "mnewString", "mnewString(0)")
|
unaryExpr(p, n, r, "mnewString", "mnewString(0)")
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
|
||||||
else:
|
else:
|
||||||
result = newIntNodeT(bitnot(getInt(a)), n, g)
|
result = newIntNodeT(bitnot(getInt(a)), n, g)
|
||||||
of mLengthArray: result = newIntNodeT(lengthOrd(g.config, a.typ), n, g)
|
of mLengthArray: result = newIntNodeT(lengthOrd(g.config, a.typ), n, g)
|
||||||
of mLengthSeq, mLengthOpenArray, mXLenSeq, mLengthStr, mXLenStr:
|
of mLengthSeq, mLengthOpenArray, mLengthStr:
|
||||||
if a.kind == nkNilLit:
|
if a.kind == nkNilLit:
|
||||||
result = newIntNodeT(Zero, n, g)
|
result = newIntNodeT(Zero, n, g)
|
||||||
elif a.kind in {nkStrLit..nkTripleStrLit}:
|
elif a.kind in {nkStrLit..nkTripleStrLit}:
|
||||||
|
|
@ -198,7 +198,6 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
|
||||||
of mUnaryPlusI, mUnaryPlusF64: result = a # throw `+` away
|
of mUnaryPlusI, mUnaryPlusF64: result = a # throw `+` away
|
||||||
# XXX: Hides overflow/underflow
|
# XXX: Hides overflow/underflow
|
||||||
of mAbsI: result = foldAbs(getInt(a), n, g)
|
of mAbsI: result = foldAbs(getInt(a), n, g)
|
||||||
of mUnaryLt: result = foldSub(getOrdValue(a), One, n, g)
|
|
||||||
of mSucc: result = foldAdd(getOrdValue(a), getInt(b), n, g)
|
of mSucc: result = foldAdd(getOrdValue(a), getInt(b), n, g)
|
||||||
of mPred: result = foldSub(getOrdValue(a), getInt(b), n, g)
|
of mPred: result = foldSub(getOrdValue(a), getInt(b), n, g)
|
||||||
of mAddI: result = foldAdd(getInt(a), getInt(b), n, g)
|
of mAddI: result = foldAdd(getInt(a), getInt(b), n, g)
|
||||||
|
|
@ -330,9 +329,6 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
|
||||||
of mMinusSet:
|
of mMinusSet:
|
||||||
result = nimsets.diffSets(g.config, a, b)
|
result = nimsets.diffSets(g.config, a, b)
|
||||||
result.info = n.info
|
result.info = n.info
|
||||||
of mSymDiffSet:
|
|
||||||
result = nimsets.symdiffSets(g.config, a, b)
|
|
||||||
result.info = n.info
|
|
||||||
of mConStrStr: result = newStrNodeT(getStrOrChar(a) & getStrOrChar(b), n, g)
|
of mConStrStr: result = newStrNodeT(getStrOrChar(a) & getStrOrChar(b), n, g)
|
||||||
of mInSet: result = newIntNodeT(toInt128(ord(inSet(a, b))), n, g)
|
of mInSet: result = newIntNodeT(toInt128(ord(inSet(a, b))), n, g)
|
||||||
of mRepr:
|
of mRepr:
|
||||||
|
|
@ -342,10 +338,6 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
|
||||||
of mBoolToStr:
|
of mBoolToStr:
|
||||||
if getOrdValue(a) == 0: result = newStrNodeT("false", n, g)
|
if getOrdValue(a) == 0: result = newStrNodeT("false", n, g)
|
||||||
else: result = newStrNodeT("true", n, g)
|
else: result = newStrNodeT("true", n, g)
|
||||||
of mCopyStr: result = newStrNodeT(substr(getStr(a), int(toInt64(getOrdValue(b)))), n, g)
|
|
||||||
of mCopyStrLast:
|
|
||||||
result = newStrNodeT(substr(getStr(a), toInt(getOrdValue(b)),
|
|
||||||
toInt(getOrdValue(c))), n, g)
|
|
||||||
of mFloatToStr: result = newStrNodeT($getFloat(a), n, g)
|
of mFloatToStr: result = newStrNodeT($getFloat(a), n, g)
|
||||||
of mCStrToStr, mCharToStr:
|
of mCStrToStr, mCharToStr:
|
||||||
if a.kind == nkBracket:
|
if a.kind == nkBracket:
|
||||||
|
|
|
||||||
|
|
@ -479,8 +479,6 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
||||||
result.typ = n[1].typ
|
result.typ = n[1].typ
|
||||||
of mDotDot:
|
of mDotDot:
|
||||||
result = n
|
result = n
|
||||||
of mRoof:
|
|
||||||
localError(c.config, n.info, "builtin roof operator is not supported anymore")
|
|
||||||
of mPlugin:
|
of mPlugin:
|
||||||
let plugin = getPlugin(c.cache, n[0].sym)
|
let plugin = getPlugin(c.cache, n[0].sym)
|
||||||
if plugin.isNil:
|
if plugin.isNil:
|
||||||
|
|
|
||||||
|
|
@ -1898,10 +1898,6 @@ proc processMagicType(c: PContext, m: PSym) =
|
||||||
setMagicIntegral(c.config, m, tyCString, c.config.target.ptrSize)
|
setMagicIntegral(c.config, m, tyCString, c.config.target.ptrSize)
|
||||||
rawAddSon(m.typ, getSysType(c.graph, m.info, tyChar))
|
rawAddSon(m.typ, getSysType(c.graph, m.info, tyChar))
|
||||||
of mPointer: setMagicIntegral(c.config, m, tyPointer, c.config.target.ptrSize)
|
of mPointer: setMagicIntegral(c.config, m, tyPointer, c.config.target.ptrSize)
|
||||||
of mEmptySet:
|
|
||||||
setMagicIntegral(c.config, m, tySet, 1)
|
|
||||||
rawAddSon(m.typ, newTypeS(tyEmpty, c))
|
|
||||||
of mIntSetBaseType: setMagicIntegral(c.config, m, tyRange, c.config.target.intSize)
|
|
||||||
of mNil: setMagicType(c.config, m, tyNil, c.config.target.ptrSize)
|
of mNil: setMagicType(c.config, m, tyNil, c.config.target.ptrSize)
|
||||||
of mExpr:
|
of mExpr:
|
||||||
if m.name.s == "auto":
|
if m.name.s == "auto":
|
||||||
|
|
@ -1937,8 +1933,6 @@ proc processMagicType(c: PContext, m: PSym) =
|
||||||
incl m.typ.flags, tfHasAsgn
|
incl m.typ.flags, tfHasAsgn
|
||||||
assert c.graph.sysTypes[tySequence] == nil
|
assert c.graph.sysTypes[tySequence] == nil
|
||||||
c.graph.sysTypes[tySequence] = m.typ
|
c.graph.sysTypes[tySequence] = m.typ
|
||||||
of mOpt:
|
|
||||||
setMagicType(c.config, m, tyOpt, szUncomputedSize)
|
|
||||||
of mOrdinal:
|
of mOrdinal:
|
||||||
setMagicIntegral(c.config, m, tyOrdinal, szUncomputedSize)
|
setMagicIntegral(c.config, m, tyOrdinal, szUncomputedSize)
|
||||||
rawAddSon(m.typ, newTypeS(tyNone, c))
|
rawAddSon(m.typ, newTypeS(tyNone, c))
|
||||||
|
|
|
||||||
|
|
@ -832,9 +832,6 @@ proc inferStaticParam*(c: var TCandidate, lhs: PNode, rhs: BiggestInt): bool =
|
||||||
#
|
#
|
||||||
if lhs.kind in nkCallKinds and lhs[0].kind == nkSym:
|
if lhs.kind in nkCallKinds and lhs[0].kind == nkSym:
|
||||||
case lhs[0].sym.magic
|
case lhs[0].sym.magic
|
||||||
of mUnaryLt:
|
|
||||||
return inferStaticParam(c, lhs[1], rhs + 1)
|
|
||||||
|
|
||||||
of mAddI, mAddU, mInc, mSucc:
|
of mAddI, mAddU, mInc, mSucc:
|
||||||
if lhs[1].kind == nkIntLit:
|
if lhs[1].kind == nkIntLit:
|
||||||
return inferStaticParam(c, lhs[2], rhs - lhs[1].intVal)
|
return inferStaticParam(c, lhs[2], rhs - lhs[1].intVal)
|
||||||
|
|
|
||||||
|
|
@ -1089,11 +1089,6 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
createSet(regs[ra])
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
nimsets.diffSets(c.config, regs[rb].node, regs[rc].node).sons)
|
nimsets.diffSets(c.config, regs[rb].node, regs[rc].node).sons)
|
||||||
of opcSymdiffSet:
|
|
||||||
decodeBC(rkNode)
|
|
||||||
createSet(regs[ra])
|
|
||||||
move(regs[ra].node.sons,
|
|
||||||
nimsets.symdiffSets(c.config, regs[rb].node, regs[rc].node).sons)
|
|
||||||
of opcConcatStr:
|
of opcConcatStr:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
createStr regs[ra]
|
createStr regs[ra]
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ type
|
||||||
opcEqRef, opcEqNimNode, opcSameNodeType,
|
opcEqRef, opcEqNimNode, opcSameNodeType,
|
||||||
opcXor, opcNot, opcUnaryMinusInt, opcUnaryMinusFloat, opcBitnotInt,
|
opcXor, opcNot, opcUnaryMinusInt, opcUnaryMinusFloat, opcBitnotInt,
|
||||||
opcEqStr, opcLeStr, opcLtStr, opcEqSet, opcLeSet, opcLtSet,
|
opcEqStr, opcLeStr, opcLtStr, opcEqSet, opcLeSet, opcLtSet,
|
||||||
opcMulSet, opcPlusSet, opcMinusSet, opcSymdiffSet, opcConcatStr,
|
opcMulSet, opcPlusSet, opcMinusSet, opcConcatStr,
|
||||||
opcContainsSet, opcRepr, opcSetLenStr, opcSetLenSeq,
|
opcContainsSet, opcRepr, opcSetLenStr, opcSetLenSeq,
|
||||||
opcIsNil, opcOf, opcIs,
|
opcIsNil, opcOf, opcIs,
|
||||||
opcSubStr, opcParseFloat, opcConv, opcCast,
|
opcSubStr, opcParseFloat, opcConv, opcCast,
|
||||||
|
|
|
||||||
|
|
@ -973,11 +973,6 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||||
case m
|
case m
|
||||||
of mAnd: c.genAndOr(n, opcFJmp, dest)
|
of mAnd: c.genAndOr(n, opcFJmp, dest)
|
||||||
of mOr: c.genAndOr(n, opcTJmp, dest)
|
of mOr: c.genAndOr(n, opcTJmp, dest)
|
||||||
of mUnaryLt:
|
|
||||||
let tmp = c.genx(n[1])
|
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
|
||||||
c.gABI(n, opcSubImmInt, dest, tmp, 1)
|
|
||||||
c.freeTemp(tmp)
|
|
||||||
of mPred, mSubI:
|
of mPred, mSubI:
|
||||||
c.genAddSubInt(n, dest, opcSubInt)
|
c.genAddSubInt(n, dest, opcSubInt)
|
||||||
of mSucc, mAddI:
|
of mSucc, mAddI:
|
||||||
|
|
@ -1020,9 +1015,9 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||||
c.gABC(n, opcNewStr, dest, tmp)
|
c.gABC(n, opcNewStr, dest, tmp)
|
||||||
c.freeTemp(tmp)
|
c.freeTemp(tmp)
|
||||||
# XXX buggy
|
# XXX buggy
|
||||||
of mLengthOpenArray, mLengthArray, mLengthSeq, mXLenSeq:
|
of mLengthOpenArray, mLengthArray, mLengthSeq:
|
||||||
genUnaryABI(c, n, dest, opcLenSeq)
|
genUnaryABI(c, n, dest, opcLenSeq)
|
||||||
of mLengthStr, mXLenStr:
|
of mLengthStr:
|
||||||
genUnaryABI(c, n, dest, opcLenStr)
|
genUnaryABI(c, n, dest, opcLenStr)
|
||||||
of mIncl, mExcl:
|
of mIncl, mExcl:
|
||||||
unused(c, n, dest)
|
unused(c, n, dest)
|
||||||
|
|
@ -1078,7 +1073,7 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||||
of mLtF64: genBinaryABC(c, n, dest, opcLtFloat)
|
of mLtF64: genBinaryABC(c, n, dest, opcLtFloat)
|
||||||
of mLePtr, mLeU, mLeU64: genBinaryABC(c, n, dest, opcLeu)
|
of mLePtr, mLeU, mLeU64: genBinaryABC(c, n, dest, opcLeu)
|
||||||
of mLtPtr, mLtU, mLtU64: genBinaryABC(c, n, dest, opcLtu)
|
of mLtPtr, mLtU, mLtU64: genBinaryABC(c, n, dest, opcLtu)
|
||||||
of mEqProc, mEqRef, mEqUntracedRef:
|
of mEqProc, mEqRef:
|
||||||
genBinaryABC(c, n, dest, opcEqRef)
|
genBinaryABC(c, n, dest, opcEqRef)
|
||||||
of mXor: genBinaryABC(c, n, dest, opcXor)
|
of mXor: genBinaryABC(c, n, dest, opcXor)
|
||||||
of mNot: genUnaryABC(c, n, dest, opcNot)
|
of mNot: genUnaryABC(c, n, dest, opcNot)
|
||||||
|
|
@ -1105,7 +1100,6 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||||
of mMulSet: genBinarySet(c, n, dest, opcMulSet)
|
of mMulSet: genBinarySet(c, n, dest, opcMulSet)
|
||||||
of mPlusSet: genBinarySet(c, n, dest, opcPlusSet)
|
of mPlusSet: genBinarySet(c, n, dest, opcPlusSet)
|
||||||
of mMinusSet: genBinarySet(c, n, dest, opcMinusSet)
|
of mMinusSet: genBinarySet(c, n, dest, opcMinusSet)
|
||||||
of mSymDiffSet: genBinarySet(c, n, dest, opcSymdiffSet)
|
|
||||||
of mConStrStr: genVarargsABC(c, n, dest, opcConcatStr)
|
of mConStrStr: genVarargsABC(c, n, dest, opcConcatStr)
|
||||||
of mInSet: genBinarySet(c, n, dest, opcContainsSet)
|
of mInSet: genBinarySet(c, n, dest, opcContainsSet)
|
||||||
of mRepr: genUnaryABC(c, n, dest, opcRepr)
|
of mRepr: genUnaryABC(c, n, dest, opcRepr)
|
||||||
|
|
@ -1126,29 +1120,6 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||||
unused(c, n, dest)
|
unused(c, n, dest)
|
||||||
c.gen(lowerSwap(c.graph, n, if c.prc == nil: c.module else: c.prc.sym))
|
c.gen(lowerSwap(c.graph, n, if c.prc == nil: c.module else: c.prc.sym))
|
||||||
of mIsNil: genUnaryABC(c, n, dest, opcIsNil)
|
of mIsNil: genUnaryABC(c, n, dest, opcIsNil)
|
||||||
of mCopyStr:
|
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
|
||||||
var
|
|
||||||
tmp1 = c.genx(n[1])
|
|
||||||
tmp2 = c.genx(n[2])
|
|
||||||
tmp3 = c.getTemp(n[2].typ)
|
|
||||||
c.gABC(n, opcLenStr, tmp3, tmp1)
|
|
||||||
c.gABC(n, opcSubStr, dest, tmp1, tmp2)
|
|
||||||
c.gABC(n, opcSubStr, tmp3)
|
|
||||||
c.freeTemp(tmp1)
|
|
||||||
c.freeTemp(tmp2)
|
|
||||||
c.freeTemp(tmp3)
|
|
||||||
of mCopyStrLast:
|
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
|
||||||
var
|
|
||||||
tmp1 = c.genx(n[1])
|
|
||||||
tmp2 = c.genx(n[2])
|
|
||||||
tmp3 = c.genx(n[3])
|
|
||||||
c.gABC(n, opcSubStr, dest, tmp1, tmp2)
|
|
||||||
c.gABC(n, opcSubStr, tmp3)
|
|
||||||
c.freeTemp(tmp1)
|
|
||||||
c.freeTemp(tmp2)
|
|
||||||
c.freeTemp(tmp3)
|
|
||||||
of mParseBiggestFloat:
|
of mParseBiggestFloat:
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
if dest < 0: dest = c.getTemp(n.typ)
|
||||||
var d2: TRegister
|
var d2: TRegister
|
||||||
|
|
|
||||||
|
|
@ -1458,7 +1458,7 @@ proc boolVal*(n: NimNode): bool {.compileTime, noSideEffect.} =
|
||||||
else: n == bindSym"true" # hacky solution for now
|
else: n == bindSym"true" # hacky solution for now
|
||||||
|
|
||||||
when defined(nimMacrosGetNodeId):
|
when defined(nimMacrosGetNodeId):
|
||||||
proc nodeID*(n: NimNode): int {.magic: NodeId.}
|
proc nodeID*(n: NimNode): int {.magic: "NodeId".}
|
||||||
## Returns the id of ``n``, when the compiler has been compiled
|
## Returns the id of ``n``, when the compiler has been compiled
|
||||||
## with the flag ``-d:useNodeids``, otherwise returns ``-1``. This
|
## with the flag ``-d:useNodeids``, otherwise returns ``-1``. This
|
||||||
## proc is for the purpose to debug the compiler only.
|
## proc is for the purpose to debug the compiler only.
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
type
|
type
|
||||||
int* {.magic: Int.} ## Default integer type; bitwidth depends on
|
int* {.magic: "Int".} ## Default integer type; bitwidth depends on
|
||||||
## architecture, but is always the same as a pointer.
|
## architecture, but is always the same as a pointer.
|
||||||
int8* {.magic: Int8.} ## Signed 8 bit integer type.
|
int8* {.magic: "Int8".} ## Signed 8 bit integer type.
|
||||||
int16* {.magic: Int16.} ## Signed 16 bit integer type.
|
int16* {.magic: "Int16".} ## Signed 16 bit integer type.
|
||||||
int32* {.magic: Int32.} ## Signed 32 bit integer type.
|
int32* {.magic: "Int32".} ## Signed 32 bit integer type.
|
||||||
int64* {.magic: Int64.} ## Signed 64 bit integer type.
|
int64* {.magic: "Int64".} ## Signed 64 bit integer type.
|
||||||
uint* {.magic: UInt.} ## Unsigned default integer type.
|
uint* {.magic: "UInt".} ## Unsigned default integer type.
|
||||||
uint8* {.magic: UInt8.} ## Unsigned 8 bit integer type.
|
uint8* {.magic: "UInt8".} ## Unsigned 8 bit integer type.
|
||||||
uint16* {.magic: UInt16.} ## Unsigned 16 bit integer type.
|
uint16* {.magic: "UInt16".} ## Unsigned 16 bit integer type.
|
||||||
uint32* {.magic: UInt32.} ## Unsigned 32 bit integer type.
|
uint32* {.magic: "UInt32".} ## Unsigned 32 bit integer type.
|
||||||
uint64* {.magic: UInt64.} ## Unsigned 64 bit integer type.
|
uint64* {.magic: "UInt64".} ## Unsigned 64 bit integer type.
|
||||||
|
|
||||||
type # we need to start a new type section here, so that ``0`` can have a type
|
type # we need to start a new type section here, so that ``0`` can have a type
|
||||||
bool* {.magic: Bool.} = enum ## Built-in boolean type.
|
bool* {.magic: "Bool".} = enum ## Built-in boolean type.
|
||||||
false = 0, true = 1
|
false = 0, true = 1
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue