| File: | src/ti_sef.c |
| Warning: | line 160, column 7 Access to field 'kind' results in a dereference of a null pointer |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /**************************************************************************** | |||
| 2 | * | |||
| 3 | * ti_sef.c: Type inference -- sefo pass. | |||
| 4 | * | |||
| 5 | * Copyright (c) 1990-2007 Aldor Software Organization Ltd (Aldor.org). | |||
| 6 | * | |||
| 7 | ***************************************************************************/ | |||
| 8 | ||||
| 9 | #include "debug.h" | |||
| 10 | #include "fluid.h" | |||
| 11 | #include "format.h" | |||
| 12 | #include "spesym.h" | |||
| 13 | #include "stab.h" | |||
| 14 | #include "ti_sef.h" | |||
| 15 | #include "tinfer.h" | |||
| 16 | #include "terror.h" | |||
| 17 | #include "util.h" | |||
| 18 | #include "sefo.h" | |||
| 19 | #include "lib.h" | |||
| 20 | #include "tposs.h" | |||
| 21 | #include "tfsat.h" | |||
| 22 | #include "abpretty.h" | |||
| 23 | ||||
| 24 | /* see ti_tdn.c for definitions of following */ | |||
| 25 | ||||
| 26 | extern TForm tuniYieldTForm, tuniReturnTForm, tuniExitTForm; | |||
| 27 | ||||
| 28 | /***************************************************************************** | |||
| 29 | * | |||
| 30 | * :: Selective debug stuff | |||
| 31 | * | |||
| 32 | ****************************************************************************/ | |||
| 33 | ||||
| 34 | Bool tipSefDebug = false((int) 0); | |||
| 35 | #define tipSefDEBUGif (!tipSefDebug) { } else afprintf DEBUG_IF(tipSef)if (!tipSefDebug) { } else afprintf | |||
| 36 | ||||
| 37 | /***************************************************************************** | |||
| 38 | * | |||
| 39 | * :: Declarations for sefo pass | |||
| 40 | * | |||
| 41 | ****************************************************************************/ | |||
| 42 | ||||
| 43 | localstatic void tisef0Generic (Stab, Sefo); | |||
| 44 | localstatic TForm tisef0Within (Stab, Sefo, SymeList); | |||
| 45 | localstatic void tisef0FarValue (Stab, Sefo, TForm *); | |||
| 46 | localstatic void tisef0ApplySymIfNeeded | |||
| 47 | (Stab, Sefo, Length, AbSynGetter, Sefo, | |||
| 48 | TFormPredicate); | |||
| 49 | localstatic void tisef0ApplySym (Stab, Sefo, Length, AbSynGetter, Sefo); | |||
| 50 | localstatic void tisef0ApplyFType(Stab, Sefo, Sefo, Length, AbSynGetter); | |||
| 51 | localstatic void tisef0ApplyJoin (Stab, Sefo, Sefo, Length, AbSynGetter); | |||
| 52 | localstatic void tisef0ApplySpecialSyme | |||
| 53 | (Stab, Sefo); | |||
| 54 | ||||
| 55 | localstatic void tisefId (Stab, Sefo); | |||
| 56 | localstatic void tisefIdSy (Stab, Sefo); | |||
| 57 | localstatic void tisefBlank (Stab, Sefo); | |||
| 58 | localstatic void tisefLitInteger (Stab, Sefo); | |||
| 59 | localstatic void tisefLitFloat (Stab, Sefo); | |||
| 60 | localstatic void tisefLitString (Stab, Sefo); | |||
| 61 | localstatic void tisefAdd (Stab, Sefo); | |||
| 62 | localstatic void tisefAnd (Stab, Sefo); | |||
| 63 | localstatic void tisefApply (Stab, Sefo); | |||
| 64 | localstatic void tisefAssert (Stab, Sefo); | |||
| 65 | localstatic void tisefAssign (Stab, Sefo); | |||
| 66 | localstatic void tisefBreak (Stab, Sefo); | |||
| 67 | localstatic void tisefBuiltin (Stab, Sefo); | |||
| 68 | localstatic void tisefCoerceTo (Stab, Sefo); | |||
| 69 | localstatic void tisefCollect (Stab, Sefo); | |||
| 70 | localstatic void tisefComma (Stab, Sefo); | |||
| 71 | localstatic void tisefDeclare (Stab, Sefo); | |||
| 72 | localstatic void tisefDefault (Stab, Sefo); | |||
| 73 | localstatic void tisefDefine (Stab, Sefo); | |||
| 74 | localstatic void tisefDelay (Stab, Sefo); | |||
| 75 | localstatic void tisefDo (Stab, Sefo); | |||
| 76 | localstatic void tisefExcept (Stab, Sefo); | |||
| 77 | localstatic void tisefRaise (Stab, Sefo); | |||
| 78 | localstatic void tisefExit (Stab, Sefo); | |||
| 79 | localstatic void tisefExport (Stab, Sefo); | |||
| 80 | localstatic void tisefExtend (Stab, Sefo); | |||
| 81 | localstatic void tisefFix (Stab, Sefo); | |||
| 82 | localstatic void tisefFluid (Stab, Sefo); | |||
| 83 | localstatic void tisefFor (Stab, Sefo); | |||
| 84 | localstatic void tisefForeignImport(Stab, Sefo); | |||
| 85 | localstatic void tisefForeignExport(Stab, Sefo); | |||
| 86 | localstatic void tisefFree (Stab, Sefo); | |||
| 87 | localstatic void tisefGenerate (Stab, Sefo); | |||
| 88 | localstatic void tisefReference (Stab, Sefo); | |||
| 89 | localstatic void tisefGoto (Stab, Sefo); | |||
| 90 | localstatic void tisefHas (Stab, Sefo); | |||
| 91 | localstatic void tisefHide (Stab, Sefo); | |||
| 92 | localstatic void tisefIf (Stab, Sefo); | |||
| 93 | localstatic void tisefImport (Stab, Sefo); | |||
| 94 | localstatic void tisefInline (Stab, Sefo); | |||
| 95 | localstatic void tisefIterate (Stab, Sefo); | |||
| 96 | localstatic void tisefLabel (Stab, Sefo); | |||
| 97 | localstatic void tisefLambda (Stab, Sefo); | |||
| 98 | localstatic void tisefLocal (Stab, Sefo); | |||
| 99 | localstatic void tisefLet (Stab, Sefo); | |||
| 100 | localstatic void tisefMacro (Stab, Sefo); | |||
| 101 | localstatic void tisefMLambda (Stab, Sefo); | |||
| 102 | localstatic void tisefNever (Stab, Sefo); | |||
| 103 | localstatic void tisefNot (Stab, Sefo); | |||
| 104 | localstatic void tisefNothing (Stab, Sefo); | |||
| 105 | localstatic void tisefOr (Stab, Sefo); | |||
| 106 | localstatic void tisefPretendTo (Stab, Sefo); | |||
| 107 | localstatic void tisefQualify (Stab, Sefo); | |||
| 108 | localstatic void tisefQuote (Stab, Sefo); | |||
| 109 | localstatic void tisefRepeat (Stab, Sefo); | |||
| 110 | localstatic void tisefRestrictTo (Stab, Sefo); | |||
| 111 | localstatic void tisefReturn (Stab, Sefo); | |||
| 112 | localstatic void tisefSelect (Stab, Sefo); | |||
| 113 | localstatic void tisefSequence (Stab, Sefo); | |||
| 114 | localstatic void tisefTest (Stab, Sefo); | |||
| 115 | localstatic void tisefTry (Stab, Sefo); | |||
| 116 | localstatic void tisefWhere (Stab, Sefo); | |||
| 117 | localstatic void tisefWhile (Stab, Sefo); | |||
| 118 | localstatic void tisefWith (Stab, Sefo); | |||
| 119 | localstatic void tisefYield (Stab, Sefo); | |||
| 120 | ||||
| 121 | /***************************************************************************** | |||
| 122 | * | |||
| 123 | * :: Sefo pass | |||
| 124 | * | |||
| 125 | ****************************************************************************/ | |||
| 126 | ||||
| 127 | Bool | |||
| 128 | tiCanSefo(Sefo sefo) | |||
| 129 | { | |||
| 130 | Bool result = true1; | |||
| 131 | Length i; | |||
| 132 | ||||
| 133 | if (abIsId(sefo)((sefo)->abHdr.tag == (AB_Id)) && abIdSym(sefo)((sefo)->abId.sym) == ssymType && abSyme(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->syme : 0 ) == NULL((void*)0)) { | |||
| 134 | abSetSyme(sefo, tfpIdSyme(stabFile(), abIdSym(sefo)((sefo)->abId.sym))); | |||
| 135 | } | |||
| 136 | ||||
| 137 | if (abIsApply(sefo)((sefo)->abHdr.tag == (AB_Apply))) | |||
| 138 | tisef0ApplySpecialSyme(stabFile(), sefo); | |||
| 139 | ||||
| 140 | if (abIsId(sefo)((sefo)->abHdr.tag == (AB_Id))) | |||
| 141 | result = abSyme(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->syme : 0 ) != NULL((void*)0); | |||
| 142 | ||||
| 143 | else if (!abIsLeaf(sefo)(((sefo)->abHdr.tag) < AB_NODE_START)) | |||
| 144 | for (i = 0; result && i < abArgc(sefo)((sefo)->abHdr.argc); i += 1) | |||
| 145 | result = tiCanSefo(abArgv(sefo)((sefo)->abGen.data.argv)[i]); | |||
| 146 | ||||
| 147 | return result; | |||
| 148 | } | |||
| 149 | ||||
| 150 | ||||
| 151 | /* Adjust the stab as needed to localize parameter symes in sefo. */ | |||
| 152 | localstatic Stab | |||
| 153 | tiSefoStab(Stab stab, Sefo sefo) | |||
| 154 | { | |||
| 155 | if (abStab(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->stab : 0 )) | |||
| 156 | return stab; | |||
| 157 | ||||
| 158 | if (abIsId(sefo)((sefo)->abHdr.tag == (AB_Id))) { | |||
| 159 | assert(abSyme(sefo))do { if (!(((sefo)->abHdr.seman ? (sefo)->abHdr.seman-> syme : 0))) _do_assert(("abSyme(sefo)"),"ti_sef.c",159); } while (0); | |||
| 160 | if (symeIsParam(abSyme(sefo))(((((((sefo)->abHdr.seman ? (sefo)->abHdr.seman->syme : 0))->kind == SYME_Trigger ? libGetAllSymes((((sefo)-> abHdr.seman ? (sefo)->abHdr.seman->syme : 0))->lib) : ((void*)0)), (((sefo)->abHdr.seman ? (sefo)->abHdr.seman ->syme : 0)))->kind) == SYME_Param)) | |||
| ||||
| 161 | stab = stabFindLevel(stab, abSyme(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->syme : 0 )); | |||
| 162 | } | |||
| 163 | ||||
| 164 | else if (!abIsLeaf(sefo)(((sefo)->abHdr.tag) < AB_NODE_START)) { | |||
| 165 | Length i; | |||
| 166 | for (i = 0; i < abArgc(sefo)((sefo)->abHdr.argc); i += 1) | |||
| 167 | stab = tiSefoStab(stab, abArgv(sefo)((sefo)->abGen.data.argv)[i]); | |||
| 168 | } | |||
| 169 | ||||
| 170 | return stab; | |||
| 171 | } | |||
| 172 | ||||
| 173 | void | |||
| 174 | tiSefo(Stab stab, Sefo sefo) | |||
| 175 | { | |||
| 176 | Scope("tiSefo")String scopeName = ("tiSefo"); int fluidLevel0 = (scopeLevel++ , fluidLevel); | |||
| 177 | ||||
| 178 | TForm fluid(tuniReturnTForm)fluidSave_tuniReturnTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniReturnTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniReturnTForm , fluidStack[fluidLevel].size = sizeof(tuniReturnTForm), fluidLevel ++, (tuniReturnTForm) ); | |||
| ||||
| 179 | TForm fluid(tuniYieldTForm)fluidSave_tuniYieldTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniYieldTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniYieldTForm , fluidStack[fluidLevel].size = sizeof(tuniYieldTForm), fluidLevel ++, (tuniYieldTForm) ); | |||
| 180 | TForm fluid(tuniExitTForm)fluidSave_tuniExitTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniExitTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniExitTForm , fluidStack[fluidLevel].size = sizeof(tuniExitTForm), fluidLevel ++, (tuniExitTForm) ); | |||
| 181 | ||||
| 182 | tuniReturnTForm = tfNone()tfMulti(0); | |||
| 183 | tuniYieldTForm = tfNone()tfMulti(0); | |||
| 184 | tuniExitTForm = tfNone()tfMulti(0); | |||
| 185 | ||||
| 186 | stab = tiSefoStab(stab, sefo); | |||
| 187 | tisef(stab, sefo); | |||
| 188 | ||||
| 189 | ReturnNothing{ fluidUnwind(fluidLevel0, ((int) 0)); return;; }; | |||
| 190 | } | |||
| 191 | ||||
| 192 | void | |||
| 193 | tisef(Stab stab, Sefo sefo) | |||
| 194 | { | |||
| 195 | static int serialNo = 0, depthNo = 0; | |||
| 196 | int serialThis; | |||
| 197 | ||||
| 198 | assert(sefo)do { if (!(sefo)) _do_assert(("sefo"),"ti_sef.c",198); } while (0); | |||
| 199 | ||||
| 200 | if (abState(sefo)((sefo)->abHdr.state) == AB_State_HasUnique) | |||
| 201 | return; | |||
| 202 | ||||
| 203 | if (abState(sefo)((sefo)->abHdr.state) == AB_State_HasPoss) { | |||
| 204 | TPoss tposs = abTPoss(sefo)((sefo)->abHdr.type.poss); | |||
| 205 | ||||
| 206 | if (tpossIsUnique(tposs)) | |||
| 207 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tpossUnique(tposs); | |||
| 208 | else { | |||
| 209 | terrorNotUniqueType(ALDOR_E_TinExprMeans164, | |||
| 210 | sefo, tfNone()tfMulti(0), tposs); | |||
| 211 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfUnknown; | |||
| 212 | } | |||
| 213 | abState(sefo)((sefo)->abHdr.state) = AB_State_HasUnique; | |||
| 214 | tpossFree(tposs); | |||
| 215 | return; | |||
| 216 | } | |||
| 217 | ||||
| 218 | if (!abIsLeaf(sefo)(((sefo)->abHdr.tag) < AB_NODE_START) && abStab(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->stab : 0 )) | |||
| 219 | stab = abStab(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->stab : 0 ); | |||
| 220 | ||||
| 221 | serialNo += 1; | |||
| 222 | depthNo += 1; | |||
| 223 | serialThis = serialNo; | |||
| 224 | if (DEBUG(tipSef)tipSefDebug) { | |||
| 225 | fprintf(dbOut,"->Sef: %*s%d= ", depthNo, "", serialThis); | |||
| 226 | abPrettyPrint(dbOut, sefo); | |||
| 227 | fnewline(dbOut); | |||
| 228 | } | |||
| 229 | ||||
| 230 | abState(sefo)((sefo)->abHdr.state) = AB_State_HasUnique; | |||
| 231 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfUnknown; | |||
| 232 | ||||
| 233 | AB_SWITCH(sefo, tisef, (stab, sefo))switch (((sefo)->abHdr.tag)) { case AB_Id: tisefId (stab, sefo ); break; case AB_IdSy: tisefIdSy (stab, sefo); break; case AB_Blank : tisefBlank (stab, sefo); break; case AB_LitInteger: tisefLitInteger (stab, sefo); break; case AB_LitFloat: tisefLitFloat (stab, sefo ); break; case AB_LitString: tisefLitString (stab, sefo); break ; case AB_Add: tisefAdd (stab, sefo); break; case AB_And: tisefAnd (stab, sefo); break; case AB_Apply: tisefApply (stab, sefo); break; case AB_Assert: tisefAssert (stab, sefo); break; case AB_Assign: tisefAssign (stab, sefo); break; case AB_Break: tisefBreak (stab, sefo); break; case AB_Builtin: tisefBuiltin (stab, sefo ); break; case AB_CoerceTo: tisefCoerceTo (stab, sefo); break ; case AB_Collect: tisefCollect (stab, sefo); break; case AB_Comma : tisefComma (stab, sefo); break; case AB_Declare: tisefDeclare (stab, sefo); break; case AB_Default: tisefDefault (stab, sefo ); break; case AB_Define: tisefDefine (stab, sefo); break; case AB_Delay: tisefDelay (stab, sefo); break; case AB_Do: tisefDo (stab, sefo); break; case AB_Except: tisefExcept (stab, sefo ); break; case AB_Raise: tisefRaise (stab, sefo); break; case AB_Exit: tisefExit (stab, sefo); break; case AB_Export: tisefExport (stab, sefo); break; case AB_Extend: tisefExtend (stab, sefo ); break; case AB_Fix: tisefFix (stab, sefo); break; case AB_Fluid : tisefFluid (stab, sefo); break; case AB_For: tisefFor (stab , sefo); break; case AB_ForeignImport: tisefForeignImport (stab , sefo); break; case AB_ForeignExport: tisefForeignExport (stab , sefo); break; case AB_Free: tisefFree (stab, sefo); break; case AB_Generate: tisefGenerate (stab, sefo); break; case AB_Goto : tisefGoto (stab, sefo); break; case AB_Has: tisefHas (stab, sefo); break; case AB_Hide: tisefHide (stab, sefo); break; case AB_If: tisefIf (stab, sefo); break; case AB_Import: tisefImport (stab, sefo); break; case AB_Inline: tisefInline (stab, sefo ); break; case AB_Iterate: tisefIterate (stab, sefo); break; case AB_Label: tisefLabel (stab, sefo); break; case AB_Lambda: tisefLambda (stab, sefo); break; case AB_Let: tisefLet (stab, sefo); break ; case AB_Local: tisefLocal (stab, sefo); break; case AB_Macro : tisefMacro (stab, sefo); break; case AB_MLambda: tisefMLambda (stab, sefo); break; case AB_Never: tisefNever (stab, sefo); break; case AB_Not: tisefNot (stab, sefo); break; case AB_Nothing : tisefNothing (stab, sefo); break; case AB_Or: tisefOr (stab , sefo); break; case AB_PLambda: tisefLambda (stab, sefo); break ; case AB_PretendTo: tisefPretendTo (stab, sefo); break; case AB_Qualify: tisefQualify (stab, sefo); break; case AB_Quote: tisefQuote (stab, sefo); break; case AB_Reference: tisefReference (stab, sefo); break; case AB_Repeat: tisefRepeat (stab, sefo ); break; case AB_RestrictTo: tisefRestrictTo (stab, sefo); break ; case AB_Return: tisefReturn (stab, sefo); break; case AB_Select : tisefSelect (stab, sefo); break; case AB_Sequence: tisefSequence (stab, sefo); break; case AB_Test: tisefTest (stab, sefo); break ; case AB_Try: tisefTry (stab, sefo); break; case AB_Where: tisefWhere (stab, sefo); break; case AB_While: tisefWhile (stab, sefo); break; case AB_With: tisefWith (stab, sefo); break; case AB_Yield : tisefYield (stab, sefo); break; default: bug("Bad case %d (line %d in file %s)." , (int) ((sefo)->abHdr.tag), 233, "ti_sef.c"); }; | |||
| 234 | ||||
| 235 | if (DEBUG(tipSef)tipSefDebug) { | |||
| 236 | fprintf(dbOut, "<-Sef: %*s%d= ", depthNo, "", serialThis); | |||
| 237 | abPrettyPrint(dbOut, sefo); | |||
| 238 | fprintf(dbOut, " @ "); | |||
| 239 | tfPrint(dbOut, abTUnique(sefo)((sefo)->abHdr.type.unique)); | |||
| 240 | fnewline(dbOut); | |||
| 241 | } | |||
| 242 | depthNo -= 1; | |||
| 243 | } | |||
| 244 | ||||
| 245 | /**************************************************************************** | |||
| 246 | * | |||
| 247 | * :: Generic: abArgc(ab), abArgv(ab) | |||
| 248 | * | |||
| 249 | ***************************************************************************/ | |||
| 250 | ||||
| 251 | localstatic void | |||
| 252 | tisef0Generic(Stab stab, Sefo sefo) | |||
| 253 | { | |||
| 254 | Length i; | |||
| 255 | if (!abIsLeaf(sefo)(((sefo)->abHdr.tag) < AB_NODE_START)) | |||
| 256 | for (i = 0; i < abArgc(sefo)((sefo)->abHdr.argc); i += 1) | |||
| 257 | tisef(stab, abArgv(sefo)((sefo)->abGen.data.argv)[i]); | |||
| 258 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfNone()tfMulti(0); | |||
| 259 | } | |||
| 260 | ||||
| 261 | /**************************************************************************** | |||
| 262 | * | |||
| 263 | * :: Within: with bodies, default bodies, conditional branches | |||
| 264 | * | |||
| 265 | ***************************************************************************/ | |||
| 266 | ||||
| 267 | localstatic TForm | |||
| 268 | tisef0Within(Stab stab, Sefo sefo, SymeList bsymes) | |||
| 269 | { | |||
| 270 | SymeList xsymes, isymes, dsymes, ssymes, symes; | |||
| 271 | Length i, argc; | |||
| 272 | AbSyn *argv; | |||
| 273 | TForm tf; | |||
| 274 | ||||
| 275 | AB_SEQ_ITER(sefo, argc, argv){ switch (((sefo)->abHdr.tag)) { case AB_Nothing: argc = 0 ; argv = 0; break; case AB_Sequence: argc = ((sefo)->abHdr .argc); argv = ((sefo)->abGen.data.argv); break; default: argc = 1; argv = &sefo; break; }; }; | |||
| 276 | ||||
| 277 | xsymes = isymes = dsymes = ssymes = listNil(Syme)((SymeList) 0); | |||
| 278 | for (i = 0; i < argc; i += 1) { | |||
| 279 | AbSyn id = abDefineeIdOrElse(argv[i], NULL((void*)0)); | |||
| 280 | ||||
| 281 | /* Empty body. */ | |||
| 282 | if (abTag(argv[i])((argv[i])->abHdr.tag) == AB_Nothing) | |||
| 283 | ; | |||
| 284 | ||||
| 285 | /* Default body. */ | |||
| 286 | else if (abTag(argv[i])((argv[i])->abHdr.tag) == AB_Default) { | |||
| 287 | tisef(stab, argv[i]); | |||
| 288 | symes = abGetCatExports(argv[i]); | |||
| 289 | dsymes = listConcat(Syme)(Syme_listPointer->Concat)(symes, dsymes); | |||
| 290 | } | |||
| 291 | ||||
| 292 | /* Explicit declaration/definition. */ | |||
| 293 | else if (id && abTag(argv[i])((argv[i])->abHdr.tag) != AB_Id) { | |||
| 294 | assert(abSyme(id))do { if (!(((id)->abHdr.seman ? (id)->abHdr.seman->syme : 0))) _do_assert(("abSyme(id)"),"ti_sef.c",294); } while (0 ); | |||
| 295 | if (symeIsExport(abSyme(id))(((((((id)->abHdr.seman ? (id)->abHdr.seman->syme : 0 ))->kind == SYME_Trigger ? libGetAllSymes((((id)->abHdr .seman ? (id)->abHdr.seman->syme : 0))->lib) : ((void *)0)), (((id)->abHdr.seman ? (id)->abHdr.seman->syme : 0)))->kind) == SYME_Export)) | |||
| 296 | xsymes = listCons(Syme)(Syme_listPointer->Cons)(abSyme(id)((id)->abHdr.seman ? (id)->abHdr.seman->syme : 0), xsymes); | |||
| 297 | } | |||
| 298 | ||||
| 299 | /* Category expression. */ | |||
| 300 | else { | |||
| 301 | tisef(stab, argv[i]); | |||
| 302 | symes = abGetCatExports(argv[i]); | |||
| 303 | isymes = symeListUnion(isymes, symes, symeEqual); | |||
| 304 | symes = abGetCatSelf(argv[i]); | |||
| 305 | ssymes = symeListUnion(ssymes, symes, symeEqual); | |||
| 306 | } | |||
| 307 | } | |||
| 308 | ||||
| 309 | /* Mark the symes which have a default implementation. */ | |||
| 310 | dsymes = listNReverse(Syme)(Syme_listPointer->NReverse)(dsymes); | |||
| 311 | for (; dsymes; dsymes = listFreeCons(Syme)(Syme_listPointer->FreeCons)(dsymes)) { | |||
| 312 | Syme dsyme = car(dsymes)((dsymes)->first); | |||
| 313 | Syme xsyme = NULL((void*)0); | |||
| 314 | ||||
| 315 | /* If the default is one of our exports, just mark it. */ | |||
| 316 | for (symes = xsymes; !xsyme && symes; symes = cdr(symes)((symes)->rest)) | |||
| 317 | if (symeEqual(car(symes)((symes)->first), dsyme)) { | |||
| 318 | xsyme = car(symes)((symes)->first); | |||
| 319 | symeSetDefault(xsyme)(((((xsyme)->kind == SYME_Trigger ? libGetAllSymes((xsyme) ->lib) : ((void*)0)), (xsyme))->bits) |= (0x0080)); | |||
| 320 | symeSetSrcPos(xsyme, symeSrcPos(dsyme))(symeSetFieldVal = ((AInt) (((SrcPos) (SYFI_SrcPos < (8 * sizeof (int)) && !(((((dsyme)->kind == SYME_Trigger ? libGetAllSymes ((dsyme)->lib) : ((void*)0)), (dsyme))->hasmask) & ( 1 << (SYFI_SrcPos))) ? (symeFieldInfo[SYFI_SrcPos].def) : (((((dsyme)->kind == SYME_Trigger ? libGetAllSymes((dsyme )->lib) : ((void*)0)), (dsyme))->locmask) & (1 << (SYFI_SrcPos))) ? ((((((dsyme)->kind == SYME_Trigger ? libGetAllSymes ((dsyme)->lib) : ((void*)0)), (dsyme))->locmask) & ( 1 << (SYFI_SrcPos))) ? ((dsyme)->fieldv)[symeIndex(dsyme ,SYFI_SrcPos)] : (symeFieldInfo[SYFI_SrcPos].def)) : symeGetFieldFn (dsyme,SYFI_SrcPos))))), (((((xsyme)->kind == SYME_Trigger ? libGetAllSymes((xsyme)->lib) : ((void*)0)), (xsyme))-> locmask) & (1 << (SYFI_SrcPos))) ? (((xsyme)->fieldv )[symeIndex(xsyme,SYFI_SrcPos)] = (symeSetFieldVal)) : !((xsyme )->full) && symeSetFieldVal == (symeFieldInfo[SYFI_SrcPos ].def) ? symeSetFieldVal : symeSetFieldFn(xsyme,SYFI_SrcPos,symeSetFieldVal )); | |||
| 321 | } | |||
| 322 | ||||
| 323 | /* If the default is inherited, use the default syme. */ | |||
| 324 | if (xsyme == NULL((void*)0)) { | |||
| 325 | xsymes = listCons(Syme)(Syme_listPointer->Cons)(dsyme, xsymes); | |||
| 326 | symeSetDefault(dsyme)(((((dsyme)->kind == SYME_Trigger ? libGetAllSymes((dsyme) ->lib) : ((void*)0)), (dsyme))->bits) |= (0x0080)); | |||
| 327 | } | |||
| 328 | } | |||
| 329 | ||||
| 330 | xsymes = listNReverse(Syme)(Syme_listPointer->NReverse)(xsymes); | |||
| 331 | xsymes = symeListUnion(isymes, xsymes, symeEqual); | |||
| 332 | ||||
| 333 | if (abTag(sefo)((sefo)->abHdr.tag) == AB_Sequence) | |||
| 334 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfThird(xsymes); | |||
| 335 | ||||
| 336 | tf = tfThird(xsymes); | |||
| 337 | tfAddSelf(tf, ssymes); | |||
| 338 | tfHasSelf(tf)((tf)->hasSelf) = true1; | |||
| 339 | ||||
| 340 | return tf; | |||
| 341 | } | |||
| 342 | ||||
| 343 | /**************************************************************************** | |||
| 344 | * | |||
| 345 | * :: Implied call: apply, set!, test, generator, ... | |||
| 346 | * | |||
| 347 | ***************************************************************************/ | |||
| 348 | ||||
| 349 | /* | |||
| 350 | * ab ==> m(i,...) -> tibup0Apply(stab, ab, 'apply, n+1, [m,i,...]) | |||
| 351 | * ab ==> m(i,...) := x -> tibup0Apply(stab, ab, 'set!, n+2, [m,i,...,x]) | |||
| 352 | * ab ==> if bb then ... -> tibup0Apply(stab, bb, 'test, 1, [bb.cond]); | |||
| 353 | * ab ==> for i in l -> tibup0Apply(stab, ab, 'iterator, 1, [l]) | |||
| 354 | * ab ==> x::T -> tibup0Apply(stab, ab, 'coerce, 1, [x]) | |||
| 355 | * | |||
| 356 | * Could also do... | |||
| 357 | * | |||
| 358 | * ab ==> 3 -> tibup0Apply(stab, ab, 'integer, 0, []) | |||
| 359 | * ab ==> "3.14" -> tibup0Apply(stab, ab, 'float, 0, []) | |||
| 360 | * ab ==> "hello" -> tibup0Apply(stab, ab, 'string, 0, []) | |||
| 361 | */ | |||
| 362 | ||||
| 363 | localstatic void | |||
| 364 | tisef0ApplySymIfNeeded(Stab stab, Sefo sefo, Length argc, AbSynGetter argf, | |||
| 365 | Sefo implicitPart, TFormPredicate pred) | |||
| 366 | { | |||
| 367 | Sefo part; | |||
| 368 | TForm tf; | |||
| 369 | ||||
| 370 | assert(argc == 1)do { if (!(argc == 1)) _do_assert(("argc == 1"),"ti_sef.c",370 ); } while (0); | |||
| 371 | ||||
| 372 | part = argf(sefo, int0((int) 0)); | |||
| 373 | tf = abTUnique(part)((part)->abHdr.type.unique); | |||
| 374 | ||||
| 375 | if (pred(tf)) | |||
| 376 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(part)((part)->abHdr.type.unique); | |||
| 377 | else | |||
| 378 | tisef0ApplySym(stab, sefo, argc, argf, implicitPart); | |||
| 379 | } | |||
| 380 | ||||
| 381 | localstatic void | |||
| 382 | tisef0ApplySym(Stab stab, Sefo sefo, Length argc, AbSynGetter argf, | |||
| 383 | Sefo implicitPart) | |||
| 384 | { | |||
| 385 | Sefo imp; | |||
| 386 | if (!implicitPart) implicitPart = sefo; | |||
| 387 | ||||
| 388 | imp = abImplicit(implicitPart)((implicitPart)->abHdr.seman ? (implicitPart)->abHdr.seman ->implicit : 0); | |||
| 389 | ||||
| 390 | if (imp) { | |||
| 391 | tisef(stab, imp); | |||
| 392 | tisef0ApplyFType(stab, sefo, imp, argc, argf); | |||
| 393 | } | |||
| 394 | else | |||
| 395 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfUnknown; | |||
| 396 | } | |||
| 397 | ||||
| 398 | localstatic void | |||
| 399 | tisef0ApplyJoin(Stab stab, Sefo sefo, Sefo op, Length argc, AbSynGetter argf) | |||
| 400 | { | |||
| 401 | SymeList symes = listNil(Syme)((SymeList) 0), mods = listNil(Syme)((SymeList) 0); | |||
| 402 | TForm selftf; | |||
| 403 | Length i; | |||
| 404 | ||||
| 405 | /* Collect the category exports for the result. */ | |||
| 406 | for (i = 0; i < argc; i += 1) { | |||
| 407 | TForm tfi = abTUnique(argf(sefo, i))((argf(sefo, i))->abHdr.type.unique); | |||
| 408 | SymeList symesi = tfGetThdExports(tfi); | |||
| 409 | symes = tfJoinExportLists(mods, symes, symesi, NULL((void*)0)); | |||
| 410 | } | |||
| 411 | selftf = tfThird(symes); | |||
| 412 | ||||
| 413 | /* Collect the symbol meaning(s) for self for the result. */ | |||
| 414 | for (i = 0; i < argc; i += 1) | |||
| 415 | tfAddSelf(selftf, tfGetThdSelf(abTUnique(argf(sefo, i))((argf(sefo, i))->abHdr.type.unique))); | |||
| 416 | ||||
| 417 | abTUnique(sefo)((sefo)->abHdr.type.unique) = selftf; | |||
| 418 | } | |||
| 419 | ||||
| 420 | localstatic void | |||
| 421 | tisef0ApplyFType(Stab stab, Sefo sefo, Sefo op, Length argc, AbSynGetter argf) | |||
| 422 | { | |||
| 423 | SatMask mask = tfSatSefMask(); | |||
| 424 | TForm opType = abTUnique(op)((op)->abHdr.type.unique), retType; | |||
| 425 | ||||
| 426 | assert(tfIsAnyMap(opType))do { if (!(((((opType)->tag) == TF_Map) || (((opType)-> tag) == TF_PackedMap)))) _do_assert(("tfIsAnyMap(opType)"),"ti_sef.c" ,426); } while (0); | |||
| 427 | retType = tfMapRet(opType)tfFollowArg(opType, 1); | |||
| 428 | ||||
| 429 | if (abIsTheId(op, ssymJoin)(((op)->abHdr.tag == (AB_Id)) && ((op)->abId.sym )==(ssymJoin)) && tfSatisfies(retType, tfCategory)) { | |||
| 430 | tisef0ApplyJoin(stab, sefo, op, argc, argf); | |||
| 431 | return; | |||
| 432 | } | |||
| 433 | ||||
| 434 | tiTfSefo(stab, opType); | |||
| 435 | tfSatMap(mask, stab, opType, tfUnknown, sefo, argc, argf); | |||
| 436 | } | |||
| 437 | ||||
| 438 | /**************************************************************************** | |||
| 439 | * | |||
| 440 | * :: Far Values: return x, yield x, a => x | |||
| 441 | * | |||
| 442 | ***************************************************************************/ | |||
| 443 | ||||
| 444 | localstatic void | |||
| 445 | tisef0FarValue(Stab stab, Sefo farValue, TForm *pFarType) | |||
| 446 | { | |||
| 447 | if (tfIsUnknown(*pFarType)(((*pFarType)->tag) == TF_Unknown)) | |||
| 448 | *pFarType = abTUnique(farValue)((farValue)->abHdr.type.unique); | |||
| 449 | } | |||
| 450 | ||||
| 451 | ||||
| 452 | /**************************************************************************** | |||
| 453 | * | |||
| 454 | * :: Id: x, +, 1 | |||
| 455 | * X | |||
| 456 | ***************************************************************************/ | |||
| 457 | ||||
| 458 | localstatic void | |||
| 459 | tisefId(Stab stab, Sefo sefo) | |||
| 460 | { | |||
| 461 | Syme syme = abSyme(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->syme : 0 ); | |||
| 462 | ||||
| 463 | if (syme) | |||
| 464 | abTUnique(sefo)((sefo)->abHdr.type.unique) = symeType(syme); | |||
| 465 | else | |||
| 466 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfUnknown; | |||
| 467 | } | |||
| 468 | ||||
| 469 | /**************************************************************************** | |||
| 470 | * | |||
| 471 | * :: LitInteger: 32 | |||
| 472 | * :: LitFloat: 4.0 | |||
| 473 | * :: LitString: "hello" | |||
| 474 | * X | |||
| 475 | * !! This stuff could be made to go through ti...0Apply. | |||
| 476 | ***************************************************************************/ | |||
| 477 | ||||
| 478 | localstatic void tisef0Literal (Stab, Sefo); | |||
| 479 | ||||
| 480 | /* | |||
| 481 | * Sefo entry points. | |||
| 482 | */ | |||
| 483 | ||||
| 484 | localstatic void | |||
| 485 | tisefLitInteger(Stab stab, Sefo sefo) | |||
| 486 | { | |||
| 487 | tisef0Literal(stab, sefo); | |||
| 488 | } | |||
| 489 | ||||
| 490 | localstatic void | |||
| 491 | tisefLitFloat(Stab stab, Sefo sefo) | |||
| 492 | { | |||
| 493 | tisef0Literal(stab, sefo); | |||
| 494 | } | |||
| 495 | ||||
| 496 | localstatic void | |||
| 497 | tisefLitString(Stab stab, Sefo sefo) | |||
| 498 | { | |||
| 499 | tisef0Literal(stab, sefo); | |||
| 500 | } | |||
| 501 | ||||
| 502 | /* | |||
| 503 | * Functions which actually do the work. | |||
| 504 | */ | |||
| 505 | ||||
| 506 | localstatic void | |||
| 507 | tisef0Literal(Stab stab, Sefo sefo) | |||
| 508 | { | |||
| 509 | Syme syme = abSyme(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->syme : 0 ); | |||
| 510 | ||||
| 511 | if (syme) | |||
| 512 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfMapRet(symeType(syme))tfFollowArg(symeType(syme), 1); | |||
| 513 | else | |||
| 514 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfUnknown; | |||
| 515 | } | |||
| 516 | ||||
| 517 | ||||
| 518 | /*************************************************************************** | |||
| 519 | * | |||
| 520 | * :: Comma: (a, b) | |||
| 521 | * | |||
| 522 | ***************************************************************************/ | |||
| 523 | ||||
| 524 | localstatic void | |||
| 525 | tisefComma(Stab stab, Sefo sefo) | |||
| 526 | { | |||
| 527 | tisef0Generic(stab, sefo); | |||
| 528 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfMultiFrTUnique(sefo); | |||
| 529 | } | |||
| 530 | ||||
| 531 | /**************************************************************************** | |||
| 532 | * | |||
| 533 | * :: Apply: f(a, b, ...) | |||
| 534 | * | |||
| 535 | ***************************************************************************/ | |||
| 536 | ||||
| 537 | localstatic void | |||
| 538 | tisef0ApplySpecialSyme(Stab stab, Sefo sefo) | |||
| 539 | { | |||
| 540 | Sefo op = abApplyOp(sefo)((sefo)->abApply.op); | |||
| 541 | Syme syme; | |||
| 542 | ||||
| 543 | if (abTag(op)((op)->abHdr.tag) == AB_Id && abSyme(op)((op)->abHdr.seman ? (op)->abHdr.seman->syme : 0) == NULL((void*)0) && | |||
| 544 | (syme = tfpOpSyme(stab, op->abId.sym, abApplyArgc(sefo)(((sefo)->abHdr.argc)-1))) != 0) | |||
| 545 | abSetSyme(op, syme); | |||
| 546 | ||||
| 547 | return; | |||
| 548 | } | |||
| 549 | ||||
| 550 | localstatic void | |||
| 551 | tisefApply(Stab stab, Sefo sefo) | |||
| 552 | { | |||
| 553 | Sefo op; | |||
| 554 | TForm tf; | |||
| 555 | ||||
| 556 | tipApplyDEBUGif (!tipApplyDebug) { } else afprintf(dbOut, "Entering tisefApply\n"); | |||
| 557 | ||||
| 558 | tisef0ApplySpecialSyme(stab, sefo); | |||
| 559 | ||||
| 560 | tisef0Generic(stab, sefo); | |||
| 561 | op = abApplyOp(sefo)((sefo)->abApply.op); | |||
| 562 | ||||
| 563 | tfFollow(abTUnique(op))((((op)->abHdr.type.unique)) = tfFollowFn(((op)->abHdr. type.unique))); | |||
| 564 | tf = abTUnique(op)((op)->abHdr.type.unique); | |||
| 565 | ||||
| 566 | if (tfIsAnyMap(tf)((((tf)->tag) == TF_Map) || (((tf)->tag) == TF_PackedMap ))) | |||
| 567 | tisef0ApplyFType(stab,sefo,op,abApplyArgc(sefo)(((sefo)->abHdr.argc)-1),abApplyArgf); | |||
| 568 | else | |||
| 569 | tisef0ApplySym(stab, sefo, abArgc(sefo)((sefo)->abHdr.argc), abArgf, NULL((void*)0)); | |||
| 570 | } | |||
| 571 | ||||
| 572 | /**************************************************************************** | |||
| 573 | * | |||
| 574 | * :: Define: a == e | |||
| 575 | * X | |||
| 576 | ***************************************************************************/ | |||
| 577 | ||||
| 578 | localstatic void | |||
| 579 | tisefDefine(Stab stab, Sefo sefo) | |||
| 580 | { | |||
| 581 | tisef0Generic(stab, sefo); | |||
| 582 | if (abTag(sefo->abDefine.lhs)((sefo->abDefine.lhs)->abHdr.tag) == AB_Declare) | |||
| 583 | abTUnique(sefo)((sefo)->abHdr.type.unique) = | |||
| 584 | abTUnique(sefo->abDefine.lhs->abDeclare.type)((sefo->abDefine.lhs->abDeclare.type)->abHdr.type.unique ); | |||
| 585 | else | |||
| 586 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abDefine.rhs)((sefo->abDefine.rhs)->abHdr.type.unique); | |||
| 587 | } | |||
| 588 | ||||
| 589 | ||||
| 590 | /**************************************************************************** | |||
| 591 | * | |||
| 592 | * :: Assign: a := e | |||
| 593 | * X | |||
| 594 | ***************************************************************************/ | |||
| 595 | ||||
| 596 | /*!! To do: (v.i,v.j) := (v.j, v.i) */ | |||
| 597 | ||||
| 598 | localstatic void | |||
| 599 | tisefAssign(Stab stab, Sefo sefo) | |||
| 600 | { | |||
| 601 | tisef0Generic(stab, sefo); | |||
| 602 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abAssign.rhs)((sefo->abAssign.rhs)->abHdr.type.unique); | |||
| 603 | } | |||
| 604 | ||||
| 605 | ||||
| 606 | /**************************************************************************** | |||
| 607 | * | |||
| 608 | * :: Declare: a: A | |||
| 609 | * | |||
| 610 | ***************************************************************************/ | |||
| 611 | ||||
| 612 | localstatic void | |||
| 613 | tisefDeclare(Stab stab, Sefo sefo) | |||
| 614 | { | |||
| 615 | tisef0Generic(stab, sefo); | |||
| 616 | ||||
| 617 | if (abUse(sefo)((sefo)->abHdr.use) == AB_Use_Define || abUse(sefo)((sefo)->abHdr.use) == AB_Use_Assign) | |||
| 618 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abDeclare.id)((sefo->abDeclare.id)->abHdr.type.unique); | |||
| 619 | else | |||
| 620 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abDeclare.type)((sefo->abDeclare.type)->abHdr.type.unique); | |||
| 621 | } | |||
| 622 | ||||
| 623 | /**************************************************************************** | |||
| 624 | * | |||
| 625 | * :: Label: @@ x @@ [e] | |||
| 626 | * | |||
| 627 | ***************************************************************************/ | |||
| 628 | ||||
| 629 | localstatic void | |||
| 630 | tisefLabel(Stab stab, Sefo sefo) | |||
| 631 | { | |||
| 632 | Sefo expr = sefo->abLabel.expr; | |||
| 633 | tisef0Generic(stab, expr); | |||
| 634 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abLabel.expr)((sefo->abLabel.expr)->abHdr.type.unique); | |||
| 635 | } | |||
| 636 | ||||
| 637 | /**************************************************************************** | |||
| 638 | * | |||
| 639 | * :: Goto: goto id | |||
| 640 | * | |||
| 641 | ***************************************************************************/ | |||
| 642 | ||||
| 643 | localstatic void | |||
| 644 | tisefGoto(Stab stab, Sefo sefo) | |||
| 645 | { | |||
| 646 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfExit; | |||
| 647 | } | |||
| 648 | ||||
| 649 | /**************************************************************************** | |||
| 650 | * | |||
| 651 | * :: Lambda: (a: A): B +-> b | |||
| 652 | * :: PLambda: (a: A): B +->* b | |||
| 653 | * | |||
| 654 | ***************************************************************************/ | |||
| 655 | ||||
| 656 | localstatic void | |||
| 657 | tisefLambda(Stab stab, Sefo sefo) | |||
| 658 | { | |||
| 659 | Scope("tisefLambda")String scopeName = ("tisefLambda"); int fluidLevel0 = (scopeLevel ++, fluidLevel); | |||
| 660 | TForm tfarg, tfret; | |||
| 661 | Bool pack = abHasTag(sefo, AB_PLambda)((sefo)->abHdr.tag == (AB_PLambda)); | |||
| 662 | ||||
| 663 | TForm fluid(tuniReturnTForm)fluidSave_tuniReturnTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniReturnTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniReturnTForm , fluidStack[fluidLevel].size = sizeof(tuniReturnTForm), fluidLevel ++, (tuniReturnTForm) ); | |||
| 664 | TForm fluid(tuniYieldTForm)fluidSave_tuniYieldTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniYieldTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniYieldTForm , fluidStack[fluidLevel].size = sizeof(tuniYieldTForm), fluidLevel ++, (tuniYieldTForm) ); | |||
| 665 | TForm fluid(tuniExitTForm)fluidSave_tuniExitTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniExitTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniExitTForm , fluidStack[fluidLevel].size = sizeof(tuniExitTForm), fluidLevel ++, (tuniExitTForm) ); | |||
| 666 | ||||
| 667 | tuniReturnTForm = tfNone()tfMulti(0); | |||
| 668 | tuniYieldTForm = tfNone()tfMulti(0); | |||
| 669 | tuniExitTForm = tfNone()tfMulti(0); | |||
| 670 | ||||
| 671 | tisef0Generic(stab, sefo); | |||
| 672 | tfarg = tiGetTForm(stab, sefo->abLambda.param); | |||
| 673 | tfret = tiGetTForm(stab, sefo->abLambda.rtype); | |||
| 674 | ||||
| 675 | if (tfarg && tfret) | |||
| 676 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfAnyMap(tfarg, tfret, pack); | |||
| 677 | else | |||
| 678 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfUnknown; | |||
| 679 | ||||
| 680 | ReturnNothing{ fluidUnwind(fluidLevel0, ((int) 0)); return;; }; | |||
| 681 | } | |||
| 682 | ||||
| 683 | /**************************************************************************** | |||
| 684 | * | |||
| 685 | * :: Sequence: (a; b; c) | |||
| 686 | * | |||
| 687 | ***************************************************************************/ | |||
| 688 | ||||
| 689 | localstatic void | |||
| 690 | tisefSequence(Stab stab, Sefo sefo) | |||
| 691 | { | |||
| 692 | Scope("tisefSequence")String scopeName = ("tisefSequence"); int fluidLevel0 = (scopeLevel ++, fluidLevel); | |||
| 693 | Length n = abArgc(sefo)((sefo)->abHdr.argc); | |||
| 694 | ||||
| 695 | TForm fluid(tuniExitTForm)fluidSave_tuniExitTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniExitTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniExitTForm , fluidStack[fluidLevel].size = sizeof(tuniExitTForm), fluidLevel ++, (tuniExitTForm) ); | |||
| 696 | tuniExitTForm = tfUnknown; | |||
| 697 | ||||
| 698 | tisef0Generic(stab, sefo); | |||
| 699 | if (n > 0) { | |||
| 700 | tisef0FarValue(stab, abArgv(sefo)((sefo)->abGen.data.argv)[n-1], &tuniExitTForm); | |||
| 701 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tuniExitTForm; | |||
| 702 | } | |||
| 703 | ||||
| 704 | ReturnNothing{ fluidUnwind(fluidLevel0, ((int) 0)); return;; }; | |||
| 705 | } | |||
| 706 | ||||
| 707 | /**************************************************************************** | |||
| 708 | * | |||
| 709 | * :: Exit: (...; b => x ; ...) | |||
| 710 | * | |||
| 711 | ***************************************************************************/ | |||
| 712 | ||||
| 713 | localstatic void | |||
| 714 | tisefExit(Stab stab, Sefo sefo) | |||
| 715 | { | |||
| 716 | tisef0Generic(stab, sefo); | |||
| 717 | tisef0FarValue(stab, sefo->abExit.value, &tuniExitTForm); | |||
| 718 | } | |||
| 719 | ||||
| 720 | /*************************************************************************** | |||
| 721 | * | |||
| 722 | * :: return: return x, return; | |||
| 723 | * | |||
| 724 | ***************************************************************************/ | |||
| 725 | ||||
| 726 | localstatic void | |||
| 727 | tisefReturn(Stab stab, Sefo sefo) | |||
| 728 | { | |||
| 729 | tisef0Generic(stab, sefo); | |||
| 730 | /* tuniReturnTForm is not used by tisefLambda. */ | |||
| 731 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfExit; | |||
| 732 | } | |||
| 733 | ||||
| 734 | /**************************************************************************** | |||
| 735 | * | |||
| 736 | * :: Generate: generate (... yield ...) | |||
| 737 | * | |||
| 738 | ***************************************************************************/ | |||
| 739 | ||||
| 740 | localstatic void | |||
| 741 | tisefGenerate(Stab stab, Sefo sefo) | |||
| 742 | { | |||
| 743 | TfGenType tfGenType; | |||
| 744 | Scope("tisefGenerate")String scopeName = ("tisefGenerate"); int fluidLevel0 = (scopeLevel ++, fluidLevel); | |||
| 745 | ||||
| 746 | TForm fluid(tuniReturnTForm)fluidSave_tuniReturnTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniReturnTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniReturnTForm , fluidStack[fluidLevel].size = sizeof(tuniReturnTForm), fluidLevel ++, (tuniReturnTForm) ); | |||
| 747 | TForm fluid(tuniYieldTForm)fluidSave_tuniYieldTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniYieldTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniYieldTForm , fluidStack[fluidLevel].size = sizeof(tuniYieldTForm), fluidLevel ++, (tuniYieldTForm) ); | |||
| 748 | TForm fluid(tuniExitTForm)fluidSave_tuniExitTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniExitTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniExitTForm , fluidStack[fluidLevel].size = sizeof(tuniExitTForm), fluidLevel ++, (tuniExitTForm) ); | |||
| 749 | ||||
| 750 | tuniReturnTForm = tfNone()tfMulti(0); | |||
| 751 | tuniYieldTForm = tfUnknown; | |||
| 752 | tuniExitTForm = tfNone()tfMulti(0); | |||
| 753 | ||||
| 754 | tisef0Generic(stab, sefo); | |||
| 755 | tfGenType = abFlag_IsNewIter(sefo)(((sefo)->abHdr.flags) == AB_Flag_NewIter) ? TFG_XGenerator : TFG_Generator; | |||
| 756 | ||||
| 757 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfAnyGenerator(tfGenType, tuniYieldTForm); | |||
| 758 | ||||
| 759 | ReturnNothing{ fluidUnwind(fluidLevel0, ((int) 0)); return;; }; | |||
| 760 | } | |||
| 761 | ||||
| 762 | /**************************************************************************** | |||
| 763 | * | |||
| 764 | * :: Reference: ref (id or id of array/record/union) | |||
| 765 | * | |||
| 766 | ***************************************************************************/ | |||
| 767 | ||||
| 768 | localstatic void | |||
| 769 | tisefReference(Stab stab, Sefo sefo) | |||
| 770 | { | |||
| 771 | tisef0Generic(stab, sefo); | |||
| 772 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfReference(abTUnique(sefo->abReference.body)((sefo->abReference.body)->abHdr.type.unique)); | |||
| 773 | } | |||
| 774 | ||||
| 775 | /*************************************************************************** | |||
| 776 | * | |||
| 777 | * :: Yield: yield x | |||
| 778 | * | |||
| 779 | ***************************************************************************/ | |||
| 780 | ||||
| 781 | localstatic void | |||
| 782 | tisefYield(Stab stab, Sefo sefo) | |||
| 783 | { | |||
| 784 | tisef0Generic(stab, sefo); | |||
| 785 | tisef0FarValue(stab, sefo->abYield.value, &tuniYieldTForm); | |||
| 786 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfExit; | |||
| 787 | } | |||
| 788 | ||||
| 789 | /**************************************************************************** | |||
| 790 | * | |||
| 791 | * :: Add: [D] add (a: A == ...) | |||
| 792 | * | |||
| 793 | ***************************************************************************/ | |||
| 794 | ||||
| 795 | localstatic void | |||
| 796 | tisefAdd(Stab stab, Sefo sefo) | |||
| 797 | { | |||
| 798 | tisef0Generic(stab, sefo); | |||
| 799 | ||||
| 800 | /* !! Should infer type of body. */ | |||
| 801 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfType; | |||
| 802 | } | |||
| 803 | ||||
| 804 | /**************************************************************************** | |||
| 805 | * | |||
| 806 | * :: With: [C] with (a: A; ...) | |||
| 807 | * | |||
| 808 | ***************************************************************************/ | |||
| 809 | ||||
| 810 | localstatic void | |||
| 811 | tisefWith(Stab stab, Sefo sefo) | |||
| 812 | { | |||
| 813 | SymeList bsymes, wsymes, symes = listNil(Syme)((SymeList) 0); | |||
| 814 | SymeList mods = listNil(Syme)((SymeList) 0); | |||
| 815 | TForm wtf, tf; | |||
| 816 | ||||
| 817 | tisef(stab, sefo->abWith.base); | |||
| 818 | bsymes = abGetCatExports(sefo->abWith.base); | |||
| 819 | ||||
| 820 | tisef(stab, sefo->abWith.within); | |||
| 821 | wtf = tisef0Within(stab, sefo->abWith.within, bsymes); | |||
| 822 | wsymes = tfGetThdExports(wtf); | |||
| 823 | ||||
| 824 | symes = tfJoinExportLists(mods, symes, bsymes, NULL((void*)0)); | |||
| 825 | symes = tfJoinExportLists(mods, symes, wsymes, NULL((void*)0)); | |||
| 826 | ||||
| 827 | tf = tfThird(symes); | |||
| 828 | tfAddSelf(tf, abGetCatSelf(sefo->abWith.base)); | |||
| 829 | tfAddSelf(tf, tfGetThdSelf(wtf)); | |||
| 830 | tfAddSelf(tf, abSelf(sefo)((sefo)->abHdr.seman ? (sefo)->abHdr.seman->self : 0 )); | |||
| 831 | ||||
| 832 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tf; | |||
| 833 | } | |||
| 834 | ||||
| 835 | /**************************************************************************** | |||
| 836 | * | |||
| 837 | * :: Where: e where d | |||
| 838 | * | |||
| 839 | ***************************************************************************/ | |||
| 840 | ||||
| 841 | localstatic void | |||
| 842 | tisefWhere(Stab stab, Sefo sefo) | |||
| 843 | { | |||
| 844 | tisef0Generic(stab, sefo); | |||
| 845 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abWhere.expr)((sefo->abWhere.expr)->abHdr.type.unique); | |||
| 846 | } | |||
| 847 | ||||
| 848 | /**************************************************************************** | |||
| 849 | * | |||
| 850 | * :: If: if b then t [else e] | |||
| 851 | * | |||
| 852 | ***************************************************************************/ | |||
| 853 | ||||
| 854 | localstatic void | |||
| 855 | tisefIf(Stab stab, Sefo sefo) | |||
| 856 | { | |||
| 857 | Sefo test = sefo->abIf.test; | |||
| 858 | Sefo thenAlt = sefo->abIf.thenAlt; | |||
| 859 | Sefo elseAlt = sefo->abIf.elseAlt; | |||
| 860 | ||||
| 861 | tisef0Generic(stab, sefo); | |||
| 862 | ||||
| 863 | if (true1) { | |||
| 864 | SymeList tsymes, esymes, symes = listNil(Syme)((SymeList) 0); | |||
| 865 | SymeList mods = listNil(Syme)((SymeList) 0); | |||
| 866 | TForm ttf, etf, tf; | |||
| 867 | ||||
| 868 | ttf = tisef0Within(stab, thenAlt, listNil(Syme)((SymeList) 0)); | |||
| 869 | ||||
| 870 | tsymes = tfGetThdExports(ttf); | |||
| 871 | ||||
| 872 | etf = tisef0Within(stab, elseAlt, listNil(Syme)((SymeList) 0)); | |||
| 873 | ||||
| 874 | esymes = tfGetThdExports(etf); | |||
| 875 | ||||
| 876 | symes = tfJoinExportLists(mods, symes, tsymes, test); | |||
| 877 | test = abNewNot(sposNone, test)abNew(AB_Not, sposNone,1, test); | |||
| 878 | symes = tfJoinExportLists(mods, symes, esymes, test); | |||
| 879 | ||||
| 880 | tf = tfThird(symes); | |||
| 881 | tfAddSelf(tf, tfGetThdSelf(ttf)); | |||
| 882 | tfAddSelf(tf, tfGetThdSelf(etf)); | |||
| 883 | ||||
| 884 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tf; | |||
| 885 | ||||
| 886 | return; | |||
| 887 | } | |||
| 888 | ||||
| 889 | /*!! This looks entirely suspect. */ | |||
| 890 | if (abIsNotNothing(elseAlt)!((elseAlt)->abHdr.tag == (AB_Nothing)) && | |||
| 891 | tfSatisfies(abTUnique(thenAlt)((thenAlt)->abHdr.type.unique), abTUnique(elseAlt)((elseAlt)->abHdr.type.unique))) | |||
| 892 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(elseAlt)((elseAlt)->abHdr.type.unique); | |||
| 893 | else | |||
| 894 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(thenAlt)((thenAlt)->abHdr.type.unique); | |||
| 895 | } | |||
| 896 | ||||
| 897 | /**************************************************************************** | |||
| 898 | * | |||
| 899 | * :: Test: implied test | |||
| 900 | * | |||
| 901 | ***************************************************************************/ | |||
| 902 | ||||
| 903 | localstatic void | |||
| 904 | tisefTest(Stab stab, Sefo sefo) | |||
| 905 | { | |||
| 906 | /* | |||
| 907 | * An unfixed compiler bug means that parts of Salli programs | |||
| 908 | * tinfered with (tfBoolean == tfUnknown). We want to catch | |||
| 909 | * this problem as soon as possible. | |||
| 910 | */ | |||
| 911 | tisef0Generic(stab, sefo); | |||
| 912 | assert(tfBoolean != tfUnknown)do { if (!(tfBoolean != tfUnknown)) _do_assert(("tfBoolean != tfUnknown" ),"ti_sef.c",912); } while (0); | |||
| 913 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfBoolean; | |||
| 914 | } | |||
| 915 | ||||
| 916 | /*************************************************************************** | |||
| 917 | * | |||
| 918 | * :: Collect: e <iter>* | |||
| 919 | * | |||
| 920 | ***************************************************************************/ | |||
| 921 | ||||
| 922 | localstatic void | |||
| 923 | tisefCollect(Stab stab, Sefo sefo) | |||
| 924 | { | |||
| 925 | Scope("tisefCollect")String scopeName = ("tisefCollect"); int fluidLevel0 = (scopeLevel ++, fluidLevel); | |||
| 926 | ||||
| 927 | TForm fluid(tuniReturnTForm)fluidSave_tuniReturnTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniReturnTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniReturnTForm , fluidStack[fluidLevel].size = sizeof(tuniReturnTForm), fluidLevel ++, (tuniReturnTForm) ); | |||
| 928 | TForm fluid(tuniYieldTForm)fluidSave_tuniYieldTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniYieldTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniYieldTForm , fluidStack[fluidLevel].size = sizeof(tuniYieldTForm), fluidLevel ++, (tuniYieldTForm) ); | |||
| 929 | TForm fluid(tuniExitTForm)fluidSave_tuniExitTForm = ( fluidStack = (fluidLevel==fluidLimit ) ? fluidGrow() : fluidStack, fluidStack[fluidLevel].scopeName = scopeName, fluidStack[fluidLevel].scopeLevel = scopeLevel, fluidStack[fluidLevel].pglobal = (Pointer) &(tuniExitTForm ), fluidStack[fluidLevel].pstack = (Pointer) &fluidSave_tuniExitTForm , fluidStack[fluidLevel].size = sizeof(tuniExitTForm), fluidLevel ++, (tuniExitTForm) ); | |||
| 930 | ||||
| 931 | tuniReturnTForm = tfNone()tfMulti(0); | |||
| 932 | tuniYieldTForm = tfNone()tfMulti(0); | |||
| 933 | tuniExitTForm = tfNone()tfMulti(0); | |||
| 934 | ||||
| 935 | tisef0Generic(stab, sefo); | |||
| 936 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfGenerator(abTUnique(sefo->abCollect.body)((sefo->abCollect.body)->abHdr.type.unique)); | |||
| 937 | ||||
| 938 | ReturnNothing{ fluidUnwind(fluidLevel0, ((int) 0)); return;; }; | |||
| 939 | } | |||
| 940 | ||||
| 941 | /**************************************************************************** | |||
| 942 | * | |||
| 943 | * :: Repeat: <iter>* repeat e | |||
| 944 | * | |||
| 945 | ***************************************************************************/ | |||
| 946 | ||||
| 947 | localstatic void | |||
| 948 | tisefRepeat(Stab stab, Sefo sefo) | |||
| 949 | { | |||
| 950 | tisef0Generic(stab, sefo); | |||
| 951 | } | |||
| 952 | ||||
| 953 | /*************************************************************************** | |||
| 954 | * | |||
| 955 | * :: Never | |||
| 956 | * X | |||
| 957 | ***************************************************************************/ | |||
| 958 | ||||
| 959 | localstatic void | |||
| 960 | tisefNever(Stab stab, Sefo sefo) | |||
| 961 | { | |||
| 962 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfExit; | |||
| 963 | } | |||
| 964 | ||||
| 965 | /*************************************************************************** | |||
| 966 | * | |||
| 967 | * :: Iterate | |||
| 968 | * X | |||
| 969 | ***************************************************************************/ | |||
| 970 | ||||
| 971 | localstatic void | |||
| 972 | tisefIterate(Stab stab, Sefo sefo) | |||
| 973 | { | |||
| 974 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfExit; | |||
| 975 | } | |||
| 976 | ||||
| 977 | /*************************************************************************** | |||
| 978 | * | |||
| 979 | * :: Break | |||
| 980 | * X | |||
| 981 | ***************************************************************************/ | |||
| 982 | ||||
| 983 | localstatic void | |||
| 984 | tisefBreak(Stab stab, Sefo sefo) | |||
| 985 | { | |||
| 986 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfExit; | |||
| 987 | } | |||
| 988 | ||||
| 989 | /**************************************************************************** | |||
| 990 | * | |||
| 991 | * :: While: while c | |||
| 992 | * | |||
| 993 | ***************************************************************************/ | |||
| 994 | ||||
| 995 | localstatic void | |||
| 996 | tisefWhile(Stab stab, Sefo sefo) | |||
| 997 | { | |||
| 998 | /* | |||
| 999 | * An unfixed compiler bug means that parts of Salli programs | |||
| 1000 | * tinfered with (tfBoolean == tfUnknown). We want to catch | |||
| 1001 | * this problem as soon as possible. | |||
| 1002 | */ | |||
| 1003 | tisef0Generic(stab, sefo); | |||
| 1004 | assert(tfBoolean != tfUnknown)do { if (!(tfBoolean != tfUnknown)) _do_assert(("tfBoolean != tfUnknown" ),"ti_sef.c",1004); } while (0); | |||
| 1005 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfBoolean; | |||
| 1006 | } | |||
| 1007 | ||||
| 1008 | ||||
| 1009 | /*************************************************************************** | |||
| 1010 | * | |||
| 1011 | * :: For: for x in l | c | |||
| 1012 | * | |||
| 1013 | ***************************************************************************/ | |||
| 1014 | ||||
| 1015 | localstatic void | |||
| 1016 | tisefFor(Stab stab, Sefo sefo) | |||
| 1017 | { | |||
| 1018 | tisef0Generic(stab, sefo); | |||
| 1019 | tisef0ApplySymIfNeeded(stab,sefo,1,abForIterArgf,NULL((void*)0),tfIsAnyGenerator); | |||
| 1020 | } | |||
| 1021 | ||||
| 1022 | /**************************************************************************** | |||
| 1023 | * | |||
| 1024 | * :: ForeignExport: export ... from Foreign(...) | |||
| 1025 | * | |||
| 1026 | ***************************************************************************/ | |||
| 1027 | ||||
| 1028 | localstatic void | |||
| 1029 | tisefForeignExport(Stab stab, Sefo sefo) | |||
| 1030 | { | |||
| 1031 | tisef0Generic(stab, sefo); | |||
| 1032 | } | |||
| 1033 | ||||
| 1034 | /**************************************************************************** | |||
| 1035 | * | |||
| 1036 | * :: ForeignImport: import ... from Foreign(...) | |||
| 1037 | * | |||
| 1038 | ***************************************************************************/ | |||
| 1039 | ||||
| 1040 | localstatic void | |||
| 1041 | tisefForeignImport(Stab stab, Sefo sefo) | |||
| 1042 | { | |||
| 1043 | tisef0Generic(stab, sefo); | |||
| 1044 | } | |||
| 1045 | ||||
| 1046 | /**************************************************************************** | |||
| 1047 | * | |||
| 1048 | * :: Import: import ... from D | |||
| 1049 | * | |||
| 1050 | ***************************************************************************/ | |||
| 1051 | ||||
| 1052 | localstatic void | |||
| 1053 | tisefImport(Stab stab, Sefo sefo) | |||
| 1054 | { | |||
| 1055 | AbSyn what = sefo->abImport.what; | |||
| 1056 | AbSyn from = sefo->abImport.origin; | |||
| 1057 | ||||
| 1058 | tisef(stab, from); | |||
| 1059 | tisef(stab, what); | |||
| 1060 | tisef0Within(stab, what, listNil(Syme)((SymeList) 0)); | |||
| 1061 | ||||
| 1062 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfNone()tfMulti(0); | |||
| 1063 | } | |||
| 1064 | ||||
| 1065 | /**************************************************************************** | |||
| 1066 | * | |||
| 1067 | * :: Inline: inline .. from D | |||
| 1068 | * | |||
| 1069 | ***************************************************************************/ | |||
| 1070 | ||||
| 1071 | localstatic void | |||
| 1072 | tisefInline(Stab stab, Sefo sefo) | |||
| 1073 | { | |||
| 1074 | AbSyn what = sefo->abInline.what; | |||
| 1075 | AbSyn from = sefo->abInline.origin; | |||
| 1076 | ||||
| 1077 | tisef(stab, from); | |||
| 1078 | tisef(stab, what); | |||
| 1079 | tisef0Within(stab, what, listNil(Syme)((SymeList) 0)); | |||
| 1080 | ||||
| 1081 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfNone()tfMulti(0); | |||
| 1082 | } | |||
| 1083 | ||||
| 1084 | /**************************************************************************** | |||
| 1085 | * | |||
| 1086 | * :: Qualify: A $ B | |||
| 1087 | * | |||
| 1088 | * ToDo: 3$Integer | |||
| 1089 | * | |||
| 1090 | ***************************************************************************/ | |||
| 1091 | ||||
| 1092 | localstatic void | |||
| 1093 | tisefQualify(Stab stab, Sefo sefo) | |||
| 1094 | { | |||
| 1095 | AbSyn what = sefo->abQualify.what; | |||
| 1096 | Syme syme = abSyme(what)((what)->abHdr.seman ? (what)->abHdr.seman->syme : 0 ); | |||
| 1097 | ||||
| 1098 | tisef0Generic(stab, sefo); | |||
| 1099 | ||||
| 1100 | if (syme) | |||
| 1101 | abTUnique(sefo)((sefo)->abHdr.type.unique) = symeType(syme); | |||
| 1102 | else | |||
| 1103 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfUnknown; | |||
| 1104 | } | |||
| 1105 | ||||
| 1106 | /*************************************************************************** | |||
| 1107 | * | |||
| 1108 | * :: CoerceTo: x :: T | |||
| 1109 | * | |||
| 1110 | ***************************************************************************/ | |||
| 1111 | ||||
| 1112 | localstatic void | |||
| 1113 | tisefCoerceTo(Stab stab, Sefo sefo) | |||
| 1114 | { | |||
| 1115 | TForm tf; | |||
| 1116 | ||||
| 1117 | tisef0Generic(stab, sefo); | |||
| 1118 | tf = tiGetTForm(stab, sefo->abCoerceTo.type); | |||
| 1119 | ||||
| 1120 | abTUnique(sefo)((sefo)->abHdr.type.unique) = (tf ? tf : tfUnknown); | |||
| 1121 | } | |||
| 1122 | ||||
| 1123 | /**************************************************************************** | |||
| 1124 | * | |||
| 1125 | * :: RestrictTo: A @ B | |||
| 1126 | * | |||
| 1127 | ***************************************************************************/ | |||
| 1128 | ||||
| 1129 | localstatic void | |||
| 1130 | tisefRestrictTo(Stab stab, Sefo sefo) | |||
| 1131 | { | |||
| 1132 | TForm tf; | |||
| 1133 | ||||
| 1134 | tisef0Generic(stab, sefo); | |||
| 1135 | tf = tiGetTForm(stab, sefo->abRestrictTo.type); | |||
| 1136 | ||||
| 1137 | abTUnique(sefo)((sefo)->abHdr.type.unique) = (tf ? tf : tfUnknown); | |||
| 1138 | } | |||
| 1139 | ||||
| 1140 | ||||
| 1141 | /**************************************************************************** | |||
| 1142 | * | |||
| 1143 | * :: PretendTo: A pretend B | |||
| 1144 | * | |||
| 1145 | ***************************************************************************/ | |||
| 1146 | ||||
| 1147 | localstatic void | |||
| 1148 | tisefPretendTo(Stab stab, Sefo sefo) | |||
| 1149 | { | |||
| 1150 | TForm tf; | |||
| 1151 | ||||
| 1152 | tisef0Generic(stab, sefo); | |||
| 1153 | tf = tiGetTForm(stab, sefo->abPretendTo.type); | |||
| 1154 | ||||
| 1155 | abTUnique(sefo)((sefo)->abHdr.type.unique) = (tf ? tf : tfUnknown); | |||
| 1156 | } | |||
| 1157 | ||||
| 1158 | /*************************************************************************** | |||
| 1159 | * | |||
| 1160 | * :: Not: not a | |||
| 1161 | * | |||
| 1162 | ***************************************************************************/ | |||
| 1163 | ||||
| 1164 | localstatic void | |||
| 1165 | tisefNot(Stab stab, Sefo sefo) | |||
| 1166 | { | |||
| 1167 | /* | |||
| 1168 | * An unfixed compiler bug means that parts of Salli programs | |||
| 1169 | * tinfered with (tfBoolean == tfUnknown). We want to catch | |||
| 1170 | * this problem as soon as possible. | |||
| 1171 | */ | |||
| 1172 | tisef0Generic(stab, sefo); | |||
| 1173 | assert(tfBoolean != tfUnknown)do { if (!(tfBoolean != tfUnknown)) _do_assert(("tfBoolean != tfUnknown" ),"ti_sef.c",1173); } while (0); | |||
| 1174 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfBoolean; | |||
| 1175 | } | |||
| 1176 | ||||
| 1177 | /*************************************************************************** | |||
| 1178 | * | |||
| 1179 | * :: And: a and b and c ... | |||
| 1180 | * | |||
| 1181 | ***************************************************************************/ | |||
| 1182 | ||||
| 1183 | localstatic void | |||
| 1184 | tisefAnd(Stab stab, Sefo sefo) | |||
| 1185 | { | |||
| 1186 | /* | |||
| 1187 | * An unfixed compiler bug means that parts of Salli programs | |||
| 1188 | * tinfered with (tfBoolean == tfUnknown). We want to catch | |||
| 1189 | * this problem as soon as possible. | |||
| 1190 | */ | |||
| 1191 | tisef0Generic(stab, sefo); | |||
| 1192 | assert(tfBoolean != tfUnknown)do { if (!(tfBoolean != tfUnknown)) _do_assert(("tfBoolean != tfUnknown" ),"ti_sef.c",1192); } while (0); | |||
| 1193 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfBoolean; | |||
| 1194 | } | |||
| 1195 | ||||
| 1196 | /*************************************************************************** | |||
| 1197 | * | |||
| 1198 | * :: Or: a or b or c ... | |||
| 1199 | * | |||
| 1200 | ***************************************************************************/ | |||
| 1201 | ||||
| 1202 | localstatic void | |||
| 1203 | tisefOr(Stab stab, Sefo sefo) | |||
| 1204 | { | |||
| 1205 | /* | |||
| 1206 | * An unfixed compiler bug means that parts of Salli programs | |||
| 1207 | * tinfered with (tfBoolean == tfUnknown). We want to catch | |||
| 1208 | * this problem as soon as possible. | |||
| 1209 | */ | |||
| 1210 | tisef0Generic(stab, sefo); | |||
| 1211 | assert(tfBoolean != tfUnknown)do { if (!(tfBoolean != tfUnknown)) _do_assert(("tfBoolean != tfUnknown" ),"ti_sef.c",1211); } while (0); | |||
| 1212 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfBoolean; | |||
| 1213 | } | |||
| 1214 | ||||
| 1215 | /*************************************************************************** | |||
| 1216 | * | |||
| 1217 | * :: Assert: | |||
| 1218 | * | |||
| 1219 | ***************************************************************************/ | |||
| 1220 | ||||
| 1221 | localstatic void | |||
| 1222 | tisefAssert(Stab stab, Sefo sefo) | |||
| 1223 | { | |||
| 1224 | tisef0Generic(stab, sefo); | |||
| 1225 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfNone()tfMulti(0); | |||
| 1226 | } | |||
| 1227 | ||||
| 1228 | /*************************************************************************** | |||
| 1229 | * | |||
| 1230 | * :: Blank: | |||
| 1231 | * | |||
| 1232 | ***************************************************************************/ | |||
| 1233 | ||||
| 1234 | localstatic void | |||
| 1235 | tisefBlank(Stab stab, Sefo sefo) | |||
| 1236 | { | |||
| 1237 | tisef0Generic(stab, sefo); | |||
| 1238 | } | |||
| 1239 | ||||
| 1240 | /*************************************************************************** | |||
| 1241 | * | |||
| 1242 | * :: Builtin: | |||
| 1243 | * | |||
| 1244 | ***************************************************************************/ | |||
| 1245 | ||||
| 1246 | localstatic void | |||
| 1247 | tisefBuiltin(Stab stab, Sefo sefo) | |||
| 1248 | { | |||
| 1249 | tisef0Generic(stab, sefo); | |||
| 1250 | } | |||
| 1251 | ||||
| 1252 | /*************************************************************************** | |||
| 1253 | * | |||
| 1254 | * :: Default: | |||
| 1255 | * | |||
| 1256 | ***************************************************************************/ | |||
| 1257 | ||||
| 1258 | localstatic void | |||
| 1259 | tisefDefault(Stab stab, Sefo sefo) | |||
| 1260 | { | |||
| 1261 | AbSyn body; | |||
| 1262 | TForm tf; | |||
| 1263 | ||||
| 1264 | body = sefo->abDefault.body; | |||
| 1265 | tisef(stab, body); | |||
| 1266 | tf = tisef0Within(stab, body, listNil(Syme)((SymeList) 0)); | |||
| 1267 | ||||
| 1268 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tf; | |||
| 1269 | } | |||
| 1270 | ||||
| 1271 | /*************************************************************************** | |||
| 1272 | * | |||
| 1273 | * :: Delay: | |||
| 1274 | * | |||
| 1275 | ***************************************************************************/ | |||
| 1276 | ||||
| 1277 | localstatic void | |||
| 1278 | tisefDelay(Stab stab, Sefo sefo) | |||
| 1279 | { | |||
| 1280 | tisef0Generic(stab, sefo); | |||
| 1281 | } | |||
| 1282 | ||||
| 1283 | /*************************************************************************** | |||
| 1284 | * | |||
| 1285 | * :: Do: | |||
| 1286 | * | |||
| 1287 | ***************************************************************************/ | |||
| 1288 | ||||
| 1289 | localstatic void | |||
| 1290 | tisefDo(Stab stab, Sefo sefo) | |||
| 1291 | { | |||
| 1292 | tisef0Generic(stab, sefo); | |||
| 1293 | } | |||
| 1294 | ||||
| 1295 | /*************************************************************************** | |||
| 1296 | * | |||
| 1297 | * :: Except: | |||
| 1298 | * | |||
| 1299 | ***************************************************************************/ | |||
| 1300 | ||||
| 1301 | localstatic void | |||
| 1302 | tisefExcept(Stab stab, Sefo sefo) | |||
| 1303 | { | |||
| 1304 | tisef(stab, sefo->abExcept.except); | |||
| 1305 | tisef(stab, sefo->abExcept.type); | |||
| 1306 | ||||
| 1307 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abExcept.type)((sefo->abExcept.type)->abHdr.type.unique); | |||
| 1308 | ||||
| 1309 | } | |||
| 1310 | ||||
| 1311 | /*************************************************************************** | |||
| 1312 | * | |||
| 1313 | * :: Raise: | |||
| 1314 | * | |||
| 1315 | ***************************************************************************/ | |||
| 1316 | ||||
| 1317 | localstatic void | |||
| 1318 | tisefRaise(Stab stab, Sefo sefo) | |||
| 1319 | { | |||
| 1320 | tisef(stab, sefo->abRaise.expr); | |||
| 1321 | ||||
| 1322 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfExcept(tfExit, tiGetTForm(stab, sefo->abRaise.expr)); | |||
| 1323 | } | |||
| 1324 | ||||
| 1325 | /*************************************************************************** | |||
| 1326 | * | |||
| 1327 | * :: Export: | |||
| 1328 | * | |||
| 1329 | ***************************************************************************/ | |||
| 1330 | ||||
| 1331 | localstatic void | |||
| 1332 | tisefExport(Stab stab, Sefo sefo) | |||
| 1333 | { | |||
| 1334 | AbSyn what = sefo->abExport.what; | |||
| 1335 | AbSyn from = sefo->abExport.origin; | |||
| 1336 | AbSyn dest = sefo->abExport.destination; | |||
| 1337 | ||||
| 1338 | tisef(stab, from); | |||
| 1339 | tisef(stab, dest); | |||
| 1340 | ||||
| 1341 | tisef(stab, what); | |||
| 1342 | if (!abIsNothing(from)((from)->abHdr.tag == (AB_Nothing)) || !abIsNothing(dest)((dest)->abHdr.tag == (AB_Nothing))) | |||
| 1343 | tisef0Within(stab, what, listNil(Syme)((SymeList) 0)); | |||
| 1344 | ||||
| 1345 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfNone()tfMulti(0); | |||
| 1346 | } | |||
| 1347 | ||||
| 1348 | /*************************************************************************** | |||
| 1349 | * | |||
| 1350 | * :: Extend: | |||
| 1351 | * | |||
| 1352 | ***************************************************************************/ | |||
| 1353 | ||||
| 1354 | localstatic void | |||
| 1355 | tisefExtend(Stab stab, Sefo sefo) | |||
| 1356 | { | |||
| 1357 | tisef0Generic(stab, sefo); | |||
| 1358 | } | |||
| 1359 | ||||
| 1360 | /*************************************************************************** | |||
| 1361 | * | |||
| 1362 | * :: Fix: | |||
| 1363 | * | |||
| 1364 | ***************************************************************************/ | |||
| 1365 | ||||
| 1366 | localstatic void | |||
| 1367 | tisefFix(Stab stab, Sefo sefo) | |||
| 1368 | { | |||
| 1369 | tisef0Generic(stab, sefo); | |||
| 1370 | } | |||
| 1371 | ||||
| 1372 | /*************************************************************************** | |||
| 1373 | * | |||
| 1374 | * :: Fluid: | |||
| 1375 | * | |||
| 1376 | ***************************************************************************/ | |||
| 1377 | ||||
| 1378 | localstatic void | |||
| 1379 | tisefFluid(Stab stab, Sefo sefo) | |||
| 1380 | { | |||
| 1381 | tisef0Generic(stab, sefo); | |||
| 1382 | } | |||
| 1383 | ||||
| 1384 | /*************************************************************************** | |||
| 1385 | * | |||
| 1386 | * :: Free: | |||
| 1387 | * | |||
| 1388 | ***************************************************************************/ | |||
| 1389 | ||||
| 1390 | localstatic void | |||
| 1391 | tisefFree(Stab stab, Sefo sefo) | |||
| 1392 | { | |||
| 1393 | tisef0Generic(stab, sefo); | |||
| 1394 | } | |||
| 1395 | ||||
| 1396 | /*************************************************************************** | |||
| 1397 | * | |||
| 1398 | * :: Has: | |||
| 1399 | * | |||
| 1400 | ***************************************************************************/ | |||
| 1401 | ||||
| 1402 | localstatic void | |||
| 1403 | tisefHas(Stab stab, Sefo sefo) | |||
| 1404 | { | |||
| 1405 | tisef0Generic(stab, sefo); | |||
| 1406 | } | |||
| 1407 | ||||
| 1408 | /*************************************************************************** | |||
| 1409 | * | |||
| 1410 | * :: Hide: | |||
| 1411 | * | |||
| 1412 | ***************************************************************************/ | |||
| 1413 | ||||
| 1414 | localstatic void | |||
| 1415 | tisefHide(Stab stab, Sefo sefo) | |||
| 1416 | { | |||
| 1417 | tisef0Generic(stab, sefo); | |||
| 1418 | } | |||
| 1419 | ||||
| 1420 | /*************************************************************************** | |||
| 1421 | * | |||
| 1422 | * :: IdSy: | |||
| 1423 | * | |||
| 1424 | ***************************************************************************/ | |||
| 1425 | ||||
| 1426 | localstatic void | |||
| 1427 | tisefIdSy(Stab stab, Sefo sefo) | |||
| 1428 | { | |||
| 1429 | tisef0Generic(stab, sefo); | |||
| 1430 | } | |||
| 1431 | ||||
| 1432 | /*************************************************************************** | |||
| 1433 | * | |||
| 1434 | * :: Let: | |||
| 1435 | * | |||
| 1436 | ***************************************************************************/ | |||
| 1437 | ||||
| 1438 | localstatic void | |||
| 1439 | tisefLet(Stab stab, Sefo sefo) | |||
| 1440 | { | |||
| 1441 | tisef0Generic(stab, sefo); | |||
| 1442 | } | |||
| 1443 | ||||
| 1444 | /*************************************************************************** | |||
| 1445 | * | |||
| 1446 | * :: Local: | |||
| 1447 | * | |||
| 1448 | ***************************************************************************/ | |||
| 1449 | ||||
| 1450 | localstatic void | |||
| 1451 | tisefLocal(Stab stab, Sefo sefo) | |||
| 1452 | { | |||
| 1453 | tisef0Generic(stab, sefo); | |||
| 1454 | } | |||
| 1455 | ||||
| 1456 | ||||
| 1457 | /*************************************************************************** | |||
| 1458 | * | |||
| 1459 | * :: Macro: | |||
| 1460 | * | |||
| 1461 | ***************************************************************************/ | |||
| 1462 | ||||
| 1463 | localstatic void | |||
| 1464 | tisefMacro(Stab stab, Sefo sefo) | |||
| 1465 | { | |||
| 1466 | tisef0Generic(stab, sefo); | |||
| 1467 | } | |||
| 1468 | ||||
| 1469 | ||||
| 1470 | /*************************************************************************** | |||
| 1471 | * | |||
| 1472 | * :: MLambda: | |||
| 1473 | * | |||
| 1474 | ***************************************************************************/ | |||
| 1475 | ||||
| 1476 | localstatic void | |||
| 1477 | tisefMLambda(Stab stab, Sefo sefo) | |||
| 1478 | { | |||
| 1479 | tisef0Generic(stab, sefo); | |||
| 1480 | } | |||
| 1481 | ||||
| 1482 | /*************************************************************************** | |||
| 1483 | * | |||
| 1484 | * :: Nothing: | |||
| 1485 | * | |||
| 1486 | ***************************************************************************/ | |||
| 1487 | ||||
| 1488 | localstatic void | |||
| 1489 | tisefNothing(Stab stab, Sefo sefo) | |||
| 1490 | { | |||
| 1491 | abTUnique(sefo)((sefo)->abHdr.type.unique) = tfNone()tfMulti(0); | |||
| 1492 | } | |||
| 1493 | ||||
| 1494 | /*************************************************************************** | |||
| 1495 | * | |||
| 1496 | * :: Quote: | |||
| 1497 | * | |||
| 1498 | ***************************************************************************/ | |||
| 1499 | ||||
| 1500 | localstatic void | |||
| 1501 | tisefQuote(Stab stab, Sefo sefo) | |||
| 1502 | { | |||
| 1503 | tisef0Generic(stab, sefo); | |||
| 1504 | } | |||
| 1505 | ||||
| 1506 | ||||
| 1507 | /*************************************************************************** | |||
| 1508 | * | |||
| 1509 | * :: Select: | |||
| 1510 | * | |||
| 1511 | ***************************************************************************/ | |||
| 1512 | ||||
| 1513 | localstatic void | |||
| 1514 | tisefSelect(Stab stab, Sefo sefo) | |||
| 1515 | { | |||
| 1516 | /* Not 100% sure about this...*/ | |||
| 1517 | tisef0Generic(stab, sefo); | |||
| 1518 | ||||
| 1519 | return; | |||
| 1520 | } | |||
| 1521 | ||||
| 1522 | ||||
| 1523 | /*************************************************************************** | |||
| 1524 | * | |||
| 1525 | * :: Try: | |||
| 1526 | * | |||
| 1527 | ***************************************************************************/ | |||
| 1528 | ||||
| 1529 | localstatic void | |||
| 1530 | tisefTry(Stab stab, Sefo sefo) | |||
| 1531 | { | |||
| 1532 | tisef(stab, sefo->abTry.id); | |||
| 1533 | tisef(stab, sefo->abTry.expr); | |||
| 1534 | tisef(stab, sefo->abTry.always); | |||
| 1535 | tisef(stab, sefo->abTry.except); | |||
| 1536 | ||||
| 1537 | abTUnique(sefo)((sefo)->abHdr.type.unique) = abTUnique(sefo->abTry.expr)((sefo->abTry.expr)->abHdr.type.unique); | |||
| 1538 | } |