mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 07:15:22 +00:00
make tsizeof run on C++ backend (#9734)
This commit is contained in:
committed by
Andreas Rumpf
parent
696dc1609f
commit
5dfcc4e91c
@@ -318,16 +318,24 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
|
||||
var headerAlign: int16
|
||||
if typ.sons[0] != nil:
|
||||
# compute header size
|
||||
var st = typ.sons[0]
|
||||
while st.kind in skipPtrs:
|
||||
st = st.sons[^1]
|
||||
computeSizeAlign(conf, st)
|
||||
if st.size == szIllegalRecursion:
|
||||
typ.size = st.size
|
||||
typ.align = st.align
|
||||
return
|
||||
headerSize = st.size
|
||||
headerAlign = st.align
|
||||
|
||||
if conf.cmd == cmdCompileToCpp:
|
||||
# if the target is C++ the members of this type are written
|
||||
# into the padding byets at the end of the parent type. At the
|
||||
# moment it is not supported to calculate that.
|
||||
headerSize = szUnknownSize
|
||||
headerAlign = szUncomputedSize
|
||||
else:
|
||||
var st = typ.sons[0]
|
||||
while st.kind in skipPtrs:
|
||||
st = st.sons[^1]
|
||||
computeSizeAlign(conf, st)
|
||||
if st.size == szIllegalRecursion:
|
||||
typ.size = st.size
|
||||
typ.align = st.align
|
||||
return
|
||||
headerSize = st.size
|
||||
headerAlign = st.align
|
||||
elif isObjectWithTypeFieldPredicate(typ):
|
||||
# this branch is taken for RootObj
|
||||
headerSize = conf.target.intSize
|
||||
|
||||
Reference in New Issue
Block a user