Added complete call-seq documentation for catch/throw functionality across
both Ruby and C implementations:
- Class documentation: explains exception raised for unmatched throws
- initialize: constructor with tag and value parameters, creates error
message with proper tag inspection and stores thrown values for debugging
- throw: transfers control to matching catch block with optional return value,
raises UncaughtThrowError if no matching catch found, supports both
single tag and tag+value forms with comprehensive usage examples
- find_catcher: searches call stack for matching catch block by comparing
tags using mrb_obj_eq, returns call stack index or 0 if not found
- catch_syms: pre-defined symbols (Object, new, call) used by catch bytecode
implementation for efficient symbol lookup
- catch_iseq: bytecode instruction sequence implementing catch method logic,
handles default tag creation (Object.new) and block parameter passing
- catch_irep: instruction representation containing bytecode metadata
for catch method execution
- catch_proc: procedure object used to identify catch blocks in call stack
during throw operations, marked with proper GC and scope flags
- mrb_mruby_catch_gem_init: defines catch and throw as private methods
in Kernel module, initializes symbols and sets up bytecode procedure
- mrb_mruby_catch_gem_final: cleanup function (currently no-op as
implementation uses static data structures)
Co-authored-by: Atlassian Rovo Dev
Static proc objects defined as methods may be placed in 4-byte alignments in 32-bit environments.
This may be misinterpreted as an immediate value depending on the address.
Since C11 and C++11 have additional language features for byte alignment, corresponding compilers use them to define the `mrb_alignas()` macro.
For earlier compilers, they use their own extensions to define the `mrb_alignas()` macro.
GCC supports `__attribute__((aligned(alignment)))` since at least version 2.95.3 (1999).
https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#IDX305
According to GPT-4, support was added in version 2.7 (1995).
It is not known which version of Visual C++ added support for `__declspec(align(n))`.
According to GPT-4, at least Visual C++ 6.0 (1998) seems to support it.
Also, the documentation of past Intel C/C++ compilers that support `__declspec(align(n))` makes reference to support with Visual C++ 4.2 (1996).
https://www.intel.com/content/dam/www/public/ijkk/jp/ja/documents/developer/ccomp40j.pdf
It is now possible to specify return destination directly.
This allows callinfo to distinguish between calls to the same proc object.
At the same time, the `Kernel#catch` method is adjusted.
By removing the previously required double lambda object, the REnv object is no longer created as well.
The following methods will be made static.
- `Class#new`
- `Proc#call`
- `Kernel#catch`
Previously, static const RProc could not be registered as a method, but this has been changed to allow it.