チェンジセット 1699

差分発生行の前後
無視リスト:
コミット日時:
2008/10/25 11:22:55 (4 年前)
コミッタ:
mzp
ログメッセージ:

trait support

ファイル:

凡例:

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

    r1698 r1699  
    11open Base 
    22open EasyXml 
     3 
     4let some x = 
     5  match x with Some _ -> "1" | None -> "0" 
     6 
     7let bool x = 
     8  if x then "1" else "0" 
    39 
    410let u30 x = 
     
    7076 
    7177let from_methods methods = 
    72   let bool x = 
    73     if x then "1" else "0" in 
    74   let some x = 
    75     match x with Some _ -> "1" | None -> "0" in 
    7678    elem "methods" @@ 
    7779      List.map  
     
    101103    elem "metadata" 
    102104 
    103 (* 
    104 <InstanceInfo nameIndex="1" superIndex="2" hasProtectedNS="1" interface="0" final="0" sealed="1" protectedNS="3" iInitIndex="1"> 
    105             <interfaces/> 
    106            <traits/> 
    107 </InstanceInfo> 
    108 *) 
     105let from_trait trait = 
     106  element  
     107    "TraitInfo"  
     108    [ "nameIndex"  ,Int32.to_string trait#name; 
     109      "hasMetadata",some trait#metadata; 
     110      "override"   ,bool trait#attr_override; 
     111      "final"      ,bool trait#attr_final] 
     112    [ elem "trait" [ 
     113        match trait#data with 
     114            `Class t -> 
     115              attr "Class" ["slotID",Int32.to_string t#slot_id;"classInfo",Int32.to_string t#classi] 
     116          | `Slot t -> 
     117              attr "Slot" @@ ([ 
     118                "slotID"    ,Int32.to_string t#slot_id; 
     119                "typeIndex" ,Int32.to_string t#type_name; 
     120                "valueIndex",Int32.to_string t#vindex; 
     121              ] @ match t#vkind with 
     122                  None -> [ ] 
     123                | Some kind -> ["valueKind",string_of_int kind]) 
     124          | `Const t -> 
     125              attr "Slot" @@ ([ 
     126                "slotID"    ,Int32.to_string t#slot_id; 
     127                "typeIndex" ,Int32.to_string t#type_name; 
     128                "valueIndex",Int32.to_string t#vindex; 
     129              ] @ match t#vkind with 
     130                  None -> [ ] 
     131                | Some kind -> ["valueKind",string_of_int kind]) 
     132          | `Function t -> 
     133              attr "Function" ["slotID",Int32.to_string t#slot_id; 
     134                               "methodInfo",Int32.to_string  t#functioni] 
     135          | `Getter t -> 
     136              attr "Getter" ["dispID",Int32.to_string t#disp_id; 
     137                             "methodInfo",Int32.to_string t#methodi] 
     138          | `Method t -> 
     139              attr "Method" ["dispID",Int32.to_string t#disp_id;"methodInfo",Int32.to_string t#methodi] 
     140          | `Setter t -> 
     141              attr "Setter" ["dispID",Int32.to_string t#disp_id;"methodInfo",Int32.to_string t#methodi] 
     142      ]] 
     143 
     144 
    109145let from_instances instances= 
    110146  instances +> 
    111147    List.map (fun i ->  
    112148                element "InstanceInfo"  
    113                   ["nameIndex" ,"1"; 
    114                    "superIndex","2"; 
    115                    "hasProtectedNS","1"; 
    116                    "interface","0"; 
    117                    "final","0"; 
    118                    "sealed","1"; 
    119                    "protectedNS","3"; 
    120                    "iInitIndex","1"] 
    121                   []) +> 
     149                  (["nameIndex"    ,Int32.to_string i#name; 
     150                   "superIndex"    ,Int32.to_string i#super_name; 
     151                   "hasProtectedNS",bool i#is_protected; 
     152                   "interface"     ,bool i#is_interface; 
     153                   "final"         ,bool i#is_final; 
     154                   "sealed"        ,bool i#is_sealed; 
     155                   "iInitIndex"    ,Int32.to_string i#iinit] @  
     156                     (match i#protectedNs with 
     157                          None -> [] 
     158                        | Some x -> 
     159                            ["protectedNS",Int32.to_string x])) 
     160                @@ [elem "interfaces" @@ List.map u30 i#interface; 
     161                    elem "traits" @@ List.map from_trait i#trait]) +> 
    122162    elem "instances" 
    123163