got rid of tyPureObject; broke bootstrapping; use generated C code
This commit is contained in:
parent
3824b6ea5f
commit
bd2d146c77
7 changed files with 19 additions and 14 deletions
|
|
@ -265,6 +265,10 @@ type
|
||||||
tyIter, # unused
|
tyIter, # unused
|
||||||
tyProxy # currently unused
|
tyProxy # currently unused
|
||||||
|
|
||||||
|
const
|
||||||
|
tyPureObject* = tyTuple
|
||||||
|
|
||||||
|
type
|
||||||
TTypeKinds* = set[TTypeKind]
|
TTypeKinds* = set[TTypeKind]
|
||||||
|
|
||||||
TNodeFlag* = enum
|
TNodeFlag* = enum
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ proc genTypeInfoAuxBase(m: BModule, typ: PType, name, base: PRope) =
|
||||||
allocMemTI(m, typ, name)
|
allocMemTI(m, typ, name)
|
||||||
if (typ.kind == tyObject) and (tfFinal in typ.flags) and
|
if (typ.kind == tyObject) and (tfFinal in typ.flags) and
|
||||||
(typ.sons[0] == nil):
|
(typ.sons[0] == nil):
|
||||||
nimtypeKind = ord(high(TTypeKind)) + 1 # tyPureObject
|
nimtypeKind = ord(tyPureObject)
|
||||||
else:
|
else:
|
||||||
nimtypeKind = ord(typ.kind)
|
nimtypeKind = ord(typ.kind)
|
||||||
appf(m.s[cfsTypeInit3],
|
appf(m.s[cfsTypeInit3],
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ proc initProc(p: var TProc, globals: PGlobals, module: BModule, procDef: PNode,
|
||||||
|
|
||||||
const
|
const
|
||||||
MappedToObject = {tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray,
|
MappedToObject = {tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray,
|
||||||
tySet, tyVar, tyRef, tyPtr}
|
tySet, tyVar, tyRef, tyPtr, tyBigNum}
|
||||||
|
|
||||||
proc mapType(typ: PType): TEcmasTypeKind =
|
proc mapType(typ: PType): TEcmasTypeKind =
|
||||||
var t = skipTypes(typ, abstractInst)
|
var t = skipTypes(typ, abstractInst)
|
||||||
|
|
@ -99,13 +99,15 @@ proc mapType(typ: PType): TEcmasTypeKind =
|
||||||
of tyPointer:
|
of tyPointer:
|
||||||
# treat a tyPointer like a typed pointer to an array of bytes
|
# treat a tyPointer like a typed pointer to an array of bytes
|
||||||
result = etyInt
|
result = etyInt
|
||||||
of tyRange, tyDistinct, tyOrdinal: result = mapType(t.sons[0])
|
of tyRange, tyDistinct, tyOrdinal, tyConst, tyMutable, tyIter, tyVarargs,
|
||||||
of tyInt..tyInt64, tyEnum, tyChar: result = etyInt
|
tyProxy:
|
||||||
|
result = mapType(t.sons[0])
|
||||||
|
of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyChar: result = etyInt
|
||||||
of tyBool: result = etyBool
|
of tyBool: result = etyBool
|
||||||
of tyFloat..tyFloat128: result = etyFloat
|
of tyFloat..tyFloat128: result = etyFloat
|
||||||
of tySet: result = etyObject # map a set to a table
|
of tySet: result = etyObject # map a set to a table
|
||||||
of tyString, tySequence: result = etyInt # little hack to get right semantics
|
of tyString, tySequence: result = etyInt # little hack to get right semantics
|
||||||
of tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray:
|
of tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray, tyBigNum:
|
||||||
result = etyObject
|
result = etyObject
|
||||||
of tyNil: result = etyNull
|
of tyNil: result = etyNull
|
||||||
of tyGenericInst, tyGenericParam, tyGenericBody, tyGenericInvokation, tyNone,
|
of tyGenericInst, tyGenericParam, tyGenericBody, tyGenericInvokation, tyNone,
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ proc genericAssignAux(dest, src: Pointer, mt: PNimType, shallow: bool) =
|
||||||
var dstseq = cast[PGenericSeq](dst)
|
var dstseq = cast[PGenericSeq](dst)
|
||||||
dstseq.len = seq.len
|
dstseq.len = seq.len
|
||||||
dstseq.space = seq.len
|
dstseq.space = seq.len
|
||||||
of tyObject, tyTuple, tyPureObject:
|
of tyObject, tyTuple:
|
||||||
# we don't need to copy m_type field for tyObject, as they are equal anyway
|
# we don't need to copy m_type field for tyObject, as they are equal anyway
|
||||||
genericAssignAux(dest, src, mt.node, shallow)
|
genericAssignAux(dest, src, mt.node, shallow)
|
||||||
of tyArray, tyArrayConstr:
|
of tyArray, tyArrayConstr:
|
||||||
|
|
@ -121,7 +121,7 @@ proc objectInit(dest: Pointer, typ: PNimType) =
|
||||||
var pint = cast[ptr PNimType](dest)
|
var pint = cast[ptr PNimType](dest)
|
||||||
pint[] = typ
|
pint[] = typ
|
||||||
objectInitAux(dest, typ.node)
|
objectInitAux(dest, typ.node)
|
||||||
of tyTuple, tyPureObject:
|
of tyTuple:
|
||||||
objectInitAux(dest, typ.node)
|
objectInitAux(dest, typ.node)
|
||||||
of tyArray, tyArrayConstr:
|
of tyArray, tyArrayConstr:
|
||||||
for i in 0..(typ.size div typ.base.size)-1:
|
for i in 0..(typ.size div typ.base.size)-1:
|
||||||
|
|
@ -149,7 +149,7 @@ proc genericReset(dest: Pointer, mt: PNimType) =
|
||||||
case mt.Kind
|
case mt.Kind
|
||||||
of tyString, tyRef, tySequence:
|
of tyString, tyRef, tySequence:
|
||||||
unsureAsgnRef(cast[ppointer](dest), nil)
|
unsureAsgnRef(cast[ppointer](dest), nil)
|
||||||
of tyObject, tyTuple, tyPureObject:
|
of tyObject, tyTuple:
|
||||||
# we don't need to reset m_type field for tyObject
|
# we don't need to reset m_type field for tyObject
|
||||||
genericResetAux(dest, mt.node)
|
genericResetAux(dest, mt.node)
|
||||||
of tyArray, tyArrayConstr:
|
of tyArray, tyArrayConstr:
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ proc forAllChildrenAux(dest: Pointer, mt: PNimType, op: TWalkOp) =
|
||||||
case mt.Kind
|
case mt.Kind
|
||||||
of tyRef, tyString, tySequence: # leaf:
|
of tyRef, tyString, tySequence: # leaf:
|
||||||
doOperation(cast[ppointer](d)[], op)
|
doOperation(cast[ppointer](d)[], op)
|
||||||
of tyObject, tyTuple, tyPureObject:
|
of tyObject, tyTuple:
|
||||||
forAllSlotsAux(dest, mt.node, op)
|
forAllSlotsAux(dest, mt.node, op)
|
||||||
of tyArray, tyArrayConstr, tyOpenArray:
|
of tyArray, tyArrayConstr, tyOpenArray:
|
||||||
for i in 0..(mt.size div mt.base.size)-1:
|
for i in 0..(mt.size div mt.base.size)-1:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ type # This should be he same as ast.TTypeKind
|
||||||
tyOrdinal,
|
tyOrdinal,
|
||||||
tyArray,
|
tyArray,
|
||||||
tyObject,
|
tyObject,
|
||||||
tyTuple,
|
tyTuple, # WARNING: The compiler uses tyTuple for pure objects!
|
||||||
tySet,
|
tySet,
|
||||||
tyRange,
|
tyRange,
|
||||||
tyPtr, tyRef,
|
tyPtr, tyRef,
|
||||||
|
|
@ -37,8 +37,7 @@ type # This should be he same as ast.TTypeKind
|
||||||
tyPointer, tyOpenArray,
|
tyPointer, tyOpenArray,
|
||||||
tyString, tyCString, tyForward,
|
tyString, tyCString, tyForward,
|
||||||
tyInt, tyInt8, tyInt16, tyInt32, tyInt64,
|
tyInt, tyInt8, tyInt16, tyInt32, tyInt64,
|
||||||
tyFloat, tyFloat32, tyFloat64, tyFloat128,
|
tyFloat, tyFloat32, tyFloat64, tyFloat128
|
||||||
tyPureObject # signals that object has no `n_type` field
|
|
||||||
|
|
||||||
TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
|
TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
|
||||||
TNimNode {.codegenType, final.} = object
|
TNimNode {.codegenType, final.} = object
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ when not defined(useNimRtl):
|
||||||
case typ.kind
|
case typ.kind
|
||||||
of tySet: reprSetAux(result, p, typ)
|
of tySet: reprSetAux(result, p, typ)
|
||||||
of tyArray: reprArray(result, p, typ, cl)
|
of tyArray: reprArray(result, p, typ, cl)
|
||||||
of tyTuple, tyPureObject: reprRecord(result, p, typ, cl)
|
of tyTuple: reprRecord(result, p, typ, cl)
|
||||||
of tyObject:
|
of tyObject:
|
||||||
var t = cast[ptr PNimType](p)[]
|
var t = cast[ptr PNimType](p)[]
|
||||||
reprRecord(result, p, t, cl)
|
reprRecord(result, p, t, cl)
|
||||||
|
|
@ -251,7 +251,7 @@ when not defined(useNimRtl):
|
||||||
cl: TReprClosure
|
cl: TReprClosure
|
||||||
initReprClosure(cl)
|
initReprClosure(cl)
|
||||||
result = ""
|
result = ""
|
||||||
if typ.kind in {tyObject, tyPureObject, tyTuple, tyArray, tySet}:
|
if typ.kind in {tyObject, tyTuple, tyArray, tySet}:
|
||||||
reprAux(result, p, typ, cl)
|
reprAux(result, p, typ, cl)
|
||||||
else:
|
else:
|
||||||
var p = p
|
var p = p
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue