compiler.lsp 200 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281
  1. (global '(s!:opcodelist))
  2. (setq s!:opcodelist
  3. '(loadloc loadloc0 loadloc1 loadloc2 loadloc3 loadloc4 loadloc5 loadloc6
  4. loadloc7 loadloc8 loadloc9 loadloc10 loadloc11 loc0loc1 loc1loc2
  5. loc2loc3 loc1loc0 loc2loc1 loc3loc2 vnil loadlit loadlit1 loadlit2
  6. loadlit3 loadlit4 loadlit5 loadlit6 loadlit7 loadfree loadfree1
  7. loadfree2 loadfree3 loadfree4 storeloc storeloc0 storeloc1 storeloc2
  8. storeloc3 storeloc4 storeloc5 storeloc6 storeloc7 storefree storefree1
  9. storefree2 storefree3 loadlex storelex closure carloc0 carloc1 carloc2
  10. carloc3 carloc4 carloc5 carloc6 carloc7 carloc8 carloc9 carloc10
  11. carloc11 cdrloc0 cdrloc1 cdrloc2 cdrloc3 cdrloc4 cdrloc5 caarloc0
  12. caarloc1 caarloc2 caarloc3 call0 call1 call2 call2r call3 calln call0_0
  13. call0_1 call0_2 call0_3 call1_0 call1_1 call1_2 call1_3 call1_4 call1_5
  14. call2_0 call2_1 call2_2 call2_3 call2_4 builtin0 builtin1 builtin2
  15. builtin2r builtin3 apply1 apply2 apply3 apply4 jcall jcalln jump jump_b
  16. jump_l jump_bl jumpnil jumpnil_b jumpnil_l jumpnil_bl jumpt jumpt_b
  17. jumpt_l jumpt_bl jumpatom jumpatom_b jumpatom_l jumpatom_bl jumpnatom
  18. jumpnatom_b jumpnatom_l jumpnatom_bl jumpeq jumpeq_b jumpeq_l jumpeq_bl
  19. jumpne jumpne_b jumpne_l jumpne_bl jumpequal jumpequal_b jumpequal_l
  20. jumpequal_bl jumpnequal jumpnequal_b jumpnequal_l jumpnequal_bl
  21. jumpl0nil jumpl0t jumpl1nil jumpl1t jumpl2nil jumpl2t jumpl3nil jumpl3t
  22. jumpl4nil jumpl4t jumpst0nil jumpst0t jumpst1nil jumpst1t jumpst2nil
  23. jumpst2t jumpl0atom jumpl0natom jumpl1atom jumpl1natom jumpl2atom
  24. jumpl2natom jumpl3atom jumpl3natom jumpfree1nil jumpfree1t jumpfree2nil
  25. jumpfree2t jumpfree3nil jumpfree3t jumpfree4nil jumpfree4t jumpfreenil
  26. jumpfreet jumplit1eq jumplit1ne jumplit2eq jumplit2ne jumplit3eq
  27. jumplit3ne jumplit4eq jumplit4ne jumpliteq jumplitne jumpb1nil jumpb1t
  28. jumpb2nil jumpb2t jumpflagp jumpnflagp jumpeqcar jumpneqcar catch
  29. catch_b catch_l catch_bl uncatch throw protect unprotect pvbind
  30. pvrestore freebind freerstr exit nilexit loc0exit loc1exit loc2exit
  31. push pushnil pushnil2 pushnil3 pushnils pop lose lose2 lose3 loses swop
  32. eq eqcar equal numberp car cdr caar cadr cdar cddr cons ncons xcons
  33. acons length list2 list2star list3 plus2 add1 difference sub1 times2
  34. greaterp lessp flagp get litget getv qgetv qgetvn bigstack bigcall
  35. icase fastget spare1 spare2))
  36. (cond
  37. ((demo!-mode)
  38. (progn
  39. (setq p s!:opcodelist)
  40. (prog (j)
  41. (setq j 0)
  42. lab (cond ((minusp (difference 254 j)) (return nil)))
  43. (progn
  44. (setq n (random!-number (difference 256 j)))
  45. (setq q p)
  46. (prog (k)
  47. (setq k 1)
  48. lab (cond ((minusp (difference n k)) (return nil)))
  49. (setq q (cdr q))
  50. (setq k (plus2 k 1))
  51. (go lab))
  52. (setq w (car p))
  53. (rplaca p (car q))
  54. (rplaca q w)
  55. (setq p (cdr p)))
  56. (setq j (plus2 j 1))
  57. (go lab)))) )
  58. (prog (n)
  59. (setq n 0)
  60. (prog (v)
  61. (setq v s!:opcodelist)
  62. lab (cond ((null v) (return nil)))
  63. ((lambda (v) (progn (put v 's!:opcode n) (setq n (plus n 1)))) (car v))
  64. (setq v (cdr v))
  65. (go lab))
  66. (return (list n 'opcodes 'allocated)))
  67. (setq s!:opcodelist nil)
  68. (de s!:vecof (l)
  69. (prog (v n)
  70. (setq v (mkvect (sub1 (length l))))
  71. (setq n 0)
  72. (prog (x)
  73. (setq x l)
  74. lab (cond ((null x) (return nil)))
  75. ((lambda (x) (progn (putv v n x) (setq n (plus n 1)))) (car x))
  76. (setq x (cdr x))
  77. (go lab))
  78. (return v)))
  79. (progn
  80. (put 'batchp 's!:builtin0 0)
  81. (put 'date 's!:builtin0 1)
  82. (put 'eject 's!:builtin0 2)
  83. (put 'error1 's!:builtin0 3)
  84. (put 'gctime 's!:builtin0 4)
  85. (put 'lposn 's!:builtin0 6)
  86. (put 'posn 's!:builtin0 8)
  87. (put 'read 's!:builtin0 9)
  88. (put 'readch 's!:builtin0 10)
  89. (put 'terpri 's!:builtin0 11)
  90. (put 'time 's!:builtin0 12)
  91. (put 'tyi 's!:builtin0 13)
  92. (put 'load!-spid 's!:builtin0 14)
  93. (put 'abs 's!:builtin1 0)
  94. (put 'add1 's!:builtin1 1)
  95. (put 'atan 's!:builtin1 2)
  96. (put 'apply0 's!:builtin1 3)
  97. (put 'atom 's!:builtin1 4)
  98. (put 'boundp 's!:builtin1 5)
  99. (put 'char!-code 's!:builtin1 6)
  100. (put 'close 's!:builtin1 7)
  101. (put 'codep 's!:builtin1 8)
  102. (put 'compress 's!:builtin1 9)
  103. (put 'constantp 's!:builtin1 10)
  104. (put 'digit 's!:builtin1 11)
  105. (put 'endp 's!:builtin1 12)
  106. (put 'eval 's!:builtin1 13)
  107. (put 'evenp 's!:builtin1 14)
  108. (put 'evlis 's!:builtin1 15)
  109. (put 'explode 's!:builtin1 16)
  110. (put 'explode2lc 's!:builtin1 17)
  111. (put 'explode2 's!:builtin1 18)
  112. (put 'explodec 's!:builtin1 18)
  113. (put 'fixp 's!:builtin1 19)
  114. (put 'float 's!:builtin1 20)
  115. (put 'floatp 's!:builtin1 21)
  116. (put 'symbol!-specialp 's!:builtin1 22)
  117. (put 'gc 's!:builtin1 23)
  118. (put 'gensym1 's!:builtin1 24)
  119. (put 'getenv 's!:builtin1 25)
  120. (put 'symbol!-globalp 's!:builtin1 26)
  121. (put 'iadd1 's!:builtin1 27)
  122. (put 'symbolp 's!:builtin1 28)
  123. (put 'iminus 's!:builtin1 29)
  124. (put 'iminusp 's!:builtin1 30)
  125. (put 'indirect 's!:builtin1 31)
  126. (put 'integerp 's!:builtin1 32)
  127. (put 'intern 's!:builtin1 33)
  128. (put 'isub1 's!:builtin1 34)
  129. (put 'length 's!:builtin1 35)
  130. (put 'lengthc 's!:builtin1 36)
  131. (put 'linelength 's!:builtin1 37)
  132. (put 'liter 's!:builtin1 38)
  133. (put 'load!-module 's!:builtin1 39)
  134. (put 'lognot 's!:builtin1 40)
  135. (put 'macroexpand 's!:builtin1 41)
  136. (put 'macroexpand!-1 's!:builtin1 42)
  137. (put 'macro!-function 's!:builtin1 43)
  138. (put 'make!-bps 's!:builtin1 44)
  139. (put 'make!-global 's!:builtin1 45)
  140. (put 'make!-simple!-string 's!:builtin1 46)
  141. (put 'make!-special 's!:builtin1 47)
  142. (put 'minus 's!:builtin1 48)
  143. (put 'minusp 's!:builtin1 49)
  144. (put 'mkvect 's!:builtin1 50)
  145. (put 'modular!-minus 's!:builtin1 51)
  146. (put 'modular!-number 's!:builtin1 52)
  147. (put 'modular!-reciprocal 's!:builtin1 53)
  148. (put 'null 's!:builtin1 54)
  149. (put 'oddp 's!:builtin1 55)
  150. (put 'onep 's!:builtin1 56)
  151. (put 'pagelength 's!:builtin1 57)
  152. (put 'pairp 's!:builtin1 58)
  153. (put 'plist 's!:builtin1 59)
  154. (put 'plusp 's!:builtin1 60)
  155. (put 'prin 's!:builtin1 61)
  156. (put 'princ 's!:builtin1 62)
  157. (put 'print 's!:builtin1 63)
  158. (put 'printc 's!:builtin1 64)
  159. (put 'rational 's!:builtin1 66)
  160. (put 'rds 's!:builtin1 68)
  161. (put 'remd 's!:builtin1 69)
  162. (put 'reverse 's!:builtin1 70)
  163. (put 'reversip 's!:builtin1 71)
  164. (put 'seprp 's!:builtin1 72)
  165. (put 'set!-small!-modulus 's!:builtin1 73)
  166. (put 'spaces 's!:builtin1 74)
  167. (put 'xtab 's!:builtin1 74)
  168. (put 'special!-char 's!:builtin1 75)
  169. (put 'special!-form!-p 's!:builtin1 76)
  170. (put 'spool 's!:builtin1 77)
  171. (put 'stop 's!:builtin1 78)
  172. (put 'stringp 's!:builtin1 79)
  173. (put 'sub1 's!:builtin1 80)
  174. (put 'symbol!-env 's!:builtin1 81)
  175. (put 'symbol!-function 's!:builtin1 82)
  176. (put 'symbol!-name 's!:builtin1 83)
  177. (put 'symbol!-value 's!:builtin1 84)
  178. (put 'system 's!:builtin1 85)
  179. (put 'fix 's!:builtin1 86)
  180. (put 'ttab 's!:builtin1 87)
  181. (put 'tyo 's!:builtin1 88)
  182. (put 'remob 's!:builtin1 89)
  183. (put 'unmake!-global 's!:builtin1 90)
  184. (put 'unmake!-special 's!:builtin1 91)
  185. (put 'upbv 's!:builtin1 92)
  186. (put 'vectorp 's!:builtin1 93)
  187. (put 'verbos 's!:builtin1 94)
  188. (put 'wrs 's!:builtin1 95)
  189. (put 'zerop 's!:builtin1 96)
  190. (put 'car 's!:builtin1 97)
  191. (put 'cdr 's!:builtin1 98)
  192. (put 'caar 's!:builtin1 99)
  193. (put 'cadr 's!:builtin1 100)
  194. (put 'cdar 's!:builtin1 101)
  195. (put 'cddr 's!:builtin1 102)
  196. (put 'qcar 's!:builtin1 103)
  197. (put 'qcdr 's!:builtin1 104)
  198. (put 'qcaar 's!:builtin1 105)
  199. (put 'qcadr 's!:builtin1 106)
  200. (put 'qcdar 's!:builtin1 107)
  201. (put 'qcddr 's!:builtin1 108)
  202. (put 'ncons 's!:builtin1 109)
  203. (put 'numberp 's!:builtin1 110)
  204. (put 'is!-spid 's!:builtin1 111)
  205. (put 'spid!-to!-nil 's!:builtin1 112)
  206. (put 'append 's!:builtin2 0)
  207. (put 'ash 's!:builtin2 1)
  208. (put 'assoc 's!:builtin2 2)
  209. (put 'assoc!*!* 's!:builtin2 2)
  210. (put 'atsoc 's!:builtin2 3)
  211. (put 'deleq 's!:builtin2 4)
  212. (put 'delete 's!:builtin2 5)
  213. (put 'divide 's!:builtin2 6)
  214. (put 'eqcar 's!:builtin2 7)
  215. (put 'eql 's!:builtin2 8)
  216. (put 'eqn 's!:builtin2 9)
  217. (put 'expt 's!:builtin2 10)
  218. (put 'flag 's!:builtin2 11)
  219. (put 'flagpcar 's!:builtin2 12)
  220. (put 'gcdn 's!:builtin2 13)
  221. (put 'geq 's!:builtin2 14)
  222. (put 'getv 's!:builtin2 15)
  223. (put 'greaterp 's!:builtin2 16)
  224. (put 'idifference 's!:builtin2 17)
  225. (put 'igreaterp 's!:builtin2 18)
  226. (put 'ilessp 's!:builtin2 19)
  227. (put 'imax 's!:builtin2 20)
  228. (put 'imin 's!:builtin2 21)
  229. (put 'iplus2 's!:builtin2 22)
  230. (put 'iquotient 's!:builtin2 23)
  231. (put 'iremainder 's!:builtin2 24)
  232. (put 'irightshift 's!:builtin2 25)
  233. (put 'itimes2 's!:builtin2 26)
  234. (put 'leq 's!:builtin2 28)
  235. (put 'lessp 's!:builtin2 29)
  236. (put 'max2 's!:builtin2 31)
  237. (put 'member 's!:builtin2 32)
  238. (put 'member!*!* 's!:builtin2 32)
  239. (put 'memq 's!:builtin2 33)
  240. (put 'min2 's!:builtin2 34)
  241. (put 'mod 's!:builtin2 35)
  242. (put 'modular!-difference 's!:builtin2 36)
  243. (put 'modular!-expt 's!:builtin2 37)
  244. (put 'modular!-plus 's!:builtin2 38)
  245. (put 'modular!-quotient 's!:builtin2 39)
  246. (put 'modular!-times 's!:builtin2 40)
  247. (put 'nconc 's!:builtin2 41)
  248. (put 'neq 's!:builtin2 42)
  249. (put 'orderp 's!:builtin2 43)
  250. (put 'quotient 's!:builtin2 44)
  251. (put 'remainder 's!:builtin2 45)
  252. (put 'remflag 's!:builtin2 46)
  253. (put 'remprop 's!:builtin2 47)
  254. (put 'rplaca 's!:builtin2 48)
  255. (put 'rplacd 's!:builtin2 49)
  256. (put 'schar 's!:builtin2 50)
  257. (put 'set 's!:builtin2 51)
  258. (put 'smemq 's!:builtin2 52)
  259. (put 'subla 's!:builtin2 53)
  260. (put 'sublis 's!:builtin2 54)
  261. (put 'symbol!-set!-definition 's!:builtin2 55)
  262. (put 'symbol!-set!-env 's!:builtin2 56)
  263. (put 'times2 's!:builtin2 57)
  264. (put 'xcons 's!:builtin2 58)
  265. (put 'equal 's!:builtin2 59)
  266. (put 'eq 's!:builtin2 60)
  267. (put 'cons 's!:builtin2 61)
  268. (put 'list2 's!:builtin2 62)
  269. (put 'get 's!:builtin2 63)
  270. (put 'qgetv 's!:builtin2 64)
  271. (put 'flagp 's!:builtin2 65)
  272. (put 'apply1 's!:builtin2 66)
  273. (put 'difference 's!:builtin2 67)
  274. (put 'plus2 's!:builtin2 68)
  275. (put 'times2 's!:builtin2 69)
  276. (put 'equalcar 's!:builtin2 70)
  277. (put 'iequal 's!:builtin2 71)
  278. (put 'bps!-putv 's!:builtin3 0)
  279. (put 'errorset 's!:builtin3 1)
  280. (put 'list2!* 's!:builtin3 2)
  281. (put 'list3 's!:builtin3 3)
  282. (put 'putprop 's!:builtin3 4)
  283. (put 'putv 's!:builtin3 5)
  284. (put 'putv!-char 's!:builtin3 6)
  285. (put 'subst 's!:builtin3 7)
  286. (put 'apply2 's!:builtin3 8)
  287. (put 'acons 's!:builtin3 9)
  288. nil)
  289. (de s!:prinhex1 (n) (princ (schar "0123456789abcdef" (logand n 15))))
  290. (de s!:prinhex2 (n) (progn (s!:prinhex1 (truncate n 16)) (s!:prinhex1 n)))
  291. (de s!:prinhex4 (n) (progn (s!:prinhex2 (truncate n 256)) (s!:prinhex2 n)))
  292. (flag
  293. '(comp plap pgwd pwrds notailcall ord nocompile carcheckflag savedef
  294. carefuleq)
  295. 'switch)
  296. (cond ((not (boundp '!*comp)) (progn (fluid '(!*comp)) (setq !*comp t))))
  297. (cond
  298. ((not (boundp '!*nocompile))
  299. (progn (fluid '(!*nocompile)) (setq !*nocompile nil))))
  300. (cond ((not (boundp '!*plap)) (progn (fluid '(!*plap)) (setq !*plap nil))))
  301. (cond ((not (boundp '!*pgwd)) (progn (fluid '(!*pgwd)) (setq !*pgwd nil))))
  302. (cond ((not (boundp '!*pwrds)) (progn (fluid '(!*pwrds)) (setq !*pwrds t))))
  303. (cond
  304. ((not (boundp '!*notailcall))
  305. (progn (fluid '(!*notailcall)) (setq !*notailcall nil))))
  306. (cond ((not (boundp '!*ord)) (progn (fluid '(!*ord)) (setq !*ord t))))
  307. (cond
  308. ((not (boundp '!*savedef))
  309. (progn (fluid '(!*savedef)) (setq !*savedef nil))))
  310. (cond
  311. ((not (boundp '!*carcheckflag))
  312. (progn (fluid '(!*carcheckflag)) (setq !*carcheckflag t))))
  313. (cond
  314. ((not (boundp '!*carefuleq))
  315. (progn
  316. (fluid '(!*carefuleq))
  317. (setq !*carefuleq (not (null (member 'jlisp lispsystem!*)))) )))
  318. (fluid
  319. '(s!:current_function
  320. s!:current_label
  321. s!:current_block
  322. s!:current_size
  323. s!:current_procedure
  324. s!:other_defs
  325. s!:lexical_env
  326. s!:has_closure
  327. s!:recent_literals
  328. s!:used_lexicals
  329. s!:a_reg_values
  330. s!:current_count))
  331. (de s!:start_procedure (nargs nopts restarg)
  332. (progn
  333. (setq s!:current_procedure nil)
  334. (setq s!:current_label (gensym))
  335. (setq s!:a_reg_values nil)
  336. (cond
  337. ((or (not (zerop nopts)) restarg)
  338. (progn
  339. (setq s!:current_block
  340. (list
  341. (list 'optargs nopts)
  342. nopts
  343. (list 'argcount nargs)
  344. nargs))
  345. (setq s!:current_size 2)))
  346. ((greaterp nargs 3)
  347. (progn
  348. (setq s!:current_block (list (list 'argcount nargs) nargs))
  349. (setq s!:current_size 1)))
  350. (t (progn (setq s!:current_block nil) (setq s!:current_size 0)))) ))
  351. (de s!:set_label (x)
  352. (progn
  353. (cond
  354. (s!:current_label
  355. (prog (w)
  356. (setq w (cons s!:current_size s!:current_block))
  357. (prog (x)
  358. (setq x s!:recent_literals)
  359. lab (cond ((null x) (return nil)))
  360. ((lambda (x) (rplaca x w)) (car x))
  361. (setq x (cdr x))
  362. (go lab))
  363. (setq s!:recent_literals nil)
  364. (setq s!:current_procedure
  365. (cons
  366. (cons s!:current_label (cons (list 'jump x) w))
  367. s!:current_procedure))
  368. (setq s!:current_block nil)
  369. (setq s!:current_size 0))))
  370. (setq s!:current_label x)
  371. (setq s!:a_reg_values nil)))
  372. (de s!:outjump (op lab)
  373. (prog (g w)
  374. (cond ((not (flagp op 's!:preserves_a)) (setq s!:a_reg_values nil)))
  375. (cond ((null s!:current_label) (return nil)))
  376. (cond
  377. ((equal op 'jump) (setq op (list op lab)))
  378. ((equal op 'icase) (setq op (cons op lab)))
  379. (t (setq op (list op lab (setq g (gensym)))) ))
  380. (setq w (cons s!:current_size s!:current_block))
  381. (prog (x)
  382. (setq x s!:recent_literals)
  383. lab (cond ((null x) (return nil)))
  384. ((lambda (x) (rplaca x w)) (car x))
  385. (setq x (cdr x))
  386. (go lab))
  387. (setq s!:recent_literals nil)
  388. (setq s!:current_procedure
  389. (cons (cons s!:current_label (cons op w)) s!:current_procedure))
  390. (setq s!:current_block nil)
  391. (setq s!:current_size 0)
  392. (setq s!:current_label g)
  393. (return op)))
  394. (de s!:outexit nil
  395. (prog (w op)
  396. (setq op '(exit))
  397. (cond ((null s!:current_label) (return nil)))
  398. (setq w (cons s!:current_size s!:current_block))
  399. (prog (x)
  400. (setq x s!:recent_literals)
  401. lab (cond ((null x) (return nil)))
  402. ((lambda (x) (rplaca x w)) (car x))
  403. (setq x (cdr x))
  404. (go lab))
  405. (setq s!:recent_literals nil)
  406. (setq s!:current_procedure
  407. (cons (cons s!:current_label (cons op w)) s!:current_procedure))
  408. (setq s!:current_block nil)
  409. (setq s!:current_size 0)
  410. (setq s!:current_label nil)))
  411. (flag
  412. '(push pushnil pushnil2 pushnil3 lose lose2 lose3 loses storeloc storeloc0
  413. storeloc1 storeloc2 storeloc3 storeloc4 storeloc5 storeloc6 storeloc7
  414. jump jumpt jumpnil jumpeq jumpequal jumpne jumpnequal jumpatom
  415. jumpnatom)
  416. 's!:preserves_a)
  417. (de s!:outopcode0 (op doc)
  418. (prog nil
  419. (cond ((not (flagp op 's!:preserves_a)) (setq s!:a_reg_values nil)))
  420. (cond ((null s!:current_label) (return nil)))
  421. (setq s!:current_block (cons op s!:current_block))
  422. (setq s!:current_size (plus s!:current_size 1))
  423. (cond
  424. ((or !*plap !*pgwd)
  425. (setq s!:current_block (cons doc s!:current_block)))) ))
  426. (de s!:outopcode1 (op arg doc)
  427. (prog nil
  428. (cond ((not (flagp op 's!:preserves_a)) (setq s!:a_reg_values nil)))
  429. (cond ((null s!:current_label) (return nil)))
  430. (setq s!:current_block (cons arg (cons op s!:current_block)))
  431. (setq s!:current_size (plus s!:current_size 2))
  432. (cond
  433. ((or !*plap !*pgwd)
  434. (setq s!:current_block (cons (list op doc) s!:current_block)))) ))
  435. (deflist
  436. '((loadlit 1) (loadfree 2) (call0 2) (call1 2) (litget 2) (jumpliteq 2)
  437. (jumplitne 2)
  438. (jumpliteq!* 2)
  439. (jumplitne!* 2)
  440. (jumpfreet 2)
  441. (jumpfreenil 2))
  442. 's!:short_form_bonus)
  443. (de s!:record_literal (env)
  444. (prog (w extra)
  445. (setq w (gethash (car s!:current_block) (car env)))
  446. (cond ((null w) (setq w (cons 0 nil))))
  447. (setq extra (get (cadr s!:current_block) 's!:short_form_bonus))
  448. (cond ((null extra) (setq extra 10)) (t (setq extra (plus extra 10))))
  449. (setq s!:recent_literals
  450. (cons (cons nil s!:current_block) s!:recent_literals))
  451. (puthash
  452. (car s!:current_block)
  453. (car env)
  454. (cons
  455. (plus (car w) extra)
  456. (cons (car s!:recent_literals) (cdr w)))) ))
  457. (de s!:record_literal_for_jump (x env lab)
  458. (prog (w extra)
  459. (cond ((null s!:current_label) (return nil)))
  460. (setq w (gethash (cadr x) (car env)))
  461. (cond ((null w) (setq w (cons 0 nil))))
  462. (setq extra (get (car x) 's!:short_form_bonus))
  463. (cond ((null extra) (setq extra 10)) (t (setq extra (plus extra 10))))
  464. (setq x (s!:outjump x lab))
  465. (puthash
  466. (cadar x)
  467. (car env)
  468. (cons (plus (car w) extra) (cons (cons nil x) (cdr w)))) ))
  469. (de s!:outopcode1lit (op arg env)
  470. (prog nil
  471. (cond ((not (flagp op 's!:preserves_a)) (setq s!:a_reg_values nil)))
  472. (cond ((null s!:current_label) (return nil)))
  473. (setq s!:current_block (cons arg (cons op s!:current_block)))
  474. (s!:record_literal env)
  475. (setq s!:current_size (plus s!:current_size 2))
  476. (cond
  477. ((or !*plap !*pgwd)
  478. (setq s!:current_block (cons (list op arg) s!:current_block)))) ))
  479. (de s!:outopcode2 (op arg1 arg2 doc)
  480. (prog nil
  481. (cond ((not (flagp op 's!:preserves_a)) (setq s!:a_reg_values nil)))
  482. (cond ((null s!:current_label) (return nil)))
  483. (setq s!:current_block
  484. (cons arg2 (cons arg1 (cons op s!:current_block))))
  485. (setq s!:current_size (plus s!:current_size 3))
  486. (cond
  487. ((or !*plap !*pgwd)
  488. (setq s!:current_block (cons (cons op doc) s!:current_block)))) ))
  489. (de s!:outopcode2lit (op arg1 arg2 doc env)
  490. (prog nil
  491. (cond ((not (flagp op 's!:preserves_a)) (setq s!:a_reg_values nil)))
  492. (cond ((null s!:current_label) (return nil)))
  493. (setq s!:current_block (cons arg1 (cons op s!:current_block)))
  494. (s!:record_literal env)
  495. (setq s!:current_block (cons arg2 s!:current_block))
  496. (setq s!:current_size (plus s!:current_size 3))
  497. (cond
  498. ((or !*plap !*pgwd)
  499. (setq s!:current_block (cons (cons op doc) s!:current_block)))) ))
  500. (de s!:outlexref (op arg1 arg2 arg3 doc)
  501. (prog (arg4)
  502. (cond ((null s!:current_label) (return nil)))
  503. (cond
  504. ((or (greaterp arg1 255) (greaterp arg2 255) (greaterp arg3 255))
  505. (progn
  506. (cond
  507. ((or
  508. (greaterp arg1 2047)
  509. (greaterp arg2 31)
  510. (greaterp arg3 2047))
  511. (error "stack frame > 2047 or > 31 deep nesting")))
  512. (setq doc (list op doc))
  513. (setq arg4 (logand arg3 255))
  514. (setq arg3
  515. (plus (truncate arg3 256) (times 16 (logand arg1 15))))
  516. (cond
  517. ((equal op 'loadlex) (setq op (plus 192 arg2)))
  518. (t (setq op (plus 224 arg2))))
  519. (setq arg2 (truncate arg1 16))
  520. (setq arg1 op)
  521. (setq op 'bigstack)))
  522. (t (setq doc (list doc))))
  523. (setq s!:current_block
  524. (cons arg3 (cons arg2 (cons arg1 (cons op s!:current_block)))) )
  525. (setq s!:current_size (plus s!:current_size 4))
  526. (cond
  527. (arg4
  528. (progn
  529. (setq s!:current_block (cons arg4 s!:current_block))
  530. (setq s!:current_size (plus s!:current_size 1)))) )
  531. (cond
  532. ((or !*plap !*pgwd)
  533. (setq s!:current_block (cons (cons op doc) s!:current_block)))) ))
  534. (put
  535. 'loadlit
  536. 's!:shortform
  537. (cons
  538. '(1 . 7)
  539. (s!:vecof
  540. '(!- loadlit1 loadlit2 loadlit3 loadlit4 loadlit5 loadlit6
  541. loadlit7))))
  542. (put
  543. 'loadfree
  544. 's!:shortform
  545. (cons '(1 . 4) (s!:vecof '(!- loadfree1 loadfree2 loadfree3 loadfree4))))
  546. (put
  547. 'storefree
  548. 's!:shortform
  549. (cons '(1 . 3) (s!:vecof '(!- storefree1 storefree2 storefree3))))
  550. (put
  551. 'call0
  552. 's!:shortform
  553. (cons '(0 . 3) (s!:vecof '(call0_0 call0_1 call0_2 call0_3))))
  554. (put
  555. 'call1
  556. 's!:shortform
  557. (cons
  558. '(0 . 5)
  559. (s!:vecof '(call1_0 call1_1 call1_2 call1_3 call1_4 call1_5))))
  560. (put
  561. 'call2
  562. 's!:shortform
  563. (cons '(0 . 4) (s!:vecof '(call2_0 call2_1 call2_2 call2_3 call2_4))))
  564. (put
  565. 'jumpfreet
  566. 's!:shortform
  567. (cons
  568. '(1 . 4)
  569. (s!:vecof '(!- jumpfree1t jumpfree2t jumpfree3t jumpfree4t))))
  570. (put
  571. 'jumpfreenil
  572. 's!:shortform
  573. (cons
  574. '(1 . 4)
  575. (s!:vecof '(!- jumpfree1nil jumpfree2nil jumpfree3nil jumpfree4nil))))
  576. (put
  577. 'jumpliteq
  578. 's!:shortform
  579. (cons
  580. '(1 . 4)
  581. (s!:vecof '(!- jumplit1eq jumplit2eq jumplit3eq jumplit4eq))))
  582. (put
  583. 'jumplitne
  584. 's!:shortform
  585. (cons
  586. '(1 . 4)
  587. (s!:vecof '(!- jumplit1ne jumplit2ne jumplit3ne jumplit4ne))))
  588. (put 'jumpliteq!* 's!:shortform (get 'jumpliteq 's!:shortform))
  589. (put 'jumplitne!* 's!:shortform (get 'jumplitne 's!:shortform))
  590. (put 'call0 's!:longform 0)
  591. (put 'call1 's!:longform 16)
  592. (put 'call2 's!:longform 32)
  593. (put 'call3 's!:longform 48)
  594. (put 'calln 's!:longform 64)
  595. (put 'call2r 's!:longform 80)
  596. (put 'loadfree 's!:longform 96)
  597. (put 'storefree 's!:longform 112)
  598. (put 'jcall0 's!:longform 128)
  599. (put 'jcall1 's!:longform 144)
  600. (put 'jcall2 's!:longform 160)
  601. (put 'jcall3 's!:longform 176)
  602. (put 'jcalln 's!:longform 192)
  603. (put 'freebind 's!:longform 208)
  604. (put 'litget 's!:longform 224)
  605. (put 'loadlit 's!:longform 240)
  606. (de s!:literal_order (a b)
  607. (cond
  608. ((equal (cadr a) (cadr b)) (orderp (car a) (car b)))
  609. (t (greaterp (cadr a) (cadr b)))) )
  610. (de s!:resolve_literals (env)
  611. (prog (w op opspec n litbytes)
  612. (setq w (hashcontents (car env)))
  613. (setq w (sort w (function s!:literal_order)))
  614. (setq n (length w))
  615. (setq litbytes (times 4 n))
  616. (cond ((greaterp n 4096) (setq w (s!:too_many_literals w n))))
  617. (setq n 0)
  618. (prog (x)
  619. (setq x w)
  620. lab (cond ((null x) (return nil)))
  621. ((lambda (x) (progn (rplaca (cdr x) n) (setq n (plus n 1)))) (car x))
  622. (setq x (cdr x))
  623. (go lab))
  624. (prog (x)
  625. (setq x w)
  626. lab (cond ((null x) (return nil)))
  627. ((lambda (x)
  628. (progn
  629. (setq n (cadr x))
  630. (prog (y)
  631. (setq y (cddr x))
  632. lab (cond ((null y) (return nil)))
  633. ((lambda (y)
  634. (progn
  635. (cond
  636. ((null (car y))
  637. (progn
  638. (setq op (caadr y))
  639. (setq opspec (get op 's!:shortform))
  640. (cond
  641. ((and
  642. opspec
  643. (leq (caar opspec) n)
  644. (leq n (cdar opspec)))
  645. (rplaca
  646. (cdr y)
  647. (getv (cdr opspec) n)))
  648. (t (rplaca (cdadr y) n)))) )
  649. (t (progn
  650. (setq op (caddr y))
  651. (cond
  652. ((greaterp n 255)
  653. (progn
  654. (rplaca (car y) (plus (caar y) 1))
  655. (setq op
  656. (plus
  657. (get op 's!:longform)
  658. (truncate n 256)))
  659. (rplaca (cdr y) (ilogand n 255))
  660. (rplaca (cddr y) 'bigcall)
  661. (rplacd
  662. (cdr y)
  663. (cons op (cddr y)))) )
  664. ((and
  665. (setq opspec (get op 's!:shortform))
  666. (leq (caar opspec) n)
  667. (leq n (cdar opspec)))
  668. (progn
  669. (rplaca
  670. (car y)
  671. (difference (caar y) 1))
  672. (rplaca
  673. (cdr y)
  674. (getv (cdr opspec) n))
  675. (rplacd (cdr y) (cdddr y))))
  676. (t (rplaca (cdr y) n)))) ))) )
  677. (car y))
  678. (setq y (cdr y))
  679. (go lab))))
  680. (car x))
  681. (setq x (cdr x))
  682. (go lab))
  683. (prog (x)
  684. (setq x w)
  685. lab (cond ((null x) (return nil)))
  686. ((lambda (x) (rplacd x (cadr x))) (car x))
  687. (setq x (cdr x))
  688. (go lab))
  689. (rplaca env (cons (reversip w) litbytes))))
  690. (de s!:only_loadlit (l)
  691. (cond
  692. ((null l) t)
  693. ((null (caar l)) nil)
  694. ((not (eqcar (cddar l) 'loadlit)) nil)
  695. (t (s!:only_loadlit (cdr l)))) )
  696. (de s!:too_many_literals (w n)
  697. (prog (k xvecs l r newrefs uses z1)
  698. (setq k 0)
  699. (setq n (plus n 1))
  700. (prog nil
  701. !G5 (cond ((not (and (greaterp n 4096) (not (null w)))) (return nil)))
  702. (progn
  703. (cond
  704. ((and
  705. (not (equal (cadar w) 10000000))
  706. (s!:only_loadlit (cddar w)))
  707. (progn
  708. (setq l (cons (car w) l))
  709. (setq n (difference n 1))
  710. (setq k (plus k 1))
  711. (cond
  712. ((equal k 256)
  713. (progn
  714. (setq xvecs (cons l xvecs))
  715. (setq l nil)
  716. (setq k 0)
  717. (setq n (plus n 1)))) )))
  718. (t (setq r (cons (car w) r))))
  719. (setq w (cdr w)))
  720. (go !G5))
  721. (cond
  722. ((greaterp n 4096)
  723. (error "function uses too many literals (4096 is limit)")))
  724. (setq xvecs (cons l xvecs))
  725. (prog nil
  726. !G6 (cond ((not r) (return nil)))
  727. (progn (setq w (cons (car r) w)) (setq r (cdr r)))
  728. (go !G6))
  729. (prog (v)
  730. (setq v xvecs)
  731. lab (cond ((null v) (return nil)))
  732. ((lambda (v)
  733. (progn (setq newrefs nil) (setq uses 0) (setq r nil) (setq k 0)
  734. (prog (q)
  735. (setq q v)
  736. lab (cond ((null q) (return nil)))
  737. ((lambda (q)
  738. (progn
  739. (prog (z)
  740. (setq z (cddr q))
  741. lab (cond ((null z) (return nil)))
  742. ((lambda (z)
  743. (progn
  744. (cond
  745. ((car z)
  746. (rplaca (car z) (plus (caar z) 2))))
  747. (setq z1
  748. (cons 'qgetvn (cons nil (cddr z))))
  749. (rplaca (cdr z) k)
  750. (rplacd (cdr z) z1)
  751. (rplacd z (cdr z1))
  752. (setq newrefs (cons z newrefs))
  753. (setq uses (plus uses 11))))
  754. (car z))
  755. (setq z (cdr z))
  756. (go lab))
  757. (setq r (cons (car q) r))
  758. (setq k (plus k 1))))
  759. (car q))
  760. (setq q (cdr q))
  761. (go lab))
  762. (setq newrefs (cons uses newrefs))
  763. (setq newrefs (cons (s!:vecof (reversip r)) newrefs))
  764. (setq w (cons newrefs w))))
  765. (car v))
  766. (setq v (cdr v))
  767. (go lab))
  768. (return (sort w (function s!:literal_order)))) )
  769. (fluid '(s!:into_c))
  770. (de s!:endprocedure (name env)
  771. (prog (pc labelvals w vec)
  772. (s!:outexit)
  773. (cond (s!:into_c (return (cons s!:current_procedure env))))
  774. (s!:resolve_literals env)
  775. (setq s!:current_procedure (s!:tidy_flowgraph s!:current_procedure))
  776. (cond
  777. ((and (not !*notailcall) (not s!:has_closure))
  778. (setq s!:current_procedure
  779. (s!:try_tailcall s!:current_procedure))))
  780. (setq s!:current_procedure (s!:tidy_exits s!:current_procedure))
  781. (setq labelvals (s!:resolve_labels))
  782. (setq pc (car labelvals))
  783. (setq labelvals (cdr labelvals))
  784. (setq vec (make!-bps pc))
  785. (setq pc 0)
  786. (cond
  787. ((or !*plap !*pgwd)
  788. (progn (terpri) (ttab 23) (princ "+++ ") (prin name)
  789. (princ " +++") (terpri))))
  790. (prog (b)
  791. (setq b s!:current_procedure)
  792. lab (cond ((null b) (return nil)))
  793. ((lambda (b)
  794. (progn
  795. (cond
  796. ((and
  797. (car b)
  798. (flagp (car b) 'used_label)
  799. (or !*plap !*pgwd))
  800. (progn (ttab 20) (prin (car b)) (princ ":") (terpri))))
  801. (setq pc (s!:plant_basic_block vec pc (reverse (cdddr b))))
  802. (setq b (cadr b))
  803. (cond
  804. ((and b (not (equal (car b) 'icase)) (cdr b) (cddr b))
  805. (setq b (list (car b) (cadr b)))) )
  806. (setq pc (s!:plant_exit_code vec pc b labelvals))))
  807. (car b))
  808. (setq b (cdr b))
  809. (go lab))
  810. (cond
  811. (!*pwrds
  812. (progn
  813. (cond ((neq (posn) 0) (terpri)))
  814. (princ "+++ ")
  815. (prin name)
  816. (princ " compiled, ")
  817. (princ pc)
  818. (princ " + ")
  819. (princ (cdar env))
  820. (princ " bytes")
  821. (terpri))))
  822. (setq env (caar env))
  823. (cond
  824. ((null env) (setq w nil))
  825. (t (progn
  826. (setq w (mkvect (cdar env)))
  827. (prog nil
  828. !G7 (cond ((not env) (return nil)))
  829. (progn (putv w (cdar env) (caar env)) (setq env (cdr env)))
  830. (go !G7)))) )
  831. (return (cons vec w))))
  832. (de s!:add_pending (lab pend blocks)
  833. (prog (w)
  834. (cond ((not (atom lab)) (return (cons (list (gensym) lab 0) pend))))
  835. (setq w (atsoc lab pend))
  836. (cond
  837. (w (return (cons w (deleq w pend))))
  838. (t (return (cons (atsoc lab blocks) pend)))) ))
  839. (de s!:invent_exit (x blocks)
  840. (prog (w)
  841. (setq w blocks)
  842. scan (cond
  843. ((null w) (go not_found))
  844. ((and (eqcar (cadar w) x) (equal (caddar w) 0))
  845. (return (cons (caar w) blocks)))
  846. (t (setq w (cdr w))))
  847. (go scan)
  848. not_found
  849. (setq w (gensym))
  850. (return (cons w (cons (list w (list x) 0) blocks)))) )
  851. (de s!:destination_label (lab blocks)
  852. (prog (n w x)
  853. (setq w (atsoc lab blocks))
  854. (cond ((s!:is_lose_and_exit w blocks) (return '(exit))))
  855. (setq x (cadr w))
  856. (setq n (caddr w))
  857. (setq w (cdddr w))
  858. (cond ((neq n 0) (return lab)))
  859. (cond
  860. ((or (null x) (null (cdr x))) (return x))
  861. ((equal (cadr x) lab) (return lab))
  862. ((null (cddr x)) (return (s!:destination_label (cadr x) blocks)))
  863. (t (return lab)))) )
  864. (de s!:remlose (b)
  865. (prog (w)
  866. (setq w b)
  867. (prog nil
  868. !G8 (cond ((not (and w (not (atom (car w)))) ) (return nil)))
  869. (setq w (cdr w))
  870. (go !G8))
  871. (cond ((null w) (return (cons 0 b))))
  872. (cond
  873. ((and (numberp (car w)) (eqcar (cdr w) 'loses))
  874. (setq w (cons 2 (cddr w))))
  875. ((or
  876. (equal (car w) 'lose)
  877. (equal (car w) 'lose2)
  878. (equal (car w) 'lose3))
  879. (setq w (cons 1 (cdr w))))
  880. (t (return (cons 0 b))))
  881. (setq b (s!:remlose (cdr w)))
  882. (return (cons (plus (car w) (car b)) (cdr b)))) )
  883. (put 'call0_0 's!:shortcall '(0 . 0))
  884. (put 'call0_1 's!:shortcall '(0 . 1))
  885. (put 'call0_2 's!:shortcall '(0 . 2))
  886. (put 'call0_3 's!:shortcall '(0 . 3))
  887. (put 'call1_0 's!:shortcall '(1 . 0))
  888. (put 'call1_1 's!:shortcall '(1 . 1))
  889. (put 'call1_2 's!:shortcall '(1 . 2))
  890. (put 'call1_3 's!:shortcall '(1 . 3))
  891. (put 'call1_4 's!:shortcall '(1 . 4))
  892. (put 'call1_5 's!:shortcall '(1 . 5))
  893. (put 'call2_0 's!:shortcall '(2 . 0))
  894. (put 'call2_1 's!:shortcall '(2 . 1))
  895. (put 'call2_2 's!:shortcall '(2 . 2))
  896. (put 'call2_3 's!:shortcall '(2 . 3))
  897. (put 'call2_4 's!:shortcall '(2 . 4))
  898. (de s!:remcall (b)
  899. (prog (w p q r s)
  900. (prog nil
  901. !G9 (cond ((not (and b (not (atom (car b)))) ) (return nil)))
  902. (progn (setq p (car b)) (setq b (cdr b)))
  903. (go !G9))
  904. (cond
  905. ((null b) (return nil))
  906. ((numberp (car b))
  907. (progn
  908. (setq r (car b))
  909. (setq s 2)
  910. (setq b (cdr b))
  911. (cond
  912. ((null b) (return nil))
  913. ((numberp (car b))
  914. (progn
  915. (setq q r)
  916. (setq r (car b))
  917. (setq s 3)
  918. (setq b (cdr b))
  919. (cond
  920. ((and
  921. b
  922. (numberp (setq w (car b)))
  923. (eqcar (cdr b) 'bigcall)
  924. (equal (truncate w 16) 4))
  925. (progn
  926. (setq r (plus (times 256 (logand w 15)) r))
  927. (setq s 4)
  928. (setq b (cdr b))))
  929. ((eqcar b 'bigcall)
  930. (progn
  931. (setq w (truncate r 16))
  932. (setq r (plus (times 256 (logand r 15)) q))
  933. (setq q w)
  934. (cond
  935. ((equal q 5)
  936. (progn
  937. (setq q 2)
  938. (setq s (difference s 1))
  939. (setq b
  940. (cons
  941. 'bigcall
  942. (cons 'swop (cdr b)))) )))
  943. (cond ((greaterp q 4) (return nil)))) )
  944. ((not (eqcar b 'calln)) (return nil)))) )
  945. ((equal (car b) 'call0) (setq q 0))
  946. ((equal (car b) 'call1) (setq q 1))
  947. ((equal (car b) 'call2) (setq q 2))
  948. ((equal (car b) 'call2r)
  949. (progn
  950. (setq q 2)
  951. (setq s (difference s 1))
  952. (setq b (cons 'call2 (cons 'swop (cdr b)))) ))
  953. ((equal (car b) 'call3) (setq q 3))
  954. (t (return nil)))
  955. (setq b (cdr b))))
  956. ((setq q (get (car b) 's!:shortcall))
  957. (progn
  958. (setq r (cdr q))
  959. (setq q (car q))
  960. (setq s 1)
  961. (setq b (cdr b))))
  962. (t (return nil)))
  963. (return (cons p (cons q (cons r (cons s b)))) )))
  964. (de s!:is_lose_and_exit (b blocks)
  965. (prog (lab exit)
  966. (setq lab (car b))
  967. (setq exit (cadr b))
  968. (setq b (cdddr b))
  969. (cond ((null exit) (return nil)))
  970. (setq b (s!:remlose b))
  971. (setq b (cdr b))
  972. (prog nil
  973. !G10 (cond ((not (and b (not (atom (car b)))) ) (return nil)))
  974. (setq b (cdr b))
  975. (go !G10))
  976. (cond
  977. (b (return nil))
  978. ((equal (car exit) 'exit) (return t))
  979. ((equal (car exit) 'jump)
  980. (progn
  981. (cond
  982. ((equal (cadr exit) lab) nil)
  983. (t (return
  984. (s!:is_lose_and_exit
  985. (atsoc (cadr exit) blocks)
  986. blocks)))) ))
  987. (t (return nil)))) )
  988. (de s!:try_tail_1 (b blocks)
  989. (prog (exit size body w w0 w1 w2 op)
  990. (setq exit (cadr b))
  991. (cond
  992. ((null exit) (return b))
  993. ((not (equal (car exit) 'exit))
  994. (progn
  995. (cond
  996. ((equal (car exit) 'jump)
  997. (progn
  998. (cond
  999. ((not
  1000. (s!:is_lose_and_exit
  1001. (atsoc (cadr exit) blocks)
  1002. blocks))
  1003. (return b)))) )
  1004. (t (return b)))) ))
  1005. (setq size (caddr b))
  1006. (setq body (cdddr b))
  1007. (setq body (s!:remlose body))
  1008. (setq size (difference size (car body)))
  1009. (setq body (cdr body))
  1010. (setq w (s!:remcall body))
  1011. (cond ((null w) (return b)))
  1012. (setq w0 (cadr w))
  1013. (setq w1 (caddr w))
  1014. (setq body (cddddr w))
  1015. (cond
  1016. ((and (leq w0 7) (leq w1 31))
  1017. (progn
  1018. (setq body (cons 'jcall body))
  1019. (setq body (cons (plus (times 32 w0) w1) body))
  1020. (setq size (difference size 1))))
  1021. ((lessp w1 256) (setq body (cons w0 (cons w1 (cons 'jcalln body)))) )
  1022. (t (progn
  1023. (setq body (cons 'bigcall body))
  1024. (setq w2 (logand w1 255))
  1025. (setq w1 (truncate w1 256))
  1026. (cond
  1027. ((lessp w0 4)
  1028. (setq body
  1029. (cons w2 (cons (plus w1 (times 16 w0) 128) body))))
  1030. (t (progn
  1031. (setq body
  1032. (cons
  1033. w0
  1034. (cons
  1035. w2
  1036. (cons (plus w1 (times 16 4) 128) body))))
  1037. (setq size (plus size 1)))) ))) )
  1038. (cond ((car w) (setq body (cons (append (car w) (list 'tail)) body))))
  1039. (rplaca (cdr b) nil)
  1040. (rplaca (cddr b) (plus (difference size (cadddr w)) 3))
  1041. (rplacd (cddr b) body)
  1042. (return b)))
  1043. (de s!:try_tailcall (b)
  1044. (prog (v !G11 endptr)
  1045. (setq v b)
  1046. (cond ((null v) (return nil)))
  1047. (setq !G11
  1048. (setq endptr (cons ((lambda (v) (s!:try_tail_1 v b)) (car v)) nil)))
  1049. looplabel
  1050. (setq v (cdr v))
  1051. (cond ((null v) (return !G11)))
  1052. (rplacd endptr (cons ((lambda (v) (s!:try_tail_1 v b)) (car v)) nil))
  1053. (setq endptr (cdr endptr))
  1054. (go looplabel)))
  1055. (de s!:tidy_exits_1 (b blocks)
  1056. (prog (exit size body comm w w0 w1 w2 op)
  1057. (setq exit (cadr b))
  1058. (cond
  1059. ((null exit) (return b))
  1060. ((not (equal (car exit) 'exit))
  1061. (progn
  1062. (cond
  1063. ((equal (car exit) 'jump)
  1064. (progn
  1065. (cond
  1066. ((not
  1067. (s!:is_lose_and_exit
  1068. (atsoc (cadr exit) blocks)
  1069. blocks))
  1070. (return b)))) )
  1071. (t (return b)))) ))
  1072. (setq size (caddr b))
  1073. (setq body (cdddr b))
  1074. (setq body (s!:remlose body))
  1075. (setq size (difference size (car body)))
  1076. (setq body (cdr body))
  1077. (prog nil
  1078. !G12 (cond ((not (and body (not (atom (car body)))) ) (return nil)))
  1079. (progn (setq comm (car body)) (setq body (cdr body)))
  1080. (go !G12))
  1081. (cond
  1082. ((eqcar body 'vnil) (setq w 'nilexit))
  1083. ((eqcar body 'loadloc0) (setq w 'loc0exit))
  1084. ((eqcar body 'loadloc1) (setq w 'loc1exit))
  1085. ((eqcar body 'loadloc2) (setq w 'loc2exit))
  1086. (t (setq w nil)))
  1087. (cond
  1088. (w
  1089. (progn
  1090. (rplaca (cdr b) (list w))
  1091. (setq body (cdr body))
  1092. (setq size (difference size 1))))
  1093. (comm (setq body (cons comm body))))
  1094. (rplaca (cddr b) size)
  1095. (rplacd (cddr b) body)
  1096. (return b)))
  1097. (de s!:tidy_exits (b)
  1098. (prog (v !G13 endptr)
  1099. (setq v b)
  1100. (cond ((null v) (return nil)))
  1101. (setq !G13
  1102. (setq endptr
  1103. (cons ((lambda (v) (s!:tidy_exits_1 v b)) (car v)) nil)))
  1104. looplabel
  1105. (setq v (cdr v))
  1106. (cond ((null v) (return !G13)))
  1107. (rplacd endptr (cons ((lambda (v) (s!:tidy_exits_1 v b)) (car v)) nil))
  1108. (setq endptr (cdr endptr))
  1109. (go looplabel)))
  1110. (de s!:tidy_flowgraph (b)
  1111. (prog (r pending)
  1112. (setq b (reverse b))
  1113. (setq pending (list (car b)))
  1114. (prog nil
  1115. !G14 (cond ((not pending) (return nil)))
  1116. (prog (c x l1 l2 done1 done2)
  1117. (setq c (car pending))
  1118. (setq pending (cdr pending))
  1119. (flag (list (car c)) 'coded)
  1120. (setq x (cadr c))
  1121. (cond
  1122. ((or (null x) (null (cdr x))) (setq r (cons c r)))
  1123. ((equal (car x) 'icase)
  1124. (progn
  1125. (rplacd x (reversip (cdr x)))
  1126. (prog (ll)
  1127. (setq ll (cdr x))
  1128. lab (cond ((null ll) (return nil)))
  1129. (progn
  1130. (setq l1 (s!:destination_label (car ll) b))
  1131. (cond
  1132. ((not (atom l1))
  1133. (progn
  1134. (setq l1 (s!:invent_exit (car l1) b))
  1135. (setq b (cdr l1))
  1136. (setq l1 (cadr l1)))) )
  1137. (rplaca ll l1)
  1138. (setq done1 (flagp l1 'coded))
  1139. (flag (list l1) 'used_label)
  1140. (cond
  1141. ((not done1)
  1142. (setq pending
  1143. (s!:add_pending l1 pending b)))) )
  1144. (setq ll (cdr ll))
  1145. (go lab))
  1146. (rplacd x (reversip (cdr x)))
  1147. (setq r (cons c r))))
  1148. ((null (cddr x))
  1149. (progn
  1150. (setq l1 (s!:destination_label (cadr x) b))
  1151. (cond
  1152. ((not (atom l1))
  1153. (setq c (cons (car c) (cons l1 (cddr c)))) )
  1154. ((flagp l1 'coded)
  1155. (progn
  1156. (flag (list l1) 'used_label)
  1157. (setq c
  1158. (cons
  1159. (car c)
  1160. (cons (list (car x) l1) (cddr c)))) ))
  1161. (t (progn
  1162. (setq c (cons (car c) (cons nil (cddr c))))
  1163. (setq pending (s!:add_pending l1 pending b)))) )
  1164. (setq r (cons c r))))
  1165. (t (progn
  1166. (setq l1 (s!:destination_label (cadr x) b))
  1167. (setq l2 (s!:destination_label (caddr x) b))
  1168. (setq done1 (and (atom l1) (flagp l1 'coded)))
  1169. (setq done2 (and (atom l2) (flagp l2 'coded)))
  1170. (cond
  1171. (done1
  1172. (progn
  1173. (cond
  1174. (done2
  1175. (progn
  1176. (flag (list l1) 'used_label)
  1177. (rplaca (cdadr c) l1)
  1178. (setq pending
  1179. (cons
  1180. (list (gensym) (list 'jump l2) 0)
  1181. pending))))
  1182. (t (progn
  1183. (flag (list l1) 'used_label)
  1184. (rplaca (cdadr c) l1)
  1185. (setq pending
  1186. (s!:add_pending l2 pending b)))) )))
  1187. (t (progn
  1188. (cond
  1189. (done2
  1190. (progn
  1191. (flag (list l2) 'used_label)
  1192. (rplaca
  1193. (cadr c)
  1194. (s!:negate_jump (car x)))
  1195. (rplaca (cdadr c) l2)
  1196. (setq pending
  1197. (s!:add_pending l1 pending b))))
  1198. (t (progn
  1199. (cond
  1200. ((not (atom l1))
  1201. (progn
  1202. (setq l1
  1203. (s!:invent_exit
  1204. (car l1)
  1205. b))
  1206. (setq b (cdr l1))
  1207. (setq l1 (car l1)))) )
  1208. (flag (list l1) 'used_label)
  1209. (rplaca (cdadr c) l1)
  1210. (cond
  1211. ((not (flagp l1 'coded))
  1212. (setq pending
  1213. (s!:add_pending
  1214. l1
  1215. pending
  1216. b))))
  1217. (setq pending
  1218. (s!:add_pending
  1219. l2
  1220. pending
  1221. b)))) ))) )
  1222. (setq r (cons c r)))) ))
  1223. (go !G14))
  1224. (return (reverse r))))
  1225. (deflist
  1226. '((jumpnil jumpt)
  1227. (jumpt jumpnil)
  1228. (jumpatom jumpnatom)
  1229. (jumpnatom jumpatom)
  1230. (jumpeq jumpne)
  1231. (jumpne jumpeq)
  1232. (jumpequal jumpnequal)
  1233. (jumpnequal jumpequal)
  1234. (jumpl0nil jumpl0t)
  1235. (jumpl0t jumpl0nil)
  1236. (jumpl1nil jumpl1t)
  1237. (jumpl1t jumpl1nil)
  1238. (jumpl2nil jumpl2t)
  1239. (jumpl2t jumpl2nil)
  1240. (jumpl3nil jumpl3t)
  1241. (jumpl3t jumpl3nil)
  1242. (jumpl4nil jumpl4t)
  1243. (jumpl4t jumpl4nil)
  1244. (jumpl0atom jumpl0natom)
  1245. (jumpl0natom jumpl0atom)
  1246. (jumpl1atom jumpl1natom)
  1247. (jumpl1natom jumpl1atom)
  1248. (jumpl2atom jumpl2natom)
  1249. (jumpl2natom jumpl2atom)
  1250. (jumpl3atom jumpl3natom)
  1251. (jumpl3natom jumpl3atom)
  1252. (jumpst0nil jumpst0t)
  1253. (jumpst0t jumpst0nil)
  1254. (jumpst1nil jumpst1t)
  1255. (jumpst1t jumpst1nil)
  1256. (jumpst2nil jumpst2t)
  1257. (jumpst2t jumpst2nil)
  1258. (jumpfree1nil jumpfree1t)
  1259. (jumpfree1t jumpfree1nil)
  1260. (jumpfree2nil jumpfree2t)
  1261. (jumpfree2t jumpfree2nil)
  1262. (jumpfree3nil jumpfree3t)
  1263. (jumpfree3t jumpfree3nil)
  1264. (jumpfree4nil jumpfree4t)
  1265. (jumpfree4t jumpfree4nil)
  1266. (jumpfreenil jumpfreet)
  1267. (jumpfreet jumpfreenil)
  1268. (jumplit1eq jumplit1ne)
  1269. (jumplit1ne jumplit1eq)
  1270. (jumplit2eq jumplit2ne)
  1271. (jumplit2ne jumplit2eq)
  1272. (jumplit3eq jumplit3ne)
  1273. (jumplit3ne jumplit3eq)
  1274. (jumplit4eq jumplit4ne)
  1275. (jumplit4ne jumplit4eq)
  1276. (jumpliteq jumplitne)
  1277. (jumplitne jumpliteq)
  1278. (jumpliteq!* jumplitne!*)
  1279. (jumplitne!* jumpliteq!*)
  1280. (jumpb1nil jumpb1t)
  1281. (jumpb1t jumpb1nil)
  1282. (jumpb2nil jumpb2t)
  1283. (jumpb2t jumpb2nil)
  1284. (jumpflagp jumpnflagp)
  1285. (jumpnflagp jumpflagp)
  1286. (jumpeqcar jumpneqcar)
  1287. (jumpneqcar jumpeqcar))
  1288. 'negjump)
  1289. (de s!:negate_jump (x)
  1290. (cond ((atom x) (get x 'negjump)) (t (rplaca x (get (car x) 'negjump)))) )
  1291. (de s!:resolve_labels nil
  1292. (prog (w labelvals converged pc x)
  1293. (prog nil
  1294. !G15 (progn
  1295. (setq converged t)
  1296. (setq pc 0)
  1297. (prog (b)
  1298. (setq b s!:current_procedure)
  1299. lab (cond ((null b) (return nil)))
  1300. ((lambda (b)
  1301. (progn
  1302. (setq w (assoc!*!* (car b) labelvals))
  1303. (cond
  1304. ((null w)
  1305. (progn
  1306. (setq converged nil)
  1307. (setq w (cons (car b) pc))
  1308. (setq labelvals (cons w labelvals))))
  1309. ((neq (cdr w) pc)
  1310. (progn (rplacd w pc) (setq converged nil))))
  1311. (setq pc (plus pc (caddr b)))
  1312. (setq x (cadr b))
  1313. (cond
  1314. ((null x) nil)
  1315. ((null (cdr x)) (setq pc (plus pc 1)))
  1316. ((equal (car x) 'icase)
  1317. (setq pc (plus pc (times 2 (length x)))) )
  1318. (t (progn
  1319. (setq w (assoc!*!* (cadr x) labelvals))
  1320. (cond
  1321. ((null w)
  1322. (progn
  1323. (setq w 128)
  1324. (setq converged nil)))
  1325. (t (setq w (difference (cdr w) pc))))
  1326. (setq w (s!:expand_jump (car x) w))
  1327. (setq pc (plus pc (length w)))) ))) )
  1328. (car b))
  1329. (setq b (cdr b))
  1330. (go lab)))
  1331. (cond ((not converged) (go !G15))))
  1332. (return (cons pc labelvals))))
  1333. (de s!:plant_basic_block (vec pc b)
  1334. (prog (tagged)
  1335. (prog (i)
  1336. (setq i b)
  1337. lab (cond ((null i) (return nil)))
  1338. ((lambda (i)
  1339. (progn
  1340. (cond
  1341. ((atom i)
  1342. (progn
  1343. (cond ((symbolp i) (setq i (get i 's!:opcode))))
  1344. (cond
  1345. ((and (not tagged) (or !*plap !*pgwd))
  1346. (progn
  1347. (s!:prinhex4 pc)
  1348. (princ ":")
  1349. (ttab 8)
  1350. (setq tagged t))))
  1351. (cond
  1352. ((or (not (fixp i)) (lessp i 0) (greaterp i 255))
  1353. (error "bad byte to put" i)))
  1354. (bps!-putv vec pc i)
  1355. (cond
  1356. ((or !*plap !*pgwd)
  1357. (progn (s!:prinhex2 i) (princ " "))))
  1358. (setq pc (plus pc 1))))
  1359. ((or !*plap !*pgwd)
  1360. (progn
  1361. (ttab 23)
  1362. (princ (car i))
  1363. (prog (w)
  1364. (setq w (cdr i))
  1365. lab (cond ((null w) (return nil)))
  1366. ((lambda (w) (progn (princ " ") (prin w)))
  1367. (car w))
  1368. (setq w (cdr w))
  1369. (go lab))
  1370. (terpri)
  1371. (setq tagged nil)))) ))
  1372. (car i))
  1373. (setq i (cdr i))
  1374. (go lab))
  1375. (return pc)))
  1376. (de s!:plant_bytes (vec pc bytelist doc)
  1377. (prog nil
  1378. (cond
  1379. ((or !*plap !*pgwd) (progn (s!:prinhex4 pc) (princ ":") (ttab 8))))
  1380. (prog (v)
  1381. (setq v bytelist)
  1382. lab (cond ((null v) (return nil)))
  1383. ((lambda (v)
  1384. (progn
  1385. (cond ((symbolp v) (setq v (get v 's!:opcode))))
  1386. (cond
  1387. ((or (not (fixp v)) (lessp v 0) (greaterp v 255))
  1388. (error "bad byte to put" v)))
  1389. (bps!-putv vec pc v)
  1390. (cond
  1391. ((or !*plap !*pgwd)
  1392. (progn
  1393. (cond
  1394. ((greaterp (posn) 50) (progn (terpri) (ttab 8))))
  1395. (s!:prinhex2 v)
  1396. (princ " "))))
  1397. (setq pc (plus pc 1))))
  1398. (car v))
  1399. (setq v (cdr v))
  1400. (go lab))
  1401. (cond
  1402. ((or !*plap !*pgwd)
  1403. (progn
  1404. (cond ((greaterp (posn) 23) (terpri)))
  1405. (ttab 23)
  1406. (princ (car doc))
  1407. (prog (w)
  1408. (setq w (cdr doc))
  1409. lab (cond ((null w) (return nil)))
  1410. ((lambda (w)
  1411. (progn
  1412. (cond
  1413. ((greaterp (posn) 65) (progn (terpri) (ttab 23))))
  1414. (princ " ")
  1415. (prin w)))
  1416. (car w))
  1417. (setq w (cdr w))
  1418. (go lab))
  1419. (terpri))))
  1420. (return pc)))
  1421. (de s!:plant_exit_code (vec pc b labelvals)
  1422. (prog (w loc low high r)
  1423. (cond
  1424. ((null b) (return pc))
  1425. ((null (cdr b))
  1426. (return
  1427. (s!:plant_bytes vec pc (list (get (car b) 's!:opcode)) b)))
  1428. ((equal (car b) 'icase)
  1429. (progn
  1430. (setq loc (plus pc 3))
  1431. (prog (ll)
  1432. (setq ll (cdr b))
  1433. lab (cond ((null ll) (return nil)))
  1434. ((lambda (ll)
  1435. (progn
  1436. (setq w
  1437. (difference (cdr (assoc!*!* ll labelvals)) loc))
  1438. (setq loc (plus loc 2))
  1439. (cond
  1440. ((lessp w 0)
  1441. (progn
  1442. (setq w (minus w))
  1443. (setq low (ilogand w 255))
  1444. (setq high
  1445. (plus
  1446. 128
  1447. (truncate (difference w low) 256)))) )
  1448. (t (progn
  1449. (setq low (ilogand w 255))
  1450. (setq high
  1451. (truncate (difference w low) 256)))) )
  1452. (setq r (cons low (cons high r)))) )
  1453. (car ll))
  1454. (setq ll (cdr ll))
  1455. (go lab))
  1456. (setq r
  1457. (cons
  1458. (get 'icase 's!:opcode)
  1459. (cons (length (cddr b)) (reversip r))))
  1460. (return (s!:plant_bytes vec pc r b)))) )
  1461. (setq w (difference (cdr (assoc!*!* (cadr b) labelvals)) pc))
  1462. (setq w (s!:expand_jump (car b) w))
  1463. (return (s!:plant_bytes vec pc w b))))
  1464. (deflist
  1465. '((jumpl0nil ((loadloc0) jumpnil))
  1466. (jumpl0t ((loadloc0) jumpt))
  1467. (jumpl1nil ((loadloc1) jumpnil))
  1468. (jumpl1t ((loadloc1) jumpt))
  1469. (jumpl2nil ((loadloc2) jumpnil))
  1470. (jumpl2t ((loadloc2) jumpt))
  1471. (jumpl3nil ((loadloc3) jumpnil))
  1472. (jumpl3t ((loadloc3) jumpt))
  1473. (jumpl4nil ((loadloc4) jumpnil))
  1474. (jumpl4t ((loadloc4) jumpt))
  1475. (jumpl0atom ((loadloc0) jumpatom))
  1476. (jumpl0natom ((loadloc0) jumpnatom))
  1477. (jumpl1atom ((loadloc1) jumpatom))
  1478. (jumpl1natom ((loadloc1) jumpnatom))
  1479. (jumpl2atom ((loadloc2) jumpatom))
  1480. (jumpl2natom ((loadloc2) jumpnatom))
  1481. (jumpl3atom ((loadloc3) jumpatom))
  1482. (jumpl3natom ((loadloc3) jumpnatom))
  1483. (jumpst0nil ((storeloc0) jumpnil))
  1484. (jumpst0t ((storeloc0) jumpt))
  1485. (jumpst1nil ((storeloc1) jumpnil))
  1486. (jumpst1t ((storeloc1) jumpt))
  1487. (jumpst2nil ((storeloc2) jumpnil))
  1488. (jumpst2t ((storeloc2) jumpt))
  1489. (jumpfree1nil ((loadfree1) jumpnil))
  1490. (jumpfree1t ((loadfree1) jumpt))
  1491. (jumpfree2nil ((loadfree2) jumpnil))
  1492. (jumpfree2t ((loadfree2) jumpt))
  1493. (jumpfree3nil ((loadfree3) jumpnil))
  1494. (jumpfree3t ((loadfree3) jumpt))
  1495. (jumpfree4nil ((loadfree4) jumpnil))
  1496. (jumpfree4t ((loadfree4) jumpt))
  1497. (jumpfreenil ((loadfree !*) jumpnil))
  1498. (jumpfreet ((loadfree !*) jumpt))
  1499. (jumplit1eq ((loadlit1) jumpeq))
  1500. (jumplit1ne ((loadlit1) jumpne))
  1501. (jumplit2eq ((loadlit2) jumpeq))
  1502. (jumplit2ne ((loadlit2) jumpne))
  1503. (jumplit3eq ((loadlit3) jumpeq))
  1504. (jumplit3ne ((loadlit3) jumpne))
  1505. (jumplit4eq ((loadlit4) jumpeq))
  1506. (jumplit4ne ((loadlit4) jumpne))
  1507. (jumpliteq ((loadlit !*) jumpeq))
  1508. (jumplitne ((loadlit !*) jumpne))
  1509. (jumpliteq!* ((loadlit !* swop) jumpeq))
  1510. (jumplitne!* ((loadlit !* swop) jumpne))
  1511. (jumpb1nil ((builtin1 !*) jumpnil))
  1512. (jumpb1t ((builtin1 !*) jumpt))
  1513. (jumpb2nil ((builtin2 !*) jumpnil))
  1514. (jumpb2t ((builtin2 !*) jumpt))
  1515. (jumpflagp ((loadlit !* flagp) jumpt))
  1516. (jumpnflagp ((loadlit !* flagp) jumpnil))
  1517. (jumpeqcar ((loadlit !* eqcar) jumpt))
  1518. (jumpneqcar ((loadlit !* eqcar) jumpnil)))
  1519. 's!:expand_jump)
  1520. (fluid '(s!:backwards_jump s!:longer_jump))
  1521. (progn
  1522. (setq s!:backwards_jump (make!-simple!-string 256))
  1523. (setq s!:longer_jump (make!-simple!-string 256))
  1524. nil)
  1525. (prog (op)
  1526. (setq op
  1527. '((jump jump_b jump_l jump_bl)
  1528. (jumpnil jumpnil_b jumpnil_l jumpnil_bl)
  1529. (jumpt jumpt_b jumpt_l jumpt_bl)
  1530. (jumpatom jumpatom_b jumpatom_l jumpatom_bl)
  1531. (jumpnatom jumpnatom_b jumpnatom_l jumpnatom_bl)
  1532. (jumpeq jumpeq_b jumpeq_l jumpeq_bl)
  1533. (jumpne jumpne_b jumpne_l jumpne_bl)
  1534. (jumpequal jumpequal_b jumpequal_l jumpequal_bl)
  1535. (jumpnequal jumpnequal_b jumpnequal_l jumpnequal_bl)
  1536. (catch catch_b catch_l catch_bl)))
  1537. lab(cond ((null op) (return nil)))
  1538. ((lambda (op)
  1539. (progn
  1540. (putv!-char
  1541. s!:backwards_jump
  1542. (get (car op) 's!:opcode)
  1543. (get (cadr op) 's!:opcode))
  1544. (putv!-char
  1545. s!:backwards_jump
  1546. (get (caddr op) 's!:opcode)
  1547. (get (cadddr op) 's!:opcode))
  1548. (putv!-char
  1549. s!:longer_jump
  1550. (get (car op) 's!:opcode)
  1551. (get (caddr op) 's!:opcode))
  1552. (putv!-char
  1553. s!:longer_jump
  1554. (get (cadr op) 's!:opcode)
  1555. (get (cadddr op) 's!:opcode))))
  1556. (car op))
  1557. (setq op (cdr op))
  1558. (go lab))
  1559. (de s!:expand_jump (op offset)
  1560. (prog (arg low high opcode expanded)
  1561. (cond
  1562. ((not (atom op))
  1563. (progn
  1564. (setq arg (cadr op))
  1565. (setq op (car op))
  1566. (setq offset (difference offset 1)))) )
  1567. (setq expanded (get op 's!:expand_jump))
  1568. (cond
  1569. ((and
  1570. expanded
  1571. (not
  1572. (and
  1573. (leq 2 offset)
  1574. (lessp offset (plus 256 2))
  1575. (or (null arg) (lessp arg 256)))) )
  1576. (progn
  1577. (setq op (cadr expanded))
  1578. (setq expanded (car expanded))
  1579. (cond
  1580. (arg
  1581. (progn
  1582. (cond
  1583. ((greaterp arg 2047)
  1584. (error
  1585. "function uses too many literals (2048 limit)"))
  1586. ((greaterp arg 255)
  1587. (prog (high low)
  1588. (setq low (ilogand expanded 255))
  1589. (setq high
  1590. (truncate (difference expanded low) 256))
  1591. (setq expanded
  1592. (plus
  1593. (cons
  1594. 'bigcall
  1595. (get (car expanded) 's!:longform))
  1596. (cons
  1597. high
  1598. (cons low (cddr expanded)))) )))
  1599. (t (setq expanded (subst arg '!* expanded))))
  1600. (setq offset (plus offset 1)))) )
  1601. (setq offset (difference offset (length expanded)))
  1602. (setq arg nil)))
  1603. (t (setq expanded nil)))
  1604. (setq opcode (get op 's!:opcode))
  1605. (cond ((null opcode) (error 0 (list op offset "invalid block exit"))))
  1606. (cond
  1607. ((and
  1608. (lessp (plus (minus 256) 2) offset)
  1609. (lessp offset (plus 256 2)))
  1610. (setq offset (difference offset 2)))
  1611. (t (progn (setq high t) (setq offset (difference offset 3)))) )
  1612. (cond
  1613. ((lessp offset 0)
  1614. (progn
  1615. (setq opcode (byte!-getv s!:backwards_jump opcode))
  1616. (setq offset (minus offset)))) )
  1617. (cond
  1618. (high
  1619. (progn
  1620. (setq low (logand offset 255))
  1621. (setq high (truncate (difference offset low) 256))))
  1622. ((greaterp (setq low offset) 255)
  1623. (error 0 "Bad offset in expand_jump")))
  1624. (cond
  1625. (arg (return (list opcode arg low)))
  1626. ((not high) (return (append expanded (list opcode low))))
  1627. (t (return
  1628. (append
  1629. expanded
  1630. (list (byte!-getv s!:longer_jump opcode) high low)))) )))
  1631. (de s!:comval (x env context)
  1632. (prog (helper)
  1633. (setq x (s!:improve x))
  1634. (cond
  1635. ((atom x) (return (s!:comatom x env context)))
  1636. ((eqcar (car x) 'lambda)
  1637. (return (s!:comlambda (cadar x) (cddar x) (cdr x) env context)))
  1638. ((eq (car x) s!:current_function) (s!:comcall x env context))
  1639. ((and
  1640. (setq helper (get (car x) 's!:compilermacro))
  1641. (setq helper (funcall helper x env context)))
  1642. (return (s!:comval helper env context)))
  1643. ((setq helper (get (car x) 's!:newname))
  1644. (return (s!:comval (cons helper (cdr x)) env context)))
  1645. ((setq helper (get (car x) 's!:compfn))
  1646. (return (funcall helper x env context)))
  1647. ((setq helper (macro!-function (car x)))
  1648. (return (s!:comval (funcall helper x) env context)))
  1649. (t (return (s!:comcall x env context)))) ))
  1650. (de s!:comspecform (x env context) (error 0 (list "special form" x)))
  1651. (cond
  1652. ((null (get 'and 's!:compfn))
  1653. (progn
  1654. (put 'compiler!-let 's!:compfn (function s!:comspecform))
  1655. (put 'de 's!:compfn (function s!:comspecform))
  1656. (put 'defun 's!:compfn (function s!:comspecform))
  1657. (put 'eval!-when 's!:compfn (function s!:comspecform))
  1658. (put 'flet 's!:compfn (function s!:comspecform))
  1659. (put 'labels 's!:compfn (function s!:comspecform))
  1660. (put 'macrolet 's!:compfn (function s!:comspecform))
  1661. (put 'multiple!-value!-call 's!:compfn (function s!:comspecform))
  1662. (put 'multiple!-value!-prog1 's!:compfn (function s!:comspecform))
  1663. (put 'prog!* 's!:compfn (function s!:comspecform))
  1664. (put 'progv 's!:compfn (function s!:comspecform))
  1665. nil)))
  1666. (de s!:improve (u)
  1667. (prog (w)
  1668. (cond
  1669. ((atom u) (return u))
  1670. ((setq w (get (car u) 's!:tidy_fn)) (return (funcall w u)))
  1671. ((setq w (get (car u) 's!:newname))
  1672. (return (s!:improve (cons w (cdr u)))) )
  1673. (t (return u)))) )
  1674. (de s!:imp_minus (u)
  1675. (prog (a)
  1676. (setq a (s!:improve (cadr u)))
  1677. (return
  1678. (cond
  1679. ((numberp a) (minus a))
  1680. ((or (eqcar a 'minus) (eqcar a 'iminus)) (cadr a))
  1681. ((eqcar a 'difference)
  1682. (s!:improve (list 'difference (caddr a) (cadr a))))
  1683. ((eqcar a 'idifference)
  1684. (s!:improve (list 'idifference (caddr a) (cadr a))))
  1685. (t (list (car u) a)))) ))
  1686. (put 'minus 's!:tidy_fn 's!:imp_minus)
  1687. (put 'iminus 's!:tidy_fn 's!:imp_minus)
  1688. (de s!:imp_times (u)
  1689. (prog (a b)
  1690. (cond
  1691. ((not (equal (length u) 3))
  1692. (return
  1693. (cons
  1694. (car u)
  1695. (prog (v !G16 endptr)
  1696. (setq v (cdr u))
  1697. (cond ((null v) (return nil)))
  1698. (setq !G16
  1699. (setq endptr
  1700. (cons ((lambda (v) (s!:improve v)) (car v)) nil)))
  1701. looplabel
  1702. (setq v (cdr v))
  1703. (cond ((null v) (return !G16)))
  1704. (rplacd
  1705. endptr
  1706. (cons ((lambda (v) (s!:improve v)) (car v)) nil))
  1707. (setq endptr (cdr endptr))
  1708. (go looplabel)))) ))
  1709. (setq a (s!:improve (cadr u)))
  1710. (setq b (s!:improve (caddr u)))
  1711. (return
  1712. (cond
  1713. ((equal a 1) b)
  1714. ((equal b 1) a)
  1715. ((equal a (minus 1)) (s!:imp_minus (list 'minus b)))
  1716. ((equal b (minus 1)) (s!:imp_minus (list 'minus a)))
  1717. (t (list (car u) a b)))) ))
  1718. (put 'times 's!:tidy_fn 's!:imp_times)
  1719. (de s!:imp_itimes (u)
  1720. (prog (a b)
  1721. (cond
  1722. ((not (equal (length u) 3))
  1723. (return
  1724. (cons
  1725. (car u)
  1726. (prog (v !G17 endptr)
  1727. (setq v (cdr u))
  1728. (cond ((null v) (return nil)))
  1729. (setq !G17
  1730. (setq endptr
  1731. (cons ((lambda (v) (s!:improve v)) (car v)) nil)))
  1732. looplabel
  1733. (setq v (cdr v))
  1734. (cond ((null v) (return !G17)))
  1735. (rplacd
  1736. endptr
  1737. (cons ((lambda (v) (s!:improve v)) (car v)) nil))
  1738. (setq endptr (cdr endptr))
  1739. (go looplabel)))) ))
  1740. (setq a (s!:improve (cadr u)))
  1741. (setq b (s!:improve (caddr u)))
  1742. (return
  1743. (cond
  1744. ((equal a 1) b)
  1745. ((equal b 1) a)
  1746. ((equal a (minus 1)) (s!:imp_minus (list 'iminus b)))
  1747. ((equal b (minus 1)) (s!:imp_minus (list 'iminus a)))
  1748. (t (list (car u) a b)))) ))
  1749. (put 'itimes 's!:tidy_fn 's!:imp_itimes)
  1750. (de s!:imp_difference (u)
  1751. (prog (a b)
  1752. (setq a (s!:improve (cadr u)))
  1753. (setq b (s!:improve (caddr u)))
  1754. (return
  1755. (cond
  1756. ((equal a 0) (s!:imp_minus (list 'minus b)))
  1757. ((equal b 0) a)
  1758. (t (list (car u) a b)))) ))
  1759. (put 'difference 's!:tidy_fn 's!:imp_difference)
  1760. (de s!:imp_idifference (u)
  1761. (prog (a b)
  1762. (setq a (s!:improve (cadr u)))
  1763. (setq b (s!:improve (caddr u)))
  1764. (return
  1765. (cond
  1766. ((equal a 0) (s!:imp_minus (list 'iminus b)))
  1767. ((equal b 0) a)
  1768. (t (list (car u) a b)))) ))
  1769. (put 'idifference 's!:tidy_fn 's!:imp_idifference)
  1770. (de s!:alwayseasy (x) t)
  1771. (put 'quote 's!:helpeasy (function s!:alwayseasy))
  1772. (put 'function 's!:helpeasy (function s!:alwayseasy))
  1773. (de s!:easyifarg (x)
  1774. (or (null (cdr x)) (and (null (cddr x)) (s!:iseasy (cadr x)))) )
  1775. (put 'ncons 's!:helpeasy (function s!:easyifarg))
  1776. (put 'car 's!:helpeasy (function s!:easyifarg))
  1777. (put 'cdr 's!:helpeasy (function s!:easyifarg))
  1778. (put 'caar 's!:helpeasy (function s!:easyifarg))
  1779. (put 'cadr 's!:helpeasy (function s!:easyifarg))
  1780. (put 'cdar 's!:helpeasy (function s!:easyifarg))
  1781. (put 'cddr 's!:helpeasy (function s!:easyifarg))
  1782. (put 'caaar 's!:helpeasy (function s!:easyifarg))
  1783. (put 'caadr 's!:helpeasy (function s!:easyifarg))
  1784. (put 'cadar 's!:helpeasy (function s!:easyifarg))
  1785. (put 'caddr 's!:helpeasy (function s!:easyifarg))
  1786. (put 'cdaar 's!:helpeasy (function s!:easyifarg))
  1787. (put 'cdadr 's!:helpeasy (function s!:easyifarg))
  1788. (put 'cddar 's!:helpeasy (function s!:easyifarg))
  1789. (put 'cdddr 's!:helpeasy (function s!:easyifarg))
  1790. (put 'caaaar 's!:helpeasy (function s!:easyifarg))
  1791. (put 'caaadr 's!:helpeasy (function s!:easyifarg))
  1792. (put 'caadar 's!:helpeasy (function s!:easyifarg))
  1793. (put 'caaddr 's!:helpeasy (function s!:easyifarg))
  1794. (put 'cadaar 's!:helpeasy (function s!:easyifarg))
  1795. (put 'cadadr 's!:helpeasy (function s!:easyifarg))
  1796. (put 'caddar 's!:helpeasy (function s!:easyifarg))
  1797. (put 'cadddr 's!:helpeasy (function s!:easyifarg))
  1798. (put 'cdaaar 's!:helpeasy (function s!:easyifarg))
  1799. (put 'cdaadr 's!:helpeasy (function s!:easyifarg))
  1800. (put 'cdadar 's!:helpeasy (function s!:easyifarg))
  1801. (put 'cdaddr 's!:helpeasy (function s!:easyifarg))
  1802. (put 'cddaar 's!:helpeasy (function s!:easyifarg))
  1803. (put 'cddadr 's!:helpeasy (function s!:easyifarg))
  1804. (put 'cdddar 's!:helpeasy (function s!:easyifarg))
  1805. (put 'cddddr 's!:helpeasy (function s!:easyifarg))
  1806. (de s!:easygetv (x)
  1807. (prog (a2)
  1808. (setq a2 (caddr x))
  1809. (cond
  1810. ((and (null !*carcheckflag) (fixp a2) (geq a2 0) (lessp a2 256))
  1811. (return (s!:iseasy (cadr x))))
  1812. (t (return nil)))) )
  1813. (put 'getv 's!:helpeasy (function s!:easygetv))
  1814. (de s!:easyqgetv (x)
  1815. (prog (a2)
  1816. (setq a2 (caddr x))
  1817. (cond
  1818. ((and (fixp a2) (geq a2 0) (lessp a2 256))
  1819. (return (s!:iseasy (cadr x))))
  1820. (t (return nil)))) )
  1821. (put 'qgetv 's!:helpeasy (function s!:easyqgetv))
  1822. (de s!:iseasy (x)
  1823. (prog (h)
  1824. (cond ((atom x) (return t)))
  1825. (cond ((not (atom (car x))) (return nil)))
  1826. (cond
  1827. ((setq h (get (car x) 's!:helpeasy)) (return (funcall h x)))
  1828. (t (return nil)))) )
  1829. (de s!:instate_local_decs (v d w)
  1830. (prog (fg)
  1831. (cond ((fluidp v) (return w)))
  1832. (prog (z)
  1833. (setq z d)
  1834. lab (cond ((null z) (return nil)))
  1835. ((lambda (z)
  1836. (cond ((and (eqcar z 'special) (memq v (cdr z))) (setq fg t))))
  1837. (car z))
  1838. (setq z (cdr z))
  1839. (go lab))
  1840. (cond (fg (progn (make!-special v) (setq w (cons v w)))) )
  1841. (return w)))
  1842. (de s!:residual_local_decs (d w)
  1843. (prog nil
  1844. (prog (z)
  1845. (setq z d)
  1846. lab (cond ((null z) (return nil)))
  1847. ((lambda (z)
  1848. (cond
  1849. ((eqcar z 'special)
  1850. (prog (v)
  1851. (setq v (cdr z))
  1852. lab (cond ((null v) (return nil)))
  1853. ((lambda (v)
  1854. (cond
  1855. ((and (not (fluidp v)) (not (globalp v)))
  1856. (progn
  1857. (make!-special v)
  1858. (setq w (cons v w)))) ))
  1859. (car v))
  1860. (setq v (cdr v))
  1861. (go lab)))) )
  1862. (car z))
  1863. (setq z (cdr z))
  1864. (go lab))
  1865. (return w)))
  1866. (de s!:cancel_local_decs (w) (unfluid w))
  1867. (de s!:find_local_decs (body)
  1868. (prog (w local_decs)
  1869. (prog nil
  1870. !G18 (cond
  1871. ((not
  1872. (and
  1873. body
  1874. (or (eqcar (car body) 'declare) (stringp (car body)))) )
  1875. (return nil)))
  1876. (progn
  1877. (cond
  1878. ((stringp (car body)) (setq w (cons (car body) w)))
  1879. (t (setq local_decs (append local_decs (cdar body)))) )
  1880. (setq body (cdr body)))
  1881. (go !G18))
  1882. (prog nil
  1883. !G19 (cond ((not w) (return nil)))
  1884. (progn (setq body (cons (car w) body)) (setq w (cdr w)))
  1885. (go !G19))
  1886. (return (cons local_decs body))))
  1887. (de s!:comlambda (bvl body args env context)
  1888. (prog (s nbvl fluids fl1 w local_decs)
  1889. (setq nbvl (setq s (cdr env)))
  1890. (setq body (s!:find_local_decs body))
  1891. (setq local_decs (car body))
  1892. (setq body (cdr body))
  1893. (cond
  1894. ((atom body) (setq body nil))
  1895. ((atom (cdr body)) (setq body (car body)))
  1896. (t (setq body (cons 'progn body))))
  1897. (setq w nil)
  1898. (prog (v)
  1899. (setq v bvl)
  1900. lab (cond ((null v) (return nil)))
  1901. ((lambda (v) (setq w (s!:instate_local_decs v local_decs w)))
  1902. (car v))
  1903. (setq v (cdr v))
  1904. (go lab))
  1905. (prog (v)
  1906. (setq v bvl)
  1907. lab (cond ((null v) (return nil)))
  1908. ((lambda (v)
  1909. (progn
  1910. (cond
  1911. ((or (fluidp v) (globalp v))
  1912. (prog (g)
  1913. (setq g (gensym))
  1914. (setq nbvl (cons g nbvl))
  1915. (setq fl1 (cons v fl1))
  1916. (setq fluids (cons (cons v g) fluids))))
  1917. (t (setq nbvl (cons v nbvl))))
  1918. (cond
  1919. ((equal (car args) nil) (s!:outstack 1))
  1920. (t (progn
  1921. (s!:comval (car args) env 1)
  1922. (s!:outopcode0 'push '(push)))) )
  1923. (rplacd env (cons 0 (cdr env)))
  1924. (setq args (cdr args))))
  1925. (car v))
  1926. (setq v (cdr v))
  1927. (go lab))
  1928. (rplacd env nbvl)
  1929. (cond
  1930. (fluids
  1931. (progn
  1932. (setq fl1 (s!:vecof fl1))
  1933. (s!:outopcode1lit 'freebind fl1 env)
  1934. (prog (v)
  1935. (setq v (cons nil fluids))
  1936. lab (cond ((null v) (return nil)))
  1937. ((lambda (v) (rplacd env (cons 0 (cdr env)))) (car v))
  1938. (setq v (cdr v))
  1939. (go lab))
  1940. (rplacd env (cons (plus 2 (length fluids)) (cdr env)))
  1941. (prog (v)
  1942. (setq v fluids)
  1943. lab (cond ((null v) (return nil)))
  1944. ((lambda (v) (s!:comval (list 'setq (car v) (cdr v)) env 2))
  1945. (car v))
  1946. (setq v (cdr v))
  1947. (go lab)))) )
  1948. (setq w (s!:residual_local_decs local_decs w))
  1949. (s!:comval body env 1)
  1950. (s!:cancel_local_decs w)
  1951. (cond (fluids (s!:outopcode0 'freerstr '(freerstr))))
  1952. (s!:outlose (length bvl))
  1953. (rplacd env s)))
  1954. (de s!:loadliteral (x env)
  1955. (cond
  1956. ((member!*!* (list 'quote x) s!:a_reg_values) nil)
  1957. (t (progn
  1958. (cond
  1959. ((equal x nil) (s!:outopcode0 'vnil '(loadlit nil)))
  1960. (t (s!:outopcode1lit 'loadlit x env)))
  1961. (setq s!:a_reg_values (list (list 'quote x)))) )))
  1962. (de s!:comquote (x env context)
  1963. (cond ((leq context 1) (s!:loadliteral (cadr x) env))))
  1964. (put 'quote 's!:compfn (function s!:comquote))
  1965. (fluid '(s!:current_exitlab s!:current_proglabels s!:local_macros))
  1966. (de s!:comfunction (x env context)
  1967. (cond
  1968. ((leq context 1)
  1969. (progn
  1970. (setq x (cadr x))
  1971. (cond
  1972. ((eqcar x 'lambda)
  1973. (prog (g w s!:used_lexicals)
  1974. (setq s!:has_closure t)
  1975. (setq g (hashtagged!-name 'lambda (cdr x)))
  1976. (setq w
  1977. (s!:compile1
  1978. g
  1979. (cadr x)
  1980. (cddr x)
  1981. (cons
  1982. (list
  1983. (cdr env)
  1984. s!:current_exitlab
  1985. s!:current_proglabels
  1986. s!:local_macros)
  1987. s!:lexical_env)))
  1988. (cond
  1989. (s!:used_lexicals
  1990. (setq w
  1991. (s!:compile1
  1992. g
  1993. (cons (gensym) (cadr x))
  1994. (cddr x)
  1995. (cons
  1996. (list
  1997. (cdr env)
  1998. s!:current_exitlab
  1999. s!:current_proglabels
  2000. s!:local_macros)
  2001. s!:lexical_env)))) )
  2002. (setq s!:other_defs (append w s!:other_defs))
  2003. (s!:loadliteral g env)
  2004. (setq w (length (cdr env)))
  2005. (cond
  2006. (s!:used_lexicals
  2007. (progn
  2008. (setq s!:has_closure t)
  2009. (cond
  2010. ((greaterp w 4095)
  2011. (error "stack frame > 4095"))
  2012. ((greaterp w 255)
  2013. (s!:outopcode2
  2014. 'bigstack
  2015. (plus 128 (truncate w 256))
  2016. (logand w 255)
  2017. (list 'closure w)))
  2018. (t (s!:outopcode1 'closure w x)))) ))) )
  2019. (t (s!:loadliteral x env)))) )))
  2020. (put 'function 's!:compfn (function s!:comfunction))
  2021. (de s!:should_be_fluid (x)
  2022. (cond
  2023. ((not (or (fluidp x) (globalp x)))
  2024. (progn
  2025. (cond
  2026. (!*pwrds
  2027. (progn
  2028. (cond ((neq (posn) 0) (terpri)))
  2029. (princ "+++ ")
  2030. (prin x)
  2031. (princ " declared fluid")
  2032. (terpri))))
  2033. (fluid (list x))
  2034. nil))))
  2035. (de s!:find_lexical (x lex n)
  2036. (prog (p)
  2037. (cond ((null lex) (return nil)))
  2038. (setq p (memq x (caar lex)))
  2039. (cond
  2040. (p
  2041. (progn
  2042. (cond
  2043. ((not (memq x s!:used_lexicals))
  2044. (setq s!:used_lexicals (cons x s!:used_lexicals))))
  2045. (return (list n (length p)))) )
  2046. (t (return (s!:find_lexical x (cdr lex) (plus n 1)))) )))
  2047. (global '(s!:loadlocs))
  2048. (setq s!:loadlocs
  2049. (s!:vecof
  2050. '(loadloc0 loadloc1 loadloc2 loadloc3 loadloc4 loadloc5 loadloc6
  2051. loadloc7 loadloc8 loadloc9 loadloc10 loadloc11)))
  2052. (de s!:comatom (x env context)
  2053. (prog (n w)
  2054. (cond
  2055. ((greaterp context 1) (return nil))
  2056. ((or (null x) (not (symbolp x))) (return (s!:loadliteral x env))))
  2057. (setq n 0)
  2058. (setq w (cdr env))
  2059. (prog nil
  2060. !G20 (cond ((not (and w (not (eqcar w x)))) (return nil)))
  2061. (progn (setq n (add1 n)) (setq w (cdr w)))
  2062. (go !G20))
  2063. (cond
  2064. (w
  2065. (progn
  2066. (setq w (cons 'loc w))
  2067. (cond
  2068. ((member!*!* w s!:a_reg_values) (return nil))
  2069. (t (progn
  2070. (cond
  2071. ((lessp n 12)
  2072. (s!:outopcode0
  2073. (getv s!:loadlocs n)
  2074. (list 'loadloc x)))
  2075. ((greaterp n 4095) (error "stack frame > 4095"))
  2076. ((greaterp n 255)
  2077. (s!:outopcode2
  2078. 'bigstack
  2079. (truncate n 256)
  2080. (logand n 255)
  2081. (list 'loadloc x)))
  2082. (t (s!:outopcode1 'loadloc n x)))
  2083. (setq s!:a_reg_values (list w))
  2084. (return nil)))) )))
  2085. (cond
  2086. ((setq w (s!:find_lexical x s!:lexical_env 0))
  2087. (progn
  2088. (cond
  2089. ((member!*!* (cons 'lex w) s!:a_reg_values) (return nil)))
  2090. (s!:outlexref 'loadlex (length (cdr env)) (car w) (cadr w) x)
  2091. (setq s!:a_reg_values (list (cons 'lex w)))
  2092. (return nil))))
  2093. (s!:should_be_fluid x)
  2094. (cond ((flagp x 'constant!?) (return (s!:loadliteral (eval x) env))))
  2095. (setq w (cons 'free x))
  2096. (cond ((member!*!* w s!:a_reg_values) (return nil)))
  2097. (s!:outopcode1lit 'loadfree x env)
  2098. (setq s!:a_reg_values (list w))))
  2099. (flag '(t !$eol!$ !$eof!$) 'constant!?)
  2100. (de s!:islocal (x env)
  2101. (prog (n w)
  2102. (cond ((or (null x) (not (symbolp x)) (eq x t)) (return 99999)))
  2103. (setq n 0)
  2104. (setq w (cdr env))
  2105. (prog nil
  2106. !G21 (cond ((not (and w (not (eqcar w x)))) (return nil)))
  2107. (progn (setq n (add1 n)) (setq w (cdr w)))
  2108. (go !G21))
  2109. (cond (w (return n)) (t (return 99999)))) )
  2110. (de s!:load2 (a b env)
  2111. (progn
  2112. (cond
  2113. ((s!:iseasy b)
  2114. (prog (wa wb w)
  2115. (setq wa (s!:islocal a env))
  2116. (setq wb (s!:islocal b env))
  2117. (cond
  2118. ((and (lessp wa 4) (lessp wb 4))
  2119. (progn
  2120. (cond
  2121. ((and (equal wa 0) (equal wb 1))
  2122. (setq w 'loc0loc1))
  2123. ((and (equal wa 1) (equal wb 2))
  2124. (setq w 'loc1loc2))
  2125. ((and (equal wa 2) (equal wb 3))
  2126. (setq w 'loc2loc3))
  2127. ((and (equal wa 1) (equal wb 0))
  2128. (setq w 'loc1loc0))
  2129. ((and (equal wa 2) (equal wb 1))
  2130. (setq w 'loc2loc1))
  2131. ((and (equal wa 3) (equal wb 2))
  2132. (setq w 'loc3loc2)))
  2133. (cond
  2134. (w
  2135. (progn
  2136. (s!:outopcode0 w (list 'locloc a b))
  2137. (return nil)))) )))
  2138. (s!:comval a env 1)
  2139. (setq s!:a_reg_values nil)
  2140. (s!:comval b env 1)
  2141. (return nil)))
  2142. (!*ord
  2143. (progn
  2144. (s!:comval a env 1)
  2145. (s!:outopcode0 'push '(push))
  2146. (rplacd env (cons 0 (cdr env)))
  2147. (setq s!:a_reg_values nil)
  2148. (s!:comval b env 1)
  2149. (s!:outopcode0 'pop '(pop))
  2150. (rplacd env (cddr env))
  2151. t))
  2152. ((s!:iseasy a)
  2153. (progn
  2154. (s!:comval b env 1)
  2155. (setq s!:a_reg_values nil)
  2156. (s!:comval a env 1)
  2157. t))
  2158. (t (progn
  2159. (s!:comval b env 1)
  2160. (s!:outopcode0 'push '(push))
  2161. (rplacd env (cons 0 (cdr env)))
  2162. (setq s!:a_reg_values nil)
  2163. (s!:comval a env 1)
  2164. (s!:outopcode0 'pop '(pop))
  2165. (rplacd env (cddr env))
  2166. nil)))) )
  2167. (global '(s!:carlocs s!:cdrlocs s!:caarlocs))
  2168. (setq s!:carlocs
  2169. (s!:vecof
  2170. '(carloc0 carloc1 carloc2 carloc3 carloc4 carloc5 carloc6 carloc7
  2171. carloc8 carloc9 carloc10 carloc11)))
  2172. (setq s!:cdrlocs
  2173. (s!:vecof '(cdrloc0 cdrloc1 cdrloc2 cdrloc3 cdrloc4 cdrloc5)))
  2174. (setq s!:caarlocs (s!:vecof '(caarloc0 caarloc1 caarloc2 caarloc3)))
  2175. (flag '(plus2 times2 eq equal) 's!:symmetric)
  2176. (flag
  2177. '(car cdr caar cadr cdar cddr ncons add1 sub1 numberp length)
  2178. 's!:onearg)
  2179. (flag
  2180. '(cons xcons list2 get flagp plus2 difference times2 greaterp lessp apply1
  2181. eq equal getv qgetv eqcar)
  2182. 's!:twoarg)
  2183. (flag '(apply2 list2!* list3 acons) 's!:threearg)
  2184. (de s!:comcall (x env context)
  2185. (prog (fn args nargs op s w1 w2 w3 sw)
  2186. (setq fn (car x))
  2187. (setq args
  2188. (prog (v !G22 endptr)
  2189. (setq v (cdr x))
  2190. (cond ((null v) (return nil)))
  2191. (setq !G22
  2192. (setq endptr (cons ((lambda (v) (s!:improve v)) (car v)) nil)))
  2193. looplabel
  2194. (setq v (cdr v))
  2195. (cond ((null v) (return !G22)))
  2196. (rplacd endptr (cons ((lambda (v) (s!:improve v)) (car v)) nil))
  2197. (setq endptr (cdr endptr))
  2198. (go looplabel)))
  2199. (setq nargs (length args))
  2200. (cond
  2201. ((and (greaterp nargs 15) !*pwrds)
  2202. (progn
  2203. (cond ((neq (posn) 0) (terpri)))
  2204. (princ "+++ ")
  2205. (prin fn)
  2206. (princ " called with ")
  2207. (prin nargs)
  2208. (princ " from function ")
  2209. (prin s!:current_function)
  2210. (terpri))))
  2211. (setq s (cdr env))
  2212. (cond
  2213. ((equal nargs 0)
  2214. (cond
  2215. ((setq w2 (get fn 's!:builtin0))
  2216. (s!:outopcode1 'builtin0 w2 fn))
  2217. (t (s!:outopcode1lit 'call0 fn env))))
  2218. ((equal nargs 1)
  2219. (progn
  2220. (cond
  2221. ((and
  2222. (equal fn 'car)
  2223. (lessp (setq w2 (s!:islocal (car args) env)) 12))
  2224. (s!:outopcode0
  2225. (getv s!:carlocs w2)
  2226. (list 'carloc (car args))))
  2227. ((and
  2228. (equal fn 'cdr)
  2229. (lessp (setq w2 (s!:islocal (car args) env)) 6))
  2230. (s!:outopcode0
  2231. (getv s!:cdrlocs w2)
  2232. (list 'cdrloc (car args))))
  2233. ((and
  2234. (equal fn 'caar)
  2235. (lessp (setq w2 (s!:islocal (car args) env)) 4))
  2236. (s!:outopcode0
  2237. (getv s!:caarlocs w2)
  2238. (list 'caarloc (car args))))
  2239. (t (progn
  2240. (s!:comval (car args) env 1)
  2241. (cond
  2242. ((flagp fn 's!:onearg)
  2243. (s!:outopcode0 fn (list fn)))
  2244. ((setq w2 (get fn 's!:builtin1))
  2245. (s!:outopcode1 'builtin1 w2 fn))
  2246. (t (s!:outopcode1lit 'call1 fn env)))) ))) )
  2247. ((equal nargs 2)
  2248. (progn
  2249. (setq sw (s!:load2 (car args) (cadr args) env))
  2250. (cond ((flagp fn 's!:symmetric) (setq sw nil)))
  2251. (cond
  2252. ((flagp fn 's!:twoarg)
  2253. (progn
  2254. (cond (sw (s!:outopcode0 'swop '(swop))))
  2255. (s!:outopcode0 fn (list fn))))
  2256. (t (progn
  2257. (setq w3 (get fn 's!:builtin2))
  2258. (cond
  2259. (sw
  2260. (progn
  2261. (cond
  2262. (w3 (s!:outopcode1 'builtin2r w3 fn))
  2263. (t (s!:outopcode1lit 'call2r fn env)))) )
  2264. (w3 (s!:outopcode1 'builtin2 w3 fn))
  2265. (t (s!:outopcode1lit 'call2 fn env)))) ))) )
  2266. ((equal nargs 3)
  2267. (progn
  2268. (cond
  2269. ((equal (car args) nil) (s!:outstack 1))
  2270. (t (progn
  2271. (s!:comval (car args) env 1)
  2272. (s!:outopcode0 'push '(pusha3)))) )
  2273. (rplacd env (cons 0 (cdr env)))
  2274. (setq s!:a_reg_values nil)
  2275. (cond
  2276. ((s!:load2 (cadr args) (caddr args) env)
  2277. (s!:outopcode0 'swop '(swop))))
  2278. (cond
  2279. ((flagp fn 's!:threearg)
  2280. (s!:outopcode0
  2281. (cond ((equal fn 'list2!*) 'list2star) (t fn))
  2282. (list fn)))
  2283. ((setq w2 (get fn 's!:builtin3))
  2284. (s!:outopcode1 'builtin3 w2 fn))
  2285. (t (s!:outopcode1lit 'call3 fn env)))
  2286. (rplacd env (cddr env))))
  2287. (t (prog (largs)
  2288. (setq largs (reverse args))
  2289. (prog (a)
  2290. (setq a (reverse (cddr largs)))
  2291. lab (cond ((null a) (return nil)))
  2292. ((lambda (a)
  2293. (progn
  2294. (cond
  2295. ((null a) (s!:outstack 1))
  2296. (t (progn
  2297. (s!:comval a env 1)
  2298. (cond
  2299. ((equal nargs 4)
  2300. (s!:outopcode0 'push '(pusha4)))
  2301. (t (s!:outopcode0 'push '(pusharg)))) )))
  2302. (rplacd env (cons 0 (cdr env)))
  2303. (setq s!:a_reg_values nil)))
  2304. (car a))
  2305. (setq a (cdr a))
  2306. (go lab))
  2307. (cond
  2308. ((s!:load2 (cadr largs) (car largs) env)
  2309. (s!:outopcode0 'swop '(swop))))
  2310. (cond
  2311. ((and (equal fn 'apply3) (equal nargs 4))
  2312. (s!:outopcode0 'apply3 '(apply3)))
  2313. ((greaterp nargs 255)
  2314. (error "Over 255 args in a function call"))
  2315. (t (s!:outopcode2lit 'calln fn nargs (list nargs fn) env)))
  2316. (rplacd env s)))) ))
  2317. (de s!:ad_name (l)
  2318. (cond
  2319. ((equal (car l) 'a) (cond ((equal (cadr l) 'a) 'caar) (t 'cadr)))
  2320. ((equal (cadr l) 'a) 'cdar)
  2321. (t 'cddr)))
  2322. (de s!:comcarcdr3 (x env context)
  2323. (prog (name outer c1 c2)
  2324. (setq name (cdr (explode2 (car x))))
  2325. (setq x
  2326. (list
  2327. (s!:ad_name name)
  2328. (list (cond ((equal (caddr name) 'a) 'car) (t 'cdr)) (cadr x))))
  2329. (return (s!:comval x env context))))
  2330. (put 'caaar 's!:compfn (function s!:comcarcdr3))
  2331. (put 'caadr 's!:compfn (function s!:comcarcdr3))
  2332. (put 'cadar 's!:compfn (function s!:comcarcdr3))
  2333. (put 'caddr 's!:compfn (function s!:comcarcdr3))
  2334. (put 'cdaar 's!:compfn (function s!:comcarcdr3))
  2335. (put 'cdadr 's!:compfn (function s!:comcarcdr3))
  2336. (put 'cddar 's!:compfn (function s!:comcarcdr3))
  2337. (put 'cdddr 's!:compfn (function s!:comcarcdr3))
  2338. (de s!:comcarcdr4 (x env context)
  2339. (prog (name outer c1 c2)
  2340. (setq name (cdr (explode2 (car x))))
  2341. (setq x
  2342. (list (s!:ad_name name) (list (s!:ad_name (cddr name)) (cadr x))))
  2343. (return (s!:comval x env context))))
  2344. (put 'caaaar 's!:compfn (function s!:comcarcdr4))
  2345. (put 'caaadr 's!:compfn (function s!:comcarcdr4))
  2346. (put 'caadar 's!:compfn (function s!:comcarcdr4))
  2347. (put 'caaddr 's!:compfn (function s!:comcarcdr4))
  2348. (put 'cadaar 's!:compfn (function s!:comcarcdr4))
  2349. (put 'cadadr 's!:compfn (function s!:comcarcdr4))
  2350. (put 'caddar 's!:compfn (function s!:comcarcdr4))
  2351. (put 'cadddr 's!:compfn (function s!:comcarcdr4))
  2352. (put 'cdaaar 's!:compfn (function s!:comcarcdr4))
  2353. (put 'cdaadr 's!:compfn (function s!:comcarcdr4))
  2354. (put 'cdadar 's!:compfn (function s!:comcarcdr4))
  2355. (put 'cdaddr 's!:compfn (function s!:comcarcdr4))
  2356. (put 'cddaar 's!:compfn (function s!:comcarcdr4))
  2357. (put 'cddadr 's!:compfn (function s!:comcarcdr4))
  2358. (put 'cdddar 's!:compfn (function s!:comcarcdr4))
  2359. (put 'cddddr 's!:compfn (function s!:comcarcdr4))
  2360. (de s!:comgetv (x env context)
  2361. (cond
  2362. (!*carcheckflag (s!:comcall x env context))
  2363. (t (s!:comval (cons 'qgetv (cdr x)) env context))))
  2364. (put 'getv 's!:compfn (function s!:comgetv))
  2365. (de s!:comqgetv (x env context)
  2366. (cond
  2367. ((and (fixp (caddr x)) (geq (caddr x) 0) (lessp (caddr x) 256))
  2368. (progn
  2369. (s!:comval (cadr x) env 1)
  2370. (s!:outopcode1 'qgetvn (caddr x) (caddr x))))
  2371. (t (s!:comcall x env context))))
  2372. (put 'qgetv 's!:compfn (function s!:comqgetv))
  2373. (de s!:comget (x env context)
  2374. (prog (a b c w)
  2375. (setq a (cadr x))
  2376. (setq b (caddr x))
  2377. (setq c (cdddr x))
  2378. (cond
  2379. ((eqcar b 'quote)
  2380. (progn
  2381. (setq b (cadr b))
  2382. (setq w (symbol!-make!-fastget b nil))
  2383. (cond
  2384. (c
  2385. (progn
  2386. (cond
  2387. (w
  2388. (progn
  2389. (cond
  2390. ((s!:load2 a b env)
  2391. (s!:outopcode0 'swop '(swop))))
  2392. (s!:outopcode1 'fastget (logor w 64) b)))
  2393. (t (s!:comcall x env context)))) )
  2394. (t (progn
  2395. (s!:comval a env 1)
  2396. (cond
  2397. (w (s!:outopcode1 'fastget w b))
  2398. (t (s!:outopcode1lit 'litget b env)))) ))) )
  2399. (t (s!:comcall x env context)))) )
  2400. (put 'get 's!:compfn (function s!:comget))
  2401. (de s!:comflagp (x env context)
  2402. (prog (a b)
  2403. (setq a (cadr x))
  2404. (setq b (caddr x))
  2405. (cond
  2406. ((eqcar b 'quote)
  2407. (progn
  2408. (setq b (cadr b))
  2409. (s!:comval a env 1)
  2410. (setq a (symbol!-make!-fastget b nil))
  2411. (cond
  2412. (a (s!:outopcode1 'fastget (logor a 128) b))
  2413. (t (s!:comcall x env context)))) )
  2414. (t (s!:comcall x env context)))) )
  2415. (put 'flagp 's!:compfn (function s!:comflagp))
  2416. (de s!:complus (x env context)
  2417. (s!:comval (expand (cdr x) 'plus2) env context))
  2418. (put 'plus 's!:compfn (function s!:complus))
  2419. (de s!:comtimes (x env context)
  2420. (s!:comval (expand (cdr x) 'times2) env context))
  2421. (put 'times 's!:compfn (function s!:comtimes))
  2422. (de s!:comiplus (x env context)
  2423. (s!:comval (expand (cdr x) 'iplus2) env context))
  2424. (put 'iplus 's!:compfn (function s!:comiplus))
  2425. (de s!:comitimes (x env context)
  2426. (s!:comval (expand (cdr x) 'itimes2) env context))
  2427. (put 'itimes 's!:compfn (function s!:comitimes))
  2428. (de s!:complus2 (x env context)
  2429. (prog (a b)
  2430. (setq a (s!:improve (cadr x)))
  2431. (setq b (s!:improve (caddr x)))
  2432. (return
  2433. (cond
  2434. ((and (numberp a) (numberp b)) (s!:comval (plus a b) env context))
  2435. ((equal a 0) (s!:comval b env context))
  2436. ((equal a 1) (s!:comval (list 'add1 b) env context))
  2437. ((equal b 0) (s!:comval a env context))
  2438. ((equal b 1) (s!:comval (list 'add1 a) env context))
  2439. ((equal b (minus 1)) (s!:comval (list 'sub1 a) env context))
  2440. (t (s!:comcall x env context)))) ))
  2441. (put 'plus2 's!:compfn (function s!:complus2))
  2442. (de s!:comdifference (x env context)
  2443. (prog (a b)
  2444. (setq a (s!:improve (cadr x)))
  2445. (setq b (s!:improve (caddr x)))
  2446. (return
  2447. (cond
  2448. ((and (numberp a) (numberp b))
  2449. (s!:comval (difference a b) env context))
  2450. ((equal a 0) (s!:comval (list 'minus b) env context))
  2451. ((equal b 0) (s!:comval a env context))
  2452. ((equal b 1) (s!:comval (list 'sub1 a) env context))
  2453. ((equal b (minus 1)) (s!:comval (list 'add1 a) env context))
  2454. (t (s!:comcall x env context)))) ))
  2455. (put 'difference 's!:compfn (function s!:comdifference))
  2456. (de s!:comiplus2 (x env context)
  2457. (prog (a b)
  2458. (setq a (s!:improve (cadr x)))
  2459. (setq b (s!:improve (caddr x)))
  2460. (return
  2461. (cond
  2462. ((and (numberp a) (numberp b)) (s!:comval (plus a b) env context))
  2463. ((equal a 1) (s!:comval (list 'iadd1 b) env context))
  2464. ((equal b 1) (s!:comval (list 'iadd1 a) env context))
  2465. ((equal b (minus 1)) (s!:comval (list 'isub1 a) env context))
  2466. (t (s!:comcall x env context)))) ))
  2467. (put 'iplus2 's!:compfn (function s!:comiplus2))
  2468. (de s!:comidifference (x env context)
  2469. (prog (a b)
  2470. (setq a (s!:improve (cadr x)))
  2471. (setq b (s!:improve (caddr x)))
  2472. (return
  2473. (cond
  2474. ((and (numberp a) (numberp b))
  2475. (s!:comval (difference a b) env context))
  2476. ((equal b 1) (s!:comval (list 'isub1 a) env context))
  2477. ((equal b (minus 1)) (s!:comval (list 'iadd1 a) env context))
  2478. (t (s!:comcall x env context)))) ))
  2479. (put 'idifference 's!:compfn (function s!:comidifference))
  2480. (de s!:comtimes2 (x env context)
  2481. (prog (a b)
  2482. (setq a (s!:improve (cadr x)))
  2483. (setq b (s!:improve (caddr x)))
  2484. (return
  2485. (cond
  2486. ((and (numberp a) (numberp b))
  2487. (s!:comval (times a b) env context))
  2488. ((equal a 1) (s!:comval b env context))
  2489. ((equal a (minus 1)) (s!:comval (list 'minus b) env context))
  2490. ((equal b 1) (s!:comval a env context))
  2491. ((equal b (minus 1)) (s!:comval (list 'minus a) env context))
  2492. (t (s!:comcall x env context)))) ))
  2493. (put 'times2 's!:compfn (function s!:comtimes2))
  2494. (put 'itimes2 's!:compfn (function s!:comtimes2))
  2495. (de s!:comminus (x env context)
  2496. (prog (a b)
  2497. (setq a (s!:improve (cadr x)))
  2498. (return
  2499. (cond
  2500. ((numberp a) (s!:comval (minus a) env context))
  2501. ((eqcar a 'minus) (s!:comval (cadr a) env context))
  2502. (t (s!:comcall x env context)))) ))
  2503. (put 'minus 's!:compfn (function s!:comminus))
  2504. (de s!:comminusp (x env context)
  2505. (prog (a)
  2506. (setq a (s!:improve (cadr x)))
  2507. (cond
  2508. ((eqcar a 'difference)
  2509. (return (s!:comval (cons 'lessp (cdr a)) env context)))
  2510. (t (return (s!:comcall x env context)))) ))
  2511. (put 'minusp 's!:compfn (function s!:comminusp))
  2512. (de s!:comlessp (x env context)
  2513. (prog (a b)
  2514. (setq a (s!:improve (cadr x)))
  2515. (setq b (s!:improve (caddr x)))
  2516. (cond
  2517. ((equal b 0) (return (s!:comval (list 'minusp a) env context)))
  2518. (t (return (s!:comcall x env context)))) ))
  2519. (put 'lessp 's!:compfn (function s!:comlessp))
  2520. (de s!:comiminusp (x env context)
  2521. (prog (a)
  2522. (setq a (s!:improve (cadr x)))
  2523. (cond
  2524. ((eqcar a 'difference)
  2525. (return (s!:comval (cons 'ilessp (cdr a)) env context)))
  2526. (t (return (s!:comcall x env context)))) ))
  2527. (put 'iminusp 's!:compfn (function s!:comiminusp))
  2528. (de s!:comilessp (x env context)
  2529. (prog (a b)
  2530. (setq a (s!:improve (cadr x)))
  2531. (setq b (s!:improve (caddr x)))
  2532. (cond
  2533. ((equal b 0) (return (s!:comval (list 'iminusp a) env context)))
  2534. (t (return (s!:comcall x env context)))) ))
  2535. (put 'ilessp 's!:compfn (function s!:comilessp))
  2536. (de s!:comprogn (x env context)
  2537. (progn
  2538. (setq x (cdr x))
  2539. (cond
  2540. ((null x) (s!:comval nil env context))
  2541. (t (prog (a)
  2542. (setq a (car x))
  2543. (prog nil
  2544. !G23 (cond ((not (setq x (cdr x))) (return nil)))
  2545. (progn
  2546. (s!:comval a env (cond ((geq context 4) context) (t 2)))
  2547. (setq a (car x)))
  2548. (go !G23))
  2549. (s!:comval a env context)))) ))
  2550. (put 'progn 's!:compfn (function s!:comprogn))
  2551. (de s!:comprog1 (x env context)
  2552. (prog nil
  2553. (setq x (cdr x))
  2554. (cond ((null x) (return (s!:comval nil env context))))
  2555. (s!:comval (car x) env context)
  2556. (cond ((null (setq x (cdr x))) (return nil)))
  2557. (s!:outopcode0 'push '(push))
  2558. (rplacd env (cons 0 (cdr env)))
  2559. (prog (a)
  2560. (setq a x)
  2561. lab (cond ((null a) (return nil)))
  2562. ((lambda (a)
  2563. (s!:comval a env (cond ((geq context 4) context) (t 2))))
  2564. (car a))
  2565. (setq a (cdr a))
  2566. (go lab))
  2567. (s!:outopcode0 'pop '(pop))
  2568. (rplacd env (cddr env))))
  2569. (put 'prog1 's!:compfn (function s!:comprog1))
  2570. (de s!:comprog2 (x env context)
  2571. (prog (a)
  2572. (setq x (cdr x))
  2573. (cond ((null x) (return (s!:comval nil env context))))
  2574. (setq a (car x))
  2575. (s!:comval a env (cond ((geq context 4) context) (t 2)))
  2576. (s!:comprog1 x env context)))
  2577. (put 'prog2 's!:compfn (function s!:comprog2))
  2578. (de s!:outstack (n)
  2579. (prog (w a)
  2580. (setq w s!:current_block)
  2581. (prog nil
  2582. !G24 (cond ((not (and w (not (atom (car w)))) ) (return nil)))
  2583. (setq w (cdr w))
  2584. (go !G24))
  2585. (cond
  2586. ((eqcar w 'pushnil) (setq a 1))
  2587. ((eqcar w 'pushnil2) (setq a 2))
  2588. ((eqcar w 'pushnil3) (setq a 3))
  2589. ((and
  2590. w
  2591. (numberp (setq a (car w)))
  2592. (not (equal a 255))
  2593. (eqcar (cdr w) 'pushnils))
  2594. (progn
  2595. (setq w (cdr w))
  2596. (setq s!:current_size (difference s!:current_size 1))))
  2597. (t (setq a nil)))
  2598. (cond
  2599. (a
  2600. (progn
  2601. (setq s!:current_block (cdr w))
  2602. (setq s!:current_size (difference s!:current_size 1))
  2603. (setq n (plus n a)))) )
  2604. (cond
  2605. ((equal n 1) (s!:outopcode0 'pushnil '(pushnil)))
  2606. ((equal n 2) (s!:outopcode0 'pushnil2 '(pushnil2)))
  2607. ((equal n 3) (s!:outopcode0 'pushnil3 '(pushnil3)))
  2608. ((greaterp n 255)
  2609. (progn
  2610. (s!:outopcode1 'pushnils 255 255)
  2611. (s!:outstack (difference n 255))))
  2612. ((greaterp n 3) (s!:outopcode1 'pushnils n n)))) )
  2613. (de s!:outlose (n)
  2614. (prog (w a)
  2615. (setq w s!:current_block)
  2616. (prog nil
  2617. !G25 (cond ((not (and w (not (atom (car w)))) ) (return nil)))
  2618. (setq w (cdr w))
  2619. (go !G25))
  2620. (cond
  2621. ((eqcar w 'lose) (setq a 1))
  2622. ((eqcar w 'lose2) (setq a 2))
  2623. ((eqcar w 'lose3) (setq a 3))
  2624. ((and
  2625. w
  2626. (numberp (setq a (car w)))
  2627. (not (equal a 255))
  2628. (eqcar (cdr w) 'loses))
  2629. (progn
  2630. (setq w (cdr w))
  2631. (setq s!:current_size (difference s!:current_size 1))))
  2632. (t (setq a nil)))
  2633. (cond
  2634. (a
  2635. (progn
  2636. (setq s!:current_block (cdr w))
  2637. (setq s!:current_size (difference s!:current_size 1))
  2638. (setq n (plus n a)))) )
  2639. (cond
  2640. ((equal n 1) (s!:outopcode0 'lose '(lose)))
  2641. ((equal n 2) (s!:outopcode0 'lose2 '(lose2)))
  2642. ((equal n 3) (s!:outopcode0 'lose3 '(lose3)))
  2643. ((greaterp n 255)
  2644. (progn
  2645. (s!:outopcode1 'loses 255 255)
  2646. (s!:outlose (difference n 255))))
  2647. ((greaterp n 3) (s!:outopcode1 'loses n n)))) )
  2648. (de s!:comprog (x env context)
  2649. (prog (labs s bvl fluids n body local_decs w)
  2650. (setq body (s!:find_local_decs (cddr x)))
  2651. (setq local_decs (car body))
  2652. (setq body (cdr body))
  2653. (setq n 0)
  2654. (prog (v)
  2655. (setq v (cadr x))
  2656. lab (cond ((null v) (return nil)))
  2657. ((lambda (v) (setq w (s!:instate_local_decs v local_decs w)))
  2658. (car v))
  2659. (setq v (cdr v))
  2660. (go lab))
  2661. (prog (v)
  2662. (setq v (cadr x))
  2663. lab (cond ((null v) (return nil)))
  2664. ((lambda (v)
  2665. (progn
  2666. (cond
  2667. ((globalp v)
  2668. (progn
  2669. (cond
  2670. (!*pwrds
  2671. (progn
  2672. (cond ((neq (posn) 0) (terpri)))
  2673. (princ "+++++ global ")
  2674. (prin v)
  2675. (princ " converted to fluid")
  2676. (terpri))))
  2677. (unglobal (list v))
  2678. (fluid (list v)))) )
  2679. (cond
  2680. ((fluidp v) (setq fluids (cons v fluids)))
  2681. (t (progn (setq n (plus n 1)) (setq bvl (cons v bvl)))) )))
  2682. (car v))
  2683. (setq v (cdr v))
  2684. (go lab))
  2685. (setq s (cdr env))
  2686. (setq s!:current_exitlab
  2687. (cons (cons nil (cons (gensym) s)) s!:current_exitlab))
  2688. (s!:outstack n)
  2689. (rplacd env (append bvl (cdr env)))
  2690. (cond
  2691. (fluids
  2692. (prog (fl1)
  2693. (setq fl1 (s!:vecof fluids))
  2694. (s!:outopcode1lit 'freebind fl1 env)
  2695. (prog (v)
  2696. (setq v (cons nil fluids))
  2697. lab (cond ((null v) (return nil)))
  2698. ((lambda (v) (rplacd env (cons 0 (cdr env)))) (car v))
  2699. (setq v (cdr v))
  2700. (go lab))
  2701. (rplacd env (cons (plus 2 (length fluids)) (cdr env)))
  2702. (cond ((equal context 0) (setq context 1)))) ))
  2703. (prog (a)
  2704. (setq a (cddr x))
  2705. lab (cond ((null a) (return nil)))
  2706. ((lambda (a)
  2707. (cond
  2708. ((atom a)
  2709. (progn
  2710. (cond
  2711. ((atsoc a labs)
  2712. (progn
  2713. (cond
  2714. ((not (null a))
  2715. (progn
  2716. (cond ((neq (posn) 0) (terpri)))
  2717. (princ "+++++ label ")
  2718. (prin a)
  2719. (princ " multiply defined")
  2720. (terpri)))) ))
  2721. (t (setq labs
  2722. (cons
  2723. (cons
  2724. a
  2725. (cons (cons (gensym) (cdr env)) nil))
  2726. labs)))) ))) )
  2727. (car a))
  2728. (setq a (cdr a))
  2729. (go lab))
  2730. (setq s!:current_proglabels (cons labs s!:current_proglabels))
  2731. (setq w (s!:residual_local_decs local_decs w))
  2732. (prog (a)
  2733. (setq a (cddr x))
  2734. lab (cond ((null a) (return nil)))
  2735. ((lambda (a)
  2736. (cond
  2737. ((not (atom a)) (s!:comval a env (plus context 4)))
  2738. (t (prog (d)
  2739. (setq d (atsoc a labs))
  2740. (cond
  2741. ((null (cddr d))
  2742. (progn
  2743. (rplacd (cdr d) t)
  2744. (s!:set_label (caadr d)))) ))) ))
  2745. (car a))
  2746. (setq a (cdr a))
  2747. (go lab))
  2748. (s!:cancel_local_decs w)
  2749. (s!:comval nil env context)
  2750. (cond (fluids (s!:outopcode0 'freerstr '(freerstr))))
  2751. (s!:outlose n)
  2752. (rplacd env s)
  2753. (s!:set_label (cadar s!:current_exitlab))
  2754. (setq s!:current_exitlab (cdr s!:current_exitlab))
  2755. (setq s!:current_proglabels (cdr s!:current_proglabels))))
  2756. (put 'prog 's!:compfn (function s!:comprog))
  2757. (de s!:comtagbody (x env context)
  2758. (prog (labs)
  2759. (prog (a)
  2760. (setq a (cdr x))
  2761. lab (cond ((null a) (return nil)))
  2762. ((lambda (a)
  2763. (cond
  2764. ((atom a)
  2765. (progn
  2766. (cond
  2767. ((atsoc a labs)
  2768. (progn
  2769. (cond
  2770. ((not (null a))
  2771. (progn
  2772. (cond ((neq (posn) 0) (terpri)))
  2773. (princ "+++++ label ")
  2774. (prin a)
  2775. (princ " multiply defined")
  2776. (terpri)))) ))
  2777. (t (setq labs
  2778. (cons
  2779. (cons
  2780. a
  2781. (cons (cons (gensym) (cdr env)) nil))
  2782. labs)))) ))) )
  2783. (car a))
  2784. (setq a (cdr a))
  2785. (go lab))
  2786. (setq s!:current_proglabels (cons labs s!:current_proglabels))
  2787. (prog (a)
  2788. (setq a (cdr x))
  2789. lab (cond ((null a) (return nil)))
  2790. ((lambda (a)
  2791. (cond
  2792. ((not (atom a)) (s!:comval a env (plus context 4)))
  2793. (t (prog (d)
  2794. (setq d (atsoc a labs))
  2795. (cond
  2796. ((null (cddr d))
  2797. (progn
  2798. (rplacd (cdr d) t)
  2799. (s!:set_label (caadr d)))) ))) ))
  2800. (car a))
  2801. (setq a (cdr a))
  2802. (go lab))
  2803. (s!:comval nil env context)
  2804. (setq s!:current_proglabels (cdr s!:current_proglabels))))
  2805. (put 'tagbody 's!:compfn (function s!:comtagbody))
  2806. (de s!:comblock (x env context)
  2807. (prog nil
  2808. (setq s!:current_exitlab
  2809. (cons (cons (cadr x) (cons (gensym) (cdr env))) s!:current_exitlab))
  2810. (s!:comval (cons 'progn (cddr x)) env context)
  2811. (s!:set_label (cadar s!:current_exitlab))
  2812. (setq s!:current_exitlab (cdr s!:current_exitlab))))
  2813. (put '!~block 's!:compfn (function s!:comblock))
  2814. (de s!:comcatch (x env context)
  2815. (prog (g)
  2816. (setq g (gensym))
  2817. (s!:comval (cadr x) env 1)
  2818. (s!:outjump 'catch g)
  2819. (rplacd env (cons '(catch) (cons 0 (cons 0 (cdr env)))) )
  2820. (s!:comval (cons 'progn (cddr x)) env context)
  2821. (s!:outopcode0 'uncatch '(uncatch))
  2822. (rplacd env (cddddr env))
  2823. (s!:set_label g)))
  2824. (put 'catch 's!:compfn 's!:comcatch)
  2825. (de s!:comthrow (x env context)
  2826. (prog nil
  2827. (s!:comval (cadr x) env 1)
  2828. (s!:outopcode0 'push '(push))
  2829. (rplacd env (cons 0 (cdr env)))
  2830. (s!:comval (caddr x) env 1)
  2831. (s!:outopcode0 'throw '(throw))
  2832. (rplacd env (cddr env))))
  2833. (put 'throw 's!:compfn 's!:comthrow)
  2834. (de s!:comunwind!-protect (x env context)
  2835. (prog (g)
  2836. (setq g (gensym))
  2837. (s!:comval '(load!-spid) env 1)
  2838. (s!:outjump 'catch g)
  2839. (rplacd
  2840. env
  2841. (cons (list 'unwind!-protect (cddr x)) (cons 0 (cons 0 (cdr env)))) )
  2842. (s!:comval (cadr x) env context)
  2843. (s!:outopcode0 'protect '(protect))
  2844. (s!:set_label g)
  2845. (rplaca (cdr env) 0)
  2846. (s!:comval (cons 'progn (cddr x)) env context)
  2847. (s!:outopcode0 'unprotect '(unprotect))
  2848. (rplacd env (cddddr env))))
  2849. (put 'unwind!-protect 's!:compfn 's!:comunwind!-protect)
  2850. (de s!:comdeclare (x env context)
  2851. (prog nil
  2852. (cond
  2853. (!*pwrds
  2854. (progn (princ "+++ ") (prin x) (princ " ignored") (terpri)))) ))
  2855. (put 'declare 's!:compfn (function s!:comdeclare))
  2856. (de s!:expand_let (vl b)
  2857. (prog (vars vals)
  2858. (prog (v)
  2859. (setq v vl)
  2860. lab (cond ((null v) (return nil)))
  2861. ((lambda (v)
  2862. (cond
  2863. ((atom v)
  2864. (progn
  2865. (setq vars (cons v vars))
  2866. (setq vals (cons nil vals))))
  2867. ((atom (cdr v))
  2868. (progn
  2869. (setq vars (cons (car v) vars))
  2870. (setq vals (cons nil vals))))
  2871. (t (progn
  2872. (setq vars (cons (car v) vars))
  2873. (setq vals (cons (cadr v) vals)))) ))
  2874. (car v))
  2875. (setq v (cdr v))
  2876. (go lab))
  2877. (return (list (cons (cons 'lambda (cons vars b)) vals)))) )
  2878. (de s!:comlet (x env context)
  2879. (s!:comval (cons 'progn (s!:expand_let (cadr x) (cddr x))) env context))
  2880. (put '!~let 's!:compfn (function s!:comlet))
  2881. (de s!:expand_let!* (vl local_decs b)
  2882. (prog (r var val)
  2883. (setq r (cons (cons 'declare local_decs) b))
  2884. (prog (x)
  2885. (setq x (reverse vl))
  2886. lab (cond ((null x) (return nil)))
  2887. ((lambda (x)
  2888. (progn
  2889. (setq val nil)
  2890. (cond
  2891. ((atom x) (setq var x))
  2892. ((atom (cdr x)) (setq var (car x)))
  2893. (t (progn (setq var (car x)) (setq val (cadr x)))) )
  2894. (prog (z)
  2895. (setq z local_decs)
  2896. lab (cond ((null z) (return nil)))
  2897. ((lambda (z)
  2898. (cond
  2899. ((eqcar z 'special)
  2900. (cond
  2901. ((memq var (cdr z))
  2902. (setq r
  2903. (cons
  2904. (list 'declare (list 'special var))
  2905. r)))) )))
  2906. (car z))
  2907. (setq z (cdr z))
  2908. (go lab))
  2909. (setq r
  2910. (list (list (cons 'lambda (cons (list var) r)) val)))) )
  2911. (car x))
  2912. (setq x (cdr x))
  2913. (go lab))
  2914. (cond
  2915. ((eqcar (car r) 'declare)
  2916. (setq r (list (cons 'lambda (cons nil r)))) )
  2917. (t (setq r (cons 'progn r))))
  2918. (return r)))
  2919. (de s!:comlet!* (x env context)
  2920. (prog (b)
  2921. (setq b (s!:find_local_decs (cddr x)))
  2922. (return
  2923. (s!:comval (s!:expand_let!* (cadr x) (car b) (cdr b)) env context))))
  2924. (put 'let!* 's!:compfn (function s!:comlet!*))
  2925. (de s!:restore_stack (e1 e2)
  2926. (prog (n)
  2927. (setq n 0)
  2928. (prog nil
  2929. !G26 (cond ((not (not (equal e1 e2))) (return nil)))
  2930. (progn
  2931. (cond
  2932. ((null e1)
  2933. (error 0 "bad block nesting with GO or RETURN-FROM")))
  2934. (cond
  2935. ((and (numberp (car e1)) (greaterp (car e1) 2))
  2936. (progn
  2937. (cond ((not (zerop n)) (s!:outlose n)))
  2938. (setq n (car e1))
  2939. (s!:outopcode0 'freerstr '(freerstr))
  2940. (prog (i)
  2941. (setq i 1)
  2942. lab (cond ((minusp (difference n i)) (return nil)))
  2943. (setq e1 (cdr e1))
  2944. (setq i (plus2 i 1))
  2945. (go lab))
  2946. (setq n 0)))
  2947. ((equal (car e1) '(catch))
  2948. (progn
  2949. (cond ((not (zerop n)) (s!:outlose n)))
  2950. (s!:outopcode0 'uncatch '(uncatch))
  2951. (setq e1 (cdddr e1))
  2952. (setq n 0)))
  2953. ((eqcar (car e1) 'unwind!-protect)
  2954. (progn
  2955. (cond ((not (zerop n)) (s!:outlose n)))
  2956. (s!:outopcode0 'protect '(protect))
  2957. (s!:comval (cons 'progn (cadar e1)) e1 2)
  2958. (s!:outopcode0 'unprotect '(unprotect))
  2959. (setq e1 (cdddr e1))
  2960. (setq n 0)))
  2961. (t (progn (setq e1 (cdr e1)) (setq n (plus n 1)))) ))
  2962. (go !G26))
  2963. (cond ((not (zerop n)) (s!:outlose n)))) )
  2964. (de s!:comgo (x env context)
  2965. (prog (pl d)
  2966. (cond
  2967. ((lessp context 4)
  2968. (progn (princ "go not in program context") (terpri))))
  2969. (setq pl s!:current_proglabels)
  2970. (prog nil
  2971. !G27 (cond ((not (and pl (null d))) (return nil)))
  2972. (progn
  2973. (setq d (atsoc (cadr x) (car pl)))
  2974. (cond ((null d) (setq pl (cdr pl)))) )
  2975. (go !G27))
  2976. (cond
  2977. ((null d)
  2978. (progn
  2979. (cond ((neq (posn) 0) (terpri)))
  2980. (princ "+++++ label ")
  2981. (prin (cadr x))
  2982. (princ " not set")
  2983. (terpri)
  2984. (return nil))))
  2985. (setq d (cadr d))
  2986. (s!:restore_stack (cdr env) (cdr d))
  2987. (s!:outjump 'jump (car d))))
  2988. (put 'go 's!:compfn (function s!:comgo))
  2989. (de s!:comreturn!-from (x env context)
  2990. (prog (tag)
  2991. (cond
  2992. ((lessp context 4)
  2993. (progn
  2994. (princ "+++++ return or return-from not in prog context")
  2995. (terpri))))
  2996. (setq x (cdr x))
  2997. (setq tag (car x))
  2998. (cond ((cdr x) (setq x (cadr x))) (t (setq x nil)))
  2999. (s!:comval x env (difference context 4))
  3000. (setq x (atsoc tag s!:current_exitlab))
  3001. (cond ((null x) (error 0 (list "invalid return-from" tag))))
  3002. (setq x (cdr x))
  3003. (s!:restore_stack (cdr env) (cdr x))
  3004. (s!:outjump 'jump (car x))))
  3005. (put 'return!-from 's!:compfn (function s!:comreturn!-from))
  3006. (de s!:comreturn (x env context)
  3007. (s!:comreturn!-from (cons 'return!-from (cons nil (cdr x))) env context))
  3008. (put 'return 's!:compfn (function s!:comreturn))
  3009. (global '(s!:jumplts s!:jumplnils s!:jumpatoms s!:jumpnatoms))
  3010. (setq s!:jumplts (s!:vecof '(jumpl0t jumpl1t jumpl2t jumpl3t jumpl4t)))
  3011. (setq s!:jumplnils
  3012. (s!:vecof '(jumpl0nil jumpl1nil jumpl2nil jumpl3nil jumpl4nil)))
  3013. (setq s!:jumpatoms (s!:vecof '(jumpl0atom jumpl1atom jumpl2atom jumpl3atom)))
  3014. (setq s!:jumpnatoms
  3015. (s!:vecof '(jumpl0natom jumpl1natom jumpl2natom jumpl3natom)))
  3016. (de s!:jumpif (neg x env lab)
  3017. (prog (w w1 j)
  3018. top (cond
  3019. ((null x)
  3020. (progn (cond ((not neg) (s!:outjump 'jump lab))) (return nil)))
  3021. ((or
  3022. (eq x t)
  3023. (and (eqcar x 'quote) (cadr x))
  3024. (and (atom x) (not (symbolp x))))
  3025. (progn (cond (neg (s!:outjump 'jump lab))) (return nil)))
  3026. ((lessp (setq w (s!:islocal x env)) 5)
  3027. (return
  3028. (s!:outjump
  3029. (getv (cond (neg s!:jumplts) (t s!:jumplnils)) w)
  3030. lab)))
  3031. ((and (equal w 99999) (symbolp x))
  3032. (progn
  3033. (s!:should_be_fluid x)
  3034. (setq w (list (cond (neg 'jumpfreet) (t 'jumpfreenil)) x x))
  3035. (return (s!:record_literal_for_jump w env lab)))) )
  3036. (cond
  3037. ((and
  3038. (not (atom x))
  3039. (atom (car x))
  3040. (setq w (get (car x) 's!:testfn)))
  3041. (return (funcall w neg x env lab))))
  3042. (cond
  3043. ((not (atom x))
  3044. (progn
  3045. (setq w (s!:improve x))
  3046. (cond
  3047. ((or (atom w) (not (eqcar x (car w))))
  3048. (progn (setq x w) (go top))))
  3049. (cond
  3050. ((and
  3051. (setq w1 (get (car w) 's!:compilermacro))
  3052. (setq w1 (funcall w1 w env 1)))
  3053. (progn (setq x w1) (go top)))) )))
  3054. remacro
  3055. (cond
  3056. ((and (not (atom w)) (setq w1 (macro!-function (car w))))
  3057. (progn
  3058. (setq w (funcall w1 w))
  3059. (cond
  3060. ((or
  3061. (atom w)
  3062. (eqcar w 'quote)
  3063. (get (car w) 's!:testfn)
  3064. (get (car w) 's!:compilermacro))
  3065. (progn (setq x w) (go top))))
  3066. (go remacro))))
  3067. (s!:comval x env 1)
  3068. (setq w s!:current_block)
  3069. (prog nil
  3070. !G28 (cond ((not (and w (not (atom (car w)))) ) (return nil)))
  3071. (setq w (cdr w))
  3072. (go !G28))
  3073. (setq j '(jumpnil . jumpt))
  3074. (cond
  3075. (w
  3076. (progn
  3077. (setq w1 (car w))
  3078. (setq w (cdr w))
  3079. (cond
  3080. ((equal w1 'storeloc0)
  3081. (progn
  3082. (setq s!:current_block w)
  3083. (setq s!:current_size (difference s!:current_size 1))
  3084. (setq j '(jumpst0nil . jumpst0t))))
  3085. ((equal w1 'storeloc1)
  3086. (progn
  3087. (setq s!:current_block w)
  3088. (setq s!:current_size (difference s!:current_size 1))
  3089. (setq j '(jumpst1nil . jumpst1t))))
  3090. ((equal w1 'storeloc2)
  3091. (progn
  3092. (setq s!:current_block w)
  3093. (setq s!:current_size (difference s!:current_size 1))
  3094. (setq j '(jumpst2nil . jumpst2t))))
  3095. ((eqcar w 'builtin1)
  3096. (progn
  3097. (setq s!:current_block (cdr w))
  3098. (setq s!:current_size (difference s!:current_size 2))
  3099. (setq j
  3100. (cons (list 'jumpb1nil w1) (list 'jumpb1t w1)))) )
  3101. ((eqcar w 'builtin2)
  3102. (progn
  3103. (setq s!:current_block (cdr w))
  3104. (setq s!:current_size (difference s!:current_size 2))
  3105. (setq j
  3106. (cons
  3107. (list 'jumpb2nil w1)
  3108. (list 'jumpb2t w1)))) ))) ))
  3109. (return (s!:outjump (cond (neg (cdr j)) (t (car j))) lab))))
  3110. (de s!:testnot (neg x env lab) (s!:jumpif (not neg) (cadr x) env lab))
  3111. (put 'null 's!:testfn (function s!:testnot))
  3112. (put 'not 's!:testfn (function s!:testnot))
  3113. (de s!:testatom (neg x env lab)
  3114. (prog (w)
  3115. (cond
  3116. ((lessp (setq w (s!:islocal (cadr x) env)) 4)
  3117. (return
  3118. (s!:outjump
  3119. (getv (cond (neg s!:jumpatoms) (t s!:jumpnatoms)) w)
  3120. lab))))
  3121. (s!:comval (cadr x) env 1)
  3122. (cond
  3123. (neg (s!:outjump 'jumpatom lab))
  3124. (t (s!:outjump 'jumpnatom lab)))) )
  3125. (put 'atom 's!:testfn (function s!:testatom))
  3126. (de s!:testconsp (neg x env lab)
  3127. (prog (w)
  3128. (cond
  3129. ((lessp (setq w (s!:islocal (cadr x) env)) 4)
  3130. (return
  3131. (s!:outjump
  3132. (getv (cond (neg s!:jumpnatoms) (t s!:jumpatoms)) w)
  3133. lab))))
  3134. (s!:comval (cadr x) env 1)
  3135. (cond
  3136. (neg (s!:outjump 'jumpnatom lab))
  3137. (t (s!:outjump 'jumpatom lab)))) )
  3138. (put 'consp 's!:testfn (function s!:testconsp))
  3139. (de s!:comcond (x env context)
  3140. (prog (l1 l2 w)
  3141. (setq l1 (gensym))
  3142. (prog nil
  3143. !G29 (cond ((not (setq x (cdr x))) (return nil)))
  3144. (progn
  3145. (setq w (car x))
  3146. (cond
  3147. ((atom (cdr w))
  3148. (progn
  3149. (s!:comval (car w) env 1)
  3150. (s!:outjump 'jumpt l1)
  3151. (setq l2 nil)))
  3152. (t (progn
  3153. (cond
  3154. ((equal (car w) t) (setq l2 nil))
  3155. (t (progn
  3156. (setq l2 (gensym))
  3157. (s!:jumpif nil (car w) env l2))))
  3158. (setq w (cdr w))
  3159. (cond
  3160. ((null (cdr w)) (setq w (car w)))
  3161. (t (setq w (cons 'progn w))))
  3162. (s!:comval w env context)
  3163. (cond
  3164. (l2 (progn (s!:outjump 'jump l1) (s!:set_label l2)))
  3165. (t (setq x '(nil)))) ))) )
  3166. (go !G29))
  3167. (cond (l2 (s!:comval nil env context)))
  3168. (s!:set_label l1)))
  3169. (put 'cond 's!:compfn (function s!:comcond))
  3170. (de s!:comif (x env context)
  3171. (prog (l1 l2)
  3172. (setq l2 (gensym))
  3173. (s!:jumpif nil (cadr x) env l2)
  3174. (setq x (cddr x))
  3175. (s!:comval (car x) env context)
  3176. (setq x (cdr x))
  3177. (cond
  3178. ((or x (and (lessp context 2) (setq x '(nil))))
  3179. (progn
  3180. (setq l1 (gensym))
  3181. (s!:outjump 'jump l1)
  3182. (s!:set_label l2)
  3183. (s!:comval (car x) env context)
  3184. (s!:set_label l1)))
  3185. (t (s!:set_label l2)))) )
  3186. (put 'if 's!:compfn (function s!:comif))
  3187. (de s!:comwhen (x env context)
  3188. (prog (l2)
  3189. (setq l2 (gensym))
  3190. (cond
  3191. ((lessp context 2)
  3192. (progn (s!:comval (cadr x) env 1) (s!:outjump 'jumpnil l2)))
  3193. (t (s!:jumpif nil (cadr x) env l2)))
  3194. (s!:comval (cons 'progn (cddr x)) env context)
  3195. (s!:set_label l2)))
  3196. (put 'when 's!:compfn (function s!:comwhen))
  3197. (de s!:comunless (x env context)
  3198. (s!:comwhen (list!* 'when (list 'not (cadr x)) (cddr x)) env context))
  3199. (put 'unless 's!:compfn (function s!:comunless))
  3200. (de s!:comicase (x env context)
  3201. (prog (l1 labs labassoc w)
  3202. (setq x (cdr x))
  3203. (prog (v)
  3204. (setq v (cdr x))
  3205. lab (cond ((null v) (return nil)))
  3206. ((lambda (v)
  3207. (progn
  3208. (setq w (assoc!*!* v labassoc))
  3209. (cond
  3210. (w (setq l1 (cons (cdr w) l1)))
  3211. (t (progn
  3212. (setq l1 (gensym))
  3213. (setq labs (cons l1 labs))
  3214. (setq labassoc (cons (cons v l1) labassoc)))) )))
  3215. (car v))
  3216. (setq v (cdr v))
  3217. (go lab))
  3218. (s!:comval (car x) env 1)
  3219. (s!:outjump 'icase (reversip labs))
  3220. (setq l1 (gensym))
  3221. (prog (v)
  3222. (setq v labassoc)
  3223. lab (cond ((null v) (return nil)))
  3224. ((lambda (v)
  3225. (progn
  3226. (s!:set_label (cdr v))
  3227. (s!:comval (car v) env context)
  3228. (s!:outjump 'jump l1)))
  3229. (car v))
  3230. (setq v (cdr v))
  3231. (go lab))
  3232. (s!:set_label l1)))
  3233. (put 's!:icase 's!:compfn (function s!:comicase))
  3234. (put 'jumpliteq!* 's!:opcode (get 'jumpliteq 's!:opcode))
  3235. (put 'jumplitne!* 's!:opcode (get 'jumplitne 's!:opcode))
  3236. (de s!:jumpliteql (val lab env)
  3237. (prog (w)
  3238. (cond
  3239. ((or (idp val) (eq!-safe val))
  3240. (progn
  3241. (setq w (list 'jumpliteq!* val val))
  3242. (s!:record_literal_for_jump w env lab)))
  3243. (t (progn
  3244. (s!:outopcode0 'push '(push))
  3245. (s!:loadliteral val env)
  3246. (s!:outopcode1 'builtin2 (get 'eql 's!:builtin2) 'eql)
  3247. (s!:outjump 'jumpt lab)
  3248. (flag (list lab) 's!:jumpliteql)
  3249. (s!:outopcode0 'pop '(pop)))) )))
  3250. (de s!:casebranch (sw env dflt)
  3251. (prog (size w w1 r g)
  3252. (setq size (plus 4 (truncate (length sw) 2)))
  3253. (prog nil
  3254. !G30 (cond
  3255. ((not
  3256. (or
  3257. (equal (remainder size 2) 0)
  3258. (equal (remainder size 3) 0)
  3259. (equal (remainder size 5) 0)
  3260. (equal (remainder size 13) 0)))
  3261. (return nil)))
  3262. (setq size (plus size 1))
  3263. (go !G30))
  3264. (prog (p)
  3265. (setq p sw)
  3266. lab (cond ((null p) (return nil)))
  3267. ((lambda (p)
  3268. (progn
  3269. (setq w (remainder (eqlhash (car p)) size))
  3270. (setq w1 (assoc!*!* w r))
  3271. (cond
  3272. (w1 (rplacd (cdr w1) (cons p (cddr w1))))
  3273. (t (setq r (cons (list w (gensym) p) r)))) ))
  3274. (car p))
  3275. (setq p (cdr p))
  3276. (go lab))
  3277. (s!:outopcode0 'push '(push))
  3278. (rplacd env (cons 0 (cdr env)))
  3279. (s!:outopcode1lit 'call1 'eqlhash env)
  3280. (s!:loadliteral size env)
  3281. (setq g (gensym))
  3282. (s!:outopcode1 'builtin2 (get 'iremainder 's!:builtin2) 'iremainder)
  3283. (s!:outjump
  3284. 'icase
  3285. (cons
  3286. g
  3287. (prog (i !G31 endptr)
  3288. (setq i 0)
  3289. (cond
  3290. ((minusp (difference (difference size 1) i)) (return nil)))
  3291. (setq !G31
  3292. (setq endptr
  3293. (cons
  3294. (progn
  3295. (setq w (assoc!*!* i r))
  3296. (cond (w (cadr w)) (t g)))
  3297. nil)))
  3298. looplabel
  3299. (setq i (plus2 i 1))
  3300. (cond
  3301. ((minusp (difference (difference size 1) i)) (return !G31)))
  3302. (rplacd
  3303. endptr
  3304. (cons
  3305. (progn
  3306. (setq w (assoc!*!* i r))
  3307. (cond (w (cadr w)) (t g)))
  3308. nil))
  3309. (setq endptr (cdr endptr))
  3310. (go looplabel))))
  3311. (prog (p)
  3312. (setq p r)
  3313. lab (cond ((null p) (return nil)))
  3314. ((lambda (p)
  3315. (progn
  3316. (s!:set_label (cadr p))
  3317. (s!:outopcode0 'pop '(pop))
  3318. (prog (q)
  3319. (setq q (cddr p))
  3320. lab (cond ((null q) (return nil)))
  3321. ((lambda (q) (s!:jumpliteql (car q) (cdr q) env)) (car q))
  3322. (setq q (cdr q))
  3323. (go lab))
  3324. (s!:outjump 'jump dflt)))
  3325. (car p))
  3326. (setq p (cdr p))
  3327. (go lab))
  3328. (s!:set_label g)
  3329. (s!:outopcode0 'pop '(pop))
  3330. (s!:outjump 'jump dflt)
  3331. (rplacd env (cddr env))))
  3332. (de s!:comcase (x env context)
  3333. (prog (keyform blocks v w g dflt sw keys nonnum)
  3334. (setq x (cdr x))
  3335. (setq keyform (car x))
  3336. (prog (y)
  3337. (setq y (cdr x))
  3338. lab (cond ((null y) (return nil)))
  3339. (progn
  3340. (setq w (assoc!*!* (cdar y) blocks))
  3341. (cond
  3342. (w (setq g (cdr w)))
  3343. (t (progn
  3344. (setq g (gensym))
  3345. (setq blocks (cons (cons (cdar y) g) blocks)))) )
  3346. (setq w (caar y))
  3347. (cond
  3348. ((and (null (cdr y)) (or (equal w t) (equal w 'otherwise)))
  3349. (setq dflt g))
  3350. (t (progn
  3351. (cond ((atom w) (setq w (list w))))
  3352. (prog (n)
  3353. (setq n w)
  3354. lab (cond ((null n) (return nil)))
  3355. ((lambda (n)
  3356. (progn
  3357. (cond
  3358. ((or (idp n) (numberp n))
  3359. (progn
  3360. (cond
  3361. ((not (fixp n)) (setq nonnum t)))
  3362. (setq keys (cons n keys))
  3363. (setq sw (cons (cons n g) sw))))
  3364. (t (error
  3365. 0
  3366. (list "illegal case label" n)))) ))
  3367. (car n))
  3368. (setq n (cdr n))
  3369. (go lab)))) ))
  3370. (setq y (cdr y))
  3371. (go lab))
  3372. (cond
  3373. ((null dflt)
  3374. (progn
  3375. (cond
  3376. ((setq w (assoc!*!* nil blocks)) (setq dflt (cdr w)))
  3377. (t (setq blocks
  3378. (cons (cons nil (setq dflt (gensym))) blocks)))) )))
  3379. (cond
  3380. ((not nonnum)
  3381. (progn
  3382. (setq keys (sort keys (function lessp)))
  3383. (setq nonnum (car keys))
  3384. (setq g (lastcar keys))
  3385. (cond
  3386. ((lessp (difference g nonnum) (times 2 (length keys)))
  3387. (progn
  3388. (cond
  3389. ((not (equal nonnum 0))
  3390. (progn
  3391. (setq keyform
  3392. (list 'xdifference keyform nonnum))
  3393. (setq sw
  3394. (prog (y !G32 endptr)
  3395. (setq y sw)
  3396. (cond ((null y) (return nil)))
  3397. (setq !G32
  3398. (setq endptr
  3399. (cons
  3400. ((lambda (y)
  3401. (cons
  3402. (difference
  3403. (car y)
  3404. nonnum)
  3405. (cdr y)))
  3406. (car y))
  3407. nil)))
  3408. looplabel
  3409. (setq y (cdr y))
  3410. (cond ((null y) (return !G32)))
  3411. (rplacd
  3412. endptr
  3413. (cons
  3414. ((lambda (y)
  3415. (cons
  3416. (difference
  3417. (car y)
  3418. nonnum)
  3419. (cdr y)))
  3420. (car y))
  3421. nil))
  3422. (setq endptr (cdr endptr))
  3423. (go looplabel)))) ))
  3424. (s!:comval keyform env 1)
  3425. (setq w nil)
  3426. (prog (i)
  3427. (setq i 0)
  3428. lab (cond ((minusp (difference g i)) (return nil)))
  3429. (cond
  3430. ((setq v (assoc!*!* i sw))
  3431. (setq w (cons (cdr v) w)))
  3432. (t (setq w (cons dflt w))))
  3433. (setq i (plus2 i 1))
  3434. (go lab))
  3435. (setq w (cons dflt (reversip w)))
  3436. (s!:outjump 'icase w)
  3437. (setq nonnum nil)))
  3438. (t (setq nonnum t)))) ))
  3439. (cond
  3440. (nonnum
  3441. (progn
  3442. (s!:comval keyform env 1)
  3443. (cond
  3444. ((lessp (length sw) 7)
  3445. (progn
  3446. (prog (y)
  3447. (setq y sw)
  3448. lab (cond ((null y) (return nil)))
  3449. ((lambda (y) (s!:jumpliteql (car y) (cdr y) env))
  3450. (car y))
  3451. (setq y (cdr y))
  3452. (go lab))
  3453. (s!:outjump 'jump dflt)))
  3454. (t (s!:casebranch sw env dflt)))) ))
  3455. (setq g (gensym))
  3456. (prog (v)
  3457. (setq v blocks)
  3458. lab (cond ((null v) (return nil)))
  3459. ((lambda (v)
  3460. (progn
  3461. (s!:set_label (cdr v))
  3462. (cond ((flagp (cdr v) 's!:jumpliteql) (s!:outlose 1)))
  3463. (s!:comval (cons 'progn (car v)) env context)
  3464. (s!:outjump 'jump g)))
  3465. (car v))
  3466. (setq v (cdr v))
  3467. (go lab))
  3468. (s!:set_label g)))
  3469. (put 'case 's!:compfn (function s!:comcase))
  3470. (fluid '(!*defn dfprint!* s!:dfprintsave s!:faslmod_name))
  3471. (de s!:comeval!-when (x env context)
  3472. (prog (y)
  3473. (setq x (cdr x))
  3474. (setq y (car x))
  3475. (setq x (cons 'progn (cdr x)))
  3476. (cond ((memq 'compile y) (eval x)))
  3477. (cond ((memq 'load y) (progn (cond (dfprint!* (apply1 dfprint!* x)))) ))
  3478. (cond
  3479. ((memq 'eval y) (s!:comval x env context))
  3480. (t (s!:comval nil env context)))) )
  3481. (put 'eval!-when 's!:compfn (function s!:comeval!-when))
  3482. (de s!:comthe (x env context) (s!:comval (caddr x) env context))
  3483. (put 'the 's!:compfn (function s!:comthe))
  3484. (de s!:comand (x env context)
  3485. (prog (l)
  3486. (setq l (gensym))
  3487. (setq x (cdr x))
  3488. (s!:comval (car x) env 1)
  3489. (prog nil
  3490. !G33 (cond ((not (setq x (cdr x))) (return nil)))
  3491. (progn (s!:outjump 'jumpnil l) (s!:comval (car x) env 1))
  3492. (go !G33))
  3493. (s!:set_label l)))
  3494. (put 'and 's!:compfn (function s!:comand))
  3495. (de s!:comor (x env context)
  3496. (prog (l)
  3497. (setq l (gensym))
  3498. (setq x (cdr x))
  3499. (s!:comval (car x) env 1)
  3500. (prog nil
  3501. !G34 (cond ((not (setq x (cdr x))) (return nil)))
  3502. (progn (s!:outjump 'jumpt l) (s!:comval (car x) env 1))
  3503. (go !G34))
  3504. (s!:set_label l)))
  3505. (put 'or 's!:compfn (function s!:comor))
  3506. (de s!:combool (neg x env lab)
  3507. (prog (fn)
  3508. (setq fn (eqcar x 'or))
  3509. (cond
  3510. ((eq fn neg)
  3511. (prog nil
  3512. !G35 (cond ((not (setq x (cdr x))) (return nil)))
  3513. (s!:jumpif fn (car x) env lab)
  3514. (go !G35)))
  3515. (t (progn
  3516. (setq neg (gensym))
  3517. (prog nil
  3518. !G36 (cond ((not (setq x (cdr x))) (return nil)))
  3519. (s!:jumpif fn (car x) env neg)
  3520. (go !G36))
  3521. (s!:outjump 'jump lab)
  3522. (s!:set_label neg)))) ))
  3523. (put 'and 's!:testfn (function s!:combool))
  3524. (put 'or 's!:testfn (function s!:combool))
  3525. (de s!:testeq (neg x env lab)
  3526. (prog (a b)
  3527. (setq a (s!:improve (cadr x)))
  3528. (setq b (s!:improve (caddr x)))
  3529. (cond
  3530. ((or (s!:eval_to_eq_unsafe a) (s!:eval_to_eq_unsafe b))
  3531. (progn
  3532. (cond ((neq (posn) 0) (terpri)))
  3533. (princ "++++ EQ on number upgraded to EQUAL in ")
  3534. (prin s!:current_function)
  3535. (princ " : ")
  3536. (prin a)
  3537. (princ " ")
  3538. (print b)
  3539. (return (s!:testequal neg (cons 'equal (cdr x)) env lab)))) )
  3540. (cond
  3541. (!*carefuleq
  3542. (progn
  3543. (s!:comval x env 1)
  3544. (s!:outjump (cond (neg 'jumpt) (t 'jumpnil)) lab)
  3545. (return nil))))
  3546. (cond
  3547. ((null a) (s!:jumpif (not neg) b env lab))
  3548. ((null b) (s!:jumpif (not neg) a env lab))
  3549. ((or (eqcar a 'quote) (and (atom a) (not (symbolp a))))
  3550. (progn
  3551. (s!:comval b env 1)
  3552. (cond ((eqcar a 'quote) (setq a (cadr a))))
  3553. (setq b (list (cond (neg 'jumpliteq) (t 'jumplitne)) a a))
  3554. (s!:record_literal_for_jump b env lab)))
  3555. ((or (eqcar b 'quote) (and (atom b) (not (symbolp b))))
  3556. (progn
  3557. (s!:comval a env 1)
  3558. (cond ((eqcar b 'quote) (setq b (cadr b))))
  3559. (setq a (list (cond (neg 'jumpliteq) (t 'jumplitne)) b b))
  3560. (s!:record_literal_for_jump a env lab)))
  3561. (t (progn
  3562. (s!:load2 a b env)
  3563. (cond
  3564. (neg (s!:outjump 'jumpeq lab))
  3565. (t (s!:outjump 'jumpne lab)))) ))) )
  3566. (de s!:testeq1 (neg x env lab)
  3567. (prog (a b)
  3568. (cond
  3569. (!*carefuleq
  3570. (progn
  3571. (s!:comval x env 1)
  3572. (s!:outjump (cond (neg 'jumpt) (t 'jumpnil)) lab)
  3573. (return nil))))
  3574. (setq a (s!:improve (cadr x)))
  3575. (setq b (s!:improve (caddr x)))
  3576. (cond
  3577. ((null a) (s!:jumpif (not neg) b env lab))
  3578. ((null b) (s!:jumpif (not neg) a env lab))
  3579. ((or (eqcar a 'quote) (and (atom a) (not (symbolp a))))
  3580. (progn
  3581. (s!:comval b env 1)
  3582. (cond ((eqcar a 'quote) (setq a (cadr a))))
  3583. (setq b (list (cond (neg 'jumpliteq) (t 'jumplitne)) a a))
  3584. (s!:record_literal_for_jump b env lab)))
  3585. ((or (eqcar b 'quote) (and (atom b) (not (symbolp b))))
  3586. (progn
  3587. (s!:comval a env 1)
  3588. (cond ((eqcar b 'quote) (setq b (cadr b))))
  3589. (setq a (list (cond (neg 'jumpliteq) (t 'jumplitne)) b b))
  3590. (s!:record_literal_for_jump a env lab)))
  3591. (t (progn
  3592. (s!:load2 a b env)
  3593. (cond
  3594. (neg (s!:outjump 'jumpeq lab))
  3595. (t (s!:outjump 'jumpne lab)))) ))) )
  3596. (put 'eq 's!:testfn (function s!:testeq))
  3597. (cond
  3598. ((eq!-safe 0) (put 'iequal 's!:testfn (function s!:testeq1)))
  3599. (t (put 'iequal 's!:testfn (function s!:testequal))))
  3600. (de s!:testequal (neg x env lab)
  3601. (prog (a b)
  3602. (setq a (cadr x))
  3603. (setq b (caddr x))
  3604. (cond
  3605. ((null a) (s!:jumpif (not neg) b env lab))
  3606. ((null b) (s!:jumpif (not neg) a env lab))
  3607. ((or
  3608. (and
  3609. (eqcar a 'quote)
  3610. (or (symbolp (cadr a)) (eq!-safe (cadr a))))
  3611. (and
  3612. (eqcar b 'quote)
  3613. (or (symbolp (cadr b)) (eq!-safe (cadr b))))
  3614. (eq!-safe a)
  3615. (eq!-safe b))
  3616. (s!:testeq1 neg (cons 'eq (cdr x)) env lab))
  3617. (t (progn
  3618. (s!:load2 a b env)
  3619. (cond
  3620. (neg (s!:outjump 'jumpequal lab))
  3621. (t (s!:outjump 'jumpnequal lab)))) ))) )
  3622. (put 'equal 's!:testfn (function s!:testequal))
  3623. (de s!:testneq (neg x env lab)
  3624. (s!:testequal (not neg) (cons 'equal (cdr x)) env lab))
  3625. (put 'neq 's!:testfn (function s!:testneq))
  3626. (de s!:testeqcar (neg x env lab)
  3627. (prog (a b sw promote)
  3628. (setq a (cadr x))
  3629. (setq b (s!:improve (caddr x)))
  3630. (cond
  3631. ((s!:eval_to_eq_unsafe b)
  3632. (progn
  3633. (cond ((neq (posn) 0) (terpri)))
  3634. (princ "++++ EQCAR on number upgraded to EQUALCAR in ")
  3635. (prin s!:current_function)
  3636. (princ " : ")
  3637. (print b)
  3638. (setq promote t)))
  3639. (!*carefuleq
  3640. (progn
  3641. (s!:comval x env 1)
  3642. (s!:outjump (cond (neg 'jumpt) (t 'jumpnil)) lab)
  3643. (return nil))))
  3644. (cond
  3645. ((and (not promote) (eqcar b 'quote))
  3646. (progn
  3647. (s!:comval a env 1)
  3648. (setq b (cadr b))
  3649. (setq a (list (cond (neg 'jumpeqcar) (t 'jumpneqcar)) b b))
  3650. (s!:record_literal_for_jump a env lab)))
  3651. (t (progn
  3652. (setq sw (s!:load2 a b env))
  3653. (cond (sw (s!:outopcode0 'swop '(swop))))
  3654. (cond
  3655. (promote
  3656. (s!:outopcode1
  3657. 'builtin2
  3658. (get 'equalcar 's!:builtin2)
  3659. 'equalcar))
  3660. (t (s!:outopcode0 'eqcar '(eqcar))))
  3661. (s!:outjump (cond (neg 'jumpt) (t 'jumpnil)) lab)))) ))
  3662. (put 'eqcar 's!:testfn (function s!:testeqcar))
  3663. (de s!:testflagp (neg x env lab)
  3664. (prog (a b sw)
  3665. (setq a (cadr x))
  3666. (setq b (caddr x))
  3667. (cond
  3668. ((eqcar b 'quote)
  3669. (progn
  3670. (s!:comval a env 1)
  3671. (setq b (cadr b))
  3672. (setq sw (symbol!-make!-fastget b nil))
  3673. (cond
  3674. (sw
  3675. (progn
  3676. (s!:outopcode1 'fastget (logor sw 128) b)
  3677. (s!:outjump (cond (neg 'jumpt) (t 'jumpnil)) lab)))
  3678. (t (progn
  3679. (setq a
  3680. (list (cond (neg 'jumpflagp) (t 'jumpnflagp)) b b))
  3681. (s!:record_literal_for_jump a env lab)))) ))
  3682. (t (progn
  3683. (setq sw (s!:load2 a b env))
  3684. (cond (sw (s!:outopcode0 'swop '(swop))))
  3685. (s!:outopcode0 'flagp '(flagp))
  3686. (s!:outjump (cond (neg 'jumpt) (t 'jumpnil)) lab)))) ))
  3687. (put 'flagp 's!:testfn (function s!:testflagp))
  3688. (global '(s!:storelocs))
  3689. (setq s!:storelocs
  3690. (s!:vecof
  3691. '(storeloc0 storeloc1 storeloc2 storeloc3 storeloc4 storeloc5 storeloc6
  3692. storeloc7)))
  3693. (de s!:comsetq (x env context)
  3694. (prog (n w var)
  3695. (setq x (cdr x))
  3696. (cond ((null x) (return nil)))
  3697. (cond
  3698. ((or (not (symbolp (car x))) (null (cdr x)))
  3699. (return (error 0 (list "bad args for setq" x)))) )
  3700. (s!:comval (cadr x) env 1)
  3701. (setq var (car x))
  3702. (setq n 0)
  3703. (setq w (cdr env))
  3704. (prog nil
  3705. !G37 (cond ((not (and w (not (eqcar w var)))) (return nil)))
  3706. (progn (setq n (add1 n)) (setq w (cdr w)))
  3707. (go !G37))
  3708. (cond
  3709. (w
  3710. (progn
  3711. (cond
  3712. ((not (member!*!* (cons 'loc w) s!:a_reg_values))
  3713. (setq s!:a_reg_values
  3714. (cons (cons 'loc w) s!:a_reg_values))))
  3715. (cond
  3716. ((lessp n 8)
  3717. (s!:outopcode0
  3718. (getv s!:storelocs n)
  3719. (list 'storeloc var)))
  3720. ((greaterp n 4095) (error "stack frame > 4095"))
  3721. ((greaterp n 255)
  3722. (s!:outopcode2
  3723. 'bigstack
  3724. (plus 64 (truncate n 256))
  3725. (logand n 255)
  3726. (list 'storeloc var)))
  3727. (t (s!:outopcode1 'storeloc n var)))) )
  3728. ((setq w (s!:find_lexical var s!:lexical_env 0))
  3729. (progn
  3730. (cond
  3731. ((not (member!*!* (cons 'lex w) s!:a_reg_values))
  3732. (setq s!:a_reg_values
  3733. (cons (cons 'lex w) s!:a_reg_values))))
  3734. (s!:outlexref 'storelex (length (cdr env)) (car w) (cadr w)
  3735. var)))
  3736. (t (progn
  3737. (cond
  3738. ((or (null var) (eq var t))
  3739. (error 0 (list "bad variable in setq" var)))
  3740. (t (s!:should_be_fluid var)))
  3741. (setq w (cons 'free var))
  3742. (cond
  3743. ((not (member!*!* w s!:a_reg_values))
  3744. (setq s!:a_reg_values (cons w s!:a_reg_values))))
  3745. (s!:outopcode1lit 'storefree var env))))
  3746. (cond ((cddr x) (return (s!:comsetq (cdr x) env context)))) ))
  3747. (put 'setq 's!:compfn (function s!:comsetq))
  3748. (put 'noisy!-setq 's!:compfn (function s!:comsetq))
  3749. (de s!:comlist (x env context)
  3750. (prog (w)
  3751. (cond ((null (setq x (cdr x))) (return (s!:comval nil env context))))
  3752. (setq s!:a_reg_values nil)
  3753. (cond
  3754. ((null (setq w (cdr x)))
  3755. (s!:comval (list 'ncons (car x)) env context))
  3756. ((null (setq w (cdr w)))
  3757. (s!:comval (list 'list2 (car x) (cadr x)) env context))
  3758. ((null (cdr w))
  3759. (s!:comval (list 'list3 (car x) (cadr x) (car w)) env context))
  3760. (t (s!:comval
  3761. (list 'list2!* (car x) (cadr x) (cons 'list w))
  3762. env
  3763. context)))) )
  3764. (put 'list 's!:compfn (function s!:comlist))
  3765. (de s!:comlist!* (x env context)
  3766. (prog (w)
  3767. (cond ((null (setq x (cdr x))) (return (s!:comval nil env context))))
  3768. (setq s!:a_reg_values nil)
  3769. (cond
  3770. ((null (setq w (cdr x))) (s!:comval (car x) env context))
  3771. ((null (setq w (cdr w)))
  3772. (s!:comval (list 'cons (car x) (cadr x)) env context))
  3773. ((null (cdr w))
  3774. (s!:comval (list 'list2!* (car x) (cadr x) (car w)) env context))
  3775. (t (s!:comval
  3776. (list 'list2!* (car x) (cadr x) (cons 'list!* w))
  3777. env
  3778. context)))) )
  3779. (put 'list!* 's!:compfn (function s!:comlist!*))
  3780. (de s!:comcons (x env context)
  3781. (prog (a b)
  3782. (setq a (cadr x))
  3783. (setq b (caddr x))
  3784. (cond
  3785. ((or (equal b nil) (equal b ''nil))
  3786. (s!:comval (list 'ncons a) env context))
  3787. ((eqcar a 'cons)
  3788. (s!:comval (list 'acons (cadr a) (caddr a) b) env context))
  3789. ((eqcar b 'cons)
  3790. (cond
  3791. ((null (caddr b))
  3792. (s!:comval (list 'list2 a (cadr b)) env context))
  3793. (t (s!:comval
  3794. (list 'list2!* a (cadr b) (caddr b))
  3795. env
  3796. context))))
  3797. ((and (not !*ord) (s!:iseasy a) (not (s!:iseasy b)))
  3798. (s!:comval (list 'xcons b a) env context))
  3799. (t (s!:comcall x env context)))) )
  3800. (put 'cons 's!:compfn (function s!:comcons))
  3801. (de s!:comapply (x env context)
  3802. (prog (a b n)
  3803. (setq a (cadr x))
  3804. (setq b (caddr x))
  3805. (cond
  3806. ((and (null (cdddr x)) (eqcar b 'list))
  3807. (progn
  3808. (cond
  3809. ((eqcar a 'quote)
  3810. (return
  3811. (progn
  3812. (setq n s!:current_function)
  3813. (prog (s!:current_function)
  3814. (setq s!:current_function
  3815. (compress
  3816. (append
  3817. (explode n)
  3818. (cons
  3819. '!!
  3820. (cons
  3821. '!.
  3822. (explodec
  3823. (setq s!:current_count
  3824. (plus
  3825. s!:current_count
  3826. 1)))) ))) )
  3827. (return
  3828. (s!:comval
  3829. (cons (cadr a) (cdr b))
  3830. env
  3831. context)))) )))
  3832. (setq n (length (setq b (cdr b))))
  3833. (return (s!:comval (cons 'funcall (cons a b)) env context))))
  3834. ((and (null b) (null (cdddr x)))
  3835. (return (s!:comval (list 'funcall a) env context)))
  3836. (t (return (s!:comcall x env context)))) ))
  3837. (put 'apply 's!:compfn (function s!:comapply))
  3838. (de s!:imp_funcall (u)
  3839. (prog (n)
  3840. (setq u (cdr u))
  3841. (cond
  3842. ((eqcar (car u) 'function)
  3843. (return (s!:improve (cons (cadar u) (cdr u)))) ))
  3844. (setq n (length (cdr u)))
  3845. (setq u
  3846. (cond
  3847. ((equal n 0) (cons 'apply0 u))
  3848. ((equal n 1) (cons 'apply1 u))
  3849. ((equal n 2) (cons 'apply2 u))
  3850. ((equal n 3) (cons 'apply3 u))
  3851. (t (cons 'funcall!* u))))
  3852. (return u)))
  3853. (put 'funcall 's!:tidy_fn 's!:imp_funcall)
  3854. (de s!:eval_to_eq_safe (x)
  3855. (or
  3856. (null x)
  3857. (equal x t)
  3858. (and (not (symbolp x)) (eq!-safe x))
  3859. (and (not (atom x)) (flagp (car x) 'eq!-safe))
  3860. (and (eqcar x 'quote) (or (symbolp (cadr x)) (eq!-safe (cadr x)))) ))
  3861. (de s!:eval_to_eq_unsafe (x)
  3862. (or
  3863. (and (atom x) (not (symbolp x)) (not (eq!-safe x)))
  3864. (and (not (atom x)) (flagp (car x) 'eq!-unsafe))
  3865. (and
  3866. (eqcar x 'quote)
  3867. (or
  3868. (not (atom (cadr x)))
  3869. (and (not (symbolp (cadr x))) (not (eq!-safe (cadr x)))) ))) )
  3870. (flag
  3871. '(eq eqcar null not greaterp lessp geq leq minusp atom numberp consp)
  3872. 'eq!-safe)
  3873. (cond
  3874. ((not (eq!-safe 1))
  3875. (flag
  3876. '(length plus minus difference times quotient plus2 times2 expt fix
  3877. float)
  3878. 'eq!-unsafe)))
  3879. (de s!:list_all_eq_safe (u)
  3880. (or
  3881. (atom u)
  3882. (and
  3883. (or (symbolp (car u)) (eq!-safe (car u)))
  3884. (s!:list_all_eq_safe (cdr u)))) )
  3885. (de s!:eval_to_list_all_eq_safe (x)
  3886. (or
  3887. (null x)
  3888. (and (eqcar x 'quote) (s!:list_all_eq_safe (cadr x)))
  3889. (and
  3890. (eqcar x 'list)
  3891. (or
  3892. (null (cdr x))
  3893. (and
  3894. (s!:eval_to_eq_safe (cadr x))
  3895. (s!:eval_to_list_all_eq_safe (cons 'list (cddr x)))) ))
  3896. (and
  3897. (eqcar x 'cons)
  3898. (s!:eval_to_eq_safe (cadr x))
  3899. (s!:eval_to_list_all_eq_safe (caddr x)))) )
  3900. (de s!:eval_to_eq_unsafe (x)
  3901. (or
  3902. (and (numberp x) (not (eq!-safe x)))
  3903. (stringp x)
  3904. (and
  3905. (eqcar x 'quote)
  3906. (or
  3907. (not (atom (cadr x)))
  3908. (and (numberp (cadr x)) (not (eq!-safe (cadr x))))
  3909. (stringp (cadr x)))) ))
  3910. (de s!:list_some_eq_unsafe (u)
  3911. (and
  3912. (not (atom u))
  3913. (or (s!:eval_to_eq_unsafe (car u)) (s!:list_some_eq_unsafe (cdr u)))) )
  3914. (de s!:eval_to_list_some_eq_unsafe (x)
  3915. (cond
  3916. ((atom x) nil)
  3917. ((eqcar x 'quote) (s!:list_some_eq_unsafe (cadr x)))
  3918. ((and (eqcar x 'list) (cdr x))
  3919. (or
  3920. (s!:eval_to_eq_unsafe (cadr x))
  3921. (s!:eval_to_list_some_eq_unsafe (cons 'list (cddr x)))) )
  3922. ((eqcar x 'cons)
  3923. (or
  3924. (s!:eval_to_eq_unsafe (cadr x))
  3925. (s!:eval_to_list_some_eq_unsafe (caddr x))))
  3926. (t nil)))
  3927. (de s!:eval_to_car_eq_safe (x)
  3928. (and
  3929. (or (eqcar x 'cons) (eqcar x 'list))
  3930. (not (null (cdr x)))
  3931. (s!:eval_to_eq_safe (cadr x))))
  3932. (de s!:eval_to_car_eq_unsafe (x)
  3933. (and
  3934. (or (eqcar x 'cons) (eqcar x 'list))
  3935. (not (null (cdr x)))
  3936. (s!:eval_to_eq_unsafe (cadr x))))
  3937. (de s!:alist_eq_safe (u)
  3938. (or
  3939. (atom u)
  3940. (and
  3941. (not (atom (car u)))
  3942. (or (symbolp (caar u)) (eq!-safe (caar u)))
  3943. (s!:alist_eq_safe (cdr u)))) )
  3944. (de s!:eval_to_alist_eq_safe (x)
  3945. (or
  3946. (null x)
  3947. (and (eqcar x 'quote) (s!:alist_eq_safe (cadr x)))
  3948. (and
  3949. (eqcar x 'list)
  3950. (or
  3951. (null (cdr x))
  3952. (and
  3953. (s!:eval_to_car_eq_safe (cadr x))
  3954. (s!:eval_to_alist_eq_safe (cons 'list (cddr x)))) ))
  3955. (and
  3956. (eqcar x 'cons)
  3957. (s!:eval_to_car_eq_safe (cadr x))
  3958. (s!:eval_to_alist_eq_safe (caddr x)))) )
  3959. (de s!:alist_eq_unsafe (u)
  3960. (and
  3961. (not (atom u))
  3962. (not (atom (car u)))
  3963. (or
  3964. (not (atom (caar u)))
  3965. (and (not (symbolp (caar u))) (not (eq!-safe (caar u))))
  3966. (s!:alist_eq_unsafe (cdr u)))) )
  3967. (de s!:eval_to_alist_eq_unsafe (x)
  3968. (cond
  3969. ((null x) nil)
  3970. ((eqcar x 'quote) (s!:alist_eq_unsafe (cadr x)))
  3971. ((eqcar x 'list)
  3972. (and
  3973. (cdr x)
  3974. (or
  3975. (s!:eval_to_car_eq_unsafe (cadr x))
  3976. (s!:eval_to_alist_eq_unsafe (cons 'list (cddr x)))) ))
  3977. ((eqcar x 'cons)
  3978. (or
  3979. (s!:eval_to_car_eq_unsafe (cadr x))
  3980. (s!:eval_to_alist_eq_safe (caddr x))))
  3981. (t nil)))
  3982. (de s!:comequal (x env context)
  3983. (cond
  3984. ((or (s!:eval_to_eq_safe (cadr x)) (s!:eval_to_eq_safe (caddr x)))
  3985. (s!:comcall (cons 'eq (cdr x)) env context))
  3986. (t (s!:comcall x env context))))
  3987. (put 'equal 's!:compfn (function s!:comequal))
  3988. (de s!:comeq (x env context)
  3989. (cond
  3990. ((or (s!:eval_to_eq_unsafe (cadr x)) (s!:eval_to_eq_unsafe (caddr x)))
  3991. (progn
  3992. (cond ((neq (posn) 0) (terpri)))
  3993. (princ "++++ EQ on number upgraded to EQUAL in ")
  3994. (prin s!:current_function)
  3995. (princ " : ")
  3996. (prin (cadr x))
  3997. (princ " ")
  3998. (print (caddr x))
  3999. (s!:comcall (cons 'equal (cdr x)) env context)))
  4000. (t (s!:comcall x env context))))
  4001. (put 'eq 's!:compfn (function s!:comeq))
  4002. (de s!:comeqcar (x env context)
  4003. (cond
  4004. ((s!:eval_to_eq_unsafe (caddr x))
  4005. (progn
  4006. (cond ((neq (posn) 0) (terpri)))
  4007. (princ "++++ EQCAR on number upgraded to EQUALCAR in ")
  4008. (prin s!:current_function)
  4009. (princ " : ")
  4010. (prin (caddr x))
  4011. (s!:comcall (cons 'equalcar (cdr x)) env context)))
  4012. (t (s!:comcall x env context))))
  4013. (put 'eqcar 's!:compfn (function s!:comeqcar))
  4014. (de s!:comsublis (x env context)
  4015. (cond
  4016. ((s!:eval_to_alist_eq_safe (cadr x))
  4017. (s!:comval (cons 'subla (cdr x)) env context))
  4018. (t (s!:comcall x env context))))
  4019. (put 'sublis 's!:compfn (function s!:comsublis))
  4020. (de s!:comsubla (x env context)
  4021. (cond
  4022. ((s!:eval_to_alist_eq_unsafe (cadr x))
  4023. (progn
  4024. (cond ((neq (posn) 0) (terpri)))
  4025. (princ "++++ SUBLA on number upgraded to SUBLIS in ")
  4026. (prin s!:current_function)
  4027. (princ " : ")
  4028. (print (cadr x))
  4029. (s!:comval (cons 'sublis (cdr x)) env context)))
  4030. (t (s!:comcall x env context))))
  4031. (put 'subla 's!:compfn (function s!:comsubla))
  4032. (de s!:comassoc (x env context)
  4033. (cond
  4034. ((and
  4035. (or
  4036. (s!:eval_to_eq_safe (cadr x))
  4037. (s!:eval_to_alist_eq_safe (caddr x)))
  4038. (equal (length x) 3))
  4039. (s!:comval (cons 'atsoc (cdr x)) env context))
  4040. ((equal (length x) 3)
  4041. (s!:comcall (cons 'assoc!*!* (cdr x)) env context))
  4042. (t (s!:comcall x env context))))
  4043. (put 'assoc 's!:compfn (function s!:comassoc))
  4044. (put 'assoc!*!* 's!:compfn (function s!:comassoc))
  4045. (de s!:comatsoc (x env context)
  4046. (cond
  4047. ((or
  4048. (s!:eval_to_eq_unsafe (cadr x))
  4049. (s!:eval_to_alist_eq_unsafe (caddr x)))
  4050. (progn
  4051. (cond ((neq (posn) 0) (terpri)))
  4052. (princ "++++ ATSOC on number upgraded to ASSOC in ")
  4053. (prin s!:current_function)
  4054. (princ " : ")
  4055. (prin (cadr x))
  4056. (princ " ")
  4057. (print (caddr x))
  4058. (s!:comval (cons 'assoc (cdr x)) env context)))
  4059. (t (s!:comcall x env context))))
  4060. (put 'atsoc 's!:compfn (function s!:comatsoc))
  4061. (de s!:commember (x env context)
  4062. (cond
  4063. ((and
  4064. (or
  4065. (s!:eval_to_eq_safe (cadr x))
  4066. (s!:eval_to_list_all_eq_safe (caddr x)))
  4067. (equal (length x) 3))
  4068. (s!:comval (cons 'memq (cdr x)) env context))
  4069. (t (s!:comcall x env context))))
  4070. (put 'member 's!:compfn (function s!:commember))
  4071. (put 'member!*!* 's!:compfn (function s!:commember))
  4072. (de s!:commemq (x env context)
  4073. (cond
  4074. ((or
  4075. (s!:eval_to_eq_unsafe (cadr x))
  4076. (s!:eval_to_list_some_eq_unsafe (caddr x)))
  4077. (progn
  4078. (cond ((neq (posn) 0) (terpri)))
  4079. (princ "++++ MEMQ on number upgraded to MEMBER in ")
  4080. (prin s!:current_function)
  4081. (princ " : ")
  4082. (prin (cadr x))
  4083. (princ " ")
  4084. (print (caddr x))
  4085. (s!:comval (cons 'member (cdr x)) env context)))
  4086. (t (s!:comcall x env context))))
  4087. (put 'memq 's!:compfn (function s!:commemq))
  4088. (de s!:comdelete (x env context)
  4089. (cond
  4090. ((and
  4091. (or
  4092. (s!:eval_to_eq_safe (cadr x))
  4093. (s!:eval_to_list_all_eq_safe (caddr x)))
  4094. (equal (length x) 3))
  4095. (s!:comval (cons 'deleq (cdr x)) env context))
  4096. (t (s!:comcall x env context))))
  4097. (put 'delete 's!:compfn (function s!:comdelete))
  4098. (de s!:comdeleq (x env context)
  4099. (cond
  4100. ((or
  4101. (s!:eval_to_eq_unsafe (cadr x))
  4102. (s!:eval_to_list_some_eq_unsafe (caddr x)))
  4103. (progn
  4104. (cond ((neq (posn) 0) (terpri)))
  4105. (princ "++++ DELEQ on number upgraded to DELETE in ")
  4106. (prin s!:current_function)
  4107. (princ " : ")
  4108. (prin (cadr x))
  4109. (princ " ")
  4110. (print (caddr x))
  4111. (s!:comval (cons 'delete (cdr x)) env context)))
  4112. (t (s!:comcall x env context))))
  4113. (put 'deleq 's!:compfn (function s!:comdeleq))
  4114. (de s!:commap (fnargs env context)
  4115. (prog (carp fn fn1 args var avar moveon l1 r s closed)
  4116. (setq fn (car fnargs))
  4117. (cond
  4118. ((greaterp context 1)
  4119. (progn
  4120. (cond
  4121. ((equal fn 'mapcar) (setq fn 'mapc))
  4122. ((equal fn 'maplist) (setq fn 'map)))) ))
  4123. (cond
  4124. ((or (equal fn 'mapc) (equal fn 'mapcar) (equal fn 'mapcan))
  4125. (setq carp t)))
  4126. (setq fnargs (cdr fnargs))
  4127. (cond ((atom fnargs) (error 0 "bad arguments to map function")))
  4128. (setq fn1 (cadr fnargs))
  4129. (prog nil
  4130. !G38 (cond
  4131. ((not
  4132. (or
  4133. (eqcar fn1 'function)
  4134. (and (eqcar fn1 'quote) (eqcar (cadr fn1) 'lambda))))
  4135. (return nil)))
  4136. (progn (setq fn1 (cadr fn1)) (setq closed t))
  4137. (go !G38))
  4138. (setq args (car fnargs))
  4139. (setq l1 (gensym))
  4140. (setq r (gensym))
  4141. (setq s (gensym))
  4142. (setq var (gensym))
  4143. (setq avar var)
  4144. (cond (carp (setq avar (list 'car avar))))
  4145. (cond
  4146. (closed (setq fn1 (list fn1 avar)))
  4147. (t (setq fn1 (list 'funcall fn1 avar))))
  4148. (setq moveon (list 'setq var (list 'cdr var)))
  4149. (cond
  4150. ((or (equal fn 'map) (equal fn 'mapc))
  4151. (setq fn
  4152. (sublis
  4153. (list
  4154. (cons 'l1 l1)
  4155. (cons 'var var)
  4156. (cons 'fn fn1)
  4157. (cons 'args args)
  4158. (cons 'moveon moveon))
  4159. '(prog (var)
  4160. (setq var args)
  4161. l1 (cond ((not var) (return nil)))
  4162. fn
  4163. moveon(go l1)))) )
  4164. ((or (equal fn 'maplist) (equal fn 'mapcar))
  4165. (setq fn
  4166. (sublis
  4167. (list
  4168. (cons 'l1 l1)
  4169. (cons 'var var)
  4170. (cons 'fn fn1)
  4171. (cons 'args args)
  4172. (cons 'moveon moveon)
  4173. (cons 'r r))
  4174. '(prog (var r)
  4175. (setq var args)
  4176. l1 (cond ((not var) (return (reversip r))))
  4177. (setq r (cons fn r))
  4178. moveon(go l1)))) )
  4179. (t (setq fn
  4180. (sublis
  4181. (list
  4182. (cons 'l1 l1)
  4183. (cons 'l2 (gensym))
  4184. (cons 'var var)
  4185. (cons 'fn fn1)
  4186. (cons 'args args)
  4187. (cons 'moveon moveon)
  4188. (cons 'r (gensym))
  4189. (cons 's (gensym)))
  4190. '(prog (var r s)
  4191. (setq var args)
  4192. (setq r (setq s (list nil)))
  4193. l1 (cond ((not var) (return (cdr r))))
  4194. (rplacd s fn)
  4195. l2 (cond ((not (atom (cdr s))) (setq s (cdr s)) (go l2)))
  4196. moveon(go l1)))) ))
  4197. (s!:comval fn env context)))
  4198. (put 'map 's!:compfn (function s!:commap))
  4199. (put 'maplist 's!:compfn (function s!:commap))
  4200. (put 'mapc 's!:compfn (function s!:commap))
  4201. (put 'mapcar 's!:compfn (function s!:commap))
  4202. (put 'mapcon 's!:compfn (function s!:commap))
  4203. (put 'mapcan 's!:compfn (function s!:commap))
  4204. (de s!:nilargs (use)
  4205. (cond
  4206. ((null use) t)
  4207. ((or (equal (car use) 'nil) (equal (car use) ''nil))
  4208. (s!:nilargs (cdr use)))
  4209. (t nil)))
  4210. (de s!:subargs (args use)
  4211. (cond
  4212. ((null use) t)
  4213. ((null args) (s!:nilargs use))
  4214. ((not (equal (car args) (car use))) nil)
  4215. (t (s!:subargs (cdr args) (cdr use)))) )
  4216. (fluid '(!*where_defined!*))
  4217. (de clear_source_database nil
  4218. (progn (setq !*where_defined!* (mkhash 10 2 1.5)) nil))
  4219. (de load_source_database (filename)
  4220. (prog (a b)
  4221. (clear_source_database)
  4222. (setq a (open filename 'input))
  4223. (cond ((null a) (return nil)))
  4224. (setq a (rds a))
  4225. (prog nil
  4226. !G39 (cond ((not (setq b (read))) (return nil)))
  4227. (puthash (car b) !*where_defined!* (cdr b))
  4228. (go !G39))
  4229. (close (rds a))
  4230. (return nil)))
  4231. (de save_source_database (filename)
  4232. (prog (a)
  4233. (setq a (open filename 'output))
  4234. (cond ((null a) (return nil)))
  4235. (setq a (wrs a))
  4236. (prog (z)
  4237. (setq z (sort (hashcontents !*where_defined!*) (function orderp)))
  4238. lab (cond ((null z) (return nil)))
  4239. ((lambda (z) (progn (prin z) (terpri))) (car z))
  4240. (setq z (cdr z))
  4241. (go lab))
  4242. (princ nil)
  4243. (terpri)
  4244. (wrs a)
  4245. (setq !*where_defined!* nil)
  4246. (return nil)))
  4247. (de display_source_database nil
  4248. (prog (w)
  4249. (cond ((null !*where_defined!*) (return nil)))
  4250. (setq w (hashcontents !*where_defined!*))
  4251. (setq w (sort w (function orderp)))
  4252. (terpri)
  4253. (prog (x)
  4254. (setq x w)
  4255. lab (cond ((null x) (return nil)))
  4256. ((lambda (x)
  4257. (progn (princ (car x)) (ttab 40) (prin (cdr x)) (terpri)))
  4258. (car x))
  4259. (setq x (cdr x))
  4260. (go lab))))
  4261. (de s!:compile1 (name args body s!:lexical_env)
  4262. (prog (w aargs oargs oinit restarg svars nargs nopts env fluids
  4263. s!:current_function
  4264. s!:current_label
  4265. s!:current_block
  4266. s!:current_size
  4267. s!:current_procedure
  4268. s!:current_exitlab
  4269. s!:current_proglabels
  4270. s!:other_defs
  4271. local_decs
  4272. s!:has_closure s!:local_macros s!:recent_literals s!:a_reg_values w1
  4273. w2 s!:current_count)
  4274. (setq s!:current_function name)
  4275. (setq s!:current_count 0)
  4276. (cond
  4277. (!*where_defined!*
  4278. (progn
  4279. (setq w name)
  4280. (puthash w !*where_defined!* (where!-was!-that)))) )
  4281. (setq body (s!:find_local_decs body))
  4282. (setq local_decs (car body))
  4283. (setq body (cdr body))
  4284. (cond
  4285. ((atom body) (setq body nil))
  4286. ((null (cdr body)) (setq body (car body)))
  4287. (t (setq body (cons 'progn body))))
  4288. (setq nargs (setq nopts 0))
  4289. (prog nil
  4290. !G40 (cond
  4291. ((not
  4292. (and
  4293. args
  4294. (not (eqcar args '!&optional))
  4295. (not (eqcar args '!&rest))))
  4296. (return nil)))
  4297. (progn
  4298. (cond
  4299. ((or (equal (car args) '!&key) (equal (car args) '!&aux))
  4300. (error 0 "&key/&aux")))
  4301. (setq aargs (cons (car args) aargs))
  4302. (setq nargs (plus nargs 1))
  4303. (setq args (cdr args)))
  4304. (go !G40))
  4305. (cond
  4306. ((eqcar args '!&optional)
  4307. (progn
  4308. (setq args (cdr args))
  4309. (prog nil
  4310. !G41 (cond
  4311. ((not (and args (not (eqcar args '!&rest))))
  4312. (return nil)))
  4313. (progn
  4314. (cond
  4315. ((or
  4316. (equal (car args) '!&key)
  4317. (equal (car args) '!&aux))
  4318. (error 0 "&key/&aux")))
  4319. (setq w (car args))
  4320. (prog nil
  4321. !G42 (cond
  4322. ((not
  4323. (and
  4324. (not (atom w))
  4325. (or
  4326. (atom (cdr w))
  4327. (equal (cdr w) '(nil)))) )
  4328. (return nil)))
  4329. (setq w (car w))
  4330. (go !G42))
  4331. (setq args (cdr args))
  4332. (setq oargs (cons w oargs))
  4333. (setq nopts (plus nopts 1))
  4334. (cond
  4335. ((atom w) (setq aargs (cons w aargs)))
  4336. (t (progn
  4337. (setq oinit t)
  4338. (setq aargs (cons (car w) aargs))
  4339. (cond
  4340. ((not (atom (cddr w)))
  4341. (setq svars
  4342. (cons (caddr w) svars)))) ))) )
  4343. (go !G41)))) )
  4344. (cond
  4345. ((eqcar args '!&rest)
  4346. (progn
  4347. (setq w (cadr args))
  4348. (setq aargs (cons w aargs))
  4349. (setq restarg w)
  4350. (setq args (cddr args))
  4351. (cond (args (error 0 "&rest arg not at end")))) ))
  4352. (setq args (reverse aargs))
  4353. (setq oargs (reverse oargs))
  4354. (prog (v)
  4355. (setq v (append svars args))
  4356. lab (cond ((null v) (return nil)))
  4357. ((lambda (v)
  4358. (progn
  4359. (cond
  4360. ((globalp v)
  4361. (progn
  4362. (cond
  4363. (!*pwrds
  4364. (progn
  4365. (cond ((neq (posn) 0) (terpri)))
  4366. (princ "+++++ global ")
  4367. (prin v)
  4368. (princ " converted to fluid")
  4369. (terpri))))
  4370. (unglobal (list v))
  4371. (fluid (list v)))) )))
  4372. (car v))
  4373. (setq v (cdr v))
  4374. (go lab))
  4375. (cond
  4376. (oinit
  4377. (return
  4378. (s!:compile2 name nargs nopts args oargs restarg body
  4379. local_decs))))
  4380. (setq w nil)
  4381. (prog (v)
  4382. (setq v args)
  4383. lab (cond ((null v) (return nil)))
  4384. ((lambda (v) (setq w (s!:instate_local_decs v local_decs w)))
  4385. (car v))
  4386. (setq v (cdr v))
  4387. (go lab))
  4388. (prog (v)
  4389. (setq v args)
  4390. lab (cond ((null v) (return nil)))
  4391. (progn
  4392. (cond
  4393. ((fluidp (car v))
  4394. (prog (g)
  4395. (setq g (gensym))
  4396. (setq fluids (cons (cons (car v) g) fluids))
  4397. (rplaca v g)))) )
  4398. (setq v (cdr v))
  4399. (go lab))
  4400. (cond
  4401. (fluids
  4402. (progn
  4403. (setq body (list (list 'return body)))
  4404. (prog (v)
  4405. (setq v fluids)
  4406. lab (cond ((null v) (return nil)))
  4407. ((lambda (v)
  4408. (setq body (cons (list 'setq (car v) (cdr v)) body)))
  4409. (car v))
  4410. (setq v (cdr v))
  4411. (go lab))
  4412. (setq body
  4413. (cons
  4414. 'prog
  4415. (cons
  4416. (prog (v !G43 endptr)
  4417. (setq v fluids)
  4418. (cond ((null v) (return nil)))
  4419. (setq !G43
  4420. (setq endptr
  4421. (cons ((lambda (v) (car v)) (car v)) nil)))
  4422. looplabel
  4423. (setq v (cdr v))
  4424. (cond ((null v) (return !G43)))
  4425. (rplacd
  4426. endptr
  4427. (cons ((lambda (v) (car v)) (car v)) nil))
  4428. (setq endptr (cdr endptr))
  4429. (go looplabel))
  4430. body)))) ))
  4431. (setq env
  4432. (cons
  4433. (mkhash 10 (cond (s!:faslmod_name 2) (t 1)) 1.5)
  4434. (reverse args)))
  4435. (puthash name (car env) (cons 10000000 nil))
  4436. (setq w (s!:residual_local_decs local_decs w))
  4437. (s!:start_procedure nargs nopts restarg)
  4438. (setq w1 body)
  4439. more (cond
  4440. ((atom w1) nil)
  4441. ((and (equal (car w1) 'block) (equal (length w1) 3))
  4442. (progn (setq w1 (caddr w1)) (go more)))
  4443. ((and (equal (car w1) 'progn) (equal (length w1) 2))
  4444. (progn (setq w1 (cadr w1)) (go more)))
  4445. ((and (atom (setq w2 (car w1))) (setq w2 (get w2 's!:newname)))
  4446. (progn (setq w1 (cons w2 (cdr w1))) (go more)))
  4447. ((and (atom (setq w2 (car w1))) (setq w2 (macro!-function w2)))
  4448. (progn (setq w1 (funcall w2 w1)) (go more))))
  4449. (cond
  4450. ((not (equal (setq w2 (s!:improve w1)) w1))
  4451. (progn (setq w1 w2) (go more))))
  4452. (cond
  4453. ((and
  4454. (not (atom w1))
  4455. (atom (car w1))
  4456. (not (special!-form!-p (car w1)))
  4457. (s!:subargs args (cdr w1))
  4458. (leq nargs 3)
  4459. (equal nopts 0)
  4460. (not restarg)
  4461. (leq (length (cdr w1)) nargs))
  4462. (progn
  4463. (s!:cancel_local_decs w)
  4464. (cond (restarg (setq nopts (plus nopts 512))))
  4465. (setq nopts (plus nopts (times 1024 (length w1))))
  4466. (setq nargs (plus nargs (times 256 nopts)))
  4467. (cond
  4468. (!*pwrds
  4469. (progn
  4470. (cond ((neq (posn) 0) (terpri)))
  4471. (princ "+++ ")
  4472. (prin name)
  4473. (princ " compiled as link to ")
  4474. (princ (car w1))
  4475. (terpri))))
  4476. (return
  4477. (cons
  4478. (cons name (cons nargs (cons nil (car w1))))
  4479. s!:other_defs)))) )
  4480. (s!:comval body env 0)
  4481. (s!:cancel_local_decs w)
  4482. (cond (restarg (setq nopts (plus nopts 512))))
  4483. (setq nargs (plus nargs (times 256 nopts)))
  4484. (return
  4485. (cons
  4486. (cons name (cons nargs (s!:endprocedure name env)))
  4487. s!:other_defs))))
  4488. (de s!:compile2 (name nargs nopts args oargs restarg body local_decs)
  4489. (prog (fluids env penv g v init atend w)
  4490. (prog (v)
  4491. (setq v args)
  4492. lab (cond ((null v) (return nil)))
  4493. ((lambda (v)
  4494. (progn (setq env (cons 0 env)) (setq penv (cons env penv))))
  4495. (car v))
  4496. (setq v (cdr v))
  4497. (go lab))
  4498. (setq env (cons (mkhash 10 (cond (s!:faslmod_name 2) (t 1)) 1.5) env))
  4499. (puthash name (car env) (cons 10000000 nil))
  4500. (setq penv (reversip penv))
  4501. (cond (restarg (setq oargs (append oargs '(0)))) )
  4502. (prog (i)
  4503. (setq i 1)
  4504. lab (cond ((minusp (difference nargs i)) (return nil)))
  4505. (setq oargs (cons 0 oargs))
  4506. (setq i (plus2 i 1))
  4507. (go lab))
  4508. (s!:start_procedure nargs nopts restarg)
  4509. (prog nil
  4510. !G44 (cond ((not args) (return nil)))
  4511. (progn
  4512. (setq v (car args))
  4513. (setq init (car oargs))
  4514. (cond
  4515. ((equal init 0)
  4516. (progn
  4517. (setq w (s!:instate_local_decs v local_decs w))
  4518. (cond
  4519. ((fluidp v)
  4520. (progn
  4521. (setq g (gensym))
  4522. (rplaca (car penv) g)
  4523. (s!:outopcode1lit
  4524. 'freebind
  4525. (s!:vecof (list v))
  4526. env)
  4527. (rplacd
  4528. env
  4529. (cons 3 (cons 0 (cons 0 (cdr env)))) )
  4530. (setq atend (cons 'freerstr atend))
  4531. (s!:comval (list 'setq v g) env 2)))
  4532. (t (rplaca (car penv) v)))) )
  4533. (t (prog (ival sp l1 l2)
  4534. (cond
  4535. ((not (atom init))
  4536. (progn
  4537. (setq init (cdr init))
  4538. (setq ival (car init))
  4539. (cond
  4540. ((not (atom (cdr init)))
  4541. (setq sp (cadr init)))) )))
  4542. (setq l1 (gensym))
  4543. (setq g (gensym))
  4544. (rplaca (car penv) g)
  4545. (cond
  4546. ((and (null ival) (null sp))
  4547. (s!:comval
  4548. (list 'setq g (list 'spid!-to!-nil g))
  4549. env
  4550. 1))
  4551. (t (progn
  4552. (s!:jumpif nil (list 'is!-spid g) env l1)
  4553. (s!:comval (list 'setq g ival) env 1)
  4554. (cond
  4555. (sp
  4556. (progn
  4557. (cond
  4558. ((fluidp sp)
  4559. (progn
  4560. (s!:outopcode1lit
  4561. 'freebind
  4562. (s!:vecof (list sp))
  4563. env)
  4564. (s!:outjump
  4565. 'jump
  4566. (setq l2 (gensym)))
  4567. (s!:set_label l1)
  4568. (s!:outopcode1lit
  4569. 'freebind
  4570. (s!:vecof (list sp))
  4571. env)
  4572. (rplacd
  4573. env
  4574. (cons
  4575. 3
  4576. (cons
  4577. 0
  4578. (cons 0 (cdr env)))) )
  4579. (s!:comval (list 'setq sp t) env 1)
  4580. (s!:set_label l2)
  4581. (setq atend
  4582. (cons 'freerstr atend))))
  4583. (t (progn
  4584. (s!:outopcode0
  4585. 'pushnil
  4586. '(pushnil))
  4587. (s!:outjump
  4588. 'jump
  4589. (setq l2 (gensym)))
  4590. (s!:set_label l1)
  4591. (s!:loadliteral t env)
  4592. (s!:outopcode0 'push '(push))
  4593. (s!:set_label l2)
  4594. (rplacd
  4595. env
  4596. (cons sp (cdr env)))
  4597. (setq atend
  4598. (cons 'lose atend)))) )))
  4599. (t (s!:set_label l1)))) ))
  4600. (setq w (s!:instate_local_decs v local_decs w))
  4601. (cond
  4602. ((fluidp v)
  4603. (progn
  4604. (s!:outopcode1lit
  4605. 'freebind
  4606. (s!:vecof (list v))
  4607. env)
  4608. (rplacd
  4609. env
  4610. (cons 3 (cons 0 (cons 0 (cdr env)))) )
  4611. (s!:comval (list 'setq v g) env 1)
  4612. (setq atend (cons 'freerstr atend))))
  4613. (t (rplaca (car penv) v)))) ))
  4614. (setq args (cdr args))
  4615. (setq oargs (cdr oargs))
  4616. (setq penv (cdr penv)))
  4617. (go !G44))
  4618. (setq w (s!:residual_local_decs local_decs w))
  4619. (s!:comval body env 0)
  4620. (prog nil
  4621. !G45 (cond ((not atend) (return nil)))
  4622. (progn
  4623. (s!:outopcode0 (car atend) (list (car atend)))
  4624. (setq atend (cdr atend)))
  4625. (go !G45))
  4626. (s!:cancel_local_decs w)
  4627. (setq nopts (plus nopts 256))
  4628. (cond (restarg (setq nopts (plus nopts 512))))
  4629. (setq nargs (plus nargs (times 256 nopts)))
  4630. (return
  4631. (cons
  4632. (cons name (cons nargs (s!:endprocedure name env)))
  4633. s!:other_defs))))
  4634. (de compile!-all nil
  4635. (prog (x)
  4636. (setq x (oblist))
  4637. lab (cond ((null x) (return nil)))
  4638. ((lambda (x)
  4639. (prog (w)
  4640. (setq w (getd x))
  4641. (cond
  4642. ((and
  4643. (or (eqcar w 'expr) (eqcar w 'macro))
  4644. (eqcar (cdr w) 'lambda))
  4645. (progn
  4646. (princ "Compile: ")
  4647. (prin x)
  4648. (terpri)
  4649. (errorset (list 'compile (mkquote (list x))) t t)))) ))
  4650. (car x))
  4651. (setq x (cdr x))
  4652. (go lab)))
  4653. (flag
  4654. '(rds deflist flag fluid global remprop remflag unfluid unglobal dm
  4655. defmacro carcheck faslend c_end)
  4656. 'eval)
  4657. (flag '(rds) 'ignore)
  4658. (fluid '(!*backtrace))
  4659. (de s!:fasl_supervisor nil
  4660. (prog (u w !*echo)
  4661. top (setq u (errorset '(read) t !*backtrace))
  4662. (cond ((atom u) (return nil)))
  4663. (setq u (car u))
  4664. (cond ((equal u !$eof!$) (return nil)))
  4665. (cond ((not (atom u)) (setq u (macroexpand u))))
  4666. (cond
  4667. ((atom u) (go top))
  4668. ((eqcar u 'faslend) (return (apply 'faslend nil)))
  4669. ((eqcar u 'rdf)
  4670. (progn
  4671. (setq w (open (setq u (eval (cadr u))) 'input))
  4672. (cond
  4673. (w
  4674. (progn (terpri) (princ "Reading file ") (prin u) (terpri)
  4675. (setq w (rds w))
  4676. (s!:fasl_supervisor)
  4677. (princ "End of file ")
  4678. (prin u)
  4679. (terpri)
  4680. (close (rds w))))
  4681. (t (progn
  4682. (princ "Failed to open file ")
  4683. (prin u)
  4684. (terpri)))) ))
  4685. (t (s!:fslout0 u)))
  4686. (go top)))
  4687. (de s!:fslout0 (u) (s!:fslout1 u nil))
  4688. (de s!:fslout1 (u loadonly)
  4689. (prog (w)
  4690. (cond ((not (atom u)) (setq u (macroexpand u))))
  4691. (cond
  4692. ((atom u) (return nil))
  4693. ((eqcar u 'progn)
  4694. (progn
  4695. (prog (v)
  4696. (setq v (cdr u))
  4697. lab (cond ((null v) (return nil)))
  4698. ((lambda (v) (s!:fslout1 v loadonly)) (car v))
  4699. (setq v (cdr v))
  4700. (go lab))
  4701. (return nil)))
  4702. ((eqcar u 'eval!-when)
  4703. (return
  4704. (prog nil
  4705. (setq w (cadr u))
  4706. (setq u (cons 'progn (cddr u)))
  4707. (cond ((and (memq 'compile w) (not loadonly)) (eval u)))
  4708. (cond ((memq 'load w) (s!:fslout1 u t)))
  4709. (return nil))))
  4710. ((or
  4711. (flagp (car u) 'eval)
  4712. (and
  4713. (equal (car u) 'setq)
  4714. (not (atom (caddr u)))
  4715. (flagp (caaddr u) 'eval)))
  4716. (cond ((not loadonly) (errorset u t !*backtrace)))) )
  4717. (cond
  4718. ((eqcar u 'rdf)
  4719. (prog nil
  4720. (setq w (open (setq u (eval (cadr u))) 'input))
  4721. (cond
  4722. (w
  4723. (progn
  4724. (princ "Reading file ")
  4725. (prin u)
  4726. (terpri)
  4727. (setq w (rds w))
  4728. (s!:fasl_supervisor)
  4729. (princ "End of file ")
  4730. (prin u)
  4731. (terpri)
  4732. (close (rds w))))
  4733. (t (progn
  4734. (princ "Failed to open file ")
  4735. (prin u)
  4736. (terpri)))) ))
  4737. (!*nocompile
  4738. (progn
  4739. (cond
  4740. ((and (not (eqcar u 'faslend)) (not (eqcar u 'carcheck)))
  4741. (write!-module u)))) )
  4742. ((or (eqcar u 'de) (eqcar u 'defun))
  4743. (progn
  4744. (setq u (cdr u))
  4745. (cond
  4746. ((and
  4747. (setq w (get (car u) 'c!-version))
  4748. (equal
  4749. w
  4750. (md60
  4751. (cons
  4752. (cadr u)
  4753. (s!:fully_macroexpand_list (cddr u)))) ))
  4754. (progn
  4755. (princ "+++ ")
  4756. (prin (car u))
  4757. (printc " not compiled (C version available)")
  4758. (write!-module
  4759. (list 'restore!-c!-code (mkquote (car u)))) ))
  4760. ((flagp (car u) 'lose)
  4761. (progn
  4762. (princ "+++ ")
  4763. (prin (car u))
  4764. (printc " not compiled (LOSE flag)")))
  4765. (t (prog (p)
  4766. (setq p (s!:compile1 (car u) (cadr u) (cddr u) nil))
  4767. lab (cond ((null p) (return nil)))
  4768. ((lambda (p) (s!:fslout2 p u)) (car p))
  4769. (setq p (cdr p))
  4770. (go lab)))) ))
  4771. ((or (eqcar u 'dm) (eqcar u 'defmacro))
  4772. (prog (g)
  4773. (setq g (hashtagged!-name (cadr u) (cddr u)))
  4774. (setq u (cdr u))
  4775. (cond
  4776. ((flagp (car u) 'lose)
  4777. (progn
  4778. (princ "+++ ")
  4779. (prin (car u))
  4780. (printc " not compiled (LOSE flag)")
  4781. (return nil))))
  4782. (setq w (cadr u))
  4783. (cond
  4784. ((and w (null (cdr w)))
  4785. (setq w
  4786. (cons
  4787. (car w)
  4788. (cons '!&optional (cons (gensym) nil)))) ))
  4789. (prog (p)
  4790. (setq p (s!:compile1 g w (cddr u) nil))
  4791. lab (cond ((null p) (return nil)))
  4792. ((lambda (p) (s!:fslout2 p u)) (car p))
  4793. (setq p (cdr p))
  4794. (go lab))
  4795. (write!-module
  4796. (list 'dm (car u) '(u !&optional e) (list g 'u 'e)))) )
  4797. ((eqcar u 'putd)
  4798. (prog (a1 a2 a3)
  4799. (setq a1 (cadr u))
  4800. (setq a2 (caddr u))
  4801. (setq a3 (cadddr u))
  4802. (cond
  4803. ((and
  4804. (eqcar a1 'quote)
  4805. (or (equal a2 ''expr) (equal a2 ''macro))
  4806. (or (eqcar a3 'quote) (eqcar a3 'function))
  4807. (eqcar (cadr a3) 'lambda))
  4808. (progn
  4809. (setq a1 (cadr a1))
  4810. (setq a2 (cadr a2))
  4811. (setq a3 (cadr a3))
  4812. (setq u
  4813. (cons
  4814. (cond ((equal a2 'expr) 'de) (t 'dm))
  4815. (cons a1 (cdr a3))))
  4816. (s!:fslout1 u loadonly)))
  4817. (t (write!-module u)))) )
  4818. ((and (not (eqcar u 'faslend)) (not (eqcar u 'carcheck)))
  4819. (write!-module u)))) )
  4820. (de s!:fslout2 (p u)
  4821. (prog (name nargs code env w)
  4822. (setq name (car p))
  4823. (setq nargs (cadr p))
  4824. (setq code (caddr p))
  4825. (setq env (cdddr p))
  4826. (cond
  4827. ((and !*savedef (equal name (car u)))
  4828. (progn
  4829. (define!-in!-module (minus 1))
  4830. (write!-module
  4831. (cons
  4832. 'lambda
  4833. (cons
  4834. (cadr u)
  4835. (s!:fully_macroexpand_list (cddr u)))) ))) )
  4836. (setq w (irightshift nargs 18))
  4837. (setq nargs (logand nargs 262143))
  4838. (cond ((not (equal w 0)) (setq code (difference w 1))))
  4839. (define!-in!-module nargs)
  4840. (write!-module name)
  4841. (write!-module code)
  4842. (write!-module env)))
  4843. (de faslend nil
  4844. (prog nil
  4845. (cond ((null s!:faslmod_name) (return nil)))
  4846. (start!-module nil)
  4847. (setq dfprint!* s!:dfprintsave)
  4848. (setq !*defn nil)
  4849. (setq !*comp (cdr s!:faslmod_name))
  4850. (setq s!:faslmod_name nil)
  4851. (return nil)))
  4852. (put 'faslend 'stat 'endstat)
  4853. (de faslout (u)
  4854. (prog nil
  4855. (terpri)
  4856. (princ "FASLOUT ")
  4857. (prin u)
  4858. (princ ": IN files; or type in expressions")
  4859. (terpri)
  4860. (princ "When all done, execute FASLEND;")
  4861. (terpri)
  4862. (cond ((not (atom u)) (setq u (car u))))
  4863. (cond
  4864. ((not (start!-module u))
  4865. (progn
  4866. (cond ((neq (posn) 0) (terpri)))
  4867. (princ "+++ Failed to open FASL output file")
  4868. (terpri)
  4869. (return nil))))
  4870. (setq s!:faslmod_name (cons u !*comp))
  4871. (setq s!:dfprintsave dfprint!*)
  4872. (setq dfprint!* 's!:fslout0)
  4873. (setq !*defn t)
  4874. (setq !*comp nil)
  4875. (cond ((getd 'begin) (return nil)))
  4876. (s!:fasl_supervisor)))
  4877. (put 'faslout 'stat 'rlis)
  4878. (de s!:c_supervisor nil
  4879. (prog (u w !*echo)
  4880. top (setq u (errorset '(read) t !*backtrace))
  4881. (cond ((atom u) (return nil)))
  4882. (setq u (car u))
  4883. (cond ((equal u !$eof!$) (return nil)))
  4884. (cond ((not (atom u)) (setq u (macroexpand u))))
  4885. (cond
  4886. ((atom u) (go top))
  4887. ((eqcar u 'c_end) (return (apply 'c_end nil)))
  4888. ((eqcar u 'rdf)
  4889. (progn
  4890. (setq w (open (setq u (eval (cadr u))) 'input))
  4891. (cond
  4892. (w
  4893. (progn (terpri) (princ "Reading file ") (prin u) (terpri)
  4894. (setq w (rds w))
  4895. (s!:c_supervisor)
  4896. (princ "End of file ")
  4897. (prin u)
  4898. (terpri)
  4899. (close (rds w))))
  4900. (t (progn
  4901. (princ "Failed to open file ")
  4902. (prin u)
  4903. (terpri)))) ))
  4904. (t (s!:cout0 u)))
  4905. (go top)))
  4906. (de s!:cout0 (u) (s!:cout1 u nil))
  4907. (de s!:cout1 (u loadonly)
  4908. (prog (s!:into_c)
  4909. (setq s!:into_c t)
  4910. (cond ((not (atom u)) (setq u (macroexpand u))))
  4911. (cond
  4912. ((atom u) (return nil))
  4913. ((eqcar u 'progn)
  4914. (progn
  4915. (prog (v)
  4916. (setq v (cdr u))
  4917. lab (cond ((null v) (return nil)))
  4918. ((lambda (v) (s!:cout1 v loadonly)) (car v))
  4919. (setq v (cdr v))
  4920. (go lab))
  4921. (return nil)))
  4922. ((eqcar u 'eval!-when)
  4923. (return
  4924. (prog (w)
  4925. (setq w (cadr u))
  4926. (setq u (cons 'progn (cddr u)))
  4927. (cond ((and (memq 'compile w) (not loadonly)) (eval u)))
  4928. (cond ((memq 'load w) (s!:cout1 u t)))
  4929. (return nil))))
  4930. ((or
  4931. (flagp (car u) 'eval)
  4932. (and
  4933. (equal (car u) 'setq)
  4934. (not (atom (caddr u)))
  4935. (flagp (caaddr u) 'eval)))
  4936. (cond ((not loadonly) (errorset u t !*backtrace)))) )
  4937. (cond
  4938. ((eqcar u 'rdf)
  4939. (prog (w)
  4940. (setq w (open (setq u (eval (cadr u))) 'input))
  4941. (cond
  4942. (w
  4943. (progn
  4944. (princ "Reading file ")
  4945. (prin u)
  4946. (terpri)
  4947. (setq w (rds w))
  4948. (s!:c_supervisor)
  4949. (princ "End of file ")
  4950. (prin u)
  4951. (terpri)
  4952. (close (rds w))))
  4953. (t (progn
  4954. (princ "Failed to open file ")
  4955. (prin u)
  4956. (terpri)))) ))
  4957. ((or (eqcar u 'de) (eqcar u 'defun))
  4958. (prog (w)
  4959. (setq u (cdr u))
  4960. (setq w (s!:compile1 (car u) (cadr u) (cddr u) nil))
  4961. (prog (p)
  4962. (setq p w)
  4963. lab (cond ((null p) (return nil)))
  4964. ((lambda (p) (s!:cgen (car p) (cadr p) (caddr p) (cdddr p)))
  4965. (car p))
  4966. (setq p (cdr p))
  4967. (go lab))))
  4968. ((or (eqcar u 'dm) (eqcar u 'defmacro))
  4969. (prog (w g)
  4970. (setq g (hashtagged!-name (cadr u) (cddr u)))
  4971. (setq u (cdr u))
  4972. (setq w (cadr u))
  4973. (cond
  4974. ((and w (null (cdr w)))
  4975. (setq w
  4976. (cons
  4977. (car w)
  4978. (cons '!&optional (cons (gensym) nil)))) ))
  4979. (setq w (s!:compile1 g w (cddr u) nil))
  4980. (prog (p)
  4981. (setq p w)
  4982. lab (cond ((null p) (return nil)))
  4983. ((lambda (p) (s!:cgen (car p) (cadr p) (caddr p) (cdddr p)))
  4984. (car p))
  4985. (setq p (cdr p))
  4986. (go lab))
  4987. (s!:cinit
  4988. (list 'dm (car u) '(u !&optional e) (list g 'u 'e)))) )
  4989. ((eqcar u 'putd)
  4990. (prog (a1 a2 a3)
  4991. (setq a1 (cadr u))
  4992. (setq a2 (caddr u))
  4993. (setq a3 (cadddr u))
  4994. (cond
  4995. ((and
  4996. (eqcar a1 'quote)
  4997. (or (equal a2 ''expr) (equal a2 ''macro))
  4998. (or (eqcar a3 'quote) (eqcar a3 'function))
  4999. (eqcar (cadr a3) 'lambda))
  5000. (progn
  5001. (setq a1 (cadr a1))
  5002. (setq a2 (cadr a2))
  5003. (setq a3 (cadr a3))
  5004. (setq u
  5005. (cons
  5006. (cond ((equal a2 'expr) 'de) (t 'dm))
  5007. (cons a1 (cdr a3))))
  5008. (s!:cout1 u loadonly)))
  5009. (t (s!:cinit u)))) )
  5010. ((and (not (eqcar u 'c_end)) (not (eqcar u 'carcheck)))
  5011. (s!:cinit u)))) )
  5012. (fluid '(s!:cmod_name))
  5013. (de c_end nil
  5014. (prog nil
  5015. (cond ((null s!:cmod_name) (return nil)))
  5016. (s!:cend)
  5017. (setq dfprint!* s!:dfprintsave)
  5018. (setq !*defn nil)
  5019. (setq !*comp (cdr s!:cmod_name))
  5020. (setq s!:cmod_name nil)
  5021. (return nil)))
  5022. (put 'c_end 'stat 'endstat)
  5023. (de c_out (u)
  5024. (prog nil
  5025. (terpri)
  5026. (princ "C_OUT ")
  5027. (prin u)
  5028. (princ ": IN files; or type in expressions")
  5029. (terpri)
  5030. (princ "When all done, execute C_END;")
  5031. (terpri)
  5032. (cond ((not (atom u)) (setq u (car u))))
  5033. (cond
  5034. ((null (s!:cstart u))
  5035. (progn
  5036. (cond ((neq (posn) 0) (terpri)))
  5037. (princ "+++ Failed to open C output file")
  5038. (terpri)
  5039. (return nil))))
  5040. (setq s!:cmod_name (cons u !*comp))
  5041. (setq s!:dfprintsave dfprint!*)
  5042. (setq dfprint!* 's!:cout0)
  5043. (setq !*defn t)
  5044. (setq !*comp nil)
  5045. (cond ((getd 'begin) (return nil)))
  5046. (s!:c_supervisor)))
  5047. (put 'c_out 'stat 'rlis)
  5048. (de s!:compile!-file!* (fromfile !&optional tofile verbose !*pwrds)
  5049. (prog (!*comp w save)
  5050. (cond ((null tofile) (setq tofile fromfile)))
  5051. (cond
  5052. (verbose
  5053. (progn
  5054. (cond ((neq (posn) 0) (terpri)))
  5055. (princ "+++ Compiling file ")
  5056. (prin fromfile)
  5057. (terpri)
  5058. (setq save (verbos nil))
  5059. (verbos (ilogand save 4)))) )
  5060. (cond
  5061. ((not (start!-module tofile))
  5062. (progn
  5063. (cond ((neq (posn) 0) (terpri)))
  5064. (princ "+++ Failed to open FASL output file")
  5065. (terpri)
  5066. (cond (save (verbos save)))
  5067. (return nil))))
  5068. (setq w (open fromfile 'input))
  5069. (cond
  5070. (w (progn (setq w (rds w)) (s!:fasl_supervisor) (close (rds w))))
  5071. (t (progn (princ "Failed to open file ") (prin fromfile) (terpri))))
  5072. (cond (save (verbos save)))
  5073. (start!-module nil)
  5074. (cond
  5075. (verbose
  5076. (progn
  5077. (cond ((neq (posn) 0) (terpri)))
  5078. (princ "+++ Compilation complete")
  5079. (terpri))))
  5080. (return t)))
  5081. (de compile!-file!* (fromfile !&optional tofile)
  5082. (s!:compile!-file!* fromfile tofile t t))
  5083. (de compd (name type defn)
  5084. (prog (g !*comp)
  5085. (setq !*comp t)
  5086. (cond
  5087. ((eqcar defn 'lambda)
  5088. (progn
  5089. (setq g (dated!-name type))
  5090. (symbol!-set!-definition g defn)
  5091. (compile (list g))
  5092. (setq defn g))))
  5093. (put name type defn)
  5094. (return name)))
  5095. (de s!:compile0 (name)
  5096. (prog (w args defn)
  5097. (setq defn (getd name))
  5098. (cond
  5099. ((and (eqcar defn 'macro) (eqcar (cdr defn) 'lambda))
  5100. (prog (!*comp lx vx bx)
  5101. (setq lx (cdr defn))
  5102. (cond
  5103. ((not
  5104. (or
  5105. (and
  5106. (equal (length lx) 3)
  5107. (not (atom (setq bx (caddr lx))))
  5108. (equal (cadr lx) (cdr bx)))
  5109. (and
  5110. (equal (length lx) 3)
  5111. (not (atom (setq bx (caddr lx))))
  5112. (not (atom (cadr lx)))
  5113. (eqcar (cdadr lx) '!&optional)
  5114. (not (atom (setq bx (cdr bx))))
  5115. (equal (caadr lx) (car bx))
  5116. (equal (cddadr lx) (cdr bx)))) )
  5117. (progn
  5118. (setq w (hashtagged!-name name defn))
  5119. (symbol!-set!-definition w (cdr defn))
  5120. (s!:compile0 w)
  5121. (cond
  5122. ((equal 1 (length (cadr lx)))
  5123. (symbol!-set!-env
  5124. name
  5125. (list '(u !&optional env) (list w 'u))))
  5126. (t (symbol!-set!-env
  5127. name
  5128. (list
  5129. '(u !&optional env)
  5130. (list w 'u 'env)))) ))) )))
  5131. ((or (not (eqcar defn 'expr)) (not (eqcar (cdr defn) 'lambda)))
  5132. (progn
  5133. (cond
  5134. (!*pwrds
  5135. (progn
  5136. (cond ((neq (posn) 0) (terpri)))
  5137. (princ "+++ ")
  5138. (prin name)
  5139. (princ " not compilable")
  5140. (terpri)))) ))
  5141. (t (progn
  5142. (setq args (cddr defn))
  5143. (setq defn (cdr args))
  5144. (setq args (car args))
  5145. (cond
  5146. ((stringp args)
  5147. (progn
  5148. (cond
  5149. (!*pwrds
  5150. (progn
  5151. (cond ((neq (posn) 0) (terpri)))
  5152. (princ "+++ ")
  5153. (prin name)
  5154. (princ " was already compiled")
  5155. (terpri)))) ))
  5156. (t (progn
  5157. (cond
  5158. (!*savedef
  5159. (put
  5160. name
  5161. '!*savedef
  5162. (cons
  5163. 'lambda
  5164. (cons
  5165. args
  5166. (s!:fully_macroexpand_list defn)))) ))
  5167. (setq w (s!:compile1 name args defn nil))
  5168. (prog (p)
  5169. (setq p w)
  5170. lab (cond ((null p) (return nil)))
  5171. ((lambda (p)
  5172. (symbol!-set!-definition (car p) (cdr p)))
  5173. (car p))
  5174. (setq p (cdr p))
  5175. (go lab)))) ))) )))
  5176. (de s!:fully_macroexpand_list (l)
  5177. (prog (u !G46 endptr)
  5178. (setq u l)
  5179. (cond ((null u) (return nil)))
  5180. (setq !G46
  5181. (setq endptr
  5182. (cons ((lambda (u) (s!:fully_macroexpand u)) (car u)) nil)))
  5183. looplabel
  5184. (setq u (cdr u))
  5185. (cond ((null u) (return !G46)))
  5186. (rplacd
  5187. endptr
  5188. (cons ((lambda (u) (s!:fully_macroexpand u)) (car u)) nil))
  5189. (setq endptr (cdr endptr))
  5190. (go looplabel)))
  5191. (de s!:fully_macroexpand (x)
  5192. (prog (helper)
  5193. (cond
  5194. ((or (atom x) (eqcar x 'quote)) (return x))
  5195. ((eqcar (car x) 'lambda)
  5196. (return
  5197. (cons
  5198. (cons
  5199. 'lambda
  5200. (cons (cadar x) (s!:fully_macroexpand_list (cddar x))))
  5201. (s!:fully_macroexpand_list (cdr x)))) )
  5202. ((setq helper (get (car x) 's!:newname))
  5203. (return (s!:fully_macroexpand (cons helper (cdr x)))) )
  5204. ((setq helper (get (car x) 's!:expandfn))
  5205. (return (funcall helper x)))
  5206. ((setq helper (macro!-function (car x)))
  5207. (return (s!:fully_macroexpand (funcall helper x))))
  5208. (t (return (cons (car x) (s!:fully_macroexpand_list (cdr x)))) ))) )
  5209. (de s!:expandfunction (u) u)
  5210. (de s!:expandflet (u) (error "expand" u))
  5211. (de s!:expandlabels (u) (error "expand" u))
  5212. (de s!:expandmacrolet (u) (error "expand" u))
  5213. (de s!:expandprog (u)
  5214. (cons (car u) (cons (cadr u) (s!:fully_macroexpand_list (cddr u)))) )
  5215. (de s!:expandtagbody (u) (s!:fully_macroexpand_list u))
  5216. (de s!:expandprogv (u)
  5217. (cons
  5218. (car u)
  5219. (cons
  5220. (cadr u)
  5221. (cons (caddr u) (s!:fully_macroexpand_list (cadddr u)))) ))
  5222. (de s!:expandblock (u)
  5223. (cons (car u) (cons (cadr u) (s!:fully_macroexpand_list (cddr u)))) )
  5224. (de s!:expanddeclare (u) u)
  5225. (de s!:expandlet (u)
  5226. (cons
  5227. (car u)
  5228. (cons
  5229. (prog (x !G47 endptr)
  5230. (setq x (cadr u))
  5231. (cond ((null x) (return nil)))
  5232. (setq !G47
  5233. (setq endptr
  5234. (cons
  5235. ((lambda (x) (s!:fully_macroexpand_list x)) (car x))
  5236. nil)))
  5237. looplabel
  5238. (setq x (cdr x))
  5239. (cond ((null x) (return !G47)))
  5240. (rplacd
  5241. endptr
  5242. (cons
  5243. ((lambda (x) (s!:fully_macroexpand_list x)) (car x))
  5244. nil))
  5245. (setq endptr (cdr endptr))
  5246. (go looplabel))
  5247. (s!:fully_macroexpand_list (cddr u)))) )
  5248. (de s!:expandlet!* (u) (s!:expandlet u))
  5249. (de s!:expandgo (u) u)
  5250. (de s!:expandreturn!-from (u)
  5251. (cons (car u) (cons (cadr u) (s!:fully_macroexpand_list (cddr u)))) )
  5252. (de s!:expandcond (u)
  5253. (cons
  5254. (car u)
  5255. (prog (x !G48 endptr)
  5256. (setq x (cdr u))
  5257. (cond ((null x) (return nil)))
  5258. (setq !G48
  5259. (setq endptr
  5260. (cons
  5261. ((lambda (x) (s!:fully_macroexpand_list x)) (car x))
  5262. nil)))
  5263. looplabel
  5264. (setq x (cdr x))
  5265. (cond ((null x) (return !G48)))
  5266. (rplacd
  5267. endptr
  5268. (cons ((lambda (x) (s!:fully_macroexpand_list x)) (car x)) nil))
  5269. (setq endptr (cdr endptr))
  5270. (go looplabel))))
  5271. (de s!:expandcase (u)
  5272. (cons
  5273. (car u)
  5274. (prog (x !G49 endptr)
  5275. (setq x (cdr u))
  5276. (cond ((null x) (return nil)))
  5277. (setq !G49
  5278. (setq endptr
  5279. (cons
  5280. ((lambda (x)
  5281. (cons (car x) (s!:fully_macroexpand_list (cdr x))))
  5282. (car x))
  5283. nil)))
  5284. looplabel
  5285. (setq x (cdr x))
  5286. (cond ((null x) (return !G49)))
  5287. (rplacd
  5288. endptr
  5289. (cons
  5290. ((lambda (x)
  5291. (cons (car x) (s!:fully_macroexpand_list (cdr x))))
  5292. (car x))
  5293. nil))
  5294. (setq endptr (cdr endptr))
  5295. (go looplabel))))
  5296. (de s!:expandeval!-when (u)
  5297. (cons (car u) (cons (cadr u) (s!:fully_macroexpand_list (cddr u)))) )
  5298. (de s!:expandthe (u)
  5299. (cons (car u) (cons (cadr u) (s!:fully_macroexpand_list (cddr u)))) )
  5300. (de s!:expandmv!-call (u)
  5301. (cons (car u) (cons (cadr u) (s!:fully_macroexpand_list (cddr u)))) )
  5302. (put 'function 's!:expandfn (function s!:expandfunction))
  5303. (put 'flet 's!:expandfn (function s!:expandflet))
  5304. (put 'labels 's!:expandfn (function s!:expandlabels))
  5305. (put 'macrolet 's!:expandfn (function s!:expandmacrolet))
  5306. (put 'prog 's!:expandfn (function s!:expandprog))
  5307. (put 'tagbody 's!:expandfn (function s!:expandtagbody))
  5308. (put 'progv 's!:expandfn (function s!:expandprogv))
  5309. (put '!~block 's!:expandfn (function s!:expandblock))
  5310. (put 'declare 's!:expandfn (function s!:expanddeclare))
  5311. (put '!~let 's!:expandfn (function s!:expandlet))
  5312. (put 'let!* 's!:expandfn (function s!:expandlet!*))
  5313. (put 'go 's!:expandfn (function s!:expandgo))
  5314. (put 'return!-from 's!:expandfn (function s!:expandreturn!-from))
  5315. (put 'cond 's!:expandfn (function s!:expandcond))
  5316. (put 'case 's!:expandfn (function s!:expandcase))
  5317. (put 'eval!-when 's!:expandfn (function s!:expandeval!-when))
  5318. (put 'the 's!:expandfn (function s!:expandthe))
  5319. (put 'multiple!-value!-call 's!:expandfn (function s!:expandmv!-call))
  5320. (de compile (l)
  5321. (prog nil
  5322. (cond ((and (atom l) (not (null l))) (setq l (list l))))
  5323. (prog (name)
  5324. (setq name l)
  5325. lab (cond ((null name) (return nil)))
  5326. ((lambda (name) (errorset (list 's!:compile0 (mkquote name)) t t))
  5327. (car name))
  5328. (setq name (cdr name))
  5329. (go lab))
  5330. (return l)))