implemented 'R ptr T' syntax
This commit is contained in:
parent
2e9950afe8
commit
d96f25619a
4 changed files with 17 additions and 11 deletions
|
|
@ -220,7 +220,7 @@ proc getPrecedence(tok: TToken, strongSpaces: bool): int =
|
|||
of tkIn, tkNotin, tkIs, tkIsnot, tkNot, tkOf, tkAs: result = 5
|
||||
of tkDotDot: result = considerStrongSpaces(6)
|
||||
of tkAnd: result = 4
|
||||
of tkOr, tkXor: result = 3
|
||||
of tkOr, tkXor, tkPtr, tkRef: result = 3
|
||||
else: result = -10
|
||||
|
||||
proc isOperator(tok: TToken): bool =
|
||||
|
|
|
|||
|
|
@ -125,11 +125,12 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
|||
if n.len < 1:
|
||||
result = newConstraint(c, kind)
|
||||
else:
|
||||
let isCall = ord(n.kind in nkCallKinds)
|
||||
let n = if n[0].kind == nkBracket: n[0] else: n
|
||||
checkMinSonsLen(n, 1)
|
||||
result = newOrPrevType(kind, prev, c)
|
||||
# check every except the last is an object:
|
||||
for i in 0 .. n.len-2:
|
||||
for i in isCall .. n.len-2:
|
||||
let region = semTypeNode(c, n[i], nil)
|
||||
if region.skipTypes({tyGenericInst}).kind notin {tyError, tyObject}:
|
||||
message n[i].info, errGenerated, "region needs to be an object type"
|
||||
|
|
@ -1107,6 +1108,10 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
|||
result = makeNotType(c, negated)
|
||||
else:
|
||||
localError(n.info, errGenerated, "invalid type")
|
||||
elif op.id == ord(wPtr):
|
||||
result = semAnyRef(c, n, tyPtr, prev)
|
||||
elif op.id == ord(wRef):
|
||||
result = semAnyRef(c, n, tyRef, prev)
|
||||
else:
|
||||
result = semTypeExpr(c, n)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue