チェンジセット 1964

差分発生行の前後
無視リスト:
コミット日時:
2008/12/05 08:28:57 (3 年前)
コミッタ:
mzp
ログメッセージ:

メソッドのダンプにも成功

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • ocaml/abc2xml/trunk/classdump/main.ml

    r1958 r1964  
    77  match List.nth cpool#namespace @@ (Int32.to_int i - 1) with 
    88      `ExplicitNamespace i -> 
    9         Printf.sprintf "explicit %s" @@ string cpool i 
     9        Printf.sprintf "[explicit %s]" @@ string cpool i 
    1010    | `Namespace i -> 
    1111       Printf.sprintf "%s" @@ string cpool i 
    1212    | `PackageInternaNs i -> 
    13         Printf.sprintf "internal %s" @@ string cpool i 
     13        Printf.sprintf "[internal %s]" @@ string cpool i 
    1414    | `PackageNamespace i -> 
    15         Printf.sprintf "package %s" @@ string cpool i 
     15        Printf.sprintf "%s" @@ string cpool i 
    1616    | `PrivateNs i -> 
    17         Printf.sprintf "private %s" @@ string cpool i 
     17        Printf.sprintf "[private %s]" @@ string cpool i 
    1818    | `ProtectedNamespace i -> 
    19         Printf.sprintf "protected %s" @@ string cpool i 
     19        Printf.sprintf "[protected %s]" @@ string cpool i 
    2020    | `StaticProtectedNs i -> 
    21         Printf.sprintf "static protected %s" @@ string cpool i 
     21        Printf.sprintf "[static protected %s]" @@ string cpool i 
    2222 
    2323let namespace_set cpool i = 
     
    2828  match List.nth cpool#multiname @@ Int32.to_int i - 1 with 
    2929      `QName obj -> 
    30         Printf.sprintf "%s::%s" (namespace cpool obj#ns) (string cpool obj#name) 
     30        Printf.sprintf "%s.%s" (namespace cpool obj#ns) (string cpool obj#name) 
    3131    | `Multiname obj -> 
    32         Printf.sprintf "%s::%s" (namespace_set cpool obj#ns_set) (string cpool obj#name) 
     32        Printf.sprintf "%s.%s" (namespace_set cpool obj#ns_set) (string cpool obj#name) 
    3333    | _ -> 
    3434        failwith "not yet" 
     35 
     36let method_info abc i = 
     37  let m = 
     38    List.nth abc#methods @@ Int32.to_int i in 
     39    multiname abc#constant_pool m#name 
     40 
     41let method_trait trait = 
     42  match trait#data with 
     43      `Method obj  
     44    | `Getter obj 
     45    | `Setter obj -> 
     46        [obj#methodi] 
     47    | _ -> 
     48        [] 
     49 
     50 
     51let instance_list abc = 
     52  let cpool = 
     53    abc#constant_pool in 
     54    List.map (fun i -> (multiname cpool i#name, 
     55                        List.map (fun t -> multiname cpool t#name) i#traits)) 
     56      abc#instances 
    3557 
    3658let dump file = 
    3759  let abc = 
    3860    Abc.of_stream @@ Byte.of_channel @@ open_in_bin file in 
    39   let cpool = 
    40     abc#constant_pool in 
    41     List.map (fun i -> multiname cpool i#name) abc#instances 
     61    instance_list abc 
    4262 
    4363let _ = 
     
    4666    match argv with 
    4767      _::xs -> 
    48         xs +> List.iter (List.iter print_endline $ dump) 
     68        List.iter (List.iter (fun (klass,methods)-> 
     69                                Printf.printf "(%s (%s))\n" klass @@ String.concat " " methods) $ dump) xs 
    4970      | [] -> 
    5071          failwith "must not happen"