* fix #16428 vmops now works for generic procs * remove duplication
This commit is contained in:
parent
297c8e403d
commit
bc84d9c8cb
3 changed files with 8 additions and 10 deletions
|
|
@ -1954,14 +1954,6 @@ proc genProc*(c: PCtx; s: PSym): int
|
||||||
|
|
||||||
proc matches(s: PSym; x: string): bool =
|
proc matches(s: PSym; x: string): bool =
|
||||||
let y = x.split('.')
|
let y = x.split('.')
|
||||||
var s = s
|
|
||||||
for i in 1..y.len:
|
|
||||||
if s == nil or (y[^i].cmpIgnoreStyle(s.name.s) != 0 and y[^i] != "*"):
|
|
||||||
return false
|
|
||||||
s = s.owner
|
|
||||||
result = true
|
|
||||||
|
|
||||||
proc matches(s: PSym; y: varargs[string]): bool =
|
|
||||||
var s = s
|
var s = s
|
||||||
for i in 1..y.len:
|
for i in 1..y.len:
|
||||||
if s == nil or (y[^i].cmpIgnoreStyle(s.name.s) != 0 and y[^i] != "*"):
|
if s == nil or (y[^i].cmpIgnoreStyle(s.name.s) != 0 and y[^i] != "*"):
|
||||||
|
|
@ -2024,11 +2016,11 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) =
|
||||||
elif s.kind == skMethod:
|
elif s.kind == skMethod:
|
||||||
localError(c.config, n.info, "cannot call method " & s.name.s &
|
localError(c.config, n.info, "cannot call method " & s.name.s &
|
||||||
" at compile time")
|
" at compile time")
|
||||||
elif matches(s, "stdlib", "marshal", "to"):
|
elif matches(s, "stdlib.marshal.to"):
|
||||||
# XXX marshal load&store should not be opcodes, but use the
|
# XXX marshal load&store should not be opcodes, but use the
|
||||||
# general callback mechanisms.
|
# general callback mechanisms.
|
||||||
genMarshalLoad(c, n, dest)
|
genMarshalLoad(c, n, dest)
|
||||||
elif matches(s, "stdlib", "marshal", "$$"):
|
elif matches(s, "stdlib.marshal.$$"):
|
||||||
genMarshalStore(c, n, dest)
|
genMarshalStore(c, n, dest)
|
||||||
else:
|
else:
|
||||||
genCall(c, n, dest)
|
genCall(c, n, dest)
|
||||||
|
|
|
||||||
|
|
@ -567,6 +567,8 @@ else: # JS
|
||||||
func tanh*[T: float32|float64](x: T): T {.importc: "Math.tanh", nodecl.}
|
func tanh*[T: float32|float64](x: T): T {.importc: "Math.tanh", nodecl.}
|
||||||
|
|
||||||
func arcsin*[T: float32|float64](x: T): T {.importc: "Math.asin", nodecl.}
|
func arcsin*[T: float32|float64](x: T): T {.importc: "Math.asin", nodecl.}
|
||||||
|
# keep this as generic or update test in `tvmops.nim` to make sure we
|
||||||
|
# keep testing that generic importc procs work
|
||||||
func arccos*[T: float32|float64](x: T): T {.importc: "Math.acos", nodecl.}
|
func arccos*[T: float32|float64](x: T): T {.importc: "Math.acos", nodecl.}
|
||||||
func arctan*[T: float32|float64](x: T): T {.importc: "Math.atan", nodecl.}
|
func arctan*[T: float32|float64](x: T): T {.importc: "Math.atan", nodecl.}
|
||||||
func arctan2*[T: float32|float64](y, x: T): T {.importc: "Math.atan2", nodecl.}
|
func arctan2*[T: float32|float64](y, x: T): T {.importc: "Math.atan2", nodecl.}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
discard """
|
||||||
|
targets: "c cpp js"
|
||||||
|
"""
|
||||||
|
|
||||||
#[
|
#[
|
||||||
test for vmops.nim
|
test for vmops.nim
|
||||||
]#
|
]#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue