YPCompiler.cs 251 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664
  1. /*
  2. * Copyright (C) 2007-2008, Jeff Thompson
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of the copyright holder nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  22. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. using System;
  31. using System.IO;
  32. using System.Collections;
  33. using System.Collections.Generic;
  34. using System.Text;
  35. using System.CodeDom.Compiler;
  36. namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
  37. {
  38. public class YPCompiler
  39. {
  40. private class CompilerState
  41. {
  42. public IndexedAnswers _pred = new IndexedAnswers();
  43. public Dictionary<YP.NameArity, Atom> _moduleForNameArity = new Dictionary<YP.NameArity, Atom>();
  44. public int _gensymCounter;
  45. public bool _useFinalCutCode;
  46. public Variable _finalCutCode;
  47. public bool _codeUsesYield;
  48. public Atom _determinism;
  49. // a list of '='(Name, Variable)
  50. public List<object> _variableNames;
  51. // Make these static functions that explicitly take the State so Prolog can call it.
  52. /// <summary>
  53. /// Make a new CompilerState and bind it to State.
  54. /// </summary>
  55. /// <param name="State"></param>
  56. /// <returns></returns>
  57. public static IEnumerable<bool> make(object State)
  58. {
  59. return YP.unify(State, new CompilerState());
  60. }
  61. public static void assertPred(object State, object Pred, object Determinism)
  62. {
  63. State = YP.getValue(State);
  64. object functorName = YP.getFunctorName(Pred);
  65. object[] functorArgs = YP.getFunctorArgs(Pred);
  66. // Debug: Should check if it's already asserted and is the same.
  67. ((CompilerState)State)._pred.addAnswer
  68. (new object[] { functorName, functorArgs.Length, Pred, YP.getValue(Determinism) });
  69. }
  70. public static void assertModuleForNameArity(object State, object Name, object Arity, object Module)
  71. {
  72. State = YP.getValue(State);
  73. Name = YP.getValue(Name);
  74. Arity = YP.getValue(Arity);
  75. Module = YP.getValue(Module);
  76. // If the Module Atom comes from the parser, it always has null _declaringClass.
  77. if (Module is Atom && ((Atom)Module)._module == null && Name is Atom && Arity is int)
  78. {
  79. // Replace a previous entry if it exists.
  80. ((CompilerState)State)._moduleForNameArity[new YP.NameArity((Atom)Name, (int)Arity)] =
  81. (Atom)Module;
  82. }
  83. }
  84. public static void startFunction(object State, object Head)
  85. {
  86. State = YP.getValue(State);
  87. ((CompilerState)State)._gensymCounter = 0;
  88. ((CompilerState)State)._useFinalCutCode = false;
  89. ((CompilerState)State)._finalCutCode = new Variable();
  90. ((CompilerState)State)._codeUsesYield = false;
  91. if (CompilerState.isDetNoneOut(State, Head))
  92. ((CompilerState)State)._determinism = Atom.a("detNoneOut");
  93. else if (CompilerState.isSemidetNoneOut(State, Head))
  94. ((CompilerState)State)._determinism = Atom.a("semidetNoneOut");
  95. else
  96. ((CompilerState)State)._determinism = Atom.a("nondet");
  97. }
  98. public static void setCodeUsesYield(object State)
  99. {
  100. State = YP.getValue(State);
  101. ((CompilerState)State)._codeUsesYield = true;
  102. }
  103. public static bool codeUsesYield(object State)
  104. {
  105. State = YP.getValue(State);
  106. return ((CompilerState)State)._codeUsesYield;
  107. }
  108. public static bool determinismEquals(object State, object Term)
  109. {
  110. State = YP.getValue(State);
  111. return YP.termEqual(((CompilerState)State)._determinism, Term);
  112. }
  113. /// <summary>
  114. /// Set _variableNames to a new list of (Name = Variable) for each unique variable in rule.
  115. /// If the variable is in variableNameSuggestions, use it, otherwise use x1, x2, etc.
  116. /// </summary>
  117. /// <param name="State"></param>
  118. /// <param name="rule"></param>
  119. /// <param name="variableNameSuggestions"></param>
  120. public static void newVariableNames(object State, object Rule, object VariableNameSuggestions)
  121. {
  122. State = YP.getValue(State);
  123. List<Variable> variablesSet = new List<Variable>();
  124. YP.addUniqueVariables(Rule, variablesSet);
  125. ((CompilerState)State)._variableNames = new List<object>();
  126. int xCounter = 0;
  127. foreach (Variable variable in variablesSet)
  128. ((CompilerState)State)._variableNames.Add
  129. (new Functor2(Atom.a("="), makeVariableName(variable, VariableNameSuggestions, ++xCounter),
  130. variable));
  131. }
  132. private static object makeVariableName(object variable, object variableNameSuggestions, int xCounter)
  133. {
  134. // Debug: should require named variables to start with _ or capital. Should
  135. // check for duplicates and clashes with keywords.
  136. for (object element = YP.getValue(variableNameSuggestions);
  137. element is Functor2 && ((Functor2)element)._name == Atom.DOT;
  138. element = YP.getValue(((Functor2)element)._arg2))
  139. {
  140. object suggestionPair = YP.getValue(((Functor2)element)._arg1);
  141. if (sameVariable(variable, ((Functor2)suggestionPair)._arg2))
  142. {
  143. Atom suggestion = (Atom)YP.getValue(((Functor2)suggestionPair)._arg1);
  144. if (suggestion.Equals(Atom.a("Atom")))
  145. suggestion = Atom.a("Atom_1");
  146. if (suggestion.Equals(Atom.a("Variable")))
  147. suggestion = Atom.a("Variable_1");
  148. if (suggestion.Equals(Atom.a("Functor")))
  149. suggestion = Atom.a("Functor_1");
  150. return suggestion;
  151. }
  152. }
  153. return Atom.a("x" + xCounter);
  154. }
  155. /// <summary>
  156. /// Unify Result with the name assigned by CompilerState.newVariableNames in State._variableNames
  157. /// for variable.
  158. /// </summary>
  159. /// <param name="variable">a Variable</param>
  160. /// <param name="State"></param>
  161. /// <param name="Result">the assigned Name</param>
  162. public static IEnumerable<bool> getVariableName(object State, object variable, object Result)
  163. {
  164. State = YP.getValue(State);
  165. foreach (object variableInfo in ((CompilerState)State)._variableNames)
  166. {
  167. if (variableInfo is Functor2 && ((Functor2)variableInfo)._name.Equals(Atom.a("=")))
  168. {
  169. if (sameVariable(variable, ((Functor2)variableInfo)._arg2))
  170. return YP.unify(Result, ((Functor2)variableInfo)._arg1);
  171. }
  172. }
  173. // We set up names for all unique variables, so this should never happen.
  174. throw new PrologException(Atom.a("Can't find entry in _variableNames"));
  175. }
  176. public static IEnumerable<bool> variableNamesList(object State, object VariableNamesList)
  177. {
  178. State = YP.getValue(State);
  179. return YP.unify(VariableNamesList, ListPair.make(((CompilerState)State)._variableNames));
  180. }
  181. public static IEnumerable<bool> gensym(object State, object Base, object Symbol)
  182. {
  183. State = YP.getValue(State);
  184. return YP.unify(Symbol, Atom.a(Base.ToString() + ++((CompilerState)State)._gensymCounter));
  185. }
  186. public static bool isDetNoneOut(object State, object Term)
  187. {
  188. State = YP.getValue(State);
  189. object functorName = YP.getFunctorName(Term);
  190. object[] functorArgs = YP.getFunctorArgs(Term);
  191. Variable pred = new Variable();
  192. // disable warning: don't see how we can code this differently short
  193. // of rewriting the whole thing
  194. #pragma warning disable 0168
  195. foreach (bool l1 in ((CompilerState)State)._pred.match
  196. (new object[] { functorName, functorArgs.Length, pred, Atom.a("det") }))
  197. {
  198. if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
  199. {
  200. return true;
  201. }
  202. }
  203. #pragma warning restore 0168
  204. return false;
  205. }
  206. public static bool isSemidetNoneOut(object State, object Term)
  207. {
  208. State = YP.getValue(State);
  209. object functorName = YP.getFunctorName(Term);
  210. object[] functorArgs = YP.getFunctorArgs(Term);
  211. Variable pred = new Variable();
  212. // disable warning: don't see how we can code this differently short
  213. // of rewriting the whole thing
  214. #pragma warning disable 0168
  215. foreach (bool l1 in ((CompilerState)State)._pred.match
  216. (new object[] { functorName, functorArgs.Length, pred, Atom.a("semidet") }))
  217. {
  218. if (CompilerState.isNoneOut(YP.getFunctorArgs(pred.getValue())))
  219. {
  220. return true;
  221. }
  222. }
  223. #pragma warning restore 0168
  224. return false;
  225. }
  226. /// <summary>
  227. /// Return false if any of args is out, otherwise true.
  228. /// args is an array of ::(Type,Mode) where Mode is in or out.
  229. /// </summary>
  230. /// <param name="args"></param>
  231. /// <returns></returns>
  232. private static bool isNoneOut(object[] args)
  233. {
  234. foreach (object arg in args)
  235. {
  236. if (arg is Functor2 && ((Functor2)arg)._name == Atom.a("::") &&
  237. ((Functor2)arg)._arg2 == Atom.a("out"))
  238. return false;
  239. }
  240. return true;
  241. }
  242. public static bool nameArityHasModule(object State, object Name, object Arity, object Module)
  243. {
  244. State = YP.getValue(State);
  245. Name = YP.getValue(Name);
  246. Arity = YP.getValue(Arity);
  247. Module = YP.getValue(Module);
  248. if (Name is Atom && Arity is int)
  249. {
  250. Atom FoundModule;
  251. if (!((CompilerState)State)._moduleForNameArity.TryGetValue
  252. (new YP.NameArity((Atom)Name, (int)Arity), out FoundModule))
  253. return false;
  254. return FoundModule == Module;
  255. }
  256. return false;
  257. }
  258. }
  259. // disable warning unused variables, the following code is
  260. // infested with it.
  261. #pragma warning disable 0168, 0219
  262. /// <summary>
  263. /// Use makeFunctionPseudoCode, convertFunctionCSharp and compileAnonymousFunction
  264. /// to return an anonymous YP.IClause for the Head and Body of a rule clause.
  265. /// </summary>
  266. /// <param name="Head">a prolog term such as new Functor2("test1", X, Y).
  267. /// Note that the name of the head is ignored.
  268. /// </param>
  269. /// <param name="Body">a prolog term such as
  270. /// new Functor2(",", new Functor1(Atom.a("test2", Atom.a("")), X),
  271. /// new Functor2("=", Y, X)).
  272. /// This may not be null. (For a head-only clause, set the Body to Atom.a("true").
  273. /// </param>
  274. /// <param name="declaringClass">if not null, the code is compiled as a subclass of this class
  275. /// to resolve references to the default module Atom.a("")</param>
  276. /// <returns>a new YP.IClause object on which you can call match(object[] args) where
  277. /// args length is the arity of the Head</returns>
  278. public static YP.IClause compileAnonymousClause(object Head, object Body, Type declaringClass)
  279. {
  280. object[] args = YP.getFunctorArgs(Head);
  281. // compileAnonymousFunction wants "function".
  282. object Rule = new Functor2(Atom.RULE, Functor.make("function", args), Body);
  283. object RuleList = ListPair.make(new Functor2(Atom.F, Rule, Atom.NIL));
  284. StringWriter functionCode = new StringWriter();
  285. Variable SaveOutputStream = new Variable();
  286. foreach (bool l1 in YP.current_output(SaveOutputStream))
  287. {
  288. try
  289. {
  290. YP.tell(functionCode);
  291. Variable FunctionCode = new Variable();
  292. foreach (bool l2 in makeFunctionPseudoCode(RuleList, FunctionCode))
  293. {
  294. if (YP.termEqual(FunctionCode, Atom.a("getDeclaringClass")))
  295. // Ignore getDeclaringClass since we have access to the one passed in.
  296. continue;
  297. // Debug: should check if FunctionCode is a single call.
  298. convertFunctionCSharp(FunctionCode);
  299. }
  300. YP.told();
  301. }
  302. finally
  303. {
  304. // Restore after calling tell.
  305. YP.tell(SaveOutputStream.getValue());
  306. }
  307. }
  308. return YPCompiler.compileAnonymousFunction
  309. (functionCode.ToString(), args.Length, declaringClass);
  310. }
  311. /// <summary>
  312. /// Use CodeDomProvider to compile the functionCode and return a YP.IClause.
  313. /// The function name must be "function" and have nArgs arguments.
  314. /// </summary>
  315. /// <param name="functionCode">the code for the iterator, such as
  316. /// "public static IEnumerable<bool> function() { yield return false; }"
  317. /// </param>
  318. /// <param name="nArgs">the number of args in the function</param>
  319. /// <param name="declaringClass">if not null, then use the functionCode inside a class which
  320. /// inherits from contextClass, so that references in functionCode to methods in declaringClass don't
  321. /// have to be qualified</param>
  322. /// <returns>a new YP.IClause object on which you can call match(object[] args) where
  323. /// args length is nArgs</returns>
  324. public static YP.IClause compileAnonymousFunction(string functionCode, int nArgs, Type declaringClass)
  325. {
  326. CompilerParameters parameters = new CompilerParameters();
  327. // This gets the location of the System assembly.
  328. parameters.ReferencedAssemblies.Add(typeof(System.Int32).Assembly.Location);
  329. // This gets the location of this assembly which also has YieldProlog.YP, etc.
  330. parameters.ReferencedAssemblies.Add(typeof(YPCompiler).Assembly.Location);
  331. if (declaringClass != null)
  332. parameters.ReferencedAssemblies.Add(declaringClass.Assembly.Location);
  333. parameters.GenerateInMemory = true;
  334. StringBuilder sourceCode = new StringBuilder();
  335. sourceCode.Append(@"
  336. using System;
  337. using System.Collections.Generic;
  338. using OpenSim.Region.ScriptEngine.Shared.YieldProlog;
  339. namespace Temporary {
  340. public class Temporary : YP.IClause {
  341. public class Inner" + (declaringClass == null ? "" : " : " + declaringClass.FullName) + @" {
  342. ");
  343. sourceCode.Append(functionCode);
  344. // Basically, match applies the args to function.
  345. sourceCode.Append(@"
  346. }
  347. public IEnumerable<bool> match(object[] args) {
  348. return Inner.function(");
  349. if (nArgs >= 1)
  350. sourceCode.Append("args[0]");
  351. for (int i = 1; i < nArgs; ++i)
  352. sourceCode.Append(", args[" + i + "]");
  353. sourceCode.Append(@");
  354. }
  355. }
  356. }
  357. ");
  358. CompilerResults results = CodeDomProvider.CreateProvider
  359. ("CSharp").CompileAssemblyFromSource(parameters, sourceCode.ToString());
  360. if (results.Errors.Count > 0)
  361. throw new Exception("Error evaluating code: " + results.Errors[0]);
  362. // Return a new Temporary.Temporary object.
  363. return (YP.IClause)results.CompiledAssembly.GetType
  364. ("Temporary.Temporary").GetConstructor(Type.EmptyTypes).Invoke(null);
  365. }
  366. // Compiler output follows.
  367. public class YPInnerClass { }
  368. public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }
  369. public static void repeatWrite(object arg1, object N)
  370. {
  371. {
  372. object _Value = arg1;
  373. if (YP.termEqual(N, 0))
  374. {
  375. return;
  376. }
  377. }
  378. {
  379. object Value = arg1;
  380. Variable NextN = new Variable();
  381. YP.write(Value);
  382. foreach (bool l2 in YP.unify(NextN, YP.subtract(N, 1)))
  383. {
  384. repeatWrite(Value, NextN);
  385. return;
  386. }
  387. }
  388. }
  389. public static bool sameVariable(object Variable1, object Variable2)
  390. {
  391. {
  392. if (YP.var(Variable1))
  393. {
  394. if (YP.var(Variable2))
  395. {
  396. if (YP.termEqual(Variable1, Variable2))
  397. {
  398. return true;
  399. }
  400. }
  401. }
  402. }
  403. return false;
  404. }
  405. public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode)
  406. {
  407. {
  408. Variable State = new Variable();
  409. foreach (bool l2 in CompilerState.make(State))
  410. {
  411. CompilerState.assertPred(State, Atom.a(@"nl"), Atom.a(@"det"));
  412. CompilerState.assertPred(State, new Functor1(@"write", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
  413. CompilerState.assertPred(State, new Functor1(@"put_code", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
  414. CompilerState.assertPred(State, new Functor1(@"throw", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"det"));
  415. CompilerState.assertPred(State, new Functor1(@"var", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  416. CompilerState.assertPred(State, new Functor1(@"nonvar", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  417. CompilerState.assertPred(State, new Functor1(@"atom", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  418. CompilerState.assertPred(State, new Functor1(@"integer", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  419. CompilerState.assertPred(State, new Functor1(@"float", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  420. CompilerState.assertPred(State, new Functor1(@"number", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  421. CompilerState.assertPred(State, new Functor1(@"atomic", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  422. CompilerState.assertPred(State, new Functor1(@"compound", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  423. CompilerState.assertPred(State, new Functor2(@"==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  424. CompilerState.assertPred(State, new Functor2(@"\==", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  425. CompilerState.assertPred(State, new Functor2(@"@<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  426. CompilerState.assertPred(State, new Functor2(@"@=<", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  427. CompilerState.assertPred(State, new Functor2(@"@>", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  428. CompilerState.assertPred(State, new Functor2(@"@>=", new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in")), new Functor2(@"::", Atom.a(@"univ"), Atom.a(@"in"))), Atom.a(@"semidet"));
  429. processCompilerDirectives(RuleList, State);
  430. foreach (bool l3 in YP.unify(FunctionCode, Atom.a(@"getDeclaringClass")))
  431. {
  432. yield return false;
  433. }
  434. foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode))
  435. {
  436. yield return false;
  437. }
  438. }
  439. }
  440. }
  441. public static void processCompilerDirectives(object arg1, object arg2)
  442. {
  443. {
  444. object _State = arg2;
  445. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  446. {
  447. return;
  448. }
  449. }
  450. {
  451. object State = arg2;
  452. Variable Pred = new Variable();
  453. Variable Determinism = new Variable();
  454. Variable x3 = new Variable();
  455. Variable RestRules = new Variable();
  456. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor1(@"pred", new Functor2(@"is", Pred, Determinism))), x3), RestRules)))
  457. {
  458. CompilerState.assertPred(State, Pred, Determinism);
  459. processCompilerDirectives(RestRules, State);
  460. return;
  461. }
  462. }
  463. {
  464. object State = arg2;
  465. Variable Module = new Variable();
  466. Variable PredicateList = new Variable();
  467. Variable x3 = new Variable();
  468. Variable RestRules = new Variable();
  469. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", new Functor2(@"import", Module, PredicateList)), x3), RestRules)))
  470. {
  471. foreach (bool l3 in importPredicateList(State, Module, PredicateList))
  472. {
  473. processCompilerDirectives(RestRules, State);
  474. return;
  475. }
  476. }
  477. }
  478. {
  479. object State = arg2;
  480. Variable x1 = new Variable();
  481. Variable x2 = new Variable();
  482. Variable RestRules = new Variable();
  483. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor1(@":-", x1), x2), RestRules)))
  484. {
  485. processCompilerDirectives(RestRules, State);
  486. return;
  487. }
  488. }
  489. {
  490. object State = arg2;
  491. Variable Head = new Variable();
  492. Variable _Body = new Variable();
  493. Variable x3 = new Variable();
  494. Variable RestRules = new Variable();
  495. Variable Name = new Variable();
  496. Variable Arity = new Variable();
  497. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", new Functor2(@":-", Head, _Body), x3), RestRules)))
  498. {
  499. foreach (bool l3 in YP.functor(Head, Name, Arity))
  500. {
  501. CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
  502. processCompilerDirectives(RestRules, State);
  503. return;
  504. }
  505. }
  506. }
  507. {
  508. object State = arg2;
  509. Variable Fact = new Variable();
  510. Variable x2 = new Variable();
  511. Variable RestRules = new Variable();
  512. Variable Name = new Variable();
  513. Variable Arity = new Variable();
  514. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", Fact, x2), RestRules)))
  515. {
  516. foreach (bool l3 in YP.functor(Fact, Name, Arity))
  517. {
  518. CompilerState.assertModuleForNameArity(State, Name, Arity, Atom.a(@""));
  519. processCompilerDirectives(RestRules, State);
  520. return;
  521. }
  522. }
  523. }
  524. {
  525. object State = arg2;
  526. Variable x1 = new Variable();
  527. Variable RestRules = new Variable();
  528. foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestRules)))
  529. {
  530. processCompilerDirectives(RestRules, State);
  531. return;
  532. }
  533. }
  534. }
  535. public static IEnumerable<bool> importPredicateList(object arg1, object arg2, object arg3)
  536. {
  537. {
  538. object _State = arg1;
  539. object _Module = arg2;
  540. foreach (bool l2 in YP.unify(arg3, Atom.NIL))
  541. {
  542. yield return true;
  543. yield break;
  544. }
  545. }
  546. {
  547. object State = arg1;
  548. object Module = arg2;
  549. Variable Name = new Variable();
  550. Variable Arity = new Variable();
  551. Variable Rest = new Variable();
  552. foreach (bool l2 in YP.unify(arg3, new ListPair(new Functor2(@"/", Name, Arity), Rest)))
  553. {
  554. CompilerState.assertModuleForNameArity(State, Name, Arity, Module);
  555. foreach (bool l3 in importPredicateList(State, Module, Rest))
  556. {
  557. yield return true;
  558. yield break;
  559. }
  560. }
  561. }
  562. {
  563. object State = arg1;
  564. object Module = arg2;
  565. Variable x3 = new Variable();
  566. Variable Rest = new Variable();
  567. foreach (bool l2 in YP.unify(arg3, new ListPair(x3, Rest)))
  568. {
  569. foreach (bool l3 in importPredicateList(State, Module, Rest))
  570. {
  571. yield return true;
  572. yield break;
  573. }
  574. }
  575. }
  576. }
  577. public static IEnumerable<bool> makeFunctionPseudoCode3(object RuleList, object State, object FunctionCode)
  578. {
  579. {
  580. Variable SamePredicateRuleList = new Variable();
  581. Variable RestRules = new Variable();
  582. foreach (bool l2 in samePredicateRuleList(RuleList, SamePredicateRuleList, RestRules))
  583. {
  584. if (YP.termNotEqual(SamePredicateRuleList, Atom.NIL))
  585. {
  586. foreach (bool l4 in compileSamePredicateFunction(SamePredicateRuleList, State, FunctionCode))
  587. {
  588. yield return false;
  589. }
  590. foreach (bool l4 in makeFunctionPseudoCode3(RestRules, State, FunctionCode))
  591. {
  592. yield return false;
  593. }
  594. }
  595. }
  596. }
  597. }
  598. public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode)
  599. {
  600. {
  601. Variable FirstRule = new Variable();
  602. Variable x5 = new Variable();
  603. Variable x6 = new Variable();
  604. Variable x7 = new Variable();
  605. Variable Head = new Variable();
  606. Variable x9 = new Variable();
  607. Variable ArgAssignments = new Variable();
  608. Variable Calls = new Variable();
  609. Variable Rule = new Variable();
  610. Variable VariableNameSuggestions = new Variable();
  611. Variable ClauseBag = new Variable();
  612. Variable Name = new Variable();
  613. Variable ArgsList = new Variable();
  614. Variable FunctionArgNames = new Variable();
  615. Variable MergedArgName = new Variable();
  616. Variable ArgName = new Variable();
  617. Variable MergedArgNames = new Variable();
  618. Variable FunctionArgs = new Variable();
  619. Variable BodyCode = new Variable();
  620. Variable ReturnType = new Variable();
  621. Variable BodyWithReturn = new Variable();
  622. foreach (bool l2 in YP.unify(new ListPair(new Functor2(@"f", FirstRule, x5), x6), SamePredicateRuleList))
  623. {
  624. foreach (bool l3 in YP.unify(FirstRule, new Functor1(@":-", x7)))
  625. {
  626. goto cutIf1;
  627. }
  628. foreach (bool l3 in YP.unify(new Functor2(@":-", Head, x9), FirstRule))
  629. {
  630. CompilerState.startFunction(State, Head);
  631. FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
  632. foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
  633. {
  634. foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
  635. {
  636. findallAnswers3.add();
  637. }
  638. }
  639. foreach (bool l4 in findallAnswers3.result(ClauseBag))
  640. {
  641. foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
  642. {
  643. foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
  644. {
  645. FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName);
  646. foreach (bool l7 in member(ArgName, FunctionArgNames))
  647. {
  648. foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
  649. {
  650. findallAnswers4.add();
  651. goto cutIf5;
  652. }
  653. foreach (bool l8 in YP.unify(MergedArgName, ArgName))
  654. {
  655. findallAnswers4.add();
  656. }
  657. cutIf5:
  658. { }
  659. }
  660. foreach (bool l7 in findallAnswers4.result(MergedArgNames))
  661. {
  662. foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
  663. {
  664. foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
  665. {
  666. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  667. {
  668. foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
  669. {
  670. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  671. {
  672. foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
  673. {
  674. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  675. {
  676. yield return false;
  677. }
  678. }
  679. goto cutIf7;
  680. }
  681. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  682. {
  683. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  684. {
  685. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  686. {
  687. yield return false;
  688. }
  689. }
  690. goto cutIf8;
  691. }
  692. if (CompilerState.codeUsesYield(State))
  693. {
  694. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  695. {
  696. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  697. {
  698. yield return false;
  699. }
  700. }
  701. goto cutIf9;
  702. }
  703. foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
  704. {
  705. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  706. {
  707. yield return false;
  708. }
  709. }
  710. cutIf9:
  711. cutIf8:
  712. cutIf7:
  713. { }
  714. }
  715. goto cutIf6;
  716. }
  717. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  718. {
  719. foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
  720. {
  721. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  722. {
  723. foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
  724. {
  725. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  726. {
  727. yield return false;
  728. }
  729. }
  730. goto cutIf11;
  731. }
  732. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  733. {
  734. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  735. {
  736. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  737. {
  738. yield return false;
  739. }
  740. }
  741. goto cutIf12;
  742. }
  743. if (CompilerState.codeUsesYield(State))
  744. {
  745. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  746. {
  747. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  748. {
  749. yield return false;
  750. }
  751. }
  752. goto cutIf13;
  753. }
  754. foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
  755. {
  756. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  757. {
  758. yield return false;
  759. }
  760. }
  761. cutIf13:
  762. cutIf12:
  763. cutIf11:
  764. { }
  765. }
  766. goto cutIf10;
  767. }
  768. foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
  769. {
  770. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  771. {
  772. foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
  773. {
  774. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  775. {
  776. yield return false;
  777. }
  778. }
  779. goto cutIf14;
  780. }
  781. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  782. {
  783. foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
  784. {
  785. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  786. {
  787. yield return false;
  788. }
  789. }
  790. goto cutIf15;
  791. }
  792. if (CompilerState.codeUsesYield(State))
  793. {
  794. foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
  795. {
  796. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  797. {
  798. yield return false;
  799. }
  800. }
  801. goto cutIf16;
  802. }
  803. foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
  804. {
  805. foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  806. {
  807. yield return false;
  808. }
  809. }
  810. cutIf16:
  811. cutIf15:
  812. cutIf14:
  813. { }
  814. }
  815. cutIf10:
  816. cutIf6:
  817. { }
  818. }
  819. }
  820. }
  821. }
  822. }
  823. }
  824. goto cutIf2;
  825. }
  826. foreach (bool l3 in YP.unify(Head, FirstRule))
  827. {
  828. CompilerState.startFunction(State, Head);
  829. FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2(@"f", ArgAssignments, Calls));
  830. foreach (bool l4 in member(new Functor2(@"f", Rule, VariableNameSuggestions), SamePredicateRuleList))
  831. {
  832. foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
  833. {
  834. findallAnswers17.add();
  835. }
  836. }
  837. foreach (bool l4 in findallAnswers17.result(ClauseBag))
  838. {
  839. foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
  840. {
  841. foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
  842. {
  843. FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName);
  844. foreach (bool l7 in member(ArgName, FunctionArgNames))
  845. {
  846. foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
  847. {
  848. findallAnswers18.add();
  849. goto cutIf19;
  850. }
  851. foreach (bool l8 in YP.unify(MergedArgName, ArgName))
  852. {
  853. findallAnswers18.add();
  854. }
  855. cutIf19:
  856. { }
  857. }
  858. foreach (bool l7 in findallAnswers18.result(MergedArgNames))
  859. {
  860. foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
  861. {
  862. foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
  863. {
  864. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  865. {
  866. foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"void")))
  867. {
  868. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  869. {
  870. foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
  871. {
  872. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  873. {
  874. yield return false;
  875. }
  876. }
  877. goto cutIf21;
  878. }
  879. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  880. {
  881. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  882. {
  883. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  884. {
  885. yield return false;
  886. }
  887. }
  888. goto cutIf22;
  889. }
  890. if (CompilerState.codeUsesYield(State))
  891. {
  892. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  893. {
  894. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  895. {
  896. yield return false;
  897. }
  898. }
  899. goto cutIf23;
  900. }
  901. foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
  902. {
  903. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  904. {
  905. yield return false;
  906. }
  907. }
  908. cutIf23:
  909. cutIf22:
  910. cutIf21:
  911. { }
  912. }
  913. goto cutIf20;
  914. }
  915. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  916. {
  917. foreach (bool l11 in YP.unify(ReturnType, Atom.a(@"bool")))
  918. {
  919. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  920. {
  921. foreach (bool l13 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
  922. {
  923. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  924. {
  925. yield return false;
  926. }
  927. }
  928. goto cutIf25;
  929. }
  930. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  931. {
  932. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  933. {
  934. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  935. {
  936. yield return false;
  937. }
  938. }
  939. goto cutIf26;
  940. }
  941. if (CompilerState.codeUsesYield(State))
  942. {
  943. foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
  944. {
  945. foreach (bool l14 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  946. {
  947. yield return false;
  948. }
  949. }
  950. goto cutIf27;
  951. }
  952. foreach (bool l12 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
  953. {
  954. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  955. {
  956. yield return false;
  957. }
  958. }
  959. cutIf27:
  960. cutIf26:
  961. cutIf25:
  962. { }
  963. }
  964. goto cutIf24;
  965. }
  966. foreach (bool l10 in YP.unify(ReturnType, Atom.a(@"IEnumerable<bool>")))
  967. {
  968. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  969. {
  970. foreach (bool l12 in append(BodyCode, new ListPair(Atom.a(@"returnfalse"), Atom.NIL), BodyWithReturn))
  971. {
  972. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  973. {
  974. yield return false;
  975. }
  976. }
  977. goto cutIf28;
  978. }
  979. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  980. {
  981. foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
  982. {
  983. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  984. {
  985. yield return false;
  986. }
  987. }
  988. goto cutIf29;
  989. }
  990. if (CompilerState.codeUsesYield(State))
  991. {
  992. foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
  993. {
  994. foreach (bool l13 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  995. {
  996. yield return false;
  997. }
  998. }
  999. goto cutIf30;
  1000. }
  1001. foreach (bool l11 in append(BodyCode, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.fail"), Atom.NIL), new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)), Atom.NIL), BodyWithReturn))
  1002. {
  1003. foreach (bool l12 in YP.unify(FunctionCode, new Functor(@"function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
  1004. {
  1005. yield return false;
  1006. }
  1007. }
  1008. cutIf30:
  1009. cutIf29:
  1010. cutIf28:
  1011. { }
  1012. }
  1013. cutIf24:
  1014. cutIf20:
  1015. { }
  1016. }
  1017. }
  1018. }
  1019. }
  1020. }
  1021. }
  1022. }
  1023. cutIf2:
  1024. cutIf1:
  1025. { }
  1026. }
  1027. }
  1028. }
  1029. public static IEnumerable<bool> samePredicateRuleList(object arg1, object arg2, object arg3)
  1030. {
  1031. {
  1032. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1033. {
  1034. foreach (bool l3 in YP.unify(arg2, Atom.NIL))
  1035. {
  1036. foreach (bool l4 in YP.unify(arg3, Atom.NIL))
  1037. {
  1038. yield return true;
  1039. yield break;
  1040. }
  1041. }
  1042. }
  1043. }
  1044. {
  1045. Variable First = new Variable();
  1046. foreach (bool l2 in YP.unify(arg1, new ListPair(First, Atom.NIL)))
  1047. {
  1048. foreach (bool l3 in YP.unify(arg2, new ListPair(First, Atom.NIL)))
  1049. {
  1050. foreach (bool l4 in YP.unify(arg3, Atom.NIL))
  1051. {
  1052. yield return true;
  1053. yield break;
  1054. }
  1055. }
  1056. }
  1057. }
  1058. {
  1059. object SamePredicateRuleList = arg2;
  1060. object RestRules = arg3;
  1061. Variable First = new Variable();
  1062. Variable Rest = new Variable();
  1063. Variable FirstRule = new Variable();
  1064. Variable x6 = new Variable();
  1065. Variable SecondRule = new Variable();
  1066. Variable x8 = new Variable();
  1067. Variable x9 = new Variable();
  1068. Variable FirstHead = new Variable();
  1069. Variable x11 = new Variable();
  1070. Variable SecondHead = new Variable();
  1071. Variable x13 = new Variable();
  1072. Variable Name = new Variable();
  1073. Variable Arity = new Variable();
  1074. Variable RestSamePredicates = new Variable();
  1075. foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
  1076. {
  1077. foreach (bool l3 in YP.unify(new Functor2(@"f", FirstRule, x6), First))
  1078. {
  1079. foreach (bool l4 in YP.unify(new ListPair(new Functor2(@"f", SecondRule, x8), x9), Rest))
  1080. {
  1081. foreach (bool l5 in YP.unify(new Functor2(@":-", FirstHead, x11), FirstRule))
  1082. {
  1083. foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
  1084. {
  1085. foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
  1086. {
  1087. foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
  1088. {
  1089. foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
  1090. {
  1091. foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
  1092. {
  1093. yield return true;
  1094. yield break;
  1095. }
  1096. }
  1097. goto cutIf3;
  1098. }
  1099. foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
  1100. {
  1101. foreach (bool l9 in YP.unify(RestRules, Rest))
  1102. {
  1103. yield return true;
  1104. yield break;
  1105. }
  1106. }
  1107. cutIf3:
  1108. { }
  1109. }
  1110. goto cutIf2;
  1111. }
  1112. foreach (bool l6 in YP.unify(SecondHead, SecondRule))
  1113. {
  1114. foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
  1115. {
  1116. foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
  1117. {
  1118. foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
  1119. {
  1120. foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
  1121. {
  1122. yield return true;
  1123. yield break;
  1124. }
  1125. }
  1126. goto cutIf4;
  1127. }
  1128. foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
  1129. {
  1130. foreach (bool l9 in YP.unify(RestRules, Rest))
  1131. {
  1132. yield return true;
  1133. yield break;
  1134. }
  1135. }
  1136. cutIf4:
  1137. { }
  1138. }
  1139. }
  1140. cutIf2:
  1141. goto cutIf1;
  1142. }
  1143. foreach (bool l5 in YP.unify(FirstHead, FirstRule))
  1144. {
  1145. foreach (bool l6 in YP.unify(new Functor2(@":-", SecondHead, x13), SecondRule))
  1146. {
  1147. foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
  1148. {
  1149. foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
  1150. {
  1151. foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
  1152. {
  1153. foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
  1154. {
  1155. yield return true;
  1156. yield break;
  1157. }
  1158. }
  1159. goto cutIf6;
  1160. }
  1161. foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
  1162. {
  1163. foreach (bool l9 in YP.unify(RestRules, Rest))
  1164. {
  1165. yield return true;
  1166. yield break;
  1167. }
  1168. }
  1169. cutIf6:
  1170. { }
  1171. }
  1172. goto cutIf5;
  1173. }
  1174. foreach (bool l6 in YP.unify(SecondHead, SecondRule))
  1175. {
  1176. foreach (bool l7 in YP.functor(FirstHead, Name, Arity))
  1177. {
  1178. foreach (bool l8 in YP.functor(SecondHead, Name, Arity))
  1179. {
  1180. foreach (bool l9 in samePredicateRuleList(Rest, RestSamePredicates, RestRules))
  1181. {
  1182. foreach (bool l10 in YP.unify(SamePredicateRuleList, new ListPair(First, RestSamePredicates)))
  1183. {
  1184. yield return true;
  1185. yield break;
  1186. }
  1187. }
  1188. goto cutIf7;
  1189. }
  1190. foreach (bool l8 in YP.unify(SamePredicateRuleList, new ListPair(First, Atom.NIL)))
  1191. {
  1192. foreach (bool l9 in YP.unify(RestRules, Rest))
  1193. {
  1194. yield return true;
  1195. yield break;
  1196. }
  1197. }
  1198. cutIf7:
  1199. { }
  1200. }
  1201. }
  1202. cutIf5:
  1203. { }
  1204. }
  1205. cutIf1:
  1206. { }
  1207. }
  1208. }
  1209. }
  1210. }
  1211. }
  1212. public static IEnumerable<bool> maplist_compileClause(object arg1, object arg2, object arg3)
  1213. {
  1214. {
  1215. object _MergedArgNames = arg2;
  1216. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1217. {
  1218. foreach (bool l3 in YP.unify(arg3, Atom.NIL))
  1219. {
  1220. yield return true;
  1221. yield break;
  1222. }
  1223. }
  1224. }
  1225. {
  1226. object MergedArgNames = arg2;
  1227. Variable ArgAssignments = new Variable();
  1228. Variable Calls = new Variable();
  1229. Variable Rest = new Variable();
  1230. Variable ClauseCode = new Variable();
  1231. Variable RestResults = new Variable();
  1232. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", ArgAssignments, Calls), Rest)))
  1233. {
  1234. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"blockScope", ClauseCode), RestResults)))
  1235. {
  1236. foreach (bool l4 in prependArgAssignments(ArgAssignments, Calls, MergedArgNames, ClauseCode))
  1237. {
  1238. foreach (bool l5 in maplist_compileClause(Rest, MergedArgNames, RestResults))
  1239. {
  1240. yield return true;
  1241. yield break;
  1242. }
  1243. }
  1244. }
  1245. }
  1246. }
  1247. }
  1248. public static IEnumerable<bool> prependArgAssignments(object arg1, object arg2, object arg3, object arg4)
  1249. {
  1250. {
  1251. object _MergedArgNames = arg3;
  1252. Variable In = new Variable();
  1253. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1254. {
  1255. foreach (bool l3 in YP.unify(arg2, In))
  1256. {
  1257. foreach (bool l4 in YP.unify(arg4, In))
  1258. {
  1259. yield return true;
  1260. yield break;
  1261. }
  1262. }
  1263. }
  1264. }
  1265. {
  1266. object In = arg2;
  1267. object MergedArgNames = arg3;
  1268. object ClauseCode = arg4;
  1269. Variable VariableName = new Variable();
  1270. Variable ArgName = new Variable();
  1271. Variable RestArgAssignments = new Variable();
  1272. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"f", VariableName, ArgName), RestArgAssignments)))
  1273. {
  1274. foreach (bool l3 in member(VariableName, MergedArgNames))
  1275. {
  1276. foreach (bool l4 in prependArgAssignments(RestArgAssignments, In, MergedArgNames, ClauseCode))
  1277. {
  1278. yield return true;
  1279. yield break;
  1280. }
  1281. goto cutIf1;
  1282. }
  1283. foreach (bool l3 in prependArgAssignments(RestArgAssignments, new ListPair(new Functor3(@"declare", Atom.a(@"object"), VariableName, new Functor1(@"var", ArgName)), In), MergedArgNames, ClauseCode))
  1284. {
  1285. yield return true;
  1286. yield break;
  1287. }
  1288. cutIf1:
  1289. { }
  1290. }
  1291. }
  1292. }
  1293. public static IEnumerable<bool> argAssignedAll(object arg1, object arg2, object VariableName)
  1294. {
  1295. {
  1296. object _ArgName = arg1;
  1297. foreach (bool l2 in YP.unify(arg2, Atom.NIL))
  1298. {
  1299. if (YP.nonvar(VariableName))
  1300. {
  1301. yield return true;
  1302. yield break;
  1303. }
  1304. }
  1305. }
  1306. {
  1307. object ArgName = arg1;
  1308. Variable ArgAssignments = new Variable();
  1309. Variable _Calls = new Variable();
  1310. Variable RestClauseBag = new Variable();
  1311. foreach (bool l2 in YP.unify(arg2, new ListPair(new Functor2(@"f", ArgAssignments, _Calls), RestClauseBag)))
  1312. {
  1313. foreach (bool l3 in member(new Functor2(@"f", VariableName, ArgName), ArgAssignments))
  1314. {
  1315. foreach (bool l4 in argAssignedAll(ArgName, RestClauseBag, VariableName))
  1316. {
  1317. yield return false;
  1318. }
  1319. }
  1320. }
  1321. }
  1322. }
  1323. public static IEnumerable<bool> maplist_arg(object arg1, object arg2)
  1324. {
  1325. {
  1326. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1327. {
  1328. foreach (bool l3 in YP.unify(arg2, Atom.NIL))
  1329. {
  1330. yield return true;
  1331. yield break;
  1332. }
  1333. }
  1334. }
  1335. {
  1336. Variable First = new Variable();
  1337. Variable Rest = new Variable();
  1338. Variable RestResults = new Variable();
  1339. foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
  1340. {
  1341. foreach (bool l3 in YP.unify(arg2, new ListPair(new Functor1(@"arg", First), RestResults)))
  1342. {
  1343. foreach (bool l4 in maplist_arg(Rest, RestResults))
  1344. {
  1345. yield return true;
  1346. yield break;
  1347. }
  1348. }
  1349. }
  1350. }
  1351. }
  1352. public static IEnumerable<bool> getFunctionArgNames(object arg1, object arg2, object arg3)
  1353. {
  1354. {
  1355. object _StartArgNumber = arg2;
  1356. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1357. {
  1358. foreach (bool l3 in YP.unify(arg3, Atom.NIL))
  1359. {
  1360. yield return true;
  1361. yield break;
  1362. }
  1363. }
  1364. }
  1365. {
  1366. object StartArgNumber = arg2;
  1367. Variable x1 = new Variable();
  1368. Variable Rest = new Variable();
  1369. Variable ArgName = new Variable();
  1370. Variable RestFunctionArgs = new Variable();
  1371. Variable NumberCodes = new Variable();
  1372. Variable NumberAtom = new Variable();
  1373. Variable NextArgNumber = new Variable();
  1374. foreach (bool l2 in YP.unify(arg1, new ListPair(x1, Rest)))
  1375. {
  1376. foreach (bool l3 in YP.unify(arg3, new ListPair(ArgName, RestFunctionArgs)))
  1377. {
  1378. foreach (bool l4 in YP.number_codes(StartArgNumber, NumberCodes))
  1379. {
  1380. foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
  1381. {
  1382. foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
  1383. {
  1384. foreach (bool l7 in YP.unify(NextArgNumber, YP.add(StartArgNumber, 1)))
  1385. {
  1386. foreach (bool l8 in getFunctionArgNames(Rest, NextArgNumber, RestFunctionArgs))
  1387. {
  1388. yield return true;
  1389. yield break;
  1390. }
  1391. }
  1392. }
  1393. }
  1394. }
  1395. }
  1396. }
  1397. }
  1398. }
  1399. public static IEnumerable<bool> compileBodyWithHeadBindings(object Rule, object VariableNameSuggestions, object State, object ArgAssignments, object Calls)
  1400. {
  1401. {
  1402. Variable Head = new Variable();
  1403. Variable Body = new Variable();
  1404. Variable x8 = new Variable();
  1405. Variable HeadArgs = new Variable();
  1406. Variable CompiledHeadArgs = new Variable();
  1407. Variable BodyCode = new Variable();
  1408. Variable VariableNamesList = new Variable();
  1409. Variable ArgUnifications = new Variable();
  1410. foreach (bool l2 in YP.unify(new Functor2(@":-", Head, Body), Rule))
  1411. {
  1412. CompilerState.newVariableNames(State, Rule, VariableNameSuggestions);
  1413. foreach (bool l3 in YP.univ(Head, new ListPair(x8, HeadArgs)))
  1414. {
  1415. foreach (bool l4 in maplist_compileTerm(HeadArgs, State, CompiledHeadArgs))
  1416. {
  1417. foreach (bool l5 in compileRuleBody(Body, State, BodyCode))
  1418. {
  1419. foreach (bool l6 in CompilerState.variableNamesList(State, VariableNamesList))
  1420. {
  1421. foreach (bool l7 in compileArgUnifications(HeadArgs, CompiledHeadArgs, 1, HeadArgs, BodyCode, ArgUnifications))
  1422. {
  1423. foreach (bool l8 in compileDeclarations(VariableNamesList, HeadArgs, Atom.NIL, ArgAssignments, ArgUnifications, Calls))
  1424. {
  1425. yield return true;
  1426. yield break;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. }
  1434. }
  1435. {
  1436. foreach (bool l2 in compileBodyWithHeadBindings(new Functor2(@":-", Rule, Atom.a(@"true")), VariableNameSuggestions, State, ArgAssignments, Calls))
  1437. {
  1438. yield return true;
  1439. yield break;
  1440. }
  1441. }
  1442. }
  1443. public static IEnumerable<bool> compileArgUnifications(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
  1444. {
  1445. {
  1446. object x1 = arg2;
  1447. object x2 = arg3;
  1448. object x3 = arg4;
  1449. Variable BodyCode = new Variable();
  1450. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1451. {
  1452. foreach (bool l3 in YP.unify(arg5, BodyCode))
  1453. {
  1454. foreach (bool l4 in YP.unify(arg6, BodyCode))
  1455. {
  1456. yield return true;
  1457. yield break;
  1458. }
  1459. }
  1460. }
  1461. }
  1462. {
  1463. object Index = arg3;
  1464. object AllHeadArgs = arg4;
  1465. object BodyCode = arg5;
  1466. object ArgUnifications = arg6;
  1467. Variable HeadArg = new Variable();
  1468. Variable RestHeadArgs = new Variable();
  1469. Variable x3 = new Variable();
  1470. Variable RestCompiledHeadArgs = new Variable();
  1471. Variable _ArgIndex1 = new Variable();
  1472. Variable NextIndex = new Variable();
  1473. foreach (bool l2 in YP.unify(arg1, new ListPair(HeadArg, RestHeadArgs)))
  1474. {
  1475. foreach (bool l3 in YP.unify(arg2, new ListPair(x3, RestCompiledHeadArgs)))
  1476. {
  1477. foreach (bool l4 in getVariableArgIndex1(HeadArg, AllHeadArgs, _ArgIndex1))
  1478. {
  1479. foreach (bool l5 in YP.unify(NextIndex, YP.add(Index, 1)))
  1480. {
  1481. foreach (bool l6 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, ArgUnifications))
  1482. {
  1483. yield return true;
  1484. yield break;
  1485. }
  1486. }
  1487. }
  1488. }
  1489. }
  1490. }
  1491. {
  1492. object Index = arg3;
  1493. object AllHeadArgs = arg4;
  1494. object BodyCode = arg5;
  1495. Variable _HeadArg = new Variable();
  1496. Variable RestHeadArgs = new Variable();
  1497. Variable CompiledHeadArg = new Variable();
  1498. Variable RestCompiledHeadArgs = new Variable();
  1499. Variable ArgName = new Variable();
  1500. Variable RestArgUnifications = new Variable();
  1501. Variable NumberCodes = new Variable();
  1502. Variable NumberAtom = new Variable();
  1503. Variable NextIndex = new Variable();
  1504. foreach (bool l2 in YP.unify(arg1, new ListPair(_HeadArg, RestHeadArgs)))
  1505. {
  1506. foreach (bool l3 in YP.unify(arg2, new ListPair(CompiledHeadArg, RestCompiledHeadArgs)))
  1507. {
  1508. foreach (bool l4 in YP.unify(arg6, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(new Functor1(@"var", ArgName), new ListPair(CompiledHeadArg, Atom.NIL))), RestArgUnifications), Atom.NIL)))
  1509. {
  1510. foreach (bool l5 in YP.number_codes(Index, NumberCodes))
  1511. {
  1512. foreach (bool l6 in YP.atom_codes(NumberAtom, NumberCodes))
  1513. {
  1514. foreach (bool l7 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
  1515. {
  1516. foreach (bool l8 in YP.unify(NextIndex, YP.add(Index, 1)))
  1517. {
  1518. foreach (bool l9 in compileArgUnifications(RestHeadArgs, RestCompiledHeadArgs, NextIndex, AllHeadArgs, BodyCode, RestArgUnifications))
  1519. {
  1520. yield return true;
  1521. yield break;
  1522. }
  1523. }
  1524. }
  1525. }
  1526. }
  1527. }
  1528. }
  1529. }
  1530. }
  1531. }
  1532. public static IEnumerable<bool> compileDeclarations(object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
  1533. {
  1534. {
  1535. object _HeadArgs = arg2;
  1536. Variable ArgAssignmentsIn = new Variable();
  1537. Variable DeclarationsIn = new Variable();
  1538. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  1539. {
  1540. foreach (bool l3 in YP.unify(arg3, ArgAssignmentsIn))
  1541. {
  1542. foreach (bool l4 in YP.unify(arg4, ArgAssignmentsIn))
  1543. {
  1544. foreach (bool l5 in YP.unify(arg5, DeclarationsIn))
  1545. {
  1546. foreach (bool l6 in YP.unify(arg6, DeclarationsIn))
  1547. {
  1548. yield return true;
  1549. yield break;
  1550. }
  1551. }
  1552. }
  1553. }
  1554. }
  1555. }
  1556. {
  1557. object HeadArgs = arg2;
  1558. object ArgAssignmentsIn = arg3;
  1559. object ArgAssignmentsOut = arg4;
  1560. object DeclarationsIn = arg5;
  1561. object DeclarationsOut = arg6;
  1562. Variable VariableName = new Variable();
  1563. Variable Var = new Variable();
  1564. Variable RestVariableNames = new Variable();
  1565. Variable ArgIndex1 = new Variable();
  1566. Variable NumberCodes = new Variable();
  1567. Variable NumberAtom = new Variable();
  1568. Variable ArgName = new Variable();
  1569. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, Var), RestVariableNames)))
  1570. {
  1571. foreach (bool l3 in getVariableArgIndex1(Var, HeadArgs, ArgIndex1))
  1572. {
  1573. foreach (bool l4 in YP.number_codes(ArgIndex1, NumberCodes))
  1574. {
  1575. foreach (bool l5 in YP.atom_codes(NumberAtom, NumberCodes))
  1576. {
  1577. foreach (bool l6 in YP.atom_concat(Atom.a(@"arg"), NumberAtom, ArgName))
  1578. {
  1579. foreach (bool l7 in compileDeclarations(RestVariableNames, HeadArgs, new ListPair(new Functor2(@"f", VariableName, ArgName), ArgAssignmentsIn), ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
  1580. {
  1581. yield return true;
  1582. yield break;
  1583. }
  1584. }
  1585. }
  1586. }
  1587. }
  1588. }
  1589. }
  1590. {
  1591. object HeadArgs = arg2;
  1592. object ArgAssignmentsIn = arg3;
  1593. object ArgAssignmentsOut = arg4;
  1594. object DeclarationsIn = arg5;
  1595. Variable VariableName = new Variable();
  1596. Variable _Var = new Variable();
  1597. Variable RestVariableNames = new Variable();
  1598. Variable DeclarationsOut = new Variable();
  1599. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"=", VariableName, _Var), RestVariableNames)))
  1600. {
  1601. foreach (bool l3 in YP.unify(arg6, new ListPair(new Functor3(@"declare", Atom.a(@"Variable"), VariableName, new Functor2(@"new", Atom.a(@"Variable"), Atom.NIL)), DeclarationsOut)))
  1602. {
  1603. foreach (bool l4 in compileDeclarations(RestVariableNames, HeadArgs, ArgAssignmentsIn, ArgAssignmentsOut, DeclarationsIn, DeclarationsOut))
  1604. {
  1605. yield return true;
  1606. yield break;
  1607. }
  1608. }
  1609. }
  1610. }
  1611. }
  1612. public static IEnumerable<bool> getVariableArgIndex1(object Var, object arg2, object arg3)
  1613. {
  1614. {
  1615. Variable FirstHeadArgs = new Variable();
  1616. Variable RestHeadArgs = new Variable();
  1617. Variable x4 = new Variable();
  1618. foreach (bool l2 in YP.unify(arg2, new ListPair(FirstHeadArgs, RestHeadArgs)))
  1619. {
  1620. foreach (bool l3 in YP.unify(arg3, 1))
  1621. {
  1622. if (sameVariable(Var, FirstHeadArgs))
  1623. {
  1624. foreach (bool l5 in getVariableArgIndex1(Var, RestHeadArgs, x4))
  1625. {
  1626. goto cutIf1;
  1627. }
  1628. yield return false;
  1629. cutIf1:
  1630. yield break;
  1631. }
  1632. }
  1633. }
  1634. }
  1635. {
  1636. object Index = arg3;
  1637. Variable x2 = new Variable();
  1638. Variable RestHeadArgs = new Variable();
  1639. Variable RestIndex = new Variable();
  1640. foreach (bool l2 in YP.unify(arg2, new ListPair(x2, RestHeadArgs)))
  1641. {
  1642. foreach (bool l3 in getVariableArgIndex1(Var, RestHeadArgs, RestIndex))
  1643. {
  1644. foreach (bool l4 in YP.unify(Index, YP.add(1, RestIndex)))
  1645. {
  1646. yield return true;
  1647. yield break;
  1648. }
  1649. }
  1650. }
  1651. }
  1652. }
  1653. public static IEnumerable<bool> compileRuleBody(object arg1, object arg2, object arg3)
  1654. {
  1655. {
  1656. object A = arg1;
  1657. object State = arg2;
  1658. object PseudoCode = arg3;
  1659. if (YP.var(A))
  1660. {
  1661. foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), Atom.a(@"true")), State, PseudoCode))
  1662. {
  1663. yield return true;
  1664. yield break;
  1665. }
  1666. }
  1667. }
  1668. {
  1669. object State = arg2;
  1670. foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
  1671. {
  1672. foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
  1673. {
  1674. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  1675. {
  1676. yield return true;
  1677. yield break;
  1678. }
  1679. }
  1680. }
  1681. }
  1682. {
  1683. object State = arg2;
  1684. foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
  1685. {
  1686. foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
  1687. {
  1688. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  1689. {
  1690. yield return true;
  1691. yield break;
  1692. }
  1693. }
  1694. }
  1695. }
  1696. {
  1697. object State = arg2;
  1698. foreach (bool l2 in YP.unify(arg1, Atom.a(@"!")))
  1699. {
  1700. foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldtrue"), new ListPair(Atom.a(@"yieldbreak"), Atom.NIL))))
  1701. {
  1702. CompilerState.setCodeUsesYield(State);
  1703. yield return true;
  1704. yield break;
  1705. }
  1706. }
  1707. }
  1708. {
  1709. object _State = arg2;
  1710. Variable Name = new Variable();
  1711. foreach (bool l2 in YP.unify(arg1, new Functor1(@"$CUTIF", Name)))
  1712. {
  1713. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL)))
  1714. {
  1715. yield return true;
  1716. yield break;
  1717. }
  1718. }
  1719. }
  1720. {
  1721. object State = arg2;
  1722. foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
  1723. {
  1724. foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"return"), Atom.NIL)))
  1725. {
  1726. if (CompilerState.determinismEquals(State, Atom.a(@"detNoneOut")))
  1727. {
  1728. yield return true;
  1729. yield break;
  1730. }
  1731. }
  1732. }
  1733. }
  1734. {
  1735. object State = arg2;
  1736. foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
  1737. {
  1738. foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"returntrue"), Atom.NIL)))
  1739. {
  1740. if (CompilerState.determinismEquals(State, Atom.a(@"semidetNoneOut")))
  1741. {
  1742. yield return true;
  1743. yield break;
  1744. }
  1745. }
  1746. }
  1747. }
  1748. {
  1749. object State = arg2;
  1750. foreach (bool l2 in YP.unify(arg1, Atom.a(@"true")))
  1751. {
  1752. foreach (bool l3 in YP.unify(arg3, new ListPair(Atom.a(@"yieldfalse"), Atom.NIL)))
  1753. {
  1754. CompilerState.setCodeUsesYield(State);
  1755. yield return true;
  1756. yield break;
  1757. }
  1758. }
  1759. }
  1760. {
  1761. object State = arg2;
  1762. object PseudoCode = arg3;
  1763. Variable A = new Variable();
  1764. Variable B = new Variable();
  1765. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
  1766. {
  1767. if (YP.var(A))
  1768. {
  1769. foreach (bool l4 in compileRuleBody(new Functor2(@",", new Functor1(@"call", A), B), State, PseudoCode))
  1770. {
  1771. yield return true;
  1772. yield break;
  1773. }
  1774. }
  1775. }
  1776. }
  1777. {
  1778. object State = arg2;
  1779. object PseudoCode = arg3;
  1780. Variable A = new Variable();
  1781. Variable T = new Variable();
  1782. Variable B = new Variable();
  1783. Variable C = new Variable();
  1784. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), B), C)))
  1785. {
  1786. foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@"->", A, new Functor2(@",", T, C)), new Functor2(@",", B, C)), State, PseudoCode))
  1787. {
  1788. yield return true;
  1789. yield break;
  1790. }
  1791. }
  1792. }
  1793. {
  1794. object State = arg2;
  1795. object PseudoCode = arg3;
  1796. Variable A = new Variable();
  1797. Variable B = new Variable();
  1798. Variable C = new Variable();
  1799. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@";", A, B), C)))
  1800. {
  1801. foreach (bool l3 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, C), new Functor2(@",", B, C)), State, PseudoCode))
  1802. {
  1803. yield return true;
  1804. yield break;
  1805. }
  1806. }
  1807. }
  1808. {
  1809. object State = arg2;
  1810. Variable A = new Variable();
  1811. Variable B = new Variable();
  1812. Variable ACode = new Variable();
  1813. Variable BCode = new Variable();
  1814. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
  1815. {
  1816. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor1(@"not", ACode), BCode), Atom.NIL)))
  1817. {
  1818. if (CompilerState.isSemidetNoneOut(State, A))
  1819. {
  1820. foreach (bool l5 in compileFunctorCall(A, State, ACode))
  1821. {
  1822. foreach (bool l6 in compileRuleBody(B, State, BCode))
  1823. {
  1824. yield return true;
  1825. yield break;
  1826. }
  1827. }
  1828. }
  1829. }
  1830. }
  1831. }
  1832. {
  1833. object State = arg2;
  1834. object PseudoCode = arg3;
  1835. Variable A = new Variable();
  1836. Variable B = new Variable();
  1837. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"\+", A), B)))
  1838. {
  1839. foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"fail")), Atom.a(@"true")), B), State, PseudoCode))
  1840. {
  1841. yield return true;
  1842. yield break;
  1843. }
  1844. }
  1845. }
  1846. {
  1847. object State = arg2;
  1848. object PseudoCode = arg3;
  1849. Variable A = new Variable();
  1850. Variable B = new Variable();
  1851. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"once", A), B)))
  1852. {
  1853. foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, Atom.a(@"true")), Atom.a(@"fail")), B), State, PseudoCode))
  1854. {
  1855. yield return true;
  1856. yield break;
  1857. }
  1858. }
  1859. }
  1860. {
  1861. object State = arg2;
  1862. object PseudoCode = arg3;
  1863. Variable A = new Variable();
  1864. Variable T = new Variable();
  1865. Variable B = new Variable();
  1866. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"->", A, T), B)))
  1867. {
  1868. foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor2(@";", new Functor2(@"->", A, T), Atom.a(@"fail")), B), State, PseudoCode))
  1869. {
  1870. yield return true;
  1871. yield break;
  1872. }
  1873. }
  1874. }
  1875. {
  1876. object State = arg2;
  1877. object PseudoCode = arg3;
  1878. Variable A = new Variable();
  1879. Variable B = new Variable();
  1880. Variable C = new Variable();
  1881. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"\=", A, B), C)))
  1882. {
  1883. foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"\+", new Functor2(@"=", A, B)), C), State, PseudoCode))
  1884. {
  1885. yield return true;
  1886. yield break;
  1887. }
  1888. }
  1889. }
  1890. {
  1891. object State = arg2;
  1892. object PseudoCode = arg3;
  1893. Variable A = new Variable();
  1894. Variable ACode = new Variable();
  1895. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"!"), A)))
  1896. {
  1897. foreach (bool l3 in compileRuleBody(A, State, ACode))
  1898. {
  1899. foreach (bool l4 in append(ACode, new ListPair(Atom.a(@"yieldbreak"), Atom.NIL), PseudoCode))
  1900. {
  1901. yield return true;
  1902. yield break;
  1903. }
  1904. }
  1905. }
  1906. }
  1907. {
  1908. object State = arg2;
  1909. object PseudoCode = arg3;
  1910. Variable Name = new Variable();
  1911. Variable A = new Variable();
  1912. Variable ACode = new Variable();
  1913. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$CUTIF", Name), A)))
  1914. {
  1915. foreach (bool l3 in compileRuleBody(A, State, ACode))
  1916. {
  1917. foreach (bool l4 in append(ACode, new ListPair(new Functor1(@"breakBlock", Name), Atom.NIL), PseudoCode))
  1918. {
  1919. yield return true;
  1920. yield break;
  1921. }
  1922. }
  1923. }
  1924. }
  1925. {
  1926. object _State = arg2;
  1927. Variable x1 = new Variable();
  1928. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"fail"), x1)))
  1929. {
  1930. foreach (bool l3 in YP.unify(arg3, Atom.NIL))
  1931. {
  1932. yield return true;
  1933. yield break;
  1934. }
  1935. }
  1936. }
  1937. {
  1938. object State = arg2;
  1939. object PseudoCode = arg3;
  1940. Variable A = new Variable();
  1941. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", Atom.a(@"true"), A)))
  1942. {
  1943. foreach (bool l3 in compileRuleBody(A, State, PseudoCode))
  1944. {
  1945. yield return true;
  1946. yield break;
  1947. }
  1948. }
  1949. }
  1950. {
  1951. object State = arg2;
  1952. Variable A = new Variable();
  1953. Variable Term = new Variable();
  1954. Variable B = new Variable();
  1955. Variable ACode = new Variable();
  1956. Variable TermCode = new Variable();
  1957. Variable BCode = new Variable();
  1958. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@"is", A, Term), B)))
  1959. {
  1960. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.unify"), new ListPair(ACode, new ListPair(TermCode, Atom.NIL))), BCode), Atom.NIL)))
  1961. {
  1962. foreach (bool l4 in compileTerm(A, State, ACode))
  1963. {
  1964. foreach (bool l5 in compileExpression(Term, State, TermCode))
  1965. {
  1966. foreach (bool l6 in compileRuleBody(B, State, BCode))
  1967. {
  1968. yield return true;
  1969. yield break;
  1970. }
  1971. }
  1972. }
  1973. }
  1974. }
  1975. }
  1976. {
  1977. object State = arg2;
  1978. Variable A = new Variable();
  1979. Variable B = new Variable();
  1980. Variable ACode = new Variable();
  1981. Variable BCode = new Variable();
  1982. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
  1983. {
  1984. foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
  1985. {
  1986. if (CompilerState.isDetNoneOut(State, A))
  1987. {
  1988. foreach (bool l5 in compileFunctorCall(A, State, ACode))
  1989. {
  1990. foreach (bool l6 in compileRuleBody(B, State, BCode))
  1991. {
  1992. yield return true;
  1993. yield break;
  1994. }
  1995. }
  1996. }
  1997. }
  1998. }
  1999. }
  2000. {
  2001. object State = arg2;
  2002. Variable A = new Variable();
  2003. Variable B = new Variable();
  2004. Variable ACode = new Variable();
  2005. Variable BCode = new Variable();
  2006. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
  2007. {
  2008. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", ACode, BCode), Atom.NIL)))
  2009. {
  2010. if (CompilerState.isSemidetNoneOut(State, A))
  2011. {
  2012. foreach (bool l5 in compileFunctorCall(A, State, ACode))
  2013. {
  2014. foreach (bool l6 in compileRuleBody(B, State, BCode))
  2015. {
  2016. yield return true;
  2017. yield break;
  2018. }
  2019. }
  2020. }
  2021. }
  2022. }
  2023. }
  2024. {
  2025. object State = arg2;
  2026. Variable ACode = new Variable();
  2027. Variable B = new Variable();
  2028. Variable BCode = new Variable();
  2029. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", ACode), B)))
  2030. {
  2031. foreach (bool l3 in YP.unify(arg3, new ListPair(ACode, BCode)))
  2032. {
  2033. foreach (bool l4 in compileRuleBody(B, State, BCode))
  2034. {
  2035. yield return true;
  2036. yield break;
  2037. }
  2038. }
  2039. }
  2040. }
  2041. {
  2042. object State = arg2;
  2043. Variable A = new Variable();
  2044. Variable B = new Variable();
  2045. Variable FunctionName = new Variable();
  2046. Variable X1Code = new Variable();
  2047. Variable X2Code = new Variable();
  2048. Variable BCode = new Variable();
  2049. Variable Name = new Variable();
  2050. Variable X1 = new Variable();
  2051. Variable X2 = new Variable();
  2052. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
  2053. {
  2054. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"if", new Functor2(@"call", FunctionName, new ListPair(X1Code, new ListPair(X2Code, Atom.NIL))), BCode), Atom.NIL)))
  2055. {
  2056. foreach (bool l4 in YP.univ(A, new ListPair(Name, new ListPair(X1, new ListPair(X2, Atom.NIL)))))
  2057. {
  2058. foreach (bool l5 in binaryExpressionConditional(Name, FunctionName))
  2059. {
  2060. foreach (bool l6 in compileExpression(X1, State, X1Code))
  2061. {
  2062. foreach (bool l7 in compileExpression(X2, State, X2Code))
  2063. {
  2064. foreach (bool l8 in compileRuleBody(B, State, BCode))
  2065. {
  2066. yield return true;
  2067. yield break;
  2068. }
  2069. }
  2070. }
  2071. }
  2072. }
  2073. }
  2074. }
  2075. }
  2076. {
  2077. object State = arg2;
  2078. object PseudoCode = arg3;
  2079. Variable A = new Variable();
  2080. Variable B = new Variable();
  2081. Variable C = new Variable();
  2082. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor2(@",", A, B), C)))
  2083. {
  2084. foreach (bool l3 in compileRuleBody(new Functor2(@",", A, new Functor2(@",", B, C)), State, PseudoCode))
  2085. {
  2086. yield return true;
  2087. yield break;
  2088. }
  2089. }
  2090. }
  2091. {
  2092. object State = arg2;
  2093. object PseudoCode = arg3;
  2094. Variable Template = new Variable();
  2095. Variable Goal = new Variable();
  2096. Variable Bag = new Variable();
  2097. Variable B = new Variable();
  2098. Variable TemplateCode = new Variable();
  2099. Variable FindallAnswers = new Variable();
  2100. Variable GoalAndAddCode = new Variable();
  2101. Variable BagCode = new Variable();
  2102. Variable BCode = new Variable();
  2103. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"findall", Template, Goal, Bag), B)))
  2104. {
  2105. foreach (bool l3 in compileTerm(Template, State, TemplateCode))
  2106. {
  2107. foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"findallAnswers"), FindallAnswers))
  2108. {
  2109. foreach (bool l5 in compileRuleBody(new Functor2(@",", Goal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode))
  2110. {
  2111. foreach (bool l6 in compileTerm(Bag, State, BagCode))
  2112. {
  2113. foreach (bool l7 in compileRuleBody(B, State, BCode))
  2114. {
  2115. foreach (bool l8 in append(new ListPair(new Functor3(@"declare", Atom.a(@"FindallAnswers"), FindallAnswers, new Functor2(@"new", Atom.a(@"FindallAnswers"), new ListPair(TemplateCode, Atom.NIL))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", FindallAnswers), Atom.a(@"result"), new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode))
  2116. {
  2117. yield return true;
  2118. yield break;
  2119. }
  2120. }
  2121. }
  2122. }
  2123. }
  2124. }
  2125. }
  2126. }
  2127. {
  2128. object State = arg2;
  2129. object PseudoCode = arg3;
  2130. Variable Template = new Variable();
  2131. Variable Goal = new Variable();
  2132. Variable Bag = new Variable();
  2133. Variable B = new Variable();
  2134. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"bagof", Template, Goal, Bag), B)))
  2135. {
  2136. foreach (bool l3 in compileBagof(Atom.a(@"result"), Template, Goal, Bag, B, State, PseudoCode))
  2137. {
  2138. yield return true;
  2139. yield break;
  2140. }
  2141. }
  2142. }
  2143. {
  2144. object State = arg2;
  2145. object PseudoCode = arg3;
  2146. Variable Template = new Variable();
  2147. Variable Goal = new Variable();
  2148. Variable Bag = new Variable();
  2149. Variable B = new Variable();
  2150. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"setof", Template, Goal, Bag), B)))
  2151. {
  2152. foreach (bool l3 in compileBagof(Atom.a(@"resultSet"), Template, Goal, Bag, B, State, PseudoCode))
  2153. {
  2154. yield return true;
  2155. yield break;
  2156. }
  2157. }
  2158. }
  2159. {
  2160. object State = arg2;
  2161. Variable A = new Variable();
  2162. Variable B = new Variable();
  2163. Variable ATermCode = new Variable();
  2164. Variable BCode = new Variable();
  2165. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"call", A), B)))
  2166. {
  2167. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode), Atom.NIL)))
  2168. {
  2169. foreach (bool l4 in compileTerm(A, State, ATermCode))
  2170. {
  2171. foreach (bool l5 in compileRuleBody(B, State, BCode))
  2172. {
  2173. yield return true;
  2174. yield break;
  2175. }
  2176. }
  2177. }
  2178. }
  2179. }
  2180. {
  2181. object State = arg2;
  2182. Variable A = new Variable();
  2183. Variable B = new Variable();
  2184. Variable ATermCode = new Variable();
  2185. Variable BCode = new Variable();
  2186. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"asserta", A), B)))
  2187. {
  2188. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.asserta"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
  2189. {
  2190. foreach (bool l4 in compileTerm(A, State, ATermCode))
  2191. {
  2192. foreach (bool l5 in compileRuleBody(B, State, BCode))
  2193. {
  2194. yield return true;
  2195. yield break;
  2196. }
  2197. }
  2198. }
  2199. }
  2200. }
  2201. {
  2202. object State = arg2;
  2203. Variable A = new Variable();
  2204. Variable B = new Variable();
  2205. Variable ATermCode = new Variable();
  2206. Variable BCode = new Variable();
  2207. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assertz", A), B)))
  2208. {
  2209. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"call", Atom.a(@"YP.assertz"), new ListPair(ATermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), BCode)))
  2210. {
  2211. foreach (bool l4 in compileTerm(A, State, ATermCode))
  2212. {
  2213. foreach (bool l5 in compileRuleBody(B, State, BCode))
  2214. {
  2215. yield return true;
  2216. yield break;
  2217. }
  2218. }
  2219. }
  2220. }
  2221. }
  2222. {
  2223. object State = arg2;
  2224. object PseudoCode = arg3;
  2225. Variable A = new Variable();
  2226. Variable B = new Variable();
  2227. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor1(@"assert", A), B)))
  2228. {
  2229. foreach (bool l3 in compileRuleBody(new Functor2(@",", new Functor1(@"assertz", A), B), State, PseudoCode))
  2230. {
  2231. yield return true;
  2232. yield break;
  2233. }
  2234. }
  2235. }
  2236. {
  2237. object State = arg2;
  2238. Variable Goal = new Variable();
  2239. Variable Catcher = new Variable();
  2240. Variable Handler = new Variable();
  2241. Variable B = new Variable();
  2242. Variable CatchGoal = new Variable();
  2243. Variable GoalTermCode = new Variable();
  2244. Variable BCode = new Variable();
  2245. Variable CatcherTermCode = new Variable();
  2246. Variable HandlerAndBCode = new Variable();
  2247. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", new Functor3(@"catch", Goal, Catcher, Handler), B)))
  2248. {
  2249. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor3(@"declare", Atom.a(@"YP.Catch"), CatchGoal, new Functor2(@"new", Atom.a(@"YP.Catch"), new ListPair(new Functor2(@"call", Atom.a(@"YP.getIterator"), new ListPair(GoalTermCode, new ListPair(new Functor2(@"call", Atom.a(@"getDeclaringClass"), Atom.NIL), Atom.NIL))), Atom.NIL))), new ListPair(new Functor2(@"foreach", new Functor1(@"var", CatchGoal), BCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", CatchGoal), Atom.a(@"unifyExceptionOrThrow"), new ListPair(CatcherTermCode, Atom.NIL)), HandlerAndBCode), Atom.NIL)))))
  2250. {
  2251. foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"catchGoal"), CatchGoal))
  2252. {
  2253. foreach (bool l5 in compileTerm(Goal, State, GoalTermCode))
  2254. {
  2255. foreach (bool l6 in compileTerm(Catcher, State, CatcherTermCode))
  2256. {
  2257. foreach (bool l7 in compileRuleBody(B, State, BCode))
  2258. {
  2259. foreach (bool l8 in compileRuleBody(new Functor2(@",", Handler, B), State, HandlerAndBCode))
  2260. {
  2261. yield return true;
  2262. yield break;
  2263. }
  2264. }
  2265. }
  2266. }
  2267. }
  2268. }
  2269. }
  2270. }
  2271. {
  2272. object State = arg2;
  2273. Variable A = new Variable();
  2274. Variable B = new Variable();
  2275. Variable ACode = new Variable();
  2276. Variable BCode = new Variable();
  2277. foreach (bool l2 in YP.unify(arg1, new Functor2(@",", A, B)))
  2278. {
  2279. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"foreach", ACode, BCode), Atom.NIL)))
  2280. {
  2281. foreach (bool l4 in compileFunctorCall(A, State, ACode))
  2282. {
  2283. foreach (bool l5 in compileRuleBody(B, State, BCode))
  2284. {
  2285. yield return true;
  2286. yield break;
  2287. }
  2288. }
  2289. }
  2290. }
  2291. }
  2292. {
  2293. object State = arg2;
  2294. object PseudoCode = arg3;
  2295. Variable A = new Variable();
  2296. Variable B = new Variable();
  2297. foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
  2298. {
  2299. if (YP.var(A))
  2300. {
  2301. foreach (bool l4 in compileRuleBody(new Functor2(@";", new Functor1(@"call", A), B), State, PseudoCode))
  2302. {
  2303. yield return true;
  2304. yield break;
  2305. }
  2306. }
  2307. }
  2308. }
  2309. {
  2310. object State = arg2;
  2311. Variable A = new Variable();
  2312. Variable T = new Variable();
  2313. Variable B = new Variable();
  2314. Variable CutIfLabel = new Variable();
  2315. Variable Code = new Variable();
  2316. foreach (bool l2 in YP.unify(arg1, new Functor2(@";", new Functor2(@"->", A, T), B)))
  2317. {
  2318. foreach (bool l3 in YP.unify(arg3, new ListPair(new Functor2(@"breakableBlock", CutIfLabel, Code), Atom.NIL)))
  2319. {
  2320. foreach (bool l4 in CompilerState.gensym(State, Atom.a(@"cutIf"), CutIfLabel))
  2321. {
  2322. foreach (bool l5 in compileRuleBody(new Functor2(@";", new Functor2(@",", A, new Functor2(@",", new Functor1(@"$CUTIF", CutIfLabel), T)), B), State, Code))
  2323. {
  2324. yield return true;
  2325. yield break;
  2326. }
  2327. }
  2328. }
  2329. }
  2330. }
  2331. {
  2332. object State = arg2;
  2333. object PseudoCode = arg3;
  2334. Variable A = new Variable();
  2335. Variable B = new Variable();
  2336. Variable ACode = new Variable();
  2337. Variable BCode = new Variable();
  2338. foreach (bool l2 in YP.unify(arg1, new Functor2(@";", A, B)))
  2339. {
  2340. foreach (bool l3 in compileRuleBody(A, State, ACode))
  2341. {
  2342. foreach (bool l4 in compileRuleBody(B, State, BCode))
  2343. {
  2344. foreach (bool l5 in append(ACode, BCode, PseudoCode))
  2345. {
  2346. yield return true;
  2347. yield break;
  2348. }
  2349. }
  2350. }
  2351. }
  2352. }
  2353. {
  2354. object A = arg1;
  2355. object State = arg2;
  2356. object PseudoCode = arg3;
  2357. foreach (bool l2 in compileRuleBody(new Functor2(@",", A, Atom.a(@"true")), State, PseudoCode))
  2358. {
  2359. yield return true;
  2360. yield break;
  2361. }
  2362. }
  2363. }
  2364. public static IEnumerable<bool> compileBagof(object ResultMethod, object Template, object Goal, object Bag, object B, object State, object PseudoCode)
  2365. {
  2366. {
  2367. Variable TemplateCode = new Variable();
  2368. Variable GoalTermCode = new Variable();
  2369. Variable UnqualifiedGoal = new Variable();
  2370. Variable BagofAnswers = new Variable();
  2371. Variable GoalAndAddCode = new Variable();
  2372. Variable BagCode = new Variable();
  2373. Variable BCode = new Variable();
  2374. foreach (bool l2 in compileTerm(Template, State, TemplateCode))
  2375. {
  2376. foreach (bool l3 in compileTerm(Goal, State, GoalTermCode))
  2377. {
  2378. foreach (bool l4 in unqualifiedGoal(Goal, UnqualifiedGoal))
  2379. {
  2380. foreach (bool l5 in CompilerState.gensym(State, Atom.a(@"bagofAnswers"), BagofAnswers))
  2381. {
  2382. foreach (bool l6 in compileRuleBody(new Functor2(@",", UnqualifiedGoal, new Functor2(@",", new Functor1(@"$DET_NONE_OUT", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), Atom.a(@"add"), Atom.NIL)), Atom.a(@"fail"))), State, GoalAndAddCode))
  2383. {
  2384. foreach (bool l7 in compileTerm(Bag, State, BagCode))
  2385. {
  2386. foreach (bool l8 in compileRuleBody(B, State, BCode))
  2387. {
  2388. foreach (bool l9 in append(new ListPair(new Functor3(@"declare", Atom.a(@"BagofAnswers"), BagofAnswers, new Functor2(@"new", Atom.a(@"BagofAnswers"), new ListPair(TemplateCode, new ListPair(GoalTermCode, Atom.NIL)))), GoalAndAddCode), new ListPair(new Functor2(@"foreach", new Functor3(@"callMember", new Functor1(@"var", BagofAnswers), ResultMethod, new ListPair(BagCode, Atom.NIL)), BCode), Atom.NIL), PseudoCode))
  2389. {
  2390. yield return true;
  2391. yield break;
  2392. }
  2393. }
  2394. }
  2395. }
  2396. }
  2397. }
  2398. }
  2399. }
  2400. }
  2401. }
  2402. public static IEnumerable<bool> unqualifiedGoal(object arg1, object arg2)
  2403. {
  2404. {
  2405. object Goal = arg1;
  2406. foreach (bool l2 in YP.unify(arg2, new Functor1(@"call", Goal)))
  2407. {
  2408. if (YP.var(Goal))
  2409. {
  2410. yield return true;
  2411. yield break;
  2412. }
  2413. }
  2414. }
  2415. {
  2416. object UnqualifiedGoal = arg2;
  2417. Variable x1 = new Variable();
  2418. Variable Goal = new Variable();
  2419. foreach (bool l2 in YP.unify(arg1, new Functor2(@"^", x1, Goal)))
  2420. {
  2421. foreach (bool l3 in unqualifiedGoal(Goal, UnqualifiedGoal))
  2422. {
  2423. yield return true;
  2424. yield break;
  2425. }
  2426. }
  2427. }
  2428. {
  2429. Variable UnqualifiedGoal = new Variable();
  2430. foreach (bool l2 in YP.unify(arg1, UnqualifiedGoal))
  2431. {
  2432. foreach (bool l3 in YP.unify(arg2, UnqualifiedGoal))
  2433. {
  2434. yield return true;
  2435. yield break;
  2436. }
  2437. }
  2438. }
  2439. }
  2440. public static IEnumerable<bool> binaryExpressionConditional(object arg1, object arg2)
  2441. {
  2442. {
  2443. foreach (bool l2 in YP.unify(arg1, Atom.a(@"=:=")))
  2444. {
  2445. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.equal")))
  2446. {
  2447. yield return true;
  2448. yield break;
  2449. }
  2450. }
  2451. }
  2452. {
  2453. foreach (bool l2 in YP.unify(arg1, Atom.a(@"=\=")))
  2454. {
  2455. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.notEqual")))
  2456. {
  2457. yield return true;
  2458. yield break;
  2459. }
  2460. }
  2461. }
  2462. {
  2463. foreach (bool l2 in YP.unify(arg1, Atom.a(@">")))
  2464. {
  2465. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThan")))
  2466. {
  2467. yield return true;
  2468. yield break;
  2469. }
  2470. }
  2471. }
  2472. {
  2473. foreach (bool l2 in YP.unify(arg1, Atom.a(@"<")))
  2474. {
  2475. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThan")))
  2476. {
  2477. yield return true;
  2478. yield break;
  2479. }
  2480. }
  2481. }
  2482. {
  2483. foreach (bool l2 in YP.unify(arg1, Atom.a(@">=")))
  2484. {
  2485. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.greaterThanOrEqual")))
  2486. {
  2487. yield return true;
  2488. yield break;
  2489. }
  2490. }
  2491. }
  2492. {
  2493. foreach (bool l2 in YP.unify(arg1, Atom.a(@"=<")))
  2494. {
  2495. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.lessThanOrEqual")))
  2496. {
  2497. yield return true;
  2498. yield break;
  2499. }
  2500. }
  2501. }
  2502. }
  2503. public static IEnumerable<bool> compileFunctorCall(object Functor_1, object State, object PseudoCode)
  2504. {
  2505. {
  2506. Variable FunctorName = new Variable();
  2507. Variable FunctorArgs = new Variable();
  2508. Variable x6 = new Variable();
  2509. Variable Arity = new Variable();
  2510. Variable CompiledArgs = new Variable();
  2511. Variable FunctionName = new Variable();
  2512. foreach (bool l2 in YP.univ(Functor_1, new ListPair(FunctorName, FunctorArgs)))
  2513. {
  2514. foreach (bool l3 in YP.functor(Functor_1, x6, Arity))
  2515. {
  2516. foreach (bool l4 in maplist_compileTerm(FunctorArgs, State, CompiledArgs))
  2517. {
  2518. foreach (bool l5 in functorCallFunctionName(State, FunctorName, Arity, FunctionName))
  2519. {
  2520. if (YP.termEqual(FunctionName, Atom.NIL))
  2521. {
  2522. foreach (bool l7 in YP.unify(PseudoCode, new Functor2(@"call", Atom.a(@"YP.matchDynamic"), new ListPair(new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", FunctorName), Atom.NIL)), new ListPair(new Functor1(@"objectArray", CompiledArgs), Atom.NIL)))))
  2523. {
  2524. yield return true;
  2525. yield break;
  2526. }
  2527. goto cutIf1;
  2528. }
  2529. foreach (bool l6 in YP.unify(PseudoCode, new Functor2(@"call", FunctionName, CompiledArgs)))
  2530. {
  2531. yield return true;
  2532. yield break;
  2533. }
  2534. cutIf1:
  2535. { }
  2536. }
  2537. }
  2538. }
  2539. }
  2540. }
  2541. }
  2542. public static IEnumerable<bool> functorCallFunctionName(object arg1, object arg2, object arg3, object arg4)
  2543. {
  2544. {
  2545. object x1 = arg1;
  2546. object Name = arg2;
  2547. object Arity = arg3;
  2548. object FunctionName = arg4;
  2549. foreach (bool l2 in functorCallYPFunctionName(Name, Arity, FunctionName))
  2550. {
  2551. yield return true;
  2552. yield break;
  2553. }
  2554. }
  2555. {
  2556. object State = arg1;
  2557. object Arity = arg3;
  2558. Variable Name = new Variable();
  2559. foreach (bool l2 in YP.unify(arg2, Name))
  2560. {
  2561. foreach (bool l3 in YP.unify(arg4, Name))
  2562. {
  2563. if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
  2564. {
  2565. yield return true;
  2566. yield break;
  2567. }
  2568. }
  2569. }
  2570. }
  2571. {
  2572. object _State = arg1;
  2573. object _Arity = arg3;
  2574. Variable Name = new Variable();
  2575. foreach (bool l2 in YP.unify(arg2, Name))
  2576. {
  2577. foreach (bool l3 in YP.unify(arg4, Name))
  2578. {
  2579. foreach (bool l4 in Atom.module(Name, Atom.a(@"")))
  2580. {
  2581. yield return true;
  2582. yield break;
  2583. }
  2584. }
  2585. }
  2586. }
  2587. {
  2588. object _State = arg1;
  2589. object Name = arg2;
  2590. object Arity = arg3;
  2591. foreach (bool l2 in YP.unify(arg4, Atom.NIL))
  2592. {
  2593. foreach (bool l3 in Atom.module(Name, Atom.NIL))
  2594. {
  2595. yield return true;
  2596. yield break;
  2597. }
  2598. }
  2599. }
  2600. {
  2601. object _State = arg1;
  2602. object Name = arg2;
  2603. object Arity = arg3;
  2604. object x4 = arg4;
  2605. Variable Module = new Variable();
  2606. Variable Message = new Variable();
  2607. foreach (bool l2 in Atom.module(Name, Module))
  2608. {
  2609. foreach (bool l3 in YP.atom_concat(Atom.a(@"Not supporting calls to external module: "), Module, Message))
  2610. {
  2611. YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), new Functor2(@"/", Name, Arity)), Message));
  2612. yield return true;
  2613. yield break;
  2614. }
  2615. }
  2616. }
  2617. {
  2618. object _State = arg1;
  2619. object Name = arg2;
  2620. object _Arity = arg3;
  2621. object x4 = arg4;
  2622. YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"callable"), Name), Atom.a(@"Term is not callable")));
  2623. yield return true;
  2624. yield break;
  2625. }
  2626. }
  2627. public static IEnumerable<bool> functorCallYPFunctionName(object arg1, object arg2, object arg3)
  2628. {
  2629. {
  2630. foreach (bool l2 in YP.unify(arg1, Atom.a(@"=")))
  2631. {
  2632. foreach (bool l3 in YP.unify(arg2, 2))
  2633. {
  2634. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.unify")))
  2635. {
  2636. yield return true;
  2637. yield break;
  2638. }
  2639. }
  2640. }
  2641. }
  2642. {
  2643. foreach (bool l2 in YP.unify(arg1, Atom.a(@"=..")))
  2644. {
  2645. foreach (bool l3 in YP.unify(arg2, 2))
  2646. {
  2647. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.univ")))
  2648. {
  2649. yield return true;
  2650. yield break;
  2651. }
  2652. }
  2653. }
  2654. }
  2655. {
  2656. foreach (bool l2 in YP.unify(arg1, Atom.a(@"var")))
  2657. {
  2658. foreach (bool l3 in YP.unify(arg2, 1))
  2659. {
  2660. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.var")))
  2661. {
  2662. yield return true;
  2663. yield break;
  2664. }
  2665. }
  2666. }
  2667. }
  2668. {
  2669. foreach (bool l2 in YP.unify(arg1, Atom.a(@"nonvar")))
  2670. {
  2671. foreach (bool l3 in YP.unify(arg2, 1))
  2672. {
  2673. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nonvar")))
  2674. {
  2675. yield return true;
  2676. yield break;
  2677. }
  2678. }
  2679. }
  2680. }
  2681. {
  2682. foreach (bool l2 in YP.unify(arg1, Atom.a(@"arg")))
  2683. {
  2684. foreach (bool l3 in YP.unify(arg2, 3))
  2685. {
  2686. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.arg")))
  2687. {
  2688. yield return true;
  2689. yield break;
  2690. }
  2691. }
  2692. }
  2693. }
  2694. {
  2695. foreach (bool l2 in YP.unify(arg1, Atom.a(@"functor")))
  2696. {
  2697. foreach (bool l3 in YP.unify(arg2, 3))
  2698. {
  2699. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.functor")))
  2700. {
  2701. yield return true;
  2702. yield break;
  2703. }
  2704. }
  2705. }
  2706. }
  2707. {
  2708. foreach (bool l2 in YP.unify(arg1, Atom.a(@"repeat")))
  2709. {
  2710. foreach (bool l3 in YP.unify(arg2, 0))
  2711. {
  2712. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.repeat")))
  2713. {
  2714. yield return true;
  2715. yield break;
  2716. }
  2717. }
  2718. }
  2719. }
  2720. {
  2721. foreach (bool l2 in YP.unify(arg1, Atom.a(@"get_code")))
  2722. {
  2723. foreach (bool l3 in YP.unify(arg2, 1))
  2724. {
  2725. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.get_code")))
  2726. {
  2727. yield return true;
  2728. yield break;
  2729. }
  2730. }
  2731. }
  2732. }
  2733. {
  2734. foreach (bool l2 in YP.unify(arg1, Atom.a(@"current_op")))
  2735. {
  2736. foreach (bool l3 in YP.unify(arg2, 3))
  2737. {
  2738. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.current_op")))
  2739. {
  2740. yield return true;
  2741. yield break;
  2742. }
  2743. }
  2744. }
  2745. }
  2746. {
  2747. foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_length")))
  2748. {
  2749. foreach (bool l3 in YP.unify(arg2, 2))
  2750. {
  2751. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_length")))
  2752. {
  2753. yield return true;
  2754. yield break;
  2755. }
  2756. }
  2757. }
  2758. }
  2759. {
  2760. foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_concat")))
  2761. {
  2762. foreach (bool l3 in YP.unify(arg2, 3))
  2763. {
  2764. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_concat")))
  2765. {
  2766. yield return true;
  2767. yield break;
  2768. }
  2769. }
  2770. }
  2771. }
  2772. {
  2773. foreach (bool l2 in YP.unify(arg1, Atom.a(@"sub_atom")))
  2774. {
  2775. foreach (bool l3 in YP.unify(arg2, 5))
  2776. {
  2777. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sub_atom")))
  2778. {
  2779. yield return true;
  2780. yield break;
  2781. }
  2782. }
  2783. }
  2784. }
  2785. {
  2786. foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom_codes")))
  2787. {
  2788. foreach (bool l3 in YP.unify(arg2, 2))
  2789. {
  2790. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom_codes")))
  2791. {
  2792. yield return true;
  2793. yield break;
  2794. }
  2795. }
  2796. }
  2797. }
  2798. {
  2799. foreach (bool l2 in YP.unify(arg1, Atom.a(@"number_codes")))
  2800. {
  2801. foreach (bool l3 in YP.unify(arg2, 2))
  2802. {
  2803. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number_codes")))
  2804. {
  2805. yield return true;
  2806. yield break;
  2807. }
  2808. }
  2809. }
  2810. }
  2811. {
  2812. foreach (bool l2 in YP.unify(arg1, Atom.a(@"copy_term")))
  2813. {
  2814. foreach (bool l3 in YP.unify(arg2, 2))
  2815. {
  2816. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.copy_term")))
  2817. {
  2818. yield return true;
  2819. yield break;
  2820. }
  2821. }
  2822. }
  2823. }
  2824. {
  2825. foreach (bool l2 in YP.unify(arg1, Atom.a(@"sort")))
  2826. {
  2827. foreach (bool l3 in YP.unify(arg2, 2))
  2828. {
  2829. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.sort")))
  2830. {
  2831. yield return true;
  2832. yield break;
  2833. }
  2834. }
  2835. }
  2836. }
  2837. {
  2838. // Manually included : script_event for callback to LSL/C#
  2839. //object x1 = arg1;
  2840. foreach (bool l2 in YP.unify(arg1, Atom.a(@"script_event")))
  2841. {
  2842. foreach (bool l3 in YP.unify(arg2, 2))
  2843. {
  2844. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.script_event")))
  2845. {
  2846. yield return true;
  2847. yield break;
  2848. }
  2849. }
  2850. }
  2851. }
  2852. {
  2853. foreach (bool l2 in YP.unify(arg1, Atom.a(@"nl")))
  2854. {
  2855. foreach (bool l3 in YP.unify(arg2, 0))
  2856. {
  2857. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.nl")))
  2858. {
  2859. yield return true;
  2860. yield break;
  2861. }
  2862. }
  2863. }
  2864. }
  2865. {
  2866. foreach (bool l2 in YP.unify(arg1, Atom.a(@"write")))
  2867. {
  2868. foreach (bool l3 in YP.unify(arg2, 1))
  2869. {
  2870. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.write")))
  2871. {
  2872. yield return true;
  2873. yield break;
  2874. }
  2875. }
  2876. }
  2877. }
  2878. {
  2879. foreach (bool l2 in YP.unify(arg1, Atom.a(@"put_code")))
  2880. {
  2881. foreach (bool l3 in YP.unify(arg2, 1))
  2882. {
  2883. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.put_code")))
  2884. {
  2885. yield return true;
  2886. yield break;
  2887. }
  2888. }
  2889. }
  2890. }
  2891. {
  2892. foreach (bool l2 in YP.unify(arg1, Atom.a(@"atom")))
  2893. {
  2894. foreach (bool l3 in YP.unify(arg2, 1))
  2895. {
  2896. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atom")))
  2897. {
  2898. yield return true;
  2899. yield break;
  2900. }
  2901. }
  2902. }
  2903. }
  2904. {
  2905. foreach (bool l2 in YP.unify(arg1, Atom.a(@"integer")))
  2906. {
  2907. foreach (bool l3 in YP.unify(arg2, 1))
  2908. {
  2909. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.integer")))
  2910. {
  2911. yield return true;
  2912. yield break;
  2913. }
  2914. }
  2915. }
  2916. }
  2917. {
  2918. foreach (bool l2 in YP.unify(arg1, Atom.a(@"float")))
  2919. {
  2920. foreach (bool l3 in YP.unify(arg2, 1))
  2921. {
  2922. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.isFloat")))
  2923. {
  2924. yield return true;
  2925. yield break;
  2926. }
  2927. }
  2928. }
  2929. }
  2930. {
  2931. foreach (bool l2 in YP.unify(arg1, Atom.a(@"number")))
  2932. {
  2933. foreach (bool l3 in YP.unify(arg2, 1))
  2934. {
  2935. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.number")))
  2936. {
  2937. yield return true;
  2938. yield break;
  2939. }
  2940. }
  2941. }
  2942. }
  2943. {
  2944. foreach (bool l2 in YP.unify(arg1, Atom.a(@"atomic")))
  2945. {
  2946. foreach (bool l3 in YP.unify(arg2, 1))
  2947. {
  2948. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.atomic")))
  2949. {
  2950. yield return true;
  2951. yield break;
  2952. }
  2953. }
  2954. }
  2955. }
  2956. {
  2957. foreach (bool l2 in YP.unify(arg1, Atom.a(@"compound")))
  2958. {
  2959. foreach (bool l3 in YP.unify(arg2, 1))
  2960. {
  2961. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.compound")))
  2962. {
  2963. yield return true;
  2964. yield break;
  2965. }
  2966. }
  2967. }
  2968. }
  2969. {
  2970. foreach (bool l2 in YP.unify(arg1, Atom.a(@"==")))
  2971. {
  2972. foreach (bool l3 in YP.unify(arg2, 2))
  2973. {
  2974. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termEqual")))
  2975. {
  2976. yield return true;
  2977. yield break;
  2978. }
  2979. }
  2980. }
  2981. }
  2982. {
  2983. foreach (bool l2 in YP.unify(arg1, Atom.a(@"\==")))
  2984. {
  2985. foreach (bool l3 in YP.unify(arg2, 2))
  2986. {
  2987. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termNotEqual")))
  2988. {
  2989. yield return true;
  2990. yield break;
  2991. }
  2992. }
  2993. }
  2994. }
  2995. {
  2996. foreach (bool l2 in YP.unify(arg1, Atom.a(@"@<")))
  2997. {
  2998. foreach (bool l3 in YP.unify(arg2, 2))
  2999. {
  3000. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThan")))
  3001. {
  3002. yield return true;
  3003. yield break;
  3004. }
  3005. }
  3006. }
  3007. }
  3008. {
  3009. foreach (bool l2 in YP.unify(arg1, Atom.a(@"@=<")))
  3010. {
  3011. foreach (bool l3 in YP.unify(arg2, 2))
  3012. {
  3013. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termLessThanOrEqual")))
  3014. {
  3015. yield return true;
  3016. yield break;
  3017. }
  3018. }
  3019. }
  3020. }
  3021. {
  3022. foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>")))
  3023. {
  3024. foreach (bool l3 in YP.unify(arg2, 2))
  3025. {
  3026. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThan")))
  3027. {
  3028. yield return true;
  3029. yield break;
  3030. }
  3031. }
  3032. }
  3033. }
  3034. {
  3035. foreach (bool l2 in YP.unify(arg1, Atom.a(@"@>=")))
  3036. {
  3037. foreach (bool l3 in YP.unify(arg2, 2))
  3038. {
  3039. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.termGreaterThanOrEqual")))
  3040. {
  3041. yield return true;
  3042. yield break;
  3043. }
  3044. }
  3045. }
  3046. }
  3047. {
  3048. foreach (bool l2 in YP.unify(arg1, Atom.a(@"throw")))
  3049. {
  3050. foreach (bool l3 in YP.unify(arg2, 1))
  3051. {
  3052. foreach (bool l4 in YP.unify(arg3, Atom.a(@"YP.throwException")))
  3053. {
  3054. yield return true;
  3055. yield break;
  3056. }
  3057. }
  3058. }
  3059. }
  3060. }
  3061. public static IEnumerable<bool> compileTerm(object arg1, object arg2, object arg3)
  3062. {
  3063. {
  3064. object Term = arg1;
  3065. object State = arg2;
  3066. Variable VariableName = new Variable();
  3067. foreach (bool l2 in YP.unify(arg3, new Functor1(@"var", VariableName)))
  3068. {
  3069. if (YP.var(Term))
  3070. {
  3071. foreach (bool l4 in CompilerState.getVariableName(State, Term, VariableName))
  3072. {
  3073. yield return true;
  3074. yield break;
  3075. }
  3076. }
  3077. }
  3078. }
  3079. {
  3080. object _State = arg2;
  3081. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  3082. {
  3083. foreach (bool l3 in YP.unify(arg3, new Functor1(@"var", Atom.a(@"Atom.NIL"))))
  3084. {
  3085. yield return true;
  3086. yield break;
  3087. }
  3088. }
  3089. }
  3090. {
  3091. object Term = arg1;
  3092. object State = arg2;
  3093. object Code = arg3;
  3094. Variable ModuleCode = new Variable();
  3095. if (YP.atom(Term))
  3096. {
  3097. foreach (bool l3 in compileAtomModule(Term, 0, State, ModuleCode))
  3098. {
  3099. foreach (bool l4 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), new ListPair(ModuleCode, Atom.NIL)))))
  3100. {
  3101. yield return true;
  3102. yield break;
  3103. }
  3104. goto cutIf1;
  3105. }
  3106. foreach (bool l3 in YP.unify(Code, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Term), Atom.NIL))))
  3107. {
  3108. yield return true;
  3109. yield break;
  3110. }
  3111. cutIf1:
  3112. { }
  3113. }
  3114. }
  3115. {
  3116. object State = arg2;
  3117. Variable First = new Variable();
  3118. Variable Rest = new Variable();
  3119. Variable Arg1 = new Variable();
  3120. Variable Arg2 = new Variable();
  3121. foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
  3122. {
  3123. foreach (bool l3 in YP.unify(arg3, new Functor2(@"new", Atom.a(@"ListPair"), new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
  3124. {
  3125. foreach (bool l4 in compileTerm(First, State, Arg1))
  3126. {
  3127. foreach (bool l5 in compileTerm(Rest, State, Arg2))
  3128. {
  3129. yield return true;
  3130. yield break;
  3131. }
  3132. }
  3133. }
  3134. }
  3135. }
  3136. {
  3137. object Term = arg1;
  3138. object State = arg2;
  3139. object Result = arg3;
  3140. Variable Name = new Variable();
  3141. Variable TermArgs = new Variable();
  3142. Variable x6 = new Variable();
  3143. Variable Arity = new Variable();
  3144. Variable ModuleCode = new Variable();
  3145. Variable NameCode = new Variable();
  3146. Variable X1 = new Variable();
  3147. Variable Arg1 = new Variable();
  3148. Variable X2 = new Variable();
  3149. Variable Arg2 = new Variable();
  3150. Variable X3 = new Variable();
  3151. Variable Arg3 = new Variable();
  3152. Variable Args = new Variable();
  3153. foreach (bool l2 in YP.univ(Term, new ListPair(Name, TermArgs)))
  3154. {
  3155. if (YP.termEqual(TermArgs, Atom.NIL))
  3156. {
  3157. foreach (bool l4 in YP.unify(Result, new Functor1(@"object", Name)))
  3158. {
  3159. yield return true;
  3160. yield break;
  3161. }
  3162. goto cutIf2;
  3163. }
  3164. foreach (bool l3 in YP.functor(Term, x6, Arity))
  3165. {
  3166. foreach (bool l4 in compileAtomModule(Name, Arity, State, ModuleCode))
  3167. {
  3168. foreach (bool l5 in YP.unify(NameCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Name), new ListPair(ModuleCode, Atom.NIL)))))
  3169. {
  3170. foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
  3171. {
  3172. foreach (bool l7 in compileTerm(X1, State, Arg1))
  3173. {
  3174. foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
  3175. {
  3176. yield return true;
  3177. yield break;
  3178. }
  3179. }
  3180. goto cutIf4;
  3181. }
  3182. foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
  3183. {
  3184. foreach (bool l7 in compileTerm(X1, State, Arg1))
  3185. {
  3186. foreach (bool l8 in compileTerm(X2, State, Arg2))
  3187. {
  3188. foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
  3189. {
  3190. yield return true;
  3191. yield break;
  3192. }
  3193. }
  3194. }
  3195. goto cutIf5;
  3196. }
  3197. foreach (bool l6 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
  3198. {
  3199. foreach (bool l7 in compileTerm(X1, State, Arg1))
  3200. {
  3201. foreach (bool l8 in compileTerm(X2, State, Arg2))
  3202. {
  3203. foreach (bool l9 in compileTerm(X3, State, Arg3))
  3204. {
  3205. foreach (bool l10 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL)))))))
  3206. {
  3207. yield return true;
  3208. yield break;
  3209. }
  3210. }
  3211. }
  3212. }
  3213. }
  3214. foreach (bool l6 in maplist_compileTerm(TermArgs, State, Args))
  3215. {
  3216. foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
  3217. {
  3218. yield return true;
  3219. yield break;
  3220. }
  3221. }
  3222. cutIf5:
  3223. cutIf4:
  3224. { }
  3225. }
  3226. goto cutIf3;
  3227. }
  3228. foreach (bool l4 in YP.unify(NameCode, new Functor1(@"object", Name)))
  3229. {
  3230. foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
  3231. {
  3232. foreach (bool l6 in compileTerm(X1, State, Arg1))
  3233. {
  3234. foreach (bool l7 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor1"), new ListPair(NameCode, new ListPair(Arg1, Atom.NIL)))))
  3235. {
  3236. yield return true;
  3237. yield break;
  3238. }
  3239. }
  3240. goto cutIf6;
  3241. }
  3242. foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
  3243. {
  3244. foreach (bool l6 in compileTerm(X1, State, Arg1))
  3245. {
  3246. foreach (bool l7 in compileTerm(X2, State, Arg2))
  3247. {
  3248. foreach (bool l8 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor2"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL))))))
  3249. {
  3250. yield return true;
  3251. yield break;
  3252. }
  3253. }
  3254. }
  3255. goto cutIf7;
  3256. }
  3257. foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, new ListPair(X3, Atom.NIL)))))
  3258. {
  3259. foreach (bool l6 in compileTerm(X1, State, Arg1))
  3260. {
  3261. foreach (bool l7 in compileTerm(X2, State, Arg2))
  3262. {
  3263. foreach (bool l8 in compileTerm(X3, State, Arg3))
  3264. {
  3265. foreach (bool l9 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor3"), new ListPair(NameCode, new ListPair(Arg1, new ListPair(Arg2, new ListPair(Arg3, Atom.NIL)))))))
  3266. {
  3267. yield return true;
  3268. yield break;
  3269. }
  3270. }
  3271. }
  3272. }
  3273. }
  3274. foreach (bool l5 in maplist_compileTerm(TermArgs, State, Args))
  3275. {
  3276. foreach (bool l6 in YP.unify(Result, new Functor2(@"new", Atom.a(@"Functor"), new ListPair(NameCode, new ListPair(new Functor1(@"objectArray", Args), Atom.NIL)))))
  3277. {
  3278. yield return true;
  3279. yield break;
  3280. }
  3281. }
  3282. cutIf7:
  3283. cutIf6:
  3284. { }
  3285. }
  3286. cutIf3:
  3287. { }
  3288. }
  3289. cutIf2:
  3290. { }
  3291. }
  3292. }
  3293. }
  3294. public static IEnumerable<bool> compileAtomModule(object Name, object Arity, object State, object ModuleCode)
  3295. {
  3296. {
  3297. if (CompilerState.nameArityHasModule(State, Name, Arity, Atom.a(@"")))
  3298. {
  3299. foreach (bool l3 in YP.unify(ModuleCode, new Functor2(@"call", Atom.a(@"Atom.a"), new ListPair(new Functor1(@"object", Atom.a(@"")), Atom.NIL))))
  3300. {
  3301. yield return true;
  3302. yield break;
  3303. }
  3304. }
  3305. }
  3306. }
  3307. public static IEnumerable<bool> maplist_compileTerm(object arg1, object arg2, object arg3)
  3308. {
  3309. {
  3310. object _State = arg2;
  3311. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  3312. {
  3313. foreach (bool l3 in YP.unify(arg3, Atom.NIL))
  3314. {
  3315. yield return true;
  3316. yield break;
  3317. }
  3318. }
  3319. }
  3320. {
  3321. object State = arg2;
  3322. Variable First = new Variable();
  3323. Variable Rest = new Variable();
  3324. Variable FirstResult = new Variable();
  3325. Variable RestResults = new Variable();
  3326. foreach (bool l2 in YP.unify(arg1, new ListPair(First, Rest)))
  3327. {
  3328. foreach (bool l3 in YP.unify(arg3, new ListPair(FirstResult, RestResults)))
  3329. {
  3330. foreach (bool l4 in compileTerm(First, State, FirstResult))
  3331. {
  3332. foreach (bool l5 in maplist_compileTerm(Rest, State, RestResults))
  3333. {
  3334. yield return true;
  3335. yield break;
  3336. }
  3337. }
  3338. }
  3339. }
  3340. }
  3341. }
  3342. public static IEnumerable<bool> compileExpression(object Term, object State, object Result)
  3343. {
  3344. {
  3345. Variable Name = new Variable();
  3346. Variable TermArgs = new Variable();
  3347. Variable X1 = new Variable();
  3348. Variable FunctionName = new Variable();
  3349. Variable Arg1 = new Variable();
  3350. Variable x9 = new Variable();
  3351. Variable X2 = new Variable();
  3352. Variable Arg2 = new Variable();
  3353. Variable x12 = new Variable();
  3354. Variable Arity = new Variable();
  3355. if (YP.nonvar(Term))
  3356. {
  3357. foreach (bool l3 in YP.univ(Term, new ListPair(Name, TermArgs)))
  3358. {
  3359. if (YP.atom(Name))
  3360. {
  3361. foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, Atom.NIL)))
  3362. {
  3363. foreach (bool l6 in unaryFunction(Name, FunctionName))
  3364. {
  3365. foreach (bool l7 in compileExpression(X1, State, Arg1))
  3366. {
  3367. foreach (bool l8 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, Atom.NIL))))
  3368. {
  3369. yield return true;
  3370. yield break;
  3371. }
  3372. }
  3373. goto cutIf1;
  3374. }
  3375. }
  3376. foreach (bool l5 in YP.unify(Term, new ListPair(x9, Atom.NIL)))
  3377. {
  3378. foreach (bool l6 in compileTerm(Term, State, Result))
  3379. {
  3380. yield return true;
  3381. yield break;
  3382. }
  3383. goto cutIf2;
  3384. }
  3385. foreach (bool l5 in YP.unify(TermArgs, new ListPair(X1, new ListPair(X2, Atom.NIL))))
  3386. {
  3387. foreach (bool l6 in binaryFunction(Name, FunctionName))
  3388. {
  3389. foreach (bool l7 in compileExpression(X1, State, Arg1))
  3390. {
  3391. foreach (bool l8 in compileExpression(X2, State, Arg2))
  3392. {
  3393. foreach (bool l9 in YP.unify(Result, new Functor2(@"call", FunctionName, new ListPair(Arg1, new ListPair(Arg2, Atom.NIL)))))
  3394. {
  3395. yield return true;
  3396. yield break;
  3397. }
  3398. }
  3399. }
  3400. goto cutIf3;
  3401. }
  3402. }
  3403. foreach (bool l5 in YP.functor(Term, x12, Arity))
  3404. {
  3405. YP.throwException(new Functor2(@"error", new Functor2(@"type_error", Atom.a(@"evaluable"), new Functor2(@"/", Name, Arity)), Atom.a(@"Not an expression function")));
  3406. yield return false;
  3407. }
  3408. cutIf3:
  3409. cutIf2:
  3410. cutIf1:
  3411. { }
  3412. }
  3413. }
  3414. }
  3415. }
  3416. {
  3417. foreach (bool l2 in compileTerm(Term, State, Result))
  3418. {
  3419. yield return true;
  3420. yield break;
  3421. }
  3422. }
  3423. }
  3424. public static IEnumerable<bool> unaryFunction(object arg1, object arg2)
  3425. {
  3426. {
  3427. foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
  3428. {
  3429. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.negate")))
  3430. {
  3431. yield return true;
  3432. yield break;
  3433. }
  3434. }
  3435. }
  3436. {
  3437. foreach (bool l2 in YP.unify(arg1, Atom.a(@"abs")))
  3438. {
  3439. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.abs")))
  3440. {
  3441. yield return true;
  3442. yield break;
  3443. }
  3444. }
  3445. }
  3446. {
  3447. foreach (bool l2 in YP.unify(arg1, Atom.a(@"sign")))
  3448. {
  3449. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sign")))
  3450. {
  3451. yield return true;
  3452. yield break;
  3453. }
  3454. }
  3455. }
  3456. {
  3457. foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
  3458. {
  3459. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.floor")))
  3460. {
  3461. yield return true;
  3462. yield break;
  3463. }
  3464. }
  3465. }
  3466. {
  3467. foreach (bool l2 in YP.unify(arg1, Atom.a(@"truncate")))
  3468. {
  3469. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.truncate")))
  3470. {
  3471. yield return true;
  3472. yield break;
  3473. }
  3474. }
  3475. }
  3476. {
  3477. foreach (bool l2 in YP.unify(arg1, Atom.a(@"round")))
  3478. {
  3479. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.round")))
  3480. {
  3481. yield return true;
  3482. yield break;
  3483. }
  3484. }
  3485. }
  3486. {
  3487. foreach (bool l2 in YP.unify(arg1, Atom.a(@"floor")))
  3488. {
  3489. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.ceiling")))
  3490. {
  3491. yield return true;
  3492. yield break;
  3493. }
  3494. }
  3495. }
  3496. {
  3497. foreach (bool l2 in YP.unify(arg1, Atom.a(@"sin")))
  3498. {
  3499. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sin")))
  3500. {
  3501. yield return true;
  3502. yield break;
  3503. }
  3504. }
  3505. }
  3506. {
  3507. foreach (bool l2 in YP.unify(arg1, Atom.a(@"cos")))
  3508. {
  3509. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.cos")))
  3510. {
  3511. yield return true;
  3512. yield break;
  3513. }
  3514. }
  3515. }
  3516. {
  3517. foreach (bool l2 in YP.unify(arg1, Atom.a(@"atan")))
  3518. {
  3519. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.atan")))
  3520. {
  3521. yield return true;
  3522. yield break;
  3523. }
  3524. }
  3525. }
  3526. {
  3527. foreach (bool l2 in YP.unify(arg1, Atom.a(@"exp")))
  3528. {
  3529. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.exp")))
  3530. {
  3531. yield return true;
  3532. yield break;
  3533. }
  3534. }
  3535. }
  3536. {
  3537. foreach (bool l2 in YP.unify(arg1, Atom.a(@"log")))
  3538. {
  3539. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.log")))
  3540. {
  3541. yield return true;
  3542. yield break;
  3543. }
  3544. }
  3545. }
  3546. {
  3547. foreach (bool l2 in YP.unify(arg1, Atom.a(@"sqrt")))
  3548. {
  3549. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.sqrt")))
  3550. {
  3551. yield return true;
  3552. yield break;
  3553. }
  3554. }
  3555. }
  3556. {
  3557. foreach (bool l2 in YP.unify(arg1, Atom.a(@"\")))
  3558. {
  3559. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseComplement")))
  3560. {
  3561. yield return true;
  3562. yield break;
  3563. }
  3564. }
  3565. }
  3566. }
  3567. public static IEnumerable<bool> binaryFunction(object arg1, object arg2)
  3568. {
  3569. {
  3570. foreach (bool l2 in YP.unify(arg1, Atom.a(@"+")))
  3571. {
  3572. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.add")))
  3573. {
  3574. yield return true;
  3575. yield break;
  3576. }
  3577. }
  3578. }
  3579. {
  3580. foreach (bool l2 in YP.unify(arg1, Atom.a(@"-")))
  3581. {
  3582. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.subtract")))
  3583. {
  3584. yield return true;
  3585. yield break;
  3586. }
  3587. }
  3588. }
  3589. {
  3590. foreach (bool l2 in YP.unify(arg1, Atom.a(@"*")))
  3591. {
  3592. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.multiply")))
  3593. {
  3594. yield return true;
  3595. yield break;
  3596. }
  3597. }
  3598. }
  3599. {
  3600. foreach (bool l2 in YP.unify(arg1, Atom.a(@"/")))
  3601. {
  3602. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.divide")))
  3603. {
  3604. yield return true;
  3605. yield break;
  3606. }
  3607. }
  3608. }
  3609. {
  3610. foreach (bool l2 in YP.unify(arg1, Atom.a(@"//")))
  3611. {
  3612. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.intDivide")))
  3613. {
  3614. yield return true;
  3615. yield break;
  3616. }
  3617. }
  3618. }
  3619. {
  3620. foreach (bool l2 in YP.unify(arg1, Atom.a(@"mod")))
  3621. {
  3622. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.mod")))
  3623. {
  3624. yield return true;
  3625. yield break;
  3626. }
  3627. }
  3628. }
  3629. {
  3630. foreach (bool l2 in YP.unify(arg1, Atom.a(@"**")))
  3631. {
  3632. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.pow")))
  3633. {
  3634. yield return true;
  3635. yield break;
  3636. }
  3637. }
  3638. }
  3639. {
  3640. foreach (bool l2 in YP.unify(arg1, Atom.a(@">>")))
  3641. {
  3642. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftRight")))
  3643. {
  3644. yield return true;
  3645. yield break;
  3646. }
  3647. }
  3648. }
  3649. {
  3650. foreach (bool l2 in YP.unify(arg1, Atom.a(@"<<")))
  3651. {
  3652. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseShiftLeft")))
  3653. {
  3654. yield return true;
  3655. yield break;
  3656. }
  3657. }
  3658. }
  3659. {
  3660. foreach (bool l2 in YP.unify(arg1, Atom.a(@"/\")))
  3661. {
  3662. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseAnd")))
  3663. {
  3664. yield return true;
  3665. yield break;
  3666. }
  3667. }
  3668. }
  3669. {
  3670. foreach (bool l2 in YP.unify(arg1, Atom.a(@"\/")))
  3671. {
  3672. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.bitwiseOr")))
  3673. {
  3674. yield return true;
  3675. yield break;
  3676. }
  3677. }
  3678. }
  3679. {
  3680. foreach (bool l2 in YP.unify(arg1, Atom.a(@"min")))
  3681. {
  3682. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.min")))
  3683. {
  3684. yield return true;
  3685. yield break;
  3686. }
  3687. }
  3688. }
  3689. {
  3690. foreach (bool l2 in YP.unify(arg1, Atom.a(@"max")))
  3691. {
  3692. foreach (bool l3 in YP.unify(arg2, Atom.a(@"YP.max")))
  3693. {
  3694. yield return true;
  3695. yield break;
  3696. }
  3697. }
  3698. }
  3699. }
  3700. public static void convertFunctionCSharp(object arg1)
  3701. {
  3702. {
  3703. foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
  3704. {
  3705. YP.write(Atom.a(@"public class YPInnerClass {}"));
  3706. YP.nl();
  3707. YP.write(Atom.a(@"public static System.Type getDeclaringClass() { return typeof(YPInnerClass).DeclaringType; }"));
  3708. YP.nl();
  3709. YP.nl();
  3710. return;
  3711. }
  3712. }
  3713. {
  3714. Variable ReturnType = new Variable();
  3715. Variable Name = new Variable();
  3716. Variable ArgList = new Variable();
  3717. Variable Body = new Variable();
  3718. Variable Level = new Variable();
  3719. foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { ReturnType, Name, ArgList, Body })))
  3720. {
  3721. YP.write(Atom.a(@"public static "));
  3722. YP.write(ReturnType);
  3723. YP.write(Atom.a(@" "));
  3724. YP.write(Name);
  3725. YP.write(Atom.a(@"("));
  3726. convertArgListCSharp(ArgList);
  3727. YP.write(Atom.a(@") {"));
  3728. YP.nl();
  3729. foreach (bool l3 in YP.unify(Level, 1))
  3730. {
  3731. convertStatementListCSharp(Body, Level);
  3732. YP.write(Atom.a(@"}"));
  3733. YP.nl();
  3734. YP.nl();
  3735. return;
  3736. }
  3737. }
  3738. }
  3739. }
  3740. public static IEnumerable<bool> convertStatementListCSharp(object arg1, object x1, object x2)
  3741. {
  3742. {
  3743. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  3744. {
  3745. yield return true;
  3746. yield break;
  3747. }
  3748. }
  3749. }
  3750. public static void convertStatementListCSharp(object arg1, object Level)
  3751. {
  3752. {
  3753. Variable Name = new Variable();
  3754. Variable Body = new Variable();
  3755. Variable RestStatements = new Variable();
  3756. Variable NewStatements = new Variable();
  3757. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
  3758. {
  3759. foreach (bool l3 in append(Body, new ListPair(new Functor1(@"label", Name), RestStatements), NewStatements))
  3760. {
  3761. convertStatementListCSharp(NewStatements, Level);
  3762. return;
  3763. }
  3764. }
  3765. }
  3766. {
  3767. Variable Type = new Variable();
  3768. Variable Name = new Variable();
  3769. Variable Expression = new Variable();
  3770. Variable RestStatements = new Variable();
  3771. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", Type, Name, Expression), RestStatements)))
  3772. {
  3773. convertIndentationCSharp(Level);
  3774. YP.write(Type);
  3775. YP.write(Atom.a(@" "));
  3776. YP.write(Name);
  3777. YP.write(Atom.a(@" = "));
  3778. convertExpressionCSharp(Expression);
  3779. YP.write(Atom.a(@";"));
  3780. YP.nl();
  3781. convertStatementListCSharp(RestStatements, Level);
  3782. return;
  3783. }
  3784. }
  3785. {
  3786. Variable Name = new Variable();
  3787. Variable Expression = new Variable();
  3788. Variable RestStatements = new Variable();
  3789. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
  3790. {
  3791. convertIndentationCSharp(Level);
  3792. YP.write(Name);
  3793. YP.write(Atom.a(@" = "));
  3794. convertExpressionCSharp(Expression);
  3795. YP.write(Atom.a(@";"));
  3796. YP.nl();
  3797. convertStatementListCSharp(RestStatements, Level);
  3798. return;
  3799. }
  3800. }
  3801. {
  3802. Variable RestStatements = new Variable();
  3803. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
  3804. {
  3805. convertIndentationCSharp(Level);
  3806. YP.write(Atom.a(@"yield return true;"));
  3807. YP.nl();
  3808. convertStatementListCSharp(RestStatements, Level);
  3809. return;
  3810. }
  3811. }
  3812. {
  3813. Variable RestStatements = new Variable();
  3814. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
  3815. {
  3816. convertIndentationCSharp(Level);
  3817. YP.write(Atom.a(@"yield return false;"));
  3818. YP.nl();
  3819. convertStatementListCSharp(RestStatements, Level);
  3820. return;
  3821. }
  3822. }
  3823. {
  3824. Variable RestStatements = new Variable();
  3825. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
  3826. {
  3827. convertIndentationCSharp(Level);
  3828. YP.write(Atom.a(@"yield break;"));
  3829. YP.nl();
  3830. convertStatementListCSharp(RestStatements, Level);
  3831. return;
  3832. }
  3833. }
  3834. {
  3835. Variable RestStatements = new Variable();
  3836. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
  3837. {
  3838. convertIndentationCSharp(Level);
  3839. YP.write(Atom.a(@"return;"));
  3840. YP.nl();
  3841. convertStatementListCSharp(RestStatements, Level);
  3842. return;
  3843. }
  3844. }
  3845. {
  3846. Variable RestStatements = new Variable();
  3847. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
  3848. {
  3849. convertIndentationCSharp(Level);
  3850. YP.write(Atom.a(@"return true;"));
  3851. YP.nl();
  3852. convertStatementListCSharp(RestStatements, Level);
  3853. return;
  3854. }
  3855. }
  3856. {
  3857. Variable RestStatements = new Variable();
  3858. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
  3859. {
  3860. convertIndentationCSharp(Level);
  3861. YP.write(Atom.a(@"return false;"));
  3862. YP.nl();
  3863. convertStatementListCSharp(RestStatements, Level);
  3864. return;
  3865. }
  3866. }
  3867. {
  3868. Variable Name = new Variable();
  3869. Variable RestStatements = new Variable();
  3870. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"label", Name), RestStatements)))
  3871. {
  3872. convertIndentationCSharp(Level);
  3873. YP.write(Name);
  3874. YP.write(Atom.a(@":"));
  3875. YP.nl();
  3876. if (YP.termEqual(RestStatements, Atom.NIL))
  3877. {
  3878. convertIndentationCSharp(Level);
  3879. YP.write(Atom.a(@"{}"));
  3880. YP.nl();
  3881. convertStatementListCSharp(RestStatements, Level);
  3882. return;
  3883. // goto cutIf1;
  3884. }
  3885. convertStatementListCSharp(RestStatements, Level);
  3886. return;
  3887. // cutIf1:
  3888. // { }
  3889. }
  3890. }
  3891. {
  3892. Variable Name = new Variable();
  3893. Variable RestStatements = new Variable();
  3894. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
  3895. {
  3896. convertIndentationCSharp(Level);
  3897. YP.write(Atom.a(@"goto "));
  3898. YP.write(Name);
  3899. YP.write(Atom.a(@";"));
  3900. YP.nl();
  3901. convertStatementListCSharp(RestStatements, Level);
  3902. return;
  3903. }
  3904. }
  3905. {
  3906. Variable Name = new Variable();
  3907. Variable ArgList = new Variable();
  3908. Variable RestStatements = new Variable();
  3909. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
  3910. {
  3911. convertIndentationCSharp(Level);
  3912. YP.write(Name);
  3913. YP.write(Atom.a(@"("));
  3914. convertArgListCSharp(ArgList);
  3915. YP.write(Atom.a(@");"));
  3916. YP.nl();
  3917. convertStatementListCSharp(RestStatements, Level);
  3918. return;
  3919. }
  3920. }
  3921. {
  3922. Variable Obj = new Variable();
  3923. Variable Name = new Variable();
  3924. Variable ArgList = new Variable();
  3925. Variable RestStatements = new Variable();
  3926. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
  3927. {
  3928. convertIndentationCSharp(Level);
  3929. YP.write(Obj);
  3930. YP.write(Atom.a(@"."));
  3931. YP.write(Name);
  3932. YP.write(Atom.a(@"("));
  3933. convertArgListCSharp(ArgList);
  3934. YP.write(Atom.a(@");"));
  3935. YP.nl();
  3936. convertStatementListCSharp(RestStatements, Level);
  3937. return;
  3938. }
  3939. }
  3940. {
  3941. Variable Body = new Variable();
  3942. Variable RestStatements = new Variable();
  3943. Variable NextLevel = new Variable();
  3944. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
  3945. {
  3946. convertIndentationCSharp(Level);
  3947. YP.write(Atom.a(@"{"));
  3948. YP.nl();
  3949. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  3950. {
  3951. convertStatementListCSharp(Body, NextLevel);
  3952. convertIndentationCSharp(Level);
  3953. YP.write(Atom.a(@"}"));
  3954. YP.nl();
  3955. convertStatementListCSharp(RestStatements, Level);
  3956. return;
  3957. }
  3958. }
  3959. }
  3960. {
  3961. Variable Expression = new Variable();
  3962. Variable Body = new Variable();
  3963. Variable RestStatements = new Variable();
  3964. Variable NextLevel = new Variable();
  3965. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
  3966. {
  3967. convertIndentationCSharp(Level);
  3968. YP.write(Atom.a(@"if ("));
  3969. convertExpressionCSharp(Expression);
  3970. YP.write(Atom.a(@") {"));
  3971. YP.nl();
  3972. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  3973. {
  3974. convertStatementListCSharp(Body, NextLevel);
  3975. convertIndentationCSharp(Level);
  3976. YP.write(Atom.a(@"}"));
  3977. YP.nl();
  3978. convertStatementListCSharp(RestStatements, Level);
  3979. return;
  3980. }
  3981. }
  3982. }
  3983. {
  3984. Variable Expression = new Variable();
  3985. Variable Body = new Variable();
  3986. Variable RestStatements = new Variable();
  3987. Variable NextLevel = new Variable();
  3988. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
  3989. {
  3990. convertIndentationCSharp(Level);
  3991. YP.write(Atom.a(@"foreach (bool l"));
  3992. YP.write(Level);
  3993. YP.write(Atom.a(@" in "));
  3994. convertExpressionCSharp(Expression);
  3995. YP.write(Atom.a(@") {"));
  3996. YP.nl();
  3997. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  3998. {
  3999. convertStatementListCSharp(Body, NextLevel);
  4000. convertIndentationCSharp(Level);
  4001. YP.write(Atom.a(@"}"));
  4002. YP.nl();
  4003. convertStatementListCSharp(RestStatements, Level);
  4004. return;
  4005. }
  4006. }
  4007. }
  4008. {
  4009. Variable Expression = new Variable();
  4010. Variable RestStatements = new Variable();
  4011. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
  4012. {
  4013. convertIndentationCSharp(Level);
  4014. YP.write(Atom.a(@"throw "));
  4015. convertExpressionCSharp(Expression);
  4016. YP.write(Atom.a(@";"));
  4017. YP.nl();
  4018. convertStatementListCSharp(RestStatements, Level);
  4019. return;
  4020. }
  4021. }
  4022. }
  4023. public static void convertIndentationCSharp(object Level)
  4024. {
  4025. {
  4026. Variable N = new Variable();
  4027. foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
  4028. {
  4029. repeatWrite(Atom.a(@" "), N);
  4030. return;
  4031. }
  4032. }
  4033. }
  4034. public static void convertArgListCSharp(object arg1)
  4035. {
  4036. {
  4037. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  4038. {
  4039. return;
  4040. }
  4041. }
  4042. {
  4043. Variable Head = new Variable();
  4044. Variable Tail = new Variable();
  4045. foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
  4046. {
  4047. convertExpressionCSharp(Head);
  4048. if (YP.termNotEqual(Tail, Atom.NIL))
  4049. {
  4050. YP.write(Atom.a(@", "));
  4051. convertArgListCSharp(Tail);
  4052. return;
  4053. // goto cutIf1;
  4054. }
  4055. convertArgListCSharp(Tail);
  4056. return;
  4057. // cutIf1:
  4058. // { }
  4059. }
  4060. }
  4061. }
  4062. public static void convertExpressionCSharp(object arg1)
  4063. {
  4064. {
  4065. Variable X = new Variable();
  4066. foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
  4067. {
  4068. YP.write(Atom.a(@"object "));
  4069. YP.write(X);
  4070. return;
  4071. }
  4072. }
  4073. {
  4074. Variable Name = new Variable();
  4075. Variable ArgList = new Variable();
  4076. foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
  4077. {
  4078. YP.write(Name);
  4079. YP.write(Atom.a(@"("));
  4080. convertArgListCSharp(ArgList);
  4081. YP.write(Atom.a(@")"));
  4082. return;
  4083. }
  4084. }
  4085. {
  4086. Variable Obj = new Variable();
  4087. Variable Name = new Variable();
  4088. Variable ArgList = new Variable();
  4089. foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
  4090. {
  4091. YP.write(Obj);
  4092. YP.write(Atom.a(@"."));
  4093. YP.write(Name);
  4094. YP.write(Atom.a(@"("));
  4095. convertArgListCSharp(ArgList);
  4096. YP.write(Atom.a(@")"));
  4097. return;
  4098. }
  4099. }
  4100. {
  4101. Variable Name = new Variable();
  4102. Variable ArgList = new Variable();
  4103. foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
  4104. {
  4105. YP.write(Atom.a(@"new "));
  4106. YP.write(Name);
  4107. YP.write(Atom.a(@"("));
  4108. convertArgListCSharp(ArgList);
  4109. YP.write(Atom.a(@")"));
  4110. return;
  4111. }
  4112. }
  4113. {
  4114. Variable Name = new Variable();
  4115. foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
  4116. {
  4117. YP.write(Name);
  4118. return;
  4119. }
  4120. }
  4121. {
  4122. foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
  4123. {
  4124. YP.write(Atom.a(@"null"));
  4125. return;
  4126. }
  4127. }
  4128. {
  4129. Variable X = new Variable();
  4130. foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
  4131. {
  4132. YP.write(Atom.a(@"!("));
  4133. convertExpressionCSharp(X);
  4134. YP.write(Atom.a(@")"));
  4135. return;
  4136. }
  4137. }
  4138. {
  4139. Variable X = new Variable();
  4140. Variable Y = new Variable();
  4141. foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
  4142. {
  4143. YP.write(Atom.a(@"("));
  4144. convertExpressionCSharp(X);
  4145. YP.write(Atom.a(@") && ("));
  4146. convertExpressionCSharp(Y);
  4147. YP.write(Atom.a(@")"));
  4148. return;
  4149. }
  4150. }
  4151. {
  4152. Variable ArgList = new Variable();
  4153. foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
  4154. {
  4155. YP.write(Atom.a(@"new object[] {"));
  4156. convertArgListCSharp(ArgList);
  4157. YP.write(Atom.a(@"}"));
  4158. return;
  4159. }
  4160. }
  4161. {
  4162. Variable X = new Variable();
  4163. Variable Codes = new Variable();
  4164. foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
  4165. {
  4166. if (YP.atom(X))
  4167. {
  4168. YP.write(Atom.a(@"@"""));
  4169. foreach (bool l4 in YP.atom_codes(X, Codes))
  4170. {
  4171. convertStringCodesCSharp(Codes);
  4172. YP.write(Atom.a(@""""));
  4173. return;
  4174. }
  4175. }
  4176. }
  4177. }
  4178. {
  4179. Variable X = new Variable();
  4180. foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
  4181. {
  4182. YP.write(X);
  4183. return;
  4184. }
  4185. }
  4186. }
  4187. public static void convertStringCodesCSharp(object arg1)
  4188. {
  4189. {
  4190. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  4191. {
  4192. return;
  4193. }
  4194. }
  4195. {
  4196. Variable Code = new Variable();
  4197. Variable RestCodes = new Variable();
  4198. foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
  4199. {
  4200. if (YP.termEqual(Code, 34))
  4201. {
  4202. YP.put_code(34);
  4203. YP.put_code(Code);
  4204. convertStringCodesCSharp(RestCodes);
  4205. return;
  4206. // goto cutIf1;
  4207. }
  4208. YP.put_code(Code);
  4209. convertStringCodesCSharp(RestCodes);
  4210. return;
  4211. // cutIf1:
  4212. // { }
  4213. }
  4214. }
  4215. }
  4216. public static void convertFunctionJavascript(object arg1)
  4217. {
  4218. {
  4219. foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
  4220. {
  4221. YP.write(Atom.a(@"function getDeclaringClass() { return null; }"));
  4222. YP.nl();
  4223. return;
  4224. }
  4225. }
  4226. {
  4227. Variable x1 = new Variable();
  4228. Variable Name = new Variable();
  4229. Variable ArgList = new Variable();
  4230. Variable Body = new Variable();
  4231. foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
  4232. {
  4233. YP.write(Atom.a(@"function "));
  4234. YP.write(Name);
  4235. YP.write(Atom.a(@"("));
  4236. convertArgListJavascript(ArgList);
  4237. YP.write(Atom.a(@") {"));
  4238. YP.nl();
  4239. convertStatementListJavascript(Body, 1);
  4240. YP.write(Atom.a(@"}"));
  4241. YP.nl();
  4242. YP.nl();
  4243. return;
  4244. }
  4245. }
  4246. }
  4247. public static void convertStatementListJavascript(object arg1, object arg2)
  4248. {
  4249. {
  4250. object x1 = arg2;
  4251. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  4252. {
  4253. return;
  4254. }
  4255. }
  4256. {
  4257. object Level = arg2;
  4258. Variable Name = new Variable();
  4259. Variable Body = new Variable();
  4260. Variable RestStatements = new Variable();
  4261. Variable NextLevel = new Variable();
  4262. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
  4263. {
  4264. convertIndentationJavascript(Level);
  4265. YP.write(Name);
  4266. YP.write(Atom.a(@":"));
  4267. YP.nl();
  4268. convertIndentationJavascript(Level);
  4269. YP.write(Atom.a(@"{"));
  4270. YP.nl();
  4271. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  4272. {
  4273. convertStatementListJavascript(Body, NextLevel);
  4274. convertIndentationJavascript(Level);
  4275. YP.write(Atom.a(@"}"));
  4276. YP.nl();
  4277. convertStatementListJavascript(RestStatements, Level);
  4278. return;
  4279. }
  4280. }
  4281. }
  4282. {
  4283. object Level = arg2;
  4284. Variable _Type = new Variable();
  4285. Variable Name = new Variable();
  4286. Variable Expression = new Variable();
  4287. Variable RestStatements = new Variable();
  4288. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
  4289. {
  4290. convertIndentationJavascript(Level);
  4291. YP.write(Atom.a(@"var "));
  4292. YP.write(Name);
  4293. YP.write(Atom.a(@" = "));
  4294. convertExpressionJavascript(Expression);
  4295. YP.write(Atom.a(@";"));
  4296. YP.nl();
  4297. convertStatementListJavascript(RestStatements, Level);
  4298. return;
  4299. }
  4300. }
  4301. {
  4302. object Level = arg2;
  4303. Variable Name = new Variable();
  4304. Variable Expression = new Variable();
  4305. Variable RestStatements = new Variable();
  4306. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
  4307. {
  4308. convertIndentationJavascript(Level);
  4309. YP.write(Name);
  4310. YP.write(Atom.a(@" = "));
  4311. convertExpressionJavascript(Expression);
  4312. YP.write(Atom.a(@";"));
  4313. YP.nl();
  4314. convertStatementListJavascript(RestStatements, Level);
  4315. return;
  4316. }
  4317. }
  4318. {
  4319. object Level = arg2;
  4320. Variable RestStatements = new Variable();
  4321. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
  4322. {
  4323. convertIndentationJavascript(Level);
  4324. YP.write(Atom.a(@"yield true;"));
  4325. YP.nl();
  4326. convertStatementListJavascript(RestStatements, Level);
  4327. return;
  4328. }
  4329. }
  4330. {
  4331. object Level = arg2;
  4332. Variable RestStatements = new Variable();
  4333. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
  4334. {
  4335. convertIndentationJavascript(Level);
  4336. YP.write(Atom.a(@"yield false;"));
  4337. YP.nl();
  4338. convertStatementListJavascript(RestStatements, Level);
  4339. return;
  4340. }
  4341. }
  4342. {
  4343. object Level = arg2;
  4344. Variable RestStatements = new Variable();
  4345. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
  4346. {
  4347. convertIndentationJavascript(Level);
  4348. YP.write(Atom.a(@"return;"));
  4349. YP.nl();
  4350. convertStatementListJavascript(RestStatements, Level);
  4351. return;
  4352. }
  4353. }
  4354. {
  4355. object Level = arg2;
  4356. Variable RestStatements = new Variable();
  4357. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
  4358. {
  4359. convertIndentationJavascript(Level);
  4360. YP.write(Atom.a(@"return;"));
  4361. YP.nl();
  4362. convertStatementListJavascript(RestStatements, Level);
  4363. return;
  4364. }
  4365. }
  4366. {
  4367. object Level = arg2;
  4368. Variable RestStatements = new Variable();
  4369. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
  4370. {
  4371. convertIndentationJavascript(Level);
  4372. YP.write(Atom.a(@"return true;"));
  4373. YP.nl();
  4374. convertStatementListJavascript(RestStatements, Level);
  4375. return;
  4376. }
  4377. }
  4378. {
  4379. object Level = arg2;
  4380. Variable RestStatements = new Variable();
  4381. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
  4382. {
  4383. convertIndentationJavascript(Level);
  4384. YP.write(Atom.a(@"return false;"));
  4385. YP.nl();
  4386. convertStatementListJavascript(RestStatements, Level);
  4387. return;
  4388. }
  4389. }
  4390. {
  4391. object Level = arg2;
  4392. Variable Name = new Variable();
  4393. Variable RestStatements = new Variable();
  4394. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
  4395. {
  4396. convertIndentationJavascript(Level);
  4397. YP.write(Atom.a(@"break "));
  4398. YP.write(Name);
  4399. YP.write(Atom.a(@";"));
  4400. YP.nl();
  4401. convertStatementListJavascript(RestStatements, Level);
  4402. return;
  4403. }
  4404. }
  4405. {
  4406. object Level = arg2;
  4407. Variable Name = new Variable();
  4408. Variable ArgList = new Variable();
  4409. Variable RestStatements = new Variable();
  4410. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
  4411. {
  4412. convertIndentationJavascript(Level);
  4413. YP.write(Name);
  4414. YP.write(Atom.a(@"("));
  4415. convertArgListJavascript(ArgList);
  4416. YP.write(Atom.a(@");"));
  4417. YP.nl();
  4418. convertStatementListJavascript(RestStatements, Level);
  4419. return;
  4420. }
  4421. }
  4422. {
  4423. object Level = arg2;
  4424. Variable Obj = new Variable();
  4425. Variable Name = new Variable();
  4426. Variable ArgList = new Variable();
  4427. Variable RestStatements = new Variable();
  4428. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
  4429. {
  4430. convertIndentationJavascript(Level);
  4431. YP.write(Obj);
  4432. YP.write(Atom.a(@"."));
  4433. YP.write(Name);
  4434. YP.write(Atom.a(@"("));
  4435. convertArgListJavascript(ArgList);
  4436. YP.write(Atom.a(@");"));
  4437. YP.nl();
  4438. convertStatementListJavascript(RestStatements, Level);
  4439. return;
  4440. }
  4441. }
  4442. {
  4443. object Level = arg2;
  4444. Variable Body = new Variable();
  4445. Variable RestStatements = new Variable();
  4446. Variable NextLevel = new Variable();
  4447. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
  4448. {
  4449. convertIndentationJavascript(Level);
  4450. YP.write(Atom.a(@"{"));
  4451. YP.nl();
  4452. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  4453. {
  4454. convertStatementListJavascript(Body, NextLevel);
  4455. convertIndentationJavascript(Level);
  4456. YP.write(Atom.a(@"}"));
  4457. YP.nl();
  4458. convertStatementListJavascript(RestStatements, Level);
  4459. return;
  4460. }
  4461. }
  4462. }
  4463. {
  4464. object Level = arg2;
  4465. Variable Expression = new Variable();
  4466. Variable Body = new Variable();
  4467. Variable RestStatements = new Variable();
  4468. Variable NextLevel = new Variable();
  4469. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
  4470. {
  4471. convertIndentationJavascript(Level);
  4472. YP.write(Atom.a(@"if ("));
  4473. convertExpressionJavascript(Expression);
  4474. YP.write(Atom.a(@") {"));
  4475. YP.nl();
  4476. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  4477. {
  4478. convertStatementListJavascript(Body, NextLevel);
  4479. convertIndentationJavascript(Level);
  4480. YP.write(Atom.a(@"}"));
  4481. YP.nl();
  4482. convertStatementListJavascript(RestStatements, Level);
  4483. return;
  4484. }
  4485. }
  4486. }
  4487. {
  4488. object Level = arg2;
  4489. Variable Expression = new Variable();
  4490. Variable Body = new Variable();
  4491. Variable RestStatements = new Variable();
  4492. Variable NextLevel = new Variable();
  4493. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
  4494. {
  4495. convertIndentationJavascript(Level);
  4496. YP.write(Atom.a(@"for each (var l"));
  4497. YP.write(Level);
  4498. YP.write(Atom.a(@" in "));
  4499. convertExpressionJavascript(Expression);
  4500. YP.write(Atom.a(@") {"));
  4501. YP.nl();
  4502. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  4503. {
  4504. convertStatementListJavascript(Body, NextLevel);
  4505. convertIndentationJavascript(Level);
  4506. YP.write(Atom.a(@"}"));
  4507. YP.nl();
  4508. convertStatementListJavascript(RestStatements, Level);
  4509. return;
  4510. }
  4511. }
  4512. }
  4513. {
  4514. object Level = arg2;
  4515. Variable Expression = new Variable();
  4516. Variable RestStatements = new Variable();
  4517. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
  4518. {
  4519. convertIndentationJavascript(Level);
  4520. YP.write(Atom.a(@"throw "));
  4521. convertExpressionJavascript(Expression);
  4522. YP.write(Atom.a(@";"));
  4523. YP.nl();
  4524. convertStatementListJavascript(RestStatements, Level);
  4525. return;
  4526. }
  4527. }
  4528. }
  4529. public static void convertIndentationJavascript(object Level)
  4530. {
  4531. {
  4532. Variable N = new Variable();
  4533. foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
  4534. {
  4535. repeatWrite(Atom.a(@" "), N);
  4536. return;
  4537. }
  4538. }
  4539. }
  4540. public static void convertArgListJavascript(object arg1)
  4541. {
  4542. {
  4543. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  4544. {
  4545. return;
  4546. }
  4547. }
  4548. {
  4549. Variable Head = new Variable();
  4550. Variable Tail = new Variable();
  4551. foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
  4552. {
  4553. convertExpressionJavascript(Head);
  4554. if (YP.termNotEqual(Tail, Atom.NIL))
  4555. {
  4556. YP.write(Atom.a(@", "));
  4557. convertArgListJavascript(Tail);
  4558. return;
  4559. // goto cutIf1;
  4560. }
  4561. convertArgListJavascript(Tail);
  4562. return;
  4563. // cutIf1:
  4564. // { }
  4565. }
  4566. }
  4567. }
  4568. public static void convertExpressionJavascript(object arg1)
  4569. {
  4570. {
  4571. Variable X = new Variable();
  4572. foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
  4573. {
  4574. YP.write(X);
  4575. return;
  4576. }
  4577. }
  4578. {
  4579. Variable Name = new Variable();
  4580. Variable ArgList = new Variable();
  4581. foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
  4582. {
  4583. YP.write(Name);
  4584. YP.write(Atom.a(@"("));
  4585. convertArgListJavascript(ArgList);
  4586. YP.write(Atom.a(@")"));
  4587. return;
  4588. }
  4589. }
  4590. {
  4591. Variable Obj = new Variable();
  4592. Variable Name = new Variable();
  4593. Variable ArgList = new Variable();
  4594. foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
  4595. {
  4596. YP.write(Obj);
  4597. YP.write(Atom.a(@"."));
  4598. YP.write(Name);
  4599. YP.write(Atom.a(@"("));
  4600. convertArgListJavascript(ArgList);
  4601. YP.write(Atom.a(@")"));
  4602. return;
  4603. }
  4604. }
  4605. {
  4606. Variable Name = new Variable();
  4607. Variable ArgList = new Variable();
  4608. foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
  4609. {
  4610. YP.write(Atom.a(@"new "));
  4611. YP.write(Name);
  4612. YP.write(Atom.a(@"("));
  4613. convertArgListJavascript(ArgList);
  4614. YP.write(Atom.a(@")"));
  4615. return;
  4616. }
  4617. }
  4618. {
  4619. Variable Name = new Variable();
  4620. foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
  4621. {
  4622. YP.write(Name);
  4623. return;
  4624. }
  4625. }
  4626. {
  4627. foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
  4628. {
  4629. YP.write(Atom.a(@"null"));
  4630. return;
  4631. }
  4632. }
  4633. {
  4634. Variable X = new Variable();
  4635. foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
  4636. {
  4637. YP.write(Atom.a(@"!("));
  4638. convertExpressionJavascript(X);
  4639. YP.write(Atom.a(@")"));
  4640. return;
  4641. }
  4642. }
  4643. {
  4644. Variable X = new Variable();
  4645. Variable Y = new Variable();
  4646. foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
  4647. {
  4648. YP.write(Atom.a(@"("));
  4649. convertExpressionJavascript(X);
  4650. YP.write(Atom.a(@") && ("));
  4651. convertExpressionJavascript(Y);
  4652. YP.write(Atom.a(@")"));
  4653. return;
  4654. }
  4655. }
  4656. {
  4657. Variable ArgList = new Variable();
  4658. foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
  4659. {
  4660. YP.write(Atom.a(@"["));
  4661. convertArgListJavascript(ArgList);
  4662. YP.write(Atom.a(@"]"));
  4663. return;
  4664. }
  4665. }
  4666. {
  4667. Variable X = new Variable();
  4668. Variable Codes = new Variable();
  4669. foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
  4670. {
  4671. if (YP.atom(X))
  4672. {
  4673. YP.write(Atom.a(@""""));
  4674. foreach (bool l4 in YP.atom_codes(X, Codes))
  4675. {
  4676. convertStringCodesJavascript(Codes);
  4677. YP.write(Atom.a(@""""));
  4678. return;
  4679. }
  4680. }
  4681. }
  4682. }
  4683. {
  4684. Variable X = new Variable();
  4685. foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
  4686. {
  4687. YP.write(X);
  4688. return;
  4689. }
  4690. }
  4691. }
  4692. public static void convertStringCodesJavascript(object arg1)
  4693. {
  4694. {
  4695. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  4696. {
  4697. return;
  4698. }
  4699. }
  4700. {
  4701. Variable Code = new Variable();
  4702. Variable RestCodes = new Variable();
  4703. foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
  4704. {
  4705. if (YP.termEqual(Code, 34))
  4706. {
  4707. YP.put_code(92);
  4708. YP.put_code(Code);
  4709. convertStringCodesJavascript(RestCodes);
  4710. return;
  4711. // goto cutIf1;
  4712. }
  4713. if (YP.termEqual(Code, 92))
  4714. {
  4715. YP.put_code(92);
  4716. YP.put_code(Code);
  4717. convertStringCodesJavascript(RestCodes);
  4718. return;
  4719. // goto cutIf1;
  4720. }
  4721. YP.put_code(Code);
  4722. convertStringCodesJavascript(RestCodes);
  4723. return;
  4724. // cutIf1:
  4725. // { }
  4726. }
  4727. }
  4728. }
  4729. public static void convertFunctionPython(object arg1)
  4730. {
  4731. {
  4732. foreach (bool l2 in YP.unify(arg1, Atom.a(@"getDeclaringClass")))
  4733. {
  4734. YP.write(Atom.a(@"def getDeclaringClass():"));
  4735. YP.nl();
  4736. YP.write(Atom.a(@" return None"));
  4737. YP.nl();
  4738. YP.nl();
  4739. return;
  4740. }
  4741. }
  4742. {
  4743. Variable x1 = new Variable();
  4744. Variable Name = new Variable();
  4745. Variable ArgList = new Variable();
  4746. Variable Body = new Variable();
  4747. Variable Level = new Variable();
  4748. Variable HasBreakableBlock = new Variable();
  4749. foreach (bool l2 in YP.unify(arg1, new Functor(@"function", new object[] { x1, Name, ArgList, Body })))
  4750. {
  4751. YP.write(Atom.a(@"def "));
  4752. YP.write(Name);
  4753. YP.write(Atom.a(@"("));
  4754. convertArgListPython(ArgList);
  4755. YP.write(Atom.a(@"):"));
  4756. YP.nl();
  4757. foreach (bool l3 in YP.unify(Level, 1))
  4758. {
  4759. if (hasBreakableBlockPython(Body))
  4760. {
  4761. foreach (bool l5 in YP.unify(HasBreakableBlock, 1))
  4762. {
  4763. if (YP.termEqual(HasBreakableBlock, 1))
  4764. {
  4765. convertIndentationPython(Level);
  4766. YP.write(Atom.a(@"doBreak = False"));
  4767. YP.nl();
  4768. foreach (bool l7 in convertStatementListPython(Body, Level, HasBreakableBlock))
  4769. {
  4770. YP.nl();
  4771. return;
  4772. }
  4773. goto cutIf2;
  4774. }
  4775. foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
  4776. {
  4777. YP.nl();
  4778. return;
  4779. }
  4780. cutIf2:
  4781. { }
  4782. }
  4783. goto cutIf1;
  4784. }
  4785. foreach (bool l4 in YP.unify(HasBreakableBlock, 0))
  4786. {
  4787. if (YP.termEqual(HasBreakableBlock, 1))
  4788. {
  4789. convertIndentationPython(Level);
  4790. YP.write(Atom.a(@"doBreak = False"));
  4791. YP.nl();
  4792. foreach (bool l6 in convertStatementListPython(Body, Level, HasBreakableBlock))
  4793. {
  4794. YP.nl();
  4795. return;
  4796. }
  4797. goto cutIf3;
  4798. }
  4799. foreach (bool l5 in convertStatementListPython(Body, Level, HasBreakableBlock))
  4800. {
  4801. YP.nl();
  4802. return;
  4803. }
  4804. cutIf3:
  4805. { }
  4806. }
  4807. cutIf1:
  4808. { }
  4809. }
  4810. }
  4811. }
  4812. }
  4813. public static bool hasBreakableBlockPython(object arg1)
  4814. {
  4815. {
  4816. Variable _Name = new Variable();
  4817. Variable _Body = new Variable();
  4818. Variable _RestStatements = new Variable();
  4819. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", _Name, _Body), _RestStatements)))
  4820. {
  4821. return true;
  4822. }
  4823. }
  4824. {
  4825. Variable Body = new Variable();
  4826. Variable _RestStatements = new Variable();
  4827. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), _RestStatements)))
  4828. {
  4829. if (hasBreakableBlockPython(Body))
  4830. {
  4831. return true;
  4832. }
  4833. }
  4834. }
  4835. {
  4836. Variable _Expression = new Variable();
  4837. Variable Body = new Variable();
  4838. Variable _RestStatements = new Variable();
  4839. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", _Expression, Body), _RestStatements)))
  4840. {
  4841. if (hasBreakableBlockPython(Body))
  4842. {
  4843. return true;
  4844. }
  4845. }
  4846. }
  4847. {
  4848. Variable _Expression = new Variable();
  4849. Variable Body = new Variable();
  4850. Variable _RestStatements = new Variable();
  4851. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", _Expression, Body), _RestStatements)))
  4852. {
  4853. if (hasBreakableBlockPython(Body))
  4854. {
  4855. return true;
  4856. }
  4857. }
  4858. }
  4859. {
  4860. Variable x1 = new Variable();
  4861. Variable RestStatements = new Variable();
  4862. foreach (bool l2 in YP.unify(arg1, new ListPair(x1, RestStatements)))
  4863. {
  4864. if (hasBreakableBlockPython(RestStatements))
  4865. {
  4866. return true;
  4867. }
  4868. }
  4869. }
  4870. return false;
  4871. }
  4872. public static IEnumerable<bool> convertStatementListPython(object arg1, object arg2, object arg3)
  4873. {
  4874. {
  4875. object x1 = arg2;
  4876. object x2 = arg3;
  4877. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  4878. {
  4879. yield return true;
  4880. yield break;
  4881. }
  4882. }
  4883. {
  4884. object Level = arg2;
  4885. object HasBreakableBlock = arg3;
  4886. Variable Name = new Variable();
  4887. Variable Body = new Variable();
  4888. Variable RestStatements = new Variable();
  4889. Variable NextLevel = new Variable();
  4890. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"breakableBlock", Name, Body), RestStatements)))
  4891. {
  4892. convertIndentationPython(Level);
  4893. YP.write(Name);
  4894. YP.write(Atom.a(@" = False"));
  4895. YP.nl();
  4896. convertIndentationPython(Level);
  4897. YP.write(Atom.a(@"for _ in [1]:"));
  4898. YP.nl();
  4899. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  4900. {
  4901. foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
  4902. {
  4903. convertIndentationPython(Level);
  4904. YP.write(Atom.a(@"if "));
  4905. YP.write(Name);
  4906. YP.write(Atom.a(@":"));
  4907. YP.nl();
  4908. convertIndentationPython(NextLevel);
  4909. YP.write(Atom.a(@"doBreak = False"));
  4910. YP.nl();
  4911. convertIndentationPython(Level);
  4912. YP.write(Atom.a(@"if doBreak:"));
  4913. YP.nl();
  4914. convertIndentationPython(NextLevel);
  4915. YP.write(Atom.a(@"break"));
  4916. YP.nl();
  4917. foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  4918. {
  4919. yield return true;
  4920. yield break;
  4921. }
  4922. }
  4923. }
  4924. }
  4925. }
  4926. {
  4927. object Level = arg2;
  4928. object HasBreakableBlock = arg3;
  4929. Variable _Type = new Variable();
  4930. Variable Name = new Variable();
  4931. Variable Expression = new Variable();
  4932. Variable RestStatements = new Variable();
  4933. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"declare", _Type, Name, Expression), RestStatements)))
  4934. {
  4935. convertIndentationPython(Level);
  4936. YP.write(Name);
  4937. YP.write(Atom.a(@" = "));
  4938. convertExpressionPython(Expression);
  4939. YP.nl();
  4940. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  4941. {
  4942. yield return true;
  4943. yield break;
  4944. }
  4945. }
  4946. }
  4947. {
  4948. object Level = arg2;
  4949. object HasBreakableBlock = arg3;
  4950. Variable Name = new Variable();
  4951. Variable Expression = new Variable();
  4952. Variable RestStatements = new Variable();
  4953. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"assign", Name, Expression), RestStatements)))
  4954. {
  4955. convertIndentationPython(Level);
  4956. YP.write(Name);
  4957. YP.write(Atom.a(@" = "));
  4958. convertExpressionPython(Expression);
  4959. YP.nl();
  4960. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  4961. {
  4962. yield return true;
  4963. yield break;
  4964. }
  4965. }
  4966. }
  4967. {
  4968. object Level = arg2;
  4969. object HasBreakableBlock = arg3;
  4970. Variable RestStatements = new Variable();
  4971. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldtrue"), RestStatements)))
  4972. {
  4973. convertIndentationPython(Level);
  4974. YP.write(Atom.a(@"yield True"));
  4975. YP.nl();
  4976. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  4977. {
  4978. yield return true;
  4979. yield break;
  4980. }
  4981. }
  4982. }
  4983. {
  4984. object Level = arg2;
  4985. object HasBreakableBlock = arg3;
  4986. Variable RestStatements = new Variable();
  4987. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldfalse"), RestStatements)))
  4988. {
  4989. convertIndentationPython(Level);
  4990. YP.write(Atom.a(@"yield False"));
  4991. YP.nl();
  4992. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  4993. {
  4994. yield return true;
  4995. yield break;
  4996. }
  4997. }
  4998. }
  4999. {
  5000. object Level = arg2;
  5001. object HasBreakableBlock = arg3;
  5002. Variable RestStatements = new Variable();
  5003. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"yieldbreak"), RestStatements)))
  5004. {
  5005. convertIndentationPython(Level);
  5006. YP.write(Atom.a(@"return"));
  5007. YP.nl();
  5008. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5009. {
  5010. yield return true;
  5011. yield break;
  5012. }
  5013. }
  5014. }
  5015. {
  5016. object Level = arg2;
  5017. object HasBreakableBlock = arg3;
  5018. Variable RestStatements = new Variable();
  5019. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"return"), RestStatements)))
  5020. {
  5021. convertIndentationPython(Level);
  5022. YP.write(Atom.a(@"return"));
  5023. YP.nl();
  5024. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5025. {
  5026. yield return true;
  5027. yield break;
  5028. }
  5029. }
  5030. }
  5031. {
  5032. object Level = arg2;
  5033. object HasBreakableBlock = arg3;
  5034. Variable RestStatements = new Variable();
  5035. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returntrue"), RestStatements)))
  5036. {
  5037. convertIndentationPython(Level);
  5038. YP.write(Atom.a(@"return True"));
  5039. YP.nl();
  5040. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5041. {
  5042. yield return true;
  5043. yield break;
  5044. }
  5045. }
  5046. }
  5047. {
  5048. object Level = arg2;
  5049. object HasBreakableBlock = arg3;
  5050. Variable RestStatements = new Variable();
  5051. foreach (bool l2 in YP.unify(arg1, new ListPair(Atom.a(@"returnfalse"), RestStatements)))
  5052. {
  5053. convertIndentationPython(Level);
  5054. YP.write(Atom.a(@"return False"));
  5055. YP.nl();
  5056. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5057. {
  5058. yield return true;
  5059. yield break;
  5060. }
  5061. }
  5062. }
  5063. {
  5064. object Level = arg2;
  5065. object HasBreakableBlock = arg3;
  5066. Variable Name = new Variable();
  5067. Variable RestStatements = new Variable();
  5068. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"breakBlock", Name), RestStatements)))
  5069. {
  5070. convertIndentationPython(Level);
  5071. YP.write(Name);
  5072. YP.write(Atom.a(@" = True"));
  5073. YP.nl();
  5074. convertIndentationPython(Level);
  5075. YP.write(Atom.a(@"doBreak = True"));
  5076. YP.nl();
  5077. convertIndentationPython(Level);
  5078. YP.write(Atom.a(@"break"));
  5079. YP.nl();
  5080. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5081. {
  5082. yield return true;
  5083. yield break;
  5084. }
  5085. }
  5086. }
  5087. {
  5088. object Level = arg2;
  5089. object HasBreakableBlock = arg3;
  5090. Variable Name = new Variable();
  5091. Variable ArgList = new Variable();
  5092. Variable RestStatements = new Variable();
  5093. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"call", Name, ArgList), RestStatements)))
  5094. {
  5095. convertIndentationPython(Level);
  5096. YP.write(Name);
  5097. YP.write(Atom.a(@"("));
  5098. convertArgListPython(ArgList);
  5099. YP.write(Atom.a(@")"));
  5100. YP.nl();
  5101. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5102. {
  5103. yield return true;
  5104. yield break;
  5105. }
  5106. }
  5107. }
  5108. {
  5109. object Level = arg2;
  5110. object HasBreakableBlock = arg3;
  5111. Variable Obj = new Variable();
  5112. Variable Name = new Variable();
  5113. Variable ArgList = new Variable();
  5114. Variable RestStatements = new Variable();
  5115. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList), RestStatements)))
  5116. {
  5117. convertIndentationPython(Level);
  5118. YP.write(Obj);
  5119. YP.write(Atom.a(@"."));
  5120. YP.write(Name);
  5121. YP.write(Atom.a(@"("));
  5122. convertArgListPython(ArgList);
  5123. YP.write(Atom.a(@")"));
  5124. YP.nl();
  5125. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5126. {
  5127. yield return true;
  5128. yield break;
  5129. }
  5130. }
  5131. }
  5132. {
  5133. object Level = arg2;
  5134. object HasBreakableBlock = arg3;
  5135. Variable Body = new Variable();
  5136. Variable RestStatements = new Variable();
  5137. Variable NextLevel = new Variable();
  5138. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"blockScope", Body), RestStatements)))
  5139. {
  5140. if (YP.termEqual(HasBreakableBlock, 1))
  5141. {
  5142. convertIndentationPython(Level);
  5143. YP.write(Atom.a(@"for _ in [1]:"));
  5144. YP.nl();
  5145. foreach (bool l4 in YP.unify(NextLevel, YP.add(Level, 1)))
  5146. {
  5147. foreach (bool l5 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
  5148. {
  5149. if (YP.termEqual(HasBreakableBlock, 1))
  5150. {
  5151. if (YP.greaterThan(Level, 1))
  5152. {
  5153. convertIndentationPython(Level);
  5154. YP.write(Atom.a(@"if doBreak:"));
  5155. YP.nl();
  5156. convertIndentationPython(NextLevel);
  5157. YP.write(Atom.a(@"break"));
  5158. YP.nl();
  5159. foreach (bool l8 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5160. {
  5161. yield return true;
  5162. yield break;
  5163. }
  5164. goto cutIf3;
  5165. }
  5166. foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5167. {
  5168. yield return true;
  5169. yield break;
  5170. }
  5171. cutIf3:
  5172. goto cutIf2;
  5173. }
  5174. foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5175. {
  5176. yield return true;
  5177. yield break;
  5178. }
  5179. cutIf2:
  5180. { }
  5181. }
  5182. }
  5183. goto cutIf1;
  5184. }
  5185. foreach (bool l3 in YP.unify(NextLevel, Level))
  5186. {
  5187. foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
  5188. {
  5189. if (YP.termEqual(HasBreakableBlock, 1))
  5190. {
  5191. if (YP.greaterThan(Level, 1))
  5192. {
  5193. convertIndentationPython(Level);
  5194. YP.write(Atom.a(@"if doBreak:"));
  5195. YP.nl();
  5196. convertIndentationPython(NextLevel);
  5197. YP.write(Atom.a(@"break"));
  5198. YP.nl();
  5199. foreach (bool l7 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5200. {
  5201. yield return true;
  5202. yield break;
  5203. }
  5204. goto cutIf5;
  5205. }
  5206. foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5207. {
  5208. yield return true;
  5209. yield break;
  5210. }
  5211. cutIf5:
  5212. goto cutIf4;
  5213. }
  5214. foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5215. {
  5216. yield return true;
  5217. yield break;
  5218. }
  5219. cutIf4:
  5220. { }
  5221. }
  5222. }
  5223. cutIf1:
  5224. { }
  5225. }
  5226. }
  5227. {
  5228. object Level = arg2;
  5229. object HasBreakableBlock = arg3;
  5230. Variable Expression = new Variable();
  5231. Variable Body = new Variable();
  5232. Variable RestStatements = new Variable();
  5233. Variable NextLevel = new Variable();
  5234. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"if", Expression, Body), RestStatements)))
  5235. {
  5236. convertIndentationPython(Level);
  5237. YP.write(Atom.a(@"if "));
  5238. convertExpressionPython(Expression);
  5239. YP.write(Atom.a(@":"));
  5240. YP.nl();
  5241. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  5242. {
  5243. foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
  5244. {
  5245. foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5246. {
  5247. yield return true;
  5248. yield break;
  5249. }
  5250. }
  5251. }
  5252. }
  5253. }
  5254. {
  5255. object Level = arg2;
  5256. object HasBreakableBlock = arg3;
  5257. Variable Expression = new Variable();
  5258. Variable Body = new Variable();
  5259. Variable RestStatements = new Variable();
  5260. Variable NextLevel = new Variable();
  5261. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor2(@"foreach", Expression, Body), RestStatements)))
  5262. {
  5263. convertIndentationPython(Level);
  5264. YP.write(Atom.a(@"for l"));
  5265. YP.write(Level);
  5266. YP.write(Atom.a(@" in "));
  5267. convertExpressionPython(Expression);
  5268. YP.write(Atom.a(@":"));
  5269. YP.nl();
  5270. foreach (bool l3 in YP.unify(NextLevel, YP.add(Level, 1)))
  5271. {
  5272. foreach (bool l4 in convertStatementListPython(Body, NextLevel, HasBreakableBlock))
  5273. {
  5274. if (YP.termEqual(HasBreakableBlock, 1))
  5275. {
  5276. convertIndentationPython(Level);
  5277. YP.write(Atom.a(@"if doBreak:"));
  5278. YP.nl();
  5279. convertIndentationPython(NextLevel);
  5280. YP.write(Atom.a(@"break"));
  5281. YP.nl();
  5282. foreach (bool l6 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5283. {
  5284. yield return true;
  5285. yield break;
  5286. }
  5287. goto cutIf6;
  5288. }
  5289. foreach (bool l5 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5290. {
  5291. yield return true;
  5292. yield break;
  5293. }
  5294. cutIf6:
  5295. { }
  5296. }
  5297. }
  5298. }
  5299. }
  5300. {
  5301. object Level = arg2;
  5302. object HasBreakableBlock = arg3;
  5303. Variable Expression = new Variable();
  5304. Variable RestStatements = new Variable();
  5305. foreach (bool l2 in YP.unify(arg1, new ListPair(new Functor1(@"throw", Expression), RestStatements)))
  5306. {
  5307. convertIndentationPython(Level);
  5308. YP.write(Atom.a(@"raise "));
  5309. convertExpressionPython(Expression);
  5310. YP.nl();
  5311. foreach (bool l3 in convertStatementListPython(RestStatements, Level, HasBreakableBlock))
  5312. {
  5313. yield return true;
  5314. yield break;
  5315. }
  5316. }
  5317. }
  5318. }
  5319. public static void convertIndentationPython(object Level)
  5320. {
  5321. {
  5322. Variable N = new Variable();
  5323. foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
  5324. {
  5325. repeatWrite(Atom.a(@" "), N);
  5326. return;
  5327. }
  5328. }
  5329. }
  5330. public static void convertArgListPython(object arg1)
  5331. {
  5332. {
  5333. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  5334. {
  5335. return;
  5336. }
  5337. }
  5338. {
  5339. Variable Head = new Variable();
  5340. Variable Tail = new Variable();
  5341. foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
  5342. {
  5343. convertExpressionPython(Head);
  5344. if (YP.termNotEqual(Tail, Atom.NIL))
  5345. {
  5346. YP.write(Atom.a(@", "));
  5347. convertArgListPython(Tail);
  5348. return;
  5349. // goto cutIf1;
  5350. }
  5351. convertArgListPython(Tail);
  5352. return;
  5353. // cutIf1:
  5354. // { }
  5355. }
  5356. }
  5357. }
  5358. public static void convertExpressionPython(object arg1)
  5359. {
  5360. {
  5361. Variable X = new Variable();
  5362. foreach (bool l2 in YP.unify(arg1, new Functor1(@"arg", X)))
  5363. {
  5364. YP.write(X);
  5365. return;
  5366. }
  5367. }
  5368. {
  5369. Variable Name = new Variable();
  5370. Variable ArgList = new Variable();
  5371. foreach (bool l2 in YP.unify(arg1, new Functor2(@"call", Name, ArgList)))
  5372. {
  5373. YP.write(Name);
  5374. YP.write(Atom.a(@"("));
  5375. convertArgListPython(ArgList);
  5376. YP.write(Atom.a(@")"));
  5377. return;
  5378. }
  5379. }
  5380. {
  5381. Variable Obj = new Variable();
  5382. Variable Name = new Variable();
  5383. Variable ArgList = new Variable();
  5384. foreach (bool l2 in YP.unify(arg1, new Functor3(@"callMember", new Functor1(@"var", Obj), Name, ArgList)))
  5385. {
  5386. YP.write(Obj);
  5387. YP.write(Atom.a(@"."));
  5388. YP.write(Name);
  5389. YP.write(Atom.a(@"("));
  5390. convertArgListPython(ArgList);
  5391. YP.write(Atom.a(@")"));
  5392. return;
  5393. }
  5394. }
  5395. {
  5396. Variable Name = new Variable();
  5397. Variable ArgList = new Variable();
  5398. foreach (bool l2 in YP.unify(arg1, new Functor2(@"new", Name, ArgList)))
  5399. {
  5400. YP.write(Name);
  5401. YP.write(Atom.a(@"("));
  5402. convertArgListPython(ArgList);
  5403. YP.write(Atom.a(@")"));
  5404. return;
  5405. }
  5406. }
  5407. {
  5408. Variable Name = new Variable();
  5409. foreach (bool l2 in YP.unify(arg1, new Functor1(@"var", Name)))
  5410. {
  5411. YP.write(Name);
  5412. return;
  5413. }
  5414. }
  5415. {
  5416. foreach (bool l2 in YP.unify(arg1, Atom.a(@"null")))
  5417. {
  5418. YP.write(Atom.a(@"None"));
  5419. return;
  5420. }
  5421. }
  5422. {
  5423. Variable X = new Variable();
  5424. foreach (bool l2 in YP.unify(arg1, new Functor1(@"not", X)))
  5425. {
  5426. YP.write(Atom.a(@"not ("));
  5427. convertExpressionPython(X);
  5428. YP.write(Atom.a(@")"));
  5429. return;
  5430. }
  5431. }
  5432. {
  5433. Variable X = new Variable();
  5434. Variable Y = new Variable();
  5435. foreach (bool l2 in YP.unify(arg1, new Functor2(@"and", X, Y)))
  5436. {
  5437. YP.write(Atom.a(@"("));
  5438. convertExpressionPython(X);
  5439. YP.write(Atom.a(@") and ("));
  5440. convertExpressionPython(Y);
  5441. YP.write(Atom.a(@")"));
  5442. return;
  5443. }
  5444. }
  5445. {
  5446. Variable ArgList = new Variable();
  5447. foreach (bool l2 in YP.unify(arg1, new Functor1(@"objectArray", ArgList)))
  5448. {
  5449. YP.write(Atom.a(@"["));
  5450. convertArgListPython(ArgList);
  5451. YP.write(Atom.a(@"]"));
  5452. return;
  5453. }
  5454. }
  5455. {
  5456. Variable X = new Variable();
  5457. Variable Codes = new Variable();
  5458. foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
  5459. {
  5460. if (YP.atom(X))
  5461. {
  5462. YP.write(Atom.a(@""""));
  5463. foreach (bool l4 in YP.atom_codes(X, Codes))
  5464. {
  5465. convertStringCodesPython(Codes);
  5466. YP.write(Atom.a(@""""));
  5467. return;
  5468. }
  5469. }
  5470. }
  5471. }
  5472. {
  5473. Variable X = new Variable();
  5474. foreach (bool l2 in YP.unify(arg1, new Functor1(@"object", X)))
  5475. {
  5476. YP.write(X);
  5477. return;
  5478. }
  5479. }
  5480. }
  5481. public static void convertStringCodesPython(object arg1)
  5482. {
  5483. {
  5484. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  5485. {
  5486. return;
  5487. }
  5488. }
  5489. {
  5490. Variable Code = new Variable();
  5491. Variable RestCodes = new Variable();
  5492. foreach (bool l2 in YP.unify(arg1, new ListPair(Code, RestCodes)))
  5493. {
  5494. if (YP.termEqual(Code, 34))
  5495. {
  5496. YP.put_code(92);
  5497. YP.put_code(Code);
  5498. convertStringCodesPython(RestCodes);
  5499. return;
  5500. // goto cutIf1;
  5501. }
  5502. if (YP.termEqual(Code, 92))
  5503. {
  5504. YP.put_code(92);
  5505. YP.put_code(Code);
  5506. convertStringCodesPython(RestCodes);
  5507. return;
  5508. // goto cutIf1;
  5509. }
  5510. YP.put_code(Code);
  5511. convertStringCodesPython(RestCodes);
  5512. return;
  5513. // cutIf1:
  5514. // { }
  5515. }
  5516. }
  5517. }
  5518. public static IEnumerable<bool> member(object X, object arg2)
  5519. {
  5520. {
  5521. Variable x2 = new Variable();
  5522. foreach (bool l2 in YP.unify(arg2, new ListPair(X, x2)))
  5523. {
  5524. yield return false;
  5525. }
  5526. }
  5527. {
  5528. Variable x2 = new Variable();
  5529. Variable Rest = new Variable();
  5530. foreach (bool l2 in YP.unify(arg2, new ListPair(x2, Rest)))
  5531. {
  5532. foreach (bool l3 in member(X, Rest))
  5533. {
  5534. yield return false;
  5535. }
  5536. }
  5537. }
  5538. }
  5539. public static IEnumerable<bool> append(object arg1, object arg2, object arg3)
  5540. {
  5541. {
  5542. Variable List = new Variable();
  5543. foreach (bool l2 in YP.unify(arg1, Atom.NIL))
  5544. {
  5545. foreach (bool l3 in YP.unify(arg2, List))
  5546. {
  5547. foreach (bool l4 in YP.unify(arg3, List))
  5548. {
  5549. yield return false;
  5550. }
  5551. }
  5552. }
  5553. }
  5554. {
  5555. object List2 = arg2;
  5556. Variable X = new Variable();
  5557. Variable List1 = new Variable();
  5558. Variable List12 = new Variable();
  5559. foreach (bool l2 in YP.unify(arg1, new ListPair(X, List1)))
  5560. {
  5561. foreach (bool l3 in YP.unify(arg3, new ListPair(X, List12)))
  5562. {
  5563. foreach (bool l4 in append(List1, List2, List12))
  5564. {
  5565. yield return false;
  5566. }
  5567. }
  5568. }
  5569. }
  5570. }
  5571. #pragma warning restore 0168
  5572. }
  5573. }