got rid of akPureObject

This commit is contained in:
Araq
2011-09-24 10:57:35 +02:00
parent ae0ab9a101
commit 98e5beb936
3 changed files with 8 additions and 8 deletions

View File

@@ -77,7 +77,8 @@ proc mapType(typ: PType): TCTypeKind =
of tySet: result = mapSetType(typ)
of tyOpenArray, tyArrayConstr, tyArray: result = ctArray
of tyObject, tyTuple: result = ctStruct
of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal:
of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal,
tyConst, tyMutable, tyIter:
result = mapType(lastSon(typ))
of tyEnum:
if firstOrd(typ) < 0:

View File

@@ -39,8 +39,7 @@ type
akFloat = 36, ## any represents a float
akFloat32 = 37, ## any represents a float32
akFloat64 = 38, ## any represents a float64
akFloat128 = 39, ## any represents a float128
akPureObject = 40 ## any represents an object that has no `type` field
akFloat128 = 39 ## any represents a float128
TAny* = object {.pure.} ## can represent any nimrod value; NOTE: the wrapped
## value can be modified with its wrapper! This means
@@ -230,7 +229,7 @@ proc fieldsAux(p: pointer, n: ptr TNimNode,
iterator fields*(x: TAny): tuple[name: string, any: TAny] =
## iterates over every active field of the any `x` that represents an object
## or a tuple.
assert x.rawType.kind in {tyTuple, tyPureObject, tyObject}
assert x.rawType.kind in {tyTuple, tyObject}
var p = x.value
var t = x.rawType
# XXX BUG: does not work yet, however is questionable anyway
@@ -282,7 +281,7 @@ proc `[]=`*(x: TAny, fieldName: string, value: TAny) =
# XXX BUG: does not work yet, however is questionable anyway
when false:
if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[]
assert x.rawType.kind in {tyTuple, tyPureObject, tyObject}
assert x.rawType.kind in {tyTuple, tyObject}
var n = getFieldNode(x.value, t.node, fieldname)
if n != nil:
assert n.typ == value.rawType
@@ -296,7 +295,7 @@ proc `[]`*(x: TAny, fieldName: string): TAny =
# XXX BUG: does not work yet, however is questionable anyway
when false:
if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[]
assert x.rawType.kind in {tyTuple, tyPureObject, tyObject}
assert x.rawType.kind in {tyTuple, tyObject}
var n = getFieldNode(x.value, t.node, fieldname)
if n != nil:
result.value = x.value +!! n.offset

View File

@@ -47,7 +47,7 @@ proc storeAny(s: PStream, a: TAny, stored: var TIntSet) =
if i > 0: s.write(", ")
storeAny(s, a[i], stored)
s.write("]")
of akObject, akPureObject, akTuple:
of akObject, akTuple:
s.write("{")
var i = 0
for key, val in fields(a):
@@ -138,7 +138,7 @@ proc loadAny(p: var TJsonParser, a: TAny, t: var TTable[biggestInt, pointer]) =
else: raiseParseErr(p, "")
else:
raiseParseErr(p, "'[' expected for a seq")
of akObject, akPureObject, akTuple:
of akObject, akTuple:
if a.kind == akObject: setObjectRuntimeType(a)
if p.kind != jsonObjectStart: raiseParseErr(p, "'{' expected for an object")
next(p)