From d2368efc799c3f9e81ab1caba1608f1fcd6ef8dd Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Mon, 1 Nov 2021 21:26:31 -0700 Subject: [PATCH] note plan for `pragma.singlePragma` - this is the next "big" nkError thing to fix - see plan in the new proc `prepareSinglePragma` --- compiler/pragmas.nim | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 2cbcbd227f9..fe28e1b4758 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -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 @@ -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: @@ -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 = @@ -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)