WIP: nothing works

This commit is contained in:
Andreas Rumpf
2018-08-05 09:38:14 +02:00
parent 700448f359
commit abe0725ab1
3 changed files with 39 additions and 12 deletions

View File

@@ -144,9 +144,7 @@ proc semSet(c: PContext, n: PNode, prev: PType): PType =
localError(c.config, n.info, errXExpectsOneTypeParam % "set")
addSonSkipIntLit(result, errorType(c))
proc semContainer(c: PContext, n: PNode, kind: TTypeKind, kindStr: string,
prev: PType): PType =
result = newOrPrevType(kind, prev, c)
proc semContainerArg(c: PContext; n: PNode, kindStr: string; result: PType) =
if sonsLen(n) == 2:
var base = semTypeNode(c, n.sons[1], nil)
if base.kind == tyVoid:
@@ -156,6 +154,11 @@ proc semContainer(c: PContext, n: PNode, kind: TTypeKind, kindStr: string,
localError(c.config, n.info, errXExpectsOneTypeParam % kindStr)
addSonSkipIntLit(result, errorType(c))
proc semContainer(c: PContext, n: PNode, kind: TTypeKind, kindStr: string,
prev: PType): PType =
result = newOrPrevType(kind, prev, c)
semContainerArg(c, n, kindStr, result)
proc semVarargs(c: PContext, n: PNode, prev: PType): PType =
result = newOrPrevType(tyVarargs, prev, c)
if sonsLen(n) == 2 or sonsLen(n) == 3:
@@ -1505,9 +1508,29 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
of mSet: result = semSet(c, n, prev)
of mOrdinal: result = semOrdinal(c, n, prev)
of mSeq:
result = semContainer(c, n, tySequence, "seq", prev)
let s = c.graph.sysTypes[tySequence]
assert s != nil
assert prev == nil
result = copyType(s, s.owner, keepId=false)
# XXX figure out why this has children already...
result.sons.setLen 0
result.n = nil
if c.config.selectedGc == gcDestructors:
incl result.flags, tfHasAsgn
result.flags = {tfHasAsgn}
else:
result.flags = {}
semContainerArg(c, n, "seq", result)
when false:
debugT = true
echo "Start!"
#debug result
assert(not containsGenericType(result))
debugT = false
echo "End!"
when false:
result = semContainer(c, n, tySequence, "seq", prev)
if c.config.selectedGc == gcDestructors:
incl result.flags, tfHasAsgn
of mOpt: result = semContainer(c, n, tyOpt, "opt", prev)
of mVarargs: result = semVarargs(c, n, prev)
of mTypeDesc, mTypeTy:
@@ -1681,8 +1704,9 @@ proc processMagicType(c: PContext, m: PSym) =
of mString:
setMagicType(c.config, m, tyString, c.config.target.ptrSize)
rawAddSon(m.typ, getSysType(c.graph, m.info, tyChar))
if c.config.selectedGc == gcDestructors:
incl m.typ.flags, tfHasAsgn
when false:
if c.config.selectedGc == gcDestructors:
incl m.typ.flags, tfHasAsgn
of mCstring:
setMagicType(c.config, m, tyCString, c.config.target.ptrSize)
rawAddSon(m.typ, getSysType(c.graph, m.info, tyChar))
@@ -1724,6 +1748,8 @@ proc processMagicType(c: PContext, m: PSym) =
setMagicType(c.config, m, tySequence, 0)
if c.config.selectedGc == gcDestructors:
incl m.typ.flags, tfHasAsgn
assert c.graph.sysTypes[tySequence] == nil
c.graph.sysTypes[tySequence] = m.typ
of mOpt:
setMagicType(c.config, m, tyOpt, 0)
of mOrdinal:

View File

@@ -46,7 +46,7 @@ template frees(s) =
s.p.region.dealloc(s.p.region, s.p, contentSize(s.p.cap))
proc `=destroy`(s: var string) =
var a = cast[ptr NimStringV2[T]](addr s)
var a = cast[ptr NimStringV2](addr s)
frees(a)
a.len = 0
a.p = nil

View File

@@ -428,10 +428,11 @@ proc getStackTrace(e: ref Exception): string =
else:
result = ""
proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
## Returns the attached stack trace to the exception ``e`` as
## a ``seq``. This is not yet available for the JS backend.
shallowCopy(result, e.trace)
when not defined(gcDestructors):
proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
## Returns the attached stack trace to the exception ``e`` as
## a ``seq``. This is not yet available for the JS backend.
shallowCopy(result, e.trace)
when defined(nimRequiresNimFrame):
proc stackOverflow() {.noinline.} =