16af3ae9fc
This commit updates all example files to use `assert_eq!` for verifying output, replacing the previous `Output:` comments. This change makes the examples more robust and self-testing. The benchmark results in some examples have also been slightly adjusted, reflecting minor performance variations after the refactoring. Additionally, a runtime panic handling mechanism has been introduced in the VM for function calls, which improves error reporting for unexpected panics.
26 lines
592 B
Plaintext
26 lines
592 B
Plaintext
;; Benchmark: 211ns
|
|
;; Benchmark-Repeat: 9558
|
|
;; examples/def_local_inlining.myc
|
|
;; Demonstrates potential for DefLocal-Inlining (Phase 2.5)
|
|
|
|
(fn []
|
|
(do
|
|
;; 1. Simple constant propagation
|
|
(def x 10)
|
|
(def y 20)
|
|
|
|
;; Expected optimization: (+ 10 20) -> 30
|
|
(def z (+ x y))
|
|
|
|
;; 2. Tracking assignments (Assign-Safety)
|
|
;; Inlining must be careful with 'assign'.
|
|
(def result
|
|
(do
|
|
(def a 100)
|
|
(assign a 200)
|
|
;; Expected optimization: 200
|
|
a))
|
|
|
|
;; 3. Return a tuple of optimized results
|
|
[z result]))
|