embedded.nim 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. when not gotoBasedExceptions:
  18. proc pushSafePoint(s: PSafePoint) {.compilerRtl, inl.} = discard
  19. proc popSafePoint {.compilerRtl, inl.} = discard
  20. proc pushCurrentException(e: ref Exception) {.compilerRtl, inl.} = discard
  21. proc popCurrentException {.compilerRtl, inl.} = discard
  22. # some platforms have native support for stack traces:
  23. const
  24. nativeStackTraceSupported = false
  25. hasSomeStackTrace = false
  26. proc quitOrDebug() {.noreturn, importc: "abort", header: "<stdlib.h>", nodecl.}
  27. proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
  28. sysFatal(ReraiseDefect, "exception handling is not available")
  29. proc raiseExceptionEx(e: sink(ref Exception), ename, procname, filename: cstring,
  30. line: int) {.compilerRtl.} =
  31. sysFatal(ReraiseDefect, "exception handling is not available")
  32. proc reraiseException() {.compilerRtl.} =
  33. sysFatal(ReraiseDefect, "no exception to reraise")
  34. proc writeStackTrace() = discard
  35. proc unsetControlCHook() = discard
  36. proc setControlCHook(hook: proc () {.noconv.}) = discard
  37. proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} =
  38. sysFatal(ReraiseDefect, "exception handling is not available")
  39. when gotoBasedExceptions:
  40. var nimInErrorMode {.threadvar.}: bool
  41. proc nimErrorFlag(): ptr bool {.compilerRtl, inl.} =
  42. result = addr(nimInErrorMode)
  43. proc nimTestErrorFlag() {.compilerRtl.} =
  44. if nimInErrorMode:
  45. sysFatal(ReraiseDefect, "exception handling is not available")