fixes ttypeselectors

This commit is contained in:
Zahary Karadjov
2012-09-28 14:30:19 +03:00
parent 95cf849954
commit 2aabae702d
3 changed files with 14 additions and 8 deletions

View File

@@ -114,6 +114,16 @@ proc semConstExpr(c: PContext, n: PNode): PNode =
include hlo, seminst, semcall
proc symFromType(t: PType, info: TLineInfo): PSym =
if t.sym != nil: return t.sym
result = newSym(skType, getIdent"AnonType", t.owner, info)
result.flags.incl sfAnon
result.typ = t
proc symNodeFromType(c: PContext, t: PType, info: TLineInfo): PNode =
result = newSymNode(symFromType(t, info), info)
result.typ = makeTypeDesc(c, t)
proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode =
inc(evalTemplateCounter)
if evalTemplateCounter > 100:
@@ -133,7 +143,8 @@ proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode =
result = semStmt(c, result)
of tyTypeDesc:
if n.kind == nkStmtList: result.kind = nkStmtListType
result.typ = semTypeNode(c, result, nil)
var typ = semTypeNode(c, result, nil)
result = symNodeFromType(c, typ, n.info)
else:
result = semExpr(c, result)
result = fitNode(c, s.typ.sons[0], result)

View File

@@ -1573,11 +1573,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
result = semExpr(c, n.sons[0], flags)
of nkTypeOfExpr:
var typ = semTypeNode(c, n, nil).skipTypes({tyTypeDesc})
typ = makeTypedesc(c, typ)
var sym = newSym(skType, getIdent"TypeOfExpr",
typ.owner, n.info).linkTo(typ)
sym.flags.incl(sfAnon)
result = newSymNode(sym, n.info)
result = symNodeFromType(c, typ, n.info)
of nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit:
# check if it is an expression macro:
checkMinSonsLen(n, 1)

View File

@@ -9,8 +9,7 @@ template selectType(x: int): typeDesc =
template simpleTypeTempl: typeDesc =
string
macro typeFromMacro(s: expr): typeDesc =
result = newIdentNode"string"
macro typeFromMacro: typedesc = string
proc t1*(x: int): simpleTypeTempl() =
result = "test"