mfichman / jogo

High(er) performance compiled programming language with clean, powerful syntax
MIT License
6 stars 1 forks source link

Coroutine cleanup/initial destructor work #43

Closed mfichman closed 12 years ago

mfichman commented 12 years ago

Reserve a global (or thread-local) variable to store a pointer to the current exception. Analyze to determine if a function can throw an exception:

  1. Set can_throw = false initially (true if there is a throw statement)
  2. Compute can_throw for child functions
  3. If a child can throw, set can_throw = false
  4. Use an enum: can_throw = true | false | undef

If a function can_throw, then generate an if block after the call to check if current_exception is non-null. If it is, then cleanup, and jump to the finally or catch if there is one; otherwise, return garbage to rax and leave current_exception set.

Justification for this plan (vs. a table-driven exception handling scheme like C++ has):

To start, do not support try/throw/catch. Just mark yield as 'can_throw', and then perform can_throw analysis and add error-checking if blocks.

mfichman commented 12 years ago

Done.