feat(joinir): Phase 224-C - MethodCallLowerer with argument support
- Add StringIndexOf to CoreMethodId (arity=1, return IntegerBox) - Extend MethodCallLowerer to handle methods with arguments - Add arity checking against CoreMethodId metadata - Recursive argument lowering via lower_value_expression - 8 unit tests PASS (indexOf, substring, arity mismatch) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -166,6 +166,7 @@ pub enum CoreMethodId {
|
||||
StringLower,
|
||||
StringConcat,
|
||||
StringSubstring,
|
||||
StringIndexOf,
|
||||
StringReplace,
|
||||
StringTrim,
|
||||
StringSplit,
|
||||
@ -213,8 +214,8 @@ impl CoreMethodId {
|
||||
use CoreMethodId::*;
|
||||
match self {
|
||||
StringLength | StringUpper | StringLower |
|
||||
StringConcat | StringSubstring | StringReplace |
|
||||
StringTrim | StringSplit => CoreBoxId::String,
|
||||
StringConcat | StringSubstring | StringIndexOf |
|
||||
StringReplace | StringTrim | StringSplit => CoreBoxId::String,
|
||||
|
||||
IntegerAbs | IntegerMin | IntegerMax => CoreBoxId::Integer,
|
||||
|
||||
@ -241,6 +242,7 @@ impl CoreMethodId {
|
||||
StringLower => "lower",
|
||||
StringConcat => "concat",
|
||||
StringSubstring => "substring",
|
||||
StringIndexOf => "indexOf",
|
||||
StringReplace => "replace",
|
||||
StringTrim => "trim",
|
||||
StringSplit => "split",
|
||||
@ -287,7 +289,7 @@ impl CoreMethodId {
|
||||
MapKeys |
|
||||
ResultIsOk | ResultGetValue => 0,
|
||||
|
||||
StringConcat | StringSubstring | StringReplace | StringSplit |
|
||||
StringConcat | StringIndexOf | StringReplace | StringSplit |
|
||||
IntegerMin | IntegerMax |
|
||||
BoolAnd | BoolOr |
|
||||
ArrayGet | ArrayPush |
|
||||
@ -295,7 +297,7 @@ impl CoreMethodId {
|
||||
ConsolePrintln | ConsoleLog | ConsoleError |
|
||||
FileRead | FileWrite | FileOpen => 1,
|
||||
|
||||
MapSet => 2,
|
||||
StringSubstring | MapSet => 2,
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +305,7 @@ impl CoreMethodId {
|
||||
pub fn return_type_name(&self) -> &'static str {
|
||||
use CoreMethodId::*;
|
||||
match self {
|
||||
StringLength | ArrayLength => "IntegerBox",
|
||||
StringLength | StringIndexOf | ArrayLength => "IntegerBox",
|
||||
|
||||
StringUpper | StringLower | StringConcat | StringSubstring |
|
||||
StringReplace | StringTrim => "StringBox",
|
||||
@ -329,7 +331,7 @@ impl CoreMethodId {
|
||||
use CoreMethodId::*;
|
||||
[
|
||||
StringLength, StringUpper, StringLower, StringConcat, StringSubstring,
|
||||
StringReplace, StringTrim, StringSplit,
|
||||
StringIndexOf, StringReplace, StringTrim, StringSplit,
|
||||
IntegerAbs, IntegerMin, IntegerMax,
|
||||
BoolNot, BoolAnd, BoolOr,
|
||||
ArrayLength, ArrayPush, ArrayPop, ArrayGet,
|
||||
@ -360,8 +362,8 @@ impl CoreMethodId {
|
||||
match self {
|
||||
// String methods (pure - return new values, don't mutate)
|
||||
StringLength | StringUpper | StringLower |
|
||||
StringConcat | StringSubstring | StringReplace |
|
||||
StringTrim | StringSplit => true,
|
||||
StringConcat | StringSubstring | StringIndexOf |
|
||||
StringReplace | StringTrim | StringSplit => true,
|
||||
|
||||
// Integer/Bool methods (pure - mathematical operations)
|
||||
IntegerAbs | IntegerMin | IntegerMax |
|
||||
@ -407,7 +409,7 @@ impl CoreMethodId {
|
||||
|
||||
// Not yet whitelisted - be conservative
|
||||
StringUpper | StringLower | StringConcat |
|
||||
StringSubstring | StringReplace | StringTrim | StringSplit => false,
|
||||
StringSubstring | StringIndexOf | StringReplace | StringTrim | StringSplit => false,
|
||||
|
||||
IntegerAbs | IntegerMin | IntegerMax => false,
|
||||
BoolNot | BoolAnd | BoolOr => false,
|
||||
@ -431,7 +433,7 @@ impl CoreMethodId {
|
||||
use CoreMethodId::*;
|
||||
match self {
|
||||
// String operations - allowed
|
||||
StringLength | StringSubstring => true,
|
||||
StringLength | StringSubstring | StringIndexOf => true,
|
||||
|
||||
// String transformations - allowed for init
|
||||
StringUpper | StringLower | StringTrim => true,
|
||||
|
||||
Reference in New Issue
Block a user