manual merge continues
This commit is contained in:
parent
f1185658cc
commit
17ab7aff44
1 changed files with 30 additions and 16 deletions
|
|
@ -86,11 +86,11 @@ proc isPureObject*(typ: PType): bool =
|
||||||
t = t.sons[0].skipTypes(skipPtrs)
|
t = t.sons[0].skipTypes(skipPtrs)
|
||||||
result = t.sym != nil and sfPure in t.sym.flags
|
result = t.sym != nil and sfPure in t.sym.flags
|
||||||
|
|
||||||
proc getValue*[T:BiggestInt|BiggestFloat|string](n: PNode): T =
|
proc getOrdValue*(n: PNode): BiggestInt =
|
||||||
## get value of liternal node
|
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkNilLit: reset(result)
|
of nkCharLit..nkUInt64Lit: result = n.intVal
|
||||||
of nkHiddenStdConv: result = getValue[T](n.sons[1])
|
of nkNilLit: result = 0
|
||||||
|
of nkHiddenStdConv: result = getOrdValue(n.sons[1])
|
||||||
else:
|
else:
|
||||||
#localError(n.info, errOrdinalTypeExpected)
|
#localError(n.info, errOrdinalTypeExpected)
|
||||||
# XXX check usages of getOrdValue
|
# XXX check usages of getOrdValue
|
||||||
|
|
@ -589,15 +589,28 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
result = typeToStr[t.kind]
|
result = typeToStr[t.kind]
|
||||||
result.addTypeFlags(t)
|
result.addTypeFlags(t)
|
||||||
|
|
||||||
proc firstValue*[T:BiggestInt|BiggestFloat](t: PType): T =
|
proc firstOrd*(t: PType): BiggestInt =
|
||||||
case t.kind:
|
case t.kind
|
||||||
of tyVar: result = firstValue[T](t.sons[0])
|
of tyBool, tyChar, tySequence, tyOpenArray, tyString, tyVarargs, tyProxy:
|
||||||
of tyGenericInst, tyDistinct, tyTypeDesc, tyAlias:
|
result = 0
|
||||||
result = firstValue[T](lastSon(t))
|
of tySet, tyVar: result = firstOrd(t.sons[0])
|
||||||
of tyRange:
|
of tyArray: result = firstOrd(t.sons[0])
|
||||||
assert(t.n != nil) # range directly given:
|
of tyRange:
|
||||||
assert(t.n.kind == nkRange)
|
assert(t.n != nil) # range directly given:
|
||||||
result = getValue[T](t.n.sons[0])
|
assert(t.n.kind == nkRange)
|
||||||
|
result = getOrdValue(t.n.sons[0])
|
||||||
|
of tyInt:
|
||||||
|
if platform.intSize == 4: result = - (2147483646) - 2
|
||||||
|
else: result = 0x8000000000000000'i64
|
||||||
|
of tyInt8: result = - 128
|
||||||
|
of tyInt16: result = - 32768
|
||||||
|
of tyInt32: result = - 2147483646 - 2
|
||||||
|
of tyInt64: result = 0x8000000000000000'i64
|
||||||
|
of tyUInt..tyUInt64: result = 0
|
||||||
|
of tyEnum:
|
||||||
|
# if basetype <> nil then return firstOrd of basetype
|
||||||
|
if sonsLen(t) > 0 and t.sons[0] != nil:
|
||||||
|
result = firstOrd(t.sons[0])
|
||||||
else:
|
else:
|
||||||
assert(t.n.sons[0].kind == nkSym)
|
assert(t.n.sons[0].kind == nkSym)
|
||||||
result = t.n.sons[0].sym.position
|
result = t.n.sons[0].sym.position
|
||||||
|
|
@ -612,9 +625,10 @@ proc firstValue*[T:BiggestInt|BiggestFloat](t: PType): T =
|
||||||
|
|
||||||
proc lastOrd*(t: PType; fixedUnsigned = false): BiggestInt =
|
proc lastOrd*(t: PType; fixedUnsigned = false): BiggestInt =
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyVar: result = lastValue[T](t.sons[0])
|
of tyBool: result = 1
|
||||||
of tyGenericInst, tyDistinct, tyTypeDesc, tyAlias:
|
of tyChar: result = 255
|
||||||
result = lastValue[T](lastSon(t))
|
of tySet, tyVar: result = lastOrd(t.sons[0])
|
||||||
|
of tyArray: result = lastOrd(t.sons[0])
|
||||||
of tyRange:
|
of tyRange:
|
||||||
assert(t.n != nil) # range directly given:
|
assert(t.n != nil) # range directly given:
|
||||||
assert(t.n.kind == nkRange)
|
assert(t.n.kind == nkRange)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue