Guest User

Untitled

a guest
Feb 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 KB | None | 0 0
  1. Index: tools/dumpobj.ml
  2. ===================================================================
  3. --- tools/dumpobj.ml (revision 15644)
  4. +++ tools/dumpobj.ml (working copy)
  5. @@ -12,10 +12,8 @@
  6.  
  7. (* Disassembler for executable and .cmo object files *)
  8.  
  9. -open Asttypes
  10. open Config
  11. open Instruct
  12. -open Lambda
  13. open Location
  14. open Opcodes
  15. open Opnames
  16. @@ -79,6 +77,9 @@
  17. else printf "%s." f
  18. ;;
  19.  
  20. +let print_struct_const _ =
  21. + printf "<strcst>" (* todo... *)
  22. +(*
  23. let rec print_struct_const = function
  24. Const_base(Const_int i) -> printf "%d" i
  25. | Const_base(Const_float f) -> print_float f
  26. @@ -104,6 +105,7 @@
  27. printf "[|";
  28. List.iter (fun f -> print_float f; printf "; ") a;
  29. printf "|]"
  30. +*)
  31.  
  32. (* Print an obj *)
  33.  
  34. Index: boot/ocamldep
  35. ===================================================================
  36. Cannot display: file marked as a binary type.
  37. svn:mime-type = application/octet-stream
  38. Index: boot/ocamllex
  39. ===================================================================
  40. Cannot display: file marked as a binary type.
  41. svn:mime-type = application/octet-stream
  42. Index: boot/ocamlc
  43. ===================================================================
  44. Cannot display: file marked as a binary type.
  45. svn:mime-type = application/octet-stream
  46. Index: bytecomp/symtable.ml
  47. ===================================================================
  48. --- bytecomp/symtable.ml (revision 15644)
  49. +++ bytecomp/symtable.ml (working copy)
  50. @@ -13,8 +13,6 @@
  51. (* To assign numbers to globals and primitives *)
  52.  
  53. open Misc
  54. -open Asttypes
  55. -open Lambda
  56. open Cmo_format
  57.  
  58. (* Functions for batch linking *)
  59. @@ -51,7 +49,7 @@
  60. (* Global variables *)
  61.  
  62. let global_table = ref(empty_numtable : Ident.t numtable)
  63. -and literal_table = ref([] : (int * structured_constant) list)
  64. +and literal_table = ref([] : (int * Obj.t) list)
  65.  
  66. let is_global_defined id =
  67. Tbl.mem id (!global_table).num_tbl
  68. @@ -140,12 +138,10 @@
  69. try List.assoc name Predef.builtin_values
  70. with Not_found -> fatal_error "Symtable.init" in
  71. let c = slot_for_setglobal id in
  72. - let cst = Const_block(Obj.object_tag,
  73. - [Const_base(Const_string (name, None));
  74. - Const_base(Const_int (-i-1))
  75. - ])
  76. - in
  77. - literal_table := (c, cst) :: !literal_table)
  78. + let block = Obj.new_block Obj.object_tag 2 in
  79. + Obj.set_field block 0 (Obj.repr name);
  80. + Obj.set_field block 1 (Obj.repr (-i-1));
  81. + literal_table := (c, block) :: !literal_table)
  82. Runtimedef.builtin_exceptions;
  83. (* Initialize the known C primitives *)
  84. if String.length !Clflags.use_prims > 0 then begin
  85. @@ -201,34 +197,12 @@
  86. let patch_object = gen_patch_object Bytes.unsafe_set
  87. let ls_patch_object = gen_patch_object LongString.set
  88.  
  89. -(* Translate structured constants *)
  90. -
  91. -let rec transl_const = function
  92. - Const_base(Const_int i) -> Obj.repr i
  93. - | Const_base(Const_char c) -> Obj.repr c
  94. - | Const_base(Const_string (s, _)) -> Obj.repr s
  95. - | Const_base(Const_float f) -> Obj.repr (float_of_string f)
  96. - | Const_base(Const_int32 i) -> Obj.repr i
  97. - | Const_base(Const_int64 i) -> Obj.repr i
  98. - | Const_base(Const_nativeint i) -> Obj.repr i
  99. - | Const_pointer i -> Obj.repr i
  100. - | Const_immstring s -> Obj.repr s
  101. - | Const_block(tag, fields) ->
  102. - let block = Obj.new_block tag (List.length fields) in
  103. - let pos = ref 0 in
  104. - List.iter
  105. - (fun c -> Obj.set_field block !pos (transl_const c); incr pos)
  106. - fields;
  107. - block
  108. - | Const_float_array fields ->
  109. - Obj.repr(Array.of_list(List.map (fun f -> float_of_string f) fields))
  110. -
  111. (* Build the initial table of globals *)
  112.  
  113. let initial_global_table () =
  114. let glob = Array.make !global_table.num_cnt (Obj.repr 0) in
  115. List.iter
  116. - (fun (slot, cst) -> glob.(slot) <- transl_const cst)
  117. + (fun (slot, cst) -> glob.(slot) <- cst)
  118. !literal_table;
  119. literal_table := [];
  120. glob
  121. @@ -250,7 +224,7 @@
  122. if ng > Array.length(Meta.global_data()) then Meta.realloc_global_data ng;
  123. let glob = Meta.global_data() in
  124. List.iter
  125. - (fun (slot, cst) -> glob.(slot) <- transl_const cst)
  126. + (fun (slot, cst) -> glob.(slot) <- cst)
  127. !literal_table;
  128. literal_table := []
  129.  
  130. Index: bytecomp/emitcode.ml
  131. ===================================================================
  132. --- bytecomp/emitcode.ml (revision 15644)
  133. +++ bytecomp/emitcode.ml (working copy)
  134. @@ -121,8 +121,28 @@
  135. let enter info =
  136. reloc_info := (info, !out_position) :: !reloc_info
  137.  
  138. +let rec transl_const = function
  139. + Const_base(Const_int i) -> Obj.repr i
  140. + | Const_base(Const_char c) -> Obj.repr c
  141. + | Const_base(Const_string (s, _)) -> Obj.repr s
  142. + | Const_base(Const_float f) -> Obj.repr (float_of_string f)
  143. + | Const_base(Const_int32 i) -> Obj.repr i
  144. + | Const_base(Const_int64 i) -> Obj.repr i
  145. + | Const_base(Const_nativeint i) -> Obj.repr i
  146. + | Const_pointer i -> Obj.repr i
  147. + | Const_immstring s -> Obj.repr s
  148. + | Const_block(tag, fields) ->
  149. + let block = Obj.new_block tag (List.length fields) in
  150. + let pos = ref 0 in
  151. + List.iter
  152. + (fun c -> Obj.set_field block !pos (transl_const c); incr pos)
  153. + fields;
  154. + block
  155. + | Const_float_array fields ->
  156. + Obj.repr(Array.of_list(List.map (fun f -> float_of_string f) fields))
  157. +
  158. let slot_for_literal sc =
  159. - enter (Reloc_literal sc);
  160. + enter (Reloc_literal (transl_const sc));
  161. out_int 0
  162. and slot_for_getglobal id =
  163. enter (Reloc_getglobal id);
  164. Index: bytecomp/cmo_format.mli
  165. ===================================================================
  166. --- bytecomp/cmo_format.mli (revision 15644)
  167. +++ bytecomp/cmo_format.mli (working copy)
  168. @@ -15,7 +15,7 @@
  169. (* Relocation information *)
  170.  
  171. type reloc_info =
  172. - Reloc_literal of Lambda.structured_constant (* structured constant *)
  173. + Reloc_literal of Obj.t (* structured constant *)
  174. | Reloc_getglobal of Ident.t (* reference to a global *)
  175. | Reloc_setglobal of Ident.t (* definition of a global *)
  176. | Reloc_primitive of string (* C primitive number *)
  177. Index: otherlibs/dynlink/Makefile
  178. ===================================================================
  179. --- otherlibs/dynlink/Makefile (revision 15644)
  180. +++ otherlibs/dynlink/Makefile (working copy)
  181. @@ -38,7 +38,7 @@
  182. ../../typing/primitive.cmo ../../typing/types.cmo \
  183. ../../typing/btype.cmo ../../typing/subst.cmo ../../typing/predef.cmo \
  184. ../../typing/datarepr.cmo ../../typing/cmi_format.cmo ../../typing/env.cmo \
  185. - ../../bytecomp/lambda.cmo ../../bytecomp/instruct.cmo \
  186. + ../../bytecomp/instruct.cmo \
  187. ../../bytecomp/cmo_format.cmi ../../bytecomp/opcodes.cmo \
  188. ../../bytecomp/runtimedef.cmo ../../bytecomp/bytesections.cmo \
  189. ../../bytecomp/dll.cmo ../../bytecomp/meta.cmo \
Add Comment
Please, Sign In to add comment