added xmltree.innerText; fixes #49
This commit is contained in:
parent
c6038dda04
commit
2183bf77a6
7 changed files with 114 additions and 33 deletions
|
|
@ -1058,8 +1058,7 @@ proc genNew(p: BProc, e: PNode) =
|
|||
proc genNewSeq(p: BProc, e: PNode) =
|
||||
var
|
||||
a, b, c: TLoc
|
||||
seqtype: PType
|
||||
seqType = skipTypes(e.sons[1].typ, abstractVarRange)
|
||||
var seqType = skipTypes(e.sons[1].typ, abstractVarRange)
|
||||
InitLocExpr(p, e.sons[1], a)
|
||||
InitLocExpr(p, e.sons[2], b)
|
||||
initLoc(c, locExpr, a.t, OnHeap)
|
||||
|
|
@ -1069,15 +1068,12 @@ proc genNewSeq(p: BProc, e: PNode) =
|
|||
genAssignment(p, a, c, {})
|
||||
|
||||
proc genOf(p: BProc, x: PNode, typ: PType, d: var TLoc) =
|
||||
var
|
||||
a: TLoc
|
||||
dest, t: PType
|
||||
r, nilcheck: PRope
|
||||
var a: TLoc
|
||||
initLocExpr(p, x, a)
|
||||
dest = skipTypes(typ, abstractPtrs)
|
||||
r = rdLoc(a)
|
||||
nilCheck = nil
|
||||
t = skipTypes(a.t, abstractInst)
|
||||
var dest = skipTypes(typ, abstractPtrs)
|
||||
var r = rdLoc(a)
|
||||
var nilCheck: PRope = nil
|
||||
var t = skipTypes(a.t, abstractInst)
|
||||
while t.kind in {tyVar, tyPtr, tyRef}:
|
||||
if t.kind != tyVar: nilCheck = r
|
||||
r = ropef("(*$1)", [r])
|
||||
|
|
@ -1546,7 +1542,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
|||
of mStrToStr: expr(p, e.sons[1], d)
|
||||
of mEnumToStr: genRepr(p, e, d)
|
||||
of mAssert:
|
||||
if (optAssert in p.Options):
|
||||
if optAssert in p.Options:
|
||||
expr(p, e.sons[1], d)
|
||||
line = toRope(toLinenumber(e.info))
|
||||
filen = makeCString(ToFilename(e.info))
|
||||
|
|
@ -1689,22 +1685,19 @@ proc genStmtListExpr(p: BProc, n: PNode, d: var TLoc) =
|
|||
if length > 0: expr(p, n.sons[length - 1], d)
|
||||
|
||||
proc upConv(p: BProc, n: PNode, d: var TLoc) =
|
||||
var
|
||||
a: TLoc
|
||||
dest, t: PType
|
||||
r, nilCheck: PRope
|
||||
var a: TLoc
|
||||
initLocExpr(p, n.sons[0], a)
|
||||
dest = skipTypes(n.typ, abstractPtrs)
|
||||
if (optObjCheck in p.options) and not (isPureObject(dest)):
|
||||
r = rdLoc(a)
|
||||
nilCheck = nil
|
||||
t = skipTypes(a.t, abstractInst)
|
||||
var dest = skipTypes(n.typ, abstractPtrs)
|
||||
if optObjCheck in p.options and not isPureObject(dest):
|
||||
var r = rdLoc(a)
|
||||
var nilCheck: PRope = nil
|
||||
var t = skipTypes(a.t, abstractInst)
|
||||
while t.kind in {tyVar, tyPtr, tyRef}:
|
||||
if t.kind != tyVar: nilCheck = r
|
||||
r = ropef("(*$1)", [r])
|
||||
t = skipTypes(t.sons[0], abstractInst)
|
||||
if gCmd != cmdCompileToCpp:
|
||||
while (t.kind == tyObject) and (t.sons[0] != nil):
|
||||
while t.kind == tyObject and t.sons[0] != nil:
|
||||
app(r, ".Sup")
|
||||
t = skipTypes(t.sons[0], abstractInst)
|
||||
if nilCheck != nil:
|
||||
|
|
@ -1753,7 +1746,7 @@ proc expr(p: BProc, e: PNode, d: var TLoc) =
|
|||
putLocIntoDest(p, d, sym.loc)
|
||||
of skProc, skConverter:
|
||||
genProc(p.module, sym)
|
||||
if ((sym.loc.r == nil) or (sym.loc.t == nil)):
|
||||
if sym.loc.r == nil or sym.loc.t == nil:
|
||||
InternalError(e.info, "expr: proc not init " & sym.name.s)
|
||||
putLocIntoDest(p, d, sym.loc)
|
||||
of skConst:
|
||||
|
|
@ -1768,7 +1761,7 @@ proc expr(p: BProc, e: PNode, d: var TLoc) =
|
|||
putIntoDest(p, d, e.typ, toRope(sym.position))
|
||||
of skVar, skResult:
|
||||
if sfGlobal in sym.flags: genVarPrototype(p.module, sym)
|
||||
if ((sym.loc.r == nil) or (sym.loc.t == nil)):
|
||||
if sym.loc.r == nil or sym.loc.t == nil:
|
||||
InternalError(e.info, "expr: var not init " & sym.name.s)
|
||||
if sfThreadVar in sym.flags:
|
||||
AccessThreadLocalVar(p, sym)
|
||||
|
|
@ -1803,7 +1796,7 @@ proc expr(p: BProc, e: PNode, d: var TLoc) =
|
|||
genCall(p, e, d)
|
||||
of nkCurly: genSetConstr(p, e, d)
|
||||
of nkBracket:
|
||||
if (skipTypes(e.typ, abstractVarRange).kind == tySequence):
|
||||
if skipTypes(e.typ, abstractVarRange).kind == tySequence:
|
||||
genSeqConstr(p, e, d)
|
||||
else:
|
||||
genArrayConstr(p, e, d)
|
||||
|
|
|
|||
|
|
@ -489,13 +489,16 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
|
|||
InternalError(a.info, "semTypeSection: containerID")
|
||||
s.typ.containerID = getID()
|
||||
a.sons[1] = semGenericParamList(c, a.sons[1], s.typ)
|
||||
s.typ.size = -1 # could not be computed properly
|
||||
# we fill it out later. For magic generics like 'seq', it won't be filled
|
||||
# so we use tyEmpty instead of nil to not crash for strange conversions
|
||||
# like: mydata.seq
|
||||
addSon(s.typ, newTypeS(tyEmpty, c))
|
||||
s.ast = a
|
||||
var body = semTypeNode(c, a.sons[2], nil)
|
||||
if body != nil: body.sym = s
|
||||
if body != nil:
|
||||
body.sym = s
|
||||
body.size = -1 # could not be computed properly
|
||||
s.typ.sons[sonsLen(s.typ) - 1] = body
|
||||
popOwner()
|
||||
closeScope(c.tab)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@
|
|||
|
||||
import ast, astalgo, msgs, types, semdata
|
||||
|
||||
proc checkPartialConstructedType(info: TLineInfo, t: PType) =
|
||||
if tfAcyclic in t.flags and skipTypes(t, abstractInst).kind != tyObject:
|
||||
LocalError(info, errInvalidPragmaX, "acyclic")
|
||||
elif t.kind == tyVar and t.sons[0].kind == tyVar:
|
||||
LocalError(info, errVarVarTypeNotAllowed)
|
||||
|
||||
proc checkConstructedType*(info: TLineInfo, t: PType) =
|
||||
if tfAcyclic in t.flags and skipTypes(t, abstractInst).kind != tyObject:
|
||||
LocalError(info, errInvalidPragmaX, "acyclic")
|
||||
|
|
@ -22,7 +28,7 @@ proc checkConstructedType*(info: TLineInfo, t: PType) =
|
|||
if t.kind == tyObject and t.sons[0] != nil:
|
||||
if t.sons[0].kind != tyObject or tfFinal in t.sons[0].flags:
|
||||
localError(info, errInheritanceOnlyWithNonFinalObjects)
|
||||
|
||||
|
||||
proc containsGenericTypeIter(t: PType, closure: PObject): bool =
|
||||
result = t.kind in GenericTypes
|
||||
|
||||
|
|
@ -121,10 +127,10 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
|
|||
var newbody = ReplaceTypeVarsT(cl, lastSon(body))
|
||||
newbody.flags = newbody.flags + t.flags + body.flags
|
||||
newbody.n = ReplaceTypeVarsN(cl, lastSon(body).n)
|
||||
addSon(result, newbody)
|
||||
addSon(result, newbody)
|
||||
#writeln(output, ropeToStr(Typetoyaml(newbody)));
|
||||
checkConstructedType(cl.info, newbody)
|
||||
|
||||
checkPartialConstructedType(cl.info, newbody)
|
||||
|
||||
proc ReplaceTypeVarsT*(cl: var TReplTypeVars, t: PType): PType =
|
||||
result = t
|
||||
if t == nil: return
|
||||
|
|
@ -139,6 +145,7 @@ proc ReplaceTypeVarsT*(cl: var TReplTypeVars, t: PType): PType =
|
|||
else:
|
||||
if containsGenericType(t):
|
||||
result = copyType(t, t.owner, false)
|
||||
result.size = -1 # needs to be recomputed
|
||||
for i in countup(0, sonsLen(result) - 1):
|
||||
result.sons[i] = ReplaceTypeVarsT(cl, result.sons[i])
|
||||
result.n = ReplaceTypeVarsN(cl, result.n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue