Show
Ignore:
Timestamp:
08/27/08 23:39:39 (4 months ago)
Author:
fujidig
Message:

UIを変更

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/hsp/misc/unused_variable_lister/unused_variable_lister.hsp

    r18343 r18345  
    22// �����Ă��Ȃ��ÓI�ϐ�������� 
    33// �t�@�C���I��C�A���O��HSP �̃I�u�W�F�N�g�t�@�C��(obj)���X�N���v�g�t�@�C��(*.hsp)��肵�Ă������� 
    4 // �I�u�W�F�N�g�t�@�C����start.ax �ł̓f�o�b�O�����t��������̂�obj ��肵�Ă��������B 
     4// �I�u�W�F�N�g�t�@�C����start.ax �ł͂Ȃ� obj ��肵�Ă��������B 
     5// start.ax ���f�o�b�O�����t��������Ȃ��̂ŁB 
    56 
    67// ���ӓ_: 
     
    1314    dupptr ret, varptr(ds) + offset, 1, 2 
    1415    return ret 
    15 #defcfunc get_type_name int type 
    16     if 0 == types { 
    17         types = "TYPE_MARK", "TYPE_VAR", "TYPE_STRING", "TYPE_DNUM", "TYPE_INUM", "TYPE_STRUCT", "TYPE_XLABEL", "TYPE_LABEL", "TYPE_INTCMD", "TYPE_EXTCMD", "TYPE_EXTSYSVAR", "TYPE_CMPCMD", "TYPE_MODCMD", "TYPE_INTFUNC", "TYPE_SYSVAR", "TYPE_PROGCMD", "TYPE_DLLFUNC", "TYPE_DLLCTRL", "TYPE_USERDEF" 
    18     } 
    19     return types.type+"("+type+")" 
    2016#global 
    2117 
     
    4238#define TYPE_USERDEF 18 
    4339 
    44 dialog "*", 16, "HSP obj file / script file" 
    45 if stat == 0 : end 
    46 obj_file_path = refstr 
    47 ext = getpath(obj_file_path, 2+16) 
    48 if ext == ".hsp" or ext == ".as" { 
    49     script_file_name = getpath(obj_file_path, 8) 
    50     obj_file_path = "obj" 
    51     hsc_ini script_file_name 
    52     hsc_objname obj_file_path 
    53     hsc_comp 1, 0 
    54     if stat { 
    55         title "�R���p�C���Ɏ��s���܂���" 
    56         hsc3_messize size 
    57         sdim error_message, size + 1 
    58         hsc_getmes error_message 
    59         mesbox error_message, 640, 480 
    60         stop 
     40    title "Unused Variable Lister" 
     41    path = "" 
     42    input path, 540 
     43    path_input_objid = stat 
     44    pos 640 - 50 - 50, 0 
     45    objsize 50 
     46    button gosub "�Q��..", *open_dialog 
     47    pos 640 - 50, 0 
     48    button gosub "��s", *start 
     49    result = "" 
     50    pos 0 
     51    mesbox result, 640, 480 - 24, 0 
     52    result_mesbox_objid = stat 
     53    sdim hr, 65 
     54    hr = "-" 
     55    repeat 6 
     56        hr += hr 
     57    loop 
     58    stop 
     59 
     60*open_dialog 
     61    dialog "", 16 
     62    if stat == 0 : return 
     63    path = refstr 
     64    objprm path_input_objid, path 
     65    gosub *start 
     66    return 
     67 
     68*result_mesbox_notify 
     69    objprm result_mesbox_objid, result 
     70    return 
     71 
     72*start 
     73    if peek(result) { 
     74        result += hr + "\n" 
    6175    } 
    62 } 
    63 exist obj_file_path 
    64 if strsize < 0 { 
    65     dialog "�I�u�W�F�N�g�t�@�C�� " + obj_file_path + "�����݂��܂���    end 
    66 } 
    67 sdim ax, strsize 
    68 bload obj_file_path, ax 
    69 if lpeek(ax) != 0x33505348 { // header magic number check 
    70     dialog "�s���ȃI�u�W�F�N�g�t�@�C���ł�", 1 
    71     end 
    72 } 
     76    gosub *start_ 
     77    gosub *result_mesbox_notify 
     78    return 
    7379 
    74 max_val   = lpeek(ax,  8) 
     80*start_ 
     81    ext = getpath(path, 2 + 16) 
     82    if ext == ".hsp" or ext == ".as" { 
     83        script_file_name = getpath(path, 8) 
     84        obj_path = "obj" 
     85        hsc_ini script_file_name 
     86        hsc_objname obj_path 
     87        hsc_comp 1, 0 
     88        if stat { 
     89            result += "�R���p�C���Ɏ��s���܂���\n" 
     90            hsc3_messize size 
     91            sdim error_message, size + 1 
     92            hsc_getmes error_message 
     93            result += error_message 
     94            return 
     95        } 
     96    } else { 
     97        obj_path = path 
     98    } 
     99    exist obj_path 
     100    if strsize < 0 { 
     101        result += "�I�u�W�F�N�g�t�@�C�� " + obj_path + " �͑��݂��܂��� 
     102        return 
     103    } 
     104    sdim ax, strsize 
     105    bload obj_path, ax 
     106    if lpeek(ax) != 0x33505348 { // header magic number check 
     107        result += "�s���ȃI�u�W�F�N�g�t�@�C���ł�\n" 
     108        return 
     109    } 
     110    gosub *list_unused_variables 
     111    result += path + "���� 
     112    if unused_variables_count { 
     113        result += "���g�p�ϐ���+ unused_variables_count + " �Œ��‚��܂���\n" 
     114    } else { 
     115        result += "���g�p�ϐ��͌��‚����������\n" 
     116    } 
     117    repeat unused_variables_count 
     118        result += varnames(unused_variables.cnt) + "\n" 
     119    loop 
     120    return 
    75121 
    76 pt_cs     = lpeek(ax, 16) 
    77 max_cs    = lpeek(ax, 20) 
    78 pt_ds     = lpeek(ax, 24) 
    79 max_ds    = lpeek(ax, 28) 
    80 pt_ot     = lpeek(ax, 32) 
    81 max_ot    = lpeek(ax, 36) 
    82 pt_dinfo  = lpeek(ax, 40) 
    83 max_dinfo = lpeek(ax, 44) 
     122*list_unused_variables 
     123    max_val   = lpeek(ax,  8) 
    84124 
    85 sdim cs,    max_cs 
    86 sdim ds,    max_ds 
    87 sdim ot,    max_ot 
    88 sdim dinfo, max_dinfo 
    89 memcpy cs,    ax, max_cs,    0, pt_cs 
    90 memcpy ds,    ax, max_ds,    0, pt_ds 
    91 memcpy ot,    ax, max_ot,    0, pt_ot 
    92 memcpy dinfo, ax, max_dinfo, 0, pt_dinfo 
     125    pt_cs     = lpeek(ax, 16) 
     126    max_cs    = lpeek(ax, 20) 
     127    pt_ds     = lpeek(ax, 24) 
     128    max_ds    = lpeek(ax, 28) 
     129    pt_ot     = lpeek(ax, 32) 
     130    max_ot    = lpeek(ax, 36) 
     131    pt_dinfo  = lpeek(ax, 40) 
     132    max_dinfo = lpeek(ax, 44) 
    93133 
    94 sdim varnames,, max_val 
    95 i = 0 
    96 repeat max_dinfo 
    97     ofs = peek(dinfo,cnt) 
    98     if ofs == 255 : break 
    99     if ofs == 254 { 
    100         continue cnt + 1 + 3 + 2 
    101     } 
    102     if ofs == 253 { 
    103         varnames.i = get_ds(ds, lpeek(dinfo, cnt + 1) & 0x00ffffff) 
    104         i ++ 
    105         continue cnt + 1 + 3 + 2 
    106     } 
    107     if ofs == 252 { 
    108         continue cnt + 1 + 2 
    109     } 
    110 loop 
     134    sdim cs,    max_cs 
     135    sdim ds,    max_ds 
     136    sdim ot,    max_ot 
     137    sdim dinfo, max_dinfo 
     138    memcpy cs,    ax, max_cs,    0, pt_cs 
     139    memcpy ds,    ax, max_ds,    0, pt_ds 
     140    memcpy ot,    ax, max_ot,    0, pt_ot 
     141    memcpy dinfo, ax, max_dinfo, 0, pt_dinfo 
    111142 
    112 dim var_used_flags, max_val 
    113 repeat max_cs 
    114     c = wpeek(cs, cnt) 
    115     sz = 2 
    116     type = c & 0x1fff 
    117     ex1 = (c & 0x2000) != 0 
    118     ex2 = (c & 0x4000) != 0 
    119     if c & 0x8000 { 
    120         code = lpeek(cs, cnt + sz) 
    121         sz += 4 
    122     } else { 
    123         code = wpeek(cs, cnt + sz) 
    124         sz += 2 
    125     } 
    126     if type == TYPE_CMPCMD { 
    127         sz += 2 
    128     } 
    129     if ex1 and type == TYPE_VAR { 
    130         var_used_flags.code = 1 
    131     } 
    132     continue cnt + sz 
    133 loop 
     143    sdim varnames,, max_val 
     144    i = 0 
     145    repeat max_dinfo 
     146        ofs = peek(dinfo,cnt) 
     147        if ofs == 255 : break 
     148        if ofs == 254 { 
     149            continue cnt + 1 + 3 + 2 
     150        } 
     151        if ofs == 253 { 
     152            varnames.i = get_ds(ds, lpeek(dinfo, cnt + 1) & 0x00ffffff) 
     153            i ++ 
     154            continue cnt + 1 + 3 + 2 
     155        } 
     156        if ofs == 252 { 
     157            continue cnt + 1 + 2 
     158        } 
     159    loop 
    134160 
    135 unused_variables_count = 0 
    136 unused_variables = 0 
    137 repeat max_val 
    138     if var_used_flags.cnt : continue 
    139     unused_variables.unused_variables_count = cnt 
    140     unused_variables_count ++ 
    141 loop 
     161    dim var_used_flags, max_val 
     162    repeat max_cs 
     163        c = wpeek(cs, cnt) 
     164        sz = 2 
     165        type = c & 0x1fff 
     166        ex1 = (c & 0x2000) != 0 
     167        ex2 = (c & 0x4000) != 0 
     168        if c & 0x8000 { 
     169            code = lpeek(cs, cnt + sz) 
     170            sz += 4 
     171        } else { 
     172            code = wpeek(cs, cnt + sz) 
     173            sz += 2 
     174        } 
     175        if type == TYPE_CMPCMD { 
     176            sz += 2 
     177        } 
     178        if ex1 and type == TYPE_VAR { 
     179            var_used_flags.code = 1 
     180        } 
     181        continue cnt + sz 
     182    loop 
    142183 
    143 if unused_variables_count { 
    144     mes "���g�p�ϐ���+ unused_variables_count + " �Œ��‚��܂���" 
    145 } else { 
    146     mes "���g�p�ϐ��͌��‚����������" 
    147 } 
    148 repeat unused_variables_count 
    149     mes varnames(unused_variables.cnt) 
    150 loop 
     184    unused_variables_count = 0 
     185    unused_variables = 0 
     186    repeat max_val 
     187        if var_used_flags.cnt : continue 
     188        unused_variables.unused_variables_count = cnt 
     189        unused_variables_count ++ 
     190    loop 
     191    return