Commit 82fd1f66
82fd1f66f8b4Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified
Description
Add alias method support
PM_ALIAS_METHOD_NODE in class bodies: copies method entry with new name. Alias'd methods share the same body AST — getter/setter inlining preserved.
Comparable (step 5) and Range-as-object (step 6) deferred:
- Operator method names (<, >, <=>) need C identifier sanitization
- Range objects need a sp_Range struct Both are better addressed with sp_RbValue (polymorphism phase).
Test: examples/bm_comparable.rb — alias greet hello.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 82fd1f66f8b4
- Parent
- bad9ff363c9b
examples/bm_comparable.rbaddedView file
1+
# Test alias2+
3+
class Greeter4+
def initialize(name)5+
@name = name6+
end7+
8+
def name9+
@name10+
end11+
12+
def hello13+
@name14+
end15+
16+
alias greet hello17+
end18+
19+
g = Greeter.new("world")20+
puts g.hello # world21+
puts g.greet # world (alias of hello)22+
puts g.name # world23+
24+
puts "done"src/codegen.cmodifiedView file
Loading diff…