| File: | src/showexports.c |
| Warning: | line 85, column 2 Value stored to 'syme' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | #include <stdlib.h> |
| 2 | |
| 3 | #include "axlobs.h" |
| 4 | #include "absyn.h" |
| 5 | #include "token.h" |
| 6 | #include "stab.h" |
| 7 | #include "tform.h" |
| 8 | #include "tqual.h" |
| 9 | #include "tinfer.h" |
| 10 | #include "srcpos.h" |
| 11 | #include "srcline.h" |
| 12 | #include "scan.h" |
| 13 | #include "linear.h" |
| 14 | #include "parseby.h" |
| 15 | #include "abnorm.h" |
| 16 | #include "macex.h" |
| 17 | #include "syscmd.h" |
| 18 | #include "stab.h" |
| 19 | #include "symbol.h" |
| 20 | #include "syme.h" |
| 21 | #include "abpretty.h" |
| 22 | #include "format.h" |
| 23 | #include "comsg.h" |
| 24 | #include "scobind.h" |
| 25 | #include "abuse.h" |
| 26 | #include "opsys.h" |
| 27 | #include "ablogic.h" |
| 28 | #include "sexpr.h" |
| 29 | #include "spesym.h" |
| 30 | #include "debug.h" |
| 31 | #include "optfoam.h" |
| 32 | #include "tfsat.h" |
| 33 | #include "formatters.h" |
| 34 | |
| 35 | localstatic AbSyn shexpParse(String); |
| 36 | |
| 37 | /* |
| 38 | * Usage: showexports libName type-expression |
| 39 | * Example: showexports libaldor.al 'List(Integer)' |
| 40 | */ |
| 41 | int |
| 42 | main(int argc, char *argv[]) |
| 43 | { |
| 44 | AbSyn arAbSyn; |
| 45 | AbSyn boolean; |
| 46 | AbSyn ab; |
| 47 | Stab stab; |
| 48 | Syme syme; |
| 49 | TForm tf; |
| 50 | |
| 51 | String archive; |
| 52 | String expression; |
| 53 | |
| 54 | osInit(); |
| 55 | sxiInit(); |
| 56 | keyInit(); |
| 57 | ssymInit(); |
| 58 | dbInit(); |
| 59 | stabInitGlobal(); |
| 60 | tfInit(); |
| 61 | fmttsInit(); |
| 62 | foamInit(); |
| 63 | optInit(); |
| 64 | tinferInit(); |
| 65 | pathInit(); |
| 66 | |
| 67 | sposInit(); |
| 68 | ablogInit(); |
| 69 | comsgInit(); |
| 70 | |
| 71 | macexInitFile(); |
| 72 | comsgInit(); |
| 73 | scobindInitFile(); |
| 74 | stabInitFile(); |
| 75 | |
| 76 | fileAddLibraryDirectory("."); |
| 77 | |
| 78 | archive = argv[1]; |
| 79 | expression = argv[2]; |
| 80 | |
| 81 | scmdHandleLibrary("LIB", archive); |
| 82 | |
| 83 | ab = shexpParse(expression); |
| 84 | stab = stabFile(); |
| 85 | syme = stabGetArchive(symInternConst("LIB")symProbe("LIB", 1)); |
Value stored to 'syme' is never read | |
| 86 | arAbSyn = abNewId(sposNone, symInternConst("LIB"))abNew(AB_Id, sposNone,1, symProbe("LIB", 1)); |
| 87 | boolean = abNewId(sposNone, symInternConst("Boolean"))abNew(AB_Id, sposNone,1, symProbe("Boolean", 1)); |
| 88 | |
| 89 | stabImportTForm(stab, tiGetTForm(stab, arAbSyn)); |
| 90 | stabImportTForm(stab, tiGetTForm(stab, boolean)); |
| 91 | abPutUse(ab, AB_Use_Value); |
| 92 | scopeBind(stab, ab); |
| 93 | typeInfer(stab, ab); |
| 94 | tf = tiGetTForm(stab, ab); |
| 95 | aprintf("Type: %s Cat: %d\n", tfPretty(tf), tfSatCat(tf)); |
| 96 | if (tfSatDom(tf)) { |
| 97 | SymeList list = tfGetCatExports(tf); |
| 98 | aprintf("Category\n"); |
| 99 | for (; list != listNil(Syme)((SymeList) 0); list = cdr(list)((list)->rest)) { |
| 100 | Syme syme = car(list)((list)->first); |
| 101 | aprintf("%5s %3d %s %pAbSynList\n", symeString(syme)((((syme)->id))->str), symeHasDefault(syme)(((((syme)->kind == SYME_Trigger ? libGetAllSymes((syme)-> lib) : ((void*)0)), (syme))->bits) & (0x0080)), |
| 102 | tfPretty(symeType(syme)), symeCondition(syme)); |
| 103 | } |
| 104 | } |
| 105 | else { |
| 106 | TQualList tqList; |
| 107 | SymeList list = tfStabGetDomImports(stab, tf); |
| 108 | aprintf(">>> Exports\n"); |
| 109 | |
| 110 | for (; list != listNil(Syme)((SymeList) 0); list = cdr(list)((list)->rest)) { |
| 111 | Syme syme = car(list)((list)->first); |
| 112 | aprintf("%s %d %d %s\n", symeString(syme)((((syme)->id))->str), |
| 113 | symeDefnNum(syme)((int) (SYFI_DefnNum < (8 * sizeof(int)) && !((((( syme)->kind == SYME_Trigger ? libGetAllSymes((syme)->lib ) : ((void*)0)), (syme))->hasmask) & (1 << (SYFI_DefnNum ))) ? (symeFieldInfo[SYFI_DefnNum].def) : (((((syme)->kind == SYME_Trigger ? libGetAllSymes((syme)->lib) : ((void*)0 )), (syme))->locmask) & (1 << (SYFI_DefnNum))) ? ((((((syme)->kind == SYME_Trigger ? libGetAllSymes((syme) ->lib) : ((void*)0)), (syme))->locmask) & (1 << (SYFI_DefnNum))) ? ((syme)->fieldv)[symeIndex(syme,SYFI_DefnNum )] : (symeFieldInfo[SYFI_DefnNum].def)) : symeGetFieldFn(syme ,SYFI_DefnNum))), symeConstNum(syme)(((AInt) (SYFI_ConstInfo < (8 * sizeof(int)) && !( ((((syme)->kind == SYME_Trigger ? libGetAllSymes((syme)-> lib) : ((void*)0)), (syme))->hasmask) & (1 << (SYFI_ConstInfo ))) ? (symeFieldInfo[SYFI_ConstInfo].def) : (((((syme)->kind == SYME_Trigger ? libGetAllSymes((syme)->lib) : ((void*)0 )), (syme))->locmask) & (1 << (SYFI_ConstInfo))) ? ((((((syme)->kind == SYME_Trigger ? libGetAllSymes((syme )->lib) : ((void*)0)), (syme))->locmask) & (1 << (SYFI_ConstInfo))) ? ((syme)->fieldv)[symeIndex(syme,SYFI_ConstInfo )] : (symeFieldInfo[SYFI_ConstInfo].def)) : symeGetFieldFn(syme ,SYFI_ConstInfo))) & 0xFFFF), tfPretty(symeType(syme))); |
| 114 | } |
| 115 | |
| 116 | aprintf(">>> Cascades\n"); |
| 117 | tqList = tfGetDomCascades(tf); |
| 118 | |
| 119 | for (; tqList != listNil(TQual)((TQualList) 0); tqList = cdr(tqList)((tqList)->rest)) { |
| 120 | TQual tq = car(tqList)((tqList)->first); |
| 121 | aprintf("--> %s\n", tfPretty(tqBase(tq)((tq)->base))); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | scobindFiniFile(); |
| 126 | stabFiniFile(); |
| 127 | comsgFini(); |
| 128 | macexFiniFile(); |
| 129 | dbFini(); |
| 130 | |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | localstatic AbSyn |
| 135 | shexpParse(String txt) |
| 136 | { |
| 137 | AbSyn ab; |
| 138 | TokenList tl; |
| 139 | SrcLineList sll; |
| 140 | SrcLine srcLine = slineNew(sposNone, 0, txt); |
| 141 | |
| 142 | sll = listList(SrcLine)(SrcLine_listPointer->List)(1, srcLine); |
| 143 | tl = scan(sll); |
| 144 | tl = linearize(tl); |
| 145 | ab = parse(&tl); |
| 146 | ab = abNormal(ab, false((int) 0)); |
| 147 | ab = macroExpand(ab); |
| 148 | ab = abNormal(ab, true1); |
| 149 | |
| 150 | return ab; |
| 151 | } |