Source

OCamlRuby / rbInt.ml

Full commit
open Util
open Expression

let of_int i = { class_name="Int"; ctx=[
		 ("to_s", Fun ([], Literal (LString (string_of_int i))));
		 ("__body", Fun ([], Literal (LInt i)) );
	       ] }

let to_int obj =
  match get_fun obj.ctx "__body" with
  | (_, Literal (LInt x)) -> x
  | _ -> failwith @@ "RbInt.to_int: " ^ obj.class_name