astToStr is now immediate
This commit is contained in:
parent
fa062ca0c4
commit
4308f32255
4 changed files with 28 additions and 6 deletions
|
|
@ -524,6 +524,8 @@ type
|
||||||
PType* = ref TType
|
PType* = ref TType
|
||||||
PSym* = ref TSym
|
PSym* = ref TSym
|
||||||
TNode*{.final, acyclic.} = object # on a 32bit machine, this takes 32 bytes
|
TNode*{.final, acyclic.} = object # on a 32bit machine, this takes 32 bytes
|
||||||
|
when defined(useNodeIds):
|
||||||
|
id*: int
|
||||||
typ*: PType
|
typ*: PType
|
||||||
comment*: string
|
comment*: string
|
||||||
info*: TLineInfo
|
info*: TLineInfo
|
||||||
|
|
@ -917,6 +919,10 @@ proc copyObjectSet(dest: var TObjectSet, src: TObjectSet) =
|
||||||
proc discardSons(father: PNode) =
|
proc discardSons(father: PNode) =
|
||||||
father.sons = nil
|
father.sons = nil
|
||||||
|
|
||||||
|
when defined(useNodeIds):
|
||||||
|
const nodeIdToDebug = 140600
|
||||||
|
var gNodeId: int
|
||||||
|
|
||||||
proc newNode(kind: TNodeKind): PNode =
|
proc newNode(kind: TNodeKind): PNode =
|
||||||
new(result)
|
new(result)
|
||||||
result.kind = kind
|
result.kind = kind
|
||||||
|
|
@ -924,6 +930,11 @@ proc newNode(kind: TNodeKind): PNode =
|
||||||
result.info.fileIndex = int32(- 1)
|
result.info.fileIndex = int32(- 1)
|
||||||
result.info.col = int16(- 1)
|
result.info.col = int16(- 1)
|
||||||
result.info.line = int16(- 1)
|
result.info.line = int16(- 1)
|
||||||
|
when defined(useNodeIds):
|
||||||
|
result.id = gNodeId
|
||||||
|
if result.id == nodeIdToDebug:
|
||||||
|
writeStackTrace()
|
||||||
|
inc gNodeId
|
||||||
|
|
||||||
proc newIntNode(kind: TNodeKind, intVal: BiggestInt): PNode =
|
proc newIntNode(kind: TNodeKind, intVal: BiggestInt): PNode =
|
||||||
result = newNode(kind)
|
result = newNode(kind)
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,7 @@ proc PragmaWatchpoint(c: PContext, n: PNode) =
|
||||||
proc semAsmOrEmit*(con: PContext, n: PNode, marker: char): PNode =
|
proc semAsmOrEmit*(con: PContext, n: PNode, marker: char): PNode =
|
||||||
case n.sons[1].kind
|
case n.sons[1].kind
|
||||||
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
||||||
result = copyNode(n)
|
result = newNode(if n.kind == nkAsmStmt: nkAsmStmt else: nkArgList, n.info)
|
||||||
var str = n.sons[1].strVal
|
var str = n.sons[1].strVal
|
||||||
if str == "":
|
if str == "":
|
||||||
LocalError(n.info, errEmptyAsm)
|
LocalError(n.info, errEmptyAsm)
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,19 @@ proc typeMismatch(n: PNode, formal, actual: PType) =
|
||||||
`%`(msgKindToString(errButExpectedX), [typeToString(formal)]))
|
`%`(msgKindToString(errButExpectedX), [typeToString(formal)]))
|
||||||
|
|
||||||
proc fitNode(c: PContext, formal: PType, arg: PNode): PNode =
|
proc fitNode(c: PContext, formal: PType, arg: PNode): PNode =
|
||||||
result = IndexTypesMatch(c, formal, arg.typ, arg)
|
if arg.typ.isNil:
|
||||||
if result == nil:
|
LocalError(arg.info, errExprXHasNoType,
|
||||||
typeMismatch(arg, formal, arg.typ)
|
renderTree(arg, {renderNoComments}))
|
||||||
# error correction:
|
# error correction:
|
||||||
result = copyNode(arg)
|
result = copyNode(arg)
|
||||||
result.typ = formal
|
result.typ = formal
|
||||||
|
else:
|
||||||
|
result = IndexTypesMatch(c, formal, arg.typ, arg)
|
||||||
|
if result == nil:
|
||||||
|
typeMismatch(arg, formal, arg.typ)
|
||||||
|
# error correction:
|
||||||
|
result = copyNode(arg)
|
||||||
|
result.typ = formal
|
||||||
|
|
||||||
var CommonTypeBegin = PType(kind: tyExpr)
|
var CommonTypeBegin = PType(kind: tyExpr)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1441,6 +1441,10 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||||
of mShallowCopy: result = semShallowCopy(c, n, flags)
|
of mShallowCopy: result = semShallowCopy(c, n, flags)
|
||||||
of mExpandToAst: result = semExpandToAst(c, n, s, flags)
|
of mExpandToAst: result = semExpandToAst(c, n, s, flags)
|
||||||
of mQuoteAst: result = semQuoteAst(c, n)
|
of mQuoteAst: result = semQuoteAst(c, n)
|
||||||
|
of mAstToStr:
|
||||||
|
checkSonsLen(n, 2)
|
||||||
|
result = newStrNodeT(renderTree(n[1], {renderNoComments}), n)
|
||||||
|
result.typ = getSysType(tyString)
|
||||||
else: result = semDirectOp(c, n, flags)
|
else: result = semDirectOp(c, n, flags)
|
||||||
|
|
||||||
proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
|
proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue