| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708 |
- commit 000a3b649e1ad2c4a49480b297896ff8f652d21b
- Author: Oliver Fabel <28701799+ofabel@users.noreply.github.com>
- Date: Tue Apr 16 17:06:38 2024 +0200
- library update
- diff --git a/extmod/modjson.c b/extmod/modjson.c
- index 1772b7299..e655a02bc 100644
- --- a/extmod/modjson.c
- +++ b/extmod/modjson.c
- @@ -41,7 +41,7 @@ enum {
- DUMP_MODE_TO_STREAM = 2,
- };
-
- -STATIC mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) {
- +static mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) {
- enum { ARG_separators };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_separators, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
- @@ -78,34 +78,34 @@ STATIC mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp
- }
- }
-
- -STATIC mp_obj_t mod_json_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- +static mp_obj_t mod_json_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STREAM);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dump_obj, 2, mod_json_dump);
- +static MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dump_obj, 2, mod_json_dump);
-
- -STATIC mp_obj_t mod_json_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- +static mp_obj_t mod_json_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STRING);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dumps_obj, 1, mod_json_dumps);
- +static MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dumps_obj, 1, mod_json_dumps);
-
- #else
-
- -STATIC mp_obj_t mod_json_dump(mp_obj_t obj, mp_obj_t stream) {
- +static mp_obj_t mod_json_dump(mp_obj_t obj, mp_obj_t stream) {
- mp_get_stream_raise(stream, MP_STREAM_OP_WRITE);
- mp_print_t print = {MP_OBJ_TO_PTR(stream), mp_stream_write_adaptor};
- mp_obj_print_helper(&print, obj, PRINT_JSON);
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_json_dump_obj, mod_json_dump);
- +static MP_DEFINE_CONST_FUN_OBJ_2(mod_json_dump_obj, mod_json_dump);
-
- -STATIC mp_obj_t mod_json_dumps(mp_obj_t obj) {
- +static mp_obj_t mod_json_dumps(mp_obj_t obj) {
- vstr_t vstr;
- mp_print_t print;
- vstr_init_print(&vstr, 8, &print);
- mp_obj_print_helper(&print, obj, PRINT_JSON);
- return mp_obj_new_str_from_utf8_vstr(&vstr);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_dumps_obj, mod_json_dumps);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_dumps_obj, mod_json_dumps);
-
- #endif
-
- @@ -134,7 +134,7 @@ typedef struct _json_stream_t {
- #define S_CUR(s) ((s).cur)
- #define S_NEXT(s) (json_stream_next(&(s)))
-
- -STATIC byte json_stream_next(json_stream_t *s) {
- +static byte json_stream_next(json_stream_t *s) {
- mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode);
- if (s->errcode != 0) {
- mp_raise_OSError(s->errcode);
- @@ -145,7 +145,7 @@ STATIC byte json_stream_next(json_stream_t *s) {
- return s->cur;
- }
-
- -STATIC mp_obj_t mod_json_load(mp_obj_t stream_obj) {
- +static mp_obj_t mod_json_load(mp_obj_t stream_obj) {
- const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
- json_stream_t s = {stream_obj, stream_p->read, 0, 0};
- vstr_t vstr;
- @@ -355,18 +355,18 @@ success:
- fail:
- mp_raise_ValueError(MP_ERROR_TEXT("syntax error in JSON"));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_load_obj, mod_json_load);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_load_obj, mod_json_load);
-
- -STATIC mp_obj_t mod_json_loads(mp_obj_t obj) {
- +static mp_obj_t mod_json_loads(mp_obj_t obj) {
- mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(obj, &bufinfo, MP_BUFFER_READ);
- vstr_t vstr = {bufinfo.len, bufinfo.len, (char *)bufinfo.buf, true};
- mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL};
- return mod_json_load(MP_OBJ_FROM_PTR(&sio));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads);
-
- -STATIC const mp_rom_map_elem_t mp_module_json_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_json_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_json) },
- { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_json_dump_obj) },
- { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_json_dumps_obj) },
- @@ -374,7 +374,7 @@ STATIC const mp_rom_map_elem_t mp_module_json_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_json_loads_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table);
-
- const mp_obj_module_t mp_module_json = {
- .base = { &mp_type_module },
- diff --git a/extmod/modrandom.c b/extmod/modrandom.c
- index e65f31488..79a1b18ba 100644
- --- a/extmod/modrandom.c
- +++ b/extmod/modrandom.c
- @@ -46,16 +46,16 @@
- #if !MICROPY_ENABLE_DYNRUNTIME
- #if SEED_ON_IMPORT
- // If the state is seeded on import then keep these variables in the BSS.
- -STATIC uint32_t yasmarang_pad, yasmarang_n, yasmarang_d;
- -STATIC uint8_t yasmarang_dat;
- +static uint32_t yasmarang_pad, yasmarang_n, yasmarang_d;
- +static uint8_t yasmarang_dat;
- #else
- // Without seed-on-import these variables must be initialised via the data section.
- -STATIC uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233;
- -STATIC uint8_t yasmarang_dat = 0;
- +static uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233;
- +static uint8_t yasmarang_dat = 0;
- #endif
- #endif
-
- -STATIC uint32_t yasmarang(void) {
- +static uint32_t yasmarang(void) {
- yasmarang_pad += yasmarang_dat + yasmarang_d * yasmarang_n;
- yasmarang_pad = (yasmarang_pad << 3) + (yasmarang_pad >> 29);
- yasmarang_n = yasmarang_pad | 2;
- @@ -71,7 +71,7 @@ STATIC uint32_t yasmarang(void) {
-
- // returns an unsigned integer below the given argument
- // n must not be zero
- -STATIC uint32_t yasmarang_randbelow(uint32_t n) {
- +static uint32_t yasmarang_randbelow(uint32_t n) {
- uint32_t mask = 1;
- while ((n & mask) < n) {
- mask = (mask << 1) | 1;
- @@ -85,8 +85,8 @@ STATIC uint32_t yasmarang_randbelow(uint32_t n) {
-
- #endif
-
- -STATIC mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
- - int n = mp_obj_get_int(num_in);
- +static mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
- + mp_int_t n = mp_obj_get_int(num_in);
- if (n > 32 || n < 0) {
- mp_raise_ValueError(MP_ERROR_TEXT("bits must be 32 or less"));
- }
- @@ -98,9 +98,9 @@ STATIC mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
- mask >>= (32 - n);
- return mp_obj_new_int_from_uint(yasmarang() & mask);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits);
-
- -STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
- mp_uint_t seed;
- if (n_args == 0 || args[0] == mp_const_none) {
- #ifdef MICROPY_PY_RANDOM_SEED_INIT_FUNC
- @@ -111,22 +111,22 @@ STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
- } else {
- seed = mp_obj_get_int_truncated(args[0]);
- }
- - yasmarang_pad = seed;
- + yasmarang_pad = (uint32_t)seed;
- yasmarang_n = 69;
- yasmarang_d = 233;
- yasmarang_dat = 0;
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed);
-
- #if MICROPY_PY_RANDOM_EXTRA_FUNCS
-
- -STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
- mp_int_t start = mp_obj_get_int(args[0]);
- if (n_args == 1) {
- // range(stop)
- if (start > 0) {
- - return mp_obj_new_int(yasmarang_randbelow(start));
- + return mp_obj_new_int(yasmarang_randbelow((uint32_t)start));
- } else {
- goto error;
- }
- @@ -135,7 +135,7 @@ STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
- if (n_args == 2) {
- // range(start, stop)
- if (start < stop) {
- - return mp_obj_new_int(start + yasmarang_randbelow(stop - start));
- + return mp_obj_new_int(start + yasmarang_randbelow((uint32_t)(stop - start)));
- } else {
- goto error;
- }
- @@ -151,7 +151,7 @@ STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
- goto error;
- }
- if (n > 0) {
- - return mp_obj_new_int(start + step * yasmarang_randbelow(n));
- + return mp_obj_new_int(start + step * yasmarang_randbelow((uint32_t)n));
- } else {
- goto error;
- }
- @@ -161,33 +161,33 @@ STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
- error:
- mp_raise_ValueError(NULL);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange);
-
- -STATIC mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) {
- +static mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) {
- mp_int_t a = mp_obj_get_int(a_in);
- mp_int_t b = mp_obj_get_int(b_in);
- if (a <= b) {
- - return mp_obj_new_int(a + yasmarang_randbelow(b - a + 1));
- + return mp_obj_new_int(a + yasmarang_randbelow((uint32_t)(b - a + 1)));
- } else {
- mp_raise_ValueError(NULL);
- }
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint);
- +static MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint);
-
- -STATIC mp_obj_t mod_random_choice(mp_obj_t seq) {
- +static mp_obj_t mod_random_choice(mp_obj_t seq) {
- mp_int_t len = mp_obj_get_int(mp_obj_len(seq));
- if (len > 0) {
- - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL);
- + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow((uint32_t)len)), MP_OBJ_SENTINEL);
- } else {
- mp_raise_type(&mp_type_IndexError);
- }
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice);
-
- #if MICROPY_PY_BUILTINS_FLOAT
-
- // returns a number in the range [0..1) using Yasmarang to fill in the fraction bits
- -STATIC mp_float_t yasmarang_float(void) {
- +static mp_float_t yasmarang_float(void) {
- mp_float_union_t u;
- u.p.sgn = 0;
- u.p.exp = (1 << (MP_FLOAT_EXP_BITS - 1)) - 1;
- @@ -199,24 +199,24 @@ STATIC mp_float_t yasmarang_float(void) {
- return u.f - 1;
- }
-
- -STATIC mp_obj_t mod_random_random(void) {
- +static mp_obj_t mod_random_random(void) {
- return mp_obj_new_float(yasmarang_float());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random);
-
- -STATIC mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) {
- +static mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) {
- mp_float_t a = mp_obj_get_float(a_in);
- mp_float_t b = mp_obj_get_float(b_in);
- return mp_obj_new_float(a + (b - a) * yasmarang_float());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform);
- +static MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform);
-
- #endif
-
- #endif // MICROPY_PY_RANDOM_EXTRA_FUNCS
-
- #if SEED_ON_IMPORT
- -STATIC mp_obj_t mod_random___init__(void) {
- +static mp_obj_t mod_random___init__(void) {
- // This module may be imported by more than one name so need to ensure
- // that it's only ever seeded once.
- static bool seeded = false;
- @@ -226,11 +226,11 @@ STATIC mp_obj_t mod_random___init__(void) {
- }
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random___init___obj, mod_random___init__);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mod_random___init___obj, mod_random___init__);
- #endif
-
- #if !MICROPY_ENABLE_DYNRUNTIME
- -STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_random_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_random) },
- #if SEED_ON_IMPORT
- { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&mod_random___init___obj) },
- @@ -248,7 +248,7 @@ STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table);
-
- const mp_obj_module_t mp_module_random = {
- .base = { &mp_type_module },
- diff --git a/extmod/modtime.c b/extmod/modtime.c
- index 805c2621c..deb4bb4c9 100644
- --- a/extmod/modtime.c
- +++ b/extmod/modtime.c
- @@ -52,7 +52,7 @@
- // - second is 0-59
- // - weekday is 0-6 for Mon-Sun
- // - yearday is 1-366
- -STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
- if (n_args == 0 || args[0] == mp_const_none) {
- // Get current date and time.
- return mp_time_localtime_get();
- @@ -80,7 +80,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_time_localtime_obj, 0, 1, time_localtime)
- // This is the inverse function of localtime. Its argument is a full 8-tuple
- // which expresses a time as per localtime. It returns an integer which is
- // the number of seconds since the Epoch (eg 1st Jan 1970, or 1st Jan 2000).
- -STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
- +static mp_obj_t time_mktime(mp_obj_t tuple) {
- size_t len;
- mp_obj_t *elem;
- mp_obj_get_array(tuple, &len, &elem);
- @@ -102,21 +102,21 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_time_mktime_obj, time_mktime);
-
- // time()
- // Return the number of seconds since the Epoch.
- -STATIC mp_obj_t time_time(void) {
- +static mp_obj_t time_time(void) {
- return mp_time_time_get();
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_obj, time_time);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_obj, time_time);
-
- // time_ns()
- // Returns the number of nanoseconds since the Epoch, as an integer.
- -STATIC mp_obj_t time_time_ns(void) {
- +static mp_obj_t time_time_ns(void) {
- return mp_obj_new_int_from_ull(mp_hal_time_ns());
- }
- MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_ns_obj, time_time_ns);
-
- #endif // MICROPY_PY_TIME_TIME_TIME_NS
-
- -STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
- +static mp_obj_t time_sleep(mp_obj_t seconds_o) {
- #ifdef MICROPY_PY_TIME_CUSTOM_SLEEP
- mp_time_sleep(seconds_o);
- #else
- @@ -130,7 +130,7 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_obj, time_sleep);
-
- -STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
- +static mp_obj_t time_sleep_ms(mp_obj_t arg) {
- mp_int_t ms = mp_obj_get_int(arg);
- if (ms >= 0) {
- mp_hal_delay_ms(ms);
- @@ -139,7 +139,7 @@ STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_ms_obj, time_sleep_ms);
-
- -STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
- +static mp_obj_t time_sleep_us(mp_obj_t arg) {
- mp_int_t us = mp_obj_get_int(arg);
- if (us > 0) {
- mp_hal_delay_us(us);
- @@ -148,22 +148,22 @@ STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_us_obj, time_sleep_us);
-
- -STATIC mp_obj_t time_ticks_ms(void) {
- +static mp_obj_t time_ticks_ms(void) {
- return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
- }
- MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_ms_obj, time_ticks_ms);
-
- -STATIC mp_obj_t time_ticks_us(void) {
- +static mp_obj_t time_ticks_us(void) {
- return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
- }
- MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_us_obj, time_ticks_us);
-
- -STATIC mp_obj_t time_ticks_cpu(void) {
- +static mp_obj_t time_ticks_cpu(void) {
- return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
- }
- MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_cpu_obj, time_ticks_cpu);
-
- -STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
- +static mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
- // we assume that the arguments come from ticks_xx so are small ints
- mp_uint_t start = MP_OBJ_SMALL_INT_VALUE(start_in);
- mp_uint_t end = MP_OBJ_SMALL_INT_VALUE(end_in);
- @@ -175,7 +175,7 @@ STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_diff_obj, time_ticks_diff);
-
- -STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
- +static mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
- // we assume that first argument come from ticks_xx so is small int
- mp_uint_t ticks = MP_OBJ_SMALL_INT_VALUE(ticks_in);
- mp_uint_t delta = mp_obj_get_int(delta_in);
- @@ -196,7 +196,7 @@ STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_add_obj, time_ticks_add);
-
- -STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_time_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) },
-
- #if MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME
- @@ -224,7 +224,7 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
- MICROPY_PY_TIME_EXTRA_GLOBALS
- #endif
- };
- -STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
-
- const mp_obj_module_t mp_module_time = {
- .base = { &mp_type_module },
- diff --git a/genhdr/mpversion.h b/genhdr/mpversion.h
- index 529bcff07..65f0a26ae 100644
- --- a/genhdr/mpversion.h
- +++ b/genhdr/mpversion.h
- @@ -1,3 +1,4 @@
- // This file was generated by py/makeversionhdr.py
- -#define MICROPY_GIT_TAG "v1.22.2-dirty"
- +#define MICROPY_GIT_TAG "v1.23.0-preview.322.g5114f2c1e"
- +#define MICROPY_GIT_HASH "5114f2c1e"
- #define MICROPY_BUILD_DATE "2024-04-16"
- diff --git a/genhdr/qstrdefs.generated.h b/genhdr/qstrdefs.generated.h
- index 5e5196286..9c7c86451 100644
- --- a/genhdr/qstrdefs.generated.h
- +++ b/genhdr/qstrdefs.generated.h
- @@ -1,323 +1,323 @@
- // This file was automatically generated by makeqstrdata.py
-
- QDEF0(MP_QSTRnull, 0, 0, "")
- -QDEF0(MP_QSTR_, 5381, 0, "")
- -QDEF0(MP_QSTR___dir__, 36730, 7, "__dir__")
- -QDEF0(MP_QSTR__0x0a_, 46511, 1, "\x0a")
- -QDEF0(MP_QSTR__space_, 46469, 1, " ")
- -QDEF0(MP_QSTR__star_, 46479, 1, "*")
- -QDEF0(MP_QSTR__slash_, 46474, 1, "/")
- -QDEF0(MP_QSTR__lt_module_gt_, 38077, 8, "<module>")
- -QDEF0(MP_QSTR__, 46586, 1, "_")
- -QDEF0(MP_QSTR___call__, 63911, 8, "__call__")
- -QDEF0(MP_QSTR___class__, 50475, 9, "__class__")
- -QDEF0(MP_QSTR___delitem__, 13821, 11, "__delitem__")
- -QDEF0(MP_QSTR___enter__, 47725, 9, "__enter__")
- -QDEF0(MP_QSTR___exit__, 63557, 8, "__exit__")
- -QDEF0(MP_QSTR___getattr__, 63552, 11, "__getattr__")
- -QDEF0(MP_QSTR___getitem__, 14630, 11, "__getitem__")
- -QDEF0(MP_QSTR___hash__, 51447, 8, "__hash__")
- -QDEF0(MP_QSTR___init__, 42335, 8, "__init__")
- -QDEF0(MP_QSTR___int__, 6934, 7, "__int__")
- -QDEF0(MP_QSTR___iter__, 13007, 8, "__iter__")
- -QDEF0(MP_QSTR___len__, 45282, 7, "__len__")
- -QDEF0(MP_QSTR___main__, 5006, 8, "__main__")
- -QDEF0(MP_QSTR___module__, 12543, 10, "__module__")
- -QDEF0(MP_QSTR___name__, 14562, 8, "__name__")
- -QDEF0(MP_QSTR___new__, 5497, 7, "__new__")
- -QDEF0(MP_QSTR___next__, 29442, 8, "__next__")
- +QDEF0(MP_QSTR_, 5, 0, "")
- +QDEF0(MP_QSTR___dir__, 122, 7, "__dir__")
- +QDEF0(MP_QSTR__0x0a_, 175, 1, "\x0a")
- +QDEF0(MP_QSTR__space_, 133, 1, " ")
- +QDEF0(MP_QSTR__star_, 143, 1, "*")
- +QDEF0(MP_QSTR__slash_, 138, 1, "/")
- +QDEF0(MP_QSTR__lt_module_gt_, 189, 8, "<module>")
- +QDEF0(MP_QSTR__, 250, 1, "_")
- +QDEF0(MP_QSTR___call__, 167, 8, "__call__")
- +QDEF0(MP_QSTR___class__, 43, 9, "__class__")
- +QDEF0(MP_QSTR___delitem__, 253, 11, "__delitem__")
- +QDEF0(MP_QSTR___enter__, 109, 9, "__enter__")
- +QDEF0(MP_QSTR___exit__, 69, 8, "__exit__")
- +QDEF0(MP_QSTR___getattr__, 64, 11, "__getattr__")
- +QDEF0(MP_QSTR___getitem__, 38, 11, "__getitem__")
- +QDEF0(MP_QSTR___hash__, 247, 8, "__hash__")
- +QDEF0(MP_QSTR___init__, 95, 8, "__init__")
- +QDEF0(MP_QSTR___int__, 22, 7, "__int__")
- +QDEF0(MP_QSTR___iter__, 207, 8, "__iter__")
- +QDEF0(MP_QSTR___len__, 226, 7, "__len__")
- +QDEF0(MP_QSTR___main__, 142, 8, "__main__")
- +QDEF0(MP_QSTR___module__, 255, 10, "__module__")
- +QDEF0(MP_QSTR___name__, 226, 8, "__name__")
- +QDEF0(MP_QSTR___new__, 121, 7, "__new__")
- +QDEF0(MP_QSTR___next__, 2, 8, "__next__")
- QDEF0(MP_QSTR___qualname__, 107, 12, "__qualname__")
- -QDEF0(MP_QSTR___repr__, 2832, 8, "__repr__")
- -QDEF0(MP_QSTR___setitem__, 15922, 11, "__setitem__")
- -QDEF0(MP_QSTR___str__, 52688, 7, "__str__")
- -QDEF0(MP_QSTR_ArithmeticError, 35885, 15, "ArithmeticError")
- -QDEF0(MP_QSTR_AssertionError, 23191, 14, "AssertionError")
- -QDEF0(MP_QSTR_AttributeError, 56865, 14, "AttributeError")
- -QDEF0(MP_QSTR_BaseException, 37383, 13, "BaseException")
- -QDEF0(MP_QSTR_EOFError, 49041, 8, "EOFError")
- -QDEF0(MP_QSTR_Ellipsis, 57584, 8, "Ellipsis")
- -QDEF0(MP_QSTR_Exception, 10738, 9, "Exception")
- -QDEF0(MP_QSTR_GeneratorExit, 25110, 13, "GeneratorExit")
- -QDEF0(MP_QSTR_ImportError, 39968, 11, "ImportError")
- -QDEF0(MP_QSTR_IndentationError, 8284, 16, "IndentationError")
- -QDEF0(MP_QSTR_IndexError, 44419, 10, "IndexError")
- +QDEF0(MP_QSTR___repr__, 16, 8, "__repr__")
- +QDEF0(MP_QSTR___setitem__, 50, 11, "__setitem__")
- +QDEF0(MP_QSTR___str__, 208, 7, "__str__")
- +QDEF0(MP_QSTR_ArithmeticError, 45, 15, "ArithmeticError")
- +QDEF0(MP_QSTR_AssertionError, 151, 14, "AssertionError")
- +QDEF0(MP_QSTR_AttributeError, 33, 14, "AttributeError")
- +QDEF0(MP_QSTR_BaseException, 7, 13, "BaseException")
- +QDEF0(MP_QSTR_EOFError, 145, 8, "EOFError")
- +QDEF0(MP_QSTR_Ellipsis, 240, 8, "Ellipsis")
- +QDEF0(MP_QSTR_Exception, 242, 9, "Exception")
- +QDEF0(MP_QSTR_GeneratorExit, 22, 13, "GeneratorExit")
- +QDEF0(MP_QSTR_ImportError, 32, 11, "ImportError")
- +QDEF0(MP_QSTR_IndentationError, 92, 16, "IndentationError")
- +QDEF0(MP_QSTR_IndexError, 131, 10, "IndexError")
- QDEF0(MP_QSTR_KeyError, 234, 8, "KeyError")
- -QDEF0(MP_QSTR_KeyboardInterrupt, 58031, 17, "KeyboardInterrupt")
- -QDEF0(MP_QSTR_LookupError, 27135, 11, "LookupError")
- -QDEF0(MP_QSTR_MemoryError, 33756, 11, "MemoryError")
- -QDEF0(MP_QSTR_NameError, 11706, 9, "NameError")
- -QDEF0(MP_QSTR_NoneType, 26647, 8, "NoneType")
- -QDEF0(MP_QSTR_NotImplementedError, 39110, 19, "NotImplementedError")
- -QDEF0(MP_QSTR_OSError, 26017, 7, "OSError")
- -QDEF0(MP_QSTR_OverflowError, 57729, 13, "OverflowError")
- -QDEF0(MP_QSTR_RuntimeError, 61793, 12, "RuntimeError")
- -QDEF0(MP_QSTR_StopIteration, 7402, 13, "StopIteration")
- -QDEF0(MP_QSTR_SyntaxError, 36756, 11, "SyntaxError")
- -QDEF0(MP_QSTR_SystemExit, 65312, 10, "SystemExit")
- -QDEF0(MP_QSTR_TypeError, 38437, 9, "TypeError")
- -QDEF0(MP_QSTR_ValueError, 34710, 10, "ValueError")
- -QDEF0(MP_QSTR_ZeroDivisionError, 10166, 17, "ZeroDivisionError")
- -QDEF0(MP_QSTR_abs, 12949, 3, "abs")
- -QDEF0(MP_QSTR_all, 13124, 3, "all")
- -QDEF0(MP_QSTR_any, 13075, 3, "any")
- -QDEF0(MP_QSTR_append, 38763, 6, "append")
- -QDEF0(MP_QSTR_args, 50882, 4, "args")
- -QDEF0(MP_QSTR_bool, 15595, 4, "bool")
- -QDEF0(MP_QSTR_builtins, 12791, 8, "builtins")
- -QDEF0(MP_QSTR_bytearray, 41846, 9, "bytearray")
- -QDEF0(MP_QSTR_bytecode, 32034, 8, "bytecode")
- -QDEF0(MP_QSTR_bytes, 45660, 5, "bytes")
- -QDEF0(MP_QSTR_callable, 28685, 8, "callable")
- -QDEF0(MP_QSTR_chr, 19676, 3, "chr")
- -QDEF0(MP_QSTR_classmethod, 36020, 11, "classmethod")
- -QDEF0(MP_QSTR_clear, 41084, 5, "clear")
- -QDEF0(MP_QSTR_close, 26419, 5, "close")
- -QDEF0(MP_QSTR_const, 65472, 5, "const")
- -QDEF0(MP_QSTR_copy, 56288, 4, "copy")
- -QDEF0(MP_QSTR_count, 19878, 5, "count")
- -QDEF0(MP_QSTR_dict, 64575, 4, "dict")
- -QDEF0(MP_QSTR_dir, 7930, 3, "dir")
- -QDEF0(MP_QSTR_divmod, 1208, 6, "divmod")
- -QDEF0(MP_QSTR_end, 8970, 3, "end")
- -QDEF0(MP_QSTR_endswith, 41755, 8, "endswith")
- -QDEF0(MP_QSTR_eval, 42651, 4, "eval")
- -QDEF0(MP_QSTR_exec, 49182, 4, "exec")
- -QDEF0(MP_QSTR_extend, 59491, 6, "extend")
- -QDEF0(MP_QSTR_find, 13312, 4, "find")
- -QDEF0(MP_QSTR_format, 13094, 6, "format")
- -QDEF0(MP_QSTR_from_bytes, 29749, 10, "from_bytes")
- -QDEF0(MP_QSTR_get, 15155, 3, "get")
- -QDEF0(MP_QSTR_getattr, 6080, 7, "getattr")
- -QDEF0(MP_QSTR_globals, 18845, 7, "globals")
- -QDEF0(MP_QSTR_hasattr, 45196, 7, "hasattr")
- -QDEF0(MP_QSTR_hash, 28855, 4, "hash")
- -QDEF0(MP_QSTR_id, 28456, 2, "id")
- -QDEF0(MP_QSTR_index, 10363, 5, "index")
- -QDEF0(MP_QSTR_insert, 21522, 6, "insert")
- -QDEF0(MP_QSTR_int, 21270, 3, "int")
- -QDEF0(MP_QSTR_isalpha, 14315, 7, "isalpha")
- -QDEF0(MP_QSTR_isdigit, 39592, 7, "isdigit")
- -QDEF0(MP_QSTR_isinstance, 48822, 10, "isinstance")
- -QDEF0(MP_QSTR_islower, 33020, 7, "islower")
- -QDEF0(MP_QSTR_isspace, 63579, 7, "isspace")
- -QDEF0(MP_QSTR_issubclass, 32693, 10, "issubclass")
- -QDEF0(MP_QSTR_isupper, 42973, 7, "isupper")
- -QDEF0(MP_QSTR_items, 21475, 5, "items")
- -QDEF0(MP_QSTR_iter, 8591, 4, "iter")
- -QDEF0(MP_QSTR_join, 23719, 4, "join")
- -QDEF0(MP_QSTR_key, 27954, 3, "key")
- -QDEF0(MP_QSTR_keys, 4865, 4, "keys")
- -QDEF0(MP_QSTR_len, 16482, 3, "len")
- -QDEF0(MP_QSTR_list, 7463, 4, "list")
- -QDEF0(MP_QSTR_little, 27273, 6, "little")
- -QDEF0(MP_QSTR_locals, 41275, 6, "locals")
- -QDEF0(MP_QSTR_lower, 52166, 5, "lower")
- -QDEF0(MP_QSTR_lstrip, 47589, 6, "lstrip")
- -QDEF0(MP_QSTR_main, 47054, 4, "main")
- -QDEF0(MP_QSTR_map, 17337, 3, "map")
- -QDEF0(MP_QSTR_micropython, 31755, 11, "micropython")
- -QDEF0(MP_QSTR_next, 34882, 4, "next")
- -QDEF0(MP_QSTR_object, 36240, 6, "object")
- -QDEF0(MP_QSTR_open, 15057, 4, "open")
- -QDEF0(MP_QSTR_ord, 24092, 3, "ord")
- -QDEF0(MP_QSTR_pop, 29482, 3, "pop")
- -QDEF0(MP_QSTR_popitem, 11455, 7, "popitem")
- -QDEF0(MP_QSTR_pow, 29485, 3, "pow")
- -QDEF0(MP_QSTR_print, 50772, 5, "print")
- -QDEF0(MP_QSTR_range, 24090, 5, "range")
- -QDEF0(MP_QSTR_read, 63927, 4, "read")
- -QDEF0(MP_QSTR_readinto, 48971, 8, "readinto")
- -QDEF0(MP_QSTR_readline, 6649, 8, "readline")
- -QDEF0(MP_QSTR_remove, 35427, 6, "remove")
- -QDEF0(MP_QSTR_replace, 9545, 7, "replace")
- -QDEF0(MP_QSTR_repr, 63440, 4, "repr")
- -QDEF0(MP_QSTR_reverse, 10789, 7, "reverse")
- -QDEF0(MP_QSTR_rfind, 40146, 5, "rfind")
- -QDEF0(MP_QSTR_rindex, 11241, 6, "rindex")
- -QDEF0(MP_QSTR_round, 9703, 5, "round")
- +QDEF0(MP_QSTR_KeyboardInterrupt, 175, 17, "KeyboardInterrupt")
- +QDEF0(MP_QSTR_LookupError, 255, 11, "LookupError")
- +QDEF0(MP_QSTR_MemoryError, 220, 11, "MemoryError")
- +QDEF0(MP_QSTR_NameError, 186, 9, "NameError")
- +QDEF0(MP_QSTR_NoneType, 23, 8, "NoneType")
- +QDEF0(MP_QSTR_NotImplementedError, 198, 19, "NotImplementedError")
- +QDEF0(MP_QSTR_OSError, 161, 7, "OSError")
- +QDEF0(MP_QSTR_OverflowError, 129, 13, "OverflowError")
- +QDEF0(MP_QSTR_RuntimeError, 97, 12, "RuntimeError")
- +QDEF0(MP_QSTR_StopIteration, 234, 13, "StopIteration")
- +QDEF0(MP_QSTR_SyntaxError, 148, 11, "SyntaxError")
- +QDEF0(MP_QSTR_SystemExit, 32, 10, "SystemExit")
- +QDEF0(MP_QSTR_TypeError, 37, 9, "TypeError")
- +QDEF0(MP_QSTR_ValueError, 150, 10, "ValueError")
- +QDEF0(MP_QSTR_ZeroDivisionError, 182, 17, "ZeroDivisionError")
- +QDEF0(MP_QSTR_abs, 149, 3, "abs")
- +QDEF0(MP_QSTR_all, 68, 3, "all")
- +QDEF0(MP_QSTR_any, 19, 3, "any")
- +QDEF0(MP_QSTR_append, 107, 6, "append")
- +QDEF0(MP_QSTR_args, 194, 4, "args")
- +QDEF0(MP_QSTR_bool, 235, 4, "bool")
- +QDEF0(MP_QSTR_builtins, 247, 8, "builtins")
- +QDEF0(MP_QSTR_bytearray, 118, 9, "bytearray")
- +QDEF0(MP_QSTR_bytecode, 34, 8, "bytecode")
- +QDEF0(MP_QSTR_bytes, 92, 5, "bytes")
- +QDEF0(MP_QSTR_callable, 13, 8, "callable")
- +QDEF0(MP_QSTR_chr, 220, 3, "chr")
- +QDEF0(MP_QSTR_classmethod, 180, 11, "classmethod")
- +QDEF0(MP_QSTR_clear, 124, 5, "clear")
- +QDEF0(MP_QSTR_close, 51, 5, "close")
- +QDEF0(MP_QSTR_const, 192, 5, "const")
- +QDEF0(MP_QSTR_copy, 224, 4, "copy")
- +QDEF0(MP_QSTR_count, 166, 5, "count")
- +QDEF0(MP_QSTR_dict, 63, 4, "dict")
- +QDEF0(MP_QSTR_dir, 250, 3, "dir")
- +QDEF0(MP_QSTR_divmod, 184, 6, "divmod")
- +QDEF0(MP_QSTR_end, 10, 3, "end")
- +QDEF0(MP_QSTR_endswith, 27, 8, "endswith")
- +QDEF0(MP_QSTR_eval, 155, 4, "eval")
- +QDEF0(MP_QSTR_exec, 30, 4, "exec")
- +QDEF0(MP_QSTR_extend, 99, 6, "extend")
- +QDEF0(MP_QSTR_find, 1, 4, "find")
- +QDEF0(MP_QSTR_format, 38, 6, "format")
- +QDEF0(MP_QSTR_from_bytes, 53, 10, "from_bytes")
- +QDEF0(MP_QSTR_get, 51, 3, "get")
- +QDEF0(MP_QSTR_getattr, 192, 7, "getattr")
- +QDEF0(MP_QSTR_globals, 157, 7, "globals")
- +QDEF0(MP_QSTR_hasattr, 140, 7, "hasattr")
- +QDEF0(MP_QSTR_hash, 183, 4, "hash")
- +QDEF0(MP_QSTR_id, 40, 2, "id")
- +QDEF0(MP_QSTR_index, 123, 5, "index")
- +QDEF0(MP_QSTR_insert, 18, 6, "insert")
- +QDEF0(MP_QSTR_int, 22, 3, "int")
- +QDEF0(MP_QSTR_isalpha, 235, 7, "isalpha")
- +QDEF0(MP_QSTR_isdigit, 168, 7, "isdigit")
- +QDEF0(MP_QSTR_isinstance, 182, 10, "isinstance")
- +QDEF0(MP_QSTR_islower, 252, 7, "islower")
- +QDEF0(MP_QSTR_isspace, 91, 7, "isspace")
- +QDEF0(MP_QSTR_issubclass, 181, 10, "issubclass")
- +QDEF0(MP_QSTR_isupper, 221, 7, "isupper")
- +QDEF0(MP_QSTR_items, 227, 5, "items")
- +QDEF0(MP_QSTR_iter, 143, 4, "iter")
- +QDEF0(MP_QSTR_join, 167, 4, "join")
- +QDEF0(MP_QSTR_key, 50, 3, "key")
- +QDEF0(MP_QSTR_keys, 1, 4, "keys")
- +QDEF0(MP_QSTR_len, 98, 3, "len")
- +QDEF0(MP_QSTR_list, 39, 4, "list")
- +QDEF0(MP_QSTR_little, 137, 6, "little")
- +QDEF0(MP_QSTR_locals, 59, 6, "locals")
- +QDEF0(MP_QSTR_lower, 198, 5, "lower")
- +QDEF0(MP_QSTR_lstrip, 229, 6, "lstrip")
- +QDEF0(MP_QSTR_main, 206, 4, "main")
- +QDEF0(MP_QSTR_map, 185, 3, "map")
- +QDEF0(MP_QSTR_micropython, 11, 11, "micropython")
- +QDEF0(MP_QSTR_next, 66, 4, "next")
- +QDEF0(MP_QSTR_object, 144, 6, "object")
- +QDEF0(MP_QSTR_open, 209, 4, "open")
- +QDEF0(MP_QSTR_ord, 28, 3, "ord")
- +QDEF0(MP_QSTR_pop, 42, 3, "pop")
- +QDEF0(MP_QSTR_popitem, 191, 7, "popitem")
- +QDEF0(MP_QSTR_pow, 45, 3, "pow")
- +QDEF0(MP_QSTR_print, 84, 5, "print")
- +QDEF0(MP_QSTR_range, 26, 5, "range")
- +QDEF0(MP_QSTR_read, 183, 4, "read")
- +QDEF0(MP_QSTR_readinto, 75, 8, "readinto")
- +QDEF0(MP_QSTR_readline, 249, 8, "readline")
- +QDEF0(MP_QSTR_remove, 99, 6, "remove")
- +QDEF0(MP_QSTR_replace, 73, 7, "replace")
- +QDEF0(MP_QSTR_repr, 208, 4, "repr")
- +QDEF0(MP_QSTR_reverse, 37, 7, "reverse")
- +QDEF0(MP_QSTR_rfind, 210, 5, "rfind")
- +QDEF0(MP_QSTR_rindex, 233, 6, "rindex")
- +QDEF0(MP_QSTR_round, 231, 5, "round")
- QDEF0(MP_QSTR_rsplit, 165, 6, "rsplit")
- -QDEF0(MP_QSTR_rstrip, 38203, 6, "rstrip")
- -QDEF0(MP_QSTR_self, 30585, 4, "self")
- -QDEF0(MP_QSTR_send, 30393, 4, "send")
- -QDEF0(MP_QSTR_sep, 36643, 3, "sep")
- -QDEF0(MP_QSTR_set, 36647, 3, "set")
- -QDEF0(MP_QSTR_setattr, 43220, 7, "setattr")
- -QDEF0(MP_QSTR_setdefault, 41836, 10, "setdefault")
- -QDEF0(MP_QSTR_sort, 40383, 4, "sort")
- -QDEF0(MP_QSTR_sorted, 5470, 6, "sorted")
- -QDEF0(MP_QSTR_split, 13239, 5, "split")
- -QDEF0(MP_QSTR_start, 61317, 5, "start")
- -QDEF0(MP_QSTR_startswith, 59508, 10, "startswith")
- -QDEF0(MP_QSTR_staticmethod, 44898, 12, "staticmethod")
- -QDEF0(MP_QSTR_step, 13911, 4, "step")
- -QDEF0(MP_QSTR_stop, 13981, 4, "stop")
- -QDEF0(MP_QSTR_str, 36176, 3, "str")
- -QDEF0(MP_QSTR_strip, 7721, 5, "strip")
- -QDEF0(MP_QSTR_sum, 36142, 3, "sum")
- -QDEF0(MP_QSTR_super, 45764, 5, "super")
- -QDEF0(MP_QSTR_throw, 17587, 5, "throw")
- -QDEF0(MP_QSTR_to_bytes, 16088, 8, "to_bytes")
- -QDEF0(MP_QSTR_tuple, 16893, 5, "tuple")
- -QDEF0(MP_QSTR_type, 32669, 4, "type")
- -QDEF0(MP_QSTR_update, 30388, 6, "update")
- -QDEF0(MP_QSTR_upper, 37927, 5, "upper")
- -QDEF0(MP_QSTR_utf_hyphen_8, 33463, 5, "utf-8")
- -QDEF0(MP_QSTR_value, 13390, 5, "value")
- -QDEF0(MP_QSTR_values, 48765, 6, "values")
- -QDEF0(MP_QSTR_write, 43160, 5, "write")
- -QDEF0(MP_QSTR_zip, 44262, 3, "zip")
- -QDEF1(MP_QSTR__percent__hash_o, 6764, 3, "%#o")
- -QDEF1(MP_QSTR__percent__hash_x, 6779, 3, "%#x")
- -QDEF1(MP_QSTR__lt_dictcomp_gt_, 36300, 10, "<dictcomp>")
- -QDEF1(MP_QSTR__lt_genexpr_gt_, 27188, 9, "<genexpr>")
- -QDEF1(MP_QSTR__lt_lambda_gt_, 35968, 8, "<lambda>")
- -QDEF1(MP_QSTR__lt_listcomp_gt_, 5588, 10, "<listcomp>")
- -QDEF1(MP_QSTR__lt_setcomp_gt_, 20820, 9, "<setcomp>")
- -QDEF1(MP_QSTR__lt_stdin_gt_, 25571, 7, "<stdin>")
- -QDEF1(MP_QSTR__lt_string_gt_, 21330, 8, "<string>")
- -QDEF1(MP_QSTR_CANVAS_ALIGN_BEGIN, 40103, 18, "CANVAS_ALIGN_BEGIN")
- -QDEF1(MP_QSTR_CANVAS_ALIGN_CENTER, 1771, 19, "CANVAS_ALIGN_CENTER")
- -QDEF1(MP_QSTR_CANVAS_ALIGN_END, 49391, 16, "CANVAS_ALIGN_END")
- -QDEF1(MP_QSTR_CANVAS_BLACK, 34261, 12, "CANVAS_BLACK")
- -QDEF1(MP_QSTR_CANVAS_FONT_PRIMARY, 35826, 19, "CANVAS_FONT_PRIMARY")
- -QDEF1(MP_QSTR_CANVAS_FONT_SECONDARY, 58372, 21, "CANVAS_FONT_SECONDARY")
- -QDEF1(MP_QSTR_CANVAS_WHITE, 11573, 12, "CANVAS_WHITE")
- -QDEF1(MP_QSTR_INPUT_BUTTON_BACK, 3502, 17, "INPUT_BUTTON_BACK")
- -QDEF1(MP_QSTR_INPUT_BUTTON_DOWN, 53239, 17, "INPUT_BUTTON_DOWN")
- -QDEF1(MP_QSTR_INPUT_BUTTON_LEFT, 5982, 17, "INPUT_BUTTON_LEFT")
- -QDEF1(MP_QSTR_INPUT_BUTTON_OK, 56353, 15, "INPUT_BUTTON_OK")
- -QDEF1(MP_QSTR_INPUT_BUTTON_RIGHT, 39685, 18, "INPUT_BUTTON_RIGHT")
- -QDEF1(MP_QSTR_INPUT_BUTTON_UP, 56672, 15, "INPUT_BUTTON_UP")
- -QDEF1(MP_QSTR_INPUT_TYPE_LONG, 24161, 15, "INPUT_TYPE_LONG")
- -QDEF1(MP_QSTR_INPUT_TYPE_PRESS, 41324, 16, "INPUT_TYPE_PRESS")
- -QDEF1(MP_QSTR_INPUT_TYPE_RELEASE, 65058, 18, "INPUT_TYPE_RELEASE")
- -QDEF1(MP_QSTR_INPUT_TYPE_REPEAT, 64028, 17, "INPUT_TYPE_REPEAT")
- -QDEF1(MP_QSTR_INPUT_TYPE_SHORT, 8601, 16, "INPUT_TYPE_SHORT")
- -QDEF1(MP_QSTR_LIGHT_BACKLIGHT, 18705, 15, "LIGHT_BACKLIGHT")
- -QDEF1(MP_QSTR_LIGHT_BLUE, 64346, 10, "LIGHT_BLUE")
- -QDEF1(MP_QSTR_LIGHT_GREEN, 32095, 11, "LIGHT_GREEN")
- -QDEF1(MP_QSTR_LIGHT_RED, 54999, 9, "LIGHT_RED")
- -QDEF0(MP_QSTR___add__, 33476, 7, "__add__")
- -QDEF1(MP_QSTR___bases__, 12291, 9, "__bases__")
- -QDEF0(MP_QSTR___bool__, 25899, 8, "__bool__")
- -QDEF1(MP_QSTR___build_class__, 34882, 15, "__build_class__")
- -QDEF0(MP_QSTR___contains__, 24518, 12, "__contains__")
- -QDEF1(MP_QSTR___dict__, 21631, 8, "__dict__")
- -QDEF0(MP_QSTR___eq__, 15985, 6, "__eq__")
- -QDEF1(MP_QSTR___file__, 21507, 8, "__file__")
- -QDEF0(MP_QSTR___float__, 28725, 9, "__float__")
- -QDEF0(MP_QSTR___ge__, 18087, 6, "__ge__")
- -QDEF1(MP_QSTR___globals__, 44701, 11, "__globals__")
- -QDEF0(MP_QSTR___gt__, 33462, 6, "__gt__")
- -QDEF0(MP_QSTR___iadd__, 19053, 8, "__iadd__")
- -QDEF1(MP_QSTR___import__, 15928, 10, "__import__")
- -QDEF0(MP_QSTR___isub__, 30728, 8, "__isub__")
- -QDEF0(MP_QSTR___le__, 5068, 6, "__le__")
- -QDEF0(MP_QSTR___lt__, 26717, 6, "__lt__")
- -QDEF0(MP_QSTR___ne__, 2830, 6, "__ne__")
- -QDEF1(MP_QSTR___path__, 9160, 8, "__path__")
- -QDEF1(MP_QSTR___repl_print__, 47872, 14, "__repl_print__")
- -QDEF1(MP_QSTR___reversed__, 65377, 12, "__reversed__")
- -QDEF0(MP_QSTR___sub__, 2337, 7, "__sub__")
- -QDEF1(MP_QSTR___traceback__, 53071, 13, "__traceback__")
- -QDEF1(MP_QSTR__input_trigger_handler, 50540, 22, "_input_trigger_handler")
- -QDEF1(MP_QSTR_add, 12868, 3, "add")
- -QDEF1(MP_QSTR_array, 29308, 5, "array")
- -QDEF1(MP_QSTR_bin, 18656, 3, "bin")
- -QDEF1(MP_QSTR_bound_method, 41623, 12, "bound_method")
- -QDEF1(MP_QSTR_canvas_clear, 30827, 12, "canvas_clear")
- -QDEF1(MP_QSTR_canvas_draw_box, 52536, 15, "canvas_draw_box")
- -QDEF1(MP_QSTR_canvas_draw_circle, 4671, 18, "canvas_draw_circle")
- -QDEF1(MP_QSTR_canvas_draw_disc, 12976, 16, "canvas_draw_disc")
- -QDEF1(MP_QSTR_canvas_draw_dot, 42162, 15, "canvas_draw_dot")
- -QDEF1(MP_QSTR_canvas_draw_frame, 4592, 17, "canvas_draw_frame")
- -QDEF1(MP_QSTR_canvas_draw_line, 4419, 16, "canvas_draw_line")
- -QDEF1(MP_QSTR_canvas_height, 65357, 13, "canvas_height")
- -QDEF1(MP_QSTR_canvas_set_color, 9394, 16, "canvas_set_color")
- -QDEF1(MP_QSTR_canvas_set_font, 57212, 15, "canvas_set_font")
- -QDEF1(MP_QSTR_canvas_set_text, 1394, 15, "canvas_set_text")
- -QDEF1(MP_QSTR_canvas_set_text_align, 56000, 21, "canvas_set_text_align")
- -QDEF1(MP_QSTR_canvas_text_height, 18415, 18, "canvas_text_height")
- -QDEF1(MP_QSTR_canvas_text_width, 2390, 17, "canvas_text_width")
- -QDEF1(MP_QSTR_canvas_update, 21379, 13, "canvas_update")
- -QDEF1(MP_QSTR_canvas_width, 41652, 12, "canvas_width")
- -QDEF1(MP_QSTR_choice, 13102, 6, "choice")
- -QDEF1(MP_QSTR_closure, 51828, 7, "closure")
- -QDEF1(MP_QSTR_collect, 26011, 7, "collect")
- -QDEF1(MP_QSTR_decode, 22953, 6, "decode")
- -QDEF1(MP_QSTR_default, 32206, 7, "default")
- -QDEF1(MP_QSTR_delattr, 51419, 7, "delattr")
- -QDEF1(MP_QSTR_deleter, 56174, 7, "deleter")
- -QDEF1(MP_QSTR_dict_view, 43309, 9, "dict_view")
- -QDEF1(MP_QSTR_difference, 9330, 10, "difference")
- -QDEF1(MP_QSTR_difference_update, 64156, 17, "difference_update")
- -QDEF1(MP_QSTR_disable, 30353, 7, "disable")
- -QDEF1(MP_QSTR_discard, 28943, 7, "discard")
- -QDEF1(MP_QSTR_doc, 7981, 3, "doc")
- -QDEF1(MP_QSTR_enable, 56836, 6, "enable")
- -QDEF1(MP_QSTR_encode, 51779, 6, "encode")
- -QDEF1(MP_QSTR_enumerate, 47729, 9, "enumerate")
- -QDEF1(MP_QSTR_errno, 4545, 5, "errno")
- -QDEF1(MP_QSTR_filter, 48677, 6, "filter")
- -QDEF1(MP_QSTR_flipperzero, 60083, 11, "flipperzero")
- -QDEF1(MP_QSTR_float, 17461, 5, "float")
- -QDEF1(MP_QSTR_fromkeys, 48439, 8, "fromkeys")
- -QDEF1(MP_QSTR_function, 551, 8, "function")
- -QDEF1(MP_QSTR_gc, 28257, 2, "gc")
- -QDEF1(MP_QSTR_generator, 50070, 9, "generator")
- -QDEF1(MP_QSTR_getrandbits, 32102, 11, "getrandbits")
- -QDEF1(MP_QSTR_getter, 45712, 6, "getter")
- -QDEF1(MP_QSTR_heap_lock, 36013, 9, "heap_lock")
- -QDEF1(MP_QSTR_heap_unlock, 11606, 11, "heap_unlock")
- -QDEF1(MP_QSTR_hex, 20592, 3, "hex")
- -QDEF1(MP_QSTR_intersection, 10792, 12, "intersection")
- -QDEF1(MP_QSTR_intersection_update, 56582, 19, "intersection_update")
- -QDEF1(MP_QSTR_isdisjoint, 26871, 10, "isdisjoint")
- -QDEF1(MP_QSTR_isenabled, 58778, 9, "isenabled")
- -QDEF1(MP_QSTR_issubset, 49593, 8, "issubset")
- -QDEF1(MP_QSTR_issuperset, 60668, 10, "issuperset")
- -QDEF1(MP_QSTR_iterable, 37413, 8, "iterable")
- -QDEF1(MP_QSTR_iterator, 48711, 8, "iterator")
- -QDEF1(MP_QSTR_light_blink_set_color, 17369, 21, "light_blink_set_color")
- -QDEF1(MP_QSTR_light_blink_start, 25721, 17, "light_blink_start")
- -QDEF1(MP_QSTR_light_blink_stop, 37921, 16, "light_blink_stop")
- -QDEF1(MP_QSTR_light_set, 18054, 9, "light_set")
- -QDEF1(MP_QSTR_max, 17329, 3, "max")
- -QDEF1(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, 7795, 32, "maximum recursion depth exceeded")
- -QDEF1(MP_QSTR_mem_alloc, 11090, 9, "mem_alloc")
- -QDEF1(MP_QSTR_mem_free, 25291, 8, "mem_free")
- -QDEF1(MP_QSTR_min, 17071, 3, "min")
- -QDEF1(MP_QSTR_module, 39359, 6, "module")
- -QDEF1(MP_QSTR_oct, 23805, 3, "oct")
- -QDEF1(MP_QSTR_on_input, 32141, 8, "on_input")
- -QDEF1(MP_QSTR_opt_level, 26503, 9, "opt_level")
- -QDEF1(MP_QSTR_property, 10690, 8, "property")
- -QDEF1(MP_QSTR_randint, 56495, 7, "randint")
- -QDEF1(MP_QSTR_random, 11454, 6, "random")
- -QDEF1(MP_QSTR_randrange, 16035, 9, "randrange")
- -QDEF1(MP_QSTR_rb, 28885, 2, "rb")
- -QDEF1(MP_QSTR_reversed, 28321, 8, "reversed")
- -QDEF1(MP_QSTR_schedule, 44256, 8, "schedule")
- -QDEF1(MP_QSTR_seed, 30098, 4, "seed")
- -QDEF1(MP_QSTR_setter, 22788, 6, "setter")
- -QDEF1(MP_QSTR_sleep, 10218, 5, "sleep")
- -QDEF1(MP_QSTR_sleep_ms, 25355, 8, "sleep_ms")
- -QDEF1(MP_QSTR_sleep_us, 24595, 8, "sleep_us")
- -QDEF1(MP_QSTR_slice, 62645, 5, "slice")
- -QDEF1(MP_QSTR_speaker_set_volume, 51060, 18, "speaker_set_volume")
- -QDEF1(MP_QSTR_speaker_start, 18433, 13, "speaker_start")
- -QDEF1(MP_QSTR_speaker_stop, 36249, 12, "speaker_stop")
- -QDEF1(MP_QSTR_symmetric_difference, 26574, 20, "symmetric_difference")
- -QDEF1(MP_QSTR_symmetric_difference_update, 63584, 27, "symmetric_difference_update")
- -QDEF1(MP_QSTR_threshold, 12274, 9, "threshold")
- -QDEF1(MP_QSTR_ticks_add, 44701, 9, "ticks_add")
- -QDEF1(MP_QSTR_ticks_cpu, 42266, 9, "ticks_cpu")
- -QDEF1(MP_QSTR_ticks_diff, 57521, 10, "ticks_diff")
- -QDEF1(MP_QSTR_ticks_ms, 12866, 8, "ticks_ms")
- -QDEF1(MP_QSTR_ticks_us, 12634, 8, "ticks_us")
- -QDEF1(MP_QSTR_time, 49648, 4, "time")
- -QDEF1(MP_QSTR_time_ns, 45682, 7, "time_ns")
- -QDEF1(MP_QSTR_uniform, 62721, 7, "uniform")
- -QDEF1(MP_QSTR_union, 31990, 5, "union")
- -QDEF1(MP_QSTR_vibro_set, 11736, 9, "vibro_set")
- -QDEF1(MP_QSTR__brace_open__colon__hash_b_brace_close_, 14168, 5, "{:#b}")
- +QDEF0(MP_QSTR_rstrip, 59, 6, "rstrip")
- +QDEF0(MP_QSTR_self, 121, 4, "self")
- +QDEF0(MP_QSTR_send, 185, 4, "send")
- +QDEF0(MP_QSTR_sep, 35, 3, "sep")
- +QDEF0(MP_QSTR_set, 39, 3, "set")
- +QDEF0(MP_QSTR_setattr, 212, 7, "setattr")
- +QDEF0(MP_QSTR_setdefault, 108, 10, "setdefault")
- +QDEF0(MP_QSTR_sort, 191, 4, "sort")
- +QDEF0(MP_QSTR_sorted, 94, 6, "sorted")
- +QDEF0(MP_QSTR_split, 183, 5, "split")
- +QDEF0(MP_QSTR_start, 133, 5, "start")
- +QDEF0(MP_QSTR_startswith, 116, 10, "startswith")
- +QDEF0(MP_QSTR_staticmethod, 98, 12, "staticmethod")
- +QDEF0(MP_QSTR_step, 87, 4, "step")
- +QDEF0(MP_QSTR_stop, 157, 4, "stop")
- +QDEF0(MP_QSTR_str, 80, 3, "str")
- +QDEF0(MP_QSTR_strip, 41, 5, "strip")
- +QDEF0(MP_QSTR_sum, 46, 3, "sum")
- +QDEF0(MP_QSTR_super, 196, 5, "super")
- +QDEF0(MP_QSTR_throw, 179, 5, "throw")
- +QDEF0(MP_QSTR_to_bytes, 216, 8, "to_bytes")
- +QDEF0(MP_QSTR_tuple, 253, 5, "tuple")
- +QDEF0(MP_QSTR_type, 157, 4, "type")
- +QDEF0(MP_QSTR_update, 180, 6, "update")
- +QDEF0(MP_QSTR_upper, 39, 5, "upper")
- +QDEF0(MP_QSTR_utf_hyphen_8, 183, 5, "utf-8")
- +QDEF0(MP_QSTR_value, 78, 5, "value")
- +QDEF0(MP_QSTR_values, 125, 6, "values")
- +QDEF0(MP_QSTR_write, 152, 5, "write")
- +QDEF0(MP_QSTR_zip, 230, 3, "zip")
- +QDEF1(MP_QSTR__percent__hash_o, 108, 3, "%#o")
- +QDEF1(MP_QSTR__percent__hash_x, 123, 3, "%#x")
- +QDEF0(MP_QSTR__lt_dictcomp_gt_, 204, 10, "<dictcomp>")
- +QDEF0(MP_QSTR__lt_genexpr_gt_, 52, 9, "<genexpr>")
- +QDEF0(MP_QSTR__lt_lambda_gt_, 128, 8, "<lambda>")
- +QDEF0(MP_QSTR__lt_listcomp_gt_, 212, 10, "<listcomp>")
- +QDEF0(MP_QSTR__lt_setcomp_gt_, 84, 9, "<setcomp>")
- +QDEF1(MP_QSTR__lt_stdin_gt_, 227, 7, "<stdin>")
- +QDEF1(MP_QSTR__lt_string_gt_, 82, 8, "<string>")
- +QDEF1(MP_QSTR_CANVAS_ALIGN_BEGIN, 167, 18, "CANVAS_ALIGN_BEGIN")
- +QDEF1(MP_QSTR_CANVAS_ALIGN_CENTER, 235, 19, "CANVAS_ALIGN_CENTER")
- +QDEF1(MP_QSTR_CANVAS_ALIGN_END, 239, 16, "CANVAS_ALIGN_END")
- +QDEF1(MP_QSTR_CANVAS_BLACK, 213, 12, "CANVAS_BLACK")
- +QDEF1(MP_QSTR_CANVAS_FONT_PRIMARY, 242, 19, "CANVAS_FONT_PRIMARY")
- +QDEF1(MP_QSTR_CANVAS_FONT_SECONDARY, 4, 21, "CANVAS_FONT_SECONDARY")
- +QDEF1(MP_QSTR_CANVAS_WHITE, 53, 12, "CANVAS_WHITE")
- +QDEF1(MP_QSTR_INPUT_BUTTON_BACK, 174, 17, "INPUT_BUTTON_BACK")
- +QDEF1(MP_QSTR_INPUT_BUTTON_DOWN, 247, 17, "INPUT_BUTTON_DOWN")
- +QDEF1(MP_QSTR_INPUT_BUTTON_LEFT, 94, 17, "INPUT_BUTTON_LEFT")
- +QDEF1(MP_QSTR_INPUT_BUTTON_OK, 33, 15, "INPUT_BUTTON_OK")
- +QDEF1(MP_QSTR_INPUT_BUTTON_RIGHT, 5, 18, "INPUT_BUTTON_RIGHT")
- +QDEF1(MP_QSTR_INPUT_BUTTON_UP, 96, 15, "INPUT_BUTTON_UP")
- +QDEF1(MP_QSTR_INPUT_TYPE_LONG, 97, 15, "INPUT_TYPE_LONG")
- +QDEF1(MP_QSTR_INPUT_TYPE_PRESS, 108, 16, "INPUT_TYPE_PRESS")
- +QDEF1(MP_QSTR_INPUT_TYPE_RELEASE, 34, 18, "INPUT_TYPE_RELEASE")
- +QDEF1(MP_QSTR_INPUT_TYPE_REPEAT, 28, 17, "INPUT_TYPE_REPEAT")
- +QDEF1(MP_QSTR_INPUT_TYPE_SHORT, 153, 16, "INPUT_TYPE_SHORT")
- +QDEF1(MP_QSTR_LIGHT_BACKLIGHT, 17, 15, "LIGHT_BACKLIGHT")
- +QDEF1(MP_QSTR_LIGHT_BLUE, 90, 10, "LIGHT_BLUE")
- +QDEF1(MP_QSTR_LIGHT_GREEN, 95, 11, "LIGHT_GREEN")
- +QDEF1(MP_QSTR_LIGHT_RED, 215, 9, "LIGHT_RED")
- +QDEF0(MP_QSTR___add__, 196, 7, "__add__")
- +QDEF1(MP_QSTR___bases__, 3, 9, "__bases__")
- +QDEF0(MP_QSTR___bool__, 43, 8, "__bool__")
- +QDEF1(MP_QSTR___build_class__, 66, 15, "__build_class__")
- +QDEF0(MP_QSTR___contains__, 198, 12, "__contains__")
- +QDEF1(MP_QSTR___dict__, 127, 8, "__dict__")
- +QDEF0(MP_QSTR___eq__, 113, 6, "__eq__")
- +QDEF1(MP_QSTR___file__, 3, 8, "__file__")
- +QDEF0(MP_QSTR___float__, 53, 9, "__float__")
- +QDEF0(MP_QSTR___ge__, 167, 6, "__ge__")
- +QDEF1(MP_QSTR___globals__, 157, 11, "__globals__")
- +QDEF0(MP_QSTR___gt__, 182, 6, "__gt__")
- +QDEF0(MP_QSTR___iadd__, 109, 8, "__iadd__")
- +QDEF1(MP_QSTR___import__, 56, 10, "__import__")
- +QDEF0(MP_QSTR___isub__, 8, 8, "__isub__")
- +QDEF0(MP_QSTR___le__, 204, 6, "__le__")
- +QDEF0(MP_QSTR___lt__, 93, 6, "__lt__")
- +QDEF0(MP_QSTR___ne__, 14, 6, "__ne__")
- +QDEF1(MP_QSTR___path__, 200, 8, "__path__")
- +QDEF1(MP_QSTR___repl_print__, 1, 14, "__repl_print__")
- +QDEF1(MP_QSTR___reversed__, 97, 12, "__reversed__")
- +QDEF0(MP_QSTR___sub__, 33, 7, "__sub__")
- +QDEF1(MP_QSTR___traceback__, 79, 13, "__traceback__")
- +QDEF1(MP_QSTR__input_trigger_handler, 108, 22, "_input_trigger_handler")
- +QDEF1(MP_QSTR_add, 68, 3, "add")
- +QDEF1(MP_QSTR_array, 124, 5, "array")
- +QDEF1(MP_QSTR_bin, 224, 3, "bin")
- +QDEF1(MP_QSTR_bound_method, 151, 12, "bound_method")
- +QDEF1(MP_QSTR_canvas_clear, 107, 12, "canvas_clear")
- +QDEF1(MP_QSTR_canvas_draw_box, 56, 15, "canvas_draw_box")
- +QDEF1(MP_QSTR_canvas_draw_circle, 63, 18, "canvas_draw_circle")
- +QDEF1(MP_QSTR_canvas_draw_disc, 176, 16, "canvas_draw_disc")
- +QDEF1(MP_QSTR_canvas_draw_dot, 178, 15, "canvas_draw_dot")
- +QDEF1(MP_QSTR_canvas_draw_frame, 240, 17, "canvas_draw_frame")
- +QDEF1(MP_QSTR_canvas_draw_line, 67, 16, "canvas_draw_line")
- +QDEF1(MP_QSTR_canvas_height, 77, 13, "canvas_height")
- +QDEF1(MP_QSTR_canvas_set_color, 178, 16, "canvas_set_color")
- +QDEF1(MP_QSTR_canvas_set_font, 124, 15, "canvas_set_font")
- +QDEF1(MP_QSTR_canvas_set_text, 114, 15, "canvas_set_text")
- +QDEF1(MP_QSTR_canvas_set_text_align, 192, 21, "canvas_set_text_align")
- +QDEF1(MP_QSTR_canvas_text_height, 239, 18, "canvas_text_height")
- +QDEF1(MP_QSTR_canvas_text_width, 86, 17, "canvas_text_width")
- +QDEF1(MP_QSTR_canvas_update, 131, 13, "canvas_update")
- +QDEF1(MP_QSTR_canvas_width, 180, 12, "canvas_width")
- +QDEF1(MP_QSTR_choice, 46, 6, "choice")
- +QDEF1(MP_QSTR_closure, 116, 7, "closure")
- +QDEF1(MP_QSTR_collect, 155, 7, "collect")
- +QDEF1(MP_QSTR_decode, 169, 6, "decode")
- +QDEF1(MP_QSTR_default, 206, 7, "default")
- +QDEF1(MP_QSTR_delattr, 219, 7, "delattr")
- +QDEF1(MP_QSTR_deleter, 110, 7, "deleter")
- +QDEF1(MP_QSTR_dict_view, 45, 9, "dict_view")
- +QDEF1(MP_QSTR_difference, 114, 10, "difference")
- +QDEF1(MP_QSTR_difference_update, 156, 17, "difference_update")
- +QDEF1(MP_QSTR_disable, 145, 7, "disable")
- +QDEF1(MP_QSTR_discard, 15, 7, "discard")
- +QDEF1(MP_QSTR_doc, 45, 3, "doc")
- +QDEF1(MP_QSTR_enable, 4, 6, "enable")
- +QDEF1(MP_QSTR_encode, 67, 6, "encode")
- +QDEF1(MP_QSTR_enumerate, 113, 9, "enumerate")
- +QDEF1(MP_QSTR_errno, 193, 5, "errno")
- +QDEF1(MP_QSTR_filter, 37, 6, "filter")
- +QDEF1(MP_QSTR_flipperzero, 179, 11, "flipperzero")
- +QDEF1(MP_QSTR_float, 53, 5, "float")
- +QDEF1(MP_QSTR_fromkeys, 55, 8, "fromkeys")
- +QDEF1(MP_QSTR_function, 39, 8, "function")
- +QDEF1(MP_QSTR_gc, 97, 2, "gc")
- +QDEF1(MP_QSTR_generator, 150, 9, "generator")
- +QDEF1(MP_QSTR_getrandbits, 102, 11, "getrandbits")
- +QDEF1(MP_QSTR_getter, 144, 6, "getter")
- +QDEF1(MP_QSTR_heap_lock, 173, 9, "heap_lock")
- +QDEF1(MP_QSTR_heap_unlock, 86, 11, "heap_unlock")
- +QDEF1(MP_QSTR_hex, 112, 3, "hex")
- +QDEF1(MP_QSTR_intersection, 40, 12, "intersection")
- +QDEF1(MP_QSTR_intersection_update, 6, 19, "intersection_update")
- +QDEF1(MP_QSTR_isdisjoint, 247, 10, "isdisjoint")
- +QDEF1(MP_QSTR_isenabled, 154, 9, "isenabled")
- +QDEF1(MP_QSTR_issubset, 185, 8, "issubset")
- +QDEF1(MP_QSTR_issuperset, 252, 10, "issuperset")
- +QDEF1(MP_QSTR_iterable, 37, 8, "iterable")
- +QDEF1(MP_QSTR_iterator, 71, 8, "iterator")
- +QDEF1(MP_QSTR_light_blink_set_color, 217, 21, "light_blink_set_color")
- +QDEF1(MP_QSTR_light_blink_start, 121, 17, "light_blink_start")
- +QDEF1(MP_QSTR_light_blink_stop, 33, 16, "light_blink_stop")
- +QDEF1(MP_QSTR_light_set, 134, 9, "light_set")
- +QDEF1(MP_QSTR_max, 177, 3, "max")
- +QDEF1(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, 115, 32, "maximum recursion depth exceeded")
- +QDEF1(MP_QSTR_mem_alloc, 82, 9, "mem_alloc")
- +QDEF1(MP_QSTR_mem_free, 203, 8, "mem_free")
- +QDEF1(MP_QSTR_min, 175, 3, "min")
- +QDEF1(MP_QSTR_module, 191, 6, "module")
- +QDEF1(MP_QSTR_oct, 253, 3, "oct")
- +QDEF1(MP_QSTR_on_input, 141, 8, "on_input")
- +QDEF1(MP_QSTR_opt_level, 135, 9, "opt_level")
- +QDEF1(MP_QSTR_property, 194, 8, "property")
- +QDEF1(MP_QSTR_randint, 175, 7, "randint")
- +QDEF1(MP_QSTR_random, 190, 6, "random")
- +QDEF1(MP_QSTR_randrange, 163, 9, "randrange")
- +QDEF1(MP_QSTR_rb, 213, 2, "rb")
- +QDEF1(MP_QSTR_reversed, 161, 8, "reversed")
- +QDEF1(MP_QSTR_schedule, 224, 8, "schedule")
- +QDEF1(MP_QSTR_seed, 146, 4, "seed")
- +QDEF1(MP_QSTR_setter, 4, 6, "setter")
- +QDEF1(MP_QSTR_sleep, 234, 5, "sleep")
- +QDEF1(MP_QSTR_sleep_ms, 11, 8, "sleep_ms")
- +QDEF1(MP_QSTR_sleep_us, 19, 8, "sleep_us")
- +QDEF1(MP_QSTR_slice, 181, 5, "slice")
- +QDEF1(MP_QSTR_speaker_set_volume, 116, 18, "speaker_set_volume")
- +QDEF1(MP_QSTR_speaker_start, 1, 13, "speaker_start")
- +QDEF1(MP_QSTR_speaker_stop, 153, 12, "speaker_stop")
- +QDEF1(MP_QSTR_symmetric_difference, 206, 20, "symmetric_difference")
- +QDEF1(MP_QSTR_symmetric_difference_update, 96, 27, "symmetric_difference_update")
- +QDEF1(MP_QSTR_threshold, 242, 9, "threshold")
- +QDEF1(MP_QSTR_ticks_add, 157, 9, "ticks_add")
- +QDEF1(MP_QSTR_ticks_cpu, 26, 9, "ticks_cpu")
- +QDEF1(MP_QSTR_ticks_diff, 177, 10, "ticks_diff")
- +QDEF1(MP_QSTR_ticks_ms, 66, 8, "ticks_ms")
- +QDEF1(MP_QSTR_ticks_us, 90, 8, "ticks_us")
- +QDEF1(MP_QSTR_time, 240, 4, "time")
- +QDEF1(MP_QSTR_time_ns, 114, 7, "time_ns")
- +QDEF1(MP_QSTR_uniform, 1, 7, "uniform")
- +QDEF1(MP_QSTR_union, 246, 5, "union")
- +QDEF1(MP_QSTR_vibro_set, 216, 9, "vibro_set")
- +QDEF1(MP_QSTR__brace_open__colon__hash_b_brace_close_, 88, 5, "{:#b}")
- diff --git a/py/asmarm.c b/py/asmarm.c
- index 42724e4d4..600649070 100644
- --- a/py/asmarm.c
- +++ b/py/asmarm.c
- @@ -39,7 +39,7 @@
- #define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000)
-
- // Insert word into instruction flow
- -STATIC void emit(asm_arm_t *as, uint op) {
- +static void emit(asm_arm_t *as, uint op) {
- uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
- if (c != NULL) {
- *(uint32_t *)c = op;
- @@ -47,73 +47,83 @@ STATIC void emit(asm_arm_t *as, uint op) {
- }
-
- // Insert word into instruction flow, add "ALWAYS" condition code
- -STATIC void emit_al(asm_arm_t *as, uint op) {
- +static void emit_al(asm_arm_t *as, uint op) {
- emit(as, op | ASM_ARM_CC_AL);
- }
-
- // Basic instructions without condition code
- -STATIC uint asm_arm_op_push(uint reglist) {
- +static uint asm_arm_op_push(uint reglist) {
- // stmfd sp!, {reglist}
- return 0x92d0000 | (reglist & 0xFFFF);
- }
-
- -STATIC uint asm_arm_op_pop(uint reglist) {
- +static uint asm_arm_op_pop(uint reglist) {
- // ldmfd sp!, {reglist}
- return 0x8bd0000 | (reglist & 0xFFFF);
- }
-
- -STATIC uint asm_arm_op_mov_reg(uint rd, uint rn) {
- +static uint asm_arm_op_mov_reg(uint rd, uint rn) {
- // mov rd, rn
- return 0x1a00000 | (rd << 12) | rn;
- }
-
- -STATIC uint asm_arm_op_mov_imm(uint rd, uint imm) {
- +static uint asm_arm_op_mov_imm(uint rd, uint imm) {
- // mov rd, #imm
- return 0x3a00000 | (rd << 12) | imm;
- }
-
- -STATIC uint asm_arm_op_mvn_imm(uint rd, uint imm) {
- +static uint asm_arm_op_mvn_imm(uint rd, uint imm) {
- // mvn rd, #imm
- return 0x3e00000 | (rd << 12) | imm;
- }
-
- -STATIC uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) {
- +static uint asm_arm_op_mvn_reg(uint rd, uint rm) {
- + // mvn rd, rm
- + return 0x1e00000 | (rd << 12) | rm;
- +}
- +
- +static uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) {
- // add rd, rn, #imm
- return 0x2800000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
- }
-
- -STATIC uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) {
- +static uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) {
- // add rd, rn, rm
- return 0x0800000 | (rn << 16) | (rd << 12) | rm;
- }
-
- -STATIC uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) {
- +static uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) {
- // sub rd, rn, #imm
- return 0x2400000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
- }
-
- -STATIC uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) {
- +static uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) {
- // sub rd, rn, rm
- return 0x0400000 | (rn << 16) | (rd << 12) | rm;
- }
-
- -STATIC uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) {
- +static uint asm_arm_op_rsb_imm(uint rd, uint rn, uint imm) {
- + // rsb rd, rn, #imm
- + return 0x2600000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
- +}
- +
- +static uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) {
- // mul rd, rm, rs
- assert(rd != rm);
- return 0x0000090 | (rd << 16) | (rs << 8) | rm;
- }
-
- -STATIC uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) {
- +static uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) {
- // and rd, rn, rm
- return 0x0000000 | (rn << 16) | (rd << 12) | rm;
- }
-
- -STATIC uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) {
- +static uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) {
- // eor rd, rn, rm
- return 0x0200000 | (rn << 16) | (rd << 12) | rm;
- }
-
- -STATIC uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) {
- +static uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) {
- // orr rd, rn, rm
- return 0x1800000 | (rn << 16) | (rd << 12) | rm;
- }
- @@ -228,11 +238,23 @@ void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond) {
- emit(as, asm_arm_op_mov_imm(rd, 0) | (cond ^ (1 << 28))); // mov!COND rd, #0
- }
-
- +void asm_arm_mvn_reg_reg(asm_arm_t *as, uint rd, uint rm) {
- + // mvn rd, rm
- + // computes: rd := ~rm
- + emit_al(as, asm_arm_op_mvn_reg(rd, rm));
- +}
- +
- void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
- // add rd, rn, rm
- emit_al(as, asm_arm_op_add_reg(rd, rn, rm));
- }
-
- +void asm_arm_rsb_reg_reg_imm(asm_arm_t *as, uint rd, uint rn, uint imm) {
- + // rsb rd, rn, #imm
- + // computes: rd := #imm - rn
- + emit_al(as, asm_arm_op_rsb_imm(rd, rn, imm));
- +}
- +
- void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
- // sub rd, rn, rm
- emit_al(as, asm_arm_op_sub_reg(rd, rn, rm));
- diff --git a/py/asmarm.h b/py/asmarm.h
- index 81c3f7b1c..4a4253aef 100644
- --- a/py/asmarm.h
- +++ b/py/asmarm.h
- @@ -94,8 +94,10 @@ void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm);
- void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn);
-
- // arithmetic
- +void asm_arm_mvn_reg_reg(asm_arm_t *as, uint rd, uint rm);
- void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
- void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
- +void asm_arm_rsb_reg_reg_imm(asm_arm_t *as, uint rd, uint rn, uint imm);
- void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
- void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
- void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
- @@ -188,6 +190,8 @@ void asm_arm_bx_reg(asm_arm_t *as, uint reg_src);
- #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_arm_mov_reg_local_addr((as), (reg_dest), (local_num))
- #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_arm_mov_reg_pcrel((as), (reg_dest), (label))
-
- +#define ASM_NOT_REG(as, reg_dest) asm_arm_mvn_reg_reg((as), (reg_dest), (reg_dest))
- +#define ASM_NEG_REG(as, reg_dest) asm_arm_rsb_reg_reg_imm((as), (reg_dest), (reg_dest), 0)
- #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_arm_lsl_reg_reg((as), (reg_dest), (reg_shift))
- #define ASM_LSR_REG_REG(as, reg_dest, reg_shift) asm_arm_lsr_reg_reg((as), (reg_dest), (reg_shift))
- #define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_arm_asr_reg_reg((as), (reg_dest), (reg_shift))
- diff --git a/py/asmthumb.c b/py/asmthumb.c
- index 395134028..0df79e5fd 100644
- --- a/py/asmthumb.c
- +++ b/py/asmthumb.c
- @@ -79,7 +79,7 @@ static inline byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int n) {
- }
-
- /*
- -STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
- +static void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
- byte *c = asm_thumb_get_cur_to_write_bytes(as, 1);
- c[0] = b1;
- }
- @@ -91,7 +91,7 @@ STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
- #define IMM32_L2(x) (((x) >> 16) & 0xff)
- #define IMM32_L3(x) (((x) >> 24) & 0xff)
-
- -STATIC void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
- +static void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
- byte *c = asm_thumb_get_cur_to_write_bytes(as, 4);
- c[0] = IMM32_L0(w32);
- c[1] = IMM32_L1(w32);
- @@ -216,7 +216,7 @@ void asm_thumb_exit(asm_thumb_t *as) {
- asm_thumb_op16(as, OP_POP_RLIST_PC(as->push_reglist));
- }
-
- -STATIC mp_uint_t get_label_dest(asm_thumb_t *as, uint label) {
- +static mp_uint_t get_label_dest(asm_thumb_t *as, uint label) {
- assert(label < as->base.max_num_labels);
- return as->base.label_offsets[label];
- }
- diff --git a/py/asmthumb.h b/py/asmthumb.h
- index 2829ac4c7..a9e68d7ad 100644
- --- a/py/asmthumb.h
- +++ b/py/asmthumb.h
- @@ -406,6 +406,8 @@ void asm_thumb_b_rel12(asm_thumb_t *as, int rel);
- #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_thumb_mov_reg_local_addr((as), (reg_dest), (local_num))
- #define ASM_MOV_REG_PCREL(as, rlo_dest, label) asm_thumb_mov_reg_pcrel((as), (rlo_dest), (label))
-
- +#define ASM_NOT_REG(as, reg_dest) asm_thumb_mvn_rlo_rlo((as), (reg_dest), (reg_dest))
- +#define ASM_NEG_REG(as, reg_dest) asm_thumb_neg_rlo_rlo((as), (reg_dest), (reg_dest))
- #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSL, (reg_dest), (reg_shift))
- #define ASM_LSR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSR, (reg_dest), (reg_shift))
- #define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_ASR, (reg_dest), (reg_shift))
- diff --git a/py/asmx64.c b/py/asmx64.c
- index 5c923a523..d9f33cfb2 100644
- --- a/py/asmx64.c
- +++ b/py/asmx64.c
- @@ -54,6 +54,8 @@
- #define OPCODE_MOVZX_RM8_TO_R64 (0xb6) /* 0x0f 0xb6/r */
- #define OPCODE_MOVZX_RM16_TO_R64 (0xb7) /* 0x0f 0xb7/r */
- #define OPCODE_LEA_MEM_TO_R64 (0x8d) /* /r */
- +#define OPCODE_NOT_RM64 (0xf7) /* /2 */
- +#define OPCODE_NEG_RM64 (0xf7) /* /3 */
- #define OPCODE_AND_R64_TO_RM64 (0x21) /* /r */
- #define OPCODE_OR_R64_TO_RM64 (0x09) /* /r */
- #define OPCODE_XOR_R64_TO_RM64 (0x31) /* /r */
- @@ -123,14 +125,14 @@ static inline byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int n) {
- return mp_asm_base_get_cur_to_write_bytes(&as->base, n);
- }
-
- -STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
- +static void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
- byte *c = asm_x64_get_cur_to_write_bytes(as, 1);
- if (c != NULL) {
- c[0] = b1;
- }
- }
-
- -STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
- +static void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
- byte *c = asm_x64_get_cur_to_write_bytes(as, 2);
- if (c != NULL) {
- c[0] = b1;
- @@ -138,7 +140,7 @@ STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
- }
- }
-
- -STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
- +static void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
- byte *c = asm_x64_get_cur_to_write_bytes(as, 3);
- if (c != NULL) {
- c[0] = b1;
- @@ -147,7 +149,7 @@ STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
- }
- }
-
- -STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
- +static void asm_x64_write_word32(asm_x64_t *as, int w32) {
- byte *c = asm_x64_get_cur_to_write_bytes(as, 4);
- if (c != NULL) {
- c[0] = IMM32_L0(w32);
- @@ -157,7 +159,7 @@ STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
- }
- }
-
- -STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
- +static void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
- byte *c = asm_x64_get_cur_to_write_bytes(as, 8);
- if (c != NULL) {
- c[0] = IMM32_L0(w64);
- @@ -172,7 +174,7 @@ STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
- }
-
- /* unused
- -STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
- +static void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
- byte* c;
- assert(offset + 4 <= as->code_size);
- c = as->code_base + offset;
- @@ -183,7 +185,7 @@ STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
- }
- */
-
- -STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
- +static void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
- uint8_t rm_disp;
- if (disp_offset == 0 && (disp_r64 & 7) != ASM_X64_REG_RBP) {
- rm_disp = MODRM_RM_DISP0;
- @@ -204,7 +206,7 @@ STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int dis
- }
- }
-
- -STATIC void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) {
- +static void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) {
- asm_x64_write_byte_3(as, REX_PREFIX | REX_W | REX_R_FROM_R64(src_r64) | REX_B_FROM_R64(dest_r64), op, MODRM_R64(src_r64) | MODRM_RM_REG | MODRM_RM_R64(dest_r64));
- }
-
- @@ -243,7 +245,7 @@ void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) {
- }
- }
-
- -STATIC void asm_x64_ret(asm_x64_t *as) {
- +static void asm_x64_ret(asm_x64_t *as) {
- asm_x64_write_byte_1(as, OPCODE_RET);
- }
-
- @@ -317,7 +319,7 @@ void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest
- asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
- }
-
- -STATIC void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
- +static void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
- // use REX prefix for 64 bit operation
- asm_x64_write_byte_2(as, REX_PREFIX | REX_W | REX_R_FROM_R64(dest_r64) | REX_B_FROM_R64(src_r64), OPCODE_LEA_MEM_TO_R64);
- asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
- @@ -362,6 +364,14 @@ void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r
- }
- }
-
- +void asm_x64_not_r64(asm_x64_t *as, int dest_r64) {
- + asm_x64_generic_r64_r64(as, dest_r64, 2, OPCODE_NOT_RM64);
- +}
- +
- +void asm_x64_neg_r64(asm_x64_t *as, int dest_r64) {
- + asm_x64_generic_r64_r64(as, dest_r64, 3, OPCODE_NEG_RM64);
- +}
- +
- void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
- asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_AND_R64_TO_RM64);
- }
- @@ -414,7 +424,7 @@ void asm_x64_sub_i32_from_r32(asm_x64_t *as, int src_i32, int dest_r32) {
- }
- */
-
- -STATIC void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) {
- +static void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) {
- assert(dest_r64 < 8);
- if (SIGNED_FIT8(src_i32)) {
- // use REX prefix for 64 bit operation
- @@ -480,7 +490,7 @@ void asm_x64_jmp_reg(asm_x64_t *as, int src_r64) {
- asm_x64_write_byte_2(as, OPCODE_JMP_RM64, MODRM_R64(4) | MODRM_RM_REG | MODRM_RM_R64(src_r64));
- }
-
- -STATIC mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) {
- +static mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) {
- assert(label < as->base.max_num_labels);
- return as->base.label_offsets[label];
- }
- @@ -560,7 +570,7 @@ void asm_x64_exit(asm_x64_t *as) {
- // ^ ^
- // | low address | high address in RAM
- //
- -STATIC int asm_x64_local_offset_from_rsp(asm_x64_t *as, int local_num) {
- +static int asm_x64_local_offset_from_rsp(asm_x64_t *as, int local_num) {
- (void)as;
- // Stack is full descending, RSP points to local0
- return local_num * WORD_SIZE;
- diff --git a/py/asmx64.h b/py/asmx64.h
- index a8efc2bf6..c63e31797 100644
- --- a/py/asmx64.h
- +++ b/py/asmx64.h
- @@ -97,6 +97,8 @@ void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int des
- void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
- void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
- void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
- +void asm_x64_not_r64(asm_x64_t *as, int dest_r64);
- +void asm_x64_neg_r64(asm_x64_t *as, int dest_r64);
- void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
- void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
- void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
- @@ -191,6 +193,8 @@ void asm_x64_call_ind(asm_x64_t *as, size_t fun_id, int temp_r32);
- #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_x64_mov_local_addr_to_r64((as), (local_num), (reg_dest))
- #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_x64_mov_reg_pcrel((as), (reg_dest), (label))
-
- +#define ASM_NOT_REG(as, reg) asm_x64_not_r64((as), (reg))
- +#define ASM_NEG_REG(as, reg) asm_x64_neg_r64((as), (reg))
- #define ASM_LSL_REG(as, reg) asm_x64_shl_r64_cl((as), (reg))
- #define ASM_LSR_REG(as, reg) asm_x64_shr_r64_cl((as), (reg))
- #define ASM_ASR_REG(as, reg) asm_x64_sar_r64_cl((as), (reg))
- diff --git a/py/asmx86.c b/py/asmx86.c
- index 4b0f8047f..4acac1b46 100644
- --- a/py/asmx86.c
- +++ b/py/asmx86.c
- @@ -54,6 +54,8 @@
- #define OPCODE_MOVZX_RM8_TO_R32 (0xb6) /* 0x0f 0xb6/r */
- #define OPCODE_MOVZX_RM16_TO_R32 (0xb7) /* 0x0f 0xb7/r */
- #define OPCODE_LEA_MEM_TO_R32 (0x8d) /* /r */
- +#define OPCODE_NOT_RM32 (0xf7) /* /2 */
- +#define OPCODE_NEG_RM32 (0xf7) /* /3 */
- #define OPCODE_AND_R32_TO_RM32 (0x21) /* /r */
- #define OPCODE_OR_R32_TO_RM32 (0x09) /* /r */
- #define OPCODE_XOR_R32_TO_RM32 (0x31) /* /r */
- @@ -103,14 +105,14 @@
-
- #define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)
-
- -STATIC void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
- +static void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
- byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 1);
- if (c != NULL) {
- c[0] = b1;
- }
- }
-
- -STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
- +static void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
- byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2);
- if (c != NULL) {
- c[0] = b1;
- @@ -118,7 +120,7 @@ STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
- }
- }
-
- -STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
- +static void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
- byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3);
- if (c != NULL) {
- c[0] = b1;
- @@ -127,7 +129,7 @@ STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
- }
- }
-
- -STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) {
- +static void asm_x86_write_word32(asm_x86_t *as, int w32) {
- byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
- if (c != NULL) {
- c[0] = IMM32_L0(w32);
- @@ -137,7 +139,7 @@ STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) {
- }
- }
-
- -STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) {
- +static void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) {
- uint8_t rm_disp;
- if (disp_offset == 0 && disp_r32 != ASM_X86_REG_EBP) {
- rm_disp = MODRM_RM_DISP0;
- @@ -158,17 +160,17 @@ STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int dis
- }
- }
-
- -STATIC void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) {
- +static void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) {
- asm_x86_write_byte_2(as, op, MODRM_R32(src_r32) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
- }
-
- #if 0
- -STATIC void asm_x86_nop(asm_x86_t *as) {
- +static void asm_x86_nop(asm_x86_t *as) {
- asm_x86_write_byte_1(as, OPCODE_NOP);
- }
- #endif
-
- -STATIC void asm_x86_push_r32(asm_x86_t *as, int src_r32) {
- +static void asm_x86_push_r32(asm_x86_t *as, int src_r32) {
- asm_x86_write_byte_1(as, OPCODE_PUSH_R32 | src_r32);
- }
-
- @@ -184,11 +186,11 @@ void asm_x86_push_disp(asm_x86_t *as, int src_r32, int src_offset) {
- }
- #endif
-
- -STATIC void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) {
- +static void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) {
- asm_x86_write_byte_1(as, OPCODE_POP_R32 | dest_r32);
- }
-
- -STATIC void asm_x86_ret(asm_x86_t *as) {
- +static void asm_x86_ret(asm_x86_t *as) {
- asm_x86_write_byte_1(as, OPCODE_RET);
- }
-
- @@ -226,7 +228,7 @@ void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest
- asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp);
- }
-
- -STATIC void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) {
- +static void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) {
- asm_x86_write_byte_1(as, OPCODE_LEA_MEM_TO_R32);
- asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp);
- }
- @@ -244,6 +246,14 @@ size_t asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32) {
- return loc;
- }
-
- +void asm_x86_not_r32(asm_x86_t *as, int dest_r32) {
- + asm_x86_generic_r32_r32(as, dest_r32, 2, OPCODE_NOT_RM32);
- +}
- +
- +void asm_x86_neg_r32(asm_x86_t *as, int dest_r32) {
- + asm_x86_generic_r32_r32(as, dest_r32, 3, OPCODE_NEG_RM32);
- +}
- +
- void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
- asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_AND_R32_TO_RM32);
- }
- @@ -272,7 +282,7 @@ void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
- asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_ADD_R32_TO_RM32);
- }
-
- -STATIC void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) {
- +static void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) {
- if (SIGNED_FIT8(src_i32)) {
- asm_x86_write_byte_2(as, OPCODE_ADD_I8_TO_RM32, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
- asm_x86_write_byte_1(as, src_i32 & 0xff);
- @@ -286,7 +296,7 @@ void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
- asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_SUB_R32_FROM_RM32);
- }
-
- -STATIC void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) {
- +static void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) {
- if (SIGNED_FIT8(src_i32)) {
- // defaults to 32 bit operation
- asm_x86_write_byte_2(as, OPCODE_SUB_I8_FROM_RM32, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
- @@ -353,7 +363,7 @@ void asm_x86_jmp_reg(asm_x86_t *as, int src_r32) {
- asm_x86_write_byte_2(as, OPCODE_JMP_RM32, MODRM_R32(4) | MODRM_RM_REG | MODRM_RM_R32(src_r32));
- }
-
- -STATIC mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) {
- +static mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) {
- assert(label < as->base.max_num_labels);
- return as->base.label_offsets[label];
- }
- @@ -422,7 +432,7 @@ void asm_x86_exit(asm_x86_t *as) {
- asm_x86_ret(as);
- }
-
- -STATIC int asm_x86_arg_offset_from_esp(asm_x86_t *as, size_t arg_num) {
- +static int asm_x86_arg_offset_from_esp(asm_x86_t *as, size_t arg_num) {
- // Above esp are: locals, 4 saved registers, return eip, arguments
- return (as->num_locals + 4 + 1 + arg_num) * WORD_SIZE;
- }
- @@ -454,7 +464,7 @@ void asm_x86_mov_r32_to_arg(asm_x86_t *as, int src_r32, int dest_arg_num) {
- // ^ ^
- // | low address | high address in RAM
- //
- -STATIC int asm_x86_local_offset_from_esp(asm_x86_t *as, int local_num) {
- +static int asm_x86_local_offset_from_esp(asm_x86_t *as, int local_num) {
- (void)as;
- // Stack is full descending, ESP points to local0
- return local_num * WORD_SIZE;
- diff --git a/py/asmx86.h b/py/asmx86.h
- index ac98643a6..027d44151 100644
- --- a/py/asmx86.h
- +++ b/py/asmx86.h
- @@ -92,6 +92,8 @@ void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest
- void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
- void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
- void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
- +void asm_x86_not_r32(asm_x86_t *as, int dest_r32);
- +void asm_x86_neg_r32(asm_x86_t *as, int dest_r32);
- void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
- void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
- void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
- @@ -186,6 +188,8 @@ void asm_x86_call_ind(asm_x86_t *as, size_t fun_id, mp_uint_t n_args, int temp_r
- #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_x86_mov_local_addr_to_r32((as), (local_num), (reg_dest))
- #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_x86_mov_reg_pcrel((as), (reg_dest), (label))
-
- +#define ASM_NOT_REG(as, reg) asm_x86_not_r32((as), (reg))
- +#define ASM_NEG_REG(as, reg) asm_x86_neg_r32((as), (reg))
- #define ASM_LSL_REG(as, reg) asm_x86_shl_r32_cl((as), (reg))
- #define ASM_LSR_REG(as, reg) asm_x86_shr_r32_cl((as), (reg))
- #define ASM_ASR_REG(as, reg) asm_x86_sar_r32_cl((as), (reg))
- diff --git a/py/asmxtensa.c b/py/asmxtensa.c
- index 8ac914ec4..0fbe351dc 100644
- --- a/py/asmxtensa.c
- +++ b/py/asmxtensa.c
- @@ -117,7 +117,7 @@ void asm_xtensa_exit_win(asm_xtensa_t *as) {
- asm_xtensa_op_retw_n(as);
- }
-
- -STATIC uint32_t get_label_dest(asm_xtensa_t *as, uint label) {
- +static uint32_t get_label_dest(asm_xtensa_t *as, uint label) {
- assert(label < as->base.max_num_labels);
- return as->base.label_offsets[label];
- }
- @@ -185,7 +185,9 @@ size_t asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
- }
-
- void asm_xtensa_mov_reg_i32_optimised(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
- - if (SIGNED_FIT12(i32)) {
- + if (-32 <= (int)i32 && (int)i32 <= 95) {
- + asm_xtensa_op_movi_n(as, reg_dest, i32);
- + } else if (SIGNED_FIT12(i32)) {
- asm_xtensa_op_movi(as, reg_dest, i32);
- } else {
- asm_xtensa_mov_reg_i32(as, reg_dest, i32);
- diff --git a/py/asmxtensa.h b/py/asmxtensa.h
- index 5bd6426a1..f226624a8 100644
- --- a/py/asmxtensa.h
- +++ b/py/asmxtensa.h
- @@ -203,14 +203,19 @@ static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t i
- asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 10, (imm12 >> 8) & 0xf, reg_dest, imm12 & 0xff));
- }
-
- -static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) {
- - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm4));
- +// Argument must be in the range (-32 .. 95) inclusive.
- +static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm7) {
- + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm7));
- }
-
- static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) {
- asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 2, 8, reg_dest, reg_src_a, reg_src_b));
- }
-
- +static inline void asm_xtensa_op_neg(asm_xtensa_t *as, uint reg_dest, uint reg_src) {
- + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 6, reg_dest, 0, reg_src));
- +}
- +
- static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) {
- asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 2, reg_dest, reg_src_a, reg_src_b));
- }
- @@ -371,6 +376,7 @@ void asm_xtensa_call_ind_win(asm_xtensa_t *as, uint idx);
- #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_xtensa_mov_reg_local_addr((as), (reg_dest), ASM_NUM_REGS_SAVED + (local_num))
- #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_xtensa_mov_reg_pcrel((as), (reg_dest), (label))
-
- +#define ASM_NEG_REG(as, reg_dest) asm_xtensa_op_neg((as), (reg_dest), (reg_dest))
- #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) \
- do { \
- asm_xtensa_op_ssl((as), (reg_shift)); \
- diff --git a/py/bc.c b/py/bc.c
- index e1795ce41..899dbd6a0 100644
- --- a/py/bc.c
- +++ b/py/bc.c
- @@ -88,7 +88,7 @@ const byte *mp_decode_uint_skip(const byte *ptr) {
- return ptr;
- }
-
- -STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
- +static NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
- #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
- // generic message, used also for other argument issues
- (void)f;
- @@ -107,7 +107,7 @@ STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected,
- }
-
- #if DEBUG_PRINT
- -STATIC void dump_args(const mp_obj_t *a, size_t sz) {
- +static void dump_args(const mp_obj_t *a, size_t sz) {
- DEBUG_printf("%p: ", a);
- for (size_t i = 0; i < sz; i++) {
- DEBUG_printf("%p ", a[i]);
- @@ -124,7 +124,7 @@ STATIC void dump_args(const mp_obj_t *a, size_t sz) {
- // - code_state->ip should contain a pointer to the beginning of the prelude
- // - code_state->sp should be: &code_state->state[0] - 1
- // - code_state->n_state should be the number of objects in the local state
- -STATIC void mp_setup_code_state_helper(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static void mp_setup_code_state_helper(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- // This function is pretty complicated. It's main aim is to be efficient in speed and RAM
- // usage for the common case of positional only args.
-
- @@ -336,9 +336,9 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
- // On entry code_state should be allocated somewhere (stack/heap) and
- // contain the following valid entries:
- // - code_state->fun_bc should contain a pointer to the function object
- -// - code_state->ip should contain a pointer to the beginning of the prelude
- // - code_state->n_state should be the number of objects in the local state
- void mp_setup_code_state_native(mp_code_state_native_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- + code_state->ip = mp_obj_fun_native_get_prelude_ptr(code_state->fun_bc);
- code_state->sp = &code_state->state[0] - 1;
- mp_setup_code_state_helper((mp_code_state_t *)code_state, n_args, n_kw, args);
- }
- diff --git a/py/bc.h b/py/bc.h
- index 0e23255f7..718ba4a68 100644
- --- a/py/bc.h
- +++ b/py/bc.h
- @@ -44,11 +44,11 @@
- // prelude size : var uint
- // contains two values interleaved bit-wise as: xIIIIIIC repeated
- // x = extension another byte follows
- -// I = n_info number of bytes in source info section
- +// I = n_info number of bytes in source info section (always > 0)
- // C = n_cells number of bytes/cells in closure section
- //
- // source info section:
- -// simple_name : var qstr
- +// simple_name : var qstr always exists
- // argname0 : var qstr
- // ... : var qstr
- // argnameN : var qstr N = num_pos_args + num_kwonly_args - 1
- @@ -226,7 +226,7 @@ typedef struct _mp_compiled_module_t {
- // Outer level struct defining a frozen module.
- typedef struct _mp_frozen_module_t {
- const mp_module_constants_t constants;
- - const struct _mp_raw_code_t *rc;
- + const void *proto_fun;
- } mp_frozen_module_t;
-
- // State for an executing function.
- @@ -281,7 +281,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state,
- mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args);
- void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args);
- void mp_setup_code_state_native(mp_code_state_native_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args);
- -void mp_bytecode_print(const mp_print_t *print, const struct _mp_raw_code_t *rc, const mp_module_constants_t *cm);
- +void mp_bytecode_print(const mp_print_t *print, const struct _mp_raw_code_t *rc, size_t fun_data_len, const mp_module_constants_t *cm);
- void mp_bytecode_print2(const mp_print_t *print, const byte *ip, size_t len, struct _mp_raw_code_t *const *child_table, const mp_module_constants_t *cm);
- const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip_start, const byte *ip, struct _mp_raw_code_t *const *child_table, const mp_module_constants_t *cm);
- #define mp_bytecode_print_inst(print, code, x_table) mp_bytecode_print2(print, code, 1, x_table)
- diff --git a/py/binary.c b/py/binary.c
- index 4c8b6ffcd..7c01cfa1c 100644
- --- a/py/binary.c
- +++ b/py/binary.c
- @@ -74,11 +74,14 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
- case 'S':
- size = sizeof(void *);
- break;
- + case 'e':
- + size = 2;
- + break;
- case 'f':
- - size = sizeof(float);
- + size = 4;
- break;
- case 'd':
- - size = sizeof(double);
- + size = 8;
- break;
- }
- break;
- @@ -122,6 +125,10 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
- align = alignof(void *);
- size = sizeof(void *);
- break;
- + case 'e':
- + align = 2;
- + size = 2;
- + break;
- case 'f':
- align = alignof(float);
- size = sizeof(float);
- @@ -144,6 +151,99 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
- return size;
- }
-
- +#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_FLOAT_USE_NATIVE_FLT16
- +
- +static inline float mp_decode_half_float(uint16_t hf) {
- + union {
- + uint16_t i;
- + _Float16 f;
- + } fpu = { .i = hf };
- + return fpu.f;
- +}
- +
- +static inline uint16_t mp_encode_half_float(float x) {
- + union {
- + uint16_t i;
- + _Float16 f;
- + } fp_sp = { .f = (_Float16)x };
- + return fp_sp.i;
- +}
- +
- +#elif MICROPY_PY_BUILTINS_FLOAT
- +
- +static float mp_decode_half_float(uint16_t hf) {
- + union {
- + uint32_t i;
- + float f;
- + } fpu;
- +
- + uint16_t m = hf & 0x3ff;
- + int e = (hf >> 10) & 0x1f;
- + if (e == 0x1f) {
- + // Half-float is infinity.
- + e = 0xff;
- + } else if (e) {
- + // Half-float is normal.
- + e += 127 - 15;
- + } else if (m) {
- + // Half-float is subnormal, make it normal.
- + e = 127 - 15;
- + while (!(m & 0x400)) {
- + m <<= 1;
- + --e;
- + }
- + m -= 0x400;
- + ++e;
- + }
- +
- + fpu.i = ((hf & 0x8000) << 16) | (e << 23) | (m << 13);
- + return fpu.f;
- +}
- +
- +static uint16_t mp_encode_half_float(float x) {
- + union {
- + uint32_t i;
- + float f;
- + } fpu = { .f = x };
- +
- + uint16_t m = (fpu.i >> 13) & 0x3ff;
- + if (fpu.i & (1 << 12)) {
- + // Round up.
- + ++m;
- + }
- + int e = (fpu.i >> 23) & 0xff;
- +
- + if (e == 0xff) {
- + // Infinity.
- + e = 0x1f;
- + } else if (e != 0) {
- + e -= 127 - 15;
- + if (e < 0) {
- + // Underflow: denormalized, or zero.
- + if (e >= -11) {
- + m = (m | 0x400) >> -e;
- + if (m & 1) {
- + m = (m >> 1) + 1;
- + } else {
- + m >>= 1;
- + }
- + } else {
- + m = 0;
- + }
- + e = 0;
- + } else if (e > 0x3f) {
- + // Overflow: infinity.
- + e = 0x1f;
- + m = 0;
- + }
- + }
- +
- + uint16_t bits = ((fpu.i >> 16) & 0x8000) | (e << 10) | m;
- + return bits;
- +}
- +
- +#endif
- +
- mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
- mp_int_t val = 0;
- switch (typecode) {
- @@ -240,6 +340,8 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
- const char *s_val = (const char *)(uintptr_t)(mp_uint_t)val;
- return mp_obj_new_str(s_val, strlen(s_val));
- #if MICROPY_PY_BUILTINS_FLOAT
- + } else if (val_type == 'e') {
- + return mp_obj_new_float_from_f(mp_decode_half_float(val));
- } else if (val_type == 'f') {
- union {
- uint32_t i;
- @@ -309,6 +411,9 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
- val = (mp_uint_t)val_in;
- break;
- #if MICROPY_PY_BUILTINS_FLOAT
- + case 'e':
- + val = mp_encode_half_float(mp_obj_get_float_to_f(val_in));
- + break;
- case 'f': {
- union {
- uint32_t i;
- diff --git a/py/builtinevex.c b/py/builtinevex.c
- index 73fca5d39..e25cbd4d0 100644
- --- a/py/builtinevex.c
- +++ b/py/builtinevex.c
- @@ -38,13 +38,13 @@ typedef struct _mp_obj_code_t {
- mp_obj_t module_fun;
- } mp_obj_code_t;
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_code,
- MP_QSTR_code,
- MP_TYPE_FLAG_NONE
- );
-
- -STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
- +static mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
- // save context
- nlr_jump_callback_node_globals_locals_t ctx;
- ctx.globals = mp_globals_get();
- @@ -57,9 +57,13 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj
- // set exception handler to restore context if an exception is raised
- nlr_push_jump_callback(&ctx.callback, mp_globals_locals_set_from_nlr_jump_callback);
-
- - // a bit of a hack: fun_bc will re-set globals, so need to make sure it's
- - // the correct one
- - if (mp_obj_is_type(self->module_fun, &mp_type_fun_bc)) {
- + // The call to mp_parse_compile_execute() in mp_builtin_compile() below passes
- + // NULL for the globals, so repopulate that entry now with the correct globals.
- + if (mp_obj_is_type(self->module_fun, &mp_type_fun_bc)
- + #if MICROPY_EMIT_NATIVE
- + || mp_obj_is_type(self->module_fun, &mp_type_fun_native)
- + #endif
- + ) {
- mp_obj_fun_bc_t *fun_bc = MP_OBJ_TO_PTR(self->module_fun);
- ((mp_module_context_t *)fun_bc->context)->module.globals = globals;
- }
- @@ -74,7 +78,7 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj
- return ret;
- }
-
- -STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
- (void)n_args;
-
- // get the source
- @@ -114,7 +118,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj, 3, 6, mp_builtin_com
-
- #if MICROPY_PY_BUILTINS_EVAL_EXEC
-
- -STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
- +static mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
- // work out the context
- mp_obj_dict_t *globals = mp_globals_get();
- mp_obj_dict_t *locals = mp_locals_get();
- @@ -154,12 +158,12 @@ STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_i
- return mp_parse_compile_execute(lex, parse_input_kind, globals, locals);
- }
-
- -STATIC mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
- return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj, 1, 3, mp_builtin_eval);
-
- -STATIC mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
- return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec);
- @@ -167,7 +171,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec);
- #endif // MICROPY_PY_BUILTINS_EVAL_EXEC
-
- #if MICROPY_PY_BUILTINS_EXECFILE
- -STATIC mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
- // MP_PARSE_SINGLE_INPUT is used to indicate a file input
- return eval_exec_helper(n_args, args, MP_PARSE_SINGLE_INPUT);
- }
- diff --git a/py/builtinhelp.c b/py/builtinhelp.c
- index 9bd56cca0..a3fcc4dfb 100644
- --- a/py/builtinhelp.c
- +++ b/py/builtinhelp.c
- @@ -47,7 +47,7 @@ const char mp_help_default_text[] =
- "For further help on a specific object, type help(obj)\n"
- ;
-
- -STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
- +static void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
- mp_print_str(MP_PYTHON_PRINTER, " ");
- mp_obj_print(name_o, PRINT_STR);
- mp_print_str(MP_PYTHON_PRINTER, " -- ");
- @@ -56,7 +56,7 @@ STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
- }
-
- #if MICROPY_PY_BUILTINS_HELP_MODULES
- -STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
- +static void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
- for (size_t i = 0; i < map->alloc; i++) {
- if (mp_map_slot_is_filled(map, i)) {
- mp_obj_list_append(list, map->table[i].key);
- @@ -65,7 +65,7 @@ STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
- }
-
- #if MICROPY_MODULE_FROZEN
- -STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) {
- +static void mp_help_add_from_names(mp_obj_t list, const char *name) {
- while (*name) {
- size_t len = strlen(name);
- // name should end in '.py' and we strip it off
- @@ -75,7 +75,7 @@ STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) {
- }
- #endif
-
- -STATIC void mp_help_print_modules(void) {
- +static void mp_help_print_modules(void) {
- mp_obj_t list = mp_obj_new_list(0, NULL);
-
- mp_help_add_from_map(list, &mp_builtin_module_map);
- @@ -122,7 +122,7 @@ STATIC void mp_help_print_modules(void) {
- }
- #endif
-
- -STATIC void mp_help_print_obj(const mp_obj_t obj) {
- +static void mp_help_print_obj(const mp_obj_t obj) {
- #if MICROPY_PY_BUILTINS_HELP_MODULES
- if (obj == MP_OBJ_NEW_QSTR(MP_QSTR_modules)) {
- mp_help_print_modules();
- @@ -158,7 +158,7 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) {
- }
- }
-
- -STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
- if (n_args == 0) {
- // print a general help message
- mp_print_str(MP_PYTHON_PRINTER, MICROPY_PY_BUILTINS_HELP_TEXT);
- diff --git a/py/builtinimport.c b/py/builtinimport.c
- index 009885498..0611926fd 100644
- --- a/py/builtinimport.c
- +++ b/py/builtinimport.c
- @@ -57,16 +57,17 @@
- // uses mp_vfs_import_stat) to also search frozen modules. Given an exact
- // path to a file or directory (e.g. "foo/bar", foo/bar.py" or "foo/bar.mpy"),
- // will return whether the path is a file, directory, or doesn't exist.
- -STATIC mp_import_stat_t stat_path(const char *path) {
- +static mp_import_stat_t stat_path(vstr_t *path) {
- + const char *str = vstr_null_terminated_str(path);
- #if MICROPY_MODULE_FROZEN
- // Only try and load as a frozen module if it starts with .frozen/.
- const int frozen_path_prefix_len = strlen(MP_FROZEN_PATH_PREFIX);
- - if (strncmp(path, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) {
- + if (strncmp(str, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) {
- // Just stat (which is the return value), don't get the data.
- - return mp_find_frozen_module(path + frozen_path_prefix_len, NULL, NULL);
- + return mp_find_frozen_module(str + frozen_path_prefix_len, NULL, NULL);
- }
- #endif
- - return mp_import_stat(path);
- + return mp_import_stat(str);
- }
-
- // Stat a given filesystem path to a .py file. If the file does not exist,
- @@ -74,8 +75,8 @@ STATIC mp_import_stat_t stat_path(const char *path) {
- // argument. This is the logic that makes .py files take precedent over .mpy
- // files. This uses stat_path above, rather than mp_import_stat directly, so
- // that the .frozen path prefix is handled.
- -STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
- - mp_import_stat_t stat = stat_path(vstr_null_terminated_str(path));
- +static mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
- + mp_import_stat_t stat = stat_path(path);
- if (stat == MP_IMPORT_STAT_FILE) {
- return stat;
- }
- @@ -85,7 +86,7 @@ STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
- // Note: There's no point doing this if it's a frozen path, but adding the check
- // would be extra code, and no harm letting mp_find_frozen_module fail instead.
- vstr_ins_byte(path, path->len - 2, 'm');
- - stat = stat_path(vstr_null_terminated_str(path));
- + stat = stat_path(path);
- if (stat == MP_IMPORT_STAT_FILE) {
- return stat;
- }
- @@ -98,8 +99,8 @@ STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
- // or "foo/bar.(m)py" in either the filesystem or frozen modules. If the
- // result is a file, the path argument will be updated to include the file
- // extension.
- -STATIC mp_import_stat_t stat_module(vstr_t *path) {
- - mp_import_stat_t stat = stat_path(vstr_null_terminated_str(path));
- +static mp_import_stat_t stat_module(vstr_t *path) {
- + mp_import_stat_t stat = stat_path(path);
- DEBUG_printf("stat %s: %d\n", vstr_str(path), stat);
- if (stat == MP_IMPORT_STAT_DIR) {
- return stat;
- @@ -113,7 +114,7 @@ STATIC mp_import_stat_t stat_module(vstr_t *path) {
- // Given a top-level module name, try and find it in each of the sys.path
- // entries. Note: On success, the dest argument will be updated to the matching
- // path (i.e. "<entry>/mod_name(.py)").
- -STATIC mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
- +static mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
- DEBUG_printf("stat_top_level: '%s'\n", qstr_str(mod_name));
- #if MICROPY_PY_SYS
- size_t path_num;
- @@ -151,7 +152,7 @@ STATIC mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
- }
-
- #if MICROPY_MODULE_FROZEN_STR || MICROPY_ENABLE_COMPILER
- -STATIC void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
- +static void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
- #if MICROPY_PY___FILE__
- qstr source_name = lex->source_name;
- mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
- @@ -164,7 +165,7 @@ STATIC void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
- #endif
-
- #if (MICROPY_HAS_FILE_READER && MICROPY_PERSISTENT_CODE_LOAD) || MICROPY_MODULE_FROZEN_MPY
- -STATIC void do_execute_raw_code(const mp_module_context_t *context, const mp_raw_code_t *rc, qstr source_name) {
- +static void do_execute_proto_fun(const mp_module_context_t *context, mp_proto_fun_t proto_fun, qstr source_name) {
- #if MICROPY_PY___FILE__
- mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
- #else
- @@ -187,7 +188,7 @@ STATIC void do_execute_raw_code(const mp_module_context_t *context, const mp_raw
- nlr_push_jump_callback(&ctx.callback, mp_globals_locals_set_from_nlr_jump_callback);
-
- // make and execute the function
- - mp_obj_t module_fun = mp_make_function_from_raw_code(rc, context, NULL);
- + mp_obj_t module_fun = mp_make_function_from_proto_fun(proto_fun, context, NULL);
- mp_call_function_0(module_fun);
-
- // deregister exception handler and restore context
- @@ -195,7 +196,7 @@ STATIC void do_execute_raw_code(const mp_module_context_t *context, const mp_raw
- }
- #endif
-
- -STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
- +static void do_load(mp_module_context_t *module_obj, vstr_t *file) {
- #if MICROPY_MODULE_FROZEN || MICROPY_ENABLE_COMPILER || (MICROPY_PERSISTENT_CODE_LOAD && MICROPY_HAS_FILE_READER)
- const char *file_str = vstr_null_terminated_str(file);
- #endif
- @@ -229,7 +230,7 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
- #else
- qstr frozen_file_qstr = MP_QSTRnull;
- #endif
- - do_execute_raw_code(module_obj, frozen->rc, frozen_file_qstr);
- + do_execute_proto_fun(module_obj, frozen->proto_fun, frozen_file_qstr);
- return;
- }
- #endif
- @@ -246,7 +247,7 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
- mp_compiled_module_t cm;
- cm.context = module_obj;
- mp_raw_code_load_file(file_qstr, &cm);
- - do_execute_raw_code(cm.context, cm.rc, file_qstr);
- + do_execute_proto_fun(cm.context, cm.rc, file_qstr);
- return;
- }
- #endif
- @@ -266,7 +267,7 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
-
- // Convert a relative (to the current module) import, going up "level" levels,
- // into an absolute import.
- -STATIC void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) {
- +static void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) {
- // What we want to do here is to take the name of the current module,
- // remove <level> trailing components, and concatenate the passed-in
- // module name.
- @@ -349,7 +350,7 @@ typedef struct _nlr_jump_callback_node_unregister_module_t {
- qstr name;
- } nlr_jump_callback_node_unregister_module_t;
-
- -STATIC void unregister_module_from_nlr_jump_callback(void *ctx_in) {
- +static void unregister_module_from_nlr_jump_callback(void *ctx_in) {
- nlr_jump_callback_node_unregister_module_t *ctx = ctx_in;
- mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map;
- mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(ctx->name), MP_MAP_LOOKUP_REMOVE_IF_FOUND);
- @@ -362,7 +363,7 @@ STATIC void unregister_module_from_nlr_jump_callback(void *ctx_in) {
- // attribute on it) (or MP_OBJ_NULL for top-level).
- // override_main: Whether to set the __name__ to "__main__" (and use __main__
- // for the actual path).
- -STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_obj_t outer_module_obj, bool override_main) {
- +static mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_obj_t outer_module_obj, bool override_main) {
- // Immediately return if the module at this level is already loaded.
- mp_map_elem_t *elem;
-
- diff --git a/py/compile.c b/py/compile.c
- index a9b34ce5d..62757de3c 100644
- --- a/py/compile.c
- +++ b/py/compile.c
- @@ -41,8 +41,6 @@
-
- #if MICROPY_ENABLE_COMPILER
-
- -// TODO need to mangle __attr names
- -
- #define INVALID_LABEL (0xffff)
-
- typedef enum {
- @@ -92,7 +90,7 @@ typedef enum {
- #define NATIVE_EMITTER(f) emit_native_table[mp_dynamic_compiler.native_arch]->emit_##f
- #define NATIVE_EMITTER_TABLE (emit_native_table[mp_dynamic_compiler.native_arch])
-
- -STATIC const emit_method_table_t *emit_native_table[] = {
- +static const emit_method_table_t *emit_native_table[] = {
- NULL,
- &emit_native_x86_method_table,
- &emit_native_x64_method_table,
- @@ -131,7 +129,7 @@ STATIC const emit_method_table_t *emit_native_table[] = {
- #define ASM_EMITTER(f) emit_asm_table[mp_dynamic_compiler.native_arch]->asm_##f
- #define ASM_EMITTER_TABLE emit_asm_table[mp_dynamic_compiler.native_arch]
-
- -STATIC const emit_inline_asm_method_table_t *emit_asm_table[] = {
- +static const emit_inline_asm_method_table_t *emit_asm_table[] = {
- NULL,
- NULL,
- NULL,
- @@ -198,11 +196,15 @@ typedef struct _compiler_t {
- mp_emit_common_t emit_common;
- } compiler_t;
-
- +#if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
- +bool mp_compile_allow_top_level_await = false;
- +#endif
- +
- /******************************************************************************/
- // mp_emit_common_t helper functions
- // These are defined here so they can be inlined, to reduce code size.
-
- -STATIC void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
- +static void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
- #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
- mp_map_init(&emit->qstr_map, 1);
-
- @@ -213,7 +215,7 @@ STATIC void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
- mp_obj_list_init(&emit->const_obj_list, 0);
- }
-
- -STATIC void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass) {
- +static void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass) {
- emit->pass = pass;
- if (pass == MP_PASS_CODE_SIZE) {
- if (emit->ct_cur_child == 0) {
- @@ -225,7 +227,7 @@ STATIC void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass)
- emit->ct_cur_child = 0;
- }
-
- -STATIC void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr source_file, mp_module_context_t *context) {
- +static void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr source_file, mp_module_context_t *context) {
- #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
- size_t qstr_map_used = emit->qstr_map.used;
- mp_module_context_alloc_tables(context, qstr_map_used, emit->const_obj_list.len);
- @@ -248,14 +250,14 @@ STATIC void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr
-
- /******************************************************************************/
-
- -STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
- +static void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
- // if the line of the error is unknown then try to update it from the pn
- if (comp->compile_error_line == 0 && MP_PARSE_NODE_IS_STRUCT(pn)) {
- comp->compile_error_line = ((mp_parse_node_struct_t *)pn)->source_line;
- }
- }
-
- -STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_error_text_t msg) {
- +static void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_error_text_t msg) {
- // only register the error if there has been no other error
- if (comp->compile_error == MP_OBJ_NULL) {
- comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
- @@ -263,17 +265,17 @@ STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_er
- }
- }
-
- -STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra);
- -STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind);
- -STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map);
- -STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn);
- +static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra);
- +static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind);
- +static void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map);
- +static void compile_node(compiler_t *comp, mp_parse_node_t pn);
-
- -STATIC uint comp_next_label(compiler_t *comp) {
- +static uint comp_next_label(compiler_t *comp) {
- return comp->next_label++;
- }
-
- #if MICROPY_EMIT_NATIVE
- -STATIC void reserve_labels_for_native(compiler_t *comp, int n) {
- +static void reserve_labels_for_native(compiler_t *comp, int n) {
- if (comp->scope_cur->emit_options != MP_EMIT_OPT_BYTECODE) {
- comp->next_label += n;
- }
- @@ -282,7 +284,7 @@ STATIC void reserve_labels_for_native(compiler_t *comp, int n) {
- #define reserve_labels_for_native(comp, n)
- #endif
-
- -STATIC void compile_increase_except_level(compiler_t *comp, uint label, int kind) {
- +static void compile_increase_except_level(compiler_t *comp, uint label, int kind) {
- EMIT_ARG(setup_block, label, kind);
- comp->cur_except_level += 1;
- if (comp->cur_except_level > comp->scope_cur->exc_stack_size) {
- @@ -290,14 +292,14 @@ STATIC void compile_increase_except_level(compiler_t *comp, uint label, int kind
- }
- }
-
- -STATIC void compile_decrease_except_level(compiler_t *comp) {
- +static void compile_decrease_except_level(compiler_t *comp) {
- assert(comp->cur_except_level > 0);
- comp->cur_except_level -= 1;
- EMIT(end_finally);
- reserve_labels_for_native(comp, 1);
- }
-
- -STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) {
- +static scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) {
- scope_t *scope = scope_new(kind, pn, emit_options);
- scope->parent = comp->scope_cur;
- scope->next = NULL;
- @@ -315,7 +317,7 @@ STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse
-
- typedef void (*apply_list_fun_t)(compiler_t *comp, mp_parse_node_t pn);
-
- -STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) {
- +static void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) {
- if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, pn_list_kind)) {
- mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
- int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- @@ -327,7 +329,7 @@ STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kin
- }
- }
-
- -STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) {
- int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- for (int i = 0; i < num_nodes; i++) {
- compile_node(comp, pns->nodes[i]);
- @@ -339,7 +341,7 @@ STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *
- }
- }
-
- -STATIC void compile_load_id(compiler_t *comp, qstr qst) {
- +static void compile_load_id(compiler_t *comp, qstr qst) {
- if (comp->pass == MP_PASS_SCOPE) {
- mp_emit_common_get_id_for_load(comp->scope_cur, qst);
- } else {
- @@ -351,7 +353,7 @@ STATIC void compile_load_id(compiler_t *comp, qstr qst) {
- }
- }
-
- -STATIC void compile_store_id(compiler_t *comp, qstr qst) {
- +static void compile_store_id(compiler_t *comp, qstr qst) {
- if (comp->pass == MP_PASS_SCOPE) {
- mp_emit_common_get_id_for_modification(comp->scope_cur, qst);
- } else {
- @@ -363,7 +365,7 @@ STATIC void compile_store_id(compiler_t *comp, qstr qst) {
- }
- }
-
- -STATIC void compile_delete_id(compiler_t *comp, qstr qst) {
- +static void compile_delete_id(compiler_t *comp, qstr qst) {
- if (comp->pass == MP_PASS_SCOPE) {
- mp_emit_common_get_id_for_modification(comp->scope_cur, qst);
- } else {
- @@ -375,7 +377,7 @@ STATIC void compile_delete_id(compiler_t *comp, qstr qst) {
- }
- }
-
- -STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // a simple tuple expression
- size_t num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- for (size_t i = 0; i < num_nodes; i++) {
- @@ -384,7 +386,7 @@ STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns)
- EMIT_ARG(build, num_nodes, MP_EMIT_BUILD_TUPLE);
- }
-
- -STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) {
- +static void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) {
- if (mp_parse_node_is_const_false(pn)) {
- if (jump_if == false) {
- EMIT_ARG(jump, label);
- @@ -432,9 +434,9 @@ STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int la
- }
-
- typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_kind_t;
- -STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind);
- +static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind);
-
- -STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) {
- +static void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) {
- if (assign_kind != ASSIGN_AUG_STORE) {
- compile_node(comp, pns->nodes[0]);
- }
- @@ -483,7 +485,7 @@ STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, as
- compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("can't assign to expression"));
- }
-
- -STATIC void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) {
- +static void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) {
- // look for star expression
- uint have_star_index = -1;
- for (uint i = 0; i < num_tail; i++) {
- @@ -510,7 +512,7 @@ STATIC void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nod
- }
-
- // assigns top of stack to pn
- -STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) {
- +static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) {
- assert(!MP_PARSE_NODE_IS_NULL(pn));
- if (MP_PARSE_NODE_IS_LEAF(pn)) {
- if (MP_PARSE_NODE_IS_ID(pn)) {
- @@ -601,7 +603,7 @@ cannot_assign:
- // if n_pos_defaults > 0 then there is a tuple on the stack with the positional defaults
- // if n_kw_defaults > 0 then there is a dictionary on the stack with the keyword defaults
- // if both exist, the tuple is above the dictionary (ie the first pop gets the tuple)
- -STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) {
- +static void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) {
- assert(n_pos_defaults >= 0);
- assert(n_kw_defaults >= 0);
-
- @@ -643,7 +645,7 @@ STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int
- }
- }
-
- -STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) {
- +static void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) {
- // For efficiency of the code below we extract the parse-node kind here
- int pn_kind;
- if (MP_PARSE_NODE_IS_ID(pn)) {
- @@ -734,7 +736,7 @@ STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn)
- }
- }
-
- -STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) {
- +static void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) {
- // When we call compile_funcdef_lambdef_param below it can compile an arbitrary
- // expression for default arguments, which may contain a lambda. The lambda will
- // call here in a nested way, so we must save and restore the relevant state.
- @@ -770,7 +772,7 @@ STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_n
-
- // leaves function object on stack
- // returns function name
- -STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
- +static qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
- if (comp->pass == MP_PASS_SCOPE) {
- // create a new scope for this function
- scope_t *s = scope_new_and_link(comp, SCOPE_FUNCTION, (mp_parse_node_t)pns, emit_options);
- @@ -790,7 +792,7 @@ STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns
-
- // leaves class object on stack
- // returns class name
- -STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
- +static qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
- if (comp->pass == MP_PASS_SCOPE) {
- // create a new scope for this class
- scope_t *s = scope_new_and_link(comp, SCOPE_CLASS, (mp_parse_node_t)pns, emit_options);
- @@ -822,7 +824,7 @@ STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pn
- }
-
- // returns true if it was a built-in decorator (even if the built-in had an error)
- -STATIC bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_parse_node_t *name_nodes, uint *emit_options) {
- +static bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_parse_node_t *name_nodes, uint *emit_options) {
- if (MP_PARSE_NODE_LEAF_ARG(name_nodes[0]) != MP_QSTR_micropython) {
- return false;
- }
- @@ -871,7 +873,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_par
- return true;
- }
-
- -STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // get the list of decorators
- mp_parse_node_t *nodes;
- size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_decorators, &nodes);
- @@ -939,13 +941,13 @@ STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_store_id(comp, body_name);
- }
-
- -STATIC void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
- qstr fname = compile_funcdef_helper(comp, pns, comp->scope_cur->emit_options);
- // store function object into function name
- compile_store_id(comp, fname);
- }
-
- -STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
- +static void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
- if (MP_PARSE_NODE_IS_ID(pn)) {
- compile_delete_id(comp, MP_PARSE_NODE_LEAF_ARG(pn));
- } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_expr_normal)) {
- @@ -1001,11 +1003,11 @@ cannot_delete:
- compile_syntax_error(comp, (mp_parse_node_t)pn, MP_ERROR_TEXT("can't delete expression"));
- }
-
- -STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- apply_to_single_or_list(comp, pns->nodes[0], PN_exprlist, c_del_stmt);
- }
-
- -STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- uint16_t label;
- if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_break_stmt) {
- label = comp->break_label;
- @@ -1019,7 +1021,7 @@ STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
- EMIT_ARG(unwind_jump, label, comp->cur_except_level - comp->break_continue_except_level);
- }
-
- -STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- #if MICROPY_CPYTHON_COMPAT
- if (comp->scope_cur->kind != SCOPE_FUNCTION) {
- compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'return' outside function"));
- @@ -1047,12 +1049,12 @@ STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- EMIT(return_value);
- }
-
- -STATIC void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_node(comp, pns->nodes[0]);
- EMIT(pop_top);
- }
-
- -STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
- // raise
- EMIT_ARG(raise_varargs, 0);
- @@ -1072,7 +1074,7 @@ STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // q_base holds the base of the name
- // eg a -> q_base=a
- // a.b.c -> q_base=a
- -STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
- +static void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
- bool is_as = false;
- if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_as_name)) {
- mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
- @@ -1133,7 +1135,7 @@ STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
- }
- }
-
- -STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
- +static void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
- EMIT_ARG(load_const_small_int, 0); // level 0 import
- EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); // not importing from anything
- qstr q_base;
- @@ -1141,11 +1143,11 @@ STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
- compile_store_id(comp, q_base);
- }
-
- -STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
- apply_to_single_or_list(comp, pns->nodes[0], PN_dotted_as_names, compile_dotted_as_name);
- }
-
- -STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
- mp_parse_node_t pn_import_source = pns->nodes[0];
-
- // extract the preceding .'s (if any) for a relative import, to compute the import level
- @@ -1233,7 +1235,7 @@ STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- }
-
- -STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
- +static void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
- if (id_info->kind != ID_INFO_KIND_UNDECIDED && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) {
- compile_syntax_error(comp, pn, MP_ERROR_TEXT("identifier redefined as global"));
- return;
- @@ -1247,7 +1249,7 @@ STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info
- }
- }
-
- -STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
- +static void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
- if (id_info->kind == ID_INFO_KIND_UNDECIDED) {
- id_info->kind = ID_INFO_KIND_GLOBAL_IMPLICIT;
- scope_check_to_close_over(comp->scope_cur, id_info);
- @@ -1259,7 +1261,7 @@ STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_in
- }
- }
-
- -STATIC void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info, bool is_global) {
- +static void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info, bool is_global) {
- if (is_global) {
- compile_declare_global(comp, pn, id_info);
- } else {
- @@ -1267,7 +1269,7 @@ STATIC void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t
- }
- }
-
- -STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (comp->pass == MP_PASS_SCOPE) {
- bool is_global = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_global_stmt;
-
- @@ -1286,7 +1288,7 @@ STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_
- }
- }
-
- -STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // with optimisations enabled we don't compile assertions
- if (MP_STATE_VM(mp_optimise_value) != 0) {
- return;
- @@ -1304,7 +1306,7 @@ STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- EMIT_ARG(label_assign, l_end);
- }
-
- -STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- uint l_end = comp_next_label(comp);
-
- // optimisation: don't emit anything when "if False"
- @@ -1374,7 +1376,7 @@ done:
- comp->continue_label = old_continue_label; \
- comp->break_continue_except_level = old_break_continue_except_level;
-
- -STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- START_BREAK_CONTINUE_BLOCK
-
- if (!mp_parse_node_is_const_false(pns->nodes[0])) { // optimisation: don't emit anything for "while False"
- @@ -1412,7 +1414,7 @@ STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // If <end> is a small-int, then the stack during the for-loop contains just
- // the current value of <var>. Otherwise, the stack contains <end> then the
- // current value of <var>.
- -STATIC void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) {
- +static void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) {
- START_BREAK_CONTINUE_BLOCK
-
- uint top_label = comp_next_label(comp);
- @@ -1494,7 +1496,7 @@ STATIC void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t p
- }
- }
-
- -STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // this bit optimises: for <x> in range(...), turning it into an explicitly incremented variable
- // this is actually slower, but uses no heap memory
- // for viper it will be much, much faster
- @@ -1574,7 +1576,7 @@ STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- EMIT_ARG(label_assign, break_label);
- }
-
- -STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) {
- +static void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_excepts, mp_parse_node_t pn_else) {
- // setup code
- uint l1 = comp_next_label(comp);
- uint success_label = comp_next_label(comp);
- @@ -1671,7 +1673,7 @@ STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_
- EMIT_ARG(label_assign, l2);
- }
-
- -STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) {
- +static void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n_except, mp_parse_node_t *pn_except, mp_parse_node_t pn_else, mp_parse_node_t pn_finally) {
- uint l_finally_block = comp_next_label(comp);
-
- compile_increase_except_level(comp, l_finally_block, MP_EMIT_SETUP_BLOCK_FINALLY);
- @@ -1700,7 +1702,7 @@ STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n
- compile_decrease_except_level(comp);
- }
-
- -STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should be
- {
- mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1];
- @@ -1727,7 +1729,7 @@ STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- }
-
- -STATIC void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
- +static void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
- if (n == 0) {
- // no more pre-bits, compile the body of the with
- compile_node(comp, body);
- @@ -1754,7 +1756,7 @@ STATIC void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t
- }
- }
-
- -STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
- mp_parse_node_t *nodes;
- size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes);
- @@ -1764,7 +1766,7 @@ STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_with_stmt_helper(comp, n, nodes, pns->nodes[1]);
- }
-
- -STATIC void compile_yield_from(compiler_t *comp) {
- +static void compile_yield_from(compiler_t *comp) {
- EMIT_ARG(get_iter, false);
- EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
- EMIT_ARG(yield, MP_EMIT_YIELD_FROM);
- @@ -1772,13 +1774,13 @@ STATIC void compile_yield_from(compiler_t *comp) {
- }
-
- #if MICROPY_PY_ASYNC_AWAIT
- -STATIC void compile_await_object_method(compiler_t *comp, qstr method) {
- +static void compile_await_object_method(compiler_t *comp, qstr method) {
- EMIT_ARG(load_method, method, false);
- EMIT_ARG(call_method, 0, 0, 0);
- compile_yield_from(comp);
- }
-
- -STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // Allocate labels.
- uint while_else_label = comp_next_label(comp);
- uint try_exception_label = comp_next_label(comp);
- @@ -1845,7 +1847,7 @@ STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns
- // Stack: (...)
- }
-
- -STATIC void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
- +static void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
- if (n == 0) {
- // no more pre-bits, compile the body of the with
- compile_node(comp, body);
- @@ -1957,7 +1959,7 @@ STATIC void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_
- }
- }
-
- -STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
- mp_parse_node_t *nodes;
- size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes);
- @@ -1967,7 +1969,7 @@ STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
- compile_async_with_stmt_helper(comp, n, nodes, pns->nodes[1]);
- }
-
- -STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[0]));
- mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t *)pns->nodes[0];
- if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_funcdef) {
- @@ -1996,7 +1998,7 @@ STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- #endif
-
- -STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- mp_parse_node_t pn_rhs = pns->nodes[1];
- if (MP_PARSE_NODE_IS_NULL(pn_rhs)) {
- if (comp->is_repl && comp->scope_cur->kind == SCOPE_MODULE) {
- @@ -2111,7 +2113,7 @@ STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- }
-
- -STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else));
- mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t *)pns->nodes[1];
-
- @@ -2126,7 +2128,7 @@ STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns)
- EMIT_ARG(label_assign, l_end);
- }
-
- -STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (comp->pass == MP_PASS_SCOPE) {
- // create a new scope for this lambda
- scope_t *s = scope_new_and_link(comp, SCOPE_LAMBDA, (mp_parse_node_t)pns, comp->scope_cur->emit_options);
- @@ -2142,7 +2144,7 @@ STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
-
- #if MICROPY_PY_ASSIGN_EXPR
- -STATIC void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name, mp_parse_node_t pn_expr) {
- +static void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name, mp_parse_node_t pn_expr) {
- if (!MP_PARSE_NODE_IS_ID(pn_name)) {
- compile_syntax_error(comp, (mp_parse_node_t)pn_name, MP_ERROR_TEXT("can't assign to expression"));
- }
- @@ -2174,12 +2176,12 @@ STATIC void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name,
- compile_store_id(comp, target);
- }
-
- -STATIC void compile_namedexpr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_namedexpr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_namedexpr_helper(comp, pns->nodes[0], pns->nodes[1]);
- }
- #endif
-
- -STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
- bool cond = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_or_test;
- uint l_end = comp_next_label(comp);
- int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- @@ -2192,12 +2194,12 @@ STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
- EMIT_ARG(label_assign, l_end);
- }
-
- -STATIC void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_node(comp, pns->nodes[0]);
- EMIT_ARG(unary_op, MP_UNARY_OP_NOT);
- }
-
- -STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
- int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- compile_node(comp, pns->nodes[0]);
- bool multi = (num_nodes > 3);
- @@ -2250,11 +2252,11 @@ STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- }
-
- -STATIC void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("*x must be assignment target"));
- }
-
- -STATIC void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
- MP_STATIC_ASSERT(MP_BINARY_OP_OR + PN_xor_expr - PN_expr == MP_BINARY_OP_XOR);
- MP_STATIC_ASSERT(MP_BINARY_OP_OR + PN_and_expr - PN_expr == MP_BINARY_OP_AND);
- mp_binary_op_t binary_op = MP_BINARY_OP_OR + MP_PARSE_NODE_STRUCT_KIND(pns) - PN_expr;
- @@ -2266,7 +2268,7 @@ STATIC void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- }
-
- -STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
- int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- compile_node(comp, pns->nodes[0]);
- for (int i = 1; i + 1 < num_nodes; i += 2) {
- @@ -2277,7 +2279,7 @@ STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- }
-
- -STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_node(comp, pns->nodes[1]);
- mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]);
- mp_unary_op_t op;
- @@ -2290,7 +2292,7 @@ STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
- EMIT_ARG(unary_op, op);
- }
-
- -STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // compile the subject of the expression
- compile_node(comp, pns->nodes[0]);
-
- @@ -2386,12 +2388,12 @@ STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *p
- }
- }
-
- -STATIC void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_generic_all_nodes(comp, pns); // 2 nodes, arguments of power
- EMIT_ARG(binary_op, MP_BINARY_OP_POWER);
- }
-
- -STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) {
- +static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) {
- // function to call is on top of stack
-
- // get the list of arguments
- @@ -2486,7 +2488,7 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
- }
-
- // pns needs to have 2 nodes, first is lhs of comprehension, second is PN_comp_for node
- -STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) {
- +static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) {
- assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2);
- assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for));
- mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t *)pns->nodes[1];
- @@ -2511,7 +2513,7 @@ STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns,
- EMIT_ARG(call_function, 1, 0, 0);
- }
-
- -STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
- // an empty tuple
- EMIT_ARG(build, 0, MP_EMIT_BUILD_TUPLE);
- @@ -2528,7 +2530,7 @@ STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- }
-
- -STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
- // empty list
- EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST);
- @@ -2549,7 +2551,7 @@ STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns)
- }
- }
-
- -STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map) {
- +static void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map) {
- mp_parse_node_t pn = pns->nodes[0];
- if (MP_PARSE_NODE_IS_NULL(pn)) {
- // empty dict
- @@ -2651,27 +2653,27 @@ STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *
- }
- }
-
- -STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_atom_brace_helper(comp, pns, true);
- }
-
- -STATIC void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
- compile_trailer_paren_helper(comp, pns->nodes[0], false, 0);
- }
-
- -STATIC void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // object who's index we want is on top of stack
- compile_node(comp, pns->nodes[0]); // the index
- EMIT_ARG(subscr, MP_EMIT_SUBSCR_LOAD);
- }
-
- -STATIC void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // object who's attribute we want is on top of stack
- EMIT_ARG(attr, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]), MP_EMIT_ATTR_LOAD); // attribute to get
- }
-
- #if MICROPY_PY_BUILTINS_SLICE
- -STATIC void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_2) {
- compile_node(comp, pns->nodes[0]); // start of slice
- assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be
- @@ -2726,19 +2728,19 @@ STATIC void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
- #endif // MICROPY_PY_BUILTINS_SLICE
-
- -STATIC void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) {
- // if this is called then we are compiling a dict key:value pair
- compile_node(comp, pns->nodes[1]); // value
- compile_node(comp, pns->nodes[0]); // key
- }
-
- -STATIC void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
- qstr cname = compile_classdef_helper(comp, pns, comp->scope_cur->emit_options);
- // store class object into class name
- compile_store_id(comp, cname);
- }
-
- -STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
- compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'yield' outside function"));
- return;
- @@ -2759,26 +2761,31 @@ STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
- }
-
- #if MICROPY_PY_ASYNC_AWAIT
- -STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) {
- if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
- - compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'await' outside function"));
- - return;
- + #if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
- + if (!mp_compile_allow_top_level_await)
- + #endif
- + {
- + compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'await' outside function"));
- + return;
- + }
- }
- compile_atom_expr_normal(comp, pns);
- compile_yield_from(comp);
- }
- #endif
-
- -STATIC mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
- +static mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
- return mp_parse_node_extract_const_object(pns);
- }
-
- -STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) {
- +static void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) {
- EMIT_ARG(load_const_obj, get_const_object(pns));
- }
-
- typedef void (*compile_function_t)(compiler_t *, mp_parse_node_struct_t *);
- -STATIC const compile_function_t compile_function[] = {
- +static const compile_function_t compile_function[] = {
- // only define rules with a compile function
- #define c(f) compile_##f
- #define DEF_RULE(rule, comp, kind, ...) comp,
- @@ -2790,7 +2797,7 @@ STATIC const compile_function_t compile_function[] = {
- compile_const_object,
- };
-
- -STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
- +static void compile_node(compiler_t *comp, mp_parse_node_t pn) {
- if (MP_PARSE_NODE_IS_NULL(pn)) {
- // pass
- } else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
- @@ -2826,7 +2833,7 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
- }
-
- #if MICROPY_EMIT_NATIVE
- -STATIC int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_annotation) {
- +static int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_annotation) {
- int native_type = MP_NATIVE_TYPE_OBJ;
- if (MP_PARSE_NODE_IS_NULL(pn_annotation)) {
- // No annotation, type defaults to object
- @@ -2844,7 +2851,7 @@ STATIC int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_an
- }
- #endif
-
- -STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) {
- +static void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_name, pn_kind_t pn_star, pn_kind_t pn_dbl_star) {
- (void)pn_dbl_star;
-
- // check that **kw is last
- @@ -2931,15 +2938,15 @@ STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn
- }
- }
-
- -STATIC void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) {
- +static void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) {
- compile_scope_func_lambda_param(comp, pn, PN_typedargslist_name, PN_typedargslist_star, PN_typedargslist_dbl_star);
- }
-
- -STATIC void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) {
- +static void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) {
- compile_scope_func_lambda_param(comp, pn, PN_varargslist_name, PN_varargslist_star, PN_varargslist_dbl_star);
- }
-
- -STATIC void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) {
- +static void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_struct_t *pns_comp_for, mp_parse_node_t pn_inner_expr, int for_depth) {
- uint l_top = comp_next_label(comp);
- uint l_end = comp_next_label(comp);
- EMIT_ARG(label_assign, l_top);
- @@ -2978,7 +2985,7 @@ tail_recursion:
- EMIT(for_iter_end);
- }
-
- -STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
- +static void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
- #if MICROPY_ENABLE_DOC_STRING
- // see http://www.python.org/dev/peps/pep-0257/
-
- @@ -3023,7 +3030,7 @@ STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
- #endif
- }
-
- -STATIC bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
- +static bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
- comp->pass = pass;
- comp->scope_cur = scope;
- comp->next_label = 0;
- @@ -3188,7 +3195,7 @@ STATIC bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
-
- #if MICROPY_EMIT_INLINE_ASM
- // requires 3 passes: SCOPE, CODE_SIZE, EMIT
- -STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
- +static void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
- comp->pass = pass;
- comp->scope_cur = scope;
- comp->next_label = 0;
- @@ -3363,7 +3370,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
- }
- #endif
-
- -STATIC void scope_compute_things(scope_t *scope) {
- +static void scope_compute_things(scope_t *scope) {
- // in MicroPython we put the *x parameter after all other parameters (except **y)
- if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) {
- id_info_t *id_param = NULL;
- @@ -3457,7 +3464,7 @@ STATIC void scope_compute_things(scope_t *scope) {
- }
-
- #if !MICROPY_PERSISTENT_CODE_SAVE
- -STATIC
- +static
- #endif
- void mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl, mp_compiled_module_t *cm) {
- // put compiler state on the stack, it's relatively small
- @@ -3625,7 +3632,7 @@ void mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, bool
- for (scope_t *s = comp->scope_head; s != NULL; s = s->next) {
- mp_raw_code_t *rc = s->raw_code;
- if (rc->kind == MP_CODE_BYTECODE) {
- - mp_bytecode_print(&mp_plat_print, rc, &cm->context->constants);
- + mp_bytecode_print(&mp_plat_print, rc, s->raw_code_data_len, &cm->context->constants);
- }
- }
- }
- @@ -3667,7 +3674,7 @@ mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl)
- cm.context->module.globals = mp_globals_get();
- mp_compile_to_raw_code(parse_tree, source_file, is_repl, &cm);
- // return function that executes the outer module
- - return mp_make_function_from_raw_code(cm.rc, cm.context, NULL);
- + return mp_make_function_from_proto_fun(cm.rc, cm.context, NULL);
- }
-
- #endif // MICROPY_ENABLE_COMPILER
- diff --git a/py/compile.h b/py/compile.h
- index 5e0fd8b31..f9970a521 100644
- --- a/py/compile.h
- +++ b/py/compile.h
- @@ -30,6 +30,11 @@
- #include "py/parse.h"
- #include "py/emitglue.h"
-
- +#if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
- +// set to `true` to allow top-level await expressions
- +extern bool mp_compile_allow_top_level_await;
- +#endif
- +
- // the compiler will raise an exception if an error occurred
- // the compiler will clear the parse tree before it returns
- // mp_globals_get() will be used for the context
- diff --git a/py/dynruntime.h b/py/dynruntime.h
- index de9c93c65..d07b1dce2 100644
- --- a/py/dynruntime.h
- +++ b/py/dynruntime.h
- @@ -29,6 +29,7 @@
- // This header file contains definitions to dynamically implement the static
- // MicroPython runtime API defined in py/obj.h and py/runtime.h.
-
- +#include "py/binary.h"
- #include "py/nativeglue.h"
- #include "py/objfun.h"
- #include "py/objstr.h"
- @@ -184,6 +185,10 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
- /******************************************************************************/
- // General runtime functions
-
- +#define mp_binary_get_size(struct_type, val_type, palign) (mp_fun_table.binary_get_size((struct_type), (val_type), (palign)))
- +#define mp_binary_get_val_array(typecode, p, index) (mp_fun_table.binary_get_val_array((typecode), (p), (index)))
- +#define mp_binary_set_val_array(typecode, p, index, val_in) (mp_fun_table.binary_set_val_array((typecode), (p), (index), (val_in)))
- +
- #define mp_load_name(qst) (mp_fun_table.load_name((qst)))
- #define mp_load_global(qst) (mp_fun_table.load_global((qst)))
- #define mp_load_attr(base, attr) (mp_fun_table.load_attr((base), (attr)))
- @@ -196,8 +201,8 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
- #define mp_unary_op(op, obj) (mp_fun_table.unary_op((op), (obj)))
- #define mp_binary_op(op, lhs, rhs) (mp_fun_table.binary_op((op), (lhs), (rhs)))
-
- -#define mp_make_function_from_raw_code(rc, context, def_args) \
- - (mp_fun_table.make_function_from_raw_code((rc), (context), (def_args)))
- +#define mp_make_function_from_proto_fun(rc, context, def_args) \
- + (mp_fun_table.make_function_from_proto_fun((rc), (context), (def_args)))
-
- #define mp_call_function_n_kw(fun, n_args, n_kw, args) \
- (mp_fun_table.call_function_n_kw((fun), (n_args) | ((n_kw) << 8), args))
- @@ -207,9 +212,11 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
-
- #define MP_DYNRUNTIME_INIT_ENTRY \
- mp_obj_t old_globals = mp_fun_table.swap_globals(self->context->module.globals); \
- - mp_raw_code_t rc; \
- + mp_raw_code_truncated_t rc; \
- + rc.proto_fun_indicator[0] = MP_PROTO_FUN_INDICATOR_RAW_CODE_0; \
- + rc.proto_fun_indicator[1] = MP_PROTO_FUN_INDICATOR_RAW_CODE_1; \
- rc.kind = MP_CODE_NATIVE_VIPER; \
- - rc.scope_flags = 0; \
- + rc.is_generator = 0; \
- (void)rc;
-
- #define MP_DYNRUNTIME_INIT_EXIT \
- @@ -217,7 +224,7 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
- return mp_const_none;
-
- #define MP_DYNRUNTIME_MAKE_FUNCTION(f) \
- - (mp_make_function_from_raw_code((rc.fun_data = (f), &rc), self->context, NULL))
- + (mp_make_function_from_proto_fun((rc.fun_data = (f), (const mp_raw_code_t *)&rc), self->context, NULL))
-
- #define mp_import_name(name, fromlist, level) \
- (mp_fun_table.import_name((name), (fromlist), (level)))
- diff --git a/py/emitbc.c b/py/emitbc.c
- index a07657408..05754cfab 100644
- --- a/py/emitbc.c
- +++ b/py/emitbc.c
- @@ -92,7 +92,7 @@ void emit_bc_free(emit_t *emit) {
- }
-
- // all functions must go through this one to emit code info
- -STATIC uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_to_write) {
- +static uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_to_write) {
- emit_t *emit = emit_in;
- if (emit->pass < MP_PASS_EMIT) {
- emit->code_info_offset += num_bytes_to_write;
- @@ -105,16 +105,16 @@ STATIC uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_
- }
- }
-
- -STATIC void emit_write_code_info_byte(emit_t *emit, byte val) {
- +static void emit_write_code_info_byte(emit_t *emit, byte val) {
- *emit_get_cur_to_write_code_info(emit, 1) = val;
- }
-
- -STATIC void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
- +static void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
- mp_encode_uint(emit, emit_get_cur_to_write_code_info, mp_emit_common_use_qstr(emit->emit_common, qst));
- }
-
- #if MICROPY_ENABLE_SOURCE_LINE
- -STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) {
- +static void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) {
- assert(bytes_to_skip > 0 || lines_to_skip > 0);
- while (bytes_to_skip > 0 || lines_to_skip > 0) {
- mp_uint_t b, l;
- @@ -143,7 +143,7 @@ STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_sk
- #endif
-
- // all functions must go through this one to emit byte code
- -STATIC uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_to_write) {
- +static uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_to_write) {
- emit_t *emit = emit_in;
- if (emit->suppress) {
- return emit->dummy_data;
- @@ -159,19 +159,19 @@ STATIC uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_t
- }
- }
-
- -STATIC void emit_write_bytecode_raw_byte(emit_t *emit, byte b1) {
- +static void emit_write_bytecode_raw_byte(emit_t *emit, byte b1) {
- byte *c = emit_get_cur_to_write_bytecode(emit, 1);
- c[0] = b1;
- }
-
- -STATIC void emit_write_bytecode_byte(emit_t *emit, int stack_adj, byte b1) {
- +static void emit_write_bytecode_byte(emit_t *emit, int stack_adj, byte b1) {
- mp_emit_bc_adjust_stack_size(emit, stack_adj);
- byte *c = emit_get_cur_to_write_bytecode(emit, 1);
- c[0] = b1;
- }
-
- // Similar to mp_encode_uint(), just some extra handling to encode sign
- -STATIC void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, mp_int_t num) {
- +static void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, mp_int_t num) {
- emit_write_bytecode_byte(emit, stack_adj, b1);
-
- // We store each 7 bits in a separate byte, and that's how many bytes needed
- @@ -197,24 +197,24 @@ STATIC void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, m
- *c = *p;
- }
-
- -STATIC void emit_write_bytecode_byte_uint(emit_t *emit, int stack_adj, byte b, mp_uint_t val) {
- +static void emit_write_bytecode_byte_uint(emit_t *emit, int stack_adj, byte b, mp_uint_t val) {
- emit_write_bytecode_byte(emit, stack_adj, b);
- mp_encode_uint(emit, emit_get_cur_to_write_bytecode, val);
- }
-
- -STATIC void emit_write_bytecode_byte_const(emit_t *emit, int stack_adj, byte b, mp_uint_t n) {
- +static void emit_write_bytecode_byte_const(emit_t *emit, int stack_adj, byte b, mp_uint_t n) {
- emit_write_bytecode_byte_uint(emit, stack_adj, b, n);
- }
-
- -STATIC void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, byte b, qstr qst) {
- +static void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, byte b, qstr qst) {
- emit_write_bytecode_byte_uint(emit, stack_adj, b, mp_emit_common_use_qstr(emit->emit_common, qst));
- }
-
- -STATIC void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, byte b, mp_obj_t obj) {
- +static void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, byte b, mp_obj_t obj) {
- emit_write_bytecode_byte_const(emit, stack_adj, b, mp_emit_common_use_const_obj(emit->emit_common, obj));
- }
-
- -STATIC void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b, mp_raw_code_t *rc) {
- +static void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b, mp_raw_code_t *rc) {
- emit_write_bytecode_byte_const(emit, stack_adj, b,
- mp_emit_common_alloc_const_child(emit->emit_common, rc));
- #if MICROPY_PY_SYS_SETTRACE
- @@ -227,7 +227,7 @@ STATIC void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b,
- // The offset is encoded as either 1 or 2 bytes, depending on how big it is.
- // The encoding of this jump opcode can change size from one pass to the next,
- // but it must only ever decrease in size on successive passes.
- -STATIC void emit_write_bytecode_byte_label(emit_t *emit, int stack_adj, byte b1, mp_uint_t label) {
- +static void emit_write_bytecode_byte_label(emit_t *emit, int stack_adj, byte b1, mp_uint_t label) {
- mp_emit_bc_adjust_stack_size(emit, stack_adj);
-
- if (emit->suppress) {
- @@ -393,13 +393,18 @@ bool mp_emit_bc_end_pass(emit_t *emit) {
- mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("bytecode overflow"));
- }
-
- + #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- + size_t bytecode_len = emit->code_info_size + emit->bytecode_size;
- + #if MICROPY_DEBUG_PRINTERS
- + emit->scope->raw_code_data_len = bytecode_len;
- + #endif
- + #endif
- +
- // Bytecode is finalised, assign it to the raw code object.
- mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base,
- - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- - emit->code_info_size + emit->bytecode_size,
- - #endif
- emit->emit_common->children,
- #if MICROPY_PERSISTENT_CODE_SAVE
- + bytecode_len,
- emit->emit_common->ct_cur_child,
- #endif
- emit->scope->scope_flags);
- @@ -443,7 +448,6 @@ void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) {
- // should be emitted (until another unconditional flow control).
- emit->suppress = false;
-
- - mp_emit_bc_adjust_stack_size(emit, 0);
- if (emit->pass == MP_PASS_SCOPE) {
- return;
- }
- @@ -764,7 +768,7 @@ void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_ov
- }
- }
-
- -STATIC void emit_bc_call_function_method_helper(emit_t *emit, int stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
- +static void emit_bc_call_function_method_helper(emit_t *emit, int stack_adj, mp_uint_t bytecode_base, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
- if (star_flags) {
- // each positional arg is one object, each kwarg is two objects, the key
- // and the value and one extra object for the star args bitmap.
- diff --git a/py/emitglue.c b/py/emitglue.c
- index 6ec6d6b88..6b6d5ccba 100644
- --- a/py/emitglue.c
- +++ b/py/emitglue.c
- @@ -61,24 +61,20 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
- }
-
- void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
- - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- - size_t len,
- - #endif
- mp_raw_code_t **children,
- #if MICROPY_PERSISTENT_CODE_SAVE
- - size_t n_children,
- + size_t len,
- + uint16_t n_children,
- #endif
- - mp_uint_t scope_flags) {
- + uint16_t scope_flags) {
-
- rc->kind = MP_CODE_BYTECODE;
- - rc->scope_flags = scope_flags;
- + rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
- rc->fun_data = code;
- - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- - rc->fun_data_len = len;
- - #endif
- rc->children = children;
-
- #if MICROPY_PERSISTENT_CODE_SAVE
- + rc->fun_data_len = len;
- rc->n_children = n_children;
- #endif
-
- @@ -88,7 +84,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
- #endif
-
- #if DEBUG_PRINT
- - #if !(MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS)
- + #if !MICROPY_PERSISTENT_CODE_SAVE
- const size_t len = 0;
- #endif
- DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags);
- @@ -96,13 +92,14 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
- }
-
- #if MICROPY_EMIT_MACHINE_CODE
- -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len,
- +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, const void *fun_data, mp_uint_t fun_len,
- mp_raw_code_t **children,
- #if MICROPY_PERSISTENT_CODE_SAVE
- - size_t n_children,
- + uint16_t n_children,
- uint16_t prelude_offset,
- #endif
- - mp_uint_t scope_flags, mp_uint_t n_pos_args, mp_uint_t type_sig) {
- + uint16_t scope_flags, uint32_t asm_n_pos_args, uint32_t asm_type_sig
- + ) {
-
- assert(kind == MP_CODE_NATIVE_PY || kind == MP_CODE_NATIVE_VIPER || kind == MP_CODE_NATIVE_ASM);
-
- @@ -118,7 +115,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
- #endif
- #elif MICROPY_EMIT_ARM
- #if (defined(__linux__) && defined(__GNUC__)) || __ARM_ARCH == 7
- - __builtin___clear_cache(fun_data, (uint8_t *)fun_data + fun_len);
- + __builtin___clear_cache((void *)fun_data, (uint8_t *)fun_data + fun_len);
- #elif defined(__arm__)
- // Flush I-cache and D-cache.
- asm volatile (
- @@ -132,10 +129,10 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
- #endif
-
- rc->kind = kind;
- - rc->scope_flags = scope_flags;
- + rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
- rc->fun_data = fun_data;
-
- - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- + #if MICROPY_PERSISTENT_CODE_SAVE
- rc->fun_data_len = fun_len;
- #endif
- rc->children = children;
- @@ -145,17 +142,19 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
- rc->prelude_offset = prelude_offset;
- #endif
-
- + #if MICROPY_EMIT_INLINE_ASM
- // These two entries are only needed for MP_CODE_NATIVE_ASM.
- - rc->n_pos_args = n_pos_args;
- - rc->type_sig = type_sig;
- + rc->asm_n_pos_args = asm_n_pos_args;
- + rc->asm_type_sig = asm_type_sig;
- + #endif
-
- #if DEBUG_PRINT
- - DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " n_pos_args=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, n_pos_args, (uint)scope_flags);
- + DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, (uint)scope_flags);
- for (mp_uint_t i = 0; i < fun_len; i++) {
- if (i > 0 && i % 16 == 0) {
- DEBUG_printf("\n");
- }
- - DEBUG_printf(" %02x", ((byte *)fun_data)[i]);
- + DEBUG_printf(" %02x", ((const byte *)fun_data)[i]);
- }
- DEBUG_printf("\n");
-
- @@ -170,9 +169,9 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
- }
- #endif
-
- -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, const mp_obj_t *def_args) {
- - DEBUG_OP_printf("make_function_from_raw_code %p\n", rc);
- - assert(rc != NULL);
- +mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, const mp_obj_t *def_args) {
- + DEBUG_OP_printf("make_function_from_proto_fun %p\n", proto_fun);
- + assert(proto_fun != NULL);
-
- // def_args must be MP_OBJ_NULL or a tuple
- assert(def_args == NULL || def_args[0] == MP_OBJ_NULL || mp_obj_is_type(def_args[0], &mp_type_tuple));
- @@ -180,22 +179,39 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
- // def_kw_args must be MP_OBJ_NULL or a dict
- assert(def_args == NULL || def_args[1] == MP_OBJ_NULL || mp_obj_is_type(def_args[1], &mp_type_dict));
-
- + #if MICROPY_MODULE_FROZEN_MPY
- + if (mp_proto_fun_is_bytecode(proto_fun)) {
- + const uint8_t *bc = proto_fun;
- + mp_obj_t fun = mp_obj_new_fun_bc(def_args, bc, context, NULL);
- + MP_BC_PRELUDE_SIG_DECODE(bc);
- + if (scope_flags & MP_SCOPE_FLAG_GENERATOR) {
- + ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
- + }
- + return fun;
- + }
- + #endif
- +
- + // the proto-function is a mp_raw_code_t
- + const mp_raw_code_t *rc = proto_fun;
- +
- // make the function, depending on the raw code kind
- mp_obj_t fun;
- switch (rc->kind) {
- #if MICROPY_EMIT_NATIVE
- case MP_CODE_NATIVE_PY:
- - case MP_CODE_NATIVE_VIPER:
- fun = mp_obj_new_fun_native(def_args, rc->fun_data, context, rc->children);
- // Check for a generator function, and if so change the type of the object
- - if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
- + if (rc->is_generator) {
- ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_gen_wrap;
- }
- break;
- + case MP_CODE_NATIVE_VIPER:
- + fun = mp_obj_new_fun_viper(rc->fun_data, context, rc->children);
- + break;
- #endif
- #if MICROPY_EMIT_INLINE_ASM
- case MP_CODE_NATIVE_ASM:
- - fun = mp_obj_new_fun_asm(rc->n_pos_args, rc->fun_data, rc->type_sig);
- + fun = mp_obj_new_fun_asm(rc->asm_n_pos_args, rc->fun_data, rc->asm_type_sig);
- break;
- #endif
- default:
- @@ -203,7 +219,7 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
- assert(rc->kind == MP_CODE_BYTECODE);
- fun = mp_obj_new_fun_bc(def_args, rc->fun_data, context, rc->children);
- // check for generator functions and if so change the type of the object
- - if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
- + if (rc->is_generator) {
- ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
- }
-
- @@ -218,16 +234,16 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
- return fun;
- }
-
- -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args) {
- - DEBUG_OP_printf("make_closure_from_raw_code %p " UINT_FMT " %p\n", rc, n_closed_over, args);
- +mp_obj_t mp_make_closure_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args) {
- + DEBUG_OP_printf("make_closure_from_proto_fun %p " UINT_FMT " %p\n", proto_fun, n_closed_over, args);
- // make function object
- mp_obj_t ffun;
- if (n_closed_over & 0x100) {
- // default positional and keyword args given
- - ffun = mp_make_function_from_raw_code(rc, context, args);
- + ffun = mp_make_function_from_proto_fun(proto_fun, context, args);
- } else {
- // default positional and keyword args not given
- - ffun = mp_make_function_from_raw_code(rc, context, NULL);
- + ffun = mp_make_function_from_proto_fun(proto_fun, context, NULL);
- }
- // wrap function in closure object
- return mp_obj_new_closure(ffun, n_closed_over & 0xff, args + ((n_closed_over >> 7) & 2));
- diff --git a/py/emitglue.h b/py/emitglue.h
- index 4ddf74011..126462671 100644
- --- a/py/emitglue.h
- +++ b/py/emitglue.h
- @@ -31,6 +31,11 @@
-
- // These variables and functions glue the code emitters to the runtime.
-
- +// Used with mp_raw_code_t::proto_fun_indicator to detect if a mp_proto_fun_t is a
- +// mp_raw_code_t struct or a direct pointer to bytecode.
- +#define MP_PROTO_FUN_INDICATOR_RAW_CODE_0 (0)
- +#define MP_PROTO_FUN_INDICATOR_RAW_CODE_1 (0)
- +
- // These must fit in 8 bits; see scope.h
- enum {
- MP_EMIT_OPT_NONE,
- @@ -49,58 +54,91 @@ typedef enum {
- MP_CODE_NATIVE_ASM,
- } mp_raw_code_kind_t;
-
- +// An mp_proto_fun_t points to static information about a non-instantiated function.
- +// A function object is created from this information, and that object can then be executed.
- +// It points either to bytecode, or an mp_raw_code_t struct.
- +typedef const void *mp_proto_fun_t;
- +
- +// Bytecode is distinguished from an mp_raw_code_t struct by the first two bytes: bytecode
- +// is guaranteed to have either its first or second byte non-zero. So if both bytes are
- +// zero then the mp_proto_fun_t pointer must be an mp_raw_code_t.
- +static inline bool mp_proto_fun_is_bytecode(mp_proto_fun_t proto_fun) {
- + const uint8_t *header = (const uint8_t *)proto_fun;
- + return (header[0] | (header[1] << 8)) != (MP_PROTO_FUN_INDICATOR_RAW_CODE_0 | (MP_PROTO_FUN_INDICATOR_RAW_CODE_1 << 8));
- +}
- +
- +// The mp_raw_code_t struct appears in the following places:
- // compiled bytecode: instance in RAM, referenced by outer scope, usually freed after first (and only) use
- // mpy file: instance in RAM, created when .mpy file is loaded (same comments as above)
- // frozen: instance in ROM
- typedef struct _mp_raw_code_t {
- - mp_uint_t kind : 3; // of type mp_raw_code_kind_t
- - mp_uint_t scope_flags : 7;
- - mp_uint_t n_pos_args : 11;
- + uint8_t proto_fun_indicator[2];
- + uint8_t kind; // of type mp_raw_code_kind_t; only 3 bits used
- + bool is_generator;
- const void *fun_data;
- - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- - size_t fun_data_len; // so mp_raw_code_save and mp_bytecode_print work
- - #endif
- struct _mp_raw_code_t **children;
- #if MICROPY_PERSISTENT_CODE_SAVE
- - size_t n_children;
- + uint32_t fun_data_len; // for mp_raw_code_save
- + uint16_t n_children;
- + #if MICROPY_EMIT_MACHINE_CODE
- + uint16_t prelude_offset;
- + #endif
- #if MICROPY_PY_SYS_SETTRACE
- - mp_bytecode_prelude_t prelude;
- // line_of_definition is a Python source line where the raw_code was
- // created e.g. MP_BC_MAKE_FUNCTION. This is different from lineno info
- // stored in prelude, which provides line number for first statement of
- // a function. Required to properly implement "call" trace event.
- - mp_uint_t line_of_definition;
- + uint32_t line_of_definition;
- + mp_bytecode_prelude_t prelude;
- #endif
- + #endif
- + #if MICROPY_EMIT_INLINE_ASM
- + uint32_t asm_n_pos_args : 8;
- + uint32_t asm_type_sig : 24; // compressed as 2-bit types; ret is MSB, then arg0, arg1, etc
- + #endif
- +} mp_raw_code_t;
- +
- +// Version of mp_raw_code_t but without the asm_n_pos_args/asm_type_sig entries, which are
- +// only needed when the kind is MP_CODE_NATIVE_ASM. So this struct can be used when the
- +// kind is MP_CODE_BYTECODE, MP_CODE_NATIVE_PY or MP_CODE_NATIVE_VIPER, to reduce its size.
- +typedef struct _mp_raw_code_truncated_t {
- + uint8_t proto_fun_indicator[2];
- + uint8_t kind;
- + bool is_generator;
- + const void *fun_data;
- + struct _mp_raw_code_t **children;
- + #if MICROPY_PERSISTENT_CODE_SAVE
- + uint32_t fun_data_len;
- + uint16_t n_children;
- #if MICROPY_EMIT_MACHINE_CODE
- uint16_t prelude_offset;
- #endif
- + #if MICROPY_PY_SYS_SETTRACE
- + uint32_t line_of_definition;
- + mp_bytecode_prelude_t prelude;
- #endif
- - #if MICROPY_EMIT_MACHINE_CODE
- - mp_uint_t type_sig; // for viper, compressed as 2-bit types; ret is MSB, then arg0, arg1, etc
- #endif
- -} mp_raw_code_t;
- +} mp_raw_code_truncated_t;
-
- mp_raw_code_t *mp_emit_glue_new_raw_code(void);
-
- void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
- - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- - size_t len,
- - #endif
- mp_raw_code_t **children,
- #if MICROPY_PERSISTENT_CODE_SAVE
- - size_t n_children,
- + size_t len,
- + uint16_t n_children,
- #endif
- - mp_uint_t scope_flags);
- + uint16_t scope_flags);
-
- -void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len,
- +void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, const void *fun_data, mp_uint_t fun_len,
- mp_raw_code_t **children,
- #if MICROPY_PERSISTENT_CODE_SAVE
- - size_t n_children,
- + uint16_t n_children,
- uint16_t prelude_offset,
- #endif
- - mp_uint_t scope_flags, mp_uint_t n_pos_args, mp_uint_t type_sig);
- + uint16_t scope_flags, uint32_t asm_n_pos_args, uint32_t asm_type_sig);
-
- -mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, const mp_obj_t *def_args);
- -mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args);
- +mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, const mp_obj_t *def_args);
- +mp_obj_t mp_make_closure_from_proto_fun(mp_proto_fun_t proto_fun, const mp_module_context_t *context, mp_uint_t n_closed_over, const mp_obj_t *args);
-
- #endif // MICROPY_INCLUDED_PY_EMITGLUE_H
- diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
- index 29487f104..7818bb4f4 100644
- --- a/py/emitinlinethumb.c
- +++ b/py/emitinlinethumb.c
- @@ -74,11 +74,11 @@ static inline bool emit_inline_thumb_allow_float(emit_inline_asm_t *emit) {
-
- #endif
-
- -STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
- +static void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
- *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
- }
-
- -STATIC void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
- +static void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
- *emit->error_slot = exc;
- }
-
- @@ -97,7 +97,7 @@ void emit_inline_thumb_free(emit_inline_asm_t *emit) {
- m_del_obj(emit_inline_asm_t, emit);
- }
-
- -STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
- +static void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
- emit->pass = pass;
- emit->error_slot = error_slot;
- if (emit->pass == MP_PASS_CODE_SIZE) {
- @@ -107,12 +107,12 @@ STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pa
- asm_thumb_entry(&emit->as, 0);
- }
-
- -STATIC void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
- +static void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
- asm_thumb_exit(&emit->as);
- asm_thumb_end_pass(&emit->as);
- }
-
- -STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
- +static mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
- if (n_params > 4) {
- emit_inline_thumb_error_msg(emit, MP_ERROR_TEXT("can only have up to 4 parameters to Thumb assembly"));
- return 0;
- @@ -131,7 +131,7 @@ STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint
- return n_params;
- }
-
- -STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
- +static bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
- assert(label_num < emit->max_num_labels);
- if (emit->pass == MP_PASS_CODE_SIZE) {
- // check for duplicate label on first pass
- @@ -149,7 +149,7 @@ STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num
- typedef struct _reg_name_t { byte reg;
- byte name[3];
- } reg_name_t;
- -STATIC const reg_name_t reg_name_table[] = {
- +static const reg_name_t reg_name_table[] = {
- {0, "r0\0"},
- {1, "r1\0"},
- {2, "r2\0"},
- @@ -177,14 +177,14 @@ STATIC const reg_name_t reg_name_table[] = {
- typedef struct _special_reg_name_t { byte reg;
- char name[MAX_SPECIAL_REGISTER_NAME_LENGTH + 1];
- } special_reg_name_t;
- -STATIC const special_reg_name_t special_reg_name_table[] = {
- +static const special_reg_name_t special_reg_name_table[] = {
- {5, "IPSR"},
- {17, "BASEPRI"},
- };
-
- // return empty string in case of error, so we can attempt to parse the string
- // without a special check if it was in fact a string
- -STATIC const char *get_arg_str(mp_parse_node_t pn) {
- +static const char *get_arg_str(mp_parse_node_t pn) {
- if (MP_PARSE_NODE_IS_ID(pn)) {
- qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
- return qstr_str(qst);
- @@ -193,7 +193,7 @@ STATIC const char *get_arg_str(mp_parse_node_t pn) {
- }
- }
-
- -STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_uint_t max_reg) {
- +static mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_uint_t max_reg) {
- const char *reg_str = get_arg_str(pn);
- for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
- const reg_name_t *r = ®_name_table[i];
- @@ -217,7 +217,7 @@ STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_n
- return 0;
- }
-
- -STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- +static mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- const char *reg_str = get_arg_str(pn);
- for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(special_reg_name_table); i++) {
- const special_reg_name_t *r = &special_reg_name_table[i];
- @@ -231,7 +231,7 @@ STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp
- return 0;
- }
-
- -STATIC mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- +static mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- const char *reg_str = get_arg_str(pn);
- if (reg_str[0] == 's' && reg_str[1] != '\0') {
- mp_uint_t regno = 0;
- @@ -258,7 +258,7 @@ malformed:
- return 0;
- }
-
- -STATIC mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- +static mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- // a register list looks like {r0, r1, r2} and is parsed as a Python set
-
- if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_brace)) {
- @@ -310,7 +310,7 @@ bad_arg:
- return 0;
- }
-
- -STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) {
- +static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) {
- mp_obj_t o;
- if (!mp_parse_node_get_int_maybe(pn, &o)) {
- emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects an integer"), op));
- @@ -324,7 +324,7 @@ STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
- return i;
- }
-
- -STATIC bool get_arg_addr(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_parse_node_t *pn_base, mp_parse_node_t *pn_offset) {
- +static bool get_arg_addr(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, mp_parse_node_t *pn_base, mp_parse_node_t *pn_offset) {
- if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_bracket)) {
- goto bad_arg;
- }
- @@ -346,7 +346,7 @@ bad_arg:
- return false;
- }
-
- -STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- +static int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- if (!MP_PARSE_NODE_IS_ID(pn)) {
- emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects a label"), op));
- return 0;
- @@ -367,7 +367,7 @@ STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_
- typedef struct _cc_name_t { byte cc;
- byte name[2];
- } cc_name_t;
- -STATIC const cc_name_t cc_name_table[] = {
- +static const cc_name_t cc_name_table[] = {
- { ASM_THUMB_CC_EQ, "eq" },
- { ASM_THUMB_CC_NE, "ne" },
- { ASM_THUMB_CC_CS, "cs" },
- @@ -388,7 +388,7 @@ typedef struct _format_4_op_t { byte op;
- char name[3];
- } format_4_op_t;
- #define X(x) (((x) >> 4) & 0xff) // only need 1 byte to distinguish these ops
- -STATIC const format_4_op_t format_4_op_table[] = {
- +static const format_4_op_t format_4_op_table[] = {
- { X(ASM_THUMB_FORMAT_4_EOR), "eor" },
- { X(ASM_THUMB_FORMAT_4_LSL), "lsl" },
- { X(ASM_THUMB_FORMAT_4_LSR), "lsr" },
- @@ -412,7 +412,7 @@ typedef struct _format_9_10_op_t { uint16_t op;
- uint16_t name;
- } format_9_10_op_t;
- #define X(x) (x)
- -STATIC const format_9_10_op_t format_9_10_op_table[] = {
- +static const format_9_10_op_t format_9_10_op_table[] = {
- { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_ldr },
- { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER), MP_QSTR_ldrb },
- { X(ASM_THUMB_FORMAT_10_LDRH), MP_QSTR_ldrh },
- @@ -427,7 +427,7 @@ typedef struct _format_vfp_op_t {
- byte op;
- char name[3];
- } format_vfp_op_t;
- -STATIC const format_vfp_op_t format_vfp_op_table[] = {
- +static const format_vfp_op_t format_vfp_op_table[] = {
- { 0x30, "add" },
- { 0x34, "sub" },
- { 0x20, "mul" },
- @@ -437,7 +437,7 @@ STATIC const format_vfp_op_t format_vfp_op_table[] = {
- // shorthand alias for whether we allow ARMv7-M instructions
- #define ARMV7M asm_thumb_allow_armv7m(&emit->as)
-
- -STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
- +static void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
- // TODO perhaps make two tables:
- // one_args =
- // "b", LAB, asm_thumb_b_n,
- diff --git a/py/emitinlinextensa.c b/py/emitinlinextensa.c
- index 5dac2ae39..57056d597 100644
- --- a/py/emitinlinextensa.c
- +++ b/py/emitinlinextensa.c
- @@ -43,11 +43,11 @@ struct _emit_inline_asm_t {
- qstr *label_lookup;
- };
-
- -STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
- +static void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
- *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
- }
-
- -STATIC void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
- +static void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
- *emit->error_slot = exc;
- }
-
- @@ -66,7 +66,7 @@ void emit_inline_xtensa_free(emit_inline_asm_t *emit) {
- m_del_obj(emit_inline_asm_t, emit);
- }
-
- -STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
- +static void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
- emit->pass = pass;
- emit->error_slot = error_slot;
- if (emit->pass == MP_PASS_CODE_SIZE) {
- @@ -76,12 +76,12 @@ STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t p
- asm_xtensa_entry(&emit->as, 0);
- }
-
- -STATIC void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
- +static void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
- asm_xtensa_exit(&emit->as);
- asm_xtensa_end_pass(&emit->as);
- }
-
- -STATIC mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
- +static mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params) {
- if (n_params > 4) {
- emit_inline_xtensa_error_msg(emit, MP_ERROR_TEXT("can only have up to 4 parameters to Xtensa assembly"));
- return 0;
- @@ -100,7 +100,7 @@ STATIC mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uin
- return n_params;
- }
-
- -STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
- +static bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
- assert(label_num < emit->max_num_labels);
- if (emit->pass == MP_PASS_CODE_SIZE) {
- // check for duplicate label on first pass
- @@ -118,7 +118,7 @@ STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_nu
- typedef struct _reg_name_t { byte reg;
- byte name[3];
- } reg_name_t;
- -STATIC const reg_name_t reg_name_table[] = {
- +static const reg_name_t reg_name_table[] = {
- {0, "a0\0"},
- {1, "a1\0"},
- {2, "a2\0"},
- @@ -139,7 +139,7 @@ STATIC const reg_name_t reg_name_table[] = {
-
- // return empty string in case of error, so we can attempt to parse the string
- // without a special check if it was in fact a string
- -STATIC const char *get_arg_str(mp_parse_node_t pn) {
- +static const char *get_arg_str(mp_parse_node_t pn) {
- if (MP_PARSE_NODE_IS_ID(pn)) {
- qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
- return qstr_str(qst);
- @@ -148,7 +148,7 @@ STATIC const char *get_arg_str(mp_parse_node_t pn) {
- }
- }
-
- -STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- +static mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- const char *reg_str = get_arg_str(pn);
- for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
- const reg_name_t *r = ®_name_table[i];
- @@ -165,7 +165,7 @@ STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_n
- return 0;
- }
-
- -STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) {
- +static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) {
- mp_obj_t o;
- if (!mp_parse_node_get_int_maybe(pn, &o)) {
- emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects an integer"), op));
- @@ -179,7 +179,7 @@ STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
- return i;
- }
-
- -STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- +static int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
- if (!MP_PARSE_NODE_IS_ID(pn)) {
- emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects a label"), op));
- return 0;
- @@ -208,7 +208,7 @@ typedef struct _opcode_table_3arg_t {
- uint8_t a1 : 4;
- } opcode_table_3arg_t;
-
- -STATIC const opcode_table_3arg_t opcode_table_3arg[] = {
- +static const opcode_table_3arg_t opcode_table_3arg[] = {
- // arithmetic opcodes: reg, reg, reg
- {MP_QSTR_and_, RRR, 0, 1},
- {MP_QSTR_or_, RRR, 0, 2},
- @@ -242,7 +242,7 @@ STATIC const opcode_table_3arg_t opcode_table_3arg[] = {
- {MP_QSTR_bnone, RRI8_B, ASM_XTENSA_CC_NONE, 0},
- };
-
- -STATIC void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
- +static void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
- size_t op_len;
- const char *op_str = (const char *)qstr_data(op, &op_len);
-
- diff --git a/py/emitnative.c b/py/emitnative.c
- index e6357b3f9..0b84a2ec8 100644
- --- a/py/emitnative.c
- +++ b/py/emitnative.c
- @@ -156,7 +156,7 @@
- #define REG_QSTR_TABLE (REG_LOCAL_3)
- #define MAX_REGS_FOR_LOCAL_VARS (2)
-
- -STATIC const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2};
- +static const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2};
-
- #else
-
- @@ -168,7 +168,7 @@ STATIC const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, RE
- #define REG_GENERATOR_STATE (REG_LOCAL_3)
- #define MAX_REGS_FOR_LOCAL_VARS (3)
-
- -STATIC const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2, REG_LOCAL_3};
- +static const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2, REG_LOCAL_3};
-
- #endif
-
- @@ -202,7 +202,7 @@ typedef enum {
- VTYPE_BUILTIN_CAST = 0x70 | MP_NATIVE_TYPE_OBJ,
- } vtype_kind_t;
-
- -STATIC qstr vtype_to_qstr(vtype_kind_t vtype) {
- +static qstr vtype_to_qstr(vtype_kind_t vtype) {
- switch (vtype) {
- case VTYPE_PYOBJ:
- return MP_QSTR_object;
- @@ -253,7 +253,6 @@ struct _emit_t {
- int pass;
-
- bool do_viper_types;
- - bool prelude_offset_uses_u16_encoding;
-
- mp_uint_t local_vtype_alloc;
- vtype_kind_t *local_vtype;
- @@ -281,10 +280,10 @@ struct _emit_t {
- ASM_T *as;
- };
-
- -STATIC void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj);
- -STATIC void emit_native_global_exc_entry(emit_t *emit);
- -STATIC void emit_native_global_exc_exit(emit_t *emit);
- -STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj);
- +static void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj);
- +static void emit_native_global_exc_entry(emit_t *emit);
- +static void emit_native_global_exc_exit(emit_t *emit);
- +static void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj);
-
- emit_t *EXPORT_FUN(new)(mp_emit_common_t * emit_common, mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels) {
- emit_t *emit = m_new0(emit_t, 1);
- @@ -309,13 +308,13 @@ void EXPORT_FUN(free)(emit_t * emit) {
- m_del_obj(emit_t, emit);
- }
-
- -STATIC void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg);
- +static void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg);
-
- -STATIC void emit_native_mov_reg_const(emit_t *emit, int reg_dest, int const_val) {
- +static void emit_native_mov_reg_const(emit_t *emit, int reg_dest, int const_val) {
- ASM_LOAD_REG_REG_OFFSET(emit->as, reg_dest, REG_FUN_TABLE, const_val);
- }
-
- -STATIC void emit_native_mov_state_reg(emit_t *emit, int local_num, int reg_src) {
- +static void emit_native_mov_state_reg(emit_t *emit, int local_num, int reg_src) {
- if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
- ASM_STORE_REG_REG_OFFSET(emit->as, reg_src, REG_GENERATOR_STATE, local_num);
- } else {
- @@ -323,7 +322,7 @@ STATIC void emit_native_mov_state_reg(emit_t *emit, int local_num, int reg_src)
- }
- }
-
- -STATIC void emit_native_mov_reg_state(emit_t *emit, int reg_dest, int local_num) {
- +static void emit_native_mov_reg_state(emit_t *emit, int reg_dest, int local_num) {
- if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
- ASM_LOAD_REG_REG_OFFSET(emit->as, reg_dest, REG_GENERATOR_STATE, local_num);
- } else {
- @@ -331,7 +330,7 @@ STATIC void emit_native_mov_reg_state(emit_t *emit, int reg_dest, int local_num)
- }
- }
-
- -STATIC void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, int local_num) {
- +static void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, int local_num) {
- if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
- ASM_MOV_REG_IMM(emit->as, reg_dest, local_num * ASM_WORD_SIZE);
- ASM_ADD_REG_REG(emit->as, reg_dest, REG_GENERATOR_STATE);
- @@ -340,7 +339,7 @@ STATIC void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, int local
- }
- }
-
- -STATIC void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
- +static void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
- #if MICROPY_PERSISTENT_CODE_SAVE
- ASM_LOAD16_REG_REG_OFFSET(emit->as, arg_reg, REG_QSTR_TABLE, mp_emit_common_use_qstr(emit->emit_common, qst));
- #else
- @@ -348,7 +347,7 @@ STATIC void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
- #endif
- }
-
- -STATIC void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qstr qst) {
- +static void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qstr qst) {
- #if MICROPY_PERSISTENT_CODE_SAVE
- emit_load_reg_with_object(emit, reg_dest, MP_OBJ_NEW_QSTR(qst));
- #else
- @@ -362,7 +361,7 @@ STATIC void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qstr qst) {
- emit_native_mov_state_reg((emit), (local_num), (reg_temp)); \
- } while (false)
-
- -STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
- +static void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
- DEBUG_printf("start_pass(pass=%u, scope=%p)\n", pass, scope);
-
- emit->pass = pass;
- @@ -519,8 +518,11 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
- // work out size of state (locals plus stack)
- emit->n_state = scope->num_locals + scope->stack_size;
-
- + // Store in the first machine-word an index used to the function's prelude.
- + // This is used at runtime by mp_obj_fun_native_get_prelude_ptr().
- + mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (uintptr_t)emit->prelude_ptr_index);
- +
- if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
- - mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (uintptr_t)emit->prelude_ptr_index);
- mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (uintptr_t)emit->start_offset);
- ASM_ENTRY(emit->as, emit->code_state_start);
-
- @@ -576,15 +578,6 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
- // Set code_state.fun_bc
- ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_FUN_OBJ(emit), REG_PARENT_ARG_1);
-
- - // Set code_state.ip, a pointer to the beginning of the prelude. This pointer is found
- - // either directly in mp_obj_fun_bc_t.child_table (if there are no children), or in
- - // mp_obj_fun_bc_t.child_table[num_children] (if num_children > 0).
- - ASM_LOAD_REG_REG_OFFSET(emit->as, REG_PARENT_ARG_1, REG_PARENT_ARG_1, OFFSETOF_OBJ_FUN_BC_CHILD_TABLE);
- - if (emit->prelude_ptr_index != 0) {
- - ASM_LOAD_REG_REG_OFFSET(emit->as, REG_PARENT_ARG_1, REG_PARENT_ARG_1, emit->prelude_ptr_index);
- - }
- - emit_native_mov_state_reg(emit, emit->code_state_start + OFFSETOF_CODE_STATE_IP, REG_PARENT_ARG_1);
- -
- // Set code_state.n_state (only works on little endian targets due to n_state being uint16_t)
- emit_native_mov_state_imm_via(emit, emit->code_state_start + OFFSETOF_CODE_STATE_N_STATE, emit->n_state, REG_ARG_1);
-
- @@ -639,7 +632,7 @@ static inline void emit_native_write_code_info_qstr(emit_t *emit, qstr qst) {
- mp_encode_uint(&emit->as->base, mp_asm_base_get_cur_to_write_bytes, mp_emit_common_use_qstr(emit->emit_common, qst));
- }
-
- -STATIC bool emit_native_end_pass(emit_t *emit) {
- +static bool emit_native_end_pass(emit_t *emit) {
- emit_native_global_exc_exit(emit);
-
- if (!emit->do_viper_types) {
- @@ -730,7 +723,7 @@ STATIC bool emit_native_end_pass(emit_t *emit) {
- return true;
- }
-
- -STATIC void ensure_extra_stack(emit_t *emit, size_t delta) {
- +static void ensure_extra_stack(emit_t *emit, size_t delta) {
- if (emit->stack_size + delta > emit->stack_info_alloc) {
- size_t new_alloc = (emit->stack_size + delta + 8) & ~3;
- emit->stack_info = m_renew(stack_info_t, emit->stack_info, emit->stack_info_alloc, new_alloc);
- @@ -738,7 +731,7 @@ STATIC void ensure_extra_stack(emit_t *emit, size_t delta) {
- }
- }
-
- -STATIC void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) {
- +static void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) {
- assert((mp_int_t)emit->stack_size + stack_size_delta >= 0);
- assert((mp_int_t)emit->stack_size + stack_size_delta <= (mp_int_t)emit->stack_info_alloc);
- emit->stack_size += stack_size_delta;
- @@ -755,7 +748,7 @@ STATIC void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) {
- #endif
- }
-
- -STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
- +static void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
- DEBUG_printf("adjust_stack_size(" INT_FMT ")\n", delta);
- if (delta > 0) {
- ensure_extra_stack(emit, delta);
- @@ -779,23 +772,23 @@ STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
- adjust_stack(emit, delta);
- }
-
- -STATIC void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) {
- +static void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) {
- (void)emit;
- (void)source_line;
- }
-
- // this must be called at start of emit functions
- -STATIC void emit_native_pre(emit_t *emit) {
- +static void emit_native_pre(emit_t *emit) {
- (void)emit;
- }
-
- // depth==0 is top, depth==1 is before top, etc
- -STATIC stack_info_t *peek_stack(emit_t *emit, mp_uint_t depth) {
- +static stack_info_t *peek_stack(emit_t *emit, mp_uint_t depth) {
- return &emit->stack_info[emit->stack_size - 1 - depth];
- }
-
- // depth==0 is top, depth==1 is before top, etc
- -STATIC vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) {
- +static vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) {
- if (emit->do_viper_types) {
- return peek_stack(emit, depth)->vtype;
- } else {
- @@ -806,7 +799,7 @@ STATIC vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) {
-
- // pos=1 is TOS, pos=2 is next, etc
- // use pos=0 for no skipping
- -STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) {
- +static void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) {
- skip_stack_pos = emit->stack_size - skip_stack_pos;
- for (int i = 0; i < emit->stack_size; i++) {
- if (i != skip_stack_pos) {
- @@ -821,7 +814,7 @@ STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) {
-
- // Ensures all unsettled registers that hold Python values are copied to the
- // concrete Python stack. All registers are then free to use.
- -STATIC void need_reg_all(emit_t *emit) {
- +static void need_reg_all(emit_t *emit) {
- for (int i = 0; i < emit->stack_size; i++) {
- stack_info_t *si = &emit->stack_info[i];
- if (si->kind == STACK_REG) {
- @@ -832,7 +825,7 @@ STATIC void need_reg_all(emit_t *emit) {
- }
- }
-
- -STATIC vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_info_t *si, bool convert_to_pyobj) {
- +static vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_info_t *si, bool convert_to_pyobj) {
- if (!convert_to_pyobj && emit->do_viper_types) {
- ASM_MOV_REG_IMM(emit->as, reg_dest, si->data.u_imm);
- return si->vtype;
- @@ -856,7 +849,7 @@ STATIC vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_i
- // concrete Python stack. This ensures the concrete Python stack holds valid
- // values for the current stack_size.
- // This function may clobber REG_TEMP1.
- -STATIC void need_stack_settled(emit_t *emit) {
- +static void need_stack_settled(emit_t *emit) {
- DEBUG_printf(" need_stack_settled; stack_size=%d\n", emit->stack_size);
- need_reg_all(emit);
- for (int i = 0; i < emit->stack_size; i++) {
- @@ -872,7 +865,7 @@ STATIC void need_stack_settled(emit_t *emit) {
- }
-
- // pos=1 is TOS, pos=2 is next, etc
- -STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int reg_dest) {
- +static void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int reg_dest) {
- need_reg_single(emit, reg_dest, pos);
- stack_info_t *si = &emit->stack_info[emit->stack_size - pos];
- *vtype = si->vtype;
- @@ -895,7 +888,7 @@ STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int re
-
- // does an efficient X=pop(); discard(); push(X)
- // needs a (non-temp) register in case the popped element was stored in the stack
- -STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) {
- +static void emit_fold_stack_top(emit_t *emit, int reg_dest) {
- stack_info_t *si = &emit->stack_info[emit->stack_size - 2];
- si[0] = si[1];
- if (si->kind == STACK_VALUE) {
- @@ -909,7 +902,7 @@ STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) {
-
- // If stacked value is in a register and the register is not r1 or r2, then
- // *reg_dest is set to that register. Otherwise the value is put in *reg_dest.
- -STATIC void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *reg_dest, int not_r1, int not_r2) {
- +static void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *reg_dest, int not_r1, int not_r2) {
- stack_info_t *si = peek_stack(emit, 0);
- if (si->kind == STACK_REG && si->data.u_reg != not_r1 && si->data.u_reg != not_r2) {
- *vtype = si->vtype;
- @@ -921,36 +914,36 @@ STATIC void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *re
- adjust_stack(emit, -1);
- }
-
- -STATIC void emit_pre_pop_discard(emit_t *emit) {
- +static void emit_pre_pop_discard(emit_t *emit) {
- adjust_stack(emit, -1);
- }
-
- -STATIC void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest) {
- +static void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest) {
- emit_access_stack(emit, 1, vtype, reg_dest);
- adjust_stack(emit, -1);
- }
-
- -STATIC void emit_pre_pop_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb) {
- +static void emit_pre_pop_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb) {
- emit_pre_pop_reg(emit, vtypea, rega);
- emit_pre_pop_reg(emit, vtypeb, regb);
- }
-
- -STATIC void emit_pre_pop_reg_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb, vtype_kind_t *vtypec, int regc) {
- +static void emit_pre_pop_reg_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb, vtype_kind_t *vtypec, int regc) {
- emit_pre_pop_reg(emit, vtypea, rega);
- emit_pre_pop_reg(emit, vtypeb, regb);
- emit_pre_pop_reg(emit, vtypec, regc);
- }
-
- -STATIC void emit_post(emit_t *emit) {
- +static void emit_post(emit_t *emit) {
- (void)emit;
- }
-
- -STATIC void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) {
- +static void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) {
- stack_info_t *si = &emit->stack_info[emit->stack_size - 1];
- si->vtype = new_vtype;
- }
-
- -STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) {
- +static void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) {
- ensure_extra_stack(emit, 1);
- stack_info_t *si = &emit->stack_info[emit->stack_size];
- si->vtype = vtype;
- @@ -959,7 +952,7 @@ STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) {
- adjust_stack(emit, 1);
- }
-
- -STATIC void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) {
- +static void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) {
- ensure_extra_stack(emit, 1);
- stack_info_t *si = &emit->stack_info[emit->stack_size];
- si->vtype = vtype;
- @@ -968,43 +961,43 @@ STATIC void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) {
- adjust_stack(emit, 1);
- }
-
- -STATIC void emit_post_push_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb) {
- +static void emit_post_push_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb) {
- emit_post_push_reg(emit, vtypea, rega);
- emit_post_push_reg(emit, vtypeb, regb);
- }
-
- -STATIC void emit_post_push_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc) {
- +static void emit_post_push_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc) {
- emit_post_push_reg(emit, vtypea, rega);
- emit_post_push_reg(emit, vtypeb, regb);
- emit_post_push_reg(emit, vtypec, regc);
- }
-
- -STATIC void emit_post_push_reg_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc, vtype_kind_t vtyped, int regd) {
- +static void emit_post_push_reg_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb, vtype_kind_t vtypec, int regc, vtype_kind_t vtyped, int regd) {
- emit_post_push_reg(emit, vtypea, rega);
- emit_post_push_reg(emit, vtypeb, regb);
- emit_post_push_reg(emit, vtypec, regc);
- emit_post_push_reg(emit, vtyped, regd);
- }
-
- -STATIC void emit_call(emit_t *emit, mp_fun_kind_t fun_kind) {
- +static void emit_call(emit_t *emit, mp_fun_kind_t fun_kind) {
- need_reg_all(emit);
- ASM_CALL_IND(emit->as, fun_kind);
- }
-
- -STATIC void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) {
- +static void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) {
- need_reg_all(emit);
- ASM_MOV_REG_IMM(emit->as, arg_reg, arg_val);
- ASM_CALL_IND(emit->as, fun_kind);
- }
-
- -STATIC void emit_call_with_2_imm_args(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val1, int arg_reg1, mp_int_t arg_val2, int arg_reg2) {
- +static void emit_call_with_2_imm_args(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val1, int arg_reg1, mp_int_t arg_val2, int arg_reg2) {
- need_reg_all(emit);
- ASM_MOV_REG_IMM(emit->as, arg_reg1, arg_val1);
- ASM_MOV_REG_IMM(emit->as, arg_reg2, arg_val2);
- ASM_CALL_IND(emit->as, fun_kind);
- }
-
- -STATIC void emit_call_with_qstr_arg(emit_t *emit, mp_fun_kind_t fun_kind, qstr qst, int arg_reg) {
- +static void emit_call_with_qstr_arg(emit_t *emit, mp_fun_kind_t fun_kind, qstr qst, int arg_reg) {
- need_reg_all(emit);
- emit_native_mov_reg_qstr(emit, arg_reg, qst);
- ASM_CALL_IND(emit->as, fun_kind);
- @@ -1014,7 +1007,7 @@ STATIC void emit_call_with_qstr_arg(emit_t *emit, mp_fun_kind_t fun_kind, qstr q
- // Will convert any items that are not VTYPE_PYOBJ to this type and put them back on the stack.
- // If any conversions of non-immediate values are needed, then it uses REG_ARG_1, REG_ARG_2 and REG_RET.
- // Otherwise, it does not use any temporary registers (but may use reg_dest before loading it with stack pointer).
- -STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_pop) {
- +static void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_pop) {
- need_reg_all(emit);
-
- // First, store any immediate values to their respective place on the stack.
- @@ -1051,7 +1044,7 @@ STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_de
- }
-
- // vtype of all n_push objects is VTYPE_PYOBJ
- -STATIC void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_push) {
- +static void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_push) {
- need_reg_all(emit);
- ensure_extra_stack(emit, n_push);
- for (mp_uint_t i = 0; i < n_push; i++) {
- @@ -1062,7 +1055,7 @@ STATIC void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_d
- adjust_stack(emit, n_push);
- }
-
- -STATIC void emit_native_push_exc_stack(emit_t *emit, uint label, bool is_finally) {
- +static void emit_native_push_exc_stack(emit_t *emit, uint label, bool is_finally) {
- if (emit->exc_stack_size + 1 > emit->exc_stack_alloc) {
- size_t new_alloc = emit->exc_stack_alloc + 4;
- emit->exc_stack = m_renew(exc_stack_entry_t, emit->exc_stack, emit->exc_stack_alloc, new_alloc);
- @@ -1079,7 +1072,7 @@ STATIC void emit_native_push_exc_stack(emit_t *emit, uint label, bool is_finally
- ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_RET);
- }
-
- -STATIC void emit_native_leave_exc_stack(emit_t *emit, bool start_of_handler) {
- +static void emit_native_leave_exc_stack(emit_t *emit, bool start_of_handler) {
- assert(emit->exc_stack_size > 0);
-
- // Get current exception handler and deactivate it
- @@ -1105,14 +1098,14 @@ STATIC void emit_native_leave_exc_stack(emit_t *emit, bool start_of_handler) {
- ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_RET);
- }
-
- -STATIC exc_stack_entry_t *emit_native_pop_exc_stack(emit_t *emit) {
- +static exc_stack_entry_t *emit_native_pop_exc_stack(emit_t *emit) {
- assert(emit->exc_stack_size > 0);
- exc_stack_entry_t *e = &emit->exc_stack[--emit->exc_stack_size];
- assert(e->is_active == false);
- return e;
- }
-
- -STATIC void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj) {
- +static void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj) {
- emit->scope->scope_flags |= MP_SCOPE_FLAG_HASCONSTS;
- size_t table_off = mp_emit_common_use_const_obj(emit->emit_common, obj);
- emit_native_mov_reg_state(emit, REG_TEMP0, LOCAL_IDX_FUN_OBJ(emit));
- @@ -1121,14 +1114,14 @@ STATIC void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj) {
- ASM_LOAD_REG_REG_OFFSET(emit->as, reg, REG_TEMP0, table_off);
- }
-
- -STATIC void emit_load_reg_with_child(emit_t *emit, int reg, mp_raw_code_t *rc) {
- +static void emit_load_reg_with_child(emit_t *emit, int reg, mp_raw_code_t *rc) {
- size_t table_off = mp_emit_common_alloc_const_child(emit->emit_common, rc);
- emit_native_mov_reg_state(emit, REG_TEMP0, LOCAL_IDX_FUN_OBJ(emit));
- ASM_LOAD_REG_REG_OFFSET(emit->as, REG_TEMP0, REG_TEMP0, OFFSETOF_OBJ_FUN_BC_CHILD_TABLE);
- ASM_LOAD_REG_REG_OFFSET(emit->as, reg, REG_TEMP0, table_off);
- }
-
- -STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
- +static void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
- DEBUG_printf("label_assign(" UINT_FMT ")\n", l);
-
- bool is_finally = false;
- @@ -1156,7 +1149,7 @@ STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
- }
- }
-
- -STATIC void emit_native_global_exc_entry(emit_t *emit) {
- +static void emit_native_global_exc_entry(emit_t *emit) {
- // Note: 4 labels are reserved for this function, starting at *emit->label_slot
-
- emit->exit_label = *emit->label_slot;
- @@ -1258,7 +1251,7 @@ STATIC void emit_native_global_exc_entry(emit_t *emit) {
- }
- }
-
- -STATIC void emit_native_global_exc_exit(emit_t *emit) {
- +static void emit_native_global_exc_exit(emit_t *emit) {
- // Label for end of function
- emit_native_label_assign(emit, emit->exit_label);
-
- @@ -1293,7 +1286,7 @@ STATIC void emit_native_global_exc_exit(emit_t *emit) {
- ASM_EXIT(emit->as);
- }
-
- -STATIC void emit_native_import_name(emit_t *emit, qstr qst) {
- +static void emit_native_import_name(emit_t *emit, qstr qst) {
- DEBUG_printf("import_name %s\n", qstr_str(qst));
-
- // get arguments from stack: arg2 = fromlist, arg3 = level
- @@ -1312,7 +1305,7 @@ STATIC void emit_native_import_name(emit_t *emit, qstr qst) {
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_import_from(emit_t *emit, qstr qst) {
- +static void emit_native_import_from(emit_t *emit, qstr qst) {
- DEBUG_printf("import_from %s\n", qstr_str(qst));
- emit_native_pre(emit);
- vtype_kind_t vtype_module;
- @@ -1322,7 +1315,7 @@ STATIC void emit_native_import_from(emit_t *emit, qstr qst) {
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_import_star(emit_t *emit) {
- +static void emit_native_import_star(emit_t *emit) {
- DEBUG_printf("import_star\n");
- vtype_kind_t vtype_module;
- emit_pre_pop_reg(emit, &vtype_module, REG_ARG_1); // arg1 = module
- @@ -1331,7 +1324,7 @@ STATIC void emit_native_import_star(emit_t *emit) {
- emit_post(emit);
- }
-
- -STATIC void emit_native_import(emit_t *emit, qstr qst, int kind) {
- +static void emit_native_import(emit_t *emit, qstr qst, int kind) {
- if (kind == MP_EMIT_IMPORT_NAME) {
- emit_native_import_name(emit, qst);
- } else if (kind == MP_EMIT_IMPORT_FROM) {
- @@ -1341,7 +1334,7 @@ STATIC void emit_native_import(emit_t *emit, qstr qst, int kind) {
- }
- }
-
- -STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
- +static void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
- DEBUG_printf("load_const_tok(tok=%u)\n", tok);
- if (tok == MP_TOKEN_ELLIPSIS) {
- emit_native_load_const_obj(emit, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj));
- @@ -1355,13 +1348,13 @@ STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
- }
- }
-
- -STATIC void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) {
- +static void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) {
- DEBUG_printf("load_const_small_int(int=" INT_FMT ")\n", arg);
- emit_native_pre(emit);
- emit_post_push_imm(emit, VTYPE_INT, arg);
- }
-
- -STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) {
- +static void emit_native_load_const_str(emit_t *emit, qstr qst) {
- emit_native_pre(emit);
- // TODO: Eventually we want to be able to work with raw pointers in viper to
- // do native array access. For now we just load them as any other object.
- @@ -1378,19 +1371,19 @@ STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) {
- }
- }
-
- -STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) {
- +static void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) {
- emit_native_pre(emit);
- need_reg_single(emit, REG_RET, 0);
- emit_load_reg_with_object(emit, REG_RET, obj);
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_load_null(emit_t *emit) {
- +static void emit_native_load_null(emit_t *emit) {
- emit_native_pre(emit);
- emit_post_push_imm(emit, VTYPE_PYOBJ, 0);
- }
-
- -STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
- +static void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
- DEBUG_printf("load_fast(%s, " UINT_FMT ")\n", qstr_str(qst), local_num);
- vtype_kind_t vtype = emit->local_vtype[local_num];
- if (vtype == VTYPE_UNBOUND) {
- @@ -1406,7 +1399,7 @@ STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
- }
- }
-
- -STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
- +static void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
- DEBUG_printf("load_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num);
- need_reg_single(emit, REG_RET, 0);
- emit_native_load_fast(emit, qst, local_num);
- @@ -1418,7 +1411,7 @@ STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num)
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_load_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
- +static void emit_native_load_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
- if (kind == MP_EMIT_IDOP_LOCAL_FAST) {
- emit_native_load_fast(emit, qst, local_num);
- } else {
- @@ -1426,7 +1419,7 @@ STATIC void emit_native_load_local(emit_t *emit, qstr qst, mp_uint_t local_num,
- }
- }
-
- -STATIC void emit_native_load_global(emit_t *emit, qstr qst, int kind) {
- +static void emit_native_load_global(emit_t *emit, qstr qst, int kind) {
- MP_STATIC_ASSERT(MP_F_LOAD_NAME + MP_EMIT_IDOP_GLOBAL_NAME == MP_F_LOAD_NAME);
- MP_STATIC_ASSERT(MP_F_LOAD_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_F_LOAD_GLOBAL);
- emit_native_pre(emit);
- @@ -1447,7 +1440,7 @@ STATIC void emit_native_load_global(emit_t *emit, qstr qst, int kind) {
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_load_attr(emit_t *emit, qstr qst) {
- +static void emit_native_load_attr(emit_t *emit, qstr qst) {
- // depends on type of subject:
- // - integer, function, pointer to integers: error
- // - pointer to structure: get member, quite easy
- @@ -1459,7 +1452,7 @@ STATIC void emit_native_load_attr(emit_t *emit, qstr qst) {
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) {
- +static void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) {
- if (is_super) {
- emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, 3); // arg2 = dest ptr
- emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_2, 2); // arg2 = dest ptr
- @@ -1473,13 +1466,13 @@ STATIC void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) {
- }
- }
-
- -STATIC void emit_native_load_build_class(emit_t *emit) {
- +static void emit_native_load_build_class(emit_t *emit) {
- emit_native_pre(emit);
- emit_call(emit, MP_F_LOAD_BUILD_CLASS);
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_load_subscr(emit_t *emit) {
- +static void emit_native_load_subscr(emit_t *emit) {
- DEBUG_printf("load_subscr\n");
- // need to compile: base[index]
-
- @@ -1619,7 +1612,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) {
- }
- }
-
- -STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
- +static void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
- vtype_kind_t vtype;
- if (local_num < MAX_REGS_FOR_LOCAL_VARS && CAN_USE_REGS_FOR_LOCALS(emit)) {
- emit_pre_pop_reg(emit, &vtype, reg_local_table[local_num]);
- @@ -1641,7 +1634,7 @@ STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num)
- }
- }
-
- -STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
- +static void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
- DEBUG_printf("store_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num);
- need_reg_single(emit, REG_TEMP0, 0);
- need_reg_single(emit, REG_TEMP1, 0);
- @@ -1655,7 +1648,7 @@ STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num)
- emit_post(emit);
- }
-
- -STATIC void emit_native_store_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
- +static void emit_native_store_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
- if (kind == MP_EMIT_IDOP_LOCAL_FAST) {
- emit_native_store_fast(emit, qst, local_num);
- } else {
- @@ -1663,7 +1656,7 @@ STATIC void emit_native_store_local(emit_t *emit, qstr qst, mp_uint_t local_num,
- }
- }
-
- -STATIC void emit_native_store_global(emit_t *emit, qstr qst, int kind) {
- +static void emit_native_store_global(emit_t *emit, qstr qst, int kind) {
- MP_STATIC_ASSERT(MP_F_STORE_NAME + MP_EMIT_IDOP_GLOBAL_NAME == MP_F_STORE_NAME);
- MP_STATIC_ASSERT(MP_F_STORE_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_F_STORE_GLOBAL);
- if (kind == MP_EMIT_IDOP_GLOBAL_NAME) {
- @@ -1685,7 +1678,7 @@ STATIC void emit_native_store_global(emit_t *emit, qstr qst, int kind) {
- emit_post(emit);
- }
-
- -STATIC void emit_native_store_attr(emit_t *emit, qstr qst) {
- +static void emit_native_store_attr(emit_t *emit, qstr qst) {
- vtype_kind_t vtype_base;
- vtype_kind_t vtype_val = peek_vtype(emit, 1);
- if (vtype_val == VTYPE_PYOBJ) {
- @@ -1702,7 +1695,7 @@ STATIC void emit_native_store_attr(emit_t *emit, qstr qst) {
- emit_post(emit);
- }
-
- -STATIC void emit_native_store_subscr(emit_t *emit) {
- +static void emit_native_store_subscr(emit_t *emit) {
- DEBUG_printf("store_subscr\n");
- // need to compile: base[index] = value
-
- @@ -1879,7 +1872,7 @@ STATIC void emit_native_store_subscr(emit_t *emit) {
- }
- }
-
- -STATIC void emit_native_delete_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
- +static void emit_native_delete_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
- if (kind == MP_EMIT_IDOP_LOCAL_FAST) {
- // TODO: This is not compliant implementation. We could use MP_OBJ_SENTINEL
- // to mark deleted vars but then every var would need to be checked on
- @@ -1891,7 +1884,7 @@ STATIC void emit_native_delete_local(emit_t *emit, qstr qst, mp_uint_t local_num
- }
- }
-
- -STATIC void emit_native_delete_global(emit_t *emit, qstr qst, int kind) {
- +static void emit_native_delete_global(emit_t *emit, qstr qst, int kind) {
- MP_STATIC_ASSERT(MP_F_DELETE_NAME + MP_EMIT_IDOP_GLOBAL_NAME == MP_F_DELETE_NAME);
- MP_STATIC_ASSERT(MP_F_DELETE_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_F_DELETE_GLOBAL);
- emit_native_pre(emit);
- @@ -1899,7 +1892,7 @@ STATIC void emit_native_delete_global(emit_t *emit, qstr qst, int kind) {
- emit_post(emit);
- }
-
- -STATIC void emit_native_delete_attr(emit_t *emit, qstr qst) {
- +static void emit_native_delete_attr(emit_t *emit, qstr qst) {
- vtype_kind_t vtype_base;
- emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base
- assert(vtype_base == VTYPE_PYOBJ);
- @@ -1908,7 +1901,7 @@ STATIC void emit_native_delete_attr(emit_t *emit, qstr qst) {
- emit_post(emit);
- }
-
- -STATIC void emit_native_delete_subscr(emit_t *emit) {
- +static void emit_native_delete_subscr(emit_t *emit) {
- vtype_kind_t vtype_index, vtype_base;
- emit_pre_pop_reg_reg(emit, &vtype_index, REG_ARG_2, &vtype_base, REG_ARG_1); // index, base
- assert(vtype_index == VTYPE_PYOBJ);
- @@ -1916,7 +1909,7 @@ STATIC void emit_native_delete_subscr(emit_t *emit) {
- emit_call_with_imm_arg(emit, MP_F_OBJ_SUBSCR, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3);
- }
-
- -STATIC void emit_native_subscr(emit_t *emit, int kind) {
- +static void emit_native_subscr(emit_t *emit, int kind) {
- if (kind == MP_EMIT_SUBSCR_LOAD) {
- emit_native_load_subscr(emit);
- } else if (kind == MP_EMIT_SUBSCR_STORE) {
- @@ -1926,7 +1919,7 @@ STATIC void emit_native_subscr(emit_t *emit, int kind) {
- }
- }
-
- -STATIC void emit_native_attr(emit_t *emit, qstr qst, int kind) {
- +static void emit_native_attr(emit_t *emit, qstr qst, int kind) {
- if (kind == MP_EMIT_ATTR_LOAD) {
- emit_native_load_attr(emit, qst);
- } else if (kind == MP_EMIT_ATTR_STORE) {
- @@ -1936,7 +1929,7 @@ STATIC void emit_native_attr(emit_t *emit, qstr qst, int kind) {
- }
- }
-
- -STATIC void emit_native_dup_top(emit_t *emit) {
- +static void emit_native_dup_top(emit_t *emit) {
- DEBUG_printf("dup_top\n");
- vtype_kind_t vtype;
- int reg = REG_TEMP0;
- @@ -1944,33 +1937,33 @@ STATIC void emit_native_dup_top(emit_t *emit) {
- emit_post_push_reg_reg(emit, vtype, reg, vtype, reg);
- }
-
- -STATIC void emit_native_dup_top_two(emit_t *emit) {
- +static void emit_native_dup_top_two(emit_t *emit) {
- vtype_kind_t vtype0, vtype1;
- emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1);
- emit_post_push_reg_reg_reg_reg(emit, vtype1, REG_TEMP1, vtype0, REG_TEMP0, vtype1, REG_TEMP1, vtype0, REG_TEMP0);
- }
-
- -STATIC void emit_native_pop_top(emit_t *emit) {
- +static void emit_native_pop_top(emit_t *emit) {
- DEBUG_printf("pop_top\n");
- emit_pre_pop_discard(emit);
- emit_post(emit);
- }
-
- -STATIC void emit_native_rot_two(emit_t *emit) {
- +static void emit_native_rot_two(emit_t *emit) {
- DEBUG_printf("rot_two\n");
- vtype_kind_t vtype0, vtype1;
- emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1);
- emit_post_push_reg_reg(emit, vtype0, REG_TEMP0, vtype1, REG_TEMP1);
- }
-
- -STATIC void emit_native_rot_three(emit_t *emit) {
- +static void emit_native_rot_three(emit_t *emit) {
- DEBUG_printf("rot_three\n");
- vtype_kind_t vtype0, vtype1, vtype2;
- emit_pre_pop_reg_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1, &vtype2, REG_TEMP2);
- emit_post_push_reg_reg_reg(emit, vtype0, REG_TEMP0, vtype2, REG_TEMP2, vtype1, REG_TEMP1);
- }
-
- -STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) {
- +static void emit_native_jump(emit_t *emit, mp_uint_t label) {
- DEBUG_printf("jump(label=" UINT_FMT ")\n", label);
- emit_native_pre(emit);
- // need to commit stack because we are jumping elsewhere
- @@ -1980,7 +1973,7 @@ STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) {
- mp_asm_base_suppress_code(&emit->as->base);
- }
-
- -STATIC void emit_native_jump_helper(emit_t *emit, bool cond, mp_uint_t label, bool pop) {
- +static void emit_native_jump_helper(emit_t *emit, bool cond, mp_uint_t label, bool pop) {
- vtype_kind_t vtype = peek_vtype(emit, 0);
- if (vtype == VTYPE_PYOBJ) {
- emit_pre_pop_reg(emit, &vtype, REG_ARG_1);
- @@ -2017,17 +2010,17 @@ STATIC void emit_native_jump_helper(emit_t *emit, bool cond, mp_uint_t label, bo
- emit_post(emit);
- }
-
- -STATIC void emit_native_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) {
- +static void emit_native_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) {
- DEBUG_printf("pop_jump_if(cond=%u, label=" UINT_FMT ")\n", cond, label);
- emit_native_jump_helper(emit, cond, label, true);
- }
-
- -STATIC void emit_native_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) {
- +static void emit_native_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) {
- DEBUG_printf("jump_if_or_pop(cond=%u, label=" UINT_FMT ")\n", cond, label);
- emit_native_jump_helper(emit, cond, label, false);
- }
-
- -STATIC void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
- +static void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
- if (except_depth > 0) {
- exc_stack_entry_t *first_finally = NULL;
- exc_stack_entry_t *prev_finally = NULL;
- @@ -2070,7 +2063,7 @@ STATIC void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t exc
- emit_native_jump(emit, label & ~MP_EMIT_BREAK_FROM_FOR);
- }
-
- -STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
- +static void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
- // the context manager is on the top of the stack
- // stack: (..., ctx_mgr)
-
- @@ -2109,7 +2102,7 @@ STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
- // stack: (..., __exit__, self, as_value, as_value)
- }
-
- -STATIC void emit_native_setup_block(emit_t *emit, mp_uint_t label, int kind) {
- +static void emit_native_setup_block(emit_t *emit, mp_uint_t label, int kind) {
- if (kind == MP_EMIT_SETUP_BLOCK_WITH) {
- emit_native_setup_with(emit, label);
- } else {
- @@ -2121,7 +2114,7 @@ STATIC void emit_native_setup_block(emit_t *emit, mp_uint_t label, int kind) {
- }
- }
-
- -STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
- +static void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
- // Note: 3 labels are reserved for this function, starting at *emit->label_slot
-
- // stack: (..., __exit__, self, as_value)
- @@ -2188,7 +2181,7 @@ STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
- // Exception is in nlr_buf.ret_val slot
- }
-
- -STATIC void emit_native_end_finally(emit_t *emit) {
- +static void emit_native_end_finally(emit_t *emit) {
- // logic:
- // exc = pop_stack
- // if exc == None: pass
- @@ -2214,7 +2207,7 @@ STATIC void emit_native_end_finally(emit_t *emit) {
- emit_post(emit);
- }
-
- -STATIC void emit_native_get_iter(emit_t *emit, bool use_stack) {
- +static void emit_native_get_iter(emit_t *emit, bool use_stack) {
- // perhaps the difficult one, as we want to rewrite for loops using native code
- // in cases where we iterate over a Python object, can we use normal runtime calls?
-
- @@ -2232,7 +2225,7 @@ STATIC void emit_native_get_iter(emit_t *emit, bool use_stack) {
- }
- }
-
- -STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
- +static void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
- emit_native_pre(emit);
- emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, MP_OBJ_ITER_BUF_NSLOTS);
- adjust_stack(emit, MP_OBJ_ITER_BUF_NSLOTS);
- @@ -2247,14 +2240,14 @@ STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_for_iter_end(emit_t *emit) {
- +static void emit_native_for_iter_end(emit_t *emit) {
- // adjust stack counter (we get here from for_iter ending, which popped the value for us)
- emit_native_pre(emit);
- adjust_stack(emit, -MP_OBJ_ITER_BUF_NSLOTS);
- emit_post(emit);
- }
-
- -STATIC void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, bool within_exc_handler) {
- +static void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, bool within_exc_handler) {
- if (within_exc_handler) {
- // Cancel any active exception so subsequent handlers don't see it
- ASM_MOV_REG_IMM(emit->as, REG_TEMP0, (mp_uint_t)MP_OBJ_NULL);
- @@ -2265,20 +2258,43 @@ STATIC void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, bool with
- emit_native_jump(emit, label);
- }
-
- -STATIC void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) {
- - vtype_kind_t vtype;
- - emit_pre_pop_reg(emit, &vtype, REG_ARG_2);
- - if (vtype == VTYPE_PYOBJ) {
- +static void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) {
- + vtype_kind_t vtype = peek_vtype(emit, 0);
- + if (vtype == VTYPE_INT || vtype == VTYPE_UINT) {
- + if (op == MP_UNARY_OP_POSITIVE) {
- + // No-operation, just leave the argument on the stack.
- + } else if (op == MP_UNARY_OP_NEGATIVE) {
- + int reg = REG_RET;
- + emit_pre_pop_reg_flexible(emit, &vtype, ®, reg, reg);
- + ASM_NEG_REG(emit->as, reg);
- + emit_post_push_reg(emit, vtype, reg);
- + } else if (op == MP_UNARY_OP_INVERT) {
- + #ifdef ASM_NOT_REG
- + int reg = REG_RET;
- + emit_pre_pop_reg_flexible(emit, &vtype, ®, reg, reg);
- + ASM_NOT_REG(emit->as, reg);
- + #else
- + int reg = REG_RET;
- + emit_pre_pop_reg_flexible(emit, &vtype, ®, REG_ARG_1, reg);
- + ASM_MOV_REG_IMM(emit->as, REG_ARG_1, -1);
- + ASM_XOR_REG_REG(emit->as, reg, REG_ARG_1);
- + #endif
- + emit_post_push_reg(emit, vtype, reg);
- + } else {
- + EMIT_NATIVE_VIPER_TYPE_ERROR(emit,
- + MP_ERROR_TEXT("'not' not implemented"), mp_binary_op_method_name[op]);
- + }
- + } else if (vtype == VTYPE_PYOBJ) {
- + emit_pre_pop_reg(emit, &vtype, REG_ARG_2);
- emit_call_with_imm_arg(emit, MP_F_UNARY_OP, op, REG_ARG_1);
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- } else {
- - adjust_stack(emit, 1);
- EMIT_NATIVE_VIPER_TYPE_ERROR(emit,
- - MP_ERROR_TEXT("unary op %q not implemented"), mp_unary_op_method_name[op]);
- + MP_ERROR_TEXT("can't do unary op of '%q'"), vtype_to_qstr(vtype));
- }
- }
-
- -STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
- +static void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
- DEBUG_printf("binary_op(" UINT_FMT ")\n", op);
- vtype_kind_t vtype_lhs = peek_vtype(emit, 1);
- vtype_kind_t vtype_rhs = peek_vtype(emit, 0);
- @@ -2541,10 +2557,10 @@ STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
- }
-
- #if MICROPY_PY_BUILTINS_SLICE
- -STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args);
- +static void emit_native_build_slice(emit_t *emit, mp_uint_t n_args);
- #endif
-
- -STATIC void emit_native_build(emit_t *emit, mp_uint_t n_args, int kind) {
- +static void emit_native_build(emit_t *emit, mp_uint_t n_args, int kind) {
- // for viper: call runtime, with types of args
- // if wrapped in byte_array, or something, allocates memory and fills it
- MP_STATIC_ASSERT(MP_F_BUILD_TUPLE + MP_EMIT_BUILD_TUPLE == MP_F_BUILD_TUPLE);
- @@ -2565,7 +2581,7 @@ STATIC void emit_native_build(emit_t *emit, mp_uint_t n_args, int kind) {
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new tuple/list/map/set
- }
-
- -STATIC void emit_native_store_map(emit_t *emit) {
- +static void emit_native_store_map(emit_t *emit) {
- vtype_kind_t vtype_key, vtype_value, vtype_map;
- emit_pre_pop_reg_reg_reg(emit, &vtype_key, REG_ARG_2, &vtype_value, REG_ARG_3, &vtype_map, REG_ARG_1); // key, value, map
- assert(vtype_key == VTYPE_PYOBJ);
- @@ -2576,7 +2592,7 @@ STATIC void emit_native_store_map(emit_t *emit) {
- }
-
- #if MICROPY_PY_BUILTINS_SLICE
- -STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) {
- +static void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) {
- DEBUG_printf("build_slice %d\n", n_args);
- if (n_args == 2) {
- vtype_kind_t vtype_start, vtype_stop;
- @@ -2597,7 +2613,7 @@ STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) {
- }
- #endif
-
- -STATIC void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_index) {
- +static void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_index) {
- mp_fun_kind_t f;
- if (kind == SCOPE_LIST_COMP) {
- vtype_kind_t vtype_item;
- @@ -2626,7 +2642,7 @@ STATIC void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t co
- emit_post(emit);
- }
-
- -STATIC void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
- +static void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
- DEBUG_printf("unpack_sequence %d\n", n_args);
- vtype_kind_t vtype_base;
- emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq
- @@ -2635,7 +2651,7 @@ STATIC void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
- emit_call_with_imm_arg(emit, MP_F_UNPACK_SEQUENCE, n_args, REG_ARG_2); // arg2 = n_args
- }
-
- -STATIC void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) {
- +static void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) {
- DEBUG_printf("unpack_ex %d %d\n", n_left, n_right);
- vtype_kind_t vtype_base;
- emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq
- @@ -2644,7 +2660,7 @@ STATIC void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_ri
- emit_call_with_imm_arg(emit, MP_F_UNPACK_EX, n_left | (n_right << 8), REG_ARG_2); // arg2 = n_left + n_right
- }
-
- -STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
- +static void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
- // call runtime, with type info for args, or don't support dict/default params, or only support Python objects for them
- emit_native_pre(emit);
- emit_native_mov_reg_state(emit, REG_ARG_2, LOCAL_IDX_FUN_OBJ(emit));
- @@ -2657,11 +2673,11 @@ STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_
- need_reg_all(emit);
- }
- emit_load_reg_with_child(emit, REG_ARG_1, scope->raw_code);
- - ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_RAW_CODE);
- + ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_PROTO_FUN);
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
- +static void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
- // make function
- emit_native_pre(emit);
- emit_native_mov_reg_state(emit, REG_ARG_2, LOCAL_IDX_FUN_OBJ(emit));
- @@ -2675,7 +2691,7 @@ STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_c
- need_reg_all(emit);
- }
- emit_load_reg_with_child(emit, REG_ARG_1, scope->raw_code);
- - ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_RAW_CODE);
- + ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_PROTO_FUN);
-
- // make closure
- #if REG_ARG_1 != REG_RET
- @@ -2690,7 +2706,7 @@ STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_c
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
- }
-
- -STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
- +static void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
- DEBUG_printf("call_function(n_pos=" UINT_FMT ", n_kw=" UINT_FMT ", star_flags=" UINT_FMT ")\n", n_positional, n_keyword, star_flags);
-
- // TODO: in viper mode, call special runtime routine with type info for args,
- @@ -2745,7 +2761,7 @@ STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_u
- }
- }
-
- -STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
- +static void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
- if (star_flags) {
- emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 3); // pointer to args
- emit_call_with_2_imm_args(emit, MP_F_CALL_METHOD_N_KW_VAR, 1, REG_ARG_1, n_positional | (n_keyword << 8), REG_ARG_2);
- @@ -2758,7 +2774,7 @@ STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uin
- }
- }
-
- -STATIC void emit_native_return_value(emit_t *emit) {
- +static void emit_native_return_value(emit_t *emit) {
- DEBUG_printf("return_value\n");
-
- if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
- @@ -2811,7 +2827,7 @@ STATIC void emit_native_return_value(emit_t *emit) {
- emit_native_unwind_jump(emit, emit->exit_label, emit->exc_stack_size);
- }
-
- -STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
- +static void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
- (void)n_args;
- assert(n_args == 1);
- vtype_kind_t vtype_exc;
- @@ -2824,7 +2840,7 @@ STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
- mp_asm_base_suppress_code(&emit->as->base);
- }
-
- -STATIC void emit_native_yield(emit_t *emit, int kind) {
- +static void emit_native_yield(emit_t *emit, int kind) {
- // Note: 1 (yield) or 3 (yield from) labels are reserved for this function, starting at *emit->label_slot
-
- if (emit->do_viper_types) {
- @@ -2907,7 +2923,7 @@ STATIC void emit_native_yield(emit_t *emit, int kind) {
- }
- }
-
- -STATIC void emit_native_start_except_handler(emit_t *emit) {
- +static void emit_native_start_except_handler(emit_t *emit) {
- // Protected block has finished so leave the current exception handler
- emit_native_leave_exc_stack(emit, true);
-
- @@ -2916,7 +2932,7 @@ STATIC void emit_native_start_except_handler(emit_t *emit) {
- emit_post_push_reg(emit, VTYPE_PYOBJ, REG_TEMP0);
- }
-
- -STATIC void emit_native_end_except_handler(emit_t *emit) {
- +static void emit_native_end_except_handler(emit_t *emit) {
- adjust_stack(emit, -1); // pop the exception (end_finally didn't use it)
- }
-
- diff --git a/py/emitnx86.c b/py/emitnx86.c
- index a9050c65d..1d2aefa79 100644
- --- a/py/emitnx86.c
- +++ b/py/emitnx86.c
- @@ -13,7 +13,7 @@
- #define NLR_BUF_IDX_LOCAL_1 (5) // ebx
-
- // x86 needs a table to know how many args a given function has
- -STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
- +static byte mp_f_n_args[MP_F_NUMBER_OF] = {
- [MP_F_CONVERT_OBJ_TO_NATIVE] = 2,
- [MP_F_CONVERT_NATIVE_TO_OBJ] = 2,
- [MP_F_NATIVE_SWAP_GLOBALS] = 1,
- @@ -37,7 +37,7 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
- [MP_F_STORE_SET] = 2,
- [MP_F_LIST_APPEND] = 2,
- [MP_F_STORE_MAP] = 3,
- - [MP_F_MAKE_FUNCTION_FROM_RAW_CODE] = 3,
- + [MP_F_MAKE_FUNCTION_FROM_PROTO_FUN] = 3,
- [MP_F_NATIVE_CALL_FUNCTION_N_KW] = 3,
- [MP_F_CALL_METHOD_N_KW] = 3,
- [MP_F_CALL_METHOD_N_KW_VAR] = 3,
- diff --git a/py/gc.c b/py/gc.c
- index b6969dfd4..8a03ce526 100644
- --- a/py/gc.c
- +++ b/py/gc.c
- @@ -121,7 +121,7 @@
- #endif
-
- // TODO waste less memory; currently requires that all entries in alloc_table have a corresponding block in pool
- -STATIC void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
- +static void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
- // calculate parameters for GC (T=total, A=alloc table, F=finaliser table, P=pool; all in bytes):
- // T = A + F + P
- // F = A * BLOCKS_PER_ATB / BLOCKS_PER_FTB
- @@ -239,7 +239,7 @@ void gc_add(void *start, void *end) {
-
- #if MICROPY_GC_SPLIT_HEAP_AUTO
- // Try to automatically add a heap area large enough to fulfill 'failed_alloc'.
- -STATIC bool gc_try_add_heap(size_t failed_alloc) {
- +static bool gc_try_add_heap(size_t failed_alloc) {
- // 'needed' is the size of a heap large enough to hold failed_alloc, with
- // the additional metadata overheads as calculated in gc_setup_area().
- //
- @@ -349,7 +349,7 @@ bool gc_is_locked(void) {
- #if MICROPY_GC_SPLIT_HEAP
- // Returns the area to which this pointer belongs, or NULL if it isn't
- // allocated on the GC-managed heap.
- -STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
- +static inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
- if (((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) != 0) { // must be aligned on a block
- return NULL;
- }
- @@ -383,9 +383,9 @@ STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
- // blocks on the stack. When all children have been checked, pop off the
- // topmost block on the stack and repeat with that one.
- #if MICROPY_GC_SPLIT_HEAP
- -STATIC void gc_mark_subtree(mp_state_mem_area_t *area, size_t block)
- +static void gc_mark_subtree(mp_state_mem_area_t *area, size_t block)
- #else
- -STATIC void gc_mark_subtree(size_t block)
- +static void gc_mark_subtree(size_t block)
- #endif
- {
- // Start with the block passed in the argument.
- @@ -456,7 +456,7 @@ STATIC void gc_mark_subtree(size_t block)
- }
- }
-
- -STATIC void gc_deal_with_stack_overflow(void) {
- +static void gc_deal_with_stack_overflow(void) {
- while (MP_STATE_MEM(gc_stack_overflow)) {
- MP_STATE_MEM(gc_stack_overflow) = 0;
-
- @@ -477,7 +477,7 @@ STATIC void gc_deal_with_stack_overflow(void) {
- }
- }
-
- -STATIC void gc_sweep(void) {
- +static void gc_sweep(void) {
- #if MICROPY_PY_GC_COLLECT_RETVAL
- MP_STATE_MEM(gc_collected) = 0;
- #endif
- diff --git a/py/lexer.c b/py/lexer.c
- index 5e911a1a2..bff8e6376 100644
- --- a/py/lexer.c
- +++ b/py/lexer.c
- @@ -42,74 +42,74 @@
- #define MP_LEXER_EOF ((unichar)MP_READER_EOF)
- #define CUR_CHAR(lex) ((lex)->chr0)
-
- -STATIC bool is_end(mp_lexer_t *lex) {
- +static bool is_end(mp_lexer_t *lex) {
- return lex->chr0 == MP_LEXER_EOF;
- }
-
- -STATIC bool is_physical_newline(mp_lexer_t *lex) {
- +static bool is_physical_newline(mp_lexer_t *lex) {
- return lex->chr0 == '\n';
- }
-
- -STATIC bool is_char(mp_lexer_t *lex, byte c) {
- +static bool is_char(mp_lexer_t *lex, byte c) {
- return lex->chr0 == c;
- }
-
- -STATIC bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
- +static bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
- return lex->chr0 == c1 || lex->chr0 == c2;
- }
-
- -STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
- +static bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
- return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3;
- }
-
- #if MICROPY_PY_FSTRINGS
- -STATIC bool is_char_or4(mp_lexer_t *lex, byte c1, byte c2, byte c3, byte c4) {
- +static bool is_char_or4(mp_lexer_t *lex, byte c1, byte c2, byte c3, byte c4) {
- return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3 || lex->chr0 == c4;
- }
- #endif
-
- -STATIC bool is_char_following(mp_lexer_t *lex, byte c) {
- +static bool is_char_following(mp_lexer_t *lex, byte c) {
- return lex->chr1 == c;
- }
-
- -STATIC bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
- +static bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
- return lex->chr1 == c1 || lex->chr1 == c2;
- }
-
- -STATIC bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) {
- +static bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) {
- return lex->chr2 == c1 || lex->chr2 == c2;
- }
-
- -STATIC bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
- +static bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
- return lex->chr0 == c1 && lex->chr1 == c2;
- }
-
- -STATIC bool is_whitespace(mp_lexer_t *lex) {
- +static bool is_whitespace(mp_lexer_t *lex) {
- return unichar_isspace(lex->chr0);
- }
-
- -STATIC bool is_letter(mp_lexer_t *lex) {
- +static bool is_letter(mp_lexer_t *lex) {
- return unichar_isalpha(lex->chr0);
- }
-
- -STATIC bool is_digit(mp_lexer_t *lex) {
- +static bool is_digit(mp_lexer_t *lex) {
- return unichar_isdigit(lex->chr0);
- }
-
- -STATIC bool is_following_digit(mp_lexer_t *lex) {
- +static bool is_following_digit(mp_lexer_t *lex) {
- return unichar_isdigit(lex->chr1);
- }
-
- -STATIC bool is_following_base_char(mp_lexer_t *lex) {
- +static bool is_following_base_char(mp_lexer_t *lex) {
- const unichar chr1 = lex->chr1 | 0x20;
- return chr1 == 'b' || chr1 == 'o' || chr1 == 'x';
- }
-
- -STATIC bool is_following_odigit(mp_lexer_t *lex) {
- +static bool is_following_odigit(mp_lexer_t *lex) {
- return lex->chr1 >= '0' && lex->chr1 <= '7';
- }
-
- -STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
- +static bool is_string_or_bytes(mp_lexer_t *lex) {
- return is_char_or(lex, '\'', '\"')
- #if MICROPY_PY_FSTRINGS
- || (is_char_or4(lex, 'r', 'u', 'b', 'f') && is_char_following_or(lex, '\'', '\"'))
- @@ -123,15 +123,15 @@ STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
- }
-
- // to easily parse utf-8 identifiers we allow any raw byte with high bit set
- -STATIC bool is_head_of_identifier(mp_lexer_t *lex) {
- +static bool is_head_of_identifier(mp_lexer_t *lex) {
- return is_letter(lex) || lex->chr0 == '_' || lex->chr0 >= 0x80;
- }
-
- -STATIC bool is_tail_of_identifier(mp_lexer_t *lex) {
- +static bool is_tail_of_identifier(mp_lexer_t *lex) {
- return is_head_of_identifier(lex) || is_digit(lex);
- }
-
- -STATIC void next_char(mp_lexer_t *lex) {
- +static void next_char(mp_lexer_t *lex) {
- if (lex->chr0 == '\n') {
- // a new line
- ++lex->line;
- @@ -189,7 +189,7 @@ STATIC void next_char(mp_lexer_t *lex) {
- }
- }
-
- -STATIC void indent_push(mp_lexer_t *lex, size_t indent) {
- +static void indent_push(mp_lexer_t *lex, size_t indent) {
- if (lex->num_indent_level >= lex->alloc_indent_level) {
- lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MICROPY_ALLOC_LEXEL_INDENT_INC);
- lex->alloc_indent_level += MICROPY_ALLOC_LEXEL_INDENT_INC;
- @@ -197,11 +197,11 @@ STATIC void indent_push(mp_lexer_t *lex, size_t indent) {
- lex->indent_level[lex->num_indent_level++] = indent;
- }
-
- -STATIC size_t indent_top(mp_lexer_t *lex) {
- +static size_t indent_top(mp_lexer_t *lex) {
- return lex->indent_level[lex->num_indent_level - 1];
- }
-
- -STATIC void indent_pop(mp_lexer_t *lex) {
- +static void indent_pop(mp_lexer_t *lex) {
- lex->num_indent_level -= 1;
- }
-
- @@ -211,7 +211,7 @@ STATIC void indent_pop(mp_lexer_t *lex) {
- // c<op> = continue with <op>, if this opchar matches then continue matching
- // this means if the start of two ops are the same then they are equal til the last char
-
- -STATIC const char *const tok_enc =
- +static const char *const tok_enc =
- "()[]{},;~" // singles
- ":e=" // : :=
- "<e=c<e=" // < <= << <<=
- @@ -229,7 +229,7 @@ STATIC const char *const tok_enc =
- "!."; // start of special cases: != . ...
-
- // TODO static assert that number of tokens is less than 256 so we can safely make this table with byte sized entries
- -STATIC const uint8_t tok_enc_kind[] = {
- +static const uint8_t tok_enc_kind[] = {
- MP_TOKEN_DEL_PAREN_OPEN, MP_TOKEN_DEL_PAREN_CLOSE,
- MP_TOKEN_DEL_BRACKET_OPEN, MP_TOKEN_DEL_BRACKET_CLOSE,
- MP_TOKEN_DEL_BRACE_OPEN, MP_TOKEN_DEL_BRACE_CLOSE,
- @@ -252,7 +252,7 @@ STATIC const uint8_t tok_enc_kind[] = {
-
- // must have the same order as enum in lexer.h
- // must be sorted according to strcmp
- -STATIC const char *const tok_kw[] = {
- +static const char *const tok_kw[] = {
- "False",
- "None",
- "True",
- @@ -296,7 +296,7 @@ STATIC const char *const tok_kw[] = {
- // This is called with CUR_CHAR() before first hex digit, and should return with
- // it pointing to last hex digit
- // num_digits must be greater than zero
- -STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
- +static bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
- mp_uint_t num = 0;
- while (num_digits-- != 0) {
- next_char(lex);
- @@ -310,7 +310,7 @@ STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
- return true;
- }
-
- -STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) {
- +static void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) {
- // get first quoting character
- char quote_char = '\'';
- if (is_char(lex, '\"')) {
- @@ -529,7 +529,7 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring)
-
- // This function returns whether it has crossed a newline or not.
- // It therefore always return true if stop_at_newline is true
- -STATIC bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) {
- +static bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) {
- while (!is_end(lex)) {
- if (is_physical_newline(lex)) {
- if (stop_at_newline && lex->nested_bracket_level == 0) {
- diff --git a/py/malloc.c b/py/malloc.c
- index ddf139e38..f557ade44 100644
- --- a/py/malloc.c
- +++ b/py/malloc.c
- @@ -69,7 +69,7 @@
- #error MICROPY_ENABLE_FINALISER requires MICROPY_ENABLE_GC
- #endif
-
- -STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
- +static void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
- if (allow_move) {
- return realloc(ptr, n_bytes);
- } else {
- @@ -221,7 +221,7 @@ typedef struct _m_tracked_node_t {
- } m_tracked_node_t;
-
- #if MICROPY_DEBUG_VERBOSE
- -STATIC size_t m_tracked_count_links(size_t *nb) {
- +static size_t m_tracked_count_links(size_t *nb) {
- m_tracked_node_t *node = MP_STATE_VM(m_tracked_head);
- size_t n = 0;
- *nb = 0;
- diff --git a/py/map.c b/py/map.c
- index c18df5a9f..d40e3dc4d 100644
- --- a/py/map.c
- +++ b/py/map.c
- @@ -65,14 +65,14 @@
- // The first set of sizes are chosen so the allocation fits exactly in a
- // 4-word GC block, and it's not so important for these small values to be
- // prime. The latter sizes are prime and increase at an increasing rate.
- -STATIC const uint16_t hash_allocation_sizes[] = {
- +static const uint16_t hash_allocation_sizes[] = {
- 0, 2, 4, 6, 8, 10, 12, // +2
- 17, 23, 29, 37, 47, 59, 73, // *1.25
- 97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, // *1.33
- 3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907, // *1.5
- };
-
- -STATIC size_t get_hash_alloc_greater_or_equal_to(size_t x) {
- +static size_t get_hash_alloc_greater_or_equal_to(size_t x) {
- for (size_t i = 0; i < MP_ARRAY_SIZE(hash_allocation_sizes); i++) {
- if (hash_allocation_sizes[i] >= x) {
- return hash_allocation_sizes[i];
- @@ -128,7 +128,7 @@ void mp_map_clear(mp_map_t *map) {
- map->table = NULL;
- }
-
- -STATIC void mp_map_rehash(mp_map_t *map) {
- +static void mp_map_rehash(mp_map_t *map) {
- size_t old_alloc = map->alloc;
- size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1);
- DEBUG_printf("mp_map_rehash(%p): " UINT_FMT " -> " UINT_FMT "\n", map, old_alloc, new_alloc);
- @@ -332,7 +332,7 @@ void mp_set_init(mp_set_t *set, size_t n) {
- set->table = m_new0(mp_obj_t, set->alloc);
- }
-
- -STATIC void mp_set_rehash(mp_set_t *set) {
- +static void mp_set_rehash(mp_set_t *set) {
- size_t old_alloc = set->alloc;
- mp_obj_t *old_table = set->table;
- set->alloc = get_hash_alloc_greater_or_equal_to(set->alloc + 1);
- diff --git a/py/misc.h b/py/misc.h
- index e19a53572..eea3e8b0f 100644
- --- a/py/misc.h
- +++ b/py/misc.h
- @@ -79,13 +79,6 @@ typedef unsigned int uint;
- #define m_new_obj_var(obj_type, var_field, var_type, var_num) ((obj_type *)m_malloc(offsetof(obj_type, var_field) + sizeof(var_type) * (var_num)))
- #define m_new_obj_var0(obj_type, var_field, var_type, var_num) ((obj_type *)m_malloc0(offsetof(obj_type, var_field) + sizeof(var_type) * (var_num)))
- #define m_new_obj_var_maybe(obj_type, var_field, var_type, var_num) ((obj_type *)m_malloc_maybe(offsetof(obj_type, var_field) + sizeof(var_type) * (var_num)))
- -#if MICROPY_ENABLE_FINALISER
- -#define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type))))
- -#define m_new_obj_var_with_finaliser(type, var_field, var_type, var_num) ((type *)m_malloc_with_finaliser(offsetof(type, var_field) + sizeof(var_type) * (var_num)))
- -#else
- -#define m_new_obj_with_finaliser(type) m_new_obj(type)
- -#define m_new_obj_var_with_finaliser(type, var_field, var_type, var_num) m_new_obj_var(type, var_field, var_type, var_num)
- -#endif
- #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
- #define m_renew(type, ptr, old_num, new_num) ((type *)(m_realloc((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num))))
- #define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type *)(m_realloc_maybe((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num), (allow_move))))
- diff --git a/py/modarray.c b/py/modarray.c
- index ac2e56ed3..116c844e8 100644
- --- a/py/modarray.c
- +++ b/py/modarray.c
- @@ -28,12 +28,12 @@
-
- #if MICROPY_PY_ARRAY
-
- -STATIC const mp_rom_map_elem_t mp_module_array_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_array_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_array) },
- { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_type_array) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table);
-
- const mp_obj_module_t mp_module_array = {
- .base = { &mp_type_module },
- diff --git a/py/modbuiltins.c b/py/modbuiltins.c
- index 4ff7d4450..51cf3137b 100644
- --- a/py/modbuiltins.c
- +++ b/py/modbuiltins.c
- @@ -46,7 +46,7 @@ extern struct _mp_dummy_t mp_sys_stdout_obj; // type is irrelevant, just need po
- // args[0] is function from class body
- // args[1] is class name
- // args[2:] are base objects
- -STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) {
- assert(2 <= n_args);
-
- // set the new classes __locals__ object
- @@ -88,12 +88,12 @@ STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args)
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__);
-
- -STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
- return mp_unary_op(MP_UNARY_OP_ABS, o_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
-
- -STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_all(mp_obj_t o_in) {
- mp_obj_iter_buf_t iter_buf;
- mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
- mp_obj_t item;
- @@ -106,7 +106,7 @@ STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
-
- -STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_any(mp_obj_t o_in) {
- mp_obj_iter_buf_t iter_buf;
- mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
- mp_obj_t item;
- @@ -119,13 +119,13 @@ STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);
-
- -STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
- mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in };
- return mp_obj_str_format(MP_ARRAY_SIZE(args), args, NULL);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin);
-
- -STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
- if (mp_obj_is_callable(o_in)) {
- return mp_const_true;
- } else {
- @@ -134,7 +134,7 @@ STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
-
- -STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
- #if MICROPY_PY_BUILTINS_STR_UNICODE
- mp_uint_t c = mp_obj_get_int(o_in);
- if (c >= 0x110000) {
- @@ -155,7 +155,7 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);
-
- -STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
- mp_obj_t dir = mp_obj_new_list(0, NULL);
- if (n_args == 0) {
- // Make a list of names in the local namespace
- @@ -188,18 +188,18 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir);
-
- -STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
- +static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
- return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod);
-
- -STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
- // result is guaranteed to be a (small) int
- return mp_unary_op(MP_UNARY_OP_HASH, o_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
-
- -STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
- #if MICROPY_PY_BUILTINS_STR_OP_MODULO
- return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in);
- #else
- @@ -219,7 +219,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
- #define mp_hal_readline readline
- #endif
-
- -STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
- if (n_args == 1) {
- mp_obj_print(args[0], PRINT_STR);
- }
- @@ -238,14 +238,14 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input
-
- #endif
-
- -STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
- return mp_getiter(o_in, NULL);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
-
- #if MICROPY_PY_BUILTINS_MIN_MAX
-
- -STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
- +static mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
- mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP);
- mp_map_elem_t *default_elem;
- mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value;
- @@ -287,12 +287,12 @@ STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t
- }
- }
-
- -STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- +static mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE);
- }
- MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max);
-
- -STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- +static mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS);
- }
- MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
- @@ -300,7 +300,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
- #endif
-
- #if MICROPY_PY_BUILTINS_NEXT2
- -STATIC mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
- if (n_args == 1) {
- mp_obj_t ret = mp_iternext_allow_raise(args[0]);
- if (ret == MP_OBJ_STOP_ITERATION) {
- @@ -315,7 +315,7 @@ STATIC mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_next_obj, 1, 2, mp_builtin_next);
- #else
- -STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
- +static mp_obj_t mp_builtin_next(mp_obj_t o) {
- mp_obj_t ret = mp_iternext_allow_raise(o);
- if (ret == MP_OBJ_STOP_ITERATION) {
- mp_raise_StopIteration(MP_STATE_THREAD(stop_iteration_arg));
- @@ -326,7 +326,7 @@ STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
- #endif
-
- -STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
- #if MICROPY_PY_BUILTINS_STR_OP_MODULO
- return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in);
- #else
- @@ -336,7 +336,7 @@ STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
-
- -STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
- size_t len;
- const byte *str = (const byte *)mp_obj_str_get_data(o_in, &len);
- #if MICROPY_PY_BUILTINS_STR_UNICODE
- @@ -363,7 +363,7 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
-
- -STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
- switch (n_args) {
- case 2:
- return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
- @@ -379,7 +379,7 @@ STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
-
- -STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- +static mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- enum { ARG_sep, ARG_end, ARG_file };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_sep, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR__space_)} },
- @@ -430,7 +430,7 @@ STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map
- }
- MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print);
-
- -STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
- +static mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
- if (o != mp_const_none) {
- mp_obj_print_helper(MP_PYTHON_PRINTER, o, PRINT_REPR);
- mp_print_str(MP_PYTHON_PRINTER, "\n");
- @@ -444,7 +444,7 @@ STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__);
-
- -STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
- +static mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
- vstr_t vstr;
- mp_print_t print;
- vstr_init_print(&vstr, 16, &print);
- @@ -453,7 +453,7 @@ STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);
-
- -STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
- mp_obj_t o_in = args[0];
- if (mp_obj_is_int(o_in)) {
- if (n_args <= 1) {
- @@ -505,7 +505,7 @@ STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round);
-
- -STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
- mp_obj_t value;
- switch (n_args) {
- case 1:
- @@ -525,7 +525,7 @@ STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);
-
- -STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- +static mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- if (n_args > 1) {
- mp_raise_TypeError(MP_ERROR_TEXT("must use keyword argument for key function"));
- }
- @@ -556,7 +556,7 @@ static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t d
- }
- }
-
- -STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
- mp_obj_t defval = MP_OBJ_NULL;
- if (n_args > 2) {
- defval = args[2];
- @@ -565,20 +565,20 @@ STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr);
-
- -STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) {
- +static mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) {
- mp_store_attr(base, mp_obj_str_get_qstr(attr), value);
- return mp_const_none;
- }
- MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr);
-
- #if MICROPY_CPYTHON_COMPAT
- -STATIC mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
- +static mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
- return mp_builtin_setattr(base, attr, MP_OBJ_NULL);
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj, mp_builtin_delattr);
- #endif
-
- -STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
- +static mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
- qstr attr = mp_obj_str_get_qstr(attr_in);
- mp_obj_t dest[2];
- mp_load_method_protected(object_in, attr, dest, false);
- @@ -586,12 +586,12 @@ STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr);
-
- -STATIC mp_obj_t mp_builtin_globals(void) {
- +static mp_obj_t mp_builtin_globals(void) {
- return MP_OBJ_FROM_PTR(mp_globals_get());
- }
- MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_globals_obj, mp_builtin_globals);
-
- -STATIC mp_obj_t mp_builtin_locals(void) {
- +static mp_obj_t mp_builtin_locals(void) {
- return MP_OBJ_FROM_PTR(mp_locals_get());
- }
- MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals);
- @@ -600,7 +600,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals);
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_obj_id);
- MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_obj_len);
-
- -STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_builtins) },
-
- // built-in core functions
- diff --git a/py/modcmath.c b/py/modcmath.c
- index 1418362ad..33cb00cbe 100644
- --- a/py/modcmath.c
- +++ b/py/modcmath.c
- @@ -31,15 +31,15 @@
- #include <math.h>
-
- // phase(z): returns the phase of the number z in the range (-pi, +pi]
- -STATIC mp_obj_t mp_cmath_phase(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_phase(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- return mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase);
-
- // polar(z): returns the polar form of z as a tuple
- -STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- mp_obj_t tuple[2] = {
- @@ -48,71 +48,71 @@ STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
- };
- return mp_obj_new_tuple(2, tuple);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar);
-
- // rect(r, phi): returns the complex number with modulus r and phase phi
- -STATIC mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) {
- +static mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) {
- mp_float_t r = mp_obj_get_float(r_obj);
- mp_float_t phi = mp_obj_get_float(phi_obj);
- return mp_obj_new_complex(r * MICROPY_FLOAT_C_FUN(cos)(phi), r * MICROPY_FLOAT_C_FUN(sin)(phi));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect);
- +static MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect);
-
- // exp(z): return the exponential of z
- -STATIC mp_obj_t mp_cmath_exp(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_exp(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- mp_float_t exp_real = MICROPY_FLOAT_C_FUN(exp)(real);
- return mp_obj_new_complex(exp_real * MICROPY_FLOAT_C_FUN(cos)(imag), exp_real * MICROPY_FLOAT_C_FUN(sin)(imag));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp);
-
- // log(z): return the natural logarithm of z, with branch cut along the negative real axis
- // TODO can take second argument, being the base
- -STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- return mp_obj_new_complex(MICROPY_FLOAT_CONST(0.5) * MICROPY_FLOAT_C_FUN(log)(real * real + imag * imag), MICROPY_FLOAT_C_FUN(atan2)(imag, real));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
-
- #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
- // log10(z): return the base-10 logarithm of z, with branch cut along the negative real axis
- -STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- return mp_obj_new_complex(MICROPY_FLOAT_CONST(0.5) * MICROPY_FLOAT_C_FUN(log10)(real * real + imag * imag), MICROPY_FLOAT_CONST(0.4342944819032518) * MICROPY_FLOAT_C_FUN(atan2)(imag, real));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
- #endif
-
- // sqrt(z): return the square-root of z
- -STATIC mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real * real + imag * imag, MICROPY_FLOAT_CONST(0.25));
- mp_float_t theta = MICROPY_FLOAT_CONST(0.5) * MICROPY_FLOAT_C_FUN(atan2)(imag, real);
- return mp_obj_new_complex(sqrt_abs * MICROPY_FLOAT_C_FUN(cos)(theta), sqrt_abs * MICROPY_FLOAT_C_FUN(sin)(theta));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt);
-
- // cos(z): return the cosine of z
- -STATIC mp_obj_t mp_cmath_cos(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_cos(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), -MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos);
-
- // sin(z): return the sine of z
- -STATIC mp_obj_t mp_cmath_sin(mp_obj_t z_obj) {
- +static mp_obj_t mp_cmath_sin(mp_obj_t z_obj) {
- mp_float_t real, imag;
- mp_obj_get_complex(z_obj, &real, &imag);
- return mp_obj_new_complex(MICROPY_FLOAT_C_FUN(sin)(real) * MICROPY_FLOAT_C_FUN(cosh)(imag), MICROPY_FLOAT_C_FUN(cos)(real) * MICROPY_FLOAT_C_FUN(sinh)(imag));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin);
-
- -STATIC const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cmath) },
- { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e },
- { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi },
- @@ -142,7 +142,7 @@ STATIC const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
- // { MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_cmath_isnan_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table);
-
- const mp_obj_module_t mp_module_cmath = {
- .base = { &mp_type_module },
- diff --git a/py/modcollections.c b/py/modcollections.c
- index 30a5881bc..46326d13e 100644
- --- a/py/modcollections.c
- +++ b/py/modcollections.c
- @@ -28,7 +28,7 @@
-
- #if MICROPY_PY_COLLECTIONS
-
- -STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_collections) },
- #if MICROPY_PY_COLLECTIONS_DEQUE
- { MP_ROM_QSTR(MP_QSTR_deque), MP_ROM_PTR(&mp_type_deque) },
- @@ -39,7 +39,7 @@ STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table);
-
- const mp_obj_module_t mp_module_collections = {
- .base = { &mp_type_module },
- diff --git a/py/moderrno.c b/py/moderrno.c
- index 4f0673a23..58a141c10 100644
- --- a/py/moderrno.c
- +++ b/py/moderrno.c
- @@ -62,13 +62,13 @@
- #endif
-
- #if MICROPY_PY_ERRNO_ERRORCODE
- -STATIC const mp_rom_map_elem_t errorcode_table[] = {
- +static const mp_rom_map_elem_t errorcode_table[] = {
- #define X(e) { MP_ROM_INT(MP_##e), MP_ROM_QSTR(MP_QSTR_##e) },
- MICROPY_PY_ERRNO_LIST
- #undef X
- };
-
- -STATIC const mp_obj_dict_t errorcode_dict = {
- +static const mp_obj_dict_t errorcode_dict = {
- .base = {&mp_type_dict},
- .map = {
- .all_keys_are_qstrs = 0, // keys are integers
- @@ -81,7 +81,7 @@ STATIC const mp_obj_dict_t errorcode_dict = {
- };
- #endif
-
- -STATIC const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_errno) },
- #if MICROPY_PY_ERRNO_ERRORCODE
- { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) },
- @@ -92,7 +92,7 @@ STATIC const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
- #undef X
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_errno_globals, mp_module_errno_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_errno_globals, mp_module_errno_globals_table);
-
- const mp_obj_module_t mp_module_errno = {
- .base = { &mp_type_module },
- diff --git a/py/modgc.c b/py/modgc.c
- index 7b18045b0..47902d8c9 100644
- --- a/py/modgc.c
- +++ b/py/modgc.c
- @@ -31,7 +31,7 @@
- #if MICROPY_PY_GC && MICROPY_ENABLE_GC
-
- // collect(): run a garbage collection
- -STATIC mp_obj_t py_gc_collect(void) {
- +static mp_obj_t py_gc_collect(void) {
- gc_collect();
- #if MICROPY_PY_GC_COLLECT_RETVAL
- return MP_OBJ_NEW_SMALL_INT(MP_STATE_MEM(gc_collected));
- @@ -42,26 +42,26 @@ STATIC mp_obj_t py_gc_collect(void) {
- MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect);
-
- // disable(): disable the garbage collector
- -STATIC mp_obj_t gc_disable(void) {
- +static mp_obj_t gc_disable(void) {
- MP_STATE_MEM(gc_auto_collect_enabled) = 0;
- return mp_const_none;
- }
- MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable);
-
- // enable(): enable the garbage collector
- -STATIC mp_obj_t gc_enable(void) {
- +static mp_obj_t gc_enable(void) {
- MP_STATE_MEM(gc_auto_collect_enabled) = 1;
- return mp_const_none;
- }
- MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable);
-
- -STATIC mp_obj_t gc_isenabled(void) {
- +static mp_obj_t gc_isenabled(void) {
- return mp_obj_new_bool(MP_STATE_MEM(gc_auto_collect_enabled));
- }
- MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled);
-
- // mem_free(): return the number of bytes of available heap RAM
- -STATIC mp_obj_t gc_mem_free(void) {
- +static mp_obj_t gc_mem_free(void) {
- gc_info_t info;
- gc_info(&info);
- #if MICROPY_GC_SPLIT_HEAP_AUTO
- @@ -74,7 +74,7 @@ STATIC mp_obj_t gc_mem_free(void) {
- MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_free_obj, gc_mem_free);
-
- // mem_alloc(): return the number of bytes of heap RAM that are allocated
- -STATIC mp_obj_t gc_mem_alloc(void) {
- +static mp_obj_t gc_mem_alloc(void) {
- gc_info_t info;
- gc_info(&info);
- return MP_OBJ_NEW_SMALL_INT(info.used);
- @@ -82,7 +82,7 @@ STATIC mp_obj_t gc_mem_alloc(void) {
- MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_alloc_obj, gc_mem_alloc);
-
- #if MICROPY_GC_ALLOC_THRESHOLD
- -STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
- if (n_args == 0) {
- if (MP_STATE_MEM(gc_alloc_threshold) == (size_t)-1) {
- return MP_OBJ_NEW_SMALL_INT(-1);
- @@ -100,7 +100,7 @@ STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gc_threshold_obj, 0, 1, gc_threshold);
- #endif
-
- -STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gc) },
- { MP_ROM_QSTR(MP_QSTR_collect), MP_ROM_PTR(&gc_collect_obj) },
- { MP_ROM_QSTR(MP_QSTR_disable), MP_ROM_PTR(&gc_disable_obj) },
- @@ -113,7 +113,7 @@ STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
-
- const mp_obj_module_t mp_module_gc = {
- .base = { &mp_type_module },
- diff --git a/py/modio.c b/py/modio.c
- index 39317c52d..d3e563dbc 100644
- --- a/py/modio.c
- +++ b/py/modio.c
- @@ -39,11 +39,11 @@
-
- #if MICROPY_PY_IO_IOBASE
-
- -STATIC const mp_obj_type_t mp_type_iobase;
- +static const mp_obj_type_t mp_type_iobase;
-
- -STATIC const mp_obj_base_t iobase_singleton = {&mp_type_iobase};
- +static const mp_obj_base_t iobase_singleton = {&mp_type_iobase};
-
- -STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type;
- (void)n_args;
- (void)n_kw;
- @@ -51,7 +51,7 @@ STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t
- return MP_OBJ_FROM_PTR(&iobase_singleton);
- }
-
- -STATIC mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode, qstr qst) {
- +static mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode, qstr qst) {
- mp_obj_t dest[3];
- mp_load_method(obj, qst, dest);
- mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, size, buf};
- @@ -69,15 +69,15 @@ STATIC mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int
- return MP_STREAM_ERROR;
- }
- }
- -STATIC mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
- +static mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
- return iobase_read_write(obj, buf, size, errcode, MP_QSTR_readinto);
- }
-
- -STATIC mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
- +static mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
- return iobase_read_write(obj, (void *)buf, size, errcode, MP_QSTR_write);
- }
-
- -STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
- +static mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
- mp_obj_t dest[4];
- mp_load_method(obj, MP_QSTR_ioctl, dest);
- dest[2] = mp_obj_new_int_from_uint(request);
- @@ -91,13 +91,13 @@ STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, in
- }
- }
-
- -STATIC const mp_stream_p_t iobase_p = {
- +static const mp_stream_p_t iobase_p = {
- .read = iobase_read,
- .write = iobase_write,
- .ioctl = iobase_ioctl,
- };
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_iobase,
- MP_QSTR_IOBase,
- MP_TYPE_FLAG_NONE,
- @@ -116,17 +116,17 @@ typedef struct _mp_obj_bufwriter_t {
- byte buf[0];
- } mp_obj_bufwriter_t;
-
- -STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 2, 2, false);
- size_t alloc = mp_obj_get_int(args[1]);
- - mp_obj_bufwriter_t *o = mp_obj_malloc_var(mp_obj_bufwriter_t, byte, alloc, type);
- + mp_obj_bufwriter_t *o = mp_obj_malloc_var(mp_obj_bufwriter_t, buf, byte, alloc, type);
- o->stream = args[0];
- o->alloc = alloc;
- o->len = 0;
- return o;
- }
-
- -STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
- +static mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
- mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in);
-
- mp_uint_t org_size = size;
- @@ -162,7 +162,7 @@ STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t si
- return org_size;
- }
-
- -STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) {
- +static mp_obj_t bufwriter_flush(mp_obj_t self_in) {
- mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in);
-
- if (self->len != 0) {
- @@ -180,19 +180,19 @@ STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) {
-
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush);
- +static MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush);
-
- -STATIC const mp_rom_map_elem_t bufwriter_locals_dict_table[] = {
- +static const mp_rom_map_elem_t bufwriter_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
- { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&bufwriter_flush_obj) },
- };
- -STATIC MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table);
-
- -STATIC const mp_stream_p_t bufwriter_stream_p = {
- +static const mp_stream_p_t bufwriter_stream_p = {
- .write = bufwriter_write,
- };
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_bufwriter,
- MP_QSTR_BufferedWriter,
- MP_TYPE_FLAG_NONE,
- @@ -202,7 +202,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
- );
- #endif // MICROPY_PY_IO_BUFFEREDWRITER
-
- -STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_io_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io) },
- // Note: mp_builtin_open_obj should be defined by port, it's not
- // part of the core.
- @@ -219,7 +219,7 @@ STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
-
- const mp_obj_module_t mp_module_io = {
- .base = { &mp_type_module },
- diff --git a/py/modmath.c b/py/modmath.c
- index 861a23b48..db30f0e62 100644
- --- a/py/modmath.c
- +++ b/py/modmath.c
- @@ -37,11 +37,11 @@
- #define MP_PI_4 MICROPY_FLOAT_CONST(0.78539816339744830962)
- #define MP_3_PI_4 MICROPY_FLOAT_CONST(2.35619449019234492885)
-
- -STATIC NORETURN void math_error(void) {
- +static NORETURN void math_error(void) {
- mp_raise_ValueError(MP_ERROR_TEXT("math domain error"));
- }
-
- -STATIC mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
- +static mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
- mp_float_t x = mp_obj_get_float(x_obj);
- mp_float_t ans = f(x);
- if ((isnan(ans) && !isnan(x)) || (isinf(ans) && !isinf(x))) {
- @@ -50,7 +50,7 @@ STATIC mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
- return mp_obj_new_float(ans);
- }
-
- -STATIC mp_obj_t math_generic_2(mp_obj_t x_obj, mp_obj_t y_obj, mp_float_t (*f)(mp_float_t, mp_float_t)) {
- +static mp_obj_t math_generic_2(mp_obj_t x_obj, mp_obj_t y_obj, mp_float_t (*f)(mp_float_t, mp_float_t)) {
- mp_float_t x = mp_obj_get_float(x_obj);
- mp_float_t y = mp_obj_get_float(y_obj);
- mp_float_t ans = f(x, y);
- @@ -61,30 +61,30 @@ STATIC mp_obj_t math_generic_2(mp_obj_t x_obj, mp_obj_t y_obj, mp_float_t (*f)(m
- }
-
- #define MATH_FUN_1(py_name, c_name) \
- - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \
- + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \
- return math_generic_1(x_obj, MICROPY_FLOAT_C_FUN(c_name)); \
- } \
- - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
- + static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
-
- #define MATH_FUN_1_TO_BOOL(py_name, c_name) \
- - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
- - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
- + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
- + static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
-
- #define MATH_FUN_1_TO_INT(py_name, c_name) \
- - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
- - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
- + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
- + static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
-
- #define MATH_FUN_2(py_name, c_name) \
- - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
- + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
- return math_generic_2(x_obj, y_obj, MICROPY_FLOAT_C_FUN(c_name)); \
- } \
- - STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
- + static MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
-
- #define MATH_FUN_2_FLT_INT(py_name, c_name) \
- - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
- + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
- return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_int(y_obj))); \
- } \
- - STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
- + static MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
-
- #if MP_NEED_LOG2
- #undef log2
- @@ -160,12 +160,12 @@ MATH_FUN_2(atan2, atan2)
- // ceil(x)
- MATH_FUN_1_TO_INT(ceil, ceil)
- // copysign(x, y)
- -STATIC mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
- +static mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
- return MICROPY_FLOAT_C_FUN(copysign)(x, y);
- }
- MATH_FUN_2(copysign, copysign_func)
- // fabs(x)
- -STATIC mp_float_t MICROPY_FLOAT_C_FUN(fabs_func)(mp_float_t x) {
- +static mp_float_t MICROPY_FLOAT_C_FUN(fabs_func)(mp_float_t x) {
- return MICROPY_FLOAT_C_FUN(fabs)(x);
- }
- MATH_FUN_1(fabs, fabs_func)
- @@ -203,7 +203,7 @@ MATH_FUN_1(lgamma, lgamma)
- // TODO: fsum
-
- #if MICROPY_PY_MATH_ISCLOSE
- -STATIC mp_obj_t mp_math_isclose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- +static mp_obj_t mp_math_isclose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- enum { ARG_rel_tol, ARG_abs_tol };
- static const mp_arg_t allowed_args[] = {
- {MP_QSTR_rel_tol, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}},
- @@ -239,7 +239,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_math_isclose_obj, 2, mp_math_isclose);
- // Function that takes a variable number of arguments
-
- // log(x[, base])
- -STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
- mp_float_t x = mp_obj_get_float(args[0]);
- if (x <= (mp_float_t)0.0) {
- math_error();
- @@ -257,12 +257,12 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
- return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
- }
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log);
-
- // Functions that return a tuple
-
- // frexp(x): converts a floating-point number to fractional and integral components
- -STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
- +static mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
- int int_exponent = 0;
- mp_float_t significand = MICROPY_FLOAT_C_FUN(frexp)(mp_obj_get_float(x_obj), &int_exponent);
- mp_obj_t tuple[2];
- @@ -270,10 +270,10 @@ STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
- tuple[1] = mp_obj_new_int(int_exponent);
- return mp_obj_new_tuple(2, tuple);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp);
-
- // modf(x)
- -STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) {
- +static mp_obj_t mp_math_modf(mp_obj_t x_obj) {
- mp_float_t int_part = 0.0;
- mp_float_t x = mp_obj_get_float(x_obj);
- mp_float_t fractional_part = MICROPY_FLOAT_C_FUN(modf)(x, &int_part);
- @@ -287,28 +287,28 @@ STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) {
- tuple[1] = mp_obj_new_float(int_part);
- return mp_obj_new_tuple(2, tuple);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf);
-
- // Angular conversions
-
- // radians(x)
- -STATIC mp_obj_t mp_math_radians(mp_obj_t x_obj) {
- +static mp_obj_t mp_math_radians(mp_obj_t x_obj) {
- return mp_obj_new_float(mp_obj_get_float(x_obj) * (MP_PI / MICROPY_FLOAT_CONST(180.0)));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians);
-
- // degrees(x)
- -STATIC mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
- +static mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
- return mp_obj_new_float(mp_obj_get_float(x_obj) * (MICROPY_FLOAT_CONST(180.0) / MP_PI));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees);
-
- #if MICROPY_PY_MATH_FACTORIAL
-
- #if MICROPY_OPT_MATH_FACTORIAL
-
- // factorial(x): slightly efficient recursive implementation
- -STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
- +static mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
- if (start == end) {
- return mp_obj_new_int(start);
- } else if (end - start == 1) {
- @@ -326,7 +326,7 @@ STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
- return mp_binary_op(MP_BINARY_OP_MULTIPLY, left, right);
- }
- }
- -STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
- +static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
- mp_int_t max = mp_obj_get_int(x_obj);
- if (max < 0) {
- mp_raise_ValueError(MP_ERROR_TEXT("negative factorial"));
- @@ -340,7 +340,7 @@ STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
-
- // factorial(x): squared difference implementation
- // based on http://www.luschny.de/math/factorial/index.html
- -STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
- +static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
- mp_int_t max = mp_obj_get_int(x_obj);
- if (max < 0) {
- mp_raise_ValueError(MP_ERROR_TEXT("negative factorial"));
- @@ -363,11 +363,11 @@ STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
-
- #endif
-
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_factorial_obj, mp_math_factorial);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_factorial_obj, mp_math_factorial);
-
- #endif
-
- -STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_math_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_math) },
- { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e },
- { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi },
- @@ -428,7 +428,7 @@ STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table);
-
- const mp_obj_module_t mp_module_math = {
- .base = { &mp_type_module },
- diff --git a/py/modmicropython.c b/py/modmicropython.c
- index bdb1e8b9b..af6ad0179 100644
- --- a/py/modmicropython.c
- +++ b/py/modmicropython.c
- @@ -38,7 +38,7 @@
- // living in micropython module
-
- #if MICROPY_ENABLE_COMPILER
- -STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
- if (n_args == 0) {
- return MP_OBJ_NEW_SMALL_INT(MP_STATE_VM(mp_optimise_value));
- } else {
- @@ -46,26 +46,26 @@ STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
- return mp_const_none;
- }
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level);
- #endif
-
- #if MICROPY_PY_MICROPYTHON_MEM_INFO
-
- #if MICROPY_MEM_STATS
- -STATIC mp_obj_t mp_micropython_mem_total(void) {
- +static mp_obj_t mp_micropython_mem_total(void) {
- return MP_OBJ_NEW_SMALL_INT(m_get_total_bytes_allocated());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total);
-
- -STATIC mp_obj_t mp_micropython_mem_current(void) {
- +static mp_obj_t mp_micropython_mem_current(void) {
- return MP_OBJ_NEW_SMALL_INT(m_get_current_bytes_allocated());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current);
-
- -STATIC mp_obj_t mp_micropython_mem_peak(void) {
- +static mp_obj_t mp_micropython_mem_peak(void) {
- return MP_OBJ_NEW_SMALL_INT(m_get_peak_bytes_allocated());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak);
- #endif
-
- mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
- @@ -91,9 +91,9 @@ mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
- #endif
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info);
-
- -STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
- (void)args;
- size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
- qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
- @@ -105,68 +105,68 @@ STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
- }
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info);
-
- #endif // MICROPY_PY_MICROPYTHON_MEM_INFO
-
- #if MICROPY_PY_MICROPYTHON_STACK_USE
- -STATIC mp_obj_t mp_micropython_stack_use(void) {
- +static mp_obj_t mp_micropython_stack_use(void) {
- return MP_OBJ_NEW_SMALL_INT(mp_stack_usage());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use);
- #endif
-
- #if MICROPY_ENABLE_PYSTACK
- -STATIC mp_obj_t mp_micropython_pystack_use(void) {
- +static mp_obj_t mp_micropython_pystack_use(void) {
- return MP_OBJ_NEW_SMALL_INT(mp_pystack_usage());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_pystack_use_obj, mp_micropython_pystack_use);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_pystack_use_obj, mp_micropython_pystack_use);
- #endif
-
- #if MICROPY_ENABLE_GC
- -STATIC mp_obj_t mp_micropython_heap_lock(void) {
- +static mp_obj_t mp_micropython_heap_lock(void) {
- gc_lock();
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock);
-
- -STATIC mp_obj_t mp_micropython_heap_unlock(void) {
- +static mp_obj_t mp_micropython_heap_unlock(void) {
- gc_unlock();
- return MP_OBJ_NEW_SMALL_INT(MP_STATE_THREAD(gc_lock_depth));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock);
-
- #if MICROPY_PY_MICROPYTHON_HEAP_LOCKED
- -STATIC mp_obj_t mp_micropython_heap_locked(void) {
- +static mp_obj_t mp_micropython_heap_locked(void) {
- return MP_OBJ_NEW_SMALL_INT(MP_STATE_THREAD(gc_lock_depth));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_locked_obj, mp_micropython_heap_locked);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_locked_obj, mp_micropython_heap_locked);
- #endif
- #endif
-
- #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0)
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf);
- #endif
-
- #if MICROPY_KBD_EXCEPTION
- -STATIC mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) {
- +static mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) {
- mp_hal_set_interrupt_char(mp_obj_get_int(int_chr_in));
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr);
- #endif
-
- #if MICROPY_ENABLE_SCHEDULER
- -STATIC mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
- +static mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
- if (!mp_sched_schedule(function, arg)) {
- mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("schedule queue full"));
- }
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
- +static MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
- #endif
-
- -STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_micropython) },
- { MP_ROM_QSTR(MP_QSTR_const), MP_ROM_PTR(&mp_identity_obj) },
- #if MICROPY_ENABLE_COMPILER
- @@ -205,7 +205,7 @@ STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table);
-
- const mp_obj_module_t mp_module_micropython = {
- .base = { &mp_type_module },
- diff --git a/py/modstruct.c b/py/modstruct.c
- index b3edc9632..3b9dd30aa 100644
- --- a/py/modstruct.c
- +++ b/py/modstruct.c
- @@ -52,7 +52,7 @@
- character data".
- */
-
- -STATIC char get_fmt_type(const char **fmt) {
- +static char get_fmt_type(const char **fmt) {
- char t = **fmt;
- switch (t) {
- case '!':
- @@ -71,7 +71,7 @@ STATIC char get_fmt_type(const char **fmt) {
- return t;
- }
-
- -STATIC mp_uint_t get_fmt_num(const char **p) {
- +static mp_uint_t get_fmt_num(const char **p) {
- const char *num = *p;
- uint len = 1;
- while (unichar_isdigit(*++num)) {
- @@ -82,7 +82,7 @@ STATIC mp_uint_t get_fmt_num(const char **p) {
- return val;
- }
-
- -STATIC size_t calc_size_items(const char *fmt, size_t *total_sz) {
- +static size_t calc_size_items(const char *fmt, size_t *total_sz) {
- char fmt_type = get_fmt_type(&fmt);
- size_t total_cnt = 0;
- size_t size;
- @@ -112,7 +112,7 @@ STATIC size_t calc_size_items(const char *fmt, size_t *total_sz) {
- return total_cnt;
- }
-
- -STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
- +static mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
- const char *fmt = mp_obj_str_get_str(fmt_in);
- size_t size;
- calc_size_items(fmt, &size);
- @@ -120,7 +120,7 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
-
- -STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
- // unpack requires that the buffer be exactly the right size.
- // unpack_from requires that the buffer be "big enough".
- // Since we implement unpack and unpack_from using the same function
- @@ -180,7 +180,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_from);
-
- // This function assumes there is enough room in p to store all the values
- -STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
- +static void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
- const char *fmt = mp_obj_str_get_str(fmt_in);
- char fmt_type = get_fmt_type(&fmt);
-
- @@ -219,7 +219,7 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c
- }
- }
-
- -STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
- // TODO: "The arguments must match the values required by the format exactly."
- mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0]));
- vstr_t vstr;
- @@ -231,7 +231,7 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack);
-
- -STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
- mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
- mp_int_t offset = mp_obj_get_int(args[2]);
- @@ -257,7 +257,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into);
-
- -STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_struct) },
- { MP_ROM_QSTR(MP_QSTR_calcsize), MP_ROM_PTR(&struct_calcsize_obj) },
- { MP_ROM_QSTR(MP_QSTR_pack), MP_ROM_PTR(&struct_pack_obj) },
- @@ -266,7 +266,7 @@ STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR_unpack_from), MP_ROM_PTR(&struct_unpack_from_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table);
-
- const mp_obj_module_t mp_module_struct = {
- .base = { &mp_type_module },
- diff --git a/py/modsys.c b/py/modsys.c
- index 2af81046f..e90ea2233 100644
- --- a/py/modsys.c
- +++ b/py/modsys.c
- @@ -56,15 +56,15 @@ const mp_print_t mp_sys_stdout_print = {&mp_sys_stdout_obj, mp_stream_write_adap
- #endif
-
- // version - Python language version that this implementation conforms to, as a string
- -STATIC const MP_DEFINE_STR_OBJ(mp_sys_version_obj, "3.4.0; " MICROPY_BANNER_NAME_AND_VERSION);
- +static const MP_DEFINE_STR_OBJ(mp_sys_version_obj, "3.4.0; " MICROPY_BANNER_NAME_AND_VERSION);
-
- // version_info - Python language version that this implementation conforms to, as a tuple of ints
- // TODO: CPython is now at 5-element array (major, minor, micro, releaselevel, serial), but save 2 els so far...
- -STATIC const mp_rom_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {MP_ROM_INT(3), MP_ROM_INT(4), MP_ROM_INT(0)}};
- +static const mp_rom_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {MP_ROM_INT(3), MP_ROM_INT(4), MP_ROM_INT(0)}};
-
- // sys.implementation object
- // this holds the MicroPython version
- -STATIC const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
- +static const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
- {&mp_type_tuple},
- 4,
- {
- @@ -78,7 +78,7 @@ STATIC const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
- #endif
- }
- };
- -STATIC const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER_MACHINE);
- +static const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER_MACHINE);
- #define SYS_IMPLEMENTATION_ELEMS_BASE \
- MP_ROM_QSTR(MP_QSTR_micropython), \
- MP_ROM_PTR(&mp_sys_implementation_version_info_obj), \
- @@ -99,7 +99,7 @@ STATIC const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER
- #define SYS_IMPLEMENTATION_ELEMS__V2
- #endif
-
- -STATIC const qstr impl_fields[] = {
- +static const qstr impl_fields[] = {
- MP_QSTR_name,
- MP_QSTR_version,
- MP_QSTR__machine,
- @@ -110,7 +110,7 @@ STATIC const qstr impl_fields[] = {
- MP_QSTR__v2,
- #endif
- };
- -STATIC MP_DEFINE_ATTRTUPLE(
- +static MP_DEFINE_ATTRTUPLE(
- mp_sys_implementation_obj,
- impl_fields,
- 3 + MICROPY_PERSISTENT_CODE_LOAD + MICROPY_PREVIEW_VERSION_2,
- @@ -119,7 +119,7 @@ STATIC MP_DEFINE_ATTRTUPLE(
- SYS_IMPLEMENTATION_ELEMS__V2
- );
- #else
- -STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
- +static const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
- {&mp_type_tuple},
- 3 + MICROPY_PERSISTENT_CODE_LOAD,
- // Do not include SYS_IMPLEMENTATION_ELEMS__V2 because
- @@ -138,7 +138,7 @@ STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
-
- #ifdef MICROPY_PY_SYS_PLATFORM
- // platform - the platform that MicroPython is running on
- -STATIC const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM);
- +static const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM);
- #endif
-
- #ifdef MICROPY_PY_SYS_EXECUTABLE
- @@ -152,7 +152,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_intern_obj, mp_obj_str_intern_checked);
- #endif
-
- // exit([retval]): raise SystemExit, with optional argument given to the exception
- -STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
- if (n_args == 0) {
- mp_raise_type(&mp_type_SystemExit);
- } else {
- @@ -161,7 +161,7 @@ STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit);
-
- -STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
- #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
- void *stream_obj = &mp_sys_stdout_obj;
- if (n_args > 1) {
- @@ -181,7 +181,7 @@ STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_print_exception_obj, 1, 2, mp_sys_print_exception);
-
- #if MICROPY_PY_SYS_EXC_INFO
- -STATIC mp_obj_t mp_sys_exc_info(void) {
- +static mp_obj_t mp_sys_exc_info(void) {
- mp_obj_t cur_exc = MP_OBJ_FROM_PTR(MP_STATE_VM(cur_exception));
- mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
-
- @@ -201,25 +201,25 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_exc_info_obj, mp_sys_exc_info);
- #endif
-
- #if MICROPY_PY_SYS_GETSIZEOF
- -STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
- +static mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
- return mp_unary_op(MP_UNARY_OP_SIZEOF, obj);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
- #endif
-
- #if MICROPY_PY_SYS_ATEXIT
- // atexit(callback): Callback is called when sys.exit is called.
- -STATIC mp_obj_t mp_sys_atexit(mp_obj_t obj) {
- +static mp_obj_t mp_sys_atexit(mp_obj_t obj) {
- mp_obj_t old = MP_STATE_VM(sys_exitfunc);
- MP_STATE_VM(sys_exitfunc) = obj;
- return old;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit);
- #endif
-
- #if MICROPY_PY_SYS_SETTRACE
- // settrace(tracefunc): Set the system's trace function.
- -STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) {
- +static mp_obj_t mp_sys_settrace(mp_obj_t obj) {
- return mp_prof_settrace(obj);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace);
- @@ -243,7 +243,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace);
-
- #if MICROPY_PY_SYS_ATTR_DELEGATION
- // Must be kept in sync with the enum at the top of mpstate.h.
- -STATIC const uint16_t sys_mutable_keys[] = {
- +static const uint16_t sys_mutable_keys[] = {
- #if MICROPY_PY_SYS_PATH
- // Code should access this (as an mp_obj_t) for use with e.g.
- // mp_obj_list_append by using the `mp_sys_path` macro defined in runtime.h.
- @@ -266,7 +266,7 @@ void mp_module_sys_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- }
- #endif
-
- -STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys) },
-
- #if MICROPY_PY_SYS_ARGV
- @@ -339,7 +339,7 @@ STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);
-
- const mp_obj_module_t mp_module_sys = {
- .base = { &mp_type_module },
- diff --git a/py/modthread.c b/py/modthread.c
- index 3a8a1e03c..2826fadea 100644
- --- a/py/modthread.c
- +++ b/py/modthread.c
- @@ -45,7 +45,7 @@
- /****************************************************************/
- // Lock object
-
- -STATIC const mp_obj_type_t mp_type_thread_lock;
- +static const mp_obj_type_t mp_type_thread_lock;
-
- typedef struct _mp_obj_thread_lock_t {
- mp_obj_base_t base;
- @@ -53,14 +53,14 @@ typedef struct _mp_obj_thread_lock_t {
- volatile bool locked;
- } mp_obj_thread_lock_t;
-
- -STATIC mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) {
- +static mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) {
- mp_obj_thread_lock_t *self = mp_obj_malloc(mp_obj_thread_lock_t, &mp_type_thread_lock);
- mp_thread_mutex_init(&self->mutex);
- self->locked = false;
- return self;
- }
-
- -STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
- mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(args[0]);
- bool wait = true;
- if (n_args > 1) {
- @@ -79,9 +79,9 @@ STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
- mp_raise_OSError(-ret);
- }
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire);
-
- -STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) {
- +static mp_obj_t thread_lock_release(mp_obj_t self_in) {
- mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in);
- if (!self->locked) {
- mp_raise_msg(&mp_type_RuntimeError, NULL);
- @@ -92,21 +92,21 @@ STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) {
- MP_THREAD_GIL_ENTER();
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release);
- +static MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release);
-
- -STATIC mp_obj_t thread_lock_locked(mp_obj_t self_in) {
- +static mp_obj_t thread_lock_locked(mp_obj_t self_in) {
- mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(self->locked);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked);
- +static MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked);
-
- -STATIC mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) {
- (void)n_args; // unused
- return thread_lock_release(args[0]);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__);
-
- -STATIC const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
- +static const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_acquire), MP_ROM_PTR(&thread_lock_acquire_obj) },
- { MP_ROM_QSTR(MP_QSTR_release), MP_ROM_PTR(&thread_lock_release_obj) },
- { MP_ROM_QSTR(MP_QSTR_locked), MP_ROM_PTR(&thread_lock_locked_obj) },
- @@ -114,9 +114,9 @@ STATIC const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&thread_lock___exit___obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table);
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_thread_lock,
- MP_QSTR_lock,
- MP_TYPE_FLAG_NONE,
- @@ -126,14 +126,14 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
- /****************************************************************/
- // _thread module
-
- -STATIC size_t thread_stack_size = 0;
- +static size_t thread_stack_size = 0;
-
- -STATIC mp_obj_t mod_thread_get_ident(void) {
- +static mp_obj_t mod_thread_get_ident(void) {
- return mp_obj_new_int_from_uint(mp_thread_get_id());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);
-
- -STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
- mp_obj_t ret = mp_obj_new_int_from_uint(thread_stack_size);
- if (n_args == 0) {
- thread_stack_size = 0;
- @@ -142,7 +142,7 @@ STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
- }
- return ret;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size);
-
- typedef struct _thread_entry_args_t {
- mp_obj_dict_t *dict_locals;
- @@ -154,16 +154,13 @@ typedef struct _thread_entry_args_t {
- mp_obj_t args[];
- } thread_entry_args_t;
-
- -STATIC void *thread_entry(void *args_in) {
- +static void *thread_entry(void *args_in) {
- // Execution begins here for a new thread. We do not have the GIL.
-
- thread_entry_args_t *args = (thread_entry_args_t *)args_in;
-
- mp_state_thread_t ts;
- - mp_thread_set_state(&ts);
- -
- - mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan
- - mp_stack_set_limit(args->stack_size);
- + mp_thread_init_state(&ts, args->stack_size, args->dict_locals, args->dict_globals);
-
- #if MICROPY_ENABLE_PYSTACK
- // TODO threading and pystack is not fully supported, for now just make a small stack
- @@ -171,16 +168,6 @@ STATIC void *thread_entry(void *args_in) {
- mp_pystack_init(mini_pystack, &mini_pystack[128]);
- #endif
-
- - // The GC starts off unlocked on this thread.
- - ts.gc_lock_depth = 0;
- -
- - ts.nlr_jump_callback_top = NULL;
- - ts.mp_pending_exception = MP_OBJ_NULL;
- -
- - // set locals and globals from the calling context
- - mp_locals_set(args->dict_locals);
- - mp_globals_set(args->dict_globals);
- -
- MP_THREAD_GIL_ENTER();
-
- // signal that we are set up and running
- @@ -220,7 +207,7 @@ STATIC void *thread_entry(void *args_in) {
- return NULL;
- }
-
- -STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) {
- // This structure holds the Python function and arguments for thread entry.
- // We copy all arguments into this structure to keep ownership of them.
- // We must be very careful about root pointers because this pointer may
- @@ -271,19 +258,19 @@ STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args)
- // spawn the thread!
- return mp_obj_new_int_from_uint(mp_thread_create(thread_entry, th_args, &th_args->stack_size));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread);
-
- -STATIC mp_obj_t mod_thread_exit(void) {
- +static mp_obj_t mod_thread_exit(void) {
- mp_raise_type(&mp_type_SystemExit);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit);
-
- -STATIC mp_obj_t mod_thread_allocate_lock(void) {
- +static mp_obj_t mod_thread_allocate_lock(void) {
- return MP_OBJ_FROM_PTR(mp_obj_new_thread_lock());
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock);
- +static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock);
-
- -STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
- +static const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__thread) },
- { MP_ROM_QSTR(MP_QSTR_LockType), MP_ROM_PTR(&mp_type_thread_lock) },
- { MP_ROM_QSTR(MP_QSTR_get_ident), MP_ROM_PTR(&mod_thread_get_ident_obj) },
- @@ -293,7 +280,7 @@ STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR_allocate_lock), MP_ROM_PTR(&mod_thread_allocate_lock_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table);
- +static MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table);
-
- const mp_obj_module_t mp_module_thread = {
- .base = { &mp_type_module },
- diff --git a/py/mpconfig.h b/py/mpconfig.h
- index 627388c67..af2480266 100644
- --- a/py/mpconfig.h
- +++ b/py/mpconfig.h
- @@ -30,9 +30,9 @@
- // as well as a fallback to generate MICROPY_GIT_TAG if the git repo or tags
- // are unavailable.
- #define MICROPY_VERSION_MAJOR 1
- -#define MICROPY_VERSION_MINOR 22
- -#define MICROPY_VERSION_MICRO 2
- -#define MICROPY_VERSION_PRERELEASE 0
- +#define MICROPY_VERSION_MINOR 23
- +#define MICROPY_VERSION_MICRO 0
- +#define MICROPY_VERSION_PRERELEASE 1
-
- // Combined version as a 32-bit number for convenience to allow version
- // comparison. Doesn't include prerelease state.
- @@ -290,10 +290,12 @@
-
- // Number of bytes used to store qstr hash
- #ifndef MICROPY_QSTR_BYTES_IN_HASH
- -#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
- +#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES
- #define MICROPY_QSTR_BYTES_IN_HASH (2)
- -#else
- +#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
- #define MICROPY_QSTR_BYTES_IN_HASH (1)
- +#else
- +#define MICROPY_QSTR_BYTES_IN_HASH (0)
- #endif
- #endif
-
- @@ -444,6 +446,11 @@
- #define MICROPY_DYNAMIC_COMPILER (0)
- #endif
-
- +// Whether the compiler allows compiling top-level await expressions
- +#ifndef MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
- +#define MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT (0)
- +#endif
- +
- // Whether to enable constant folding; eg 1+2 rewritten as 3
- #ifndef MICROPY_COMP_CONST_FOLDING
- #define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
- @@ -828,6 +835,15 @@ typedef double mp_float_t;
- #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
- #endif
-
- +// Whether to use the native _Float16 for 16-bit float support
- +#ifndef MICROPY_FLOAT_USE_NATIVE_FLT16
- +#ifdef __FLT16_MAX__
- +#define MICROPY_FLOAT_USE_NATIVE_FLT16 (1)
- +#else
- +#define MICROPY_FLOAT_USE_NATIVE_FLT16 (0)
- +#endif
- +#endif
- +
- // Whether to provide a high-quality hash for float and complex numbers.
- // Otherwise the default is a very simple but correct hashing function.
- #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
- @@ -1301,6 +1317,16 @@ typedef double mp_float_t;
- #define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
- #endif
-
- +// Whether "collections.deque" supports iteration
- +#ifndef MICROPY_PY_COLLECTIONS_DEQUE_ITER
- +#define MICROPY_PY_COLLECTIONS_DEQUE_ITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
- +#endif
- +
- +// Whether "collections.deque" supports subscription
- +#ifndef MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
- +#define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
- +#endif
- +
- // Whether to provide "collections.OrderedDict" type
- #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
- #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
- @@ -1690,6 +1716,11 @@ typedef double mp_float_t;
- #define MICROPY_PY_MACHINE (0)
- #endif
-
- +// Whether to include: reset, reset_cause
- +#ifndef MICROPY_PY_MACHINE_RESET
- +#define MICROPY_PY_MACHINE_RESET (0)
- +#endif
- +
- // Whether to include: bitstream
- #ifndef MICROPY_PY_MACHINE_BITSTREAM
- #define MICROPY_PY_MACHINE_BITSTREAM (0)
- @@ -1700,6 +1731,16 @@ typedef double mp_float_t;
- #define MICROPY_PY_MACHINE_PULSE (0)
- #endif
-
- +// Whether to provide the "machine.mem8/16/32" objects
- +#ifndef MICROPY_PY_MACHINE_MEMX
- +#define MICROPY_PY_MACHINE_MEMX (MICROPY_PY_MACHINE)
- +#endif
- +
- +// Whether to provide the "machine.Signal" class
- +#ifndef MICROPY_PY_MACHINE_SIGNAL
- +#define MICROPY_PY_MACHINE_SIGNAL (MICROPY_PY_MACHINE)
- +#endif
- +
- #ifndef MICROPY_PY_MACHINE_I2C
- #define MICROPY_PY_MACHINE_I2C (0)
- #endif
- @@ -1742,6 +1783,11 @@ typedef double mp_float_t;
- #define MICROPY_PY_SSL_FINALISER (MICROPY_ENABLE_FINALISER)
- #endif
-
- +// Whether to provide the "vfs" module
- +#ifndef MICROPY_PY_VFS
- +#define MICROPY_PY_VFS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES && MICROPY_VFS)
- +#endif
- +
- #ifndef MICROPY_PY_WEBSOCKET
- #define MICROPY_PY_WEBSOCKET (0)
- #endif
- @@ -1855,12 +1901,6 @@ typedef double mp_float_t;
- #endif
- #endif
-
- -// Allow to override static modifier for global objects, e.g. to use with
- -// object code analysis tools which don't support static symbols.
- -#ifndef STATIC
- -#define STATIC static
- -#endif
- -
- // Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t
- #ifndef MP_BYTES_PER_OBJ_WORD
- #define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t))
- diff --git a/py/mpprint.c b/py/mpprint.c
- index 3218bd2f4..291e4145f 100644
- --- a/py/mpprint.c
- +++ b/py/mpprint.c
- @@ -43,7 +43,7 @@
- static const char pad_spaces[] = " ";
- static const char pad_zeroes[] = "0000000000000000";
-
- -STATIC void plat_print_strn(void *env, const char *str, size_t len) {
- +static void plat_print_strn(void *env, const char *str, size_t len) {
- (void)env;
- MP_PLAT_PRINT_STRN(str, len);
- }
- @@ -127,7 +127,7 @@ int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flag
-
- // This function is used exclusively by mp_vprintf to format ints.
- // It needs to be a separate function to mp_print_mp_int, since converting to a mp_int looses the MSB.
- -STATIC int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) {
- +static int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width) {
- char sign = 0;
- if (sgn) {
- if ((mp_int_t)x < 0) {
- diff --git a/py/mpstate.h b/py/mpstate.h
- index 0e0388e41..af55e764f 100644
- --- a/py/mpstate.h
- +++ b/py/mpstate.h
- @@ -310,7 +310,6 @@ extern mp_state_ctx_t mp_state_ctx;
- #define MP_STATE_MAIN_THREAD(x) (mp_state_ctx.thread.x)
-
- #if MICROPY_PY_THREAD
- -extern mp_state_thread_t *mp_thread_get_state(void);
- #define MP_STATE_THREAD(x) (mp_thread_get_state()->x)
- #define mp_thread_is_main_thread() (mp_thread_get_state() == &mp_state_ctx.thread)
- #else
- diff --git a/py/mpz.c b/py/mpz.c
- index b61997e2f..502d4e1c1 100644
- --- a/py/mpz.c
- +++ b/py/mpz.c
- @@ -49,7 +49,7 @@
- Definition of normalise: ?
- */
-
- -STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
- +static size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
- for (--idig; idig >= oidig && *idig == 0; --idig) {
- }
- return idig + 1 - oidig;
- @@ -59,7 +59,7 @@ STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
- returns sign(i - j)
- assumes i, j are normalised
- */
- -STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) {
- +static int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) {
- if (ilen < jlen) {
- return -1;
- }
- @@ -85,7 +85,7 @@ STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, si
- assumes enough memory in i; assumes normalised j; assumes n > 0
- can have i, j pointing to same memory
- */
- -STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
- +static size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
- mp_uint_t n_whole = (n + DIG_SIZE - 1) / DIG_SIZE;
- mp_uint_t n_part = n % DIG_SIZE;
- if (n_part == 0) {
- @@ -124,7 +124,7 @@ STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n
- assumes enough memory in i; assumes normalised j; assumes n > 0
- can have i, j pointing to same memory
- */
- -STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
- +static size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
- mp_uint_t n_whole = n / DIG_SIZE;
- mp_uint_t n_part = n % DIG_SIZE;
-
- @@ -156,7 +156,7 @@ STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n
- assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
- can have i, j, k pointing to same memory
- */
- -STATIC size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- +static size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- mpz_dig_t *oidig = idig;
- mpz_dbl_dig_t carry = 0;
-
- @@ -186,7 +186,7 @@ STATIC size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
- assumes enough memory in i; assumes normalised j, k; assumes j >= k
- can have i, j, k pointing to same memory
- */
- -STATIC size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- +static size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- mpz_dig_t *oidig = idig;
- mpz_dbl_dig_signed_t borrow = 0;
-
- @@ -214,7 +214,7 @@ STATIC size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
- assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen (jlen argument not needed)
- can have i, j, k pointing to same memory
- */
- -STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) {
- +static size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) {
- mpz_dig_t *oidig = idig;
-
- for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) {
- @@ -235,7 +235,7 @@ STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *k
- assumes enough memory in i; assumes normalised j, k; assumes length j >= length k
- can have i, j, k pointing to same memory
- */
- -STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- +static size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
- mpz_dig_t *oidig = idig;
- mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
- @@ -266,7 +266,7 @@ STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, c
- assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
- can have i, j, k pointing to same memory
- */
- -STATIC size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- +static size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- mpz_dig_t *oidig = idig;
-
- jlen -= klen;
- @@ -296,7 +296,7 @@ STATIC size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
-
- #if MICROPY_OPT_MPZ_BITWISE
-
- -STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- +static size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
- mpz_dig_t *oidig = idig;
- mpz_dbl_dig_t carryi = 1;
- @@ -326,7 +326,7 @@ STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, co
-
- #else
-
- -STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- +static size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
- mpz_dig_t *oidig = idig;
- mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
- @@ -358,7 +358,7 @@ STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, co
- assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
- can have i, j, k pointing to same memory
- */
- -STATIC size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- +static size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen) {
- mpz_dig_t *oidig = idig;
-
- jlen -= klen;
- @@ -385,7 +385,7 @@ STATIC size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
- assumes enough memory in i; assumes normalised j, k; assumes length j >= length k
- can have i, j, k pointing to same memory
- */
- -STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- +static size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
- mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
- mpz_dig_t *oidig = idig;
-
- @@ -410,7 +410,7 @@ STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, c
- returns number of digits in i
- assumes enough memory in i; assumes normalised i; assumes dmul != 0
- */
- -STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) {
- +static size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) {
- mpz_dig_t *oidig = idig;
- mpz_dbl_dig_t carry = dadd;
-
- @@ -432,7 +432,7 @@ STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul,
- assumes enough memory in i; assumes i is zeroed; assumes normalised j, k
- can have j, k point to same memory
- */
- -STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) {
- +static size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) {
- mpz_dig_t *oidig = idig;
- size_t ilen = 0;
-
- @@ -463,7 +463,7 @@ STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *
- assumes quo_dig has enough memory (as many digits as num)
- assumes quo_dig is filled with zeros
- */
- -STATIC void mpn_div(mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t *den_dig, size_t den_len, mpz_dig_t *quo_dig, size_t *quo_len) {
- +static void mpn_div(mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t *den_dig, size_t den_len, mpz_dig_t *quo_dig, size_t *quo_len) {
- mpz_dig_t *orig_num_dig = num_dig;
- mpz_dig_t *orig_quo_dig = quo_dig;
- mpz_dig_t norm_shift = 0;
- @@ -668,14 +668,14 @@ mpz_t *mpz_from_str(const char *str, size_t len, bool neg, unsigned int base) {
- }
- #endif
-
- -STATIC void mpz_free(mpz_t *z) {
- +static void mpz_free(mpz_t *z) {
- if (z != NULL) {
- m_del(mpz_dig_t, z->dig, z->alloc);
- m_del_obj(mpz_t, z);
- }
- }
-
- -STATIC void mpz_need_dig(mpz_t *z, size_t need) {
- +static void mpz_need_dig(mpz_t *z, size_t need) {
- if (need < MIN_ALLOC) {
- need = MIN_ALLOC;
- }
- @@ -689,7 +689,7 @@ STATIC void mpz_need_dig(mpz_t *z, size_t need) {
- }
- }
-
- -STATIC mpz_t *mpz_clone(const mpz_t *src) {
- +static mpz_t *mpz_clone(const mpz_t *src) {
- assert(src->alloc != 0);
- mpz_t *z = m_new_obj(mpz_t);
- z->neg = src->neg;
- diff --git a/py/nativeglue.c b/py/nativeglue.c
- index 217c6b3df..ba3d93f76 100644
- --- a/py/nativeglue.c
- +++ b/py/nativeglue.c
- @@ -29,6 +29,7 @@
- #include <string.h>
- #include <assert.h>
-
- +#include "py/binary.h"
- #include "py/runtime.h"
- #include "py/smallint.h"
- #include "py/nativeglue.h"
- @@ -139,7 +140,7 @@ mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
- }
- #endif
-
- -STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
- +static mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
- if (new_globals == NULL) {
- // Globals were the originally the same so don't restore them
- return NULL;
- @@ -155,20 +156,20 @@ STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
-
- // wrapper that accepts n_args and n_kw in one argument
- // (native emitter can only pass at most 3 arguments to a function)
- -STATIC mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) {
- +static mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) {
- return mp_call_function_n_kw(fun_in, n_args_kw & 0xff, (n_args_kw >> 8) & 0xff, args);
- }
-
- // wrapper that makes raise obj and raises it
- // END_FINALLY opcode requires that we don't raise if o==None
- -STATIC void mp_native_raise(mp_obj_t o) {
- +static void mp_native_raise(mp_obj_t o) {
- if (o != MP_OBJ_NULL && o != mp_const_none) {
- nlr_raise(mp_make_raise_obj(o));
- }
- }
-
- // wrapper that handles iterator buffer
- -STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
- +static mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
- if (iter == NULL) {
- return mp_getiter(obj, NULL);
- } else {
- @@ -183,7 +184,7 @@ STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
- }
-
- // wrapper that handles iterator buffer
- -STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
- +static mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
- mp_obj_t obj;
- if (iter->base.type == MP_OBJ_NULL) {
- obj = iter->buf[0];
- @@ -193,7 +194,7 @@ STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
- return mp_iternext(obj);
- }
-
- -STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
- +static bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
- mp_vm_return_kind_t ret_kind;
- nlr_buf_t nlr_buf;
- mp_obj_t throw_value = *ret_value;
- @@ -231,22 +232,22 @@ STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *re
-
- #if !MICROPY_PY_BUILTINS_FLOAT
-
- -STATIC mp_obj_t mp_obj_new_float_from_f(float f) {
- +static mp_obj_t mp_obj_new_float_from_f(float f) {
- (void)f;
- mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
- }
-
- -STATIC mp_obj_t mp_obj_new_float_from_d(double d) {
- +static mp_obj_t mp_obj_new_float_from_d(double d) {
- (void)d;
- mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
- }
-
- -STATIC float mp_obj_get_float_to_f(mp_obj_t o) {
- +static float mp_obj_get_float_to_f(mp_obj_t o) {
- (void)o;
- mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
- }
-
- -STATIC double mp_obj_get_float_to_d(mp_obj_t o) {
- +static double mp_obj_get_float_to_d(mp_obj_t o) {
- (void)o;
- mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
- }
- @@ -281,7 +282,7 @@ const mp_fun_table_t mp_fun_table = {
- mp_obj_set_store,
- mp_obj_list_append,
- mp_obj_dict_store,
- - mp_make_function_from_raw_code,
- + mp_make_function_from_proto_fun,
- mp_native_call_function_n_kw,
- mp_call_method_n_kw,
- mp_call_method_n_kw_var,
- @@ -330,6 +331,9 @@ const mp_fun_table_t mp_fun_table = {
- mp_obj_get_float_to_d,
- mp_get_buffer,
- mp_get_stream_raise,
- + mp_binary_get_size,
- + mp_binary_get_val_array,
- + mp_binary_set_val_array,
- &mp_plat_print,
- &mp_type_type,
- &mp_type_str,
- diff --git a/py/nativeglue.h b/py/nativeglue.h
- index cf73ffbfc..1fa859334 100644
- --- a/py/nativeglue.h
- +++ b/py/nativeglue.h
- @@ -58,7 +58,7 @@ typedef enum {
- MP_F_STORE_SET,
- MP_F_LIST_APPEND,
- MP_F_STORE_MAP,
- - MP_F_MAKE_FUNCTION_FROM_RAW_CODE,
- + MP_F_MAKE_FUNCTION_FROM_PROTO_FUN,
- MP_F_NATIVE_CALL_FUNCTION_N_KW,
- MP_F_CALL_METHOD_N_KW,
- MP_F_CALL_METHOD_N_KW_VAR,
- @@ -112,7 +112,7 @@ typedef struct _mp_fun_table_t {
- void (*set_store)(mp_obj_t self_in, mp_obj_t item);
- mp_obj_t (*list_append)(mp_obj_t self_in, mp_obj_t arg);
- mp_obj_t (*dict_store)(mp_obj_t self_in, mp_obj_t key, mp_obj_t value);
- - mp_obj_t (*make_function_from_raw_code)(const mp_raw_code_t *rc, const mp_module_context_t *cm, const mp_obj_t *def_args);
- + mp_obj_t (*make_function_from_proto_fun)(mp_proto_fun_t proto_fun, const mp_module_context_t *cm, const mp_obj_t *def_args);
- mp_obj_t (*call_function_n_kw)(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args);
- mp_obj_t (*call_method_n_kw)(size_t n_args, size_t n_kw, const mp_obj_t *args);
- mp_obj_t (*call_method_n_kw_var)(bool have_self, size_t n_args_n_kw, const mp_obj_t *args);
- @@ -156,7 +156,12 @@ typedef struct _mp_fun_table_t {
- double (*obj_get_float_to_d)(mp_obj_t o);
- bool (*get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
- const mp_stream_p_t *(*get_stream_raise)(mp_obj_t self_in, int flags);
- + size_t (*binary_get_size)(char struct_type, char val_type, size_t *palign);
- + mp_obj_t (*binary_get_val_array)(char typecode, void *p, size_t index);
- + void (*binary_set_val_array)(char typecode, void *p, size_t index, mp_obj_t val_in);
- const mp_print_t *plat_print;
- + // The following entries start at index 70 and are referenced by tools-mpy_ld.py,
- + // see constant MP_FUN_TABLE_MP_TYPE_TYPE_OFFSET.
- const mp_obj_type_t *type_type;
- const mp_obj_type_t *type_str;
- const mp_obj_type_t *type_list;
- diff --git a/py/nlraarch64.c b/py/nlraarch64.c
- index fcc318f2d..d6d87ebc5 100644
- --- a/py/nlraarch64.c
- +++ b/py/nlraarch64.c
- @@ -75,7 +75,7 @@ NORETURN void nlr_jump(void *val) {
- "ret \n"
- :
- : "r" (top)
- - :
- + : "memory"
- );
-
- MP_UNREACHABLE
- diff --git a/py/nlrmips.c b/py/nlrmips.c
- index bd5d73b6f..cba52b16a 100644
- --- a/py/nlrmips.c
- +++ b/py/nlrmips.c
- @@ -78,7 +78,7 @@ NORETURN void nlr_jump(void *val) {
- "nop \n"
- :
- : "r" (top)
- - :
- + : "memory"
- );
- MP_UNREACHABLE
- }
- diff --git a/py/nlrpowerpc.c b/py/nlrpowerpc.c
- index 448459216..8a69fe1ee 100644
- --- a/py/nlrpowerpc.c
- +++ b/py/nlrpowerpc.c
- @@ -114,7 +114,7 @@ NORETURN void nlr_jump(void *val) {
- "blr ;"
- :
- : "r" (&top->regs)
- - :
- + : "memory"
- );
-
- MP_UNREACHABLE;
- @@ -203,7 +203,7 @@ NORETURN void nlr_jump(void *val) {
- "blr ;"
- :
- : "r" (&top->regs)
- - :
- + : "memory"
- );
-
- MP_UNREACHABLE;
- diff --git a/py/nlrthumb.c b/py/nlrthumb.c
- index a8ffecc47..a22c5df5b 100644
- --- a/py/nlrthumb.c
- +++ b/py/nlrthumb.c
- @@ -132,7 +132,7 @@ NORETURN void nlr_jump(void *val) {
- "bx lr \n" // return
- : // output operands
- : "r" (top) // input operands
- - : // clobbered registers
- + : "memory" // clobbered registers
- );
-
- MP_UNREACHABLE
- diff --git a/py/nlrx64.c b/py/nlrx64.c
- index 6b7d0262f..d1ad91ff7 100644
- --- a/py/nlrx64.c
- +++ b/py/nlrx64.c
- @@ -123,7 +123,7 @@ NORETURN void nlr_jump(void *val) {
- "ret \n" // return
- : // output operands
- : "r" (top) // input operands
- - : // clobbered registers
- + : "memory" // clobbered registers
- );
-
- MP_UNREACHABLE
- diff --git a/py/nlrx86.c b/py/nlrx86.c
- index f658d4191..085e30d20 100644
- --- a/py/nlrx86.c
- +++ b/py/nlrx86.c
- @@ -95,7 +95,7 @@ NORETURN void nlr_jump(void *val) {
- "ret \n" // return
- : // output operands
- : "r" (top) // input operands
- - : // clobbered registers
- + : "memory" // clobbered registers
- );
-
- MP_UNREACHABLE
- diff --git a/py/nlrxtensa.c b/py/nlrxtensa.c
- index abe9042af..ff7af6ede 100644
- --- a/py/nlrxtensa.c
- +++ b/py/nlrxtensa.c
- @@ -74,7 +74,7 @@ NORETURN void nlr_jump(void *val) {
- "ret.n \n" // return
- : // output operands
- : "r" (top) // input operands
- - : // clobbered registers
- + : "memory" // clobbered registers
- );
-
- MP_UNREACHABLE
- diff --git a/py/obj.c b/py/obj.c
- index 5e01198b6..e43451dad 100644
- --- a/py/obj.c
- +++ b/py/obj.c
- @@ -44,6 +44,15 @@ MP_NOINLINE void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *ty
- return base;
- }
-
- +#if MICROPY_ENABLE_FINALISER
- +// Allocates an object and also sets type, for mp_obj_malloc{,_var}_with_finaliser macros.
- +MP_NOINLINE void *mp_obj_malloc_with_finaliser_helper(size_t num_bytes, const mp_obj_type_t *type) {
- + mp_obj_base_t *base = (mp_obj_base_t *)m_malloc_with_finaliser(num_bytes);
- + base->type = type;
- + return base;
- +}
- +#endif
- +
- const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_t o_in) {
- #if MICROPY_OBJ_IMMEDIATE_OBJS && MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A
-
- diff --git a/py/obj.h b/py/obj.h
- index c7b7db0c3..9f2bb46e4 100644
- --- a/py/obj.h
- +++ b/py/obj.h
- @@ -833,6 +833,9 @@ extern const mp_obj_type_t mp_type_fun_builtin_2;
- extern const mp_obj_type_t mp_type_fun_builtin_3;
- extern const mp_obj_type_t mp_type_fun_builtin_var;
- extern const mp_obj_type_t mp_type_fun_bc;
- +extern const mp_obj_type_t mp_type_fun_native;
- +extern const mp_obj_type_t mp_type_fun_viper;
- +extern const mp_obj_type_t mp_type_fun_asm;
- extern const mp_obj_type_t mp_type_module;
- extern const mp_obj_type_t mp_type_staticmethod;
- extern const mp_obj_type_t mp_type_classmethod;
- @@ -913,9 +916,19 @@ extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj;
- // Helper versions of m_new_obj when you need to immediately set base.type.
- // Implementing this as a call rather than inline saves 8 bytes per usage.
- #define mp_obj_malloc(struct_type, obj_type) ((struct_type *)mp_obj_malloc_helper(sizeof(struct_type), obj_type))
- -#define mp_obj_malloc_var(struct_type, var_type, var_num, obj_type) ((struct_type *)mp_obj_malloc_helper(sizeof(struct_type) + sizeof(var_type) * (var_num), obj_type))
- +#define mp_obj_malloc_var(struct_type, var_field, var_type, var_num, obj_type) ((struct_type *)mp_obj_malloc_helper(offsetof(struct_type, var_field) + sizeof(var_type) * (var_num), obj_type))
- void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type);
-
- +// Object allocation macros for allocating objects that have a finaliser.
- +#if MICROPY_ENABLE_FINALISER
- +#define mp_obj_malloc_with_finaliser(struct_type, obj_type) ((struct_type *)mp_obj_malloc_with_finaliser_helper(sizeof(struct_type), obj_type))
- +#define mp_obj_malloc_var_with_finaliser(struct_type, var_type, var_num, obj_type) ((struct_type *)mp_obj_malloc_with_finaliser_helper(sizeof(struct_type) + sizeof(var_type) * (var_num), obj_type))
- +void *mp_obj_malloc_with_finaliser_helper(size_t num_bytes, const mp_obj_type_t *type);
- +#else
- +#define mp_obj_malloc_with_finaliser(struct_type, obj_type) mp_obj_malloc(struct_type, obj_type)
- +#define mp_obj_malloc_var_with_finaliser(struct_type, var_type, var_num, obj_type) mp_obj_malloc_var(struct_type, var_type, var_num, obj_type)
- +#endif
- +
- // These macros are derived from more primitive ones and are used to
- // check for more specific object types.
- // Note: these are kept as macros because inline functions sometimes use much
- diff --git a/py/objarray.c b/py/objarray.c
- index a3adb255e..1fff23482 100644
- --- a/py/objarray.c
- +++ b/py/objarray.c
- @@ -61,16 +61,16 @@
- // so not defined to catch errors
- #endif
-
- -STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf);
- -STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
- -STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
- -STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
- +static mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf);
- +static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
- +static mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
- +static mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
-
- /******************************************************************************/
- // array
-
- #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
- -STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
- if (o->typecode == BYTEARRAY_TYPECODE) {
- @@ -94,7 +94,7 @@ STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
- #endif
-
- #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
- -STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
- +static mp_obj_array_t *array_new(char typecode, size_t n) {
- int typecode_size = mp_binary_get_size('@', typecode, NULL);
- mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
- #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY
- @@ -113,7 +113,7 @@ STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
- #endif
-
- #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
- -STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
- +static mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
- // bytearrays can be raw-initialised from anything with the buffer protocol
- // other arrays can only be raw-initialised from bytes and bytearray objects
- mp_buffer_info_t bufinfo;
- @@ -159,7 +159,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
- #endif
-
- #if MICROPY_PY_ARRAY
- -STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
- mp_arg_check_num(n_args, n_kw, 1, 2, false);
-
- @@ -177,7 +177,7 @@ STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size
- #endif
-
- #if MICROPY_PY_BUILTINS_BYTEARRAY
- -STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
- // Can take 2nd/3rd arg if constructs from str
- mp_arg_check_num(n_args, n_kw, 0, 3, false);
- @@ -214,7 +214,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) {
- return MP_OBJ_FROM_PTR(self);
- }
-
- -STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
-
- // TODO possibly allow memoryview constructor to take start/stop so that one
- @@ -246,7 +246,7 @@ STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args,
- }
-
- #if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
- -STATIC void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- return;
- }
- @@ -265,7 +265,7 @@ STATIC void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
-
- #endif
-
- -STATIC mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- +static mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- @@ -277,7 +277,7 @@ STATIC mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- }
- }
-
- -STATIC int typecode_for_comparison(int typecode, bool *is_unsigned) {
- +static int typecode_for_comparison(int typecode, bool *is_unsigned) {
- if (typecode == BYTEARRAY_TYPECODE) {
- typecode = 'B';
- }
- @@ -288,7 +288,7 @@ STATIC int typecode_for_comparison(int typecode, bool *is_unsigned) {
- return typecode;
- }
-
- -STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
- switch (op) {
- case MP_BINARY_OP_ADD: {
- @@ -383,7 +383,7 @@ STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
- }
-
- #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
- -STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
- +static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
- // self is not a memoryview, so we don't need to use (& TYPECODE_MASK)
- assert((MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(self_in, &mp_type_bytearray))
- || (MICROPY_PY_ARRAY && mp_obj_is_type(self_in, &mp_type_array)));
- @@ -404,7 +404,7 @@ STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_obj_array_append_obj, array_append);
-
- -STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
- +static mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
- // self is not a memoryview, so we don't need to use (& TYPECODE_MASK)
- assert((MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(self_in, &mp_type_bytearray))
- || (MICROPY_PY_ARRAY && mp_obj_is_type(self_in, &mp_type_array)));
- @@ -437,7 +437,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
- MP_DEFINE_CONST_FUN_OBJ_2(mp_obj_array_extend_obj, array_extend);
- #endif
-
- -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
- +static mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
- if (value == MP_OBJ_NULL) {
- // delete item
- // TODO implement
- @@ -568,7 +568,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
- }
- }
-
- -STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
- +static mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
- mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
- size_t sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL);
- bufinfo->buf = o->items;
- @@ -682,7 +682,7 @@ typedef struct _mp_obj_array_it_t {
- size_t cur;
- } mp_obj_array_it_t;
-
- -STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t array_it_iternext(mp_obj_t self_in) {
- mp_obj_array_it_t *self = MP_OBJ_TO_PTR(self_in);
- if (self->cur < self->array->len) {
- return mp_binary_get_val_array(self->array->typecode & TYPECODE_MASK, self->array->items, self->offset + self->cur++);
- @@ -691,14 +691,14 @@ STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
- }
- }
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_array_it,
- MP_QSTR_iterator,
- MP_TYPE_FLAG_ITER_IS_ITERNEXT,
- iter, array_it_iternext
- );
-
- -STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {
- assert(sizeof(mp_obj_array_t) <= sizeof(mp_obj_iter_buf_t));
- mp_obj_array_t *array = MP_OBJ_TO_PTR(array_in);
- mp_obj_array_it_t *o = (mp_obj_array_it_t *)iter_buf;
- diff --git a/py/objattrtuple.c b/py/objattrtuple.c
- index fbe04bedb..1280e3308 100644
- --- a/py/objattrtuple.c
- +++ b/py/objattrtuple.c
- @@ -30,7 +30,7 @@
-
- // this helper function is used by collections.namedtuple
- #if !MICROPY_PY_COLLECTIONS
- -STATIC
- +static
- #endif
- void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o) {
- mp_print_str(print, "(");
- @@ -48,14 +48,14 @@ void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields,
-
- #if MICROPY_PY_ATTRTUPLE
-
- -STATIC void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in);
- const qstr *fields = (const qstr *)MP_OBJ_TO_PTR(o->items[o->len]);
- mp_obj_attrtuple_print_helper(print, fields, o);
- }
-
- -STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] == MP_OBJ_NULL) {
- // load attribute
- mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -71,7 +71,7 @@ STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- }
-
- mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items) {
- - mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, n + 1, &mp_type_attrtuple);
- + mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, n + 1, &mp_type_attrtuple);
- o->len = n;
- for (size_t i = 0; i < n; i++) {
- o->items[i] = items[i];
- diff --git a/py/objbool.c b/py/objbool.c
- index 96f0e60dd..5b3e3660e 100644
- --- a/py/objbool.c
- +++ b/py/objbool.c
- @@ -43,7 +43,7 @@ typedef struct _mp_obj_bool_t {
-
- #endif
-
- -STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- bool value = BOOL_VALUE(self_in);
- if (MICROPY_PY_JSON && kind == PRINT_JSON) {
- if (value) {
- @@ -60,7 +60,7 @@ STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
- }
- }
-
- -STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
- mp_arg_check_num(n_args, n_kw, 0, 1, false);
-
- @@ -71,7 +71,7 @@ STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
- }
- }
-
- -STATIC mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- +static mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- if (op == MP_UNARY_OP_LEN) {
- return MP_OBJ_NULL;
- }
- @@ -79,7 +79,7 @@ STATIC mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- return mp_unary_op(op, MP_OBJ_NEW_SMALL_INT(value));
- }
-
- -STATIC mp_obj_t bool_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t bool_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- bool value = BOOL_VALUE(lhs_in);
- return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(value), rhs_in);
- }
- diff --git a/py/objboundmeth.c b/py/objboundmeth.c
- index b0be810c5..e3503ff15 100644
- --- a/py/objboundmeth.c
- +++ b/py/objboundmeth.c
- @@ -36,7 +36,7 @@ typedef struct _mp_obj_bound_meth_t {
- } mp_obj_bound_meth_t;
-
- #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
- -STATIC void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(o_in);
- mp_printf(print, "<bound_method %p ", o);
- @@ -78,12 +78,12 @@ mp_obj_t mp_call_method_self_n_kw(mp_obj_t meth, mp_obj_t self, size_t n_args, s
- return res;
- }
-
- -STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t bound_meth_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_call_method_self_n_kw(self->meth, self->self, n_args, n_kw, args);
- }
-
- -STATIC mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in);
- switch (op) {
- case MP_UNARY_OP_HASH:
- @@ -93,7 +93,7 @@ STATIC mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- }
- }
-
- -STATIC mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- // The MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE flag is clear for this type, so if this
- // function is called with MP_BINARY_OP_EQUAL then lhs_in and rhs_in must have the
- // same type, which is mp_type_bound_meth.
- @@ -106,7 +106,7 @@ STATIC mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_
- }
-
- #if MICROPY_PY_FUNCTION_ATTRS
- -STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- // not load attribute
- return;
- diff --git a/py/objcell.c b/py/objcell.c
- index 0a74e29d2..95966c791 100644
- --- a/py/objcell.c
- +++ b/py/objcell.c
- @@ -27,7 +27,7 @@
- #include "py/obj.h"
-
- #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
- -STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_cell_t *o = MP_OBJ_TO_PTR(o_in);
- mp_printf(print, "<cell %p ", o->obj);
- @@ -46,7 +46,7 @@ STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
- #define CELL_TYPE_PRINT
- #endif
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- // cell representation is just value in < >
- mp_type_cell, MP_QSTR_, MP_TYPE_FLAG_NONE
- CELL_TYPE_PRINT
- diff --git a/py/objclosure.c b/py/objclosure.c
- index 6059d1810..3ba507b95 100644
- --- a/py/objclosure.c
- +++ b/py/objclosure.c
- @@ -36,7 +36,7 @@ typedef struct _mp_obj_closure_t {
- mp_obj_t closed[];
- } mp_obj_closure_t;
-
- -STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_obj_closure_t *self = MP_OBJ_TO_PTR(self_in);
-
- // need to concatenate closed-over-vars and args
- @@ -60,7 +60,7 @@ STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
- }
-
- #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
- -STATIC void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_closure_t *o = MP_OBJ_TO_PTR(o_in);
- mp_print_str(print, "<closure ");
- @@ -79,7 +79,7 @@ STATIC void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_
- #endif
-
- #if MICROPY_PY_FUNCTION_ATTRS
- -STATIC void mp_obj_closure_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void mp_obj_closure_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- // forward to self_in->fun
- mp_obj_closure_t *o = MP_OBJ_TO_PTR(self_in);
- mp_load_method_maybe(o->fun, attr, dest);
- @@ -105,7 +105,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- );
-
- mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) {
- - mp_obj_closure_t *o = mp_obj_malloc_var(mp_obj_closure_t, mp_obj_t, n_closed_over, &mp_type_closure);
- + mp_obj_closure_t *o = mp_obj_malloc_var(mp_obj_closure_t, closed, mp_obj_t, n_closed_over, &mp_type_closure);
- o->fun = fun;
- o->n_closed = n_closed_over;
- memcpy(o->closed, closed, n_closed_over * sizeof(mp_obj_t));
- diff --git a/py/objcomplex.c b/py/objcomplex.c
- index ddd103eeb..85b585284 100644
- --- a/py/objcomplex.c
- +++ b/py/objcomplex.c
- @@ -42,7 +42,7 @@ typedef struct _mp_obj_complex_t {
- mp_float_t imag;
- } mp_obj_complex_t;
-
- -STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
- #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
- @@ -70,7 +70,7 @@ STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_
- }
- }
-
- -STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
- mp_arg_check_num(n_args, n_kw, 0, 2, false);
-
- @@ -115,7 +115,7 @@ STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, si
- }
- }
-
- -STATIC mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- +static mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- @@ -133,12 +133,12 @@ STATIC mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- }
- }
-
- -STATIC mp_obj_t complex_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t complex_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- mp_obj_complex_t *lhs = MP_OBJ_TO_PTR(lhs_in);
- return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
- }
-
- -STATIC void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- // not load attribute
- return;
- diff --git a/py/objdeque.c b/py/objdeque.c
- index 8b52b8d38..583537017 100644
- --- a/py/objdeque.c
- +++ b/py/objdeque.c
- @@ -25,13 +25,11 @@
- */
-
- #include <unistd.h> // for ssize_t
- -#include <string.h>
- -
- -#include "py/mpconfig.h"
- -#if MICROPY_PY_COLLECTIONS_DEQUE
-
- #include "py/runtime.h"
-
- +#if MICROPY_PY_COLLECTIONS_DEQUE
- +
- typedef struct _mp_obj_deque_t {
- mp_obj_base_t base;
- size_t alloc;
- @@ -42,14 +40,14 @@ typedef struct _mp_obj_deque_t {
- #define FLAG_CHECK_OVERFLOW 1
- } mp_obj_deque_t;
-
- -STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- - mp_arg_check_num(n_args, n_kw, 2, 3, false);
- +static mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg);
- +static mp_obj_t mp_obj_deque_extend(mp_obj_t self_in, mp_obj_t arg_in);
- +#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
- +static mp_obj_t mp_obj_new_deque_it(mp_obj_t deque, mp_obj_iter_buf_t *iter_buf);
- +#endif
-
- - /* Initialization from existing sequence is not supported, so an empty
- - tuple must be passed as such. */
- - if (args[0] != mp_const_empty_tuple) {
- - mp_raise_ValueError(NULL);
- - }
- +static mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- + mp_arg_check_num(n_args, n_kw, 2, 3, false);
-
- // Protect against -1 leading to zero-length allocation and bad array access
- mp_int_t maxlen = mp_obj_get_int(args[1]);
- @@ -66,21 +64,27 @@ STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t
- o->flags = mp_obj_get_int(args[2]);
- }
-
- + mp_obj_deque_extend(MP_OBJ_FROM_PTR(o), args[0]);
- +
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static size_t deque_len(mp_obj_deque_t *self) {
- + ssize_t len = self->i_put - self->i_get;
- + if (len < 0) {
- + len += self->alloc;
- + }
- + return len;
- +}
- +
- +static mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- return mp_obj_new_bool(self->i_get != self->i_put);
- - case MP_UNARY_OP_LEN: {
- - ssize_t len = self->i_put - self->i_get;
- - if (len < 0) {
- - len += self->alloc;
- - }
- - return MP_OBJ_NEW_SMALL_INT(len);
- - }
- + case MP_UNARY_OP_LEN:
- + return MP_OBJ_NEW_SMALL_INT(deque_len(self));
- +
- #if MICROPY_PY_SYS_GETSIZEOF
- case MP_UNARY_OP_SIZEOF: {
- size_t sz = sizeof(*self) + sizeof(mp_obj_t) * self->alloc;
- @@ -92,7 +96,7 @@ STATIC mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- }
- }
-
- -STATIC mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
- +static mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
- mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
-
- size_t new_i_put = self->i_put + 1;
- @@ -115,9 +119,48 @@ STATIC mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
-
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(deque_append_obj, mp_obj_deque_append);
- +static MP_DEFINE_CONST_FUN_OBJ_2(deque_append_obj, mp_obj_deque_append);
- +
- +static mp_obj_t mp_obj_deque_appendleft(mp_obj_t self_in, mp_obj_t arg) {
- + mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
- +
- + size_t new_i_get = self->i_get - 1;
- + if (self->i_get == 0) {
- + new_i_get = self->alloc - 1;
- + }
- +
- + if (self->flags & FLAG_CHECK_OVERFLOW && new_i_get == self->i_put) {
- + mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("full"));
- + }
- +
- + self->i_get = new_i_get;
- + self->items[self->i_get] = arg;
- +
- + // overwriting first element in deque
- + if (self->i_put == new_i_get) {
- + if (self->i_put == 0) {
- + self->i_put = self->alloc - 1;
- + } else {
- + self->i_put--;
- + }
- + }
- +
- + return mp_const_none;
- +}
- +static MP_DEFINE_CONST_FUN_OBJ_2(deque_appendleft_obj, mp_obj_deque_appendleft);
-
- -STATIC mp_obj_t deque_popleft(mp_obj_t self_in) {
- +static mp_obj_t mp_obj_deque_extend(mp_obj_t self_in, mp_obj_t arg_in) {
- + mp_obj_iter_buf_t iter_buf;
- + mp_obj_t iter = mp_getiter(arg_in, &iter_buf);
- + mp_obj_t item;
- + while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
- + mp_obj_deque_append(self_in, item);
- + }
- + return mp_const_none;
- +}
- +static MP_DEFINE_CONST_FUN_OBJ_2(deque_extend_obj, mp_obj_deque_extend);
- +
- +static mp_obj_t deque_popleft(mp_obj_t self_in) {
- mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
-
- if (self->i_get == self->i_put) {
- @@ -133,35 +176,139 @@ STATIC mp_obj_t deque_popleft(mp_obj_t self_in) {
-
- return ret;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(deque_popleft_obj, deque_popleft);
- +static MP_DEFINE_CONST_FUN_OBJ_1(deque_popleft_obj, deque_popleft);
- +
- +static mp_obj_t deque_pop(mp_obj_t self_in) {
- + mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
- +
- + if (self->i_get == self->i_put) {
- + mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("empty"));
- + }
- +
- + if (self->i_put == 0) {
- + self->i_put = self->alloc - 1;
- + } else {
- + self->i_put--;
- + }
- +
- + mp_obj_t ret = self->items[self->i_put];
- + self->items[self->i_put] = MP_OBJ_NULL;
- +
- + return ret;
- +}
- +static MP_DEFINE_CONST_FUN_OBJ_1(deque_pop_obj, deque_pop);
- +
- +#if MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
- +static mp_obj_t deque_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- + if (value == MP_OBJ_NULL) {
- + // delete not supported, fall back to mp_obj_subscr() error message
- + return MP_OBJ_NULL;
- + }
- + mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
- +
- + size_t offset = mp_get_index(self->base.type, deque_len(self), index, false);
- + size_t index_val = self->i_get + offset;
- + if (index_val > self->alloc) {
- + index_val -= self->alloc;
- + }
- +
- + if (value == MP_OBJ_SENTINEL) {
- + // load
- + return self->items[index_val];
- + } else {
- + // store into deque
- + self->items[index_val] = value;
- + return mp_const_none;
- + }
- +}
- +#endif
-
- #if 0
- -STATIC mp_obj_t deque_clear(mp_obj_t self_in) {
- +static mp_obj_t deque_clear(mp_obj_t self_in) {
- mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
- self->i_get = self->i_put = 0;
- mp_seq_clear(self->items, 0, self->alloc, sizeof(*self->items));
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(deque_clear_obj, deque_clear);
- +static MP_DEFINE_CONST_FUN_OBJ_1(deque_clear_obj, deque_clear);
- #endif
-
- -STATIC const mp_rom_map_elem_t deque_locals_dict_table[] = {
- +static const mp_rom_map_elem_t deque_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&deque_append_obj) },
- + { MP_ROM_QSTR(MP_QSTR_appendleft), MP_ROM_PTR(&deque_appendleft_obj) },
- + { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&deque_extend_obj) },
- #if 0
- { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&deque_clear_obj) },
- #endif
- + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&deque_pop_obj) },
- { MP_ROM_QSTR(MP_QSTR_popleft), MP_ROM_PTR(&deque_popleft_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(deque_locals_dict, deque_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(deque_locals_dict, deque_locals_dict_table);
- +
- +#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
- +#define DEQUE_TYPE_FLAGS MP_TYPE_FLAG_ITER_IS_GETITER
- +#define DEQUE_TYPE_ITER iter, mp_obj_new_deque_it,
- +#else
- +#define DEQUE_TYPE_FLAGS MP_TYPE_FLAG_NONE
- +#define DEQUE_TYPE_ITER
- +#endif
- +
- +#if MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
- +#define DEQUE_TYPE_SUBSCR subscr, deque_subscr,
- +#else
- +#define DEQUE_TYPE_SUBSCR
- +#endif
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_deque,
- MP_QSTR_deque,
- - MP_TYPE_FLAG_NONE,
- + MP_TYPE_FLAG_ITER_IS_GETITER,
- make_new, deque_make_new,
- unary_op, deque_unary_op,
- + DEQUE_TYPE_SUBSCR
- + DEQUE_TYPE_ITER
- locals_dict, &deque_locals_dict
- );
-
- +/******************************************************************************/
- +/* deque iterator */
- +
- +#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
- +
- +typedef struct _mp_obj_deque_it_t {
- + mp_obj_base_t base;
- + mp_fun_1_t iternext;
- + mp_obj_t deque;
- + size_t cur;
- +} mp_obj_deque_it_t;
- +
- +static mp_obj_t deque_it_iternext(mp_obj_t self_in) {
- + mp_obj_deque_it_t *self = MP_OBJ_TO_PTR(self_in);
- + mp_obj_deque_t *deque = MP_OBJ_TO_PTR(self->deque);
- + if (self->cur != deque->i_put) {
- + mp_obj_t o_out = deque->items[self->cur];
- + if (++self->cur == deque->alloc) {
- + self->cur = 0;
- + }
- + return o_out;
- + } else {
- + return MP_OBJ_STOP_ITERATION;
- + }
- +}
- +
- +static mp_obj_t mp_obj_new_deque_it(mp_obj_t deque, mp_obj_iter_buf_t *iter_buf) {
- + mp_obj_deque_t *deque_ = MP_OBJ_TO_PTR(deque);
- + size_t i_get = deque_->i_get;
- + assert(sizeof(mp_obj_deque_it_t) <= sizeof(mp_obj_iter_buf_t));
- + mp_obj_deque_it_t *o = (mp_obj_deque_it_t *)iter_buf;
- + o->base.type = &mp_type_polymorph_iter;
- + o->iternext = deque_it_iternext;
- + o->deque = deque;
- + o->cur = i_get;
- + return MP_OBJ_FROM_PTR(o);
- +}
- +
- +#endif
- +
- #endif // MICROPY_PY_COLLECTIONS_DEQUE
- diff --git a/py/objdict.c b/py/objdict.c
- index 8aafe607d..cf64fa955 100644
- --- a/py/objdict.c
- +++ b/py/objdict.c
- @@ -49,12 +49,12 @@ const mp_obj_dict_t mp_const_empty_dict_obj = {
- }
- };
-
- -STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
- +static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
-
- // This is a helper function to iterate through a dictionary. The state of
- // the iteration is held in *cur and should be initialised with zero for the
- // first call. Will return NULL when no more elements are available.
- -STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
- +static mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
- size_t max = dict->map.alloc;
- mp_map_t *map = &dict->map;
-
- @@ -70,7 +70,7 @@ STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
- return NULL;
- }
-
- -STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
- bool first = true;
- const char *item_separator = ", ";
- @@ -129,7 +129,7 @@ mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
- return dict_out;
- }
-
- -STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- @@ -147,7 +147,7 @@ STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- }
- }
-
- -STATIC mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- mp_obj_dict_t *o = MP_OBJ_TO_PTR(lhs_in);
- switch (op) {
- case MP_BINARY_OP_CONTAINS: {
- @@ -218,7 +218,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) {
- }
- }
-
- -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- +static mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- if (value == MP_OBJ_NULL) {
- // delete
- mp_obj_dict_delete(self_in, index);
- @@ -242,13 +242,13 @@ STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- /******************************************************************************/
- /* dict methods */
-
- -STATIC void mp_ensure_not_fixed(const mp_obj_dict_t *dict) {
- +static void mp_ensure_not_fixed(const mp_obj_dict_t *dict) {
- if (dict->map.is_fixed) {
- mp_raise_TypeError(NULL);
- }
- }
-
- -STATIC mp_obj_t dict_clear(mp_obj_t self_in) {
- +static mp_obj_t dict_clear(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
- mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
- mp_ensure_not_fixed(self);
- @@ -257,7 +257,7 @@ STATIC mp_obj_t dict_clear(mp_obj_t self_in) {
-
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
- +static MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
-
- mp_obj_t mp_obj_dict_copy(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
- @@ -272,11 +272,11 @@ mp_obj_t mp_obj_dict_copy(mp_obj_t self_in) {
- memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t));
- return other_out;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, mp_obj_dict_copy);
- +static MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, mp_obj_dict_copy);
-
- #if MICROPY_PY_BUILTINS_DICT_FROMKEYS
- // this is a classmethod
- -STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
- mp_obj_t iter = mp_getiter(args[1], NULL);
- mp_obj_t value = mp_const_none;
- mp_obj_t next = MP_OBJ_NULL;
- @@ -302,11 +302,11 @@ STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
-
- return self_out;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys);
- -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj));
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys);
- +static MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj));
- #endif
-
- -STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) {
- +static mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) {
- mp_check_self(mp_obj_is_dict_or_ordereddict(args[0]));
- mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
- if (lookup_kind != MP_MAP_LOOKUP) {
- @@ -336,22 +336,22 @@ STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_look
- return value;
- }
-
- -STATIC mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) {
- return dict_get_helper(n_args, args, MP_MAP_LOOKUP);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get);
-
- -STATIC mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) {
- return dict_get_helper(n_args, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop);
-
- -STATIC mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) {
- return dict_get_helper(n_args, args, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault);
-
- -STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
- +static mp_obj_t dict_popitem(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
- mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
- mp_ensure_not_fixed(self);
- @@ -374,9 +374,9 @@ STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
-
- return tuple;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem);
- +static MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem);
-
- -STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- +static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- mp_check_self(mp_obj_is_dict_or_ordereddict(args[0]));
- mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
- mp_ensure_not_fixed(self);
- @@ -424,14 +424,14 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
-
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
- +static MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
-
-
- /******************************************************************************/
- /* dict views */
-
- -STATIC const mp_obj_type_t mp_type_dict_view;
- -STATIC const mp_obj_type_t mp_type_dict_view_it;
- +static const mp_obj_type_t mp_type_dict_view;
- +static const mp_obj_type_t mp_type_dict_view_it;
-
- typedef enum _mp_dict_view_kind_t {
- MP_DICT_VIEW_ITEMS,
- @@ -439,7 +439,7 @@ typedef enum _mp_dict_view_kind_t {
- MP_DICT_VIEW_VALUES,
- } mp_dict_view_kind_t;
-
- -STATIC const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
- +static const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
-
- typedef struct _mp_obj_dict_view_it_t {
- mp_obj_base_t base;
- @@ -454,7 +454,7 @@ typedef struct _mp_obj_dict_view_t {
- mp_dict_view_kind_t kind;
- } mp_obj_dict_view_t;
-
- -STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_dict_view_it));
- mp_obj_dict_view_it_t *self = MP_OBJ_TO_PTR(self_in);
- mp_map_elem_t *next = dict_iter_next(MP_OBJ_TO_PTR(self->dict), &self->cur);
- @@ -476,14 +476,14 @@ STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
- }
- }
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_dict_view_it,
- MP_QSTR_iterator,
- MP_TYPE_FLAG_ITER_IS_ITERNEXT,
- iter, dict_view_it_iternext
- );
-
- -STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) {
- assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
- mp_check_self(mp_obj_is_type(view_in, &mp_type_dict_view));
- mp_obj_dict_view_t *view = MP_OBJ_TO_PTR(view_in);
- @@ -495,7 +495,7 @@ STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf)
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_check_self(mp_obj_is_type(self_in, &mp_type_dict_view));
- mp_obj_dict_view_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -515,7 +515,7 @@ STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
- mp_print_str(print, "])");
- }
-
- -STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- +static mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(o_in);
- // only dict.values() supports __hash__.
- if (op == MP_UNARY_OP_HASH && o->kind == MP_DICT_VIEW_VALUES) {
- @@ -524,7 +524,7 @@ STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- return MP_OBJ_NULL;
- }
-
- -STATIC mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- // only supported for the 'keys' kind until sets and dicts are refactored
- mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(lhs_in);
- if (o->kind != MP_DICT_VIEW_KEYS) {
- @@ -536,7 +536,7 @@ STATIC mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t
- return dict_binary_op(op, o->dict, rhs_in);
- }
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_dict_view,
- MP_QSTR_dict_view,
- MP_TYPE_FLAG_ITER_IS_GETITER,
- @@ -546,37 +546,37 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
- iter, dict_view_getiter
- );
-
- -STATIC mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) {
- +static mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) {
- mp_obj_dict_view_t *o = mp_obj_malloc(mp_obj_dict_view_t, &mp_type_dict_view);
- o->dict = dict;
- o->kind = kind;
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
- +static mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
- mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
- return mp_obj_new_dict_view(self_in, kind);
- }
-
- -STATIC mp_obj_t dict_items(mp_obj_t self_in) {
- +static mp_obj_t dict_items(mp_obj_t self_in) {
- return dict_view(self_in, MP_DICT_VIEW_ITEMS);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
- +static MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
-
- -STATIC mp_obj_t dict_keys(mp_obj_t self_in) {
- +static mp_obj_t dict_keys(mp_obj_t self_in) {
- return dict_view(self_in, MP_DICT_VIEW_KEYS);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
- +static MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
-
- -STATIC mp_obj_t dict_values(mp_obj_t self_in) {
- +static mp_obj_t dict_values(mp_obj_t self_in) {
- return dict_view(self_in, MP_DICT_VIEW_VALUES);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
- +static MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
-
- /******************************************************************************/
- /* dict iterator */
-
- -STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
- assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
- mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
- mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t *)iter_buf;
- @@ -590,7 +590,7 @@ STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
- /******************************************************************************/
- /* dict constructors & public C API */
-
- -STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = {
- +static const mp_rom_map_elem_t dict_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&dict_clear_obj) },
- { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&dict_copy_obj) },
- #if MICROPY_PY_BUILTINS_DICT_FROMKEYS
- @@ -609,7 +609,7 @@ STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR___delitem__), MP_ROM_PTR(&mp_op_delitem_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_dict,
- diff --git a/py/objenumerate.c b/py/objenumerate.c
- index 40bed919e..8217a0d4f 100644
- --- a/py/objenumerate.c
- +++ b/py/objenumerate.c
- @@ -37,9 +37,9 @@ typedef struct _mp_obj_enumerate_t {
- mp_int_t cur;
- } mp_obj_enumerate_t;
-
- -STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in);
- +static mp_obj_t enumerate_iternext(mp_obj_t self_in);
-
- -STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- #if MICROPY_CPYTHON_COMPAT
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_iterable, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
- @@ -75,7 +75,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- iter, enumerate_iternext
- );
-
- -STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) {
- +static mp_obj_t enumerate_iternext(mp_obj_t self_in) {
- assert(mp_obj_is_type(self_in, &mp_type_enumerate));
- mp_obj_enumerate_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t next = mp_iternext(self->iter);
- diff --git a/py/objexcept.c b/py/objexcept.c
- index fe74458ca..5bf4e672b 100644
- --- a/py/objexcept.c
- +++ b/py/objexcept.c
- @@ -117,7 +117,7 @@ bool mp_obj_is_native_exception_instance(mp_obj_t self_in) {
- return MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(self_in), make_new) == mp_obj_exception_make_new;
- }
-
- -STATIC mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
- +static mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
- assert(mp_obj_is_exception_instance(self_in));
- if (mp_obj_is_native_exception_instance(self_in)) {
- return MP_OBJ_TO_PTR(self_in);
- @@ -126,7 +126,7 @@ STATIC mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
- }
- }
-
- -STATIC void decompress_error_text_maybe(mp_obj_exception_t *o) {
- +static void decompress_error_text_maybe(mp_obj_exception_t *o) {
- #if MICROPY_ROM_TEXT_COMPRESSION
- if (o->args->len == 1 && mp_obj_is_exact_type(o->args->items[0], &mp_type_str)) {
- mp_obj_str_t *o_str = MP_OBJ_TO_PTR(o->args->items[0]);
- @@ -439,7 +439,7 @@ struct _exc_printer_t {
- byte *buf;
- };
-
- -STATIC void exc_add_strn(void *data, const char *str, size_t len) {
- +static void exc_add_strn(void *data, const char *str, size_t len) {
- struct _exc_printer_t *pr = data;
- if (pr->len + len >= pr->alloc) {
- // Not enough room for data plus a null byte so try to grow the buffer
- diff --git a/py/objfilter.c b/py/objfilter.c
- index 2a657fde4..7f1f700f6 100644
- --- a/py/objfilter.c
- +++ b/py/objfilter.c
- @@ -34,7 +34,7 @@ typedef struct _mp_obj_filter_t {
- mp_obj_t iter;
- } mp_obj_filter_t;
-
- -STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 2, 2, false);
- mp_obj_filter_t *o = mp_obj_malloc(mp_obj_filter_t, type);
- o->fun = args[0];
- @@ -42,7 +42,7 @@ STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t filter_iternext(mp_obj_t self_in) {
- +static mp_obj_t filter_iternext(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_filter));
- mp_obj_filter_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t next;
- diff --git a/py/objfloat.c b/py/objfloat.c
- index c862b4843..5c90b1491 100644
- --- a/py/objfloat.c
- +++ b/py/objfloat.c
- @@ -102,7 +102,7 @@ mp_int_t mp_float_hash(mp_float_t src) {
- }
- #endif
-
- -STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_float_t o_val = mp_obj_float_get(o_in);
- #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
- @@ -124,7 +124,7 @@ STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
- }
- }
-
- -STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
- mp_arg_check_num(n_args, n_kw, 0, 1, false);
-
- @@ -149,7 +149,7 @@ STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size
- }
- }
-
- -STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- +static mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- mp_float_t val = mp_obj_float_get(o_in);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- @@ -172,7 +172,7 @@ STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- }
- }
-
- -STATIC mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- mp_float_t lhs_val = mp_obj_float_get(lhs_in);
- #if MICROPY_PY_BUILTINS_COMPLEX
- if (mp_obj_is_type(rhs_in, &mp_type_complex)) {
- @@ -208,7 +208,7 @@ mp_float_t mp_obj_float_get(mp_obj_t self_in) {
-
- #endif
-
- -STATIC void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) {
- +static void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) {
- // logic here follows that of CPython
- // https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
- // x == (x//y)*y + (x%y)
- diff --git a/py/objfun.c b/py/objfun.c
- index e2136968b..1ebfa3d5a 100644
- --- a/py/objfun.c
- +++ b/py/objfun.c
- @@ -48,7 +48,7 @@
- /******************************************************************************/
- /* builtin functions */
-
- -STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)args;
- assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_0));
- mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -61,7 +61,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- call, fun_builtin_0_call
- );
-
- -STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_1));
- mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
- mp_arg_check_num(n_args, n_kw, 1, 1, false);
- @@ -73,7 +73,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- call, fun_builtin_1_call
- );
-
- -STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_2));
- mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
- mp_arg_check_num(n_args, n_kw, 2, 2, false);
- @@ -85,7 +85,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- call, fun_builtin_2_call
- );
-
- -STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_3));
- mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
- mp_arg_check_num(n_args, n_kw, 3, 3, false);
- @@ -97,7 +97,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- call, fun_builtin_3_call
- );
-
- -STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_var));
- mp_obj_fun_builtin_var_t *self = MP_OBJ_TO_PTR(self_in);
-
- @@ -128,35 +128,29 @@ MP_DEFINE_CONST_OBJ_TYPE(
- /******************************************************************************/
- /* byte code functions */
-
- -STATIC qstr mp_obj_code_get_name(const mp_obj_fun_bc_t *fun, const byte *code_info) {
- - MP_BC_PRELUDE_SIZE_DECODE(code_info);
- - mp_uint_t name = mp_decode_uint_value(code_info);
- - #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
- - name = fun->context->constants.qstr_table[name];
- - #endif
- - return name;
- -}
- -
- -#if MICROPY_EMIT_NATIVE
- -STATIC const mp_obj_type_t mp_type_fun_native;
- -#endif
- -
- qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
- const mp_obj_fun_bc_t *fun = MP_OBJ_TO_PTR(fun_in);
- + const byte *bc = fun->bytecode;
- +
- #if MICROPY_EMIT_NATIVE
- if (fun->base.type == &mp_type_fun_native || fun->base.type == &mp_type_native_gen_wrap) {
- - // TODO native functions don't have name stored
- - return MP_QSTR_;
- + bc = mp_obj_fun_native_get_prelude_ptr(fun);
- }
- #endif
-
- - const byte *bc = fun->bytecode;
- MP_BC_PRELUDE_SIG_DECODE(bc);
- - return mp_obj_code_get_name(fun, bc);
- + MP_BC_PRELUDE_SIZE_DECODE(bc);
- +
- + mp_uint_t name = mp_decode_uint_value(bc);
- + #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
- + name = fun->context->constants.qstr_table[name];
- + #endif
- +
- + return name;
- }
-
- #if MICROPY_CPYTHON_COMPAT
- -STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(o_in);
- mp_printf(print, "<function %q at 0x%p>", mp_obj_fun_get_name(o_in), o);
- @@ -164,7 +158,7 @@ STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
- #endif
-
- #if DEBUG_PRINT
- -STATIC void dump_args(const mp_obj_t *a, size_t sz) {
- +static void dump_args(const mp_obj_t *a, size_t sz) {
- DEBUG_printf("%p: ", a);
- for (size_t i = 0; i < sz; i++) {
- DEBUG_printf("%p ", a[i]);
- @@ -230,7 +224,7 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args
- }
- #endif
-
- -STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- MP_STACK_CHECK();
-
- DEBUG_printf("Input n_args: " UINT_FMT ", n_kw: " UINT_FMT "\n", n_args, n_kw);
- @@ -384,7 +378,7 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
- def_kw_args = def_args[1];
- n_extra_args += 1;
- }
- - mp_obj_fun_bc_t *o = mp_obj_malloc_var(mp_obj_fun_bc_t, mp_obj_t, n_extra_args, &mp_type_fun_bc);
- + mp_obj_fun_bc_t *o = mp_obj_malloc_var(mp_obj_fun_bc_t, extra_args, mp_obj_t, n_extra_args, &mp_type_fun_bc);
- o->bytecode = code;
- o->context = context;
- o->child_table = child_table;
- @@ -402,10 +396,10 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
-
- #if MICROPY_EMIT_NATIVE
-
- -STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- MP_STACK_CHECK();
- mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
- - mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
- + mp_call_fun_t fun = mp_obj_fun_native_get_function_start(self);
- return fun(self_in, n_args, n_kw, args);
- }
-
- @@ -420,7 +414,7 @@ STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, co
- #define FUN_BC_TYPE_ATTR
- #endif
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_fun_native,
- MP_QSTR_function,
- MP_TYPE_FLAG_BINDS_SELF,
- @@ -429,12 +423,27 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
- call, fun_native_call
- );
-
- -mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
- - mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
- - o->base.type = &mp_type_fun_native;
- - return MP_OBJ_FROM_PTR(o);
- +#endif // MICROPY_EMIT_NATIVE
- +
- +/******************************************************************************/
- +/* viper functions */
- +
- +#if MICROPY_EMIT_NATIVE
- +
- +static mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- + MP_STACK_CHECK();
- + mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
- + mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
- + return fun(self_in, n_args, n_kw, args);
- }
-
- +MP_DEFINE_CONST_OBJ_TYPE(
- + mp_type_fun_viper,
- + MP_QSTR_function,
- + MP_TYPE_FLAG_BINDS_SELF,
- + call, fun_viper_call
- + );
- +
- #endif // MICROPY_EMIT_NATIVE
-
- /******************************************************************************/
- @@ -442,13 +451,6 @@ mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, c
-
- #if MICROPY_EMIT_INLINE_ASM
-
- -typedef struct _mp_obj_fun_asm_t {
- - mp_obj_base_t base;
- - size_t n_args;
- - const void *fun_data; // GC must be able to trace this pointer
- - mp_uint_t type_sig;
- -} mp_obj_fun_asm_t;
- -
- typedef mp_uint_t (*inline_asm_fun_0_t)(void);
- typedef mp_uint_t (*inline_asm_fun_1_t)(mp_uint_t);
- typedef mp_uint_t (*inline_asm_fun_2_t)(mp_uint_t, mp_uint_t);
- @@ -456,7 +458,7 @@ typedef mp_uint_t (*inline_asm_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t);
- typedef mp_uint_t (*inline_asm_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t);
-
- // convert a MicroPython object to a sensible value for inline asm
- -STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
- +static mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
- // TODO for byte_array, pass pointer to the array
- if (mp_obj_is_small_int(obj)) {
- return MP_OBJ_SMALL_INT_VALUE(obj);
- @@ -499,7 +501,7 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
- }
- }
-
- -STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_obj_fun_asm_t *self = MP_OBJ_TO_PTR(self_in);
-
- mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
- @@ -529,19 +531,11 @@ STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
- return mp_native_to_obj(ret, self->type_sig);
- }
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_fun_asm,
- MP_QSTR_function,
- MP_TYPE_FLAG_BINDS_SELF,
- call, fun_asm_call
- );
-
- -mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
- - mp_obj_fun_asm_t *o = mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
- - o->n_args = n_args;
- - o->fun_data = fun_data;
- - o->type_sig = type_sig;
- - return MP_OBJ_FROM_PTR(o);
- -}
- -
- #endif // MICROPY_EMIT_INLINE_ASM
- diff --git a/py/objfun.h b/py/objfun.h
- index 9de15b884..af7c33485 100644
- --- a/py/objfun.h
- +++ b/py/objfun.h
- @@ -43,9 +43,70 @@ typedef struct _mp_obj_fun_bc_t {
- mp_obj_t extra_args[];
- } mp_obj_fun_bc_t;
-
- +typedef struct _mp_obj_fun_asm_t {
- + mp_obj_base_t base;
- + size_t n_args;
- + const void *fun_data; // GC must be able to trace this pointer
- + mp_uint_t type_sig;
- +} mp_obj_fun_asm_t;
- +
- mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_module_context_t *cm, struct _mp_raw_code_t *const *raw_code_table);
- -mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *cm, struct _mp_raw_code_t *const *raw_code_table);
- -mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig);
- void mp_obj_fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
-
- +#if MICROPY_EMIT_NATIVE
- +
- +static inline mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
- + mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
- + o->base.type = &mp_type_fun_native;
- + return MP_OBJ_FROM_PTR(o);
- +}
- +
- +static inline mp_obj_t mp_obj_new_fun_viper(const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
- + mp_obj_fun_bc_t *o = mp_obj_malloc(mp_obj_fun_bc_t, &mp_type_fun_viper);
- + o->bytecode = fun_data;
- + o->context = mc;
- + o->child_table = child_table;
- + return MP_OBJ_FROM_PTR(o);
- +}
- +
- +static inline const uint8_t *mp_obj_fun_native_get_prelude_ptr(const mp_obj_fun_bc_t *fun_native) {
- + // Obtain a pointer to the start of the function prelude, based on prelude_ptr_index.
- + uintptr_t prelude_ptr_index = ((uintptr_t *)fun_native->bytecode)[0];
- + const uint8_t *prelude_ptr;
- + if (prelude_ptr_index == 0) {
- + prelude_ptr = (const uint8_t *)fun_native->child_table;
- + } else {
- + prelude_ptr = (const uint8_t *)fun_native->child_table[prelude_ptr_index];
- + }
- + return prelude_ptr;
- +}
- +
- +static inline void *mp_obj_fun_native_get_function_start(const mp_obj_fun_bc_t *fun_native) {
- + // Obtain a pointer to the start of the function executable machine code.
- + return MICROPY_MAKE_POINTER_CALLABLE((void *)(fun_native->bytecode + sizeof(uintptr_t)));
- +}
- +
- +static inline void *mp_obj_fun_native_get_generator_start(const mp_obj_fun_bc_t *fun_native) {
- + // Obtain a pointer to the start of the generator executable machine code.
- + uintptr_t start_offset = ((uintptr_t *)fun_native->bytecode)[1];
- + return MICROPY_MAKE_POINTER_CALLABLE((void *)(fun_native->bytecode + start_offset));
- +}
- +
- +static inline void *mp_obj_fun_native_get_generator_resume(const mp_obj_fun_bc_t *fun_native) {
- + // Obtain a pointer to the resume location of the generator executable machine code.
- + return MICROPY_MAKE_POINTER_CALLABLE((void *)&((uintptr_t *)fun_native->bytecode)[2]);
- +}
- +
- +#endif
- +
- +#if MICROPY_EMIT_INLINE_ASM
- +static inline mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
- + mp_obj_fun_asm_t *o = mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
- + o->n_args = n_args;
- + o->fun_data = fun_data;
- + o->type_sig = type_sig;
- + return MP_OBJ_FROM_PTR(o);
- +}
- +#endif
- +
- #endif // MICROPY_INCLUDED_PY_OBJFUN_H
- diff --git a/py/objgenerator.c b/py/objgenerator.c
- index ecd1f583e..431cbad5a 100644
- --- a/py/objgenerator.c
- +++ b/py/objgenerator.c
- @@ -50,7 +50,7 @@ typedef struct _mp_obj_gen_instance_t {
- mp_code_state_t code_state;
- } mp_obj_gen_instance_t;
-
- -STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- // A generating function is just a bytecode function with type mp_type_gen_wrap
- mp_obj_fun_bc_t *self_fun = MP_OBJ_TO_PTR(self_in);
-
- @@ -59,7 +59,7 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
- MP_BC_PRELUDE_SIG_DECODE(ip);
-
- // allocate the generator object, with room for local stack and exception stack
- - mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, byte,
- + mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, code_state.state, byte,
- n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t),
- &mp_type_gen_instance);
-
- @@ -96,40 +96,31 @@ typedef struct _mp_obj_gen_instance_native_t {
- mp_code_state_native_t code_state;
- } mp_obj_gen_instance_native_t;
-
- -STATIC mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- // The state for a native generating function is held in the same struct as a bytecode function
- mp_obj_fun_bc_t *self_fun = MP_OBJ_TO_PTR(self_in);
-
- // Determine start of prelude.
- - uintptr_t prelude_ptr_index = ((uintptr_t *)self_fun->bytecode)[0];
- - const uint8_t *prelude_ptr;
- - if (prelude_ptr_index == 0) {
- - prelude_ptr = (void *)self_fun->child_table;
- - } else {
- - prelude_ptr = (void *)self_fun->child_table[prelude_ptr_index];
- - }
- + const uint8_t *prelude_ptr = mp_obj_fun_native_get_prelude_ptr(self_fun);
-
- // Extract n_state from the prelude.
- const uint8_t *ip = prelude_ptr;
- MP_BC_PRELUDE_SIG_DECODE(ip);
-
- // Allocate the generator object, with room for local stack (exception stack not needed).
- - mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, byte, n_state * sizeof(mp_obj_t), &mp_type_gen_instance);
- + mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, code_state.state, byte, n_state * sizeof(mp_obj_t), &mp_type_gen_instance);
-
- // Parse the input arguments and set up the code state
- o->pend_exc = mp_const_none;
- o->code_state.fun_bc = self_fun;
- - o->code_state.ip = prelude_ptr;
- o->code_state.n_state = n_state;
- - o->code_state.sp = &o->code_state.state[0] - 1;
- mp_setup_code_state_native(&o->code_state, n_args, n_kw, args);
-
- // Indicate we are a native function, which doesn't use this variable
- o->code_state.exc_sp_idx = MP_CODE_STATE_EXC_SP_IDX_SENTINEL;
-
- // Prepare the generator instance for execution
- - uintptr_t start_offset = ((uintptr_t *)self_fun->bytecode)[1];
- - o->code_state.ip = MICROPY_MAKE_POINTER_CALLABLE((void *)(self_fun->bytecode + start_offset));
- + o->code_state.ip = mp_obj_fun_native_get_generator_start(self_fun);
-
- return MP_OBJ_FROM_PTR(o);
- }
- @@ -153,7 +144,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- /******************************************************************************/
- /* generator instance */
-
- -STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
- mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
- @@ -208,9 +199,9 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
-
- #if MICROPY_EMIT_NATIVE
- if (self->code_state.exc_sp_idx == MP_CODE_STATE_EXC_SP_IDX_SENTINEL) {
- - // A native generator, with entry point 2 words into the "bytecode" pointer
- + // A native generator.
- typedef uintptr_t (*mp_fun_native_gen_t)(void *, mp_obj_t);
- - mp_fun_native_gen_t fun = MICROPY_MAKE_POINTER_CALLABLE((const void *)(self->code_state.fun_bc->bytecode + 2 * sizeof(uintptr_t)));
- + mp_fun_native_gen_t fun = mp_obj_fun_native_get_generator_resume(self->code_state.fun_bc);
- ret_kind = fun((void *)&self->code_state, throw_value);
- } else
- #endif
- @@ -263,7 +254,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
- return ret_kind;
- }
-
- -STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, bool raise_stop_iteration) {
- +static mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, bool raise_stop_iteration) {
- mp_obj_t ret;
- switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) {
- case MP_VM_RETURN_NORMAL:
- @@ -287,16 +278,16 @@ STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_o
- }
- }
-
- -STATIC mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
- +static mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
- return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL, false);
- }
-
- -STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
- +static mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
- return gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL, true);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
- +static MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
-
- -STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
- // The signature of this function is: throw(type[, value[, traceback]])
- // CPython will pass all given arguments through the call chain and process them
- // at the point they are used (native generators will handle them differently to
- @@ -316,9 +307,9 @@ STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
-
- return gen_resume_and_raise(args[0], mp_const_none, exc, true);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw);
-
- -STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {
- +static mp_obj_t gen_instance_close(mp_obj_t self_in) {
- mp_obj_t ret;
- switch (mp_obj_gen_resume(self_in, mp_const_none, MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj), &ret)) {
- case MP_VM_RETURN_YIELD:
- @@ -337,10 +328,10 @@ STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {
- return mp_const_none;
- }
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close);
- +static MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close);
-
- #if MICROPY_PY_GENERATOR_PEND_THROW
- -STATIC mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
- +static mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
- mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
- if (self->pend_exc == MP_OBJ_NULL) {
- mp_raise_ValueError(MP_ERROR_TEXT("generator already executing"));
- @@ -349,10 +340,10 @@ STATIC mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
- self->pend_exc = exc_in;
- return prev;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_pend_throw_obj, gen_instance_pend_throw);
- +static MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_pend_throw_obj, gen_instance_pend_throw);
- #endif
-
- -STATIC const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
- +static const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&gen_instance_close_obj) },
- { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&gen_instance_send_obj) },
- { MP_ROM_QSTR(MP_QSTR_throw), MP_ROM_PTR(&gen_instance_throw_obj) },
- @@ -361,7 +352,7 @@ STATIC const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_gen_instance,
- diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c
- index c598d1daa..c735c65b6 100644
- --- a/py/objgetitemiter.c
- +++ b/py/objgetitemiter.c
- @@ -35,7 +35,7 @@ typedef struct _mp_obj_getitem_iter_t {
- mp_obj_t args[3];
- } mp_obj_getitem_iter_t;
-
- -STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
- +static mp_obj_t it_iternext(mp_obj_t self_in) {
- mp_obj_getitem_iter_t *self = MP_OBJ_TO_PTR(self_in);
- nlr_buf_t nlr;
- if (nlr_push(&nlr) == 0) {
- @@ -56,7 +56,7 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
- }
- }
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_it,
- MP_QSTR_iterator,
- MP_TYPE_FLAG_ITER_IS_ITERNEXT,
- diff --git a/py/objint.c b/py/objint.c
- index be5f4653a..6caa608f3 100644
- --- a/py/objint.c
- +++ b/py/objint.c
- @@ -40,7 +40,7 @@
- #endif
-
- // This dispatcher function is expected to be independent of the implementation of long int
- -STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
- mp_arg_check_num(n_args, n_kw, 0, 2, false);
-
- @@ -83,7 +83,7 @@ typedef enum {
- MP_FP_CLASS_OVERFLOW
- } mp_fp_as_int_class_t;
-
- -STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
- +static mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
- union {
- mp_float_t f;
- #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
- @@ -193,7 +193,7 @@ void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
- }
- }
-
- -STATIC const uint8_t log_base2_floor[] = {
- +static const uint8_t log_base2_floor[] = {
- 0, 1, 1, 2,
- 2, 2, 2, 3,
- 3, 3, 3, 3,
- @@ -388,7 +388,7 @@ mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp
- }
-
- // this is a classmethod
- -STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
- // TODO: Support signed param (assumes signed=False at the moment)
- (void)n_args;
-
- @@ -417,10 +417,10 @@ STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
- return mp_obj_new_int_from_uint(value);
- }
-
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);
- -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj));
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);
- +static MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj));
-
- -STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
- // TODO: Support signed param (assumes signed=False)
- (void)n_args;
-
- @@ -448,14 +448,14 @@ STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
-
- return mp_obj_new_bytes_from_vstr(&vstr);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes);
-
- -STATIC const mp_rom_map_elem_t int_locals_dict_table[] = {
- +static const mp_rom_map_elem_t int_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) },
- { MP_ROM_QSTR(MP_QSTR_to_bytes), MP_ROM_PTR(&int_to_bytes_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_int,
- diff --git a/py/objint_mpz.c b/py/objint_mpz.c
- index 8078441d6..600316a42 100644
- --- a/py/objint_mpz.c
- +++ b/py/objint_mpz.c
- @@ -43,7 +43,7 @@
- // Export value for sys.maxsize
- // *FORMAT-OFF*
- #define DIG_MASK ((MPZ_LONG_1 << MPZ_DIG_SIZE) - 1)
- -STATIC const mpz_dig_t maxsize_dig[] = {
- +static const mpz_dig_t maxsize_dig[] = {
- #define NUM_DIG 1
- (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) & DIG_MASK,
- #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) > DIG_MASK
- @@ -335,7 +335,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
- }
-
- #if MICROPY_PY_BUILTINS_POW3
- -STATIC mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
- +static mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
- if (mp_obj_is_small_int(arg)) {
- mpz_init_from_int(temp, MP_OBJ_SMALL_INT_VALUE(arg));
- return temp;
- diff --git a/py/objlist.c b/py/objlist.c
- index 1423cb1de..2198beb83 100644
- --- a/py/objlist.c
- +++ b/py/objlist.c
- @@ -31,10 +31,10 @@
- #include "py/runtime.h"
- #include "py/stackctrl.h"
-
- -STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf);
- -STATIC mp_obj_list_t *list_new(size_t n);
- -STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
- -STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
- +static mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf);
- +static mp_obj_list_t *list_new(size_t n);
- +static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
- +static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
-
- // TODO: Move to mpconfig.h
- #define LIST_MIN_ALLOC 4
- @@ -42,7 +42,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
- /******************************************************************************/
- /* list */
-
- -STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in);
- const char *item_separator = ", ";
- if (!(MICROPY_PY_JSON && kind == PRINT_JSON)) {
- @@ -62,7 +62,7 @@ STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
- mp_print_str(print, "]");
- }
-
- -STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
- +static mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
- mp_obj_t iter = mp_getiter(iterable, NULL);
- mp_obj_t item;
- while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
- @@ -90,7 +90,7 @@ mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
- }
- }
-
- -STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- @@ -108,7 +108,7 @@ STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- }
- }
-
- -STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
- +static mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
- mp_obj_list_t *o = MP_OBJ_TO_PTR(lhs);
- switch (op) {
- case MP_BINARY_OP_ADD: {
- @@ -158,7 +158,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
- }
- }
-
- -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- +static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- if (value == MP_OBJ_NULL) {
- // delete
- #if MICROPY_PY_BUILTINS_SLICE
- @@ -234,7 +234,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- }
- }
-
- -STATIC mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
- return mp_obj_new_list_iterator(o_in, 0, iter_buf);
- }
-
- @@ -250,7 +250,7 @@ mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) {
- return mp_const_none; // return None, as per CPython
- }
-
- -STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
- +static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
- if (mp_obj_is_type(arg_in, &mp_type_list)) {
- mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -271,7 +271,7 @@ STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
- return mp_const_none; // return None, as per CPython
- }
-
- -STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
- mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
- mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]);
- if (self->len == 0) {
- @@ -290,7 +290,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
- return ret;
- }
-
- -STATIC void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) {
- +static void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) {
- MP_STACK_CHECK();
- while (head < tail) {
- mp_obj_t *h = head - 1;
- @@ -348,7 +348,7 @@ mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_
- return mp_const_none;
- }
-
- -STATIC mp_obj_t list_clear(mp_obj_t self_in) {
- +static mp_obj_t list_clear(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
- mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
- self->len = 0;
- @@ -358,25 +358,25 @@ STATIC mp_obj_t list_clear(mp_obj_t self_in) {
- return mp_const_none;
- }
-
- -STATIC mp_obj_t list_copy(mp_obj_t self_in) {
- +static mp_obj_t list_copy(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
- mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_list(self->len, self->items);
- }
-
- -STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
- +static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
- mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_seq_count_obj(self->items, self->len, value);
- }
-
- -STATIC mp_obj_t list_index(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t list_index(size_t n_args, const mp_obj_t *args) {
- mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
- mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]);
- return mp_seq_index_obj(self->items, self->len, n_args, args);
- }
-
- -STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
- +static mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
- mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
- // insert has its own strange index logic
- @@ -410,7 +410,7 @@ mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) {
- return mp_const_none;
- }
-
- -STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
- +static mp_obj_t list_reverse(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
- mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
-
- @@ -424,19 +424,19 @@ STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
- return mp_const_none;
- }
-
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
- -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort);
- -
- -STATIC const mp_rom_map_elem_t list_locals_dict_table[] = {
- +static MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
- +static MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
- +static MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
- +static MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
- +static MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
- +static MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
- +static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove);
- +static MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
- +static MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort);
- +
- +static const mp_rom_map_elem_t list_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&list_append_obj) },
- { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&list_clear_obj) },
- { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&list_copy_obj) },
- @@ -450,7 +450,7 @@ STATIC const mp_rom_map_elem_t list_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_sort), MP_ROM_PTR(&list_sort_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_list,
- @@ -474,7 +474,7 @@ void mp_obj_list_init(mp_obj_list_t *o, size_t n) {
- mp_seq_clear(o->items, n, o->alloc, sizeof(*o->items));
- }
-
- -STATIC mp_obj_list_t *list_new(size_t n) {
- +static mp_obj_list_t *list_new(size_t n) {
- mp_obj_list_t *o = m_new_obj(mp_obj_list_t);
- mp_obj_list_init(o, n);
- return o;
- @@ -519,7 +519,7 @@ typedef struct _mp_obj_list_it_t {
- size_t cur;
- } mp_obj_list_it_t;
-
- -STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t list_it_iternext(mp_obj_t self_in) {
- mp_obj_list_it_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_list_t *list = MP_OBJ_TO_PTR(self->list);
- if (self->cur < list->len) {
- diff --git a/py/objmap.c b/py/objmap.c
- index e7e594cd2..1911a7510 100644
- --- a/py/objmap.c
- +++ b/py/objmap.c
- @@ -36,9 +36,9 @@ typedef struct _mp_obj_map_t {
- mp_obj_t iters[];
- } mp_obj_map_t;
-
- -STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 2, MP_OBJ_FUN_ARGS_MAX, false);
- - mp_obj_map_t *o = mp_obj_malloc_var(mp_obj_map_t, mp_obj_t, n_args - 1, type);
- + mp_obj_map_t *o = mp_obj_malloc_var(mp_obj_map_t, iters, mp_obj_t, n_args - 1, type);
- o->n_iters = n_args - 1;
- o->fun = args[0];
- for (size_t i = 0; i < n_args - 1; i++) {
- @@ -47,7 +47,7 @@ STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t map_iternext(mp_obj_t self_in) {
- +static mp_obj_t map_iternext(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_map));
- mp_obj_map_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t *nextses = m_new(mp_obj_t, self->n_iters);
- diff --git a/py/objmodule.c b/py/objmodule.c
- index 5266421b7..5ce373b83 100644
- --- a/py/objmodule.c
- +++ b/py/objmodule.c
- @@ -34,7 +34,7 @@
- #include "py/runtime.h"
- #include "py/builtin.h"
-
- -STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
-
- @@ -57,9 +57,9 @@ STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin
- mp_printf(print, "<module '%s'>", module_name);
- }
-
- -STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
- +static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
-
- -STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
- if (dest[0] == MP_OBJ_NULL) {
- // load attribute
- @@ -146,13 +146,13 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
- /******************************************************************************/
- // Global module table and related functions
-
- -STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
- +static const mp_rom_map_elem_t mp_builtin_module_table[] = {
- // built-in modules declared with MP_REGISTER_MODULE()
- MICROPY_REGISTERED_MODULES
- };
- MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table);
-
- -STATIC const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = {
- +static const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = {
- // built-in modules declared with MP_REGISTER_EXTENSIBLE_MODULE()
- MICROPY_REGISTERED_EXTENSIBLE_MODULES
- };
- @@ -164,7 +164,7 @@ typedef struct _mp_module_delegation_entry_t {
- mp_attr_fun_t fun;
- } mp_module_delegation_entry_t;
-
- -STATIC const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = {
- +static const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = {
- // delegation entries declared with MP_REGISTER_MODULE_DELEGATION()
- MICROPY_MODULE_DELEGATIONS
- };
- @@ -223,7 +223,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
- return elem->value;
- }
-
- -STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- #if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS)
- // Delegate lookup to a module's custom attr method.
- size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table);
- diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
- index e586f0894..f019604d5 100644
- --- a/py/objnamedtuple.c
- +++ b/py/objnamedtuple.c
- @@ -44,7 +44,7 @@ size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr n
- }
-
- #if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
- -STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
- +static mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
- mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
- const qstr *fields = ((mp_obj_namedtuple_type_t *)self->tuple.base.type)->fields;
- mp_obj_t dict = mp_obj_new_dict(self->tuple.len);
- @@ -60,7 +60,7 @@ STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
- MP_DEFINE_CONST_FUN_OBJ_1(namedtuple_asdict_obj, namedtuple_asdict);
- #endif
-
- -STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_namedtuple_t *o = MP_OBJ_TO_PTR(o_in);
- mp_printf(print, "%q", o->tuple.base.type->name);
- @@ -68,7 +68,7 @@ STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_ki
- mp_obj_attrtuple_print_helper(print, fields, &o->tuple);
- }
-
- -STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] == MP_OBJ_NULL) {
- // load attribute
- mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -91,7 +91,7 @@ STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- }
- }
-
- -STATIC mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t *)type_in;
- size_t num_fields = type->n_fields;
- if (n_args + n_kw != num_fields) {
- @@ -110,7 +110,7 @@ STATIC mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args,
-
- // Create a namedtuple with explicit malloc. Calling mp_obj_new_tuple
- // with num_fields=0 returns a read-only object.
- - mp_obj_tuple_t *tuple = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, num_fields, type_in);
- + mp_obj_tuple_t *tuple = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, num_fields, type_in);
- tuple->len = num_fields;
-
- // Copy the positional args into the first slots of the namedtuple
- @@ -151,7 +151,7 @@ mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *
- return o;
- }
-
- -STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) {
- +static mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) {
- mp_obj_namedtuple_type_t *o = mp_obj_new_namedtuple_base(n_fields, fields);
- mp_obj_type_t *type = (mp_obj_type_t *)&o->base;
- type->base.type = &mp_type_type;
- @@ -168,7 +168,7 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
- +static mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
- qstr name = mp_obj_str_get_qstr(name_in);
- size_t n_fields;
- mp_obj_t *fields;
- diff --git a/py/objnone.c b/py/objnone.c
- index 5b25cd38c..a8ce8ebfe 100644
- --- a/py/objnone.c
- +++ b/py/objnone.c
- @@ -34,7 +34,7 @@ typedef struct _mp_obj_none_t {
- } mp_obj_none_t;
- #endif
-
- -STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)self_in;
- if (MICROPY_PY_JSON && kind == PRINT_JSON) {
- mp_print_str(print, "null");
- diff --git a/py/objobject.c b/py/objobject.c
- index 1acae6d00..ff93fd082 100644
- --- a/py/objobject.c
- +++ b/py/objobject.c
- @@ -33,7 +33,7 @@ typedef struct _mp_obj_object_t {
- mp_obj_base_t base;
- } mp_obj_object_t;
-
- -STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)args;
- mp_arg_check_num(n_args, n_kw, 0, 0, false);
- mp_obj_object_t *o = mp_obj_malloc(mp_obj_object_t, type);
- @@ -41,13 +41,13 @@ STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t
- }
-
- #if MICROPY_CPYTHON_COMPAT
- -STATIC mp_obj_t object___init__(mp_obj_t self) {
- +static mp_obj_t object___init__(mp_obj_t self) {
- (void)self;
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
- +static MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
-
- -STATIC mp_obj_t object___new__(mp_obj_t cls) {
- +static mp_obj_t object___new__(mp_obj_t cls) {
- if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) {
- mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
- }
- @@ -58,11 +58,11 @@ STATIC mp_obj_t object___new__(mp_obj_t cls) {
- const mp_obj_type_t *native_base;
- return MP_OBJ_FROM_PTR(mp_obj_new_instance(MP_OBJ_TO_PTR(cls), &native_base));
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
- -STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));
- +static MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
- +static MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));
-
- #if MICROPY_PY_DELATTR_SETATTR
- -STATIC mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) {
- +static mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) {
- if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) {
- mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
- }
- @@ -75,9 +75,9 @@ STATIC mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t val
- mp_map_lookup(&self->members, attr, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__);
- +static MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__);
-
- -STATIC mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
- +static mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
- if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) {
- mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
- }
- @@ -92,10 +92,10 @@ STATIC mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
- }
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__);
- +static MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__);
- #endif
-
- -STATIC const mp_rom_map_elem_t object_locals_dict_table[] = {
- +static const mp_rom_map_elem_t object_locals_dict_table[] = {
- #if MICROPY_CPYTHON_COMPAT
- { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&object___init___obj) },
- #endif
- @@ -108,7 +108,7 @@ STATIC const mp_rom_map_elem_t object_locals_dict_table[] = {
- #endif
- };
-
- -STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
- #endif
-
- #if MICROPY_CPYTHON_COMPAT
- diff --git a/py/objpolyiter.c b/py/objpolyiter.c
- index 78b600aba..65c1f182e 100644
- --- a/py/objpolyiter.c
- +++ b/py/objpolyiter.c
- @@ -39,7 +39,7 @@ typedef struct _mp_obj_polymorph_iter_t {
- mp_fun_1_t iternext;
- } mp_obj_polymorph_iter_t;
-
- -STATIC mp_obj_t polymorph_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t polymorph_it_iternext(mp_obj_t self_in) {
- mp_obj_polymorph_iter_t *self = MP_OBJ_TO_PTR(self_in);
- // Redirect call to object instance's iternext method
- return self->iternext(self_in);
- @@ -64,17 +64,17 @@ typedef struct _mp_obj_polymorph_iter_with_finaliser_t {
- mp_fun_1_t finaliser;
- } mp_obj_polymorph_with_finaliser_iter_t;
-
- -STATIC mp_obj_t mp_obj_polymorph_iter_del(mp_obj_t self_in) {
- +static mp_obj_t mp_obj_polymorph_iter_del(mp_obj_t self_in) {
- mp_obj_polymorph_with_finaliser_iter_t *self = MP_OBJ_TO_PTR(self_in);
- // Redirect call to object instance's finaliser method
- return self->finaliser(self_in);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_obj_polymorph_iter_del_obj, mp_obj_polymorph_iter_del);
- +static MP_DEFINE_CONST_FUN_OBJ_1(mp_obj_polymorph_iter_del_obj, mp_obj_polymorph_iter_del);
-
- -STATIC const mp_rom_map_elem_t mp_obj_polymorph_iter_locals_dict_table[] = {
- +static const mp_rom_map_elem_t mp_obj_polymorph_iter_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_obj_polymorph_iter_del_obj) },
- };
- -STATIC MP_DEFINE_CONST_DICT(mp_obj_polymorph_iter_locals_dict, mp_obj_polymorph_iter_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(mp_obj_polymorph_iter_locals_dict, mp_obj_polymorph_iter_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_polymorph_iter_with_finaliser,
- diff --git a/py/objproperty.c b/py/objproperty.c
- index 2d3af10e8..155ffb16b 100644
- --- a/py/objproperty.c
- +++ b/py/objproperty.c
- @@ -36,7 +36,7 @@ typedef struct _mp_obj_property_t {
- mp_obj_t proxy[3]; // getter, setter, deleter
- } mp_obj_property_t;
-
- -STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- enum { ARG_fget, ARG_fset, ARG_fdel, ARG_doc };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
- @@ -55,40 +55,40 @@ STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) {
- +static mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) {
- mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
- *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
- p2->proxy[0] = getter;
- return MP_OBJ_FROM_PTR(p2);
- }
-
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter);
- +static MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter);
-
- -STATIC mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) {
- +static mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) {
- mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
- *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
- p2->proxy[1] = setter;
- return MP_OBJ_FROM_PTR(p2);
- }
-
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter);
- +static MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter);
-
- -STATIC mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) {
- +static mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) {
- mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
- *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
- p2->proxy[2] = deleter;
- return MP_OBJ_FROM_PTR(p2);
- }
-
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter);
- +static MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter);
-
- -STATIC const mp_rom_map_elem_t property_locals_dict_table[] = {
- +static const mp_rom_map_elem_t property_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_getter), MP_ROM_PTR(&property_getter_obj) },
- { MP_ROM_QSTR(MP_QSTR_setter), MP_ROM_PTR(&property_setter_obj) },
- { MP_ROM_QSTR(MP_QSTR_deleter), MP_ROM_PTR(&property_deleter_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_property,
- diff --git a/py/objrange.c b/py/objrange.c
- index f0fe56d9d..9a4ecd3fc 100644
- --- a/py/objrange.c
- +++ b/py/objrange.c
- @@ -39,7 +39,7 @@ typedef struct _mp_obj_range_it_t {
- mp_int_t step;
- } mp_obj_range_it_t;
-
- -STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
- +static mp_obj_t range_it_iternext(mp_obj_t o_in) {
- mp_obj_range_it_t *o = MP_OBJ_TO_PTR(o_in);
- if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) {
- mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(o->cur);
- @@ -50,14 +50,14 @@ STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
- }
- }
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_range_it,
- MP_QSTR_iterator,
- MP_TYPE_FLAG_ITER_IS_ITERNEXT,
- iter, range_it_iternext
- );
-
- -STATIC mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) {
- assert(sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t));
- mp_obj_range_it_t *o = (mp_obj_range_it_t *)iter_buf;
- o->base.type = &mp_type_range_it;
- @@ -78,7 +78,7 @@ typedef struct _mp_obj_range_t {
- mp_int_t step;
- } mp_obj_range_t;
-
- -STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
- mp_printf(print, "range(" INT_FMT ", " INT_FMT "", self->start, self->stop);
- @@ -89,7 +89,7 @@ STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind
- }
- }
-
- -STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 1, 3, false);
-
- mp_obj_range_t *o = mp_obj_malloc(mp_obj_range_t, type);
- @@ -112,7 +112,7 @@ STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_int_t range_len(mp_obj_range_t *self) {
- +static mp_int_t range_len(mp_obj_range_t *self) {
- // When computing length, need to take into account step!=1 and step<0.
- mp_int_t len = self->stop - self->start + self->step;
- if (self->step > 0) {
- @@ -127,7 +127,7 @@ STATIC mp_int_t range_len(mp_obj_range_t *self) {
- return len;
- }
-
- -STATIC mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
- mp_int_t len = range_len(self);
- switch (op) {
- @@ -141,7 +141,7 @@ STATIC mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- }
-
- #if MICROPY_PY_BUILTINS_RANGE_BINOP
- -STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- if (!mp_obj_is_type(rhs_in, &mp_type_range) || op != MP_BINARY_OP_EQUAL) {
- return MP_OBJ_NULL; // op not supported
- }
- @@ -158,7 +158,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
- }
- #endif
-
- -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- +static mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- if (value == MP_OBJ_SENTINEL) {
- // load
- mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -185,14 +185,14 @@ STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- }
- }
-
- -STATIC mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
- mp_obj_range_t *o = MP_OBJ_TO_PTR(o_in);
- return mp_obj_new_range_iterator(o->start, o->stop, o->step, iter_buf);
- }
-
-
- #if MICROPY_PY_BUILTINS_RANGE_ATTRS
- -STATIC void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
- +static void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- // not load attribute
- return;
- diff --git a/py/objreversed.c b/py/objreversed.c
- index c66698f02..c580ee286 100644
- --- a/py/objreversed.c
- +++ b/py/objreversed.c
- @@ -37,7 +37,7 @@ typedef struct _mp_obj_reversed_t {
- mp_uint_t cur_index; // current index, plus 1; 0=no more, 1=last one (index 0)
- } mp_obj_reversed_t;
-
- -STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 1, 1, false);
-
- // check if __reversed__ exists, and if so delegate to it
- @@ -54,7 +54,7 @@ STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) {
- +static mp_obj_t reversed_iternext(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_reversed));
- mp_obj_reversed_t *self = MP_OBJ_TO_PTR(self_in);
-
- diff --git a/py/objset.c b/py/objset.c
- index 906807889..c8fa12a7e 100644
- --- a/py/objset.c
- +++ b/py/objset.c
- @@ -45,7 +45,7 @@ typedef struct _mp_obj_set_it_t {
- size_t cur;
- } mp_obj_set_it_t;
-
- -STATIC bool is_set_or_frozenset(mp_obj_t o) {
- +static bool is_set_or_frozenset(mp_obj_t o) {
- return mp_obj_is_type(o, &mp_type_set)
- #if MICROPY_PY_BUILTINS_FROZENSET
- || mp_obj_is_type(o, &mp_type_frozenset)
- @@ -60,7 +60,7 @@ STATIC bool is_set_or_frozenset(mp_obj_t o) {
- // set or frozenset for methods that operate on both of these types.
- #define check_set_or_frozenset(o) mp_check_self(is_set_or_frozenset(o))
-
- -STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- #if MICROPY_PY_BUILTINS_FROZENSET
- @@ -99,7 +99,7 @@ STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
- #endif
- }
-
- -STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 0, 1, false);
-
- switch (n_args) {
- @@ -127,7 +127,7 @@ STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
- }
- }
-
- -STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t set_it_iternext(mp_obj_t self_in) {
- mp_obj_set_it_t *self = MP_OBJ_TO_PTR(self_in);
- size_t max = self->set->set.alloc;
- mp_set_t *set = &self->set->set;
- @@ -142,7 +142,7 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
- return MP_OBJ_STOP_ITERATION;
- }
-
- -STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
- assert(sizeof(mp_obj_set_it_t) <= sizeof(mp_obj_iter_buf_t));
- mp_obj_set_it_t *o = (mp_obj_set_it_t *)iter_buf;
- o->base.type = &mp_type_polymorph_iter;
- @@ -155,23 +155,23 @@ STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
- /******************************************************************************/
- /* set methods */
-
- -STATIC mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
- +static mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
- check_set(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
-
- -STATIC mp_obj_t set_clear(mp_obj_t self_in) {
- +static mp_obj_t set_clear(mp_obj_t self_in) {
- check_set(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- mp_set_clear(&self->set);
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
- +static MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
-
- -STATIC mp_obj_t set_copy(mp_obj_t self_in) {
- +static mp_obj_t set_copy(mp_obj_t self_in) {
- check_set_or_frozenset(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_set_t *other = mp_obj_malloc(mp_obj_set_t, self->base.type);
- @@ -180,17 +180,17 @@ STATIC mp_obj_t set_copy(mp_obj_t self_in) {
- memcpy(other->set.table, self->set.table, self->set.alloc * sizeof(mp_obj_t));
- return MP_OBJ_FROM_PTR(other);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
- +static MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
-
- -STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
- +static mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
- check_set(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
-
- -STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
- +static mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
- mp_obj_t self;
- if (update) {
- check_set(args[0]);
- @@ -216,18 +216,18 @@ STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
- return self;
- }
-
- -STATIC mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) {
- return set_diff_int(n_args, args, false);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
-
- -STATIC mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) {
- set_diff_int(n_args, args, true);
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
-
- -STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
- +static mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
- if (update) {
- check_set(self_in);
- } else {
- @@ -259,17 +259,17 @@ STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update)
- return update ? mp_const_none : MP_OBJ_FROM_PTR(out);
- }
-
- -STATIC mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
- +static mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
- return set_intersect_int(self_in, other, false);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
-
- -STATIC mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
- +static mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
- return set_intersect_int(self_in, other, true);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
-
- -STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
- +static mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
- check_set_or_frozenset(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
-
- @@ -283,9 +283,9 @@ STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
- }
- return mp_const_true;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
-
- -STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
- +static mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
- mp_obj_set_t *self;
- bool cleanup_self = false;
- if (is_set_or_frozenset(self_in)) {
- @@ -327,25 +327,25 @@ STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool
- return out;
- }
-
- -STATIC mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
- return set_issubset_internal(self_in, other_in, false);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
-
- -STATIC mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
- return set_issubset_internal(self_in, other_in, true);
- }
-
- -STATIC mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
- return set_issubset_internal(other_in, self_in, false);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
-
- -STATIC mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
- return set_issubset_internal(other_in, self_in, true);
- }
-
- -STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
- assert(is_set_or_frozenset(other_in));
- check_set_or_frozenset(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -356,7 +356,7 @@ STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
- return set_issubset(self_in, other_in);
- }
-
- -STATIC mp_obj_t set_pop(mp_obj_t self_in) {
- +static mp_obj_t set_pop(mp_obj_t self_in) {
- check_set(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t obj = mp_set_remove_first(&self->set);
- @@ -365,9 +365,9 @@ STATIC mp_obj_t set_pop(mp_obj_t self_in) {
- }
- return obj;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
- +static MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
-
- -STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
- +static mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
- check_set(self_in);
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) {
- @@ -375,9 +375,9 @@ STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
- }
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
-
- -STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
- check_set_or_frozenset(self_in); // can be frozenset due to call from set_symmetric_difference
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t iter = mp_getiter(other_in, NULL);
- @@ -387,16 +387,16 @@ STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other
- }
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
-
- -STATIC mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
- mp_obj_t self_out = set_copy(self_in);
- set_symmetric_difference_update(self_out, other_in);
- return self_out;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
-
- -STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
- +static void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
- mp_obj_t iter = mp_getiter(other_in, NULL);
- mp_obj_t next;
- while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
- @@ -404,7 +404,7 @@ STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
- }
- }
-
- -STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
- check_set(args[0]);
- for (size_t i = 1; i < n_args; i++) {
- set_update_int(MP_OBJ_TO_PTR(args[0]), args[i]);
- @@ -412,17 +412,17 @@ STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
-
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
-
- -STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
- +static mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
- check_set_or_frozenset(self_in);
- mp_obj_t self = set_copy(self_in);
- set_update_int(MP_OBJ_TO_PTR(self), other_in);
- return self;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
- +static MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
-
- -STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- @@ -451,7 +451,7 @@ STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- }
- }
-
- -STATIC mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
- +static mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
- mp_obj_t args[] = {lhs, rhs};
- #if MICROPY_PY_BUILTINS_FROZENSET
- bool update = mp_obj_is_type(lhs, &mp_type_set);
- @@ -517,7 +517,7 @@ STATIC mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
- /******************************************************************************/
- /* set constructors & public C API */
-
- -STATIC const mp_rom_map_elem_t set_locals_dict_table[] = {
- +static const mp_rom_map_elem_t set_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_add), MP_ROM_PTR(&set_add_obj) },
- { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&set_clear_obj) },
- { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) },
- @@ -537,7 +537,7 @@ STATIC const mp_rom_map_elem_t set_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&set_update_obj) },
- { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) },
- };
- -STATIC MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_set,
- @@ -552,7 +552,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- );
-
- #if MICROPY_PY_BUILTINS_FROZENSET
- -STATIC const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
- +static const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) },
- { MP_ROM_QSTR(MP_QSTR_difference), MP_ROM_PTR(&set_diff_obj) },
- { MP_ROM_QSTR(MP_QSTR_intersection), MP_ROM_PTR(&set_intersect_obj) },
- @@ -563,7 +563,7 @@ STATIC const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_union), MP_ROM_PTR(&set_union_obj) },
- { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) },
- };
- -STATIC MP_DEFINE_CONST_DICT(frozenset_locals_dict, frozenset_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(frozenset_locals_dict, frozenset_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_frozenset,
- diff --git a/py/objsingleton.c b/py/objsingleton.c
- index 6537676c5..c1f102c94 100644
- --- a/py/objsingleton.c
- +++ b/py/objsingleton.c
- @@ -37,7 +37,7 @@ typedef struct _mp_obj_singleton_t {
- qstr name;
- } mp_obj_singleton_t;
-
- -STATIC void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_singleton_t *self = MP_OBJ_TO_PTR(self_in);
- mp_printf(print, "%q", self->name);
- diff --git a/py/objslice.c b/py/objslice.c
- index dcd6af8b2..3e7575522 100644
- --- a/py/objslice.c
- +++ b/py/objslice.c
- @@ -34,7 +34,7 @@
-
- #if MICROPY_PY_BUILTINS_SLICE
-
- -STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_slice_t *o = MP_OBJ_TO_PTR(o_in);
- mp_print_str(print, "slice(");
- @@ -46,14 +46,14 @@ STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
- mp_print_str(print, ")");
- }
-
- -STATIC mp_obj_t slice_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- +static mp_obj_t slice_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- // Needed to explicitly opt out of default __hash__.
- // REVISIT: CPython implements comparison operators for slice.
- return MP_OBJ_NULL;
- }
-
- #if MICROPY_PY_BUILTINS_SLICE_INDICES
- -STATIC mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
- +static mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
- mp_int_t length = mp_obj_get_int(length_obj);
- mp_bound_slice_t bound_indices;
- mp_obj_slice_indices(self_in, length, &bound_indices);
- @@ -65,11 +65,11 @@ STATIC mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
- };
- return mp_obj_new_tuple(3, results);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(slice_indices_obj, slice_indices);
- +static MP_DEFINE_CONST_FUN_OBJ_2(slice_indices_obj, slice_indices);
- #endif
-
- #if MICROPY_PY_BUILTINS_SLICE_ATTRS
- -STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- // not load attribute
- return;
- @@ -92,10 +92,10 @@ STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- #endif
-
- #if MICROPY_PY_BUILTINS_SLICE_INDICES && !MICROPY_PY_BUILTINS_SLICE_ATTRS
- -STATIC const mp_rom_map_elem_t slice_locals_dict_table[] = {
- +static const mp_rom_map_elem_t slice_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_indices), MP_ROM_PTR(&slice_indices_obj) },
- };
- -STATIC MP_DEFINE_CONST_DICT(slice_locals_dict, slice_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(slice_locals_dict, slice_locals_dict_table);
- #endif
-
- #if MICROPY_PY_BUILTINS_SLICE_ATTRS
- diff --git a/py/objstr.c b/py/objstr.c
- index 5dfe94ac4..c7e4ebf53 100644
- --- a/py/objstr.c
- +++ b/py/objstr.c
- @@ -35,15 +35,15 @@
- #include "py/stackctrl.h"
-
- #if MICROPY_PY_BUILTINS_STR_OP_MODULO
- -STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
- +static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
- #endif
-
- -STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
- -STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in);
- +static mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
- +static NORETURN void bad_implicit_conversion(mp_obj_t self_in);
-
- -STATIC mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
- +static mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
-
- -STATIC void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t arg) {
- +static void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t arg) {
- // String operations generally need the args type to match the object they're called on,
- // e.g. str.find(str), byte.startswith(byte)
- // with the exception that bytes may be used for bytearray and vice versa.
- @@ -63,7 +63,7 @@ STATIC void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t ar
- }
- }
-
- -STATIC void check_is_str_or_bytes(mp_obj_t self_in) {
- +static void check_is_str_or_bytes(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_str_or_bytes(self_in));
- }
-
- @@ -135,7 +135,7 @@ void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str
- }
- #endif
-
- -STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- GET_STR_DATA_LEN(self_in, str_data, str_len);
- #if MICROPY_PY_JSON
- if (kind == PRINT_JSON) {
- @@ -212,7 +212,7 @@ mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
- }
- }
-
- -STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
-
- #if MICROPY_CPYTHON_COMPAT
- @@ -458,7 +458,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
- #endif
-
- // This is used for both bytes and 8-bit strings. This is not used for unicode strings.
- -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- +static mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- const mp_obj_type_t *type = mp_obj_get_type(self_in);
- GET_STR_DATA_LEN(self_in, self_data, self_len);
- if (value == MP_OBJ_SENTINEL) {
- @@ -484,7 +484,7 @@ STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- }
- }
-
- -STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
- +static mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
- check_is_str_or_bytes(self_in);
- const mp_obj_type_t *self_type = mp_obj_get_type(self_in);
- const mp_obj_type_t *ret_type = self_type;
- @@ -628,7 +628,7 @@ mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) {
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, mp_obj_str_split);
-
- #if MICROPY_PY_BUILTINS_STR_SPLITLINES
- -STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- +static mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- enum { ARG_keepends };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_keepends, MP_ARG_BOOL, {.u_bool = false} },
- @@ -674,7 +674,7 @@ STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t
- MP_DEFINE_CONST_FUN_OBJ_KW(str_splitlines_obj, 1, str_splitlines);
- #endif
-
- -STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
- if (n_args < 3) {
- // If we don't have split limit, it doesn't matter from which side
- // we split.
- @@ -739,7 +739,7 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj, 1, 3, str_rsplit);
-
- -STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) {
- +static mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) {
- const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
- check_is_str_or_bytes(args[0]);
-
- @@ -782,28 +782,28 @@ STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, b
- }
- }
-
- -STATIC mp_obj_t str_find(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_find(size_t n_args, const mp_obj_t *args) {
- return str_finder(n_args, args, 1, false);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj, 2, 4, str_find);
-
- -STATIC mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) {
- return str_finder(n_args, args, -1, false);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj, 2, 4, str_rfind);
-
- -STATIC mp_obj_t str_index(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_index(size_t n_args, const mp_obj_t *args) {
- return str_finder(n_args, args, 1, true);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj, 2, 4, str_index);
-
- -STATIC mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) {
- return str_finder(n_args, args, -1, true);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj, 2, 4, str_rindex);
-
- // TODO: (Much) more variety in args
- -STATIC mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
- const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
- GET_STR_DATA_LEN(args[0], str, str_len);
- size_t prefix_len;
- @@ -819,7 +819,7 @@ STATIC mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj, 2, 3, str_startswith);
-
- -STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
- GET_STR_DATA_LEN(args[0], str, str_len);
- size_t suffix_len;
- const char *suffix = mp_obj_str_get_data(args[1], &suffix_len);
- @@ -836,7 +836,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj, 2, 3, str_endswith);
-
- enum { LSTRIP, RSTRIP, STRIP };
-
- -STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
- check_is_str_or_bytes(args[0]);
- const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
-
- @@ -905,23 +905,23 @@ STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
- return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len);
- }
-
- -STATIC mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) {
- return str_uni_strip(STRIP, n_args, args);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj, 1, 2, str_strip);
-
- -STATIC mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) {
- return str_uni_strip(LSTRIP, n_args, args);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_lstrip_obj, 1, 2, str_lstrip);
-
- -STATIC mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) {
- return str_uni_strip(RSTRIP, n_args, args);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rstrip_obj, 1, 2, str_rstrip);
-
- #if MICROPY_PY_BUILTINS_STR_CENTER
- -STATIC mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) {
- +static mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) {
- GET_STR_DATA_LEN(str_in, str, str_len);
- mp_uint_t width = mp_obj_get_int(width_in);
- if (str_len >= width) {
- @@ -940,7 +940,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(str_center_obj, str_center);
-
- // Takes an int arg, but only parses unsigned numbers, and only changes
- // *num if at least one digit was parsed.
- -STATIC const char *str_to_int(const char *str, const char *top, int *num) {
- +static const char *str_to_int(const char *str, const char *top, int *num) {
- if (str < top && '0' <= *str && *str <= '9') {
- *num = 0;
- do {
- @@ -952,19 +952,19 @@ STATIC const char *str_to_int(const char *str, const char *top, int *num) {
- return str;
- }
-
- -STATIC bool isalignment(char ch) {
- +static bool isalignment(char ch) {
- return ch && strchr("<>=^", ch) != NULL;
- }
-
- -STATIC bool istype(char ch) {
- +static bool istype(char ch) {
- return ch && strchr("bcdeEfFgGnosxX%", ch) != NULL;
- }
-
- -STATIC bool arg_looks_integer(mp_obj_t arg) {
- +static bool arg_looks_integer(mp_obj_t arg) {
- return mp_obj_is_bool(arg) || mp_obj_is_int(arg);
- }
-
- -STATIC bool arg_looks_numeric(mp_obj_t arg) {
- +static bool arg_looks_numeric(mp_obj_t arg) {
- return arg_looks_integer(arg)
- #if MICROPY_PY_BUILTINS_FLOAT
- || mp_obj_is_float(arg)
- @@ -973,7 +973,7 @@ STATIC bool arg_looks_numeric(mp_obj_t arg) {
- }
-
- #if MICROPY_PY_BUILTINS_STR_OP_MODULO
- -STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
- +static mp_obj_t arg_as_int(mp_obj_t arg) {
- #if MICROPY_PY_BUILTINS_FLOAT
- if (mp_obj_is_float(arg)) {
- return mp_obj_new_int_from_float(mp_obj_float_get(arg));
- @@ -984,7 +984,7 @@ STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
- #endif
-
- #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
- -STATIC NORETURN void terse_str_format_value_error(void) {
- +static NORETURN void terse_str_format_value_error(void) {
- mp_raise_ValueError(MP_ERROR_TEXT("bad format string"));
- }
- #else
- @@ -992,7 +992,7 @@ STATIC NORETURN void terse_str_format_value_error(void) {
- #define terse_str_format_value_error()
- #endif
-
- -STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- +static vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *arg_i, size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
- vstr_t vstr;
- mp_print_t print;
- vstr_init_print(&vstr, 16, &print);
- @@ -1449,7 +1449,7 @@ mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
- MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format);
-
- #if MICROPY_PY_BUILTINS_STR_OP_MODULO
- -STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) {
- +static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) {
- check_is_str_or_bytes(pattern);
-
- GET_STR_DATA_LEN(pattern, str, len);
- @@ -1657,7 +1657,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
-
- // The implementation is optimized, returning the original string if there's
- // nothing to replace.
- -STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
- check_is_str_or_bytes(args[0]);
-
- mp_int_t max_rep = -1;
- @@ -1759,7 +1759,7 @@ STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace);
-
- #if MICROPY_PY_BUILTINS_STR_COUNT
- -STATIC mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
- const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
- check_is_str_or_bytes(args[0]);
-
- @@ -1802,7 +1802,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj, 2, 4, str_count);
- #endif
-
- #if MICROPY_PY_BUILTINS_STR_PARTITION
- -STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
- +static mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
- check_is_str_or_bytes(self_in);
- const mp_obj_type_t *self_type = mp_obj_get_type(self_in);
- str_check_arg_type(self_type, arg);
- @@ -1848,19 +1848,19 @@ STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
- return mp_obj_new_tuple(3, result);
- }
-
- -STATIC mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) {
- +static mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) {
- return str_partitioner(self_in, arg, 1);
- }
- MP_DEFINE_CONST_FUN_OBJ_2(str_partition_obj, str_partition);
-
- -STATIC mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) {
- +static mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) {
- return str_partitioner(self_in, arg, -1);
- }
- MP_DEFINE_CONST_FUN_OBJ_2(str_rpartition_obj, str_rpartition);
- #endif
-
- // Supposedly not too critical operations, so optimize for code size
- -STATIC mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
- +static mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
- GET_STR_DATA_LEN(self_in, self_data, self_len);
- vstr_t vstr;
- vstr_init_len(&vstr, self_len);
- @@ -1871,17 +1871,17 @@ STATIC mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
- return mp_obj_new_str_type_from_vstr(mp_obj_get_type(self_in), &vstr);
- }
-
- -STATIC mp_obj_t str_lower(mp_obj_t self_in) {
- +static mp_obj_t str_lower(mp_obj_t self_in) {
- return str_caseconv(unichar_tolower, self_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(str_lower_obj, str_lower);
-
- -STATIC mp_obj_t str_upper(mp_obj_t self_in) {
- +static mp_obj_t str_upper(mp_obj_t self_in) {
- return str_caseconv(unichar_toupper, self_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(str_upper_obj, str_upper);
-
- -STATIC mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
- +static mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
- GET_STR_DATA_LEN(self_in, self_data, self_len);
-
- if (self_len == 0) {
- @@ -1914,27 +1914,27 @@ STATIC mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
- return mp_const_true;
- }
-
- -STATIC mp_obj_t str_isspace(mp_obj_t self_in) {
- +static mp_obj_t str_isspace(mp_obj_t self_in) {
- return str_uni_istype(unichar_isspace, self_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(str_isspace_obj, str_isspace);
-
- -STATIC mp_obj_t str_isalpha(mp_obj_t self_in) {
- +static mp_obj_t str_isalpha(mp_obj_t self_in) {
- return str_uni_istype(unichar_isalpha, self_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(str_isalpha_obj, str_isalpha);
-
- -STATIC mp_obj_t str_isdigit(mp_obj_t self_in) {
- +static mp_obj_t str_isdigit(mp_obj_t self_in) {
- return str_uni_istype(unichar_isdigit, self_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(str_isdigit_obj, str_isdigit);
-
- -STATIC mp_obj_t str_isupper(mp_obj_t self_in) {
- +static mp_obj_t str_isupper(mp_obj_t self_in) {
- return str_uni_istype(unichar_isupper, self_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(str_isupper_obj, str_isupper);
-
- -STATIC mp_obj_t str_islower(mp_obj_t self_in) {
- +static mp_obj_t str_islower(mp_obj_t self_in) {
- return str_uni_istype(unichar_islower, self_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower);
- @@ -1943,7 +1943,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower);
- // These methods are superfluous in the presence of str() and bytes()
- // constructors.
- // TODO: should accept kwargs too
- -STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
- mp_obj_t new_args[2];
- if (n_args == 1) {
- new_args[0] = args[0];
- @@ -1956,7 +1956,7 @@ STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj, 1, 3, bytes_decode);
-
- // TODO: should accept kwargs too
- -STATIC mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) {
- mp_obj_t new_args[2];
- if (n_args == 1) {
- new_args[0] = args[0];
- @@ -2038,13 +2038,13 @@ mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data) {
- return mp_obj_new_str_type_from_vstr(MP_OBJ_TO_PTR(type_in), &vstr);
- }
-
- -STATIC mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) {
- return mp_obj_bytes_hex(n_args, args, &mp_type_str);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str);
-
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex);
- -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj));
- +static MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex);
- +static MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj));
- #endif // MICROPY_PY_BUILTINS_BYTES_HEX
-
- mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
- @@ -2068,7 +2068,7 @@ void mp_obj_str_set_data(mp_obj_str_t *str, const byte *data, size_t len) {
-
- // This locals table is used for the following types: str, bytes, bytearray, array.array.
- // Each type takes a different section (start to end offset) of this table.
- -STATIC const mp_rom_map_elem_t array_bytearray_str_bytes_locals_table[] = {
- +static const mp_rom_map_elem_t array_bytearray_str_bytes_locals_table[] = {
- #if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY
- { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&mp_obj_array_append_obj) },
- { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&mp_obj_array_extend_obj) },
- @@ -2168,7 +2168,7 @@ MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict,
- #endif
-
- #if !MICROPY_PY_BUILTINS_STR_UNICODE
- -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
- +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_str,
- @@ -2240,7 +2240,7 @@ mp_obj_t mp_obj_new_str_via_qstr(const char *data, size_t len) {
- // Create a str/bytes object from the given vstr. The vstr buffer is resized to
- // the exact length required and then reused for the str/bytes object. The vstr
- // is cleared and can safely be passed to vstr_free if it was heap allocated.
- -STATIC mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) {
- +static mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) {
- // if not a bytes object, look if a qstr with this data already exists
- if (type == &mp_type_str) {
- qstr q = qstr_find_strn(vstr->buf, vstr->len);
- @@ -2342,7 +2342,7 @@ bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) {
- }
- }
-
- -STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
- +static NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
- #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
- mp_raise_TypeError(MP_ERROR_TEXT("can't convert to str implicitly"));
- #else
- @@ -2411,7 +2411,7 @@ typedef struct _mp_obj_str8_it_t {
- } mp_obj_str8_it_t;
-
- #if !MICROPY_PY_BUILTINS_STR_UNICODE
- -STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t str_it_iternext(mp_obj_t self_in) {
- mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
- GET_STR_DATA_LEN(self->str, str, len);
- if (self->cur < len) {
- @@ -2423,7 +2423,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
- }
- }
-
- -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
- assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t));
- mp_obj_str8_it_t *o = (mp_obj_str8_it_t *)iter_buf;
- o->base.type = &mp_type_polymorph_iter;
- @@ -2434,7 +2434,7 @@ STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_bu
- }
- #endif
-
- -STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
- mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
- GET_STR_DATA_LEN(self->str, str, len);
- if (self->cur < len) {
- diff --git a/py/objstr.h b/py/objstr.h
- index 72fe1cfef..028fc9597 100644
- --- a/py/objstr.h
- +++ b/py/objstr.h
- @@ -100,6 +100,8 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
- mp_obj_t index, bool is_slice);
- const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction);
-
- +#define MP_DEFINE_BYTES_OBJ(obj_name, target, len) mp_obj_str_t obj_name = {{&mp_type_bytes}, 0, (len), (const byte *)(target)}
- +
- mp_obj_t mp_obj_bytes_hex(size_t n_args, const mp_obj_t *args, const mp_obj_type_t *type);
- mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data);
-
- diff --git a/py/objstringio.c b/py/objstringio.c
- index a3c66ed01..a4dc8cfc9 100644
- --- a/py/objstringio.c
- +++ b/py/objstringio.c
- @@ -36,7 +36,7 @@
- #if MICROPY_PY_IO
-
- #if MICROPY_CPYTHON_COMPAT
- -STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) {
- +static void check_stringio_is_open(const mp_obj_stringio_t *o) {
- if (o->vstr == NULL) {
- mp_raise_ValueError(MP_ERROR_TEXT("I/O operation on closed file"));
- }
- @@ -45,13 +45,13 @@ STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) {
- #define check_stringio_is_open(o)
- #endif
-
- -STATIC void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in);
- mp_printf(print, self->base.type == &mp_type_stringio ? "<io.StringIO 0x%x>" : "<io.BytesIO 0x%x>", self);
- }
-
- -STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
- +static mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
- (void)errcode;
- mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
- check_stringio_is_open(o);
- @@ -67,7 +67,7 @@ STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
- return size;
- }
-
- -STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
- +static void stringio_copy_on_write(mp_obj_stringio_t *o) {
- const void *buf = o->vstr->buf;
- o->vstr->buf = m_new(char, o->vstr->len);
- o->vstr->fixed_buf = false;
- @@ -75,7 +75,7 @@ STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
- memcpy(o->vstr->buf, buf, o->vstr->len);
- }
-
- -STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
- +static mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
- (void)errcode;
- mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
- check_stringio_is_open(o);
- @@ -109,7 +109,7 @@ STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size,
- return size;
- }
-
- -STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
- +static mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
- (void)errcode;
- mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
- switch (request) {
- @@ -162,22 +162,22 @@ STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg,
-
- #define STREAM_TO_CONTENT_TYPE(o) (((o)->base.type == &mp_type_stringio) ? &mp_type_str : &mp_type_bytes)
-
- -STATIC mp_obj_t stringio_getvalue(mp_obj_t self_in) {
- +static mp_obj_t stringio_getvalue(mp_obj_t self_in) {
- mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in);
- check_stringio_is_open(self);
- // TODO: Try to avoid copying string
- return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte *)self->vstr->buf, self->vstr->len);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue);
- +static MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue);
-
- -STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
- +static mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
- mp_obj_stringio_t *o = mp_obj_malloc(mp_obj_stringio_t, type);
- o->pos = 0;
- o->ref_obj = MP_OBJ_NULL;
- return o;
- }
-
- -STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)n_kw; // TODO check n_kw==0
-
- mp_uint_t sz = 16;
- @@ -215,7 +215,7 @@ STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, s
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = {
- +static const mp_rom_map_elem_t stringio_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
- { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
- { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
- @@ -229,9 +229,9 @@ STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&mp_stream___exit___obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table);
-
- -STATIC const mp_stream_p_t stringio_stream_p = {
- +static const mp_stream_p_t stringio_stream_p = {
- .read = stringio_read,
- .write = stringio_write,
- .ioctl = stringio_ioctl,
- @@ -249,7 +249,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
- );
-
- #if MICROPY_PY_IO_BYTESIO
- -STATIC const mp_stream_p_t bytesio_stream_p = {
- +static const mp_stream_p_t bytesio_stream_p = {
- .read = stringio_read,
- .write = stringio_write,
- .ioctl = stringio_ioctl,
- diff --git a/py/objstrunicode.c b/py/objstrunicode.c
- index cbc797de2..d7ce4fca0 100644
- --- a/py/objstrunicode.c
- +++ b/py/objstrunicode.c
- @@ -34,12 +34,12 @@
-
- #if MICROPY_PY_BUILTINS_STR_UNICODE
-
- -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
- +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
-
- /******************************************************************************/
- /* str */
-
- -STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
- +static void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
- // this escapes characters, but it will be very slow to print (calling print many times)
- bool has_single_quote = false;
- bool has_double_quote = false;
- @@ -83,7 +83,7 @@ STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint
- mp_printf(print, "%c", quote_char);
- }
-
- -STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- GET_STR_DATA_LEN(self_in, str_data, str_len);
- #if MICROPY_PY_JSON
- if (kind == PRINT_JSON) {
- @@ -98,7 +98,7 @@ STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
- }
- }
-
- -STATIC mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- GET_STR_DATA_LEN(self_in, str_data, str_len);
- switch (op) {
- case MP_UNARY_OP_BOOL:
- @@ -178,7 +178,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
- return s;
- }
-
- -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- +static mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- const mp_obj_type_t *type = mp_obj_get_type(self_in);
- assert(type == &mp_type_str);
- GET_STR_DATA_LEN(self_in, self_data, self_len);
- @@ -253,7 +253,7 @@ typedef struct _mp_obj_str_it_t {
- size_t cur;
- } mp_obj_str_it_t;
-
- -STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t str_it_iternext(mp_obj_t self_in) {
- mp_obj_str_it_t *self = MP_OBJ_TO_PTR(self_in);
- GET_STR_DATA_LEN(self->str, str, len);
- if (self->cur < len) {
- @@ -267,7 +267,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
- }
- }
-
- -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
- +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
- assert(sizeof(mp_obj_str_it_t) <= sizeof(mp_obj_iter_buf_t));
- mp_obj_str_it_t *o = (mp_obj_str_it_t *)iter_buf;
- o->base.type = &mp_type_polymorph_iter;
- diff --git a/py/objtuple.c b/py/objtuple.c
- index 969c488ee..2cbcc0e50 100644
- --- a/py/objtuple.c
- +++ b/py/objtuple.c
- @@ -65,7 +65,7 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
- }
- }
-
- -STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
-
- mp_arg_check_num(n_args, n_kw, 0, 1, false);
- @@ -107,7 +107,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
- }
-
- // Don't pass MP_BINARY_OP_NOT_EQUAL here
- -STATIC mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
- +static mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
- mp_check_self(mp_obj_is_tuple_compatible(self_in));
- const mp_obj_type_t *another_type = mp_obj_get_type(another_in);
- mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -203,26 +203,26 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- }
- }
-
- -STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
- +static mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_tuple));
- mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_seq_count_obj(self->items, self->len, value);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
- +static MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
-
- -STATIC mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
- mp_check_self(mp_obj_is_type(args[0], &mp_type_tuple));
- mp_obj_tuple_t *self = MP_OBJ_TO_PTR(args[0]);
- return mp_seq_index_obj(self->items, self->len, n_args, args);
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
-
- -STATIC const mp_rom_map_elem_t tuple_locals_dict_table[] = {
- +static const mp_rom_map_elem_t tuple_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&tuple_count_obj) },
- { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&tuple_index_obj) },
- };
-
- -STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
- +static MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
-
- MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_tuple,
- @@ -244,7 +244,7 @@ mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) {
- if (n == 0) {
- return mp_const_empty_tuple;
- }
- - mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, n, &mp_type_tuple);
- + mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, n, &mp_type_tuple);
- o->len = n;
- if (items) {
- for (size_t i = 0; i < n; i++) {
- @@ -277,7 +277,7 @@ typedef struct _mp_obj_tuple_it_t {
- size_t cur;
- } mp_obj_tuple_it_t;
-
- -STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
- +static mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
- mp_obj_tuple_it_t *self = MP_OBJ_TO_PTR(self_in);
- if (self->cur < self->tuple->len) {
- mp_obj_t o_out = self->tuple->items[self->cur];
- diff --git a/py/objtype.c b/py/objtype.c
- index d21c2a4b5..b6d600e94 100644
- --- a/py/objtype.c
- +++ b/py/objtype.c
- @@ -44,12 +44,12 @@
- #define ENABLE_SPECIAL_ACCESSORS \
- (MICROPY_PY_DESCRIPTORS || MICROPY_PY_DELATTR_SETATTR || MICROPY_PY_BUILTINS_PROPERTY)
-
- -STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
- +static mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
-
- /******************************************************************************/
- // instance object
-
- -STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) {
- +static int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) {
- int count = 0;
- for (;;) {
- if (type == &mp_type_object) {
- @@ -84,22 +84,22 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
-
- // This wrapper function is allows a subclass of a native type to call the
- // __init__() method (corresponding to type->make_new) of the native type.
- -STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *args) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(args[0]);
- const mp_obj_type_t *native_base = NULL;
- instance_count_native_bases(self->base.type, &native_base);
- self->subobj[0] = MP_OBJ_TYPE_GET_SLOT(native_base, make_new)(native_base, n_args - 1, 0, args + 1);
- return mp_const_none;
- }
- -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(native_base_init_wrapper_obj, 1, MP_OBJ_FUN_ARGS_MAX, native_base_init_wrapper);
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(native_base_init_wrapper_obj, 1, MP_OBJ_FUN_ARGS_MAX, native_base_init_wrapper);
-
- #if !MICROPY_CPYTHON_COMPAT
- -STATIC
- +static
- #endif
- mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *class, const mp_obj_type_t **native_base) {
- size_t num_native_bases = instance_count_native_bases(class, native_base);
- assert(num_native_bases < 2);
- - mp_obj_instance_t *o = mp_obj_malloc_var(mp_obj_instance_t, mp_obj_t, num_native_bases, class);
- + mp_obj_instance_t *o = mp_obj_malloc_var(mp_obj_instance_t, subobj, mp_obj_t, num_native_bases, class);
- mp_map_init(&o->members, 0);
- // Initialise the native base-class slot (should be 1 at most) with a valid
- // object. It doesn't matter which object, so long as it can be uniquely
- @@ -132,7 +132,7 @@ struct class_lookup_data {
- bool is_type;
- };
-
- -STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) {
- +static void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) {
- assert(lookup->dest[0] == MP_OBJ_NULL);
- assert(lookup->dest[1] == MP_OBJ_NULL);
- for (;;) {
- @@ -235,7 +235,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_t
- }
- }
-
- -STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
- qstr meth = (kind == PRINT_STR) ? MP_QSTR___str__ : MP_QSTR___repr__;
- mp_obj_t member[2] = {MP_OBJ_NULL};
- @@ -277,7 +277,7 @@ STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k
- mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self);
- }
-
- -STATIC mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- assert(mp_obj_is_instance_type(self));
-
- // look for __new__ function
- @@ -370,6 +370,8 @@ STATIC mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_arg
-
- // Qstrs for special methods are guaranteed to have a small value, so we use byte
- // type to represent them.
- +// The (unescaped) names appear in `unsorted_str_list` in the QSTR
- +// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
- const byte mp_unary_op_method_name[MP_UNARY_OP_NUM_RUNTIME] = {
- [MP_UNARY_OP_BOOL] = MP_QSTR___bool__,
- [MP_UNARY_OP_LEN] = MP_QSTR___len__,
- @@ -392,7 +394,7 @@ const byte mp_unary_op_method_name[MP_UNARY_OP_NUM_RUNTIME] = {
- #endif
- };
-
- -STATIC mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- +static mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
-
- #if MICROPY_PY_SYS_GETSIZEOF
- @@ -468,6 +470,8 @@ STATIC mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
- // fail). They can be added at the expense of code size for the qstr.
- // Qstrs for special methods are guaranteed to have a small value, so we use byte
- // type to represent them.
- +// The (unescaped) names appear in `unsorted_str_list` in the QSTR
- +// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
- const byte mp_binary_op_method_name[MP_BINARY_OP_NUM_RUNTIME] = {
- [MP_BINARY_OP_LESS] = MP_QSTR___lt__,
- [MP_BINARY_OP_MORE] = MP_QSTR___gt__,
- @@ -530,7 +534,7 @@ const byte mp_binary_op_method_name[MP_BINARY_OP_NUM_RUNTIME] = {
- #endif
- };
-
- -STATIC mp_obj_t instance_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t instance_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
- // Note: For ducktyping, CPython does not look in the instance members or use
- // __getattr__ or __getattribute__. It only looks in the class dictionary.
- mp_obj_instance_t *lhs = MP_OBJ_TO_PTR(lhs_in);
- @@ -572,7 +576,7 @@ STATIC mp_obj_t instance_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t
- return res;
- }
-
- -STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- // logic: look in instance members then class locals
- assert(mp_obj_is_instance_type(mp_obj_get_type(self_in)));
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -669,7 +673,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
- }
- }
-
- -STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
- +static bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
-
- if (!(self->base.type->flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS)) {
- @@ -792,7 +796,7 @@ skip_special_accessors:
- }
- }
-
- -STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] == MP_OBJ_NULL) {
- mp_obj_instance_load_attr(self_in, attr, dest);
- } else {
- @@ -802,7 +806,7 @@ STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- }
- }
-
- -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- +static mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t member[4] = {MP_OBJ_NULL, MP_OBJ_NULL, index, value};
- struct class_lookup_data lookup = {
- @@ -837,7 +841,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
- }
- }
-
- -STATIC mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) {
- +static mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
- struct class_lookup_data lookup = {
- .obj = self,
- @@ -903,7 +907,7 @@ mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf)
- }
- }
-
- -STATIC mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
- +static mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
- mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t member[2] = {MP_OBJ_NULL};
- struct class_lookup_data lookup = {
- @@ -929,7 +933,7 @@ STATIC mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo,
- // - creating a new class (a new type) creates a new mp_obj_type_t
-
- #if ENABLE_SPECIAL_ACCESSORS
- -STATIC bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
- +static bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
- #if MICROPY_PY_DELATTR_SETATTR
- if (key == MP_OBJ_NEW_QSTR(MP_QSTR___setattr__) || key == MP_OBJ_NEW_QSTR(MP_QSTR___delattr__)) {
- return true;
- @@ -956,13 +960,13 @@ STATIC bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
- }
- #endif
-
- -STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in);
- mp_printf(print, "<class '%q'>", self->name);
- }
-
- -STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
-
- mp_arg_check_num(n_args, n_kw, 1, 3, false);
- @@ -982,7 +986,7 @@ STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
- }
- }
-
- -STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- // instantiate an instance of a class
-
- mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in);
- @@ -1002,7 +1006,7 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp
- return o;
- }
-
- -STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- assert(mp_obj_is_type(self_in, &mp_type_type));
- mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in);
-
- @@ -1235,7 +1239,7 @@ typedef struct _mp_obj_super_t {
- mp_obj_t obj;
- } mp_obj_super_t;
-
- -STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- +static void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_super_t *self = MP_OBJ_TO_PTR(self_in);
- mp_print_str(print, "<super: ");
- @@ -1245,7 +1249,7 @@ STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind
- mp_print_str(print, ">");
- }
-
- -STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- (void)type_in;
- // 0 arguments are turned into 2 in the compiler
- // 1 argument is not yet implemented
- @@ -1258,7 +1262,7 @@ STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- // not load attribute
- return;
- @@ -1386,7 +1390,7 @@ bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) {
- }
- }
-
- -STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
- +static mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
- size_t len;
- mp_obj_t *items;
- if (mp_obj_is_type(classinfo, &mp_type_type)) {
- @@ -1407,7 +1411,7 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
- return mp_const_false;
- }
-
- -STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
- +static mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
- if (!mp_obj_is_type(object, &mp_type_type)) {
- mp_raise_TypeError(MP_ERROR_TEXT("issubclass() arg 1 must be a class"));
- }
- @@ -1416,7 +1420,7 @@ STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
-
- MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_issubclass_obj, mp_builtin_issubclass);
-
- -STATIC mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) {
- +static mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) {
- return mp_obj_is_subclass(MP_OBJ_FROM_PTR(mp_obj_get_type(object)), classinfo);
- }
-
- @@ -1438,7 +1442,7 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type
- /******************************************************************************/
- // staticmethod and classmethod types (probably should go in a different file)
-
- -STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- assert(self == &mp_type_staticmethod || self == &mp_type_classmethod);
-
- mp_arg_check_num(n_args, n_kw, 1, 1, false);
- diff --git a/py/objzip.c b/py/objzip.c
- index 3c3138180..dd2b39ee0 100644
- --- a/py/objzip.c
- +++ b/py/objzip.c
- @@ -36,10 +36,10 @@ typedef struct _mp_obj_zip_t {
- mp_obj_t iters[];
- } mp_obj_zip_t;
-
- -STATIC mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false);
-
- - mp_obj_zip_t *o = mp_obj_malloc_var(mp_obj_zip_t, mp_obj_t, n_args, type);
- + mp_obj_zip_t *o = mp_obj_malloc_var(mp_obj_zip_t, iters, mp_obj_t, n_args, type);
- o->n_iters = n_args;
- for (size_t i = 0; i < n_args; i++) {
- o->iters[i] = mp_getiter(args[i], NULL);
- @@ -47,7 +47,7 @@ STATIC mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
- return MP_OBJ_FROM_PTR(o);
- }
-
- -STATIC mp_obj_t zip_iternext(mp_obj_t self_in) {
- +static mp_obj_t zip_iternext(mp_obj_t self_in) {
- mp_check_self(mp_obj_is_type(self_in, &mp_type_zip));
- mp_obj_zip_t *self = MP_OBJ_TO_PTR(self_in);
- if (self->n_iters == 0) {
- diff --git a/py/opmethods.c b/py/opmethods.c
- index c3931fd35..32ab187b0 100644
- --- a/py/opmethods.c
- +++ b/py/opmethods.c
- @@ -27,28 +27,28 @@
- #include "py/obj.h"
- #include "py/builtin.h"
-
- -STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) {
- +static mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) {
- const mp_obj_type_t *type = mp_obj_get_type(self_in);
- // Note: assumes type must have subscr (only used by dict).
- return MP_OBJ_TYPE_GET_SLOT(type, subscr)(self_in, key_in, MP_OBJ_SENTINEL);
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem);
-
- -STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) {
- +static mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) {
- const mp_obj_type_t *type = mp_obj_get_type(self_in);
- // Note: assumes type must have subscr (only used by dict).
- return MP_OBJ_TYPE_GET_SLOT(type, subscr)(self_in, key_in, value_in);
- }
- MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem);
-
- -STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) {
- +static mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) {
- const mp_obj_type_t *type = mp_obj_get_type(self_in);
- // Note: assumes type must have subscr (only used by dict).
- return MP_OBJ_TYPE_GET_SLOT(type, subscr)(self_in, key_in, MP_OBJ_NULL);
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem);
-
- -STATIC mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) {
- +static mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) {
- const mp_obj_type_t *type = mp_obj_get_type(lhs_in);
- // Note: assumes type must have binary_op (only used by set/frozenset).
- return MP_OBJ_TYPE_GET_SLOT(type, binary_op)(MP_BINARY_OP_CONTAINS, lhs_in, rhs_in);
- diff --git a/py/parse.c b/py/parse.c
- index e86103ed8..1392303e6 100644
- --- a/py/parse.c
- +++ b/py/parse.c
- @@ -75,7 +75,7 @@ enum {
- };
-
- // Define an array of actions corresponding to each rule
- -STATIC const uint8_t rule_act_table[] = {
- +static const uint8_t rule_act_table[] = {
- #define or(n) (RULE_ACT_OR | n)
- #define and(n) (RULE_ACT_AND | n)
- #define and_ident(n) (RULE_ACT_AND | n | RULE_ACT_ALLOW_IDENT)
- @@ -108,7 +108,7 @@ STATIC const uint8_t rule_act_table[] = {
- };
-
- // Define the argument data for each rule, as a combined array
- -STATIC const uint16_t rule_arg_combined_table[] = {
- +static const uint16_t rule_arg_combined_table[] = {
- #define tok(t) (RULE_ARG_TOK | MP_TOKEN_##t)
- #define rule(r) (RULE_ARG_RULE | RULE_##r)
- #define opt_rule(r) (RULE_ARG_OPT_RULE | RULE_##r)
- @@ -161,7 +161,7 @@ enum {
- // data, which indexes rule_arg_combined_table. The offsets require 9 bits of
- // storage but only the lower 8 bits are stored here. The 9th bit is computed
- // in get_rule_arg using the FIRST_RULE_WITH_OFFSET_ABOVE_255 constant.
- -STATIC const uint8_t rule_arg_offset_table[] = {
- +static const uint8_t rule_arg_offset_table[] = {
- #define DEF_RULE(rule, comp, kind, ...) RULE_ARG_OFFSET(rule, __VA_ARGS__) & 0xff,
- #define DEF_RULE_NC(rule, kind, ...)
- #include "py/grammar.h"
- @@ -191,7 +191,7 @@ static const size_t FIRST_RULE_WITH_OFFSET_ABOVE_255 =
-
- #if MICROPY_DEBUG_PARSE_RULE_NAME
- // Define an array of rule names corresponding to each rule
- -STATIC const char *const rule_name_table[] = {
- +static const char *const rule_name_table[] = {
- #define DEF_RULE(rule, comp, kind, ...) #rule,
- #define DEF_RULE_NC(rule, kind, ...)
- #include "py/grammar.h"
- @@ -242,9 +242,9 @@ typedef struct _parser_t {
- #endif
- } parser_t;
-
- -STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args);
- +static void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args);
-
- -STATIC const uint16_t *get_rule_arg(uint8_t r_id) {
- +static const uint16_t *get_rule_arg(uint8_t r_id) {
- size_t off = rule_arg_offset_table[r_id];
- if (r_id >= FIRST_RULE_WITH_OFFSET_ABOVE_255) {
- off |= 0x100;
- @@ -252,7 +252,7 @@ STATIC const uint16_t *get_rule_arg(uint8_t r_id) {
- return &rule_arg_combined_table[off];
- }
-
- -STATIC void *parser_alloc(parser_t *parser, size_t num_bytes) {
- +static void *parser_alloc(parser_t *parser, size_t num_bytes) {
- // use a custom memory allocator to store parse nodes sequentially in large chunks
-
- mp_parse_chunk_t *chunk = parser->cur_chunk;
- @@ -294,7 +294,7 @@ STATIC void *parser_alloc(parser_t *parser, size_t num_bytes) {
- }
-
- #if MICROPY_COMP_CONST_TUPLE
- -STATIC void parser_free_parse_node_struct(parser_t *parser, mp_parse_node_struct_t *pns) {
- +static void parser_free_parse_node_struct(parser_t *parser, mp_parse_node_struct_t *pns) {
- mp_parse_chunk_t *chunk = parser->cur_chunk;
- if (chunk->data <= (byte *)pns && (byte *)pns < chunk->data + chunk->union_.used) {
- size_t num_bytes = sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
- @@ -303,7 +303,7 @@ STATIC void parser_free_parse_node_struct(parser_t *parser, mp_parse_node_struct
- }
- #endif
-
- -STATIC void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t arg_i) {
- +static void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t arg_i) {
- if (parser->rule_stack_top >= parser->rule_stack_alloc) {
- rule_stack_t *rs = m_renew(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MICROPY_ALLOC_PARSE_RULE_INC);
- parser->rule_stack = rs;
- @@ -315,13 +315,13 @@ STATIC void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t
- rs->arg_i = arg_i;
- }
-
- -STATIC void push_rule_from_arg(parser_t *parser, size_t arg) {
- +static void push_rule_from_arg(parser_t *parser, size_t arg) {
- assert((arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE || (arg & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE);
- size_t rule_id = arg & RULE_ARG_ARG_MASK;
- push_rule(parser, parser->lexer->tok_line, rule_id, 0);
- }
-
- -STATIC uint8_t pop_rule(parser_t *parser, size_t *arg_i, size_t *src_line) {
- +static uint8_t pop_rule(parser_t *parser, size_t *arg_i, size_t *src_line) {
- parser->rule_stack_top -= 1;
- uint8_t rule_id = parser->rule_stack[parser->rule_stack_top].rule_id;
- *arg_i = parser->rule_stack[parser->rule_stack_top].arg_i;
- @@ -330,7 +330,7 @@ STATIC uint8_t pop_rule(parser_t *parser, size_t *arg_i, size_t *src_line) {
- }
-
- #if MICROPY_COMP_CONST_TUPLE
- -STATIC uint8_t peek_rule(parser_t *parser, size_t n) {
- +static uint8_t peek_rule(parser_t *parser, size_t n) {
- assert(parser->rule_stack_top > n);
- return parser->rule_stack[parser->rule_stack_top - 1 - n].rule_id;
- }
- @@ -350,7 +350,7 @@ bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) {
- }
-
- #if MICROPY_COMP_CONST_TUPLE || MICROPY_COMP_CONST
- -STATIC bool mp_parse_node_is_const(mp_parse_node_t pn) {
- +static bool mp_parse_node_is_const(mp_parse_node_t pn) {
- if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
- // Small integer.
- return true;
- @@ -377,7 +377,7 @@ STATIC bool mp_parse_node_is_const(mp_parse_node_t pn) {
- return false;
- }
-
- -STATIC mp_obj_t mp_parse_node_convert_to_obj(mp_parse_node_t pn) {
- +static mp_obj_t mp_parse_node_convert_to_obj(mp_parse_node_t pn) {
- assert(mp_parse_node_is_const(pn));
- if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
- mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn);
- @@ -419,7 +419,7 @@ STATIC mp_obj_t mp_parse_node_convert_to_obj(mp_parse_node_t pn) {
- }
- #endif
-
- -STATIC bool parse_node_is_const_bool(mp_parse_node_t pn, bool value) {
- +static bool parse_node_is_const_bool(mp_parse_node_t pn, bool value) {
- // Returns true if 'pn' is a constant whose boolean value is equivalent to 'value'
- #if MICROPY_COMP_CONST_TUPLE || MICROPY_COMP_CONST
- return mp_parse_node_is_const(pn) && mp_obj_is_true(mp_parse_node_convert_to_obj(pn)) == value;
- @@ -513,7 +513,7 @@ void mp_parse_node_print(const mp_print_t *print, mp_parse_node_t pn, size_t ind
- #endif // MICROPY_DEBUG_PRINTERS
-
- /*
- -STATIC void result_stack_show(const mp_print_t *print, parser_t *parser) {
- +static void result_stack_show(const mp_print_t *print, parser_t *parser) {
- mp_printf(print, "result stack, most recent first\n");
- for (ssize_t i = parser->result_stack_top - 1; i >= 0; i--) {
- mp_parse_node_print(print, parser->result_stack[i], 0);
- @@ -521,17 +521,17 @@ STATIC void result_stack_show(const mp_print_t *print, parser_t *parser) {
- }
- */
-
- -STATIC mp_parse_node_t pop_result(parser_t *parser) {
- +static mp_parse_node_t pop_result(parser_t *parser) {
- assert(parser->result_stack_top > 0);
- return parser->result_stack[--parser->result_stack_top];
- }
-
- -STATIC mp_parse_node_t peek_result(parser_t *parser, size_t pos) {
- +static mp_parse_node_t peek_result(parser_t *parser, size_t pos) {
- assert(parser->result_stack_top > pos);
- return parser->result_stack[parser->result_stack_top - 1 - pos];
- }
-
- -STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
- +static void push_result_node(parser_t *parser, mp_parse_node_t pn) {
- if (parser->result_stack_top >= parser->result_stack_alloc) {
- mp_parse_node_t *stack = m_renew(mp_parse_node_t, parser->result_stack, parser->result_stack_alloc, parser->result_stack_alloc + MICROPY_ALLOC_PARSE_RESULT_INC);
- parser->result_stack = stack;
- @@ -540,7 +540,7 @@ STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
- parser->result_stack[parser->result_stack_top++] = pn;
- }
-
- -STATIC mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) {
- +static mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) {
- mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_obj_t));
- pn->source_line = src_line;
- #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
- @@ -557,7 +557,7 @@ STATIC mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line,
-
- // Create a parse node representing a constant object, possibly optimising the case of
- // an integer, by putting the (small) integer value directly in the parse node itself.
- -STATIC mp_parse_node_t make_node_const_object_optimised(parser_t *parser, size_t src_line, mp_obj_t obj) {
- +static mp_parse_node_t make_node_const_object_optimised(parser_t *parser, size_t src_line, mp_obj_t obj) {
- if (mp_obj_is_small_int(obj)) {
- mp_int_t val = MP_OBJ_SMALL_INT_VALUE(obj);
- #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
- @@ -579,7 +579,7 @@ STATIC mp_parse_node_t make_node_const_object_optimised(parser_t *parser, size_t
- }
- }
-
- -STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
- +static void push_result_token(parser_t *parser, uint8_t rule_id) {
- mp_parse_node_t pn;
- mp_lexer_t *lex = parser->lexer;
- if (lex->tok_kind == MP_TOKEN_NAME) {
- @@ -635,7 +635,7 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
- #if MICROPY_COMP_CONST_FOLDING
-
- #if MICROPY_COMP_MODULE_CONST
- -STATIC const mp_rom_map_elem_t mp_constants_table[] = {
- +static const mp_rom_map_elem_t mp_constants_table[] = {
- #if MICROPY_PY_ERRNO
- { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_errno) },
- #endif
- @@ -645,7 +645,7 @@ STATIC const mp_rom_map_elem_t mp_constants_table[] = {
- // Extra constants as defined by a port
- MICROPY_PORT_CONSTANTS
- };
- -STATIC MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table);
- +static MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table);
- #endif
-
- #if MICROPY_COMP_CONST_FOLDING_COMPILER_WORKAROUND
- @@ -653,7 +653,7 @@ STATIC MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table);
- // function is static, so provide a hook for them to work around this problem.
- MP_NOINLINE
- #endif
- -STATIC bool fold_logical_constants(parser_t *parser, uint8_t rule_id, size_t *num_args) {
- +static bool fold_logical_constants(parser_t *parser, uint8_t rule_id, size_t *num_args) {
- if (rule_id == RULE_or_test
- || rule_id == RULE_and_test) {
- // folding for binary logical ops: or and
- @@ -710,7 +710,7 @@ STATIC bool fold_logical_constants(parser_t *parser, uint8_t rule_id, size_t *nu
- return false;
- }
-
- -STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
- +static bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
- // this code does folding of arbitrary integer expressions, eg 1 + 2 * 3 + 4
- // it does not do partial folding, eg 1 + 2 + x -> 3 + x
-
- @@ -894,7 +894,7 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
- #endif // MICROPY_COMP_CONST_FOLDING
-
- #if MICROPY_COMP_CONST_TUPLE
- -STATIC bool build_tuple_from_stack(parser_t *parser, size_t src_line, size_t num_args) {
- +static bool build_tuple_from_stack(parser_t *parser, size_t src_line, size_t num_args) {
- for (size_t i = num_args; i > 0;) {
- mp_parse_node_t pn = peek_result(parser, --i);
- if (!mp_parse_node_is_const(pn)) {
- @@ -913,7 +913,7 @@ STATIC bool build_tuple_from_stack(parser_t *parser, size_t src_line, size_t num
- return true;
- }
-
- -STATIC bool build_tuple(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
- +static bool build_tuple(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
- if (rule_id == RULE_testlist_comp) {
- if (peek_rule(parser, 0) == RULE_atom_paren) {
- // Tuple of the form "(a,)".
- @@ -946,7 +946,7 @@ STATIC bool build_tuple(parser_t *parser, size_t src_line, uint8_t rule_id, size
- }
- #endif
-
- -STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
- +static void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
- // Simplify and optimise certain rules, to reduce memory usage and simplify the compiler.
- if (rule_id == RULE_atom_paren) {
- // Remove parenthesis around a single expression if possible.
- @@ -1386,6 +1386,7 @@ void mp_parse_tree_clear(mp_parse_tree_t *tree) {
- m_del(byte, chunk, sizeof(mp_parse_chunk_t) + chunk->alloc);
- chunk = next;
- }
- + tree->chunk = NULL; // Avoid dangling pointer that may live on stack
- }
-
- #endif // MICROPY_ENABLE_COMPILER
- diff --git a/py/parsenum.c b/py/parsenum.c
- index e3ad8070c..b33ffb6ff 100644
- --- a/py/parsenum.c
- +++ b/py/parsenum.c
- @@ -36,7 +36,7 @@
- #include <math.h>
- #endif
-
- -STATIC NORETURN void raise_exc(mp_obj_t exc, mp_lexer_t *lex) {
- +static NORETURN void raise_exc(mp_obj_t exc, mp_lexer_t *lex) {
- // if lex!=NULL then the parser called us and we need to convert the
- // exception's type from ValueError to SyntaxError and add traceback info
- if (lex != NULL) {
- diff --git a/py/persistentcode.c b/py/persistentcode.c
- index df1003bab..5088c05f0 100644
- --- a/py/persistentcode.c
- +++ b/py/persistentcode.c
- @@ -69,8 +69,8 @@ typedef struct _bytecode_prelude_t {
-
- #include "py/parsenum.h"
-
- -STATIC int read_byte(mp_reader_t *reader);
- -STATIC size_t read_uint(mp_reader_t *reader);
- +static int read_byte(mp_reader_t *reader);
- +static size_t read_uint(mp_reader_t *reader);
-
- #if MICROPY_EMIT_MACHINE_CODE
-
- @@ -138,17 +138,17 @@ void mp_native_relocate(void *ri_in, uint8_t *text, uintptr_t reloc_text) {
-
- #endif
-
- -STATIC int read_byte(mp_reader_t *reader) {
- +static int read_byte(mp_reader_t *reader) {
- return reader->readbyte(reader->data);
- }
-
- -STATIC void read_bytes(mp_reader_t *reader, byte *buf, size_t len) {
- +static void read_bytes(mp_reader_t *reader, byte *buf, size_t len) {
- while (len-- > 0) {
- *buf++ = reader->readbyte(reader->data);
- }
- }
-
- -STATIC size_t read_uint(mp_reader_t *reader) {
- +static size_t read_uint(mp_reader_t *reader) {
- size_t unum = 0;
- for (;;) {
- byte b = reader->readbyte(reader->data);
- @@ -160,7 +160,7 @@ STATIC size_t read_uint(mp_reader_t *reader) {
- return unum;
- }
-
- -STATIC qstr load_qstr(mp_reader_t *reader) {
- +static qstr load_qstr(mp_reader_t *reader) {
- size_t len = read_uint(reader);
- if (len & 1) {
- // static qstr
- @@ -175,7 +175,7 @@ STATIC qstr load_qstr(mp_reader_t *reader) {
- return qst;
- }
-
- -STATIC mp_obj_t load_obj(mp_reader_t *reader) {
- +static mp_obj_t load_obj(mp_reader_t *reader) {
- byte obj_type = read_byte(reader);
- #if MICROPY_EMIT_MACHINE_CODE
- if (obj_type == MP_PERSISTENT_OBJ_FUN_TABLE) {
- @@ -221,7 +221,7 @@ STATIC mp_obj_t load_obj(mp_reader_t *reader) {
- }
- }
-
- -STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader, mp_module_context_t *context) {
- +static mp_raw_code_t *load_raw_code(mp_reader_t *reader, mp_module_context_t *context) {
- // Load function kind and data length
- size_t kind_len = read_uint(reader);
- int kind = (kind_len & 3) + MP_CODE_BYTECODE;
- @@ -324,11 +324,9 @@ STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader, mp_module_context_t *co
- MP_BC_PRELUDE_SIG_DECODE(ip);
- // Assign bytecode to raw code object
- mp_emit_glue_assign_bytecode(rc, fun_data,
- - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
- - fun_data_len,
- - #endif
- children,
- #if MICROPY_PERSISTENT_CODE_SAVE
- + fun_data_len,
- n_children,
- #endif
- scope_flags);
- @@ -470,12 +468,12 @@ void mp_raw_code_load_file(qstr filename, mp_compiled_module_t *context) {
-
- #include "py/objstr.h"
-
- -STATIC void mp_print_bytes(mp_print_t *print, const byte *data, size_t len) {
- +static void mp_print_bytes(mp_print_t *print, const byte *data, size_t len) {
- print->print_strn(print->data, (const char *)data, len);
- }
-
- #define BYTES_FOR_INT ((MP_BYTES_PER_OBJ_WORD * 8 + 6) / 7)
- -STATIC void mp_print_uint(mp_print_t *print, size_t n) {
- +static void mp_print_uint(mp_print_t *print, size_t n) {
- byte buf[BYTES_FOR_INT];
- byte *p = buf + sizeof(buf);
- *--p = n & 0x7f;
- @@ -486,7 +484,7 @@ STATIC void mp_print_uint(mp_print_t *print, size_t n) {
- print->print_strn(print->data, (char *)p, buf + sizeof(buf) - p);
- }
-
- -STATIC void save_qstr(mp_print_t *print, qstr qst) {
- +static void save_qstr(mp_print_t *print, qstr qst) {
- if (qst <= QSTR_LAST_STATIC) {
- // encode static qstr
- mp_print_uint(print, qst << 1 | 1);
- @@ -498,7 +496,7 @@ STATIC void save_qstr(mp_print_t *print, qstr qst) {
- mp_print_bytes(print, str, len + 1); // +1 to store null terminator
- }
-
- -STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
- +static void save_obj(mp_print_t *print, mp_obj_t o) {
- #if MICROPY_EMIT_MACHINE_CODE
- if (o == MP_OBJ_FROM_PTR(&mp_fun_table)) {
- byte obj_type = MP_PERSISTENT_OBJ_FUN_TABLE;
- @@ -564,7 +562,7 @@ STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
- }
- }
-
- -STATIC void save_raw_code(mp_print_t *print, const mp_raw_code_t *rc) {
- +static void save_raw_code(mp_print_t *print, const mp_raw_code_t *rc) {
- // Save function kind and data length
- mp_print_uint(print, (rc->fun_data_len << 3) | ((rc->n_children != 0) << 2) | (rc->kind - MP_CODE_BYTECODE));
-
- @@ -577,11 +575,15 @@ STATIC void save_raw_code(mp_print_t *print, const mp_raw_code_t *rc) {
- mp_print_uint(print, rc->prelude_offset);
- } else if (rc->kind == MP_CODE_NATIVE_VIPER || rc->kind == MP_CODE_NATIVE_ASM) {
- // Save basic scope info for viper and asm
- - mp_print_uint(print, rc->scope_flags & MP_SCOPE_FLAG_ALL_SIG);
- + // Viper/asm functions don't support generator, variable args, or default keyword args
- + // so (scope_flags & MP_SCOPE_FLAG_ALL_SIG) for these functions is always 0.
- + mp_print_uint(print, 0);
- + #if MICROPY_EMIT_INLINE_ASM
- if (rc->kind == MP_CODE_NATIVE_ASM) {
- - mp_print_uint(print, rc->n_pos_args);
- - mp_print_uint(print, rc->type_sig);
- + mp_print_uint(print, rc->asm_n_pos_args);
- + mp_print_uint(print, rc->asm_type_sig);
- }
- + #endif
- }
- #endif
-
- @@ -635,7 +637,7 @@ void mp_raw_code_save(mp_compiled_module_t *cm, mp_print_t *print) {
- #include <sys/stat.h>
- #include <fcntl.h>
-
- -STATIC void fd_print_strn(void *env, const char *str, size_t len) {
- +static void fd_print_strn(void *env, const char *str, size_t len) {
- int fd = (intptr_t)env;
- MP_THREAD_GIL_EXIT();
- ssize_t ret = write(fd, str, len);
- diff --git a/py/persistentcode.h b/py/persistentcode.h
- index 45a268d63..d2b310f24 100644
- --- a/py/persistentcode.h
- +++ b/py/persistentcode.h
- @@ -35,7 +35,7 @@
- // set) must also match MPY_SUB_VERSION. This allows 3 additional updates to
- // the native ABI per bytecode revision.
- #define MPY_VERSION 6
- -#define MPY_SUB_VERSION 2
- +#define MPY_SUB_VERSION 3
-
- // Macros to encode/decode sub-version to/from the feature byte. This replaces
- // the bits previously used to encode the flags (map caching and unicode)
- diff --git a/py/profile.c b/py/profile.c
- index 274089d70..92f414ace 100644
- --- a/py/profile.c
- +++ b/py/profile.c
- @@ -40,7 +40,7 @@
- #define prof_trace_cb MP_STATE_THREAD(prof_trace_callback)
- #define QSTR_MAP(context, idx) (context->constants.qstr_table[idx])
-
- -STATIC uint mp_prof_bytecode_lineno(const mp_raw_code_t *rc, size_t bc) {
- +static uint mp_prof_bytecode_lineno(const mp_raw_code_t *rc, size_t bc) {
- const mp_bytecode_prelude_t *prelude = &rc->prelude;
- return mp_bytecode_get_source_line(prelude->line_info, prelude->line_info_top, bc);
- }
- @@ -71,7 +71,7 @@ void mp_prof_extract_prelude(const byte *bytecode, mp_bytecode_prelude_t *prelud
- /******************************************************************************/
- // code object
-
- -STATIC void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_code_t *o = MP_OBJ_TO_PTR(o_in);
- const mp_raw_code_t *rc = o->rc;
- @@ -85,7 +85,7 @@ STATIC void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
- );
- }
-
- -STATIC mp_obj_tuple_t *code_consts(const mp_module_context_t *context, const mp_raw_code_t *rc) {
- +static mp_obj_tuple_t *code_consts(const mp_module_context_t *context, const mp_raw_code_t *rc) {
- mp_obj_tuple_t *consts = MP_OBJ_TO_PTR(mp_obj_new_tuple(rc->n_children + 1, NULL));
-
- size_t const_no = 0;
- @@ -101,7 +101,7 @@ STATIC mp_obj_tuple_t *code_consts(const mp_module_context_t *context, const mp_
- return consts;
- }
-
- -STATIC mp_obj_t raw_code_lnotab(const mp_raw_code_t *rc) {
- +static mp_obj_t raw_code_lnotab(const mp_raw_code_t *rc) {
- // const mp_bytecode_prelude_t *prelude = &rc->prelude;
- uint start = 0;
- uint stop = rc->fun_data_len - start;
- @@ -139,7 +139,7 @@ STATIC mp_obj_t raw_code_lnotab(const mp_raw_code_t *rc) {
- return o;
- }
-
- -STATIC void code_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void code_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- // not load attribute
- return;
- @@ -202,7 +202,7 @@ mp_obj_t mp_obj_new_code(const mp_module_context_t *context, const mp_raw_code_t
- /******************************************************************************/
- // frame object
-
- -STATIC void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- +static void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
- (void)kind;
- mp_obj_frame_t *frame = MP_OBJ_TO_PTR(o_in);
- mp_obj_code_t *code = frame->code;
- @@ -217,7 +217,7 @@ STATIC void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
- );
- }
-
- -STATIC void frame_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- +static void frame_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
- if (dest[0] != MP_OBJ_NULL) {
- // not load attribute
- return;
- @@ -294,7 +294,7 @@ typedef struct {
- mp_obj_t arg;
- } prof_callback_args_t;
-
- -STATIC mp_obj_t mp_prof_callback_invoke(mp_obj_t callback, prof_callback_args_t *args) {
- +static mp_obj_t mp_prof_callback_invoke(mp_obj_t callback, prof_callback_args_t *args) {
- assert(mp_obj_is_callable(callback));
-
- mp_prof_is_executing = true;
- @@ -474,7 +474,7 @@ typedef struct _mp_dis_instruction_t {
- mp_obj_t argobjex_cache;
- } mp_dis_instruction_t;
-
- -STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_table, mp_dis_instruction_t *instruction) {
- +static const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_table, mp_dis_instruction_t *instruction) {
- mp_uint_t unum;
- const byte *ptr;
- mp_obj_t obj;
- diff --git a/py/qstr.c b/py/qstr.c
- index dc89013f8..fea7f44fe 100644
- --- a/py/qstr.c
- +++ b/py/qstr.c
- @@ -42,7 +42,11 @@
- // A qstr is an index into the qstr pool.
- // The data for a qstr is \0 terminated (so they can be printed using printf)
-
- +#if MICROPY_QSTR_BYTES_IN_HASH
- #define Q_HASH_MASK ((1 << (8 * MICROPY_QSTR_BYTES_IN_HASH)) - 1)
- +#else
- +#define Q_HASH_MASK (0xffff)
- +#endif
-
- #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
- #define QSTR_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(qstr_mutex), 1)
- @@ -75,8 +79,9 @@ size_t qstr_compute_hash(const byte *data, size_t len) {
- // it is part of the .mpy ABI. See the top of py/persistentcode.c and
- // static_qstr_list in makeqstrdata.py. This pool is unsorted (although in a
- // future .mpy version we could re-order them and make it sorted). It also
- -// contains additional qstrs that must have IDs <256, see operator_qstr_list
- +// contains additional qstrs that must have IDs <256, see unsorted_qstr_list
- // in makeqstrdata.py.
- +#if MICROPY_QSTR_BYTES_IN_HASH
- const qstr_hash_t mp_qstr_const_hashes_static[] = {
- #ifndef NO_QSTR
- #define QDEF0(id, hash, len, str) hash,
- @@ -86,6 +91,7 @@ const qstr_hash_t mp_qstr_const_hashes_static[] = {
- #undef QDEF1
- #endif
- };
- +#endif
-
- const qstr_len_t mp_qstr_const_lengths_static[] = {
- #ifndef NO_QSTR
- @@ -103,7 +109,9 @@ const qstr_pool_t mp_qstr_const_pool_static = {
- false, // is_sorted
- MICROPY_ALLOC_QSTR_ENTRIES_INIT,
- MP_QSTRnumber_of_static, // corresponds to number of strings in array just below
- + #if MICROPY_QSTR_BYTES_IN_HASH
- (qstr_hash_t *)mp_qstr_const_hashes_static,
- + #endif
- (qstr_len_t *)mp_qstr_const_lengths_static,
- {
- #ifndef NO_QSTR
- @@ -118,6 +126,7 @@ const qstr_pool_t mp_qstr_const_pool_static = {
-
- // The next pool is the remainder of the qstrs defined in the firmware. This
- // is sorted.
- +#if MICROPY_QSTR_BYTES_IN_HASH
- const qstr_hash_t mp_qstr_const_hashes[] = {
- #ifndef NO_QSTR
- #define QDEF0(id, hash, len, str)
- @@ -127,6 +136,7 @@ const qstr_hash_t mp_qstr_const_hashes[] = {
- #undef QDEF1
- #endif
- };
- +#endif
-
- const qstr_len_t mp_qstr_const_lengths[] = {
- #ifndef NO_QSTR
- @@ -144,7 +154,9 @@ const qstr_pool_t mp_qstr_const_pool = {
- true, // is_sorted
- MICROPY_ALLOC_QSTR_ENTRIES_INIT,
- MP_QSTRnumber_of - MP_QSTRnumber_of_static, // corresponds to number of strings in array just below
- + #if MICROPY_QSTR_BYTES_IN_HASH
- (qstr_hash_t *)mp_qstr_const_hashes,
- + #endif
- (qstr_len_t *)mp_qstr_const_lengths,
- {
- #ifndef NO_QSTR
- @@ -175,7 +187,7 @@ void qstr_init(void) {
- #endif
- }
-
- -STATIC const qstr_pool_t *find_qstr(qstr *q) {
- +static const qstr_pool_t *find_qstr(qstr *q) {
- // search pool for this qstr
- // total_prev_len==0 in the final pool, so the loop will always terminate
- const qstr_pool_t *pool = MP_STATE_VM(last_pool);
- @@ -188,8 +200,13 @@ STATIC const qstr_pool_t *find_qstr(qstr *q) {
- }
-
- // qstr_mutex must be taken while in this function
- -STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
- +static qstr qstr_add(mp_uint_t len, const char *q_ptr) {
- + #if MICROPY_QSTR_BYTES_IN_HASH
- + mp_uint_t hash = qstr_compute_hash((const byte *)q_ptr, len);
- DEBUG_printf("QSTR: add hash=%d len=%d data=%.*s\n", hash, len, len, q_ptr);
- + #else
- + DEBUG_printf("QSTR: add len=%d data=%.*s\n", len, len, q_ptr);
- + #endif
-
- // make sure we have room in the pool for a new qstr
- if (MP_STATE_VM(last_pool)->len >= MP_STATE_VM(last_pool)->alloc) {
- @@ -199,7 +216,11 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
- new_alloc = MAX(MICROPY_ALLOC_QSTR_ENTRIES_INIT, new_alloc);
- #endif
- mp_uint_t pool_size = sizeof(qstr_pool_t)
- - + (sizeof(const char *) + sizeof(qstr_hash_t) + sizeof(qstr_len_t)) * new_alloc;
- + + (sizeof(const char *)
- + #if MICROPY_QSTR_BYTES_IN_HASH
- + + sizeof(qstr_hash_t)
- + #endif
- + + sizeof(qstr_len_t)) * new_alloc;
- qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size);
- if (pool == NULL) {
- // Keep qstr_last_chunk consistent with qstr_pool_t: qstr_last_chunk is not scanned
- @@ -211,8 +232,12 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
- QSTR_EXIT();
- m_malloc_fail(new_alloc);
- }
- + #if MICROPY_QSTR_BYTES_IN_HASH
- pool->hashes = (qstr_hash_t *)(pool->qstrs + new_alloc);
- pool->lengths = (qstr_len_t *)(pool->hashes + new_alloc);
- + #else
- + pool->lengths = (qstr_len_t *)(pool->qstrs + new_alloc);
- + #endif
- pool->prev = MP_STATE_VM(last_pool);
- pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len;
- pool->alloc = new_alloc;
- @@ -223,7 +248,9 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
-
- // add the new qstr
- mp_uint_t at = MP_STATE_VM(last_pool)->len;
- + #if MICROPY_QSTR_BYTES_IN_HASH
- MP_STATE_VM(last_pool)->hashes[at] = hash;
- + #endif
- MP_STATE_VM(last_pool)->lengths[at] = len;
- MP_STATE_VM(last_pool)->qstrs[at] = q_ptr;
- MP_STATE_VM(last_pool)->len++;
- @@ -238,8 +265,10 @@ qstr qstr_find_strn(const char *str, size_t str_len) {
- return MP_QSTR_;
- }
-
- + #if MICROPY_QSTR_BYTES_IN_HASH
- // work out hash of str
- size_t str_hash = qstr_compute_hash((const byte *)str, str_len);
- + #endif
-
- // search pools for the data
- for (const qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) {
- @@ -261,7 +290,11 @@ qstr qstr_find_strn(const char *str, size_t str_len) {
-
- // sequential search for the remaining strings
- for (mp_uint_t at = low; at < high + 1; at++) {
- - if (pool->hashes[at] == str_hash && pool->lengths[at] == str_len
- + if (
- + #if MICROPY_QSTR_BYTES_IN_HASH
- + pool->hashes[at] == str_hash &&
- + #endif
- + pool->lengths[at] == str_len
- && memcmp(pool->qstrs[at], str, str_len) == 0) {
- return pool->total_prev_len + at;
- }
- @@ -329,10 +362,9 @@ qstr qstr_from_strn(const char *str, size_t len) {
- MP_STATE_VM(qstr_last_used) += n_bytes;
-
- // store the interned strings' data
- - size_t hash = qstr_compute_hash((const byte *)str, len);
- memcpy(q_ptr, str, len);
- q_ptr[len] = '\0';
- - q = qstr_add(hash, len, q_ptr);
- + q = qstr_add(len, q_ptr);
- }
- QSTR_EXIT();
- return q;
- @@ -340,7 +372,11 @@ qstr qstr_from_strn(const char *str, size_t len) {
-
- mp_uint_t qstr_hash(qstr q) {
- const qstr_pool_t *pool = find_qstr(&q);
- + #if MICROPY_QSTR_BYTES_IN_HASH
- return pool->hashes[q];
- + #else
- + return qstr_compute_hash((byte *)pool->qstrs[q], pool->lengths[q]);
- + #endif
- }
-
- size_t qstr_len(qstr q) {
- @@ -375,7 +411,11 @@ void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, si
- *n_total_bytes += gc_nbytes(pool); // this counts actual bytes used in heap
- #else
- *n_total_bytes += sizeof(qstr_pool_t)
- - + (sizeof(const char *) + sizeof(qstr_hash_t) + sizeof(qstr_len_t)) * pool->alloc;
- + + (sizeof(const char *)
- + #if MICROPY_QSTR_BYTES_IN_HASH
- + + sizeof(qstr_hash_t)
- + #endif
- + + sizeof(qstr_len_t)) * pool->alloc;
- #endif
- }
- *n_total_bytes += *n_str_data_bytes;
- @@ -404,7 +444,7 @@ void qstr_dump_data(void) {
- #else
-
- // Emit the compressed_string_data string.
- -#define MP_COMPRESSED_DATA(x) STATIC const char *compressed_string_data = x;
- +#define MP_COMPRESSED_DATA(x) static const char *compressed_string_data = x;
- #define MP_MATCH_COMPRESSED(a, b)
- #include "genhdr/compressed.data.h"
- #undef MP_COMPRESSED_DATA
- @@ -418,7 +458,7 @@ void qstr_dump_data(void) {
- // The compressed string data is delimited by setting high bit in the final char of each word.
- // e.g. aaaa<0x80|a>bbbbbb<0x80|b>....
- // This method finds the n'th string.
- -STATIC const byte *find_uncompressed_string(uint8_t n) {
- +static const byte *find_uncompressed_string(uint8_t n) {
- const byte *c = (byte *)compressed_string_data;
- while (n > 0) {
- while ((*c & 0x80) == 0) {
- diff --git a/py/qstr.h b/py/qstr.h
- index 0c4fc4632..58ce285fd 100644
- --- a/py/qstr.h
- +++ b/py/qstr.h
- @@ -60,7 +60,9 @@ enum {
- typedef size_t qstr;
- typedef uint16_t qstr_short_t;
-
- -#if MICROPY_QSTR_BYTES_IN_HASH == 1
- +#if MICROPY_QSTR_BYTES_IN_HASH == 0
- +// No qstr_hash_t type needed.
- +#elif MICROPY_QSTR_BYTES_IN_HASH == 1
- typedef uint8_t qstr_hash_t;
- #elif MICROPY_QSTR_BYTES_IN_HASH == 2
- typedef uint16_t qstr_hash_t;
- @@ -82,7 +84,9 @@ typedef struct _qstr_pool_t {
- size_t is_sorted : 1;
- size_t alloc;
- size_t len;
- + #if MICROPY_QSTR_BYTES_IN_HASH
- qstr_hash_t *hashes;
- + #endif
- qstr_len_t *lengths;
- const char *qstrs[];
- } qstr_pool_t;
- @@ -92,6 +96,7 @@ typedef struct _qstr_pool_t {
- void qstr_init(void);
-
- size_t qstr_compute_hash(const byte *data, size_t len);
- +
- qstr qstr_find_strn(const char *str, size_t str_len); // returns MP_QSTRnull if not found
-
- qstr qstr_from_str(const char *str);
- diff --git a/py/reader.c b/py/reader.c
- index d2af62cfb..151e04cac 100644
- --- a/py/reader.c
- +++ b/py/reader.c
- @@ -39,7 +39,7 @@ typedef struct _mp_reader_mem_t {
- const byte *end;
- } mp_reader_mem_t;
-
- -STATIC mp_uint_t mp_reader_mem_readbyte(void *data) {
- +static mp_uint_t mp_reader_mem_readbyte(void *data) {
- mp_reader_mem_t *reader = (mp_reader_mem_t *)data;
- if (reader->cur < reader->end) {
- return *reader->cur++;
- @@ -48,7 +48,7 @@ STATIC mp_uint_t mp_reader_mem_readbyte(void *data) {
- }
- }
-
- -STATIC void mp_reader_mem_close(void *data) {
- +static void mp_reader_mem_close(void *data) {
- mp_reader_mem_t *reader = (mp_reader_mem_t *)data;
- if (reader->free_len > 0) {
- m_del(char, (char *)reader->beg, reader->free_len);
- @@ -81,7 +81,7 @@ typedef struct _mp_reader_posix_t {
- byte buf[20];
- } mp_reader_posix_t;
-
- -STATIC mp_uint_t mp_reader_posix_readbyte(void *data) {
- +static mp_uint_t mp_reader_posix_readbyte(void *data) {
- mp_reader_posix_t *reader = (mp_reader_posix_t *)data;
- if (reader->pos >= reader->len) {
- if (reader->len == 0) {
- @@ -101,7 +101,7 @@ STATIC mp_uint_t mp_reader_posix_readbyte(void *data) {
- return reader->buf[reader->pos++];
- }
-
- -STATIC void mp_reader_posix_close(void *data) {
- +static void mp_reader_posix_close(void *data) {
- mp_reader_posix_t *reader = (mp_reader_posix_t *)data;
- if (reader->close_fd) {
- MP_THREAD_GIL_EXIT();
- diff --git a/py/repl.c b/py/repl.c
- index cf69d3d89..b79a2d3c4 100644
- --- a/py/repl.c
- +++ b/py/repl.c
- @@ -43,7 +43,7 @@ const char *mp_repl_get_psx(unsigned int entry) {
- }
- #endif
-
- -STATIC bool str_startswith_word(const char *str, const char *head) {
- +static bool str_startswith_word(const char *str, const char *head) {
- size_t i;
- for (i = 0; str[i] && head[i]; i++) {
- if (str[i] != head[i]) {
- @@ -154,7 +154,7 @@ bool mp_repl_continue_with_input(const char *input) {
- return false;
- }
-
- -STATIC bool test_qstr(mp_obj_t obj, qstr name) {
- +static bool test_qstr(mp_obj_t obj, qstr name) {
- if (obj) {
- // try object member
- mp_obj_t dest[2];
- @@ -167,7 +167,7 @@ STATIC bool test_qstr(mp_obj_t obj, qstr name) {
- }
- }
-
- -STATIC const char *find_completions(const char *s_start, size_t s_len,
- +static const char *find_completions(const char *s_start, size_t s_len,
- mp_obj_t obj, size_t *match_len, qstr *q_first, qstr *q_last) {
-
- const char *match_str = NULL;
- @@ -207,7 +207,7 @@ STATIC const char *find_completions(const char *s_start, size_t s_len,
- return match_str;
- }
-
- -STATIC void print_completions(const mp_print_t *print,
- +static void print_completions(const mp_print_t *print,
- const char *s_start, size_t s_len,
- mp_obj_t obj, qstr q_first, qstr q_last) {
-
- diff --git a/py/runtime.c b/py/runtime.c
- index 6d8eddedc..1836f5d92 100644
- --- a/py/runtime.c
- +++ b/py/runtime.c
- @@ -171,6 +171,10 @@ void mp_init(void) {
- MP_STATE_VM(bluetooth) = MP_OBJ_NULL;
- #endif
-
- + #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
- + MP_STATE_VM(usbd) = MP_OBJ_NULL;
- + #endif
- +
- #if MICROPY_PY_THREAD_GIL
- mp_thread_mutex_init(&MP_STATE_VM(gil_mutex));
- #endif
- @@ -731,7 +735,7 @@ mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args) {
-
- // This function only needs to be exposed externally when in stackless mode.
- #if !MICROPY_STACKLESS
- -STATIC
- +static
- #endif
- void mp_call_prepare_args_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args) {
- mp_obj_t fun = *args++;
- @@ -1074,7 +1078,7 @@ typedef struct _mp_obj_checked_fun_t {
- mp_obj_t fun;
- } mp_obj_checked_fun_t;
-
- -STATIC mp_obj_t checked_fun_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- +static mp_obj_t checked_fun_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_obj_checked_fun_t *self = MP_OBJ_TO_PTR(self_in);
- if (n_args > 0) {
- const mp_obj_type_t *arg0_type = mp_obj_get_type(args[0]);
- @@ -1090,14 +1094,14 @@ STATIC mp_obj_t checked_fun_call(mp_obj_t self_in, size_t n_args, size_t n_kw, c
- return mp_call_function_n_kw(self->fun, n_args, n_kw, args);
- }
-
- -STATIC MP_DEFINE_CONST_OBJ_TYPE(
- +static MP_DEFINE_CONST_OBJ_TYPE(
- mp_type_checked_fun,
- MP_QSTR_function,
- MP_TYPE_FLAG_BINDS_SELF,
- call, checked_fun_call
- );
-
- -STATIC mp_obj_t mp_obj_new_checked_fun(const mp_obj_type_t *type, mp_obj_t fun) {
- +static mp_obj_t mp_obj_new_checked_fun(const mp_obj_type_t *type, mp_obj_t fun) {
- mp_obj_checked_fun_t *o = mp_obj_malloc(mp_obj_checked_fun_t, &mp_type_checked_fun);
- o->type = type;
- o->fun = fun;
- @@ -1326,7 +1330,7 @@ mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
-
- }
-
- -STATIC mp_fun_1_t type_get_iternext(const mp_obj_type_t *type) {
- +static mp_fun_1_t type_get_iternext(const mp_obj_type_t *type) {
- if ((type->flags & MP_TYPE_FLAG_ITER_IS_STREAM) == MP_TYPE_FLAG_ITER_IS_STREAM) {
- return mp_stream_unbuffered_iter;
- } else if (type->flags & MP_TYPE_FLAG_ITER_IS_ITERNEXT) {
- diff --git a/py/runtime.h b/py/runtime.h
- index a04d4584f..5465c06d8 100644
- --- a/py/runtime.h
- +++ b/py/runtime.h
- @@ -28,6 +28,7 @@
-
- #include "py/mpstate.h"
- #include "py/pystack.h"
- +#include "py/stackctrl.h"
-
- // For use with mp_call_function_1_from_nlr_jump_callback.
- #define MP_DEFINE_NLR_JUMP_CALLBACK_FUNCTION_1(ctx, f, a) \
- @@ -154,6 +155,32 @@ static inline void mp_globals_set(mp_obj_dict_t *d) {
- void mp_globals_locals_set_from_nlr_jump_callback(void *ctx_in);
- void mp_call_function_1_from_nlr_jump_callback(void *ctx_in);
-
- +#if MICROPY_PY_THREAD
- +static inline void mp_thread_init_state(mp_state_thread_t *ts, size_t stack_size, mp_obj_dict_t *locals, mp_obj_dict_t *globals) {
- + mp_thread_set_state(ts);
- +
- + mp_stack_set_top(ts + 1); // need to include ts in root-pointer scan
- + mp_stack_set_limit(stack_size);
- +
- + // GC starts off unlocked
- + ts->gc_lock_depth = 0;
- +
- + // There are no pending jump callbacks or exceptions yet
- + ts->nlr_jump_callback_top = NULL;
- + ts->mp_pending_exception = MP_OBJ_NULL;
- +
- + // If locals/globals are not given, inherit from main thread
- + if (locals == NULL) {
- + locals = mp_state_ctx.thread.dict_locals;
- + }
- + if (globals == NULL) {
- + globals = mp_state_ctx.thread.dict_globals;
- + }
- + mp_locals_set(locals);
- + mp_globals_set(globals);
- +}
- +#endif
- +
- mp_obj_t mp_load_name(qstr qst);
- mp_obj_t mp_load_global(qstr qst);
- mp_obj_t mp_load_build_class(void);
- diff --git a/py/runtime0.h b/py/runtime0.h
- index 69af38ddc..9c6f0e079 100644
- --- a/py/runtime0.h
- +++ b/py/runtime0.h
- @@ -26,8 +26,11 @@
- #ifndef MICROPY_INCLUDED_PY_RUNTIME0_H
- #define MICROPY_INCLUDED_PY_RUNTIME0_H
-
- -// The first four must fit in 8 bits, see emitbc.c
- -// The remaining must fit in 16 bits, see scope.h
- +// These constants are used by:
- +// - mp_raw_code_t::is_generator (only MP_SCOPE_FLAG_GENERATOR)
- +// - scope_t::scope_flags (16 bits)
- +// - MP_BC_PRELUDE_SIG_ENCODE macro, masked by MP_SCOPE_FLAG_ALL_SIG (4 bits)
- +// - tools/mpy_ld.py, when generating mpy files (maximum 7 bits)
- #define MP_SCOPE_FLAG_ALL_SIG (0x0f)
- #define MP_SCOPE_FLAG_GENERATOR (0x01)
- #define MP_SCOPE_FLAG_VARKEYWORDS (0x02)
- diff --git a/py/scope.c b/py/scope.c
- index 8fc094328..4893e7cc4 100644
- --- a/py/scope.c
- +++ b/py/scope.c
- @@ -31,7 +31,9 @@
- #if MICROPY_ENABLE_COMPILER
-
- // These low numbered qstrs should fit in 8 bits. See assertions below.
- -STATIC const uint8_t scope_simple_name_table[] = {
- +// The (unescaped) names appear in `unsorted_str_list` in the QSTR
- +// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
- +static const uint8_t scope_simple_name_table[] = {
- [SCOPE_MODULE] = MP_QSTR__lt_module_gt_,
- [SCOPE_LAMBDA] = MP_QSTR__lt_lambda_gt_,
- [SCOPE_LIST_COMP] = MP_QSTR__lt_listcomp_gt_,
- @@ -111,7 +113,7 @@ id_info_t *scope_find_global(scope_t *scope, qstr qst) {
- return scope_find(scope, qst);
- }
-
- -STATIC void scope_close_over_in_parents(scope_t *scope, qstr qst) {
- +static void scope_close_over_in_parents(scope_t *scope, qstr qst) {
- assert(scope->parent != NULL); // we should have at least 1 parent
- for (scope_t *s = scope->parent;; s = s->parent) {
- assert(s->parent != NULL); // we should not get to the outer scope
- diff --git a/py/scope.h b/py/scope.h
- index e7d2a304f..927c4a7b9 100644
- --- a/py/scope.h
- +++ b/py/scope.h
- @@ -76,6 +76,9 @@ typedef struct _scope_t {
- struct _scope_t *next;
- mp_parse_node_t pn;
- mp_raw_code_t *raw_code;
- + #if MICROPY_DEBUG_PRINTERS
- + size_t raw_code_data_len; // for mp_bytecode_print
- + #endif
- uint16_t simple_name; // a qstr
- uint16_t scope_flags; // see runtime0.h
- uint16_t emit_options; // see emitglue.h
- diff --git a/py/showbc.c b/py/showbc.c
- index f9c334b93..6913d18c1 100644
- --- a/py/showbc.c
- +++ b/py/showbc.c
- @@ -83,7 +83,7 @@
- DECODE_UINT; \
- unum = (mp_uint_t)obj_table[unum]
-
- -void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, const mp_module_constants_t *cm) {
- +void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, size_t fun_data_len, const mp_module_constants_t *cm) {
- const byte *ip_start = rc->fun_data;
- const byte *ip = rc->fun_data;
-
- @@ -100,13 +100,13 @@ void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, const m
- qstr source_file = cm->source_file;
- #endif
- mp_printf(print, "File %s, code block '%s' (descriptor: %p, bytecode @%p %u bytes)\n",
- - qstr_str(source_file), qstr_str(block_name), rc, ip_start, (unsigned)rc->fun_data_len);
- + qstr_str(source_file), qstr_str(block_name), rc, ip_start, (unsigned)fun_data_len);
-
- // raw bytecode dump
- size_t prelude_size = ip - ip_start + n_info + n_cell;
- mp_printf(print, "Raw bytecode (code_info_size=%u, bytecode_size=%u):\n",
- - (unsigned)prelude_size, (unsigned)(rc->fun_data_len - prelude_size));
- - for (size_t i = 0; i < rc->fun_data_len; i++) {
- + (unsigned)prelude_size, (unsigned)(fun_data_len - prelude_size));
- + for (size_t i = 0; i < fun_data_len; i++) {
- if (i > 0 && i % 16 == 0) {
- mp_printf(print, "\n");
- }
- @@ -158,7 +158,7 @@ void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, const m
- mp_printf(print, " bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
- }
- }
- - mp_bytecode_print2(print, ip, rc->fun_data_len - prelude_size, rc->children, cm);
- + mp_bytecode_print2(print, ip, fun_data_len - prelude_size, rc->children, cm);
- }
-
- const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip_start, const byte *ip, mp_raw_code_t *const *child_table, const mp_module_constants_t *cm) {
- diff --git a/py/stream.c b/py/stream.c
- index ac0234ac1..d7a8881e1 100644
- --- a/py/stream.c
- +++ b/py/stream.c
- @@ -38,7 +38,7 @@
- // TODO: should be in mpconfig.h
- #define DEFAULT_BUFFER_SIZE 256
-
- -STATIC mp_obj_t stream_readall(mp_obj_t self_in);
- +static mp_obj_t stream_readall(mp_obj_t self_in);
-
- // Returns error condition in *errcode, if non-zero, return value is number of bytes written
- // before error condition occurred. If *errcode == 0, returns total bytes written (which will
- @@ -82,6 +82,18 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode
- return done;
- }
-
- +mp_off_t mp_stream_seek(mp_obj_t stream, mp_off_t offset, int whence, int *errcode) {
- + struct mp_stream_seek_t seek_s;
- + seek_s.offset = offset;
- + seek_s.whence = whence;
- + const mp_stream_p_t *stream_p = mp_get_stream(stream);
- + mp_uint_t res = stream_p->ioctl(MP_OBJ_FROM_PTR(stream), MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, errcode);
- + if (res == MP_STREAM_ERROR) {
- + return (mp_off_t)-1;
- + }
- + return seek_s.offset;
- +}
- +
- const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
- const mp_obj_type_t *type = mp_obj_get_type(self_in);
- if (MP_OBJ_TYPE_HAS_SLOT(type, protocol)) {
- @@ -96,7 +108,7 @@ const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
- mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("stream operation not supported"));
- }
-
- -STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) {
- +static mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) {
- // What to do if sz < -1? Python docs don't specify this case.
- // CPython does a readall, but here we silently let negatives through,
- // and they will cause a MemoryError.
- @@ -218,12 +230,12 @@ STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte fl
- }
- }
-
- -STATIC mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) {
- return stream_read_generic(n_args, args, MP_STREAM_RW_READ);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj, 1, 2, stream_read);
-
- -STATIC mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) {
- return stream_read_generic(n_args, args, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read1_obj, 1, 2, stream_read1);
- @@ -249,7 +261,7 @@ void mp_stream_write_adaptor(void *self, const char *buf, size_t len) {
- mp_stream_write(MP_OBJ_FROM_PTR(self), buf, len, MP_STREAM_RW_WRITE);
- }
-
- -STATIC mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) {
- mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
- size_t max_len = (size_t)-1;
- @@ -268,14 +280,14 @@ STATIC mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_write_obj, 2, 4, stream_write_method);
-
- -STATIC mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) {
- +static mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) {
- mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ);
- return mp_stream_write(self_in, bufinfo.buf, bufinfo.len, MP_STREAM_RW_WRITE | MP_STREAM_RW_ONCE);
- }
- MP_DEFINE_CONST_FUN_OBJ_2(mp_stream_write1_obj, stream_write1_method);
-
- -STATIC mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) {
- mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
-
- @@ -303,7 +315,7 @@ STATIC mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) {
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj, 2, 3, stream_readinto);
-
- -STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
- +static mp_obj_t stream_readall(mp_obj_t self_in) {
- const mp_stream_p_t *stream_p = mp_get_stream(self_in);
-
- mp_uint_t total_size = 0;
- @@ -348,7 +360,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
- }
-
- // Unbuffered, inefficient implementation of readline() for raw I/O files.
- -STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) {
- const mp_stream_p_t *stream_p = mp_get_stream(args[0]);
-
- mp_int_t max_size = -1;
- @@ -406,7 +418,7 @@ STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args)
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_unbuffered_readline_obj, 1, 2, stream_unbuffered_readline);
-
- // TODO take an optional extra argument (what does it do exactly?)
- -STATIC mp_obj_t stream_unbuffered_readlines(mp_obj_t self) {
- +static mp_obj_t stream_unbuffered_readlines(mp_obj_t self) {
- mp_obj_t lines = mp_obj_new_list(0, NULL);
- for (;;) {
- mp_obj_t line = stream_unbuffered_readline(1, &self);
- @@ -438,39 +450,37 @@ mp_obj_t mp_stream_close(mp_obj_t stream) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_close_obj, mp_stream_close);
-
- -STATIC mp_obj_t mp_stream___exit__(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t mp_stream___exit__(size_t n_args, const mp_obj_t *args) {
- (void)n_args;
- return mp_stream_close(args[0]);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream___exit___obj, 4, 4, mp_stream___exit__);
-
- -STATIC mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) {
- - struct mp_stream_seek_t seek_s;
- +static mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) {
- // TODO: Could be uint64
- - seek_s.offset = mp_obj_get_int(args[1]);
- - seek_s.whence = SEEK_SET;
- + mp_off_t offset = mp_obj_get_int(args[1]);
- + int whence = SEEK_SET;
- if (n_args == 3) {
- - seek_s.whence = mp_obj_get_int(args[2]);
- + whence = mp_obj_get_int(args[2]);
- }
-
- // In POSIX, it's error to seek before end of stream, we enforce it here.
- - if (seek_s.whence == SEEK_SET && seek_s.offset < 0) {
- + if (whence == SEEK_SET && offset < 0) {
- mp_raise_OSError(MP_EINVAL);
- }
-
- - const mp_stream_p_t *stream_p = mp_get_stream(args[0]);
- int error;
- - mp_uint_t res = stream_p->ioctl(args[0], MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error);
- - if (res == MP_STREAM_ERROR) {
- + mp_off_t res = mp_stream_seek(args[0], offset, whence, &error);
- + if (res == (mp_off_t)-1) {
- mp_raise_OSError(error);
- }
-
- // TODO: Could be uint64
- - return mp_obj_new_int_from_uint(seek_s.offset);
- + return mp_obj_new_int_from_uint(res);
- }
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_seek_obj, 2, 3, stream_seek);
-
- -STATIC mp_obj_t stream_tell(mp_obj_t self) {
- +static mp_obj_t stream_tell(mp_obj_t self) {
- mp_obj_t offset = MP_OBJ_NEW_SMALL_INT(0);
- mp_obj_t whence = MP_OBJ_NEW_SMALL_INT(SEEK_CUR);
- const mp_obj_t args[3] = {self, offset, whence};
- @@ -478,7 +488,7 @@ STATIC mp_obj_t stream_tell(mp_obj_t self) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_tell_obj, stream_tell);
-
- -STATIC mp_obj_t stream_flush(mp_obj_t self) {
- +static mp_obj_t stream_flush(mp_obj_t self) {
- const mp_stream_p_t *stream_p = mp_get_stream(self);
- int error;
- mp_uint_t res = stream_p->ioctl(self, MP_STREAM_FLUSH, 0, &error);
- @@ -489,7 +499,7 @@ STATIC mp_obj_t stream_flush(mp_obj_t self) {
- }
- MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_flush_obj, stream_flush);
-
- -STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
- +static mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
- mp_buffer_info_t bufinfo;
- uintptr_t val = 0;
- if (n_args > 2) {
- @@ -545,16 +555,11 @@ ssize_t mp_stream_posix_read(void *stream, void *buf, size_t len) {
- }
-
- off_t mp_stream_posix_lseek(void *stream, off_t offset, int whence) {
- - const mp_obj_base_t *o = stream;
- - const mp_stream_p_t *stream_p = MP_OBJ_TYPE_GET_SLOT(o->type, protocol);
- - struct mp_stream_seek_t seek_s;
- - seek_s.offset = offset;
- - seek_s.whence = whence;
- - mp_uint_t res = stream_p->ioctl(MP_OBJ_FROM_PTR(stream), MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &errno);
- - if (res == MP_STREAM_ERROR) {
- + mp_off_t res = mp_stream_seek(MP_OBJ_FROM_PTR(stream), offset, whence, &errno);
- + if (res == (mp_off_t)-1) {
- return -1;
- }
- - return seek_s.offset;
- + return res;
- }
-
- int mp_stream_posix_fsync(void *stream) {
- diff --git a/py/stream.h b/py/stream.h
- index e6e6f283d..7c4d38afa 100644
- --- a/py/stream.h
- +++ b/py/stream.h
- @@ -115,6 +115,7 @@ mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte fla
- mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags);
- #define mp_stream_write_exactly(stream, buf, size, err) mp_stream_rw(stream, (byte *)buf, size, err, MP_STREAM_RW_WRITE)
- #define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ)
- +mp_off_t mp_stream_seek(mp_obj_t stream, mp_off_t offset, int whence, int *errcode);
-
- void mp_stream_write_adaptor(void *self, const char *buf, size_t len);
-
- diff --git a/py/unicode.c b/py/unicode.c
- index 5acaad378..81a37880f 100644
- --- a/py/unicode.c
- +++ b/py/unicode.c
- @@ -48,7 +48,7 @@
- #define AT_LX (FL_LOWER | FL_ALPHA | FL_PRINT | FL_XDIGIT)
-
- // table of attributes for ascii characters
- -STATIC const uint8_t attr[] = {
- +static const uint8_t attr[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, AT_SP, AT_SP, AT_SP, AT_SP, AT_SP, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- diff --git a/py/vm.c b/py/vm.c
- index a7902d927..f87e52c92 100644
- --- a/py/vm.c
- +++ b/py/vm.c
- @@ -893,7 +893,7 @@ unwind_jump:;
-
- ENTRY(MP_BC_MAKE_FUNCTION): {
- DECODE_PTR;
- - PUSH(mp_make_function_from_raw_code(ptr, code_state->fun_bc->context, NULL));
- + PUSH(mp_make_function_from_proto_fun(ptr, code_state->fun_bc->context, NULL));
- DISPATCH();
- }
-
- @@ -901,7 +901,7 @@ unwind_jump:;
- DECODE_PTR;
- // Stack layout: def_tuple def_dict <- TOS
- sp -= 1;
- - SET_TOP(mp_make_function_from_raw_code(ptr, code_state->fun_bc->context, sp));
- + SET_TOP(mp_make_function_from_proto_fun(ptr, code_state->fun_bc->context, sp));
- DISPATCH();
- }
-
- @@ -910,7 +910,7 @@ unwind_jump:;
- size_t n_closed_over = *ip++;
- // Stack layout: closed_overs <- TOS
- sp -= n_closed_over - 1;
- - SET_TOP(mp_make_closure_from_raw_code(ptr, code_state->fun_bc->context, n_closed_over, sp));
- + SET_TOP(mp_make_closure_from_proto_fun(ptr, code_state->fun_bc->context, n_closed_over, sp));
- DISPATCH();
- }
-
- @@ -919,7 +919,7 @@ unwind_jump:;
- size_t n_closed_over = *ip++;
- // Stack layout: def_tuple def_dict closed_overs <- TOS
- sp -= 2 + n_closed_over - 1;
- - SET_TOP(mp_make_closure_from_raw_code(ptr, code_state->fun_bc->context, 0x100 | n_closed_over, sp));
- + SET_TOP(mp_make_closure_from_proto_fun(ptr, code_state->fun_bc->context, 0x100 | n_closed_over, sp));
- DISPATCH();
- }
-
- diff --git a/py/vstr.c b/py/vstr.c
- index 56327b5f7..fc55d6948 100644
- --- a/py/vstr.c
- +++ b/py/vstr.c
- @@ -104,7 +104,7 @@ char *vstr_extend(vstr_t *vstr, size_t size) {
- return p;
- }
-
- -STATIC void vstr_ensure_extra(vstr_t *vstr, size_t size) {
- +static void vstr_ensure_extra(vstr_t *vstr, size_t size) {
- if (vstr->len + size > vstr->alloc) {
- if (vstr->fixed_buf) {
- // We can't reallocate, and the caller is expecting the space to
- @@ -183,7 +183,7 @@ void vstr_add_strn(vstr_t *vstr, const char *str, size_t len) {
- vstr->len += len;
- }
-
- -STATIC char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) {
- +static char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) {
- size_t l = vstr->len;
- if (byte_pos > l) {
- byte_pos = l;
- diff --git a/shared/runtime/gchelper_generic.c b/shared/runtime/gchelper_generic.c
- index 272e37056..4ef2e73f7 100644
- --- a/shared/runtime/gchelper_generic.c
- +++ b/shared/runtime/gchelper_generic.c
- @@ -42,7 +42,7 @@
- // stack already by the caller.
- #if defined(__x86_64__)
-
- -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
- +static void gc_helper_get_regs(gc_helper_regs_t arr) {
- register long rbx asm ("rbx");
- register long rbp asm ("rbp");
- register long r12 asm ("r12");
- @@ -73,7 +73,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
-
- #elif defined(__i386__)
-
- -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
- +static void gc_helper_get_regs(gc_helper_regs_t arr) {
- register long ebx asm ("ebx");
- register long esi asm ("esi");
- register long edi asm ("edi");
- @@ -100,7 +100,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
-
- // Fallback implementation, prefer gchelper_thumb1.s or gchelper_thumb2.s
-
- -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
- +static void gc_helper_get_regs(gc_helper_regs_t arr) {
- register long r4 asm ("r4");
- register long r5 asm ("r5");
- register long r6 asm ("r6");
- @@ -125,7 +125,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
-
- #elif defined(__aarch64__)
-
- -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
- +static void gc_helper_get_regs(gc_helper_regs_t arr) {
- const register long x19 asm ("x19");
- const register long x20 asm ("x20");
- const register long x21 asm ("x21");
- @@ -161,7 +161,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
- // Even if we have specific support for an architecture, it is
- // possible to force use of setjmp-based implementation.
-
- -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
- +static void gc_helper_get_regs(gc_helper_regs_t arr) {
- setjmp(arr);
- }
-
|