Commit 4fd787f5

4fd787f5c6d5Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified

Description

Add LINE, FILE, defined?, fix nil literal

  • PM_SOURCE_LINE_NODE → line number constant
  • PM_SOURCE_FILE_NODE → filename string
  • PM_DEFINED_NODE → compile-time variable existence check
  • nil literal now generates 0 /* nil */ (valid C expression)

Category 7 (control flow) — partial. Remaining: catch/throw, method.

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
4fd787f5c6d5
Parent
550261d75077

examples/bm_control.rbaddedView file

1+# Test control flow additions
2+
3+# __LINE__
4+puts __LINE__ # 4
5+
6+# defined? on known variable
7+x = 42
8+puts defined?(x) ? "yes" : "no" # yes
9+
10+# String freeze (no-op in AOT)
11+s = "hello"
12+puts s # hello
13+
14+# Modifier if/unless
15+y = 10
16+puts "big" if y > 5 # big
17+puts "small" unless y > 100 # small
18+
19+# Ternary chains
20+a = 3
21+puts(a == 1 ? "one" : a == 2 ? "two" : a == 3 ? "three" : "other") # three
22+
23+puts "done"