Skip to content

Commit

Permalink
note plan for pragma.singlePragma
Browse files Browse the repository at this point in the history
- this is the next "big" nkError thing to fix
- see plan in the new proc `prepareSinglePragma`
  • Loading branch information
saem committed Nov 2, 2021
1 parent d0f63d2 commit d2368ef
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ proc processDynLib(c: PContext, n: PNode, sym: PSym) =
proc processNote(c: PContext, n: PNode) =
template handleNote(enumVals, notes) =
let x = findStr(enumVals.a, enumVals.b, n[0][1].ident.s, errUnknown)
if x != errUnknown:
if x != errUnknown:
nk = TNoteKind(x)
let x = c.semConstBoolExpr(c, n[1])
n[1] = x
Expand Down Expand Up @@ -762,8 +762,10 @@ proc semCustomPragma(c: PContext, n: PNode): PNode =
elif n.kind in nkPragmaCallKinds:
callNode = n
else:
invalidPragma(c, n)
return n
result = newError(c, n, InvalidPragma)
return
# invalidPragma(c, n)
# return n

let r = c.semOverloadedCall(c, callNode, n, {skTemplate}, {efNoUndeclared})
if r.isNil or sfCustomPragma notin r[0].sym.flags:
Expand Down Expand Up @@ -801,6 +803,20 @@ proc processEffectsOf(c: PContext, n: PNode; owner: PSym) =
else:
processParam(c, it)

proc prepareSinglePragma(
c: PContext; sym: PSym, n: PNode, i: var int, validPragmas: TSpecialWords,
comesFromPush, isStatement: bool
): PNode =
## xxx: implement me, replacing `singlePragma`:
## - return nil if not a single pragma
## - return an nkError if `invalidPragma` would have been called
## - return the pragma after prep and it's good to go
## - all the localErrors and what not should be nkErrors
## - see if there is a better name than `prepareSinglePragma`
## - replace all usages of `singlePragma`
## - have a nice day
result = nil

proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
validPragmas: TSpecialWords,
comesFromPush, isStatement: bool): bool =
Expand Down Expand Up @@ -1313,8 +1329,7 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords;
# XXX: in the case of a callable def, this should use its info
implicitPragmas(c, sym, n.info, validPragmas)

proc pragmaCallable*(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords,
isStatement: bool = false) =
proc pragmaCallable*(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
if n == nil: return
if n[pragmasPos].kind != nkEmpty:
pragmaRec(c, sym, n[pragmasPos], validPragmas, isStatement)
pragmaRec(c, sym, n[pragmasPos], validPragmas, false)

0 comments on commit d2368ef

Please sign in to comment.