Commit 488ab2c0
488ab2c05a5fMerged
Ryan Seys <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified
Description
feat(analyze,codegen): trap accepts Signal receiver and expr position
Extend the trap no-op stub to the CRuby-equivalent shapes that
previously errored at compile time, and return a value-typed
placeholder for expression position.
- analyze infer_call_type:
trapreturns "string" so callers likeprev = trap("INT") { }infer prev as a string-typed local. - codegen trap_call_is_signal_stub: match implicit-self,
ConstantReadNode("Signal"), and toplevel ConstantPathNode
(
::Signal) with tailSignal. RejectFoo::Signal.trap-- different module. - codegen compile_call_expr: emit SPL("DEFAULT") so the expr-form return matches CRuby's first-call value for any unset signal. Spinel does not track per-signal state so subsequent calls also return "DEFAULT"; full state tracking is deferred to a follow-up.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 488ab2c05a5f
- Parent
- 097825fd48d1
spinel_analyze.rbmodifiedView file
@@ -3200,6 +3200,11 @@
32003200
if mname == "system"32013201
return "bool"32023202
end3203+
# trap / Signal.trap stub returns the previous-handler string;3204+
# codegen emits SPL("DEFAULT") since per-signal state is not tracked.3205+
if mname == "trap"3206+
return "string"3207+
end32033208
32043209
# Constructor .new32053210
r = infer_constructor_type(nid, mname, recv)spinel_codegen.rbmodifiedView file
Loading diff…
test/signal_trap_stub.rbaddedView file
Loading diff…
test/signal_trap_stub.rb.expectedaddedView file
Loading diff…