got rid of akPureObject
This commit is contained in:
parent
ae0ab9a101
commit
98e5beb936
3 changed files with 8 additions and 8 deletions
|
|
@ -77,7 +77,8 @@ proc mapType(typ: PType): TCTypeKind =
|
||||||
of tySet: result = mapSetType(typ)
|
of tySet: result = mapSetType(typ)
|
||||||
of tyOpenArray, tyArrayConstr, tyArray: result = ctArray
|
of tyOpenArray, tyArrayConstr, tyArray: result = ctArray
|
||||||
of tyObject, tyTuple: result = ctStruct
|
of tyObject, tyTuple: result = ctStruct
|
||||||
of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal:
|
of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal,
|
||||||
|
tyConst, tyMutable, tyIter:
|
||||||
result = mapType(lastSon(typ))
|
result = mapType(lastSon(typ))
|
||||||
of tyEnum:
|
of tyEnum:
|
||||||
if firstOrd(typ) < 0:
|
if firstOrd(typ) < 0:
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ type
|
||||||
akFloat = 36, ## any represents a float
|
akFloat = 36, ## any represents a float
|
||||||
akFloat32 = 37, ## any represents a float32
|
akFloat32 = 37, ## any represents a float32
|
||||||
akFloat64 = 38, ## any represents a float64
|
akFloat64 = 38, ## any represents a float64
|
||||||
akFloat128 = 39, ## any represents a float128
|
akFloat128 = 39 ## any represents a float128
|
||||||
akPureObject = 40 ## any represents an object that has no `type` field
|
|
||||||
|
|
||||||
TAny* = object {.pure.} ## can represent any nimrod value; NOTE: the wrapped
|
TAny* = object {.pure.} ## can represent any nimrod value; NOTE: the wrapped
|
||||||
## value can be modified with its wrapper! This means
|
## 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] =
|
iterator fields*(x: TAny): tuple[name: string, any: TAny] =
|
||||||
## iterates over every active field of the any `x` that represents an object
|
## iterates over every active field of the any `x` that represents an object
|
||||||
## or a tuple.
|
## or a tuple.
|
||||||
assert x.rawType.kind in {tyTuple, tyPureObject, tyObject}
|
assert x.rawType.kind in {tyTuple, tyObject}
|
||||||
var p = x.value
|
var p = x.value
|
||||||
var t = x.rawType
|
var t = x.rawType
|
||||||
# XXX BUG: does not work yet, however is questionable anyway
|
# 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
|
# XXX BUG: does not work yet, however is questionable anyway
|
||||||
when false:
|
when false:
|
||||||
if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[]
|
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)
|
var n = getFieldNode(x.value, t.node, fieldname)
|
||||||
if n != nil:
|
if n != nil:
|
||||||
assert n.typ == value.rawType
|
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
|
# XXX BUG: does not work yet, however is questionable anyway
|
||||||
when false:
|
when false:
|
||||||
if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[]
|
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)
|
var n = getFieldNode(x.value, t.node, fieldname)
|
||||||
if n != nil:
|
if n != nil:
|
||||||
result.value = x.value +!! n.offset
|
result.value = x.value +!! n.offset
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ proc storeAny(s: PStream, a: TAny, stored: var TIntSet) =
|
||||||
if i > 0: s.write(", ")
|
if i > 0: s.write(", ")
|
||||||
storeAny(s, a[i], stored)
|
storeAny(s, a[i], stored)
|
||||||
s.write("]")
|
s.write("]")
|
||||||
of akObject, akPureObject, akTuple:
|
of akObject, akTuple:
|
||||||
s.write("{")
|
s.write("{")
|
||||||
var i = 0
|
var i = 0
|
||||||
for key, val in fields(a):
|
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, "")
|
||||||
else:
|
else:
|
||||||
raiseParseErr(p, "'[' expected for a seq")
|
raiseParseErr(p, "'[' expected for a seq")
|
||||||
of akObject, akPureObject, akTuple:
|
of akObject, akTuple:
|
||||||
if a.kind == akObject: setObjectRuntimeType(a)
|
if a.kind == akObject: setObjectRuntimeType(a)
|
||||||
if p.kind != jsonObjectStart: raiseParseErr(p, "'{' expected for an object")
|
if p.kind != jsonObjectStart: raiseParseErr(p, "'{' expected for an object")
|
||||||
next(p)
|
next(p)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue