array bytes_of_method_info info;
bytes_of_list metadata;
(* todo: instances *)
- array bytes_of_class classes;
- HList.concat_map bytes_of_instance instances;
+ array bytes_of_instance instances;
+ HList.concat_map bytes_of_class classes;
array bytes_of_script script;
array bytes_of_method_body body
]
(**{6 Collecting some information}*)
(** [collect_const meth] returns all constant value which contained by [meth]. *)
-let collect_const =
- fold_instruction
+let collect_const meth=
+ Cpool.append
+ (method_const meth)
+ @@ fold_instruction
(fun cpool i-> Cpool.append cpool (get_config i).const)
- Cpool.empty
+ Cpool.empty meth
(** [collect_klass meth] returns all class which contained by [meth]. *)
let info =
{ Abc.params=m.params;
Abc.return=m.return;
- Abc.name=index;
+ Abc.name=Cpool.multiname_nget m.name map.cpool;
Abc.flags=m.flags } in
let body =
{ Abc.method_sig=index;
| _ -> failwith "must not happen"
with Not_found -> Cpool.empty];
List.map multiname [cname;sname];
- List.map method_const methods]
+ List.map method_const (cinit::iinit::methods)]
-
#include "match.ml"
assert_equal {Abc.empty_cpool with
Abc.int = [~-42];
Abc.uint = [42];
- Abc.string=["";"print"];
+ Abc.string=["";"main";"print"];
Abc.namespace = [{Abc.kind=0x08; Abc.ns_name=1}];
- Abc.multiname = [Abc.QName (1,2)]} cpool;
- assert_equal [{Abc.params=[]; Abc.return=0; Abc.name=0; Abc.flags=0}] info;
- assert_equal [{Abc.method_sig=0;
+ Abc.multiname = [Abc.QName (1,2);Abc.QName (1,3)]} cpool;
+ assert_equal [{Abc.params=[]; Abc.return=0; Abc.name=1; Abc.flags=0}] info;
+ assert_equal [{Abc.method_sig=0;
Abc.max_stack=3;
Abc.local_count=1;
Abc.init_scope_depth=0;
Abc.max_scope_depth=1;
Abc.code=[u8 208;
u8 48;
- u8 93; u30 1;
+ u8 93; u30 2;
u8 45; u30 1; (* pushint *)
u8 46; u30 1; (* pushuint *)
- u8 76; u30 1; u30 1;
+ u8 76; u30 2; u30 1;
u8 41;
u8 71];
Abc.exceptions=[];
List.fold_left Cpool.append Cpool.empty
[string "hoge";
int 42;
- multiname @@ make_qname "f"] in
+ multiname @@ make_qname "f";
+ multiname @@ make_qname "g"] in
let meth =
- make_meth "" [
+ make_meth "g" [
PushInt 42;
NewFunction (make_meth "f" [PushString "hoge"])] in
- OUnit.assert_equal ~printer:to_string cpool (collect_const meth)
+ assert_equal (Cpool.to_abc cpool) (Cpool.to_abc (collect_const meth))
module Set = Core.Std.Set