YPCompiler.cs 279 KB

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