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 additions2+
3+
# __LINE__4+
puts __LINE__ # 45+
6+
# defined? on known variable7+
x = 428+
puts defined?(x) ? "yes" : "no" # yes9+
10+
# String freeze (no-op in AOT)11+
s = "hello"12+
puts s # hello13+
14+
# Modifier if/unless15+
y = 1016+
puts "big" if y > 5 # big17+
puts "small" unless y > 100 # small18+
19+
# Ternary chains20+
a = 321+
puts(a == 1 ? "one" : a == 2 ? "two" : a == 3 ? "three" : "other") # three22+
23+
puts "done"src/codegen.cmodifiedView file
Loading diff…