mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-02 09:58:01 +00:00
type
This commit is contained in:
@@ -317,6 +317,6 @@ proc registerAdditionalOps*(c: PCtx) =
|
||||
setResult(a, (fn.typ != nil and tfNoSideEffect in fn.typ.flags) or
|
||||
(fn.kind == nkSym and fn.sym.kind == skFunc))
|
||||
|
||||
registerCallback c, "stdlib.effecttraits.hasClosureImpl", proc (a: VmArgs) =
|
||||
registerCallback c, "stdlib.typetraits.hasClosureImpl", proc (a: VmArgs) =
|
||||
let fn = getNode(a, 0)
|
||||
setResult(a, fn.kind == nkClosure or (fn.typ != nil and fn.typ.callConv == ccClosure))
|
||||
|
||||
@@ -263,3 +263,14 @@ since (1, 1):
|
||||
|
||||
type T2 = T
|
||||
genericParamsImpl(T2)
|
||||
|
||||
|
||||
proc hasClosureImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
|
||||
|
||||
proc hasClosure*(fn: NimNode): bool {.since: (1, 5, 1).} =
|
||||
## Return true if the func/proc/etc `fn` has `closure`.
|
||||
## `fn` has to be a resolved symbol of kind `nnkSym`. This
|
||||
## implies that the macro that calls this proc should accept `typed`
|
||||
## arguments and not `untyped` arguments.
|
||||
expectKind fn, nnkSym
|
||||
result = hasClosureImpl(fn)
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
## via `defined(nimHasEffectTraitsModule)`.
|
||||
|
||||
import std/macros
|
||||
import std/private/since
|
||||
|
||||
proc getRaisesListImpl(n: NimNode): NimNode = discard "see compiler/vmops.nim"
|
||||
proc getTagsListImpl(n: NimNode): NimNode = discard "see compiler/vmops.nim"
|
||||
proc isGcSafeImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
|
||||
proc hasNoSideEffectsImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
|
||||
proc hasClosureImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
|
||||
|
||||
proc getRaisesList*(fn: NimNode): NimNode =
|
||||
## Extracts the `.raises` list of the func/proc/etc `fn`.
|
||||
@@ -54,11 +52,3 @@ proc hasNoSideEffects*(fn: NimNode): bool =
|
||||
## arguments and not `untyped` arguments.
|
||||
expectKind fn, nnkSym
|
||||
result = hasNoSideEffectsImpl(fn)
|
||||
|
||||
proc hasClosure*(fn: NimNode): bool {.since: (1, 5, 1).} =
|
||||
## Return true if the func/proc/etc `fn` has `closure`.
|
||||
## `fn` has to be a resolved symbol of kind `nnkSym`. This
|
||||
## implies that the macro that calls this proc should accept `typed`
|
||||
## arguments and not `untyped` arguments.
|
||||
expectKind fn, nnkSym
|
||||
result = hasClosureImpl(fn)
|
||||
|
||||
@@ -2,7 +2,7 @@ discard """
|
||||
targets: "c cpp js"
|
||||
"""
|
||||
|
||||
import std/effecttraits
|
||||
import std/typetraits
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user