チェンジセット 1501

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

methodsとmetadataを追加

ファイル:

凡例:

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

    r1498 r1501  
    44 
    55let rec times f n stream = 
    6   if n = 0 then 
     6  if n = 0l then 
    77    [] 
    88  else 
    99    let x =  
    1010      f stream in 
    11       x::times f (n - 1) stream 
     11      x::times f (Int32.sub n 1l) stream 
    1212 
    1313let array f stream = 
    1414  let n = 
    15     Int32.to_int @@ u30 stream in 
     15    u30 stream in 
    1616    times f n stream 
    1717 
    1818let carray f stream = 
    1919  let n = 
    20     Int32.to_int @@ u30 stream in 
    21     times f (n-1) stream 
     20    u30 stream in 
     21    times f (Int32.sub n 1l) stream 
    2222 
    2323let string_info stream = 
     
    6767     multiname=carray multiname_info stream 
    6868  |} 
    69      
     69 
     70let option_detail stream = 
     71  let value = 
     72    u30 stream in 
     73    match u8 stream with 
     74        0x03 -> 
     75          `Int value 
     76      | 0x04 -> 
     77          `UInt value 
     78      | 0x06 -> 
     79          `Double value 
     80      | 0x01 -> 
     81          `String value 
     82      | 0x0B -> 
     83          `Bool true 
     84      | 0x0A -> 
     85          `Bool false 
     86      | 0x0C -> 
     87          `Null 
     88      | 0x00 -> 
     89          `Undefined 
     90      | 0x08 | 0x16 | 0x17 | 0x18 | 0x19 | 0x1A | 0x05 -> 
     91          `Namespace value 
     92 
     93let option_info stream = 
     94  array option_detail stream 
     95 
     96let has x y = 
     97  x land y = y 
     98 
     99let method_info stream = 
     100  let param_count = 
     101    u30 stream in 
     102  let return_type = 
     103    u30 stream in 
     104  let param_types = 
     105    times u30 param_count stream in 
     106  let name = 
     107    u30 stream in 
     108  let flags = 
     109    u8 stream in 
     110  let options = 
     111    if has flags 0x08 then  
     112      Some (option_info stream ) 
     113    else  
     114      None in 
     115  let param_names =  
     116    if has flags 0x80 then 
     117      Some (times u30 param_count stream) 
     118    else  
     119      None in 
     120    {| param_types     = param_types; 
     121       return_type     = return_type; 
     122       name            = name; 
     123       need_arguments  = has flags 0x01; 
     124       need_activation = has flags 0x02; 
     125       need_rest       = has flags 0x04; 
     126       need_optional   = has flags 0x08; 
     127       sex_dxns        = has flags 0x40; 
     128       has_param_names = has flags 0x80; 
     129       options         = options; 
     130       param_info      = param_names 
     131    |} 
     132 
     133let item_info stream = 
     134  {| key=u30 stream;  
     135     value=u30 stream |} 
     136 
     137let metadata_info stream = 
     138  {| name  = u30 stream; 
     139     items = array item_info stream 
     140  |} 
     141 
    70142let abcFile stream = 
    71   {| minor_version=u16 stream; 
    72      major_version=u16 stream; 
    73      constant_pool=constant_pool stream 
     143  {| minor_version = u16 stream; 
     144     major_version = u16 stream; 
     145     constant_pool = constant_pool stream; 
     146     methods       = array method_info stream; 
     147     metadata      = array metadata_info stream 
    74148 |} 
    75149