pub fn core_m(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "m requires two arguments");
            return 0;
        }

        let regex_rr = self.stack.pop().unwrap();
        let regex_str_rr_opt = to_string_value(regex_rr);
        if regex_str_rr_opt.is_none() {
            print_error(chunk, i, "regex must be a string");
            return 0;
        }
        let regex_str_rr = regex_str_rr_opt.unwrap();

        {
            let mut regex_str_rrb = regex_str_rr.borrow_mut();
            let res = regex_str_rrb.gen_regex(chunk, i);
            if !res {
                return 0;
            }
        }
        let regex_str_rrb = regex_str_rr.borrow();
        let regex_opt = regex_str_rrb.to_regex();

        let str_rr = self.stack.pop().unwrap();
        let str_rrb = str_rr.borrow();
        let str_pre = str_rrb.to_string();
        let str_opt = to_string_2(&str_pre);

        match (regex_opt, str_opt) {
            (Some(regex), Some(s)) => {
                let res = if regex.is_match(s) { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first m argument must be string");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second m argument must be string");
                return 0;
            }
        }
        return 1;
    }
/// Takes a value that can be stringified and a regex string as
/// its arguments.  Tests whether the value matches as against the
/// regex and puts a boolean onto the stack accordingly.
Takes a value that can be stringified and a regex string as
its arguments.  Tests whether the value matches as against the
regex and puts a boolean onto the stack accordingly.
Takes a value that can be stringified and a regex string as its arguments . Tests whether the value matches as against the regex and puts a boolean onto the stack accordingly .
pub fn core_m(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "m requires two arguments");
            return 0;
        }
        let regex_rr = self.stack.pop().unwrap();
        let regex_str_rr_opt = to_string_value(regex_rr);
        if regex_str_rr_opt.is_none() {
            print_error(chunk, i, "regex must be a string");
            return 0;
        }
        let regex_str_rr = regex_str_rr_opt.unwrap();
        {
            let mut regex_str_rrb = regex_str_rr.borrow_mut();
            let res = regex_str_rrb.gen_regex(chunk, i);
            if !res {
                return 0;
            }
        }
        let regex_str_rrb = regex_str_rr.borrow();
        let regex_opt = regex_str_rrb.to_regex();
        let str_rr = self.stack.pop().unwrap();
        let str_rrb = str_rr.borrow();
        let str_pre = str_rrb.to_string();
        let str_opt = to_string_2(&str_pre);
        match (regex_opt, str_opt) {
            (Some(regex), Some(s)) => {
                let res = if regex.is_match(s) { 1 } else { 0 };
                self.stack.push(Rc::new(RefCell::new(Value::Int(res))));
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first m argument must be string");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second m argument must be string");
                return 0;
            }
        }
        return 1;
    }
pub fn core_m ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 2 { print_error ( chunk , i , " " ) ; return 0 ; } let regex_rr = self . stack . pop ( ) . unwrap ( ) ; let regex_str_rr_opt = to_string_value ( regex_rr ) ; if regex_str_rr_opt . is_none ( ) { print_error ( chunk , i , " " ) ; return 0 ; } let regex_str_rr = regex_str_rr_opt . unwrap ( ) ; { let mut regex_str_rrb = regex_str_rr . borrow_mut ( ) ; let res = regex_str_rrb . gen_regex ( chunk , i ) ; if ! res { return 0 ; } } let regex_str_rrb = regex_str_rr . borrow ( ) ; let regex_opt = regex_str_rrb . to_regex ( ) ; let str_rr = self . stack . pop ( ) . unwrap ( ) ; let str_rrb = str_rr . borrow ( ) ; let str_pre = str_rrb . to_string ( ) ; let str_opt = to_string_2 ( & str_pre ) ; match ( regex_opt , str_opt ) { ( Some ( regex ) , Some ( s ) ) => { let res = if regex . is_match ( s ) { 1 } else { 0 } ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( res ) ) ) ) ; } ( _ , Some ( _ ) ) => { print_error ( chunk , i , " " ) ; return 0 ; } ( _ , _ ) => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
Takes a value that can be stringified and a regex string as
its arguments.
Takes a value that can be stringified and a regex string as its arguments .
&mut self
chunk
&Chunk
i
usize