shape_jit/ffi/call_method/
object.rs1use crate::ffi::jit_kinds::*;
9use crate::ffi::value_ffi::*;
10use std::collections::HashMap;
11
12#[inline(always)]
14pub fn call_object_method(receiver_bits: u64, method_name: &str, args: &[u64]) -> u64 {
15 unsafe {
16 if !is_heap_kind(receiver_bits, HK_JIT_OBJECT) {
17 return TAG_NULL;
18 }
19 let obj = unified_unbox::<HashMap<String, u64>>(receiver_bits);
20
21 match method_name {
22 "hasOwnProperty" | "has" => {
23 if args.is_empty() {
24 return TAG_BOOL_FALSE;
25 }
26 if is_heap_kind(args[0], HK_STRING) {
27 let key = unbox_string(args[0]);
28 if obj.contains_key(key) {
29 return TAG_BOOL_TRUE;
30 }
31 }
32 TAG_BOOL_FALSE
33 }
34 "length" | "len" => box_number(obj.len() as f64),
35 "mean" | "sum" | "min" | "max" | "std" => {
37 if let Some(&type_bits) = obj.get("__type") {
39 if is_heap_kind(type_bits, HK_STRING) {
40 let type_str = unbox_string(type_bits);
41 if type_str == "RollingWindow" {
42 let series_bits = obj.get("series").copied().unwrap_or(TAG_NULL);
44 let window_bits = obj.get("window").copied().unwrap_or(TAG_NULL);
45
46 if is_heap_kind(series_bits, HK_COLUMN_REF) && is_number(window_bits) {
47 let _ = (series_bits, window_bits, method_name);
49 return TAG_NULL;
50 }
51 }
52 }
53 }
54 TAG_NULL
55 }
56 "filter_by" => TAG_NULL,
58 "group_by_month" => TAG_NULL,
59 _ => TAG_NULL,
60 }
61 }
62}