瀏覽代碼

write chunk name before length, and remove crc

The 4 bytes of the name don't contribute to the length, so this makes more sense.
Simon Krajewski 1 年之前
父節點
當前提交
fea2f466ef
共有 2 個文件被更改,包括 3 次插入7 次删除
  1. 1 3
      src/compiler/hxb/hxbReader.ml
  2. 2 4
      src/compiler/hxb/hxbWriter.ml

+ 1 - 3
src/compiler/hxb/hxbReader.ml

@@ -1491,11 +1491,9 @@ class hxb_reader
 		);
 
 	method read_chunk =
-		let size = Int32.to_int self#read_i32 in
 		let name = Bytes.unsafe_to_string (IO.nread ch 4) in
+		let size = Int32.to_int self#read_i32 in
 		let data = IO.nread ch size in
-		let crc = self#read_i32 in
-		ignore(crc); (* TODO *)
 		let kind = chunk_kind_of_string name in
 		(kind,data)
 

+ 2 - 4
src/compiler/hxb/hxbWriter.ml

@@ -316,6 +316,7 @@ module IOChunk = struct
 		write_u8 io (if b then 1 else 0)
 
 	let export : 'a . hxb_writer_stats -> t -> 'a IO.output -> unit = fun stats io chex ->
+		IO.nwrite chex (Bytes.unsafe_of_string io.name);
 		let bytes = get_bytes io in
 		let length = Bytes.length bytes in
 		IO.write_real_i32 chex (Int32.of_int length);
@@ -326,10 +327,7 @@ module IOChunk = struct
 		with Not_found ->
 			Hashtbl.add stats.chunk_sizes io.name (ref length,ref length);
 		end; *)
-		IO.nwrite chex (Bytes.unsafe_of_string io.name);
-		IO.nwrite chex bytes;
-		let crc = Int32.of_int 0x1234567 in (* TODO *)
-		IO.write_real_i32 chex crc
+		IO.nwrite chex bytes
 end
 
 class string_pool (kind : chunk_kind) = object(self)