(_state: &mut State<'gc>, args: Vec<Value<'gc>>)
| 134 | } |
| 135 | |
| 136 | fn len<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> { |
| 137 | if args.len() != 1 { |
| 138 | return Err(VmError::RuntimeError( |
| 139 | "len() takes exactly one argument.".into(), |
| 140 | )); |
| 141 | } |
| 142 | |
| 143 | match &args[0] { |
| 144 | Value::String(s) => Ok(Value::Number(s.len() as f64)), |
| 145 | Value::IoString(s) => Ok(Value::Number(s.len() as f64)), |
| 146 | Value::List(arr) => Ok(Value::Number(arr.borrow().data.len() as f64)), |
| 147 | Value::Object(obj) => Ok(Value::Number(obj.borrow().fields.len() as f64)), |
| 148 | _ => Err(VmError::RuntimeError( |
| 149 | "len() argument must be a string, array or object.".into(), |
| 150 | )), |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | fn any<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> { |
| 155 | if args.len() != 1 { |
nothing calls this directly
no test coverage detected