Commits

Anonymous committed 0ca503c

+ ti_inherit (for selective overriding of runtime methods)

Comments (0)

Files changed (1)

 ;
 
 
+value ti_inherit (ti : #ti 'a) : ti 'a =
+  let meths = Meths.create () in
+  let type_id = Type_id.next () in
+  let put_func = ti#put_func
+  and get_exn = ti#get_exn in
+  let type_desc = ti#type_desc in
+  let type_name = lazy ti#type_name in
+  let get_meth_super = ti#get_meth_exn in
+
+  object (_ : #ti 'a)
+
+    method type_desc = type_desc
+    ;
+    method type_name = Lazy.force type_name
+    ;
+    method meths = meths
+    ;
+    method put_func = put_func
+    ;
+    method get_exn = get_exn
+    ;
+    method type_id = type_id
+    ;
+    method polyapp_Ab : ! 'b . polyapp_Ab 'b -> R.ubox -> 'b
+      = ti#polyapp_Ab
+    ;
+
+    method get_meth_exn mn =
+      try
+        Meths.get mn meths
+      with
+      [ No_meth -> get_meth_super mn ]
+    ;
+
+  end
+
+
+;
+
+
 value expect_abs
  : uti -> ubox -> (uti * (ubox -> ubox -> ubox))
  = fun uti_arg ubox_func ->