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 alias
2+
3+class Greeter
4+ def initialize(name)
5+ @name = name
6+ end
7+
8+ def name
9+ @name
10+ end
11+
12+ def hello
13+ @name
14+ end
15+
16+ alias greet hello
17+end
18+
19+g = Greeter.new("world")
20+puts g.hello # world
21+puts g.greet # world (alias of hello)
22+puts g.name # world
23+
24+puts "done"