embedded.nim 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2012 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. # Bare-bones implementation of some things for embedded targets.
  10. proc chckIndx(i, a, b: int): int {.inline, compilerproc.}
  11. proc chckRange(i, a, b: int): int {.inline, compilerproc.}
  12. proc chckRangeF(x, a, b: float): float {.inline, compilerproc.}
  13. proc chckNil(p: pointer) {.inline, compilerproc.}
  14. proc nimFrame(s: PFrame) {.compilerRtl, inl, exportc: "nimFrame".} = discard
  15. proc popFrame {.compilerRtl, inl.} = discard
  16. proc setFrame(s: PFrame) {.compilerRtl, inl.} = discard
  17. proc pushSafePoint(s: PSafePoint) {.compilerRtl, inl.} = discard
  18. proc popSafePoint {.compilerRtl, inl.} = discard
  19. proc pushCurrentException(e: ref Exception) {.compilerRtl, inl.} = discard
  20. proc popCurrentException {.compilerRtl, inl.} = discard
  21. # some platforms have native support for stack traces:
  22. const
  23. nativeStackTraceSupported = false
  24. hasSomeStackTrace = false
  25. proc quitOrDebug() {.noreturn, importc: "abort", header: "<stdlib.h>", nodecl.}
  26. proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
  27. sysFatal(ReraiseDefect, "exception handling is not available")
  28. proc raiseExceptionEx(e: sink(ref Exception), ename, procname, filename: cstring,
  29. line: int) {.compilerRtl.} =
  30. sysFatal(ReraiseDefect, "exception handling is not available")
  31. proc reraiseException() {.compilerRtl.} =
  32. sysFatal(ReraiseDefect, "no exception to reraise")
  33. proc writeStackTrace() = discard
  34. proc unsetControlCHook() = discard
  35. proc setControlCHook(hook: proc () {.noconv.}) = discard
  36. proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} =
  37. sysFatal(ReraiseDefect, "exception handling is not available")
  38. when gotoBasedExceptions:
  39. var nimInErrorMode {.threadvar.}: bool
  40. proc nimErrorFlag(): ptr bool {.compilerRtl, inl.} =
  41. result = addr(nimInErrorMode)
  42. proc nimTestErrorFlag() {.compilerRtl.} =
  43. if nimInErrorMode:
  44. sysFatal(ReraiseDefect, "exception handling is not available")