Update 'isCastable' and 'semCast' doc-comments
This commit is contained in:
parent
97fa3391f2
commit
6608fcc60f
1 changed files with 6 additions and 2 deletions
|
|
@ -176,13 +176,16 @@ proc checkConvertible(c: PContext, castDest, src: PType): TConvStatus =
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc isCastable(dst, src: PType): bool =
|
proc isCastable(dst, src: PType): bool =
|
||||||
|
## Checks whether the source type can be casted to the destination type.
|
||||||
|
## Casting is very unrestrictive; casts are allowed as long as
|
||||||
|
## castDest.size >= src.size, and typeAllowed(dst, skParam)
|
||||||
#const
|
#const
|
||||||
# castableTypeKinds = {tyInt, tyPtr, tyRef, tyCstring, tyString,
|
# castableTypeKinds = {tyInt, tyPtr, tyRef, tyCstring, tyString,
|
||||||
# tySequence, tyPointer, tyNil, tyOpenArray,
|
# tySequence, tyPointer, tyNil, tyOpenArray,
|
||||||
# tyProc, tySet, tyEnum, tyBool, tyChar}
|
# tyProc, tySet, tyEnum, tyBool, tyChar}
|
||||||
var ds, ss: BiggestInt
|
var ds, ss: BiggestInt
|
||||||
# this is very unrestrictive; cast is allowed if castDest.size >= src.size
|
|
||||||
ds = computeSize(dst)
|
ds = computeSize(dst)
|
||||||
ss = computeSize(src)
|
ss = computeSize(src)
|
||||||
if ds < 0:
|
if ds < 0:
|
||||||
|
|
@ -254,6 +257,7 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||||
localError(n.info, errUseQualifier, op.sons[0].sym.name.s)
|
localError(n.info, errUseQualifier, op.sons[0].sym.name.s)
|
||||||
|
|
||||||
proc semCast(c: PContext, n: PNode): PNode =
|
proc semCast(c: PContext, n: PNode): PNode =
|
||||||
|
## Semantically analyze a casting ("cast[type](param)")
|
||||||
if optSafeCode in gGlobalOptions: localError(n.info, errCastNotInSafeMode)
|
if optSafeCode in gGlobalOptions: localError(n.info, errCastNotInSafeMode)
|
||||||
#incl(c.p.owner.flags, sfSideEffect)
|
#incl(c.p.owner.flags, sfSideEffect)
|
||||||
checkSonsLen(n, 2)
|
checkSonsLen(n, 2)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue