micropython 273 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708
  1. commit 000a3b649e1ad2c4a49480b297896ff8f652d21b
  2. Author: Oliver Fabel <28701799+ofabel@users.noreply.github.com>
  3. Date: Tue Apr 16 17:06:38 2024 +0200
  4. library update
  5. diff --git a/extmod/modjson.c b/extmod/modjson.c
  6. index 1772b7299..e655a02bc 100644
  7. --- a/extmod/modjson.c
  8. +++ b/extmod/modjson.c
  9. @@ -41,7 +41,7 @@ enum {
  10. DUMP_MODE_TO_STREAM = 2,
  11. };
  12. -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) {
  13. +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) {
  14. enum { ARG_separators };
  15. static const mp_arg_t allowed_args[] = {
  16. { MP_QSTR_separators, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
  17. @@ -78,34 +78,34 @@ STATIC mp_obj_t mod_json_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp
  18. }
  19. }
  20. -STATIC mp_obj_t mod_json_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  21. +static mp_obj_t mod_json_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  22. return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STREAM);
  23. }
  24. -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dump_obj, 2, mod_json_dump);
  25. +static MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dump_obj, 2, mod_json_dump);
  26. -STATIC mp_obj_t mod_json_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  27. +static mp_obj_t mod_json_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  28. return mod_json_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STRING);
  29. }
  30. -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dumps_obj, 1, mod_json_dumps);
  31. +static MP_DEFINE_CONST_FUN_OBJ_KW(mod_json_dumps_obj, 1, mod_json_dumps);
  32. #else
  33. -STATIC mp_obj_t mod_json_dump(mp_obj_t obj, mp_obj_t stream) {
  34. +static mp_obj_t mod_json_dump(mp_obj_t obj, mp_obj_t stream) {
  35. mp_get_stream_raise(stream, MP_STREAM_OP_WRITE);
  36. mp_print_t print = {MP_OBJ_TO_PTR(stream), mp_stream_write_adaptor};
  37. mp_obj_print_helper(&print, obj, PRINT_JSON);
  38. return mp_const_none;
  39. }
  40. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_json_dump_obj, mod_json_dump);
  41. +static MP_DEFINE_CONST_FUN_OBJ_2(mod_json_dump_obj, mod_json_dump);
  42. -STATIC mp_obj_t mod_json_dumps(mp_obj_t obj) {
  43. +static mp_obj_t mod_json_dumps(mp_obj_t obj) {
  44. vstr_t vstr;
  45. mp_print_t print;
  46. vstr_init_print(&vstr, 8, &print);
  47. mp_obj_print_helper(&print, obj, PRINT_JSON);
  48. return mp_obj_new_str_from_utf8_vstr(&vstr);
  49. }
  50. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_dumps_obj, mod_json_dumps);
  51. +static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_dumps_obj, mod_json_dumps);
  52. #endif
  53. @@ -134,7 +134,7 @@ typedef struct _json_stream_t {
  54. #define S_CUR(s) ((s).cur)
  55. #define S_NEXT(s) (json_stream_next(&(s)))
  56. -STATIC byte json_stream_next(json_stream_t *s) {
  57. +static byte json_stream_next(json_stream_t *s) {
  58. mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode);
  59. if (s->errcode != 0) {
  60. mp_raise_OSError(s->errcode);
  61. @@ -145,7 +145,7 @@ STATIC byte json_stream_next(json_stream_t *s) {
  62. return s->cur;
  63. }
  64. -STATIC mp_obj_t mod_json_load(mp_obj_t stream_obj) {
  65. +static mp_obj_t mod_json_load(mp_obj_t stream_obj) {
  66. const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
  67. json_stream_t s = {stream_obj, stream_p->read, 0, 0};
  68. vstr_t vstr;
  69. @@ -355,18 +355,18 @@ success:
  70. fail:
  71. mp_raise_ValueError(MP_ERROR_TEXT("syntax error in JSON"));
  72. }
  73. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_load_obj, mod_json_load);
  74. +static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_load_obj, mod_json_load);
  75. -STATIC mp_obj_t mod_json_loads(mp_obj_t obj) {
  76. +static mp_obj_t mod_json_loads(mp_obj_t obj) {
  77. mp_buffer_info_t bufinfo;
  78. mp_get_buffer_raise(obj, &bufinfo, MP_BUFFER_READ);
  79. vstr_t vstr = {bufinfo.len, bufinfo.len, (char *)bufinfo.buf, true};
  80. mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL};
  81. return mod_json_load(MP_OBJ_FROM_PTR(&sio));
  82. }
  83. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads);
  84. +static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads);
  85. -STATIC const mp_rom_map_elem_t mp_module_json_globals_table[] = {
  86. +static const mp_rom_map_elem_t mp_module_json_globals_table[] = {
  87. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_json) },
  88. { MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_json_dump_obj) },
  89. { MP_ROM_QSTR(MP_QSTR_dumps), MP_ROM_PTR(&mod_json_dumps_obj) },
  90. @@ -374,7 +374,7 @@ STATIC const mp_rom_map_elem_t mp_module_json_globals_table[] = {
  91. { MP_ROM_QSTR(MP_QSTR_loads), MP_ROM_PTR(&mod_json_loads_obj) },
  92. };
  93. -STATIC MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table);
  94. +static MP_DEFINE_CONST_DICT(mp_module_json_globals, mp_module_json_globals_table);
  95. const mp_obj_module_t mp_module_json = {
  96. .base = { &mp_type_module },
  97. diff --git a/extmod/modrandom.c b/extmod/modrandom.c
  98. index e65f31488..79a1b18ba 100644
  99. --- a/extmod/modrandom.c
  100. +++ b/extmod/modrandom.c
  101. @@ -46,16 +46,16 @@
  102. #if !MICROPY_ENABLE_DYNRUNTIME
  103. #if SEED_ON_IMPORT
  104. // If the state is seeded on import then keep these variables in the BSS.
  105. -STATIC uint32_t yasmarang_pad, yasmarang_n, yasmarang_d;
  106. -STATIC uint8_t yasmarang_dat;
  107. +static uint32_t yasmarang_pad, yasmarang_n, yasmarang_d;
  108. +static uint8_t yasmarang_dat;
  109. #else
  110. // Without seed-on-import these variables must be initialised via the data section.
  111. -STATIC uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233;
  112. -STATIC uint8_t yasmarang_dat = 0;
  113. +static uint32_t yasmarang_pad = 0xeda4baba, yasmarang_n = 69, yasmarang_d = 233;
  114. +static uint8_t yasmarang_dat = 0;
  115. #endif
  116. #endif
  117. -STATIC uint32_t yasmarang(void) {
  118. +static uint32_t yasmarang(void) {
  119. yasmarang_pad += yasmarang_dat + yasmarang_d * yasmarang_n;
  120. yasmarang_pad = (yasmarang_pad << 3) + (yasmarang_pad >> 29);
  121. yasmarang_n = yasmarang_pad | 2;
  122. @@ -71,7 +71,7 @@ STATIC uint32_t yasmarang(void) {
  123. // returns an unsigned integer below the given argument
  124. // n must not be zero
  125. -STATIC uint32_t yasmarang_randbelow(uint32_t n) {
  126. +static uint32_t yasmarang_randbelow(uint32_t n) {
  127. uint32_t mask = 1;
  128. while ((n & mask) < n) {
  129. mask = (mask << 1) | 1;
  130. @@ -85,8 +85,8 @@ STATIC uint32_t yasmarang_randbelow(uint32_t n) {
  131. #endif
  132. -STATIC mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
  133. - int n = mp_obj_get_int(num_in);
  134. +static mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
  135. + mp_int_t n = mp_obj_get_int(num_in);
  136. if (n > 32 || n < 0) {
  137. mp_raise_ValueError(MP_ERROR_TEXT("bits must be 32 or less"));
  138. }
  139. @@ -98,9 +98,9 @@ STATIC mp_obj_t mod_random_getrandbits(mp_obj_t num_in) {
  140. mask >>= (32 - n);
  141. return mp_obj_new_int_from_uint(yasmarang() & mask);
  142. }
  143. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits);
  144. +static MP_DEFINE_CONST_FUN_OBJ_1(mod_random_getrandbits_obj, mod_random_getrandbits);
  145. -STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
  146. +static mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
  147. mp_uint_t seed;
  148. if (n_args == 0 || args[0] == mp_const_none) {
  149. #ifdef MICROPY_PY_RANDOM_SEED_INIT_FUNC
  150. @@ -111,22 +111,22 @@ STATIC mp_obj_t mod_random_seed(size_t n_args, const mp_obj_t *args) {
  151. } else {
  152. seed = mp_obj_get_int_truncated(args[0]);
  153. }
  154. - yasmarang_pad = seed;
  155. + yasmarang_pad = (uint32_t)seed;
  156. yasmarang_n = 69;
  157. yasmarang_d = 233;
  158. yasmarang_dat = 0;
  159. return mp_const_none;
  160. }
  161. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed);
  162. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_seed_obj, 0, 1, mod_random_seed);
  163. #if MICROPY_PY_RANDOM_EXTRA_FUNCS
  164. -STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
  165. +static mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
  166. mp_int_t start = mp_obj_get_int(args[0]);
  167. if (n_args == 1) {
  168. // range(stop)
  169. if (start > 0) {
  170. - return mp_obj_new_int(yasmarang_randbelow(start));
  171. + return mp_obj_new_int(yasmarang_randbelow((uint32_t)start));
  172. } else {
  173. goto error;
  174. }
  175. @@ -135,7 +135,7 @@ STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
  176. if (n_args == 2) {
  177. // range(start, stop)
  178. if (start < stop) {
  179. - return mp_obj_new_int(start + yasmarang_randbelow(stop - start));
  180. + return mp_obj_new_int(start + yasmarang_randbelow((uint32_t)(stop - start)));
  181. } else {
  182. goto error;
  183. }
  184. @@ -151,7 +151,7 @@ STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
  185. goto error;
  186. }
  187. if (n > 0) {
  188. - return mp_obj_new_int(start + step * yasmarang_randbelow(n));
  189. + return mp_obj_new_int(start + step * yasmarang_randbelow((uint32_t)n));
  190. } else {
  191. goto error;
  192. }
  193. @@ -161,33 +161,33 @@ STATIC mp_obj_t mod_random_randrange(size_t n_args, const mp_obj_t *args) {
  194. error:
  195. mp_raise_ValueError(NULL);
  196. }
  197. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange);
  198. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_random_randrange_obj, 1, 3, mod_random_randrange);
  199. -STATIC mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) {
  200. +static mp_obj_t mod_random_randint(mp_obj_t a_in, mp_obj_t b_in) {
  201. mp_int_t a = mp_obj_get_int(a_in);
  202. mp_int_t b = mp_obj_get_int(b_in);
  203. if (a <= b) {
  204. - return mp_obj_new_int(a + yasmarang_randbelow(b - a + 1));
  205. + return mp_obj_new_int(a + yasmarang_randbelow((uint32_t)(b - a + 1)));
  206. } else {
  207. mp_raise_ValueError(NULL);
  208. }
  209. }
  210. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint);
  211. +static MP_DEFINE_CONST_FUN_OBJ_2(mod_random_randint_obj, mod_random_randint);
  212. -STATIC mp_obj_t mod_random_choice(mp_obj_t seq) {
  213. +static mp_obj_t mod_random_choice(mp_obj_t seq) {
  214. mp_int_t len = mp_obj_get_int(mp_obj_len(seq));
  215. if (len > 0) {
  216. - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL);
  217. + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow((uint32_t)len)), MP_OBJ_SENTINEL);
  218. } else {
  219. mp_raise_type(&mp_type_IndexError);
  220. }
  221. }
  222. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice);
  223. +static MP_DEFINE_CONST_FUN_OBJ_1(mod_random_choice_obj, mod_random_choice);
  224. #if MICROPY_PY_BUILTINS_FLOAT
  225. // returns a number in the range [0..1) using Yasmarang to fill in the fraction bits
  226. -STATIC mp_float_t yasmarang_float(void) {
  227. +static mp_float_t yasmarang_float(void) {
  228. mp_float_union_t u;
  229. u.p.sgn = 0;
  230. u.p.exp = (1 << (MP_FLOAT_EXP_BITS - 1)) - 1;
  231. @@ -199,24 +199,24 @@ STATIC mp_float_t yasmarang_float(void) {
  232. return u.f - 1;
  233. }
  234. -STATIC mp_obj_t mod_random_random(void) {
  235. +static mp_obj_t mod_random_random(void) {
  236. return mp_obj_new_float(yasmarang_float());
  237. }
  238. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random);
  239. +static MP_DEFINE_CONST_FUN_OBJ_0(mod_random_random_obj, mod_random_random);
  240. -STATIC mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) {
  241. +static mp_obj_t mod_random_uniform(mp_obj_t a_in, mp_obj_t b_in) {
  242. mp_float_t a = mp_obj_get_float(a_in);
  243. mp_float_t b = mp_obj_get_float(b_in);
  244. return mp_obj_new_float(a + (b - a) * yasmarang_float());
  245. }
  246. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform);
  247. +static MP_DEFINE_CONST_FUN_OBJ_2(mod_random_uniform_obj, mod_random_uniform);
  248. #endif
  249. #endif // MICROPY_PY_RANDOM_EXTRA_FUNCS
  250. #if SEED_ON_IMPORT
  251. -STATIC mp_obj_t mod_random___init__(void) {
  252. +static mp_obj_t mod_random___init__(void) {
  253. // This module may be imported by more than one name so need to ensure
  254. // that it's only ever seeded once.
  255. static bool seeded = false;
  256. @@ -226,11 +226,11 @@ STATIC mp_obj_t mod_random___init__(void) {
  257. }
  258. return mp_const_none;
  259. }
  260. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_random___init___obj, mod_random___init__);
  261. +static MP_DEFINE_CONST_FUN_OBJ_0(mod_random___init___obj, mod_random___init__);
  262. #endif
  263. #if !MICROPY_ENABLE_DYNRUNTIME
  264. -STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = {
  265. +static const mp_rom_map_elem_t mp_module_random_globals_table[] = {
  266. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_random) },
  267. #if SEED_ON_IMPORT
  268. { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&mod_random___init___obj) },
  269. @@ -248,7 +248,7 @@ STATIC const mp_rom_map_elem_t mp_module_random_globals_table[] = {
  270. #endif
  271. };
  272. -STATIC MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table);
  273. +static MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_table);
  274. const mp_obj_module_t mp_module_random = {
  275. .base = { &mp_type_module },
  276. diff --git a/extmod/modtime.c b/extmod/modtime.c
  277. index 805c2621c..deb4bb4c9 100644
  278. --- a/extmod/modtime.c
  279. +++ b/extmod/modtime.c
  280. @@ -52,7 +52,7 @@
  281. // - second is 0-59
  282. // - weekday is 0-6 for Mon-Sun
  283. // - yearday is 1-366
  284. -STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
  285. +static mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
  286. if (n_args == 0 || args[0] == mp_const_none) {
  287. // Get current date and time.
  288. return mp_time_localtime_get();
  289. @@ -80,7 +80,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_time_localtime_obj, 0, 1, time_localtime)
  290. // This is the inverse function of localtime. Its argument is a full 8-tuple
  291. // which expresses a time as per localtime. It returns an integer which is
  292. // the number of seconds since the Epoch (eg 1st Jan 1970, or 1st Jan 2000).
  293. -STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
  294. +static mp_obj_t time_mktime(mp_obj_t tuple) {
  295. size_t len;
  296. mp_obj_t *elem;
  297. mp_obj_get_array(tuple, &len, &elem);
  298. @@ -102,21 +102,21 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_time_mktime_obj, time_mktime);
  299. // time()
  300. // Return the number of seconds since the Epoch.
  301. -STATIC mp_obj_t time_time(void) {
  302. +static mp_obj_t time_time(void) {
  303. return mp_time_time_get();
  304. }
  305. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_obj, time_time);
  306. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_obj, time_time);
  307. // time_ns()
  308. // Returns the number of nanoseconds since the Epoch, as an integer.
  309. -STATIC mp_obj_t time_time_ns(void) {
  310. +static mp_obj_t time_time_ns(void) {
  311. return mp_obj_new_int_from_ull(mp_hal_time_ns());
  312. }
  313. MP_DEFINE_CONST_FUN_OBJ_0(mp_time_time_ns_obj, time_time_ns);
  314. #endif // MICROPY_PY_TIME_TIME_TIME_NS
  315. -STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
  316. +static mp_obj_t time_sleep(mp_obj_t seconds_o) {
  317. #ifdef MICROPY_PY_TIME_CUSTOM_SLEEP
  318. mp_time_sleep(seconds_o);
  319. #else
  320. @@ -130,7 +130,7 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
  321. }
  322. MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_obj, time_sleep);
  323. -STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
  324. +static mp_obj_t time_sleep_ms(mp_obj_t arg) {
  325. mp_int_t ms = mp_obj_get_int(arg);
  326. if (ms >= 0) {
  327. mp_hal_delay_ms(ms);
  328. @@ -139,7 +139,7 @@ STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
  329. }
  330. MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_ms_obj, time_sleep_ms);
  331. -STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
  332. +static mp_obj_t time_sleep_us(mp_obj_t arg) {
  333. mp_int_t us = mp_obj_get_int(arg);
  334. if (us > 0) {
  335. mp_hal_delay_us(us);
  336. @@ -148,22 +148,22 @@ STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
  337. }
  338. MP_DEFINE_CONST_FUN_OBJ_1(mp_time_sleep_us_obj, time_sleep_us);
  339. -STATIC mp_obj_t time_ticks_ms(void) {
  340. +static mp_obj_t time_ticks_ms(void) {
  341. return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
  342. }
  343. MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_ms_obj, time_ticks_ms);
  344. -STATIC mp_obj_t time_ticks_us(void) {
  345. +static mp_obj_t time_ticks_us(void) {
  346. return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_us() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
  347. }
  348. MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_us_obj, time_ticks_us);
  349. -STATIC mp_obj_t time_ticks_cpu(void) {
  350. +static mp_obj_t time_ticks_cpu(void) {
  351. return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & (MICROPY_PY_TIME_TICKS_PERIOD - 1));
  352. }
  353. MP_DEFINE_CONST_FUN_OBJ_0(mp_time_ticks_cpu_obj, time_ticks_cpu);
  354. -STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
  355. +static mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
  356. // we assume that the arguments come from ticks_xx so are small ints
  357. mp_uint_t start = MP_OBJ_SMALL_INT_VALUE(start_in);
  358. mp_uint_t end = MP_OBJ_SMALL_INT_VALUE(end_in);
  359. @@ -175,7 +175,7 @@ STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
  360. }
  361. MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_diff_obj, time_ticks_diff);
  362. -STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
  363. +static mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
  364. // we assume that first argument come from ticks_xx so is small int
  365. mp_uint_t ticks = MP_OBJ_SMALL_INT_VALUE(ticks_in);
  366. mp_uint_t delta = mp_obj_get_int(delta_in);
  367. @@ -196,7 +196,7 @@ STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
  368. }
  369. MP_DEFINE_CONST_FUN_OBJ_2(mp_time_ticks_add_obj, time_ticks_add);
  370. -STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
  371. +static const mp_rom_map_elem_t mp_module_time_globals_table[] = {
  372. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) },
  373. #if MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME
  374. @@ -224,7 +224,7 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
  375. MICROPY_PY_TIME_EXTRA_GLOBALS
  376. #endif
  377. };
  378. -STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
  379. +static MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
  380. const mp_obj_module_t mp_module_time = {
  381. .base = { &mp_type_module },
  382. diff --git a/genhdr/mpversion.h b/genhdr/mpversion.h
  383. index 529bcff07..65f0a26ae 100644
  384. --- a/genhdr/mpversion.h
  385. +++ b/genhdr/mpversion.h
  386. @@ -1,3 +1,4 @@
  387. // This file was generated by py/makeversionhdr.py
  388. -#define MICROPY_GIT_TAG "v1.22.2-dirty"
  389. +#define MICROPY_GIT_TAG "v1.23.0-preview.322.g5114f2c1e"
  390. +#define MICROPY_GIT_HASH "5114f2c1e"
  391. #define MICROPY_BUILD_DATE "2024-04-16"
  392. diff --git a/genhdr/qstrdefs.generated.h b/genhdr/qstrdefs.generated.h
  393. index 5e5196286..9c7c86451 100644
  394. --- a/genhdr/qstrdefs.generated.h
  395. +++ b/genhdr/qstrdefs.generated.h
  396. @@ -1,323 +1,323 @@
  397. // This file was automatically generated by makeqstrdata.py
  398. QDEF0(MP_QSTRnull, 0, 0, "")
  399. -QDEF0(MP_QSTR_, 5381, 0, "")
  400. -QDEF0(MP_QSTR___dir__, 36730, 7, "__dir__")
  401. -QDEF0(MP_QSTR__0x0a_, 46511, 1, "\x0a")
  402. -QDEF0(MP_QSTR__space_, 46469, 1, " ")
  403. -QDEF0(MP_QSTR__star_, 46479, 1, "*")
  404. -QDEF0(MP_QSTR__slash_, 46474, 1, "/")
  405. -QDEF0(MP_QSTR__lt_module_gt_, 38077, 8, "<module>")
  406. -QDEF0(MP_QSTR__, 46586, 1, "_")
  407. -QDEF0(MP_QSTR___call__, 63911, 8, "__call__")
  408. -QDEF0(MP_QSTR___class__, 50475, 9, "__class__")
  409. -QDEF0(MP_QSTR___delitem__, 13821, 11, "__delitem__")
  410. -QDEF0(MP_QSTR___enter__, 47725, 9, "__enter__")
  411. -QDEF0(MP_QSTR___exit__, 63557, 8, "__exit__")
  412. -QDEF0(MP_QSTR___getattr__, 63552, 11, "__getattr__")
  413. -QDEF0(MP_QSTR___getitem__, 14630, 11, "__getitem__")
  414. -QDEF0(MP_QSTR___hash__, 51447, 8, "__hash__")
  415. -QDEF0(MP_QSTR___init__, 42335, 8, "__init__")
  416. -QDEF0(MP_QSTR___int__, 6934, 7, "__int__")
  417. -QDEF0(MP_QSTR___iter__, 13007, 8, "__iter__")
  418. -QDEF0(MP_QSTR___len__, 45282, 7, "__len__")
  419. -QDEF0(MP_QSTR___main__, 5006, 8, "__main__")
  420. -QDEF0(MP_QSTR___module__, 12543, 10, "__module__")
  421. -QDEF0(MP_QSTR___name__, 14562, 8, "__name__")
  422. -QDEF0(MP_QSTR___new__, 5497, 7, "__new__")
  423. -QDEF0(MP_QSTR___next__, 29442, 8, "__next__")
  424. +QDEF0(MP_QSTR_, 5, 0, "")
  425. +QDEF0(MP_QSTR___dir__, 122, 7, "__dir__")
  426. +QDEF0(MP_QSTR__0x0a_, 175, 1, "\x0a")
  427. +QDEF0(MP_QSTR__space_, 133, 1, " ")
  428. +QDEF0(MP_QSTR__star_, 143, 1, "*")
  429. +QDEF0(MP_QSTR__slash_, 138, 1, "/")
  430. +QDEF0(MP_QSTR__lt_module_gt_, 189, 8, "<module>")
  431. +QDEF0(MP_QSTR__, 250, 1, "_")
  432. +QDEF0(MP_QSTR___call__, 167, 8, "__call__")
  433. +QDEF0(MP_QSTR___class__, 43, 9, "__class__")
  434. +QDEF0(MP_QSTR___delitem__, 253, 11, "__delitem__")
  435. +QDEF0(MP_QSTR___enter__, 109, 9, "__enter__")
  436. +QDEF0(MP_QSTR___exit__, 69, 8, "__exit__")
  437. +QDEF0(MP_QSTR___getattr__, 64, 11, "__getattr__")
  438. +QDEF0(MP_QSTR___getitem__, 38, 11, "__getitem__")
  439. +QDEF0(MP_QSTR___hash__, 247, 8, "__hash__")
  440. +QDEF0(MP_QSTR___init__, 95, 8, "__init__")
  441. +QDEF0(MP_QSTR___int__, 22, 7, "__int__")
  442. +QDEF0(MP_QSTR___iter__, 207, 8, "__iter__")
  443. +QDEF0(MP_QSTR___len__, 226, 7, "__len__")
  444. +QDEF0(MP_QSTR___main__, 142, 8, "__main__")
  445. +QDEF0(MP_QSTR___module__, 255, 10, "__module__")
  446. +QDEF0(MP_QSTR___name__, 226, 8, "__name__")
  447. +QDEF0(MP_QSTR___new__, 121, 7, "__new__")
  448. +QDEF0(MP_QSTR___next__, 2, 8, "__next__")
  449. QDEF0(MP_QSTR___qualname__, 107, 12, "__qualname__")
  450. -QDEF0(MP_QSTR___repr__, 2832, 8, "__repr__")
  451. -QDEF0(MP_QSTR___setitem__, 15922, 11, "__setitem__")
  452. -QDEF0(MP_QSTR___str__, 52688, 7, "__str__")
  453. -QDEF0(MP_QSTR_ArithmeticError, 35885, 15, "ArithmeticError")
  454. -QDEF0(MP_QSTR_AssertionError, 23191, 14, "AssertionError")
  455. -QDEF0(MP_QSTR_AttributeError, 56865, 14, "AttributeError")
  456. -QDEF0(MP_QSTR_BaseException, 37383, 13, "BaseException")
  457. -QDEF0(MP_QSTR_EOFError, 49041, 8, "EOFError")
  458. -QDEF0(MP_QSTR_Ellipsis, 57584, 8, "Ellipsis")
  459. -QDEF0(MP_QSTR_Exception, 10738, 9, "Exception")
  460. -QDEF0(MP_QSTR_GeneratorExit, 25110, 13, "GeneratorExit")
  461. -QDEF0(MP_QSTR_ImportError, 39968, 11, "ImportError")
  462. -QDEF0(MP_QSTR_IndentationError, 8284, 16, "IndentationError")
  463. -QDEF0(MP_QSTR_IndexError, 44419, 10, "IndexError")
  464. +QDEF0(MP_QSTR___repr__, 16, 8, "__repr__")
  465. +QDEF0(MP_QSTR___setitem__, 50, 11, "__setitem__")
  466. +QDEF0(MP_QSTR___str__, 208, 7, "__str__")
  467. +QDEF0(MP_QSTR_ArithmeticError, 45, 15, "ArithmeticError")
  468. +QDEF0(MP_QSTR_AssertionError, 151, 14, "AssertionError")
  469. +QDEF0(MP_QSTR_AttributeError, 33, 14, "AttributeError")
  470. +QDEF0(MP_QSTR_BaseException, 7, 13, "BaseException")
  471. +QDEF0(MP_QSTR_EOFError, 145, 8, "EOFError")
  472. +QDEF0(MP_QSTR_Ellipsis, 240, 8, "Ellipsis")
  473. +QDEF0(MP_QSTR_Exception, 242, 9, "Exception")
  474. +QDEF0(MP_QSTR_GeneratorExit, 22, 13, "GeneratorExit")
  475. +QDEF0(MP_QSTR_ImportError, 32, 11, "ImportError")
  476. +QDEF0(MP_QSTR_IndentationError, 92, 16, "IndentationError")
  477. +QDEF0(MP_QSTR_IndexError, 131, 10, "IndexError")
  478. QDEF0(MP_QSTR_KeyError, 234, 8, "KeyError")
  479. -QDEF0(MP_QSTR_KeyboardInterrupt, 58031, 17, "KeyboardInterrupt")
  480. -QDEF0(MP_QSTR_LookupError, 27135, 11, "LookupError")
  481. -QDEF0(MP_QSTR_MemoryError, 33756, 11, "MemoryError")
  482. -QDEF0(MP_QSTR_NameError, 11706, 9, "NameError")
  483. -QDEF0(MP_QSTR_NoneType, 26647, 8, "NoneType")
  484. -QDEF0(MP_QSTR_NotImplementedError, 39110, 19, "NotImplementedError")
  485. -QDEF0(MP_QSTR_OSError, 26017, 7, "OSError")
  486. -QDEF0(MP_QSTR_OverflowError, 57729, 13, "OverflowError")
  487. -QDEF0(MP_QSTR_RuntimeError, 61793, 12, "RuntimeError")
  488. -QDEF0(MP_QSTR_StopIteration, 7402, 13, "StopIteration")
  489. -QDEF0(MP_QSTR_SyntaxError, 36756, 11, "SyntaxError")
  490. -QDEF0(MP_QSTR_SystemExit, 65312, 10, "SystemExit")
  491. -QDEF0(MP_QSTR_TypeError, 38437, 9, "TypeError")
  492. -QDEF0(MP_QSTR_ValueError, 34710, 10, "ValueError")
  493. -QDEF0(MP_QSTR_ZeroDivisionError, 10166, 17, "ZeroDivisionError")
  494. -QDEF0(MP_QSTR_abs, 12949, 3, "abs")
  495. -QDEF0(MP_QSTR_all, 13124, 3, "all")
  496. -QDEF0(MP_QSTR_any, 13075, 3, "any")
  497. -QDEF0(MP_QSTR_append, 38763, 6, "append")
  498. -QDEF0(MP_QSTR_args, 50882, 4, "args")
  499. -QDEF0(MP_QSTR_bool, 15595, 4, "bool")
  500. -QDEF0(MP_QSTR_builtins, 12791, 8, "builtins")
  501. -QDEF0(MP_QSTR_bytearray, 41846, 9, "bytearray")
  502. -QDEF0(MP_QSTR_bytecode, 32034, 8, "bytecode")
  503. -QDEF0(MP_QSTR_bytes, 45660, 5, "bytes")
  504. -QDEF0(MP_QSTR_callable, 28685, 8, "callable")
  505. -QDEF0(MP_QSTR_chr, 19676, 3, "chr")
  506. -QDEF0(MP_QSTR_classmethod, 36020, 11, "classmethod")
  507. -QDEF0(MP_QSTR_clear, 41084, 5, "clear")
  508. -QDEF0(MP_QSTR_close, 26419, 5, "close")
  509. -QDEF0(MP_QSTR_const, 65472, 5, "const")
  510. -QDEF0(MP_QSTR_copy, 56288, 4, "copy")
  511. -QDEF0(MP_QSTR_count, 19878, 5, "count")
  512. -QDEF0(MP_QSTR_dict, 64575, 4, "dict")
  513. -QDEF0(MP_QSTR_dir, 7930, 3, "dir")
  514. -QDEF0(MP_QSTR_divmod, 1208, 6, "divmod")
  515. -QDEF0(MP_QSTR_end, 8970, 3, "end")
  516. -QDEF0(MP_QSTR_endswith, 41755, 8, "endswith")
  517. -QDEF0(MP_QSTR_eval, 42651, 4, "eval")
  518. -QDEF0(MP_QSTR_exec, 49182, 4, "exec")
  519. -QDEF0(MP_QSTR_extend, 59491, 6, "extend")
  520. -QDEF0(MP_QSTR_find, 13312, 4, "find")
  521. -QDEF0(MP_QSTR_format, 13094, 6, "format")
  522. -QDEF0(MP_QSTR_from_bytes, 29749, 10, "from_bytes")
  523. -QDEF0(MP_QSTR_get, 15155, 3, "get")
  524. -QDEF0(MP_QSTR_getattr, 6080, 7, "getattr")
  525. -QDEF0(MP_QSTR_globals, 18845, 7, "globals")
  526. -QDEF0(MP_QSTR_hasattr, 45196, 7, "hasattr")
  527. -QDEF0(MP_QSTR_hash, 28855, 4, "hash")
  528. -QDEF0(MP_QSTR_id, 28456, 2, "id")
  529. -QDEF0(MP_QSTR_index, 10363, 5, "index")
  530. -QDEF0(MP_QSTR_insert, 21522, 6, "insert")
  531. -QDEF0(MP_QSTR_int, 21270, 3, "int")
  532. -QDEF0(MP_QSTR_isalpha, 14315, 7, "isalpha")
  533. -QDEF0(MP_QSTR_isdigit, 39592, 7, "isdigit")
  534. -QDEF0(MP_QSTR_isinstance, 48822, 10, "isinstance")
  535. -QDEF0(MP_QSTR_islower, 33020, 7, "islower")
  536. -QDEF0(MP_QSTR_isspace, 63579, 7, "isspace")
  537. -QDEF0(MP_QSTR_issubclass, 32693, 10, "issubclass")
  538. -QDEF0(MP_QSTR_isupper, 42973, 7, "isupper")
  539. -QDEF0(MP_QSTR_items, 21475, 5, "items")
  540. -QDEF0(MP_QSTR_iter, 8591, 4, "iter")
  541. -QDEF0(MP_QSTR_join, 23719, 4, "join")
  542. -QDEF0(MP_QSTR_key, 27954, 3, "key")
  543. -QDEF0(MP_QSTR_keys, 4865, 4, "keys")
  544. -QDEF0(MP_QSTR_len, 16482, 3, "len")
  545. -QDEF0(MP_QSTR_list, 7463, 4, "list")
  546. -QDEF0(MP_QSTR_little, 27273, 6, "little")
  547. -QDEF0(MP_QSTR_locals, 41275, 6, "locals")
  548. -QDEF0(MP_QSTR_lower, 52166, 5, "lower")
  549. -QDEF0(MP_QSTR_lstrip, 47589, 6, "lstrip")
  550. -QDEF0(MP_QSTR_main, 47054, 4, "main")
  551. -QDEF0(MP_QSTR_map, 17337, 3, "map")
  552. -QDEF0(MP_QSTR_micropython, 31755, 11, "micropython")
  553. -QDEF0(MP_QSTR_next, 34882, 4, "next")
  554. -QDEF0(MP_QSTR_object, 36240, 6, "object")
  555. -QDEF0(MP_QSTR_open, 15057, 4, "open")
  556. -QDEF0(MP_QSTR_ord, 24092, 3, "ord")
  557. -QDEF0(MP_QSTR_pop, 29482, 3, "pop")
  558. -QDEF0(MP_QSTR_popitem, 11455, 7, "popitem")
  559. -QDEF0(MP_QSTR_pow, 29485, 3, "pow")
  560. -QDEF0(MP_QSTR_print, 50772, 5, "print")
  561. -QDEF0(MP_QSTR_range, 24090, 5, "range")
  562. -QDEF0(MP_QSTR_read, 63927, 4, "read")
  563. -QDEF0(MP_QSTR_readinto, 48971, 8, "readinto")
  564. -QDEF0(MP_QSTR_readline, 6649, 8, "readline")
  565. -QDEF0(MP_QSTR_remove, 35427, 6, "remove")
  566. -QDEF0(MP_QSTR_replace, 9545, 7, "replace")
  567. -QDEF0(MP_QSTR_repr, 63440, 4, "repr")
  568. -QDEF0(MP_QSTR_reverse, 10789, 7, "reverse")
  569. -QDEF0(MP_QSTR_rfind, 40146, 5, "rfind")
  570. -QDEF0(MP_QSTR_rindex, 11241, 6, "rindex")
  571. -QDEF0(MP_QSTR_round, 9703, 5, "round")
  572. +QDEF0(MP_QSTR_KeyboardInterrupt, 175, 17, "KeyboardInterrupt")
  573. +QDEF0(MP_QSTR_LookupError, 255, 11, "LookupError")
  574. +QDEF0(MP_QSTR_MemoryError, 220, 11, "MemoryError")
  575. +QDEF0(MP_QSTR_NameError, 186, 9, "NameError")
  576. +QDEF0(MP_QSTR_NoneType, 23, 8, "NoneType")
  577. +QDEF0(MP_QSTR_NotImplementedError, 198, 19, "NotImplementedError")
  578. +QDEF0(MP_QSTR_OSError, 161, 7, "OSError")
  579. +QDEF0(MP_QSTR_OverflowError, 129, 13, "OverflowError")
  580. +QDEF0(MP_QSTR_RuntimeError, 97, 12, "RuntimeError")
  581. +QDEF0(MP_QSTR_StopIteration, 234, 13, "StopIteration")
  582. +QDEF0(MP_QSTR_SyntaxError, 148, 11, "SyntaxError")
  583. +QDEF0(MP_QSTR_SystemExit, 32, 10, "SystemExit")
  584. +QDEF0(MP_QSTR_TypeError, 37, 9, "TypeError")
  585. +QDEF0(MP_QSTR_ValueError, 150, 10, "ValueError")
  586. +QDEF0(MP_QSTR_ZeroDivisionError, 182, 17, "ZeroDivisionError")
  587. +QDEF0(MP_QSTR_abs, 149, 3, "abs")
  588. +QDEF0(MP_QSTR_all, 68, 3, "all")
  589. +QDEF0(MP_QSTR_any, 19, 3, "any")
  590. +QDEF0(MP_QSTR_append, 107, 6, "append")
  591. +QDEF0(MP_QSTR_args, 194, 4, "args")
  592. +QDEF0(MP_QSTR_bool, 235, 4, "bool")
  593. +QDEF0(MP_QSTR_builtins, 247, 8, "builtins")
  594. +QDEF0(MP_QSTR_bytearray, 118, 9, "bytearray")
  595. +QDEF0(MP_QSTR_bytecode, 34, 8, "bytecode")
  596. +QDEF0(MP_QSTR_bytes, 92, 5, "bytes")
  597. +QDEF0(MP_QSTR_callable, 13, 8, "callable")
  598. +QDEF0(MP_QSTR_chr, 220, 3, "chr")
  599. +QDEF0(MP_QSTR_classmethod, 180, 11, "classmethod")
  600. +QDEF0(MP_QSTR_clear, 124, 5, "clear")
  601. +QDEF0(MP_QSTR_close, 51, 5, "close")
  602. +QDEF0(MP_QSTR_const, 192, 5, "const")
  603. +QDEF0(MP_QSTR_copy, 224, 4, "copy")
  604. +QDEF0(MP_QSTR_count, 166, 5, "count")
  605. +QDEF0(MP_QSTR_dict, 63, 4, "dict")
  606. +QDEF0(MP_QSTR_dir, 250, 3, "dir")
  607. +QDEF0(MP_QSTR_divmod, 184, 6, "divmod")
  608. +QDEF0(MP_QSTR_end, 10, 3, "end")
  609. +QDEF0(MP_QSTR_endswith, 27, 8, "endswith")
  610. +QDEF0(MP_QSTR_eval, 155, 4, "eval")
  611. +QDEF0(MP_QSTR_exec, 30, 4, "exec")
  612. +QDEF0(MP_QSTR_extend, 99, 6, "extend")
  613. +QDEF0(MP_QSTR_find, 1, 4, "find")
  614. +QDEF0(MP_QSTR_format, 38, 6, "format")
  615. +QDEF0(MP_QSTR_from_bytes, 53, 10, "from_bytes")
  616. +QDEF0(MP_QSTR_get, 51, 3, "get")
  617. +QDEF0(MP_QSTR_getattr, 192, 7, "getattr")
  618. +QDEF0(MP_QSTR_globals, 157, 7, "globals")
  619. +QDEF0(MP_QSTR_hasattr, 140, 7, "hasattr")
  620. +QDEF0(MP_QSTR_hash, 183, 4, "hash")
  621. +QDEF0(MP_QSTR_id, 40, 2, "id")
  622. +QDEF0(MP_QSTR_index, 123, 5, "index")
  623. +QDEF0(MP_QSTR_insert, 18, 6, "insert")
  624. +QDEF0(MP_QSTR_int, 22, 3, "int")
  625. +QDEF0(MP_QSTR_isalpha, 235, 7, "isalpha")
  626. +QDEF0(MP_QSTR_isdigit, 168, 7, "isdigit")
  627. +QDEF0(MP_QSTR_isinstance, 182, 10, "isinstance")
  628. +QDEF0(MP_QSTR_islower, 252, 7, "islower")
  629. +QDEF0(MP_QSTR_isspace, 91, 7, "isspace")
  630. +QDEF0(MP_QSTR_issubclass, 181, 10, "issubclass")
  631. +QDEF0(MP_QSTR_isupper, 221, 7, "isupper")
  632. +QDEF0(MP_QSTR_items, 227, 5, "items")
  633. +QDEF0(MP_QSTR_iter, 143, 4, "iter")
  634. +QDEF0(MP_QSTR_join, 167, 4, "join")
  635. +QDEF0(MP_QSTR_key, 50, 3, "key")
  636. +QDEF0(MP_QSTR_keys, 1, 4, "keys")
  637. +QDEF0(MP_QSTR_len, 98, 3, "len")
  638. +QDEF0(MP_QSTR_list, 39, 4, "list")
  639. +QDEF0(MP_QSTR_little, 137, 6, "little")
  640. +QDEF0(MP_QSTR_locals, 59, 6, "locals")
  641. +QDEF0(MP_QSTR_lower, 198, 5, "lower")
  642. +QDEF0(MP_QSTR_lstrip, 229, 6, "lstrip")
  643. +QDEF0(MP_QSTR_main, 206, 4, "main")
  644. +QDEF0(MP_QSTR_map, 185, 3, "map")
  645. +QDEF0(MP_QSTR_micropython, 11, 11, "micropython")
  646. +QDEF0(MP_QSTR_next, 66, 4, "next")
  647. +QDEF0(MP_QSTR_object, 144, 6, "object")
  648. +QDEF0(MP_QSTR_open, 209, 4, "open")
  649. +QDEF0(MP_QSTR_ord, 28, 3, "ord")
  650. +QDEF0(MP_QSTR_pop, 42, 3, "pop")
  651. +QDEF0(MP_QSTR_popitem, 191, 7, "popitem")
  652. +QDEF0(MP_QSTR_pow, 45, 3, "pow")
  653. +QDEF0(MP_QSTR_print, 84, 5, "print")
  654. +QDEF0(MP_QSTR_range, 26, 5, "range")
  655. +QDEF0(MP_QSTR_read, 183, 4, "read")
  656. +QDEF0(MP_QSTR_readinto, 75, 8, "readinto")
  657. +QDEF0(MP_QSTR_readline, 249, 8, "readline")
  658. +QDEF0(MP_QSTR_remove, 99, 6, "remove")
  659. +QDEF0(MP_QSTR_replace, 73, 7, "replace")
  660. +QDEF0(MP_QSTR_repr, 208, 4, "repr")
  661. +QDEF0(MP_QSTR_reverse, 37, 7, "reverse")
  662. +QDEF0(MP_QSTR_rfind, 210, 5, "rfind")
  663. +QDEF0(MP_QSTR_rindex, 233, 6, "rindex")
  664. +QDEF0(MP_QSTR_round, 231, 5, "round")
  665. QDEF0(MP_QSTR_rsplit, 165, 6, "rsplit")
  666. -QDEF0(MP_QSTR_rstrip, 38203, 6, "rstrip")
  667. -QDEF0(MP_QSTR_self, 30585, 4, "self")
  668. -QDEF0(MP_QSTR_send, 30393, 4, "send")
  669. -QDEF0(MP_QSTR_sep, 36643, 3, "sep")
  670. -QDEF0(MP_QSTR_set, 36647, 3, "set")
  671. -QDEF0(MP_QSTR_setattr, 43220, 7, "setattr")
  672. -QDEF0(MP_QSTR_setdefault, 41836, 10, "setdefault")
  673. -QDEF0(MP_QSTR_sort, 40383, 4, "sort")
  674. -QDEF0(MP_QSTR_sorted, 5470, 6, "sorted")
  675. -QDEF0(MP_QSTR_split, 13239, 5, "split")
  676. -QDEF0(MP_QSTR_start, 61317, 5, "start")
  677. -QDEF0(MP_QSTR_startswith, 59508, 10, "startswith")
  678. -QDEF0(MP_QSTR_staticmethod, 44898, 12, "staticmethod")
  679. -QDEF0(MP_QSTR_step, 13911, 4, "step")
  680. -QDEF0(MP_QSTR_stop, 13981, 4, "stop")
  681. -QDEF0(MP_QSTR_str, 36176, 3, "str")
  682. -QDEF0(MP_QSTR_strip, 7721, 5, "strip")
  683. -QDEF0(MP_QSTR_sum, 36142, 3, "sum")
  684. -QDEF0(MP_QSTR_super, 45764, 5, "super")
  685. -QDEF0(MP_QSTR_throw, 17587, 5, "throw")
  686. -QDEF0(MP_QSTR_to_bytes, 16088, 8, "to_bytes")
  687. -QDEF0(MP_QSTR_tuple, 16893, 5, "tuple")
  688. -QDEF0(MP_QSTR_type, 32669, 4, "type")
  689. -QDEF0(MP_QSTR_update, 30388, 6, "update")
  690. -QDEF0(MP_QSTR_upper, 37927, 5, "upper")
  691. -QDEF0(MP_QSTR_utf_hyphen_8, 33463, 5, "utf-8")
  692. -QDEF0(MP_QSTR_value, 13390, 5, "value")
  693. -QDEF0(MP_QSTR_values, 48765, 6, "values")
  694. -QDEF0(MP_QSTR_write, 43160, 5, "write")
  695. -QDEF0(MP_QSTR_zip, 44262, 3, "zip")
  696. -QDEF1(MP_QSTR__percent__hash_o, 6764, 3, "%#o")
  697. -QDEF1(MP_QSTR__percent__hash_x, 6779, 3, "%#x")
  698. -QDEF1(MP_QSTR__lt_dictcomp_gt_, 36300, 10, "<dictcomp>")
  699. -QDEF1(MP_QSTR__lt_genexpr_gt_, 27188, 9, "<genexpr>")
  700. -QDEF1(MP_QSTR__lt_lambda_gt_, 35968, 8, "<lambda>")
  701. -QDEF1(MP_QSTR__lt_listcomp_gt_, 5588, 10, "<listcomp>")
  702. -QDEF1(MP_QSTR__lt_setcomp_gt_, 20820, 9, "<setcomp>")
  703. -QDEF1(MP_QSTR__lt_stdin_gt_, 25571, 7, "<stdin>")
  704. -QDEF1(MP_QSTR__lt_string_gt_, 21330, 8, "<string>")
  705. -QDEF1(MP_QSTR_CANVAS_ALIGN_BEGIN, 40103, 18, "CANVAS_ALIGN_BEGIN")
  706. -QDEF1(MP_QSTR_CANVAS_ALIGN_CENTER, 1771, 19, "CANVAS_ALIGN_CENTER")
  707. -QDEF1(MP_QSTR_CANVAS_ALIGN_END, 49391, 16, "CANVAS_ALIGN_END")
  708. -QDEF1(MP_QSTR_CANVAS_BLACK, 34261, 12, "CANVAS_BLACK")
  709. -QDEF1(MP_QSTR_CANVAS_FONT_PRIMARY, 35826, 19, "CANVAS_FONT_PRIMARY")
  710. -QDEF1(MP_QSTR_CANVAS_FONT_SECONDARY, 58372, 21, "CANVAS_FONT_SECONDARY")
  711. -QDEF1(MP_QSTR_CANVAS_WHITE, 11573, 12, "CANVAS_WHITE")
  712. -QDEF1(MP_QSTR_INPUT_BUTTON_BACK, 3502, 17, "INPUT_BUTTON_BACK")
  713. -QDEF1(MP_QSTR_INPUT_BUTTON_DOWN, 53239, 17, "INPUT_BUTTON_DOWN")
  714. -QDEF1(MP_QSTR_INPUT_BUTTON_LEFT, 5982, 17, "INPUT_BUTTON_LEFT")
  715. -QDEF1(MP_QSTR_INPUT_BUTTON_OK, 56353, 15, "INPUT_BUTTON_OK")
  716. -QDEF1(MP_QSTR_INPUT_BUTTON_RIGHT, 39685, 18, "INPUT_BUTTON_RIGHT")
  717. -QDEF1(MP_QSTR_INPUT_BUTTON_UP, 56672, 15, "INPUT_BUTTON_UP")
  718. -QDEF1(MP_QSTR_INPUT_TYPE_LONG, 24161, 15, "INPUT_TYPE_LONG")
  719. -QDEF1(MP_QSTR_INPUT_TYPE_PRESS, 41324, 16, "INPUT_TYPE_PRESS")
  720. -QDEF1(MP_QSTR_INPUT_TYPE_RELEASE, 65058, 18, "INPUT_TYPE_RELEASE")
  721. -QDEF1(MP_QSTR_INPUT_TYPE_REPEAT, 64028, 17, "INPUT_TYPE_REPEAT")
  722. -QDEF1(MP_QSTR_INPUT_TYPE_SHORT, 8601, 16, "INPUT_TYPE_SHORT")
  723. -QDEF1(MP_QSTR_LIGHT_BACKLIGHT, 18705, 15, "LIGHT_BACKLIGHT")
  724. -QDEF1(MP_QSTR_LIGHT_BLUE, 64346, 10, "LIGHT_BLUE")
  725. -QDEF1(MP_QSTR_LIGHT_GREEN, 32095, 11, "LIGHT_GREEN")
  726. -QDEF1(MP_QSTR_LIGHT_RED, 54999, 9, "LIGHT_RED")
  727. -QDEF0(MP_QSTR___add__, 33476, 7, "__add__")
  728. -QDEF1(MP_QSTR___bases__, 12291, 9, "__bases__")
  729. -QDEF0(MP_QSTR___bool__, 25899, 8, "__bool__")
  730. -QDEF1(MP_QSTR___build_class__, 34882, 15, "__build_class__")
  731. -QDEF0(MP_QSTR___contains__, 24518, 12, "__contains__")
  732. -QDEF1(MP_QSTR___dict__, 21631, 8, "__dict__")
  733. -QDEF0(MP_QSTR___eq__, 15985, 6, "__eq__")
  734. -QDEF1(MP_QSTR___file__, 21507, 8, "__file__")
  735. -QDEF0(MP_QSTR___float__, 28725, 9, "__float__")
  736. -QDEF0(MP_QSTR___ge__, 18087, 6, "__ge__")
  737. -QDEF1(MP_QSTR___globals__, 44701, 11, "__globals__")
  738. -QDEF0(MP_QSTR___gt__, 33462, 6, "__gt__")
  739. -QDEF0(MP_QSTR___iadd__, 19053, 8, "__iadd__")
  740. -QDEF1(MP_QSTR___import__, 15928, 10, "__import__")
  741. -QDEF0(MP_QSTR___isub__, 30728, 8, "__isub__")
  742. -QDEF0(MP_QSTR___le__, 5068, 6, "__le__")
  743. -QDEF0(MP_QSTR___lt__, 26717, 6, "__lt__")
  744. -QDEF0(MP_QSTR___ne__, 2830, 6, "__ne__")
  745. -QDEF1(MP_QSTR___path__, 9160, 8, "__path__")
  746. -QDEF1(MP_QSTR___repl_print__, 47872, 14, "__repl_print__")
  747. -QDEF1(MP_QSTR___reversed__, 65377, 12, "__reversed__")
  748. -QDEF0(MP_QSTR___sub__, 2337, 7, "__sub__")
  749. -QDEF1(MP_QSTR___traceback__, 53071, 13, "__traceback__")
  750. -QDEF1(MP_QSTR__input_trigger_handler, 50540, 22, "_input_trigger_handler")
  751. -QDEF1(MP_QSTR_add, 12868, 3, "add")
  752. -QDEF1(MP_QSTR_array, 29308, 5, "array")
  753. -QDEF1(MP_QSTR_bin, 18656, 3, "bin")
  754. -QDEF1(MP_QSTR_bound_method, 41623, 12, "bound_method")
  755. -QDEF1(MP_QSTR_canvas_clear, 30827, 12, "canvas_clear")
  756. -QDEF1(MP_QSTR_canvas_draw_box, 52536, 15, "canvas_draw_box")
  757. -QDEF1(MP_QSTR_canvas_draw_circle, 4671, 18, "canvas_draw_circle")
  758. -QDEF1(MP_QSTR_canvas_draw_disc, 12976, 16, "canvas_draw_disc")
  759. -QDEF1(MP_QSTR_canvas_draw_dot, 42162, 15, "canvas_draw_dot")
  760. -QDEF1(MP_QSTR_canvas_draw_frame, 4592, 17, "canvas_draw_frame")
  761. -QDEF1(MP_QSTR_canvas_draw_line, 4419, 16, "canvas_draw_line")
  762. -QDEF1(MP_QSTR_canvas_height, 65357, 13, "canvas_height")
  763. -QDEF1(MP_QSTR_canvas_set_color, 9394, 16, "canvas_set_color")
  764. -QDEF1(MP_QSTR_canvas_set_font, 57212, 15, "canvas_set_font")
  765. -QDEF1(MP_QSTR_canvas_set_text, 1394, 15, "canvas_set_text")
  766. -QDEF1(MP_QSTR_canvas_set_text_align, 56000, 21, "canvas_set_text_align")
  767. -QDEF1(MP_QSTR_canvas_text_height, 18415, 18, "canvas_text_height")
  768. -QDEF1(MP_QSTR_canvas_text_width, 2390, 17, "canvas_text_width")
  769. -QDEF1(MP_QSTR_canvas_update, 21379, 13, "canvas_update")
  770. -QDEF1(MP_QSTR_canvas_width, 41652, 12, "canvas_width")
  771. -QDEF1(MP_QSTR_choice, 13102, 6, "choice")
  772. -QDEF1(MP_QSTR_closure, 51828, 7, "closure")
  773. -QDEF1(MP_QSTR_collect, 26011, 7, "collect")
  774. -QDEF1(MP_QSTR_decode, 22953, 6, "decode")
  775. -QDEF1(MP_QSTR_default, 32206, 7, "default")
  776. -QDEF1(MP_QSTR_delattr, 51419, 7, "delattr")
  777. -QDEF1(MP_QSTR_deleter, 56174, 7, "deleter")
  778. -QDEF1(MP_QSTR_dict_view, 43309, 9, "dict_view")
  779. -QDEF1(MP_QSTR_difference, 9330, 10, "difference")
  780. -QDEF1(MP_QSTR_difference_update, 64156, 17, "difference_update")
  781. -QDEF1(MP_QSTR_disable, 30353, 7, "disable")
  782. -QDEF1(MP_QSTR_discard, 28943, 7, "discard")
  783. -QDEF1(MP_QSTR_doc, 7981, 3, "doc")
  784. -QDEF1(MP_QSTR_enable, 56836, 6, "enable")
  785. -QDEF1(MP_QSTR_encode, 51779, 6, "encode")
  786. -QDEF1(MP_QSTR_enumerate, 47729, 9, "enumerate")
  787. -QDEF1(MP_QSTR_errno, 4545, 5, "errno")
  788. -QDEF1(MP_QSTR_filter, 48677, 6, "filter")
  789. -QDEF1(MP_QSTR_flipperzero, 60083, 11, "flipperzero")
  790. -QDEF1(MP_QSTR_float, 17461, 5, "float")
  791. -QDEF1(MP_QSTR_fromkeys, 48439, 8, "fromkeys")
  792. -QDEF1(MP_QSTR_function, 551, 8, "function")
  793. -QDEF1(MP_QSTR_gc, 28257, 2, "gc")
  794. -QDEF1(MP_QSTR_generator, 50070, 9, "generator")
  795. -QDEF1(MP_QSTR_getrandbits, 32102, 11, "getrandbits")
  796. -QDEF1(MP_QSTR_getter, 45712, 6, "getter")
  797. -QDEF1(MP_QSTR_heap_lock, 36013, 9, "heap_lock")
  798. -QDEF1(MP_QSTR_heap_unlock, 11606, 11, "heap_unlock")
  799. -QDEF1(MP_QSTR_hex, 20592, 3, "hex")
  800. -QDEF1(MP_QSTR_intersection, 10792, 12, "intersection")
  801. -QDEF1(MP_QSTR_intersection_update, 56582, 19, "intersection_update")
  802. -QDEF1(MP_QSTR_isdisjoint, 26871, 10, "isdisjoint")
  803. -QDEF1(MP_QSTR_isenabled, 58778, 9, "isenabled")
  804. -QDEF1(MP_QSTR_issubset, 49593, 8, "issubset")
  805. -QDEF1(MP_QSTR_issuperset, 60668, 10, "issuperset")
  806. -QDEF1(MP_QSTR_iterable, 37413, 8, "iterable")
  807. -QDEF1(MP_QSTR_iterator, 48711, 8, "iterator")
  808. -QDEF1(MP_QSTR_light_blink_set_color, 17369, 21, "light_blink_set_color")
  809. -QDEF1(MP_QSTR_light_blink_start, 25721, 17, "light_blink_start")
  810. -QDEF1(MP_QSTR_light_blink_stop, 37921, 16, "light_blink_stop")
  811. -QDEF1(MP_QSTR_light_set, 18054, 9, "light_set")
  812. -QDEF1(MP_QSTR_max, 17329, 3, "max")
  813. -QDEF1(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, 7795, 32, "maximum recursion depth exceeded")
  814. -QDEF1(MP_QSTR_mem_alloc, 11090, 9, "mem_alloc")
  815. -QDEF1(MP_QSTR_mem_free, 25291, 8, "mem_free")
  816. -QDEF1(MP_QSTR_min, 17071, 3, "min")
  817. -QDEF1(MP_QSTR_module, 39359, 6, "module")
  818. -QDEF1(MP_QSTR_oct, 23805, 3, "oct")
  819. -QDEF1(MP_QSTR_on_input, 32141, 8, "on_input")
  820. -QDEF1(MP_QSTR_opt_level, 26503, 9, "opt_level")
  821. -QDEF1(MP_QSTR_property, 10690, 8, "property")
  822. -QDEF1(MP_QSTR_randint, 56495, 7, "randint")
  823. -QDEF1(MP_QSTR_random, 11454, 6, "random")
  824. -QDEF1(MP_QSTR_randrange, 16035, 9, "randrange")
  825. -QDEF1(MP_QSTR_rb, 28885, 2, "rb")
  826. -QDEF1(MP_QSTR_reversed, 28321, 8, "reversed")
  827. -QDEF1(MP_QSTR_schedule, 44256, 8, "schedule")
  828. -QDEF1(MP_QSTR_seed, 30098, 4, "seed")
  829. -QDEF1(MP_QSTR_setter, 22788, 6, "setter")
  830. -QDEF1(MP_QSTR_sleep, 10218, 5, "sleep")
  831. -QDEF1(MP_QSTR_sleep_ms, 25355, 8, "sleep_ms")
  832. -QDEF1(MP_QSTR_sleep_us, 24595, 8, "sleep_us")
  833. -QDEF1(MP_QSTR_slice, 62645, 5, "slice")
  834. -QDEF1(MP_QSTR_speaker_set_volume, 51060, 18, "speaker_set_volume")
  835. -QDEF1(MP_QSTR_speaker_start, 18433, 13, "speaker_start")
  836. -QDEF1(MP_QSTR_speaker_stop, 36249, 12, "speaker_stop")
  837. -QDEF1(MP_QSTR_symmetric_difference, 26574, 20, "symmetric_difference")
  838. -QDEF1(MP_QSTR_symmetric_difference_update, 63584, 27, "symmetric_difference_update")
  839. -QDEF1(MP_QSTR_threshold, 12274, 9, "threshold")
  840. -QDEF1(MP_QSTR_ticks_add, 44701, 9, "ticks_add")
  841. -QDEF1(MP_QSTR_ticks_cpu, 42266, 9, "ticks_cpu")
  842. -QDEF1(MP_QSTR_ticks_diff, 57521, 10, "ticks_diff")
  843. -QDEF1(MP_QSTR_ticks_ms, 12866, 8, "ticks_ms")
  844. -QDEF1(MP_QSTR_ticks_us, 12634, 8, "ticks_us")
  845. -QDEF1(MP_QSTR_time, 49648, 4, "time")
  846. -QDEF1(MP_QSTR_time_ns, 45682, 7, "time_ns")
  847. -QDEF1(MP_QSTR_uniform, 62721, 7, "uniform")
  848. -QDEF1(MP_QSTR_union, 31990, 5, "union")
  849. -QDEF1(MP_QSTR_vibro_set, 11736, 9, "vibro_set")
  850. -QDEF1(MP_QSTR__brace_open__colon__hash_b_brace_close_, 14168, 5, "{:#b}")
  851. +QDEF0(MP_QSTR_rstrip, 59, 6, "rstrip")
  852. +QDEF0(MP_QSTR_self, 121, 4, "self")
  853. +QDEF0(MP_QSTR_send, 185, 4, "send")
  854. +QDEF0(MP_QSTR_sep, 35, 3, "sep")
  855. +QDEF0(MP_QSTR_set, 39, 3, "set")
  856. +QDEF0(MP_QSTR_setattr, 212, 7, "setattr")
  857. +QDEF0(MP_QSTR_setdefault, 108, 10, "setdefault")
  858. +QDEF0(MP_QSTR_sort, 191, 4, "sort")
  859. +QDEF0(MP_QSTR_sorted, 94, 6, "sorted")
  860. +QDEF0(MP_QSTR_split, 183, 5, "split")
  861. +QDEF0(MP_QSTR_start, 133, 5, "start")
  862. +QDEF0(MP_QSTR_startswith, 116, 10, "startswith")
  863. +QDEF0(MP_QSTR_staticmethod, 98, 12, "staticmethod")
  864. +QDEF0(MP_QSTR_step, 87, 4, "step")
  865. +QDEF0(MP_QSTR_stop, 157, 4, "stop")
  866. +QDEF0(MP_QSTR_str, 80, 3, "str")
  867. +QDEF0(MP_QSTR_strip, 41, 5, "strip")
  868. +QDEF0(MP_QSTR_sum, 46, 3, "sum")
  869. +QDEF0(MP_QSTR_super, 196, 5, "super")
  870. +QDEF0(MP_QSTR_throw, 179, 5, "throw")
  871. +QDEF0(MP_QSTR_to_bytes, 216, 8, "to_bytes")
  872. +QDEF0(MP_QSTR_tuple, 253, 5, "tuple")
  873. +QDEF0(MP_QSTR_type, 157, 4, "type")
  874. +QDEF0(MP_QSTR_update, 180, 6, "update")
  875. +QDEF0(MP_QSTR_upper, 39, 5, "upper")
  876. +QDEF0(MP_QSTR_utf_hyphen_8, 183, 5, "utf-8")
  877. +QDEF0(MP_QSTR_value, 78, 5, "value")
  878. +QDEF0(MP_QSTR_values, 125, 6, "values")
  879. +QDEF0(MP_QSTR_write, 152, 5, "write")
  880. +QDEF0(MP_QSTR_zip, 230, 3, "zip")
  881. +QDEF1(MP_QSTR__percent__hash_o, 108, 3, "%#o")
  882. +QDEF1(MP_QSTR__percent__hash_x, 123, 3, "%#x")
  883. +QDEF0(MP_QSTR__lt_dictcomp_gt_, 204, 10, "<dictcomp>")
  884. +QDEF0(MP_QSTR__lt_genexpr_gt_, 52, 9, "<genexpr>")
  885. +QDEF0(MP_QSTR__lt_lambda_gt_, 128, 8, "<lambda>")
  886. +QDEF0(MP_QSTR__lt_listcomp_gt_, 212, 10, "<listcomp>")
  887. +QDEF0(MP_QSTR__lt_setcomp_gt_, 84, 9, "<setcomp>")
  888. +QDEF1(MP_QSTR__lt_stdin_gt_, 227, 7, "<stdin>")
  889. +QDEF1(MP_QSTR__lt_string_gt_, 82, 8, "<string>")
  890. +QDEF1(MP_QSTR_CANVAS_ALIGN_BEGIN, 167, 18, "CANVAS_ALIGN_BEGIN")
  891. +QDEF1(MP_QSTR_CANVAS_ALIGN_CENTER, 235, 19, "CANVAS_ALIGN_CENTER")
  892. +QDEF1(MP_QSTR_CANVAS_ALIGN_END, 239, 16, "CANVAS_ALIGN_END")
  893. +QDEF1(MP_QSTR_CANVAS_BLACK, 213, 12, "CANVAS_BLACK")
  894. +QDEF1(MP_QSTR_CANVAS_FONT_PRIMARY, 242, 19, "CANVAS_FONT_PRIMARY")
  895. +QDEF1(MP_QSTR_CANVAS_FONT_SECONDARY, 4, 21, "CANVAS_FONT_SECONDARY")
  896. +QDEF1(MP_QSTR_CANVAS_WHITE, 53, 12, "CANVAS_WHITE")
  897. +QDEF1(MP_QSTR_INPUT_BUTTON_BACK, 174, 17, "INPUT_BUTTON_BACK")
  898. +QDEF1(MP_QSTR_INPUT_BUTTON_DOWN, 247, 17, "INPUT_BUTTON_DOWN")
  899. +QDEF1(MP_QSTR_INPUT_BUTTON_LEFT, 94, 17, "INPUT_BUTTON_LEFT")
  900. +QDEF1(MP_QSTR_INPUT_BUTTON_OK, 33, 15, "INPUT_BUTTON_OK")
  901. +QDEF1(MP_QSTR_INPUT_BUTTON_RIGHT, 5, 18, "INPUT_BUTTON_RIGHT")
  902. +QDEF1(MP_QSTR_INPUT_BUTTON_UP, 96, 15, "INPUT_BUTTON_UP")
  903. +QDEF1(MP_QSTR_INPUT_TYPE_LONG, 97, 15, "INPUT_TYPE_LONG")
  904. +QDEF1(MP_QSTR_INPUT_TYPE_PRESS, 108, 16, "INPUT_TYPE_PRESS")
  905. +QDEF1(MP_QSTR_INPUT_TYPE_RELEASE, 34, 18, "INPUT_TYPE_RELEASE")
  906. +QDEF1(MP_QSTR_INPUT_TYPE_REPEAT, 28, 17, "INPUT_TYPE_REPEAT")
  907. +QDEF1(MP_QSTR_INPUT_TYPE_SHORT, 153, 16, "INPUT_TYPE_SHORT")
  908. +QDEF1(MP_QSTR_LIGHT_BACKLIGHT, 17, 15, "LIGHT_BACKLIGHT")
  909. +QDEF1(MP_QSTR_LIGHT_BLUE, 90, 10, "LIGHT_BLUE")
  910. +QDEF1(MP_QSTR_LIGHT_GREEN, 95, 11, "LIGHT_GREEN")
  911. +QDEF1(MP_QSTR_LIGHT_RED, 215, 9, "LIGHT_RED")
  912. +QDEF0(MP_QSTR___add__, 196, 7, "__add__")
  913. +QDEF1(MP_QSTR___bases__, 3, 9, "__bases__")
  914. +QDEF0(MP_QSTR___bool__, 43, 8, "__bool__")
  915. +QDEF1(MP_QSTR___build_class__, 66, 15, "__build_class__")
  916. +QDEF0(MP_QSTR___contains__, 198, 12, "__contains__")
  917. +QDEF1(MP_QSTR___dict__, 127, 8, "__dict__")
  918. +QDEF0(MP_QSTR___eq__, 113, 6, "__eq__")
  919. +QDEF1(MP_QSTR___file__, 3, 8, "__file__")
  920. +QDEF0(MP_QSTR___float__, 53, 9, "__float__")
  921. +QDEF0(MP_QSTR___ge__, 167, 6, "__ge__")
  922. +QDEF1(MP_QSTR___globals__, 157, 11, "__globals__")
  923. +QDEF0(MP_QSTR___gt__, 182, 6, "__gt__")
  924. +QDEF0(MP_QSTR___iadd__, 109, 8, "__iadd__")
  925. +QDEF1(MP_QSTR___import__, 56, 10, "__import__")
  926. +QDEF0(MP_QSTR___isub__, 8, 8, "__isub__")
  927. +QDEF0(MP_QSTR___le__, 204, 6, "__le__")
  928. +QDEF0(MP_QSTR___lt__, 93, 6, "__lt__")
  929. +QDEF0(MP_QSTR___ne__, 14, 6, "__ne__")
  930. +QDEF1(MP_QSTR___path__, 200, 8, "__path__")
  931. +QDEF1(MP_QSTR___repl_print__, 1, 14, "__repl_print__")
  932. +QDEF1(MP_QSTR___reversed__, 97, 12, "__reversed__")
  933. +QDEF0(MP_QSTR___sub__, 33, 7, "__sub__")
  934. +QDEF1(MP_QSTR___traceback__, 79, 13, "__traceback__")
  935. +QDEF1(MP_QSTR__input_trigger_handler, 108, 22, "_input_trigger_handler")
  936. +QDEF1(MP_QSTR_add, 68, 3, "add")
  937. +QDEF1(MP_QSTR_array, 124, 5, "array")
  938. +QDEF1(MP_QSTR_bin, 224, 3, "bin")
  939. +QDEF1(MP_QSTR_bound_method, 151, 12, "bound_method")
  940. +QDEF1(MP_QSTR_canvas_clear, 107, 12, "canvas_clear")
  941. +QDEF1(MP_QSTR_canvas_draw_box, 56, 15, "canvas_draw_box")
  942. +QDEF1(MP_QSTR_canvas_draw_circle, 63, 18, "canvas_draw_circle")
  943. +QDEF1(MP_QSTR_canvas_draw_disc, 176, 16, "canvas_draw_disc")
  944. +QDEF1(MP_QSTR_canvas_draw_dot, 178, 15, "canvas_draw_dot")
  945. +QDEF1(MP_QSTR_canvas_draw_frame, 240, 17, "canvas_draw_frame")
  946. +QDEF1(MP_QSTR_canvas_draw_line, 67, 16, "canvas_draw_line")
  947. +QDEF1(MP_QSTR_canvas_height, 77, 13, "canvas_height")
  948. +QDEF1(MP_QSTR_canvas_set_color, 178, 16, "canvas_set_color")
  949. +QDEF1(MP_QSTR_canvas_set_font, 124, 15, "canvas_set_font")
  950. +QDEF1(MP_QSTR_canvas_set_text, 114, 15, "canvas_set_text")
  951. +QDEF1(MP_QSTR_canvas_set_text_align, 192, 21, "canvas_set_text_align")
  952. +QDEF1(MP_QSTR_canvas_text_height, 239, 18, "canvas_text_height")
  953. +QDEF1(MP_QSTR_canvas_text_width, 86, 17, "canvas_text_width")
  954. +QDEF1(MP_QSTR_canvas_update, 131, 13, "canvas_update")
  955. +QDEF1(MP_QSTR_canvas_width, 180, 12, "canvas_width")
  956. +QDEF1(MP_QSTR_choice, 46, 6, "choice")
  957. +QDEF1(MP_QSTR_closure, 116, 7, "closure")
  958. +QDEF1(MP_QSTR_collect, 155, 7, "collect")
  959. +QDEF1(MP_QSTR_decode, 169, 6, "decode")
  960. +QDEF1(MP_QSTR_default, 206, 7, "default")
  961. +QDEF1(MP_QSTR_delattr, 219, 7, "delattr")
  962. +QDEF1(MP_QSTR_deleter, 110, 7, "deleter")
  963. +QDEF1(MP_QSTR_dict_view, 45, 9, "dict_view")
  964. +QDEF1(MP_QSTR_difference, 114, 10, "difference")
  965. +QDEF1(MP_QSTR_difference_update, 156, 17, "difference_update")
  966. +QDEF1(MP_QSTR_disable, 145, 7, "disable")
  967. +QDEF1(MP_QSTR_discard, 15, 7, "discard")
  968. +QDEF1(MP_QSTR_doc, 45, 3, "doc")
  969. +QDEF1(MP_QSTR_enable, 4, 6, "enable")
  970. +QDEF1(MP_QSTR_encode, 67, 6, "encode")
  971. +QDEF1(MP_QSTR_enumerate, 113, 9, "enumerate")
  972. +QDEF1(MP_QSTR_errno, 193, 5, "errno")
  973. +QDEF1(MP_QSTR_filter, 37, 6, "filter")
  974. +QDEF1(MP_QSTR_flipperzero, 179, 11, "flipperzero")
  975. +QDEF1(MP_QSTR_float, 53, 5, "float")
  976. +QDEF1(MP_QSTR_fromkeys, 55, 8, "fromkeys")
  977. +QDEF1(MP_QSTR_function, 39, 8, "function")
  978. +QDEF1(MP_QSTR_gc, 97, 2, "gc")
  979. +QDEF1(MP_QSTR_generator, 150, 9, "generator")
  980. +QDEF1(MP_QSTR_getrandbits, 102, 11, "getrandbits")
  981. +QDEF1(MP_QSTR_getter, 144, 6, "getter")
  982. +QDEF1(MP_QSTR_heap_lock, 173, 9, "heap_lock")
  983. +QDEF1(MP_QSTR_heap_unlock, 86, 11, "heap_unlock")
  984. +QDEF1(MP_QSTR_hex, 112, 3, "hex")
  985. +QDEF1(MP_QSTR_intersection, 40, 12, "intersection")
  986. +QDEF1(MP_QSTR_intersection_update, 6, 19, "intersection_update")
  987. +QDEF1(MP_QSTR_isdisjoint, 247, 10, "isdisjoint")
  988. +QDEF1(MP_QSTR_isenabled, 154, 9, "isenabled")
  989. +QDEF1(MP_QSTR_issubset, 185, 8, "issubset")
  990. +QDEF1(MP_QSTR_issuperset, 252, 10, "issuperset")
  991. +QDEF1(MP_QSTR_iterable, 37, 8, "iterable")
  992. +QDEF1(MP_QSTR_iterator, 71, 8, "iterator")
  993. +QDEF1(MP_QSTR_light_blink_set_color, 217, 21, "light_blink_set_color")
  994. +QDEF1(MP_QSTR_light_blink_start, 121, 17, "light_blink_start")
  995. +QDEF1(MP_QSTR_light_blink_stop, 33, 16, "light_blink_stop")
  996. +QDEF1(MP_QSTR_light_set, 134, 9, "light_set")
  997. +QDEF1(MP_QSTR_max, 177, 3, "max")
  998. +QDEF1(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, 115, 32, "maximum recursion depth exceeded")
  999. +QDEF1(MP_QSTR_mem_alloc, 82, 9, "mem_alloc")
  1000. +QDEF1(MP_QSTR_mem_free, 203, 8, "mem_free")
  1001. +QDEF1(MP_QSTR_min, 175, 3, "min")
  1002. +QDEF1(MP_QSTR_module, 191, 6, "module")
  1003. +QDEF1(MP_QSTR_oct, 253, 3, "oct")
  1004. +QDEF1(MP_QSTR_on_input, 141, 8, "on_input")
  1005. +QDEF1(MP_QSTR_opt_level, 135, 9, "opt_level")
  1006. +QDEF1(MP_QSTR_property, 194, 8, "property")
  1007. +QDEF1(MP_QSTR_randint, 175, 7, "randint")
  1008. +QDEF1(MP_QSTR_random, 190, 6, "random")
  1009. +QDEF1(MP_QSTR_randrange, 163, 9, "randrange")
  1010. +QDEF1(MP_QSTR_rb, 213, 2, "rb")
  1011. +QDEF1(MP_QSTR_reversed, 161, 8, "reversed")
  1012. +QDEF1(MP_QSTR_schedule, 224, 8, "schedule")
  1013. +QDEF1(MP_QSTR_seed, 146, 4, "seed")
  1014. +QDEF1(MP_QSTR_setter, 4, 6, "setter")
  1015. +QDEF1(MP_QSTR_sleep, 234, 5, "sleep")
  1016. +QDEF1(MP_QSTR_sleep_ms, 11, 8, "sleep_ms")
  1017. +QDEF1(MP_QSTR_sleep_us, 19, 8, "sleep_us")
  1018. +QDEF1(MP_QSTR_slice, 181, 5, "slice")
  1019. +QDEF1(MP_QSTR_speaker_set_volume, 116, 18, "speaker_set_volume")
  1020. +QDEF1(MP_QSTR_speaker_start, 1, 13, "speaker_start")
  1021. +QDEF1(MP_QSTR_speaker_stop, 153, 12, "speaker_stop")
  1022. +QDEF1(MP_QSTR_symmetric_difference, 206, 20, "symmetric_difference")
  1023. +QDEF1(MP_QSTR_symmetric_difference_update, 96, 27, "symmetric_difference_update")
  1024. +QDEF1(MP_QSTR_threshold, 242, 9, "threshold")
  1025. +QDEF1(MP_QSTR_ticks_add, 157, 9, "ticks_add")
  1026. +QDEF1(MP_QSTR_ticks_cpu, 26, 9, "ticks_cpu")
  1027. +QDEF1(MP_QSTR_ticks_diff, 177, 10, "ticks_diff")
  1028. +QDEF1(MP_QSTR_ticks_ms, 66, 8, "ticks_ms")
  1029. +QDEF1(MP_QSTR_ticks_us, 90, 8, "ticks_us")
  1030. +QDEF1(MP_QSTR_time, 240, 4, "time")
  1031. +QDEF1(MP_QSTR_time_ns, 114, 7, "time_ns")
  1032. +QDEF1(MP_QSTR_uniform, 1, 7, "uniform")
  1033. +QDEF1(MP_QSTR_union, 246, 5, "union")
  1034. +QDEF1(MP_QSTR_vibro_set, 216, 9, "vibro_set")
  1035. +QDEF1(MP_QSTR__brace_open__colon__hash_b_brace_close_, 88, 5, "{:#b}")
  1036. diff --git a/py/asmarm.c b/py/asmarm.c
  1037. index 42724e4d4..600649070 100644
  1038. --- a/py/asmarm.c
  1039. +++ b/py/asmarm.c
  1040. @@ -39,7 +39,7 @@
  1041. #define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000)
  1042. // Insert word into instruction flow
  1043. -STATIC void emit(asm_arm_t *as, uint op) {
  1044. +static void emit(asm_arm_t *as, uint op) {
  1045. uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
  1046. if (c != NULL) {
  1047. *(uint32_t *)c = op;
  1048. @@ -47,73 +47,83 @@ STATIC void emit(asm_arm_t *as, uint op) {
  1049. }
  1050. // Insert word into instruction flow, add "ALWAYS" condition code
  1051. -STATIC void emit_al(asm_arm_t *as, uint op) {
  1052. +static void emit_al(asm_arm_t *as, uint op) {
  1053. emit(as, op | ASM_ARM_CC_AL);
  1054. }
  1055. // Basic instructions without condition code
  1056. -STATIC uint asm_arm_op_push(uint reglist) {
  1057. +static uint asm_arm_op_push(uint reglist) {
  1058. // stmfd sp!, {reglist}
  1059. return 0x92d0000 | (reglist & 0xFFFF);
  1060. }
  1061. -STATIC uint asm_arm_op_pop(uint reglist) {
  1062. +static uint asm_arm_op_pop(uint reglist) {
  1063. // ldmfd sp!, {reglist}
  1064. return 0x8bd0000 | (reglist & 0xFFFF);
  1065. }
  1066. -STATIC uint asm_arm_op_mov_reg(uint rd, uint rn) {
  1067. +static uint asm_arm_op_mov_reg(uint rd, uint rn) {
  1068. // mov rd, rn
  1069. return 0x1a00000 | (rd << 12) | rn;
  1070. }
  1071. -STATIC uint asm_arm_op_mov_imm(uint rd, uint imm) {
  1072. +static uint asm_arm_op_mov_imm(uint rd, uint imm) {
  1073. // mov rd, #imm
  1074. return 0x3a00000 | (rd << 12) | imm;
  1075. }
  1076. -STATIC uint asm_arm_op_mvn_imm(uint rd, uint imm) {
  1077. +static uint asm_arm_op_mvn_imm(uint rd, uint imm) {
  1078. // mvn rd, #imm
  1079. return 0x3e00000 | (rd << 12) | imm;
  1080. }
  1081. -STATIC uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) {
  1082. +static uint asm_arm_op_mvn_reg(uint rd, uint rm) {
  1083. + // mvn rd, rm
  1084. + return 0x1e00000 | (rd << 12) | rm;
  1085. +}
  1086. +
  1087. +static uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) {
  1088. // add rd, rn, #imm
  1089. return 0x2800000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
  1090. }
  1091. -STATIC uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) {
  1092. +static uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) {
  1093. // add rd, rn, rm
  1094. return 0x0800000 | (rn << 16) | (rd << 12) | rm;
  1095. }
  1096. -STATIC uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) {
  1097. +static uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) {
  1098. // sub rd, rn, #imm
  1099. return 0x2400000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
  1100. }
  1101. -STATIC uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) {
  1102. +static uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) {
  1103. // sub rd, rn, rm
  1104. return 0x0400000 | (rn << 16) | (rd << 12) | rm;
  1105. }
  1106. -STATIC uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) {
  1107. +static uint asm_arm_op_rsb_imm(uint rd, uint rn, uint imm) {
  1108. + // rsb rd, rn, #imm
  1109. + return 0x2600000 | (rn << 16) | (rd << 12) | (imm & 0xFF);
  1110. +}
  1111. +
  1112. +static uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) {
  1113. // mul rd, rm, rs
  1114. assert(rd != rm);
  1115. return 0x0000090 | (rd << 16) | (rs << 8) | rm;
  1116. }
  1117. -STATIC uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) {
  1118. +static uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) {
  1119. // and rd, rn, rm
  1120. return 0x0000000 | (rn << 16) | (rd << 12) | rm;
  1121. }
  1122. -STATIC uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) {
  1123. +static uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) {
  1124. // eor rd, rn, rm
  1125. return 0x0200000 | (rn << 16) | (rd << 12) | rm;
  1126. }
  1127. -STATIC uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) {
  1128. +static uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) {
  1129. // orr rd, rn, rm
  1130. return 0x1800000 | (rn << 16) | (rd << 12) | rm;
  1131. }
  1132. @@ -228,11 +238,23 @@ void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond) {
  1133. emit(as, asm_arm_op_mov_imm(rd, 0) | (cond ^ (1 << 28))); // mov!COND rd, #0
  1134. }
  1135. +void asm_arm_mvn_reg_reg(asm_arm_t *as, uint rd, uint rm) {
  1136. + // mvn rd, rm
  1137. + // computes: rd := ~rm
  1138. + emit_al(as, asm_arm_op_mvn_reg(rd, rm));
  1139. +}
  1140. +
  1141. void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
  1142. // add rd, rn, rm
  1143. emit_al(as, asm_arm_op_add_reg(rd, rn, rm));
  1144. }
  1145. +void asm_arm_rsb_reg_reg_imm(asm_arm_t *as, uint rd, uint rn, uint imm) {
  1146. + // rsb rd, rn, #imm
  1147. + // computes: rd := #imm - rn
  1148. + emit_al(as, asm_arm_op_rsb_imm(rd, rn, imm));
  1149. +}
  1150. +
  1151. void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
  1152. // sub rd, rn, rm
  1153. emit_al(as, asm_arm_op_sub_reg(rd, rn, rm));
  1154. diff --git a/py/asmarm.h b/py/asmarm.h
  1155. index 81c3f7b1c..4a4253aef 100644
  1156. --- a/py/asmarm.h
  1157. +++ b/py/asmarm.h
  1158. @@ -94,8 +94,10 @@ void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm);
  1159. void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn);
  1160. // arithmetic
  1161. +void asm_arm_mvn_reg_reg(asm_arm_t *as, uint rd, uint rm);
  1162. void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
  1163. void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
  1164. +void asm_arm_rsb_reg_reg_imm(asm_arm_t *as, uint rd, uint rn, uint imm);
  1165. void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
  1166. void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
  1167. void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm);
  1168. @@ -188,6 +190,8 @@ void asm_arm_bx_reg(asm_arm_t *as, uint reg_src);
  1169. #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_arm_mov_reg_local_addr((as), (reg_dest), (local_num))
  1170. #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_arm_mov_reg_pcrel((as), (reg_dest), (label))
  1171. +#define ASM_NOT_REG(as, reg_dest) asm_arm_mvn_reg_reg((as), (reg_dest), (reg_dest))
  1172. +#define ASM_NEG_REG(as, reg_dest) asm_arm_rsb_reg_reg_imm((as), (reg_dest), (reg_dest), 0)
  1173. #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_arm_lsl_reg_reg((as), (reg_dest), (reg_shift))
  1174. #define ASM_LSR_REG_REG(as, reg_dest, reg_shift) asm_arm_lsr_reg_reg((as), (reg_dest), (reg_shift))
  1175. #define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_arm_asr_reg_reg((as), (reg_dest), (reg_shift))
  1176. diff --git a/py/asmthumb.c b/py/asmthumb.c
  1177. index 395134028..0df79e5fd 100644
  1178. --- a/py/asmthumb.c
  1179. +++ b/py/asmthumb.c
  1180. @@ -79,7 +79,7 @@ static inline byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, int n) {
  1181. }
  1182. /*
  1183. -STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
  1184. +static void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
  1185. byte *c = asm_thumb_get_cur_to_write_bytes(as, 1);
  1186. c[0] = b1;
  1187. }
  1188. @@ -91,7 +91,7 @@ STATIC void asm_thumb_write_byte_1(asm_thumb_t *as, byte b1) {
  1189. #define IMM32_L2(x) (((x) >> 16) & 0xff)
  1190. #define IMM32_L3(x) (((x) >> 24) & 0xff)
  1191. -STATIC void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
  1192. +static void asm_thumb_write_word32(asm_thumb_t *as, int w32) {
  1193. byte *c = asm_thumb_get_cur_to_write_bytes(as, 4);
  1194. c[0] = IMM32_L0(w32);
  1195. c[1] = IMM32_L1(w32);
  1196. @@ -216,7 +216,7 @@ void asm_thumb_exit(asm_thumb_t *as) {
  1197. asm_thumb_op16(as, OP_POP_RLIST_PC(as->push_reglist));
  1198. }
  1199. -STATIC mp_uint_t get_label_dest(asm_thumb_t *as, uint label) {
  1200. +static mp_uint_t get_label_dest(asm_thumb_t *as, uint label) {
  1201. assert(label < as->base.max_num_labels);
  1202. return as->base.label_offsets[label];
  1203. }
  1204. diff --git a/py/asmthumb.h b/py/asmthumb.h
  1205. index 2829ac4c7..a9e68d7ad 100644
  1206. --- a/py/asmthumb.h
  1207. +++ b/py/asmthumb.h
  1208. @@ -406,6 +406,8 @@ void asm_thumb_b_rel12(asm_thumb_t *as, int rel);
  1209. #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_thumb_mov_reg_local_addr((as), (reg_dest), (local_num))
  1210. #define ASM_MOV_REG_PCREL(as, rlo_dest, label) asm_thumb_mov_reg_pcrel((as), (rlo_dest), (label))
  1211. +#define ASM_NOT_REG(as, reg_dest) asm_thumb_mvn_rlo_rlo((as), (reg_dest), (reg_dest))
  1212. +#define ASM_NEG_REG(as, reg_dest) asm_thumb_neg_rlo_rlo((as), (reg_dest), (reg_dest))
  1213. #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSL, (reg_dest), (reg_shift))
  1214. #define ASM_LSR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_LSR, (reg_dest), (reg_shift))
  1215. #define ASM_ASR_REG_REG(as, reg_dest, reg_shift) asm_thumb_format_4((as), ASM_THUMB_FORMAT_4_ASR, (reg_dest), (reg_shift))
  1216. diff --git a/py/asmx64.c b/py/asmx64.c
  1217. index 5c923a523..d9f33cfb2 100644
  1218. --- a/py/asmx64.c
  1219. +++ b/py/asmx64.c
  1220. @@ -54,6 +54,8 @@
  1221. #define OPCODE_MOVZX_RM8_TO_R64 (0xb6) /* 0x0f 0xb6/r */
  1222. #define OPCODE_MOVZX_RM16_TO_R64 (0xb7) /* 0x0f 0xb7/r */
  1223. #define OPCODE_LEA_MEM_TO_R64 (0x8d) /* /r */
  1224. +#define OPCODE_NOT_RM64 (0xf7) /* /2 */
  1225. +#define OPCODE_NEG_RM64 (0xf7) /* /3 */
  1226. #define OPCODE_AND_R64_TO_RM64 (0x21) /* /r */
  1227. #define OPCODE_OR_R64_TO_RM64 (0x09) /* /r */
  1228. #define OPCODE_XOR_R64_TO_RM64 (0x31) /* /r */
  1229. @@ -123,14 +125,14 @@ static inline byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int n) {
  1230. return mp_asm_base_get_cur_to_write_bytes(&as->base, n);
  1231. }
  1232. -STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
  1233. +static void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
  1234. byte *c = asm_x64_get_cur_to_write_bytes(as, 1);
  1235. if (c != NULL) {
  1236. c[0] = b1;
  1237. }
  1238. }
  1239. -STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
  1240. +static void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
  1241. byte *c = asm_x64_get_cur_to_write_bytes(as, 2);
  1242. if (c != NULL) {
  1243. c[0] = b1;
  1244. @@ -138,7 +140,7 @@ STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
  1245. }
  1246. }
  1247. -STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
  1248. +static void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
  1249. byte *c = asm_x64_get_cur_to_write_bytes(as, 3);
  1250. if (c != NULL) {
  1251. c[0] = b1;
  1252. @@ -147,7 +149,7 @@ STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
  1253. }
  1254. }
  1255. -STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
  1256. +static void asm_x64_write_word32(asm_x64_t *as, int w32) {
  1257. byte *c = asm_x64_get_cur_to_write_bytes(as, 4);
  1258. if (c != NULL) {
  1259. c[0] = IMM32_L0(w32);
  1260. @@ -157,7 +159,7 @@ STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
  1261. }
  1262. }
  1263. -STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
  1264. +static void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
  1265. byte *c = asm_x64_get_cur_to_write_bytes(as, 8);
  1266. if (c != NULL) {
  1267. c[0] = IMM32_L0(w64);
  1268. @@ -172,7 +174,7 @@ STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
  1269. }
  1270. /* unused
  1271. -STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
  1272. +static void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
  1273. byte* c;
  1274. assert(offset + 4 <= as->code_size);
  1275. c = as->code_base + offset;
  1276. @@ -183,7 +185,7 @@ STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
  1277. }
  1278. */
  1279. -STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
  1280. +static void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int disp_offset) {
  1281. uint8_t rm_disp;
  1282. if (disp_offset == 0 && (disp_r64 & 7) != ASM_X64_REG_RBP) {
  1283. rm_disp = MODRM_RM_DISP0;
  1284. @@ -204,7 +206,7 @@ STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64, int dis
  1285. }
  1286. }
  1287. -STATIC void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) {
  1288. +static void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src_r64, int op) {
  1289. 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));
  1290. }
  1291. @@ -243,7 +245,7 @@ void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) {
  1292. }
  1293. }
  1294. -STATIC void asm_x64_ret(asm_x64_t *as) {
  1295. +static void asm_x64_ret(asm_x64_t *as) {
  1296. asm_x64_write_byte_1(as, OPCODE_RET);
  1297. }
  1298. @@ -317,7 +319,7 @@ void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest
  1299. asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
  1300. }
  1301. -STATIC void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
  1302. +static void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64) {
  1303. // use REX prefix for 64 bit operation
  1304. 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);
  1305. asm_x64_write_r64_disp(as, dest_r64, src_r64, src_disp);
  1306. @@ -362,6 +364,14 @@ void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r
  1307. }
  1308. }
  1309. +void asm_x64_not_r64(asm_x64_t *as, int dest_r64) {
  1310. + asm_x64_generic_r64_r64(as, dest_r64, 2, OPCODE_NOT_RM64);
  1311. +}
  1312. +
  1313. +void asm_x64_neg_r64(asm_x64_t *as, int dest_r64) {
  1314. + asm_x64_generic_r64_r64(as, dest_r64, 3, OPCODE_NEG_RM64);
  1315. +}
  1316. +
  1317. void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
  1318. asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_AND_R64_TO_RM64);
  1319. }
  1320. @@ -414,7 +424,7 @@ void asm_x64_sub_i32_from_r32(asm_x64_t *as, int src_i32, int dest_r32) {
  1321. }
  1322. */
  1323. -STATIC void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) {
  1324. +static void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) {
  1325. assert(dest_r64 < 8);
  1326. if (SIGNED_FIT8(src_i32)) {
  1327. // use REX prefix for 64 bit operation
  1328. @@ -480,7 +490,7 @@ void asm_x64_jmp_reg(asm_x64_t *as, int src_r64) {
  1329. asm_x64_write_byte_2(as, OPCODE_JMP_RM64, MODRM_R64(4) | MODRM_RM_REG | MODRM_RM_R64(src_r64));
  1330. }
  1331. -STATIC mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) {
  1332. +static mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) {
  1333. assert(label < as->base.max_num_labels);
  1334. return as->base.label_offsets[label];
  1335. }
  1336. @@ -560,7 +570,7 @@ void asm_x64_exit(asm_x64_t *as) {
  1337. // ^ ^
  1338. // | low address | high address in RAM
  1339. //
  1340. -STATIC int asm_x64_local_offset_from_rsp(asm_x64_t *as, int local_num) {
  1341. +static int asm_x64_local_offset_from_rsp(asm_x64_t *as, int local_num) {
  1342. (void)as;
  1343. // Stack is full descending, RSP points to local0
  1344. return local_num * WORD_SIZE;
  1345. diff --git a/py/asmx64.h b/py/asmx64.h
  1346. index a8efc2bf6..c63e31797 100644
  1347. --- a/py/asmx64.h
  1348. +++ b/py/asmx64.h
  1349. @@ -97,6 +97,8 @@ void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int des
  1350. void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
  1351. void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
  1352. void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, int dest_r64);
  1353. +void asm_x64_not_r64(asm_x64_t *as, int dest_r64);
  1354. +void asm_x64_neg_r64(asm_x64_t *as, int dest_r64);
  1355. void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
  1356. void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
  1357. void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
  1358. @@ -191,6 +193,8 @@ void asm_x64_call_ind(asm_x64_t *as, size_t fun_id, int temp_r32);
  1359. #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_x64_mov_local_addr_to_r64((as), (local_num), (reg_dest))
  1360. #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_x64_mov_reg_pcrel((as), (reg_dest), (label))
  1361. +#define ASM_NOT_REG(as, reg) asm_x64_not_r64((as), (reg))
  1362. +#define ASM_NEG_REG(as, reg) asm_x64_neg_r64((as), (reg))
  1363. #define ASM_LSL_REG(as, reg) asm_x64_shl_r64_cl((as), (reg))
  1364. #define ASM_LSR_REG(as, reg) asm_x64_shr_r64_cl((as), (reg))
  1365. #define ASM_ASR_REG(as, reg) asm_x64_sar_r64_cl((as), (reg))
  1366. diff --git a/py/asmx86.c b/py/asmx86.c
  1367. index 4b0f8047f..4acac1b46 100644
  1368. --- a/py/asmx86.c
  1369. +++ b/py/asmx86.c
  1370. @@ -54,6 +54,8 @@
  1371. #define OPCODE_MOVZX_RM8_TO_R32 (0xb6) /* 0x0f 0xb6/r */
  1372. #define OPCODE_MOVZX_RM16_TO_R32 (0xb7) /* 0x0f 0xb7/r */
  1373. #define OPCODE_LEA_MEM_TO_R32 (0x8d) /* /r */
  1374. +#define OPCODE_NOT_RM32 (0xf7) /* /2 */
  1375. +#define OPCODE_NEG_RM32 (0xf7) /* /3 */
  1376. #define OPCODE_AND_R32_TO_RM32 (0x21) /* /r */
  1377. #define OPCODE_OR_R32_TO_RM32 (0x09) /* /r */
  1378. #define OPCODE_XOR_R32_TO_RM32 (0x31) /* /r */
  1379. @@ -103,14 +105,14 @@
  1380. #define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)
  1381. -STATIC void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
  1382. +static void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
  1383. byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 1);
  1384. if (c != NULL) {
  1385. c[0] = b1;
  1386. }
  1387. }
  1388. -STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
  1389. +static void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
  1390. byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2);
  1391. if (c != NULL) {
  1392. c[0] = b1;
  1393. @@ -118,7 +120,7 @@ STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
  1394. }
  1395. }
  1396. -STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
  1397. +static void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
  1398. byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3);
  1399. if (c != NULL) {
  1400. c[0] = b1;
  1401. @@ -127,7 +129,7 @@ STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
  1402. }
  1403. }
  1404. -STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) {
  1405. +static void asm_x86_write_word32(asm_x86_t *as, int w32) {
  1406. byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
  1407. if (c != NULL) {
  1408. c[0] = IMM32_L0(w32);
  1409. @@ -137,7 +139,7 @@ STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) {
  1410. }
  1411. }
  1412. -STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) {
  1413. +static void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int disp_offset) {
  1414. uint8_t rm_disp;
  1415. if (disp_offset == 0 && disp_r32 != ASM_X86_REG_EBP) {
  1416. rm_disp = MODRM_RM_DISP0;
  1417. @@ -158,17 +160,17 @@ STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32, int dis
  1418. }
  1419. }
  1420. -STATIC void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) {
  1421. +static void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src_r32, int op) {
  1422. asm_x86_write_byte_2(as, op, MODRM_R32(src_r32) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
  1423. }
  1424. #if 0
  1425. -STATIC void asm_x86_nop(asm_x86_t *as) {
  1426. +static void asm_x86_nop(asm_x86_t *as) {
  1427. asm_x86_write_byte_1(as, OPCODE_NOP);
  1428. }
  1429. #endif
  1430. -STATIC void asm_x86_push_r32(asm_x86_t *as, int src_r32) {
  1431. +static void asm_x86_push_r32(asm_x86_t *as, int src_r32) {
  1432. asm_x86_write_byte_1(as, OPCODE_PUSH_R32 | src_r32);
  1433. }
  1434. @@ -184,11 +186,11 @@ void asm_x86_push_disp(asm_x86_t *as, int src_r32, int src_offset) {
  1435. }
  1436. #endif
  1437. -STATIC void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) {
  1438. +static void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) {
  1439. asm_x86_write_byte_1(as, OPCODE_POP_R32 | dest_r32);
  1440. }
  1441. -STATIC void asm_x86_ret(asm_x86_t *as) {
  1442. +static void asm_x86_ret(asm_x86_t *as) {
  1443. asm_x86_write_byte_1(as, OPCODE_RET);
  1444. }
  1445. @@ -226,7 +228,7 @@ void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest
  1446. asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp);
  1447. }
  1448. -STATIC void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) {
  1449. +static void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32) {
  1450. asm_x86_write_byte_1(as, OPCODE_LEA_MEM_TO_R32);
  1451. asm_x86_write_r32_disp(as, dest_r32, src_r32, src_disp);
  1452. }
  1453. @@ -244,6 +246,14 @@ size_t asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32) {
  1454. return loc;
  1455. }
  1456. +void asm_x86_not_r32(asm_x86_t *as, int dest_r32) {
  1457. + asm_x86_generic_r32_r32(as, dest_r32, 2, OPCODE_NOT_RM32);
  1458. +}
  1459. +
  1460. +void asm_x86_neg_r32(asm_x86_t *as, int dest_r32) {
  1461. + asm_x86_generic_r32_r32(as, dest_r32, 3, OPCODE_NEG_RM32);
  1462. +}
  1463. +
  1464. void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
  1465. asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_AND_R32_TO_RM32);
  1466. }
  1467. @@ -272,7 +282,7 @@ void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
  1468. asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_ADD_R32_TO_RM32);
  1469. }
  1470. -STATIC void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) {
  1471. +static void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_r32) {
  1472. if (SIGNED_FIT8(src_i32)) {
  1473. asm_x86_write_byte_2(as, OPCODE_ADD_I8_TO_RM32, MODRM_R32(0) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
  1474. asm_x86_write_byte_1(as, src_i32 & 0xff);
  1475. @@ -286,7 +296,7 @@ void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
  1476. asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_SUB_R32_FROM_RM32);
  1477. }
  1478. -STATIC void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) {
  1479. +static void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) {
  1480. if (SIGNED_FIT8(src_i32)) {
  1481. // defaults to 32 bit operation
  1482. asm_x86_write_byte_2(as, OPCODE_SUB_I8_FROM_RM32, MODRM_R32(5) | MODRM_RM_REG | MODRM_RM_R32(dest_r32));
  1483. @@ -353,7 +363,7 @@ void asm_x86_jmp_reg(asm_x86_t *as, int src_r32) {
  1484. asm_x86_write_byte_2(as, OPCODE_JMP_RM32, MODRM_R32(4) | MODRM_RM_REG | MODRM_RM_R32(src_r32));
  1485. }
  1486. -STATIC mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) {
  1487. +static mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) {
  1488. assert(label < as->base.max_num_labels);
  1489. return as->base.label_offsets[label];
  1490. }
  1491. @@ -422,7 +432,7 @@ void asm_x86_exit(asm_x86_t *as) {
  1492. asm_x86_ret(as);
  1493. }
  1494. -STATIC int asm_x86_arg_offset_from_esp(asm_x86_t *as, size_t arg_num) {
  1495. +static int asm_x86_arg_offset_from_esp(asm_x86_t *as, size_t arg_num) {
  1496. // Above esp are: locals, 4 saved registers, return eip, arguments
  1497. return (as->num_locals + 4 + 1 + arg_num) * WORD_SIZE;
  1498. }
  1499. @@ -454,7 +464,7 @@ void asm_x86_mov_r32_to_arg(asm_x86_t *as, int src_r32, int dest_arg_num) {
  1500. // ^ ^
  1501. // | low address | high address in RAM
  1502. //
  1503. -STATIC int asm_x86_local_offset_from_esp(asm_x86_t *as, int local_num) {
  1504. +static int asm_x86_local_offset_from_esp(asm_x86_t *as, int local_num) {
  1505. (void)as;
  1506. // Stack is full descending, ESP points to local0
  1507. return local_num * WORD_SIZE;
  1508. diff --git a/py/asmx86.h b/py/asmx86.h
  1509. index ac98643a6..027d44151 100644
  1510. --- a/py/asmx86.h
  1511. +++ b/py/asmx86.h
  1512. @@ -92,6 +92,8 @@ void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, int dest
  1513. void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
  1514. void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
  1515. void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, int dest_r32);
  1516. +void asm_x86_not_r32(asm_x86_t *as, int dest_r32);
  1517. +void asm_x86_neg_r32(asm_x86_t *as, int dest_r32);
  1518. void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
  1519. void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
  1520. void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
  1521. @@ -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
  1522. #define ASM_MOV_REG_LOCAL_ADDR(as, reg_dest, local_num) asm_x86_mov_local_addr_to_r32((as), (local_num), (reg_dest))
  1523. #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_x86_mov_reg_pcrel((as), (reg_dest), (label))
  1524. +#define ASM_NOT_REG(as, reg) asm_x86_not_r32((as), (reg))
  1525. +#define ASM_NEG_REG(as, reg) asm_x86_neg_r32((as), (reg))
  1526. #define ASM_LSL_REG(as, reg) asm_x86_shl_r32_cl((as), (reg))
  1527. #define ASM_LSR_REG(as, reg) asm_x86_shr_r32_cl((as), (reg))
  1528. #define ASM_ASR_REG(as, reg) asm_x86_sar_r32_cl((as), (reg))
  1529. diff --git a/py/asmxtensa.c b/py/asmxtensa.c
  1530. index 8ac914ec4..0fbe351dc 100644
  1531. --- a/py/asmxtensa.c
  1532. +++ b/py/asmxtensa.c
  1533. @@ -117,7 +117,7 @@ void asm_xtensa_exit_win(asm_xtensa_t *as) {
  1534. asm_xtensa_op_retw_n(as);
  1535. }
  1536. -STATIC uint32_t get_label_dest(asm_xtensa_t *as, uint label) {
  1537. +static uint32_t get_label_dest(asm_xtensa_t *as, uint label) {
  1538. assert(label < as->base.max_num_labels);
  1539. return as->base.label_offsets[label];
  1540. }
  1541. @@ -185,7 +185,9 @@ size_t asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
  1542. }
  1543. void asm_xtensa_mov_reg_i32_optimised(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
  1544. - if (SIGNED_FIT12(i32)) {
  1545. + if (-32 <= (int)i32 && (int)i32 <= 95) {
  1546. + asm_xtensa_op_movi_n(as, reg_dest, i32);
  1547. + } else if (SIGNED_FIT12(i32)) {
  1548. asm_xtensa_op_movi(as, reg_dest, i32);
  1549. } else {
  1550. asm_xtensa_mov_reg_i32(as, reg_dest, i32);
  1551. diff --git a/py/asmxtensa.h b/py/asmxtensa.h
  1552. index 5bd6426a1..f226624a8 100644
  1553. --- a/py/asmxtensa.h
  1554. +++ b/py/asmxtensa.h
  1555. @@ -203,14 +203,19 @@ static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t i
  1556. asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 10, (imm12 >> 8) & 0xf, reg_dest, imm12 & 0xff));
  1557. }
  1558. -static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) {
  1559. - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm4));
  1560. +// Argument must be in the range (-32 .. 95) inclusive.
  1561. +static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm7) {
  1562. + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm7));
  1563. }
  1564. static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) {
  1565. asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 2, 8, reg_dest, reg_src_a, reg_src_b));
  1566. }
  1567. +static inline void asm_xtensa_op_neg(asm_xtensa_t *as, uint reg_dest, uint reg_src) {
  1568. + asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 6, reg_dest, 0, reg_src));
  1569. +}
  1570. +
  1571. static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) {
  1572. asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRR(0, 0, 2, reg_dest, reg_src_a, reg_src_b));
  1573. }
  1574. @@ -371,6 +376,7 @@ void asm_xtensa_call_ind_win(asm_xtensa_t *as, uint idx);
  1575. #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))
  1576. #define ASM_MOV_REG_PCREL(as, reg_dest, label) asm_xtensa_mov_reg_pcrel((as), (reg_dest), (label))
  1577. +#define ASM_NEG_REG(as, reg_dest) asm_xtensa_op_neg((as), (reg_dest), (reg_dest))
  1578. #define ASM_LSL_REG_REG(as, reg_dest, reg_shift) \
  1579. do { \
  1580. asm_xtensa_op_ssl((as), (reg_shift)); \
  1581. diff --git a/py/bc.c b/py/bc.c
  1582. index e1795ce41..899dbd6a0 100644
  1583. --- a/py/bc.c
  1584. +++ b/py/bc.c
  1585. @@ -88,7 +88,7 @@ const byte *mp_decode_uint_skip(const byte *ptr) {
  1586. return ptr;
  1587. }
  1588. -STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
  1589. +static NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
  1590. #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
  1591. // generic message, used also for other argument issues
  1592. (void)f;
  1593. @@ -107,7 +107,7 @@ STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected,
  1594. }
  1595. #if DEBUG_PRINT
  1596. -STATIC void dump_args(const mp_obj_t *a, size_t sz) {
  1597. +static void dump_args(const mp_obj_t *a, size_t sz) {
  1598. DEBUG_printf("%p: ", a);
  1599. for (size_t i = 0; i < sz; i++) {
  1600. DEBUG_printf("%p ", a[i]);
  1601. @@ -124,7 +124,7 @@ STATIC void dump_args(const mp_obj_t *a, size_t sz) {
  1602. // - code_state->ip should contain a pointer to the beginning of the prelude
  1603. // - code_state->sp should be: &code_state->state[0] - 1
  1604. // - code_state->n_state should be the number of objects in the local state
  1605. -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) {
  1606. +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) {
  1607. // This function is pretty complicated. It's main aim is to be efficient in speed and RAM
  1608. // usage for the common case of positional only args.
  1609. @@ -336,9 +336,9 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
  1610. // On entry code_state should be allocated somewhere (stack/heap) and
  1611. // contain the following valid entries:
  1612. // - code_state->fun_bc should contain a pointer to the function object
  1613. -// - code_state->ip should contain a pointer to the beginning of the prelude
  1614. // - code_state->n_state should be the number of objects in the local state
  1615. 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) {
  1616. + code_state->ip = mp_obj_fun_native_get_prelude_ptr(code_state->fun_bc);
  1617. code_state->sp = &code_state->state[0] - 1;
  1618. mp_setup_code_state_helper((mp_code_state_t *)code_state, n_args, n_kw, args);
  1619. }
  1620. diff --git a/py/bc.h b/py/bc.h
  1621. index 0e23255f7..718ba4a68 100644
  1622. --- a/py/bc.h
  1623. +++ b/py/bc.h
  1624. @@ -44,11 +44,11 @@
  1625. // prelude size : var uint
  1626. // contains two values interleaved bit-wise as: xIIIIIIC repeated
  1627. // x = extension another byte follows
  1628. -// I = n_info number of bytes in source info section
  1629. +// I = n_info number of bytes in source info section (always > 0)
  1630. // C = n_cells number of bytes/cells in closure section
  1631. //
  1632. // source info section:
  1633. -// simple_name : var qstr
  1634. +// simple_name : var qstr always exists
  1635. // argname0 : var qstr
  1636. // ... : var qstr
  1637. // argnameN : var qstr N = num_pos_args + num_kwonly_args - 1
  1638. @@ -226,7 +226,7 @@ typedef struct _mp_compiled_module_t {
  1639. // Outer level struct defining a frozen module.
  1640. typedef struct _mp_frozen_module_t {
  1641. const mp_module_constants_t constants;
  1642. - const struct _mp_raw_code_t *rc;
  1643. + const void *proto_fun;
  1644. } mp_frozen_module_t;
  1645. // State for an executing function.
  1646. @@ -281,7 +281,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state,
  1647. 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);
  1648. void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw, const mp_obj_t *args);
  1649. 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);
  1650. -void mp_bytecode_print(const mp_print_t *print, const struct _mp_raw_code_t *rc, const mp_module_constants_t *cm);
  1651. +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);
  1652. 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);
  1653. 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);
  1654. #define mp_bytecode_print_inst(print, code, x_table) mp_bytecode_print2(print, code, 1, x_table)
  1655. diff --git a/py/binary.c b/py/binary.c
  1656. index 4c8b6ffcd..7c01cfa1c 100644
  1657. --- a/py/binary.c
  1658. +++ b/py/binary.c
  1659. @@ -74,11 +74,14 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
  1660. case 'S':
  1661. size = sizeof(void *);
  1662. break;
  1663. + case 'e':
  1664. + size = 2;
  1665. + break;
  1666. case 'f':
  1667. - size = sizeof(float);
  1668. + size = 4;
  1669. break;
  1670. case 'd':
  1671. - size = sizeof(double);
  1672. + size = 8;
  1673. break;
  1674. }
  1675. break;
  1676. @@ -122,6 +125,10 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
  1677. align = alignof(void *);
  1678. size = sizeof(void *);
  1679. break;
  1680. + case 'e':
  1681. + align = 2;
  1682. + size = 2;
  1683. + break;
  1684. case 'f':
  1685. align = alignof(float);
  1686. size = sizeof(float);
  1687. @@ -144,6 +151,99 @@ size_t mp_binary_get_size(char struct_type, char val_type, size_t *palign) {
  1688. return size;
  1689. }
  1690. +#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_FLOAT_USE_NATIVE_FLT16
  1691. +
  1692. +static inline float mp_decode_half_float(uint16_t hf) {
  1693. + union {
  1694. + uint16_t i;
  1695. + _Float16 f;
  1696. + } fpu = { .i = hf };
  1697. + return fpu.f;
  1698. +}
  1699. +
  1700. +static inline uint16_t mp_encode_half_float(float x) {
  1701. + union {
  1702. + uint16_t i;
  1703. + _Float16 f;
  1704. + } fp_sp = { .f = (_Float16)x };
  1705. + return fp_sp.i;
  1706. +}
  1707. +
  1708. +#elif MICROPY_PY_BUILTINS_FLOAT
  1709. +
  1710. +static float mp_decode_half_float(uint16_t hf) {
  1711. + union {
  1712. + uint32_t i;
  1713. + float f;
  1714. + } fpu;
  1715. +
  1716. + uint16_t m = hf & 0x3ff;
  1717. + int e = (hf >> 10) & 0x1f;
  1718. + if (e == 0x1f) {
  1719. + // Half-float is infinity.
  1720. + e = 0xff;
  1721. + } else if (e) {
  1722. + // Half-float is normal.
  1723. + e += 127 - 15;
  1724. + } else if (m) {
  1725. + // Half-float is subnormal, make it normal.
  1726. + e = 127 - 15;
  1727. + while (!(m & 0x400)) {
  1728. + m <<= 1;
  1729. + --e;
  1730. + }
  1731. + m -= 0x400;
  1732. + ++e;
  1733. + }
  1734. +
  1735. + fpu.i = ((hf & 0x8000) << 16) | (e << 23) | (m << 13);
  1736. + return fpu.f;
  1737. +}
  1738. +
  1739. +static uint16_t mp_encode_half_float(float x) {
  1740. + union {
  1741. + uint32_t i;
  1742. + float f;
  1743. + } fpu = { .f = x };
  1744. +
  1745. + uint16_t m = (fpu.i >> 13) & 0x3ff;
  1746. + if (fpu.i & (1 << 12)) {
  1747. + // Round up.
  1748. + ++m;
  1749. + }
  1750. + int e = (fpu.i >> 23) & 0xff;
  1751. +
  1752. + if (e == 0xff) {
  1753. + // Infinity.
  1754. + e = 0x1f;
  1755. + } else if (e != 0) {
  1756. + e -= 127 - 15;
  1757. + if (e < 0) {
  1758. + // Underflow: denormalized, or zero.
  1759. + if (e >= -11) {
  1760. + m = (m | 0x400) >> -e;
  1761. + if (m & 1) {
  1762. + m = (m >> 1) + 1;
  1763. + } else {
  1764. + m >>= 1;
  1765. + }
  1766. + } else {
  1767. + m = 0;
  1768. + }
  1769. + e = 0;
  1770. + } else if (e > 0x3f) {
  1771. + // Overflow: infinity.
  1772. + e = 0x1f;
  1773. + m = 0;
  1774. + }
  1775. + }
  1776. +
  1777. + uint16_t bits = ((fpu.i >> 16) & 0x8000) | (e << 10) | m;
  1778. + return bits;
  1779. +}
  1780. +
  1781. +#endif
  1782. +
  1783. mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
  1784. mp_int_t val = 0;
  1785. switch (typecode) {
  1786. @@ -240,6 +340,8 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
  1787. const char *s_val = (const char *)(uintptr_t)(mp_uint_t)val;
  1788. return mp_obj_new_str(s_val, strlen(s_val));
  1789. #if MICROPY_PY_BUILTINS_FLOAT
  1790. + } else if (val_type == 'e') {
  1791. + return mp_obj_new_float_from_f(mp_decode_half_float(val));
  1792. } else if (val_type == 'f') {
  1793. union {
  1794. uint32_t i;
  1795. @@ -309,6 +411,9 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
  1796. val = (mp_uint_t)val_in;
  1797. break;
  1798. #if MICROPY_PY_BUILTINS_FLOAT
  1799. + case 'e':
  1800. + val = mp_encode_half_float(mp_obj_get_float_to_f(val_in));
  1801. + break;
  1802. case 'f': {
  1803. union {
  1804. uint32_t i;
  1805. diff --git a/py/builtinevex.c b/py/builtinevex.c
  1806. index 73fca5d39..e25cbd4d0 100644
  1807. --- a/py/builtinevex.c
  1808. +++ b/py/builtinevex.c
  1809. @@ -38,13 +38,13 @@ typedef struct _mp_obj_code_t {
  1810. mp_obj_t module_fun;
  1811. } mp_obj_code_t;
  1812. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  1813. +static MP_DEFINE_CONST_OBJ_TYPE(
  1814. mp_type_code,
  1815. MP_QSTR_code,
  1816. MP_TYPE_FLAG_NONE
  1817. );
  1818. -STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
  1819. +static mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
  1820. // save context
  1821. nlr_jump_callback_node_globals_locals_t ctx;
  1822. ctx.globals = mp_globals_get();
  1823. @@ -57,9 +57,13 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj
  1824. // set exception handler to restore context if an exception is raised
  1825. nlr_push_jump_callback(&ctx.callback, mp_globals_locals_set_from_nlr_jump_callback);
  1826. - // a bit of a hack: fun_bc will re-set globals, so need to make sure it's
  1827. - // the correct one
  1828. - if (mp_obj_is_type(self->module_fun, &mp_type_fun_bc)) {
  1829. + // The call to mp_parse_compile_execute() in mp_builtin_compile() below passes
  1830. + // NULL for the globals, so repopulate that entry now with the correct globals.
  1831. + if (mp_obj_is_type(self->module_fun, &mp_type_fun_bc)
  1832. + #if MICROPY_EMIT_NATIVE
  1833. + || mp_obj_is_type(self->module_fun, &mp_type_fun_native)
  1834. + #endif
  1835. + ) {
  1836. mp_obj_fun_bc_t *fun_bc = MP_OBJ_TO_PTR(self->module_fun);
  1837. ((mp_module_context_t *)fun_bc->context)->module.globals = globals;
  1838. }
  1839. @@ -74,7 +78,7 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj
  1840. return ret;
  1841. }
  1842. -STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
  1843. +static mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
  1844. (void)n_args;
  1845. // get the source
  1846. @@ -114,7 +118,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj, 3, 6, mp_builtin_com
  1847. #if MICROPY_PY_BUILTINS_EVAL_EXEC
  1848. -STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
  1849. +static mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_input_kind_t parse_input_kind) {
  1850. // work out the context
  1851. mp_obj_dict_t *globals = mp_globals_get();
  1852. mp_obj_dict_t *locals = mp_locals_get();
  1853. @@ -154,12 +158,12 @@ STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_i
  1854. return mp_parse_compile_execute(lex, parse_input_kind, globals, locals);
  1855. }
  1856. -STATIC mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
  1857. +static mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
  1858. return eval_exec_helper(n_args, args, MP_PARSE_EVAL_INPUT);
  1859. }
  1860. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_eval_obj, 1, 3, mp_builtin_eval);
  1861. -STATIC mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
  1862. +static mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
  1863. return eval_exec_helper(n_args, args, MP_PARSE_FILE_INPUT);
  1864. }
  1865. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec);
  1866. @@ -167,7 +171,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_exec_obj, 1, 3, mp_builtin_exec);
  1867. #endif // MICROPY_PY_BUILTINS_EVAL_EXEC
  1868. #if MICROPY_PY_BUILTINS_EXECFILE
  1869. -STATIC mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
  1870. +static mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
  1871. // MP_PARSE_SINGLE_INPUT is used to indicate a file input
  1872. return eval_exec_helper(n_args, args, MP_PARSE_SINGLE_INPUT);
  1873. }
  1874. diff --git a/py/builtinhelp.c b/py/builtinhelp.c
  1875. index 9bd56cca0..a3fcc4dfb 100644
  1876. --- a/py/builtinhelp.c
  1877. +++ b/py/builtinhelp.c
  1878. @@ -47,7 +47,7 @@ const char mp_help_default_text[] =
  1879. "For further help on a specific object, type help(obj)\n"
  1880. ;
  1881. -STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
  1882. +static void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
  1883. mp_print_str(MP_PYTHON_PRINTER, " ");
  1884. mp_obj_print(name_o, PRINT_STR);
  1885. mp_print_str(MP_PYTHON_PRINTER, " -- ");
  1886. @@ -56,7 +56,7 @@ STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
  1887. }
  1888. #if MICROPY_PY_BUILTINS_HELP_MODULES
  1889. -STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
  1890. +static void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
  1891. for (size_t i = 0; i < map->alloc; i++) {
  1892. if (mp_map_slot_is_filled(map, i)) {
  1893. mp_obj_list_append(list, map->table[i].key);
  1894. @@ -65,7 +65,7 @@ STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
  1895. }
  1896. #if MICROPY_MODULE_FROZEN
  1897. -STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) {
  1898. +static void mp_help_add_from_names(mp_obj_t list, const char *name) {
  1899. while (*name) {
  1900. size_t len = strlen(name);
  1901. // name should end in '.py' and we strip it off
  1902. @@ -75,7 +75,7 @@ STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) {
  1903. }
  1904. #endif
  1905. -STATIC void mp_help_print_modules(void) {
  1906. +static void mp_help_print_modules(void) {
  1907. mp_obj_t list = mp_obj_new_list(0, NULL);
  1908. mp_help_add_from_map(list, &mp_builtin_module_map);
  1909. @@ -122,7 +122,7 @@ STATIC void mp_help_print_modules(void) {
  1910. }
  1911. #endif
  1912. -STATIC void mp_help_print_obj(const mp_obj_t obj) {
  1913. +static void mp_help_print_obj(const mp_obj_t obj) {
  1914. #if MICROPY_PY_BUILTINS_HELP_MODULES
  1915. if (obj == MP_OBJ_NEW_QSTR(MP_QSTR_modules)) {
  1916. mp_help_print_modules();
  1917. @@ -158,7 +158,7 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) {
  1918. }
  1919. }
  1920. -STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
  1921. +static mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
  1922. if (n_args == 0) {
  1923. // print a general help message
  1924. mp_print_str(MP_PYTHON_PRINTER, MICROPY_PY_BUILTINS_HELP_TEXT);
  1925. diff --git a/py/builtinimport.c b/py/builtinimport.c
  1926. index 009885498..0611926fd 100644
  1927. --- a/py/builtinimport.c
  1928. +++ b/py/builtinimport.c
  1929. @@ -57,16 +57,17 @@
  1930. // uses mp_vfs_import_stat) to also search frozen modules. Given an exact
  1931. // path to a file or directory (e.g. "foo/bar", foo/bar.py" or "foo/bar.mpy"),
  1932. // will return whether the path is a file, directory, or doesn't exist.
  1933. -STATIC mp_import_stat_t stat_path(const char *path) {
  1934. +static mp_import_stat_t stat_path(vstr_t *path) {
  1935. + const char *str = vstr_null_terminated_str(path);
  1936. #if MICROPY_MODULE_FROZEN
  1937. // Only try and load as a frozen module if it starts with .frozen/.
  1938. const int frozen_path_prefix_len = strlen(MP_FROZEN_PATH_PREFIX);
  1939. - if (strncmp(path, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) {
  1940. + if (strncmp(str, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) {
  1941. // Just stat (which is the return value), don't get the data.
  1942. - return mp_find_frozen_module(path + frozen_path_prefix_len, NULL, NULL);
  1943. + return mp_find_frozen_module(str + frozen_path_prefix_len, NULL, NULL);
  1944. }
  1945. #endif
  1946. - return mp_import_stat(path);
  1947. + return mp_import_stat(str);
  1948. }
  1949. // Stat a given filesystem path to a .py file. If the file does not exist,
  1950. @@ -74,8 +75,8 @@ STATIC mp_import_stat_t stat_path(const char *path) {
  1951. // argument. This is the logic that makes .py files take precedent over .mpy
  1952. // files. This uses stat_path above, rather than mp_import_stat directly, so
  1953. // that the .frozen path prefix is handled.
  1954. -STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
  1955. - mp_import_stat_t stat = stat_path(vstr_null_terminated_str(path));
  1956. +static mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
  1957. + mp_import_stat_t stat = stat_path(path);
  1958. if (stat == MP_IMPORT_STAT_FILE) {
  1959. return stat;
  1960. }
  1961. @@ -85,7 +86,7 @@ STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
  1962. // Note: There's no point doing this if it's a frozen path, but adding the check
  1963. // would be extra code, and no harm letting mp_find_frozen_module fail instead.
  1964. vstr_ins_byte(path, path->len - 2, 'm');
  1965. - stat = stat_path(vstr_null_terminated_str(path));
  1966. + stat = stat_path(path);
  1967. if (stat == MP_IMPORT_STAT_FILE) {
  1968. return stat;
  1969. }
  1970. @@ -98,8 +99,8 @@ STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
  1971. // or "foo/bar.(m)py" in either the filesystem or frozen modules. If the
  1972. // result is a file, the path argument will be updated to include the file
  1973. // extension.
  1974. -STATIC mp_import_stat_t stat_module(vstr_t *path) {
  1975. - mp_import_stat_t stat = stat_path(vstr_null_terminated_str(path));
  1976. +static mp_import_stat_t stat_module(vstr_t *path) {
  1977. + mp_import_stat_t stat = stat_path(path);
  1978. DEBUG_printf("stat %s: %d\n", vstr_str(path), stat);
  1979. if (stat == MP_IMPORT_STAT_DIR) {
  1980. return stat;
  1981. @@ -113,7 +114,7 @@ STATIC mp_import_stat_t stat_module(vstr_t *path) {
  1982. // Given a top-level module name, try and find it in each of the sys.path
  1983. // entries. Note: On success, the dest argument will be updated to the matching
  1984. // path (i.e. "<entry>/mod_name(.py)").
  1985. -STATIC mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
  1986. +static mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
  1987. DEBUG_printf("stat_top_level: '%s'\n", qstr_str(mod_name));
  1988. #if MICROPY_PY_SYS
  1989. size_t path_num;
  1990. @@ -151,7 +152,7 @@ STATIC mp_import_stat_t stat_top_level(qstr mod_name, vstr_t *dest) {
  1991. }
  1992. #if MICROPY_MODULE_FROZEN_STR || MICROPY_ENABLE_COMPILER
  1993. -STATIC void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
  1994. +static void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
  1995. #if MICROPY_PY___FILE__
  1996. qstr source_name = lex->source_name;
  1997. mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
  1998. @@ -164,7 +165,7 @@ STATIC void do_load_from_lexer(mp_module_context_t *context, mp_lexer_t *lex) {
  1999. #endif
  2000. #if (MICROPY_HAS_FILE_READER && MICROPY_PERSISTENT_CODE_LOAD) || MICROPY_MODULE_FROZEN_MPY
  2001. -STATIC void do_execute_raw_code(const mp_module_context_t *context, const mp_raw_code_t *rc, qstr source_name) {
  2002. +static void do_execute_proto_fun(const mp_module_context_t *context, mp_proto_fun_t proto_fun, qstr source_name) {
  2003. #if MICROPY_PY___FILE__
  2004. mp_store_attr(MP_OBJ_FROM_PTR(&context->module), MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
  2005. #else
  2006. @@ -187,7 +188,7 @@ STATIC void do_execute_raw_code(const mp_module_context_t *context, const mp_raw
  2007. nlr_push_jump_callback(&ctx.callback, mp_globals_locals_set_from_nlr_jump_callback);
  2008. // make and execute the function
  2009. - mp_obj_t module_fun = mp_make_function_from_raw_code(rc, context, NULL);
  2010. + mp_obj_t module_fun = mp_make_function_from_proto_fun(proto_fun, context, NULL);
  2011. mp_call_function_0(module_fun);
  2012. // deregister exception handler and restore context
  2013. @@ -195,7 +196,7 @@ STATIC void do_execute_raw_code(const mp_module_context_t *context, const mp_raw
  2014. }
  2015. #endif
  2016. -STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
  2017. +static void do_load(mp_module_context_t *module_obj, vstr_t *file) {
  2018. #if MICROPY_MODULE_FROZEN || MICROPY_ENABLE_COMPILER || (MICROPY_PERSISTENT_CODE_LOAD && MICROPY_HAS_FILE_READER)
  2019. const char *file_str = vstr_null_terminated_str(file);
  2020. #endif
  2021. @@ -229,7 +230,7 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
  2022. #else
  2023. qstr frozen_file_qstr = MP_QSTRnull;
  2024. #endif
  2025. - do_execute_raw_code(module_obj, frozen->rc, frozen_file_qstr);
  2026. + do_execute_proto_fun(module_obj, frozen->proto_fun, frozen_file_qstr);
  2027. return;
  2028. }
  2029. #endif
  2030. @@ -246,7 +247,7 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
  2031. mp_compiled_module_t cm;
  2032. cm.context = module_obj;
  2033. mp_raw_code_load_file(file_qstr, &cm);
  2034. - do_execute_raw_code(cm.context, cm.rc, file_qstr);
  2035. + do_execute_proto_fun(cm.context, cm.rc, file_qstr);
  2036. return;
  2037. }
  2038. #endif
  2039. @@ -266,7 +267,7 @@ STATIC void do_load(mp_module_context_t *module_obj, vstr_t *file) {
  2040. // Convert a relative (to the current module) import, going up "level" levels,
  2041. // into an absolute import.
  2042. -STATIC void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) {
  2043. +static void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) {
  2044. // What we want to do here is to take the name of the current module,
  2045. // remove <level> trailing components, and concatenate the passed-in
  2046. // module name.
  2047. @@ -349,7 +350,7 @@ typedef struct _nlr_jump_callback_node_unregister_module_t {
  2048. qstr name;
  2049. } nlr_jump_callback_node_unregister_module_t;
  2050. -STATIC void unregister_module_from_nlr_jump_callback(void *ctx_in) {
  2051. +static void unregister_module_from_nlr_jump_callback(void *ctx_in) {
  2052. nlr_jump_callback_node_unregister_module_t *ctx = ctx_in;
  2053. mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map;
  2054. mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(ctx->name), MP_MAP_LOOKUP_REMOVE_IF_FOUND);
  2055. @@ -362,7 +363,7 @@ STATIC void unregister_module_from_nlr_jump_callback(void *ctx_in) {
  2056. // attribute on it) (or MP_OBJ_NULL for top-level).
  2057. // override_main: Whether to set the __name__ to "__main__" (and use __main__
  2058. // for the actual path).
  2059. -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) {
  2060. +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) {
  2061. // Immediately return if the module at this level is already loaded.
  2062. mp_map_elem_t *elem;
  2063. diff --git a/py/compile.c b/py/compile.c
  2064. index a9b34ce5d..62757de3c 100644
  2065. --- a/py/compile.c
  2066. +++ b/py/compile.c
  2067. @@ -41,8 +41,6 @@
  2068. #if MICROPY_ENABLE_COMPILER
  2069. -// TODO need to mangle __attr names
  2070. -
  2071. #define INVALID_LABEL (0xffff)
  2072. typedef enum {
  2073. @@ -92,7 +90,7 @@ typedef enum {
  2074. #define NATIVE_EMITTER(f) emit_native_table[mp_dynamic_compiler.native_arch]->emit_##f
  2075. #define NATIVE_EMITTER_TABLE (emit_native_table[mp_dynamic_compiler.native_arch])
  2076. -STATIC const emit_method_table_t *emit_native_table[] = {
  2077. +static const emit_method_table_t *emit_native_table[] = {
  2078. NULL,
  2079. &emit_native_x86_method_table,
  2080. &emit_native_x64_method_table,
  2081. @@ -131,7 +129,7 @@ STATIC const emit_method_table_t *emit_native_table[] = {
  2082. #define ASM_EMITTER(f) emit_asm_table[mp_dynamic_compiler.native_arch]->asm_##f
  2083. #define ASM_EMITTER_TABLE emit_asm_table[mp_dynamic_compiler.native_arch]
  2084. -STATIC const emit_inline_asm_method_table_t *emit_asm_table[] = {
  2085. +static const emit_inline_asm_method_table_t *emit_asm_table[] = {
  2086. NULL,
  2087. NULL,
  2088. NULL,
  2089. @@ -198,11 +196,15 @@ typedef struct _compiler_t {
  2090. mp_emit_common_t emit_common;
  2091. } compiler_t;
  2092. +#if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
  2093. +bool mp_compile_allow_top_level_await = false;
  2094. +#endif
  2095. +
  2096. /******************************************************************************/
  2097. // mp_emit_common_t helper functions
  2098. // These are defined here so they can be inlined, to reduce code size.
  2099. -STATIC void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
  2100. +static void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
  2101. #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
  2102. mp_map_init(&emit->qstr_map, 1);
  2103. @@ -213,7 +215,7 @@ STATIC void mp_emit_common_init(mp_emit_common_t *emit, qstr source_file) {
  2104. mp_obj_list_init(&emit->const_obj_list, 0);
  2105. }
  2106. -STATIC void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass) {
  2107. +static void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass) {
  2108. emit->pass = pass;
  2109. if (pass == MP_PASS_CODE_SIZE) {
  2110. if (emit->ct_cur_child == 0) {
  2111. @@ -225,7 +227,7 @@ STATIC void mp_emit_common_start_pass(mp_emit_common_t *emit, pass_kind_t pass)
  2112. emit->ct_cur_child = 0;
  2113. }
  2114. -STATIC void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr source_file, mp_module_context_t *context) {
  2115. +static void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr source_file, mp_module_context_t *context) {
  2116. #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
  2117. size_t qstr_map_used = emit->qstr_map.used;
  2118. mp_module_context_alloc_tables(context, qstr_map_used, emit->const_obj_list.len);
  2119. @@ -248,14 +250,14 @@ STATIC void mp_emit_common_populate_module_context(mp_emit_common_t *emit, qstr
  2120. /******************************************************************************/
  2121. -STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
  2122. +static void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
  2123. // if the line of the error is unknown then try to update it from the pn
  2124. if (comp->compile_error_line == 0 && MP_PARSE_NODE_IS_STRUCT(pn)) {
  2125. comp->compile_error_line = ((mp_parse_node_struct_t *)pn)->source_line;
  2126. }
  2127. }
  2128. -STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_error_text_t msg) {
  2129. +static void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_error_text_t msg) {
  2130. // only register the error if there has been no other error
  2131. if (comp->compile_error == MP_OBJ_NULL) {
  2132. comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
  2133. @@ -263,17 +265,17 @@ STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_er
  2134. }
  2135. }
  2136. -STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra);
  2137. -STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind);
  2138. -STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map);
  2139. -STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn);
  2140. +static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra);
  2141. +static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind);
  2142. +static void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map);
  2143. +static void compile_node(compiler_t *comp, mp_parse_node_t pn);
  2144. -STATIC uint comp_next_label(compiler_t *comp) {
  2145. +static uint comp_next_label(compiler_t *comp) {
  2146. return comp->next_label++;
  2147. }
  2148. #if MICROPY_EMIT_NATIVE
  2149. -STATIC void reserve_labels_for_native(compiler_t *comp, int n) {
  2150. +static void reserve_labels_for_native(compiler_t *comp, int n) {
  2151. if (comp->scope_cur->emit_options != MP_EMIT_OPT_BYTECODE) {
  2152. comp->next_label += n;
  2153. }
  2154. @@ -282,7 +284,7 @@ STATIC void reserve_labels_for_native(compiler_t *comp, int n) {
  2155. #define reserve_labels_for_native(comp, n)
  2156. #endif
  2157. -STATIC void compile_increase_except_level(compiler_t *comp, uint label, int kind) {
  2158. +static void compile_increase_except_level(compiler_t *comp, uint label, int kind) {
  2159. EMIT_ARG(setup_block, label, kind);
  2160. comp->cur_except_level += 1;
  2161. if (comp->cur_except_level > comp->scope_cur->exc_stack_size) {
  2162. @@ -290,14 +292,14 @@ STATIC void compile_increase_except_level(compiler_t *comp, uint label, int kind
  2163. }
  2164. }
  2165. -STATIC void compile_decrease_except_level(compiler_t *comp) {
  2166. +static void compile_decrease_except_level(compiler_t *comp) {
  2167. assert(comp->cur_except_level > 0);
  2168. comp->cur_except_level -= 1;
  2169. EMIT(end_finally);
  2170. reserve_labels_for_native(comp, 1);
  2171. }
  2172. -STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) {
  2173. +static scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse_node_t pn, uint emit_options) {
  2174. scope_t *scope = scope_new(kind, pn, emit_options);
  2175. scope->parent = comp->scope_cur;
  2176. scope->next = NULL;
  2177. @@ -315,7 +317,7 @@ STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, mp_parse
  2178. typedef void (*apply_list_fun_t)(compiler_t *comp, mp_parse_node_t pn);
  2179. -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) {
  2180. +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) {
  2181. if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, pn_list_kind)) {
  2182. mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
  2183. int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
  2184. @@ -327,7 +329,7 @@ STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kin
  2185. }
  2186. }
  2187. -STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2188. +static void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2189. int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
  2190. for (int i = 0; i < num_nodes; i++) {
  2191. compile_node(comp, pns->nodes[i]);
  2192. @@ -339,7 +341,7 @@ STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_struct_t *
  2193. }
  2194. }
  2195. -STATIC void compile_load_id(compiler_t *comp, qstr qst) {
  2196. +static void compile_load_id(compiler_t *comp, qstr qst) {
  2197. if (comp->pass == MP_PASS_SCOPE) {
  2198. mp_emit_common_get_id_for_load(comp->scope_cur, qst);
  2199. } else {
  2200. @@ -351,7 +353,7 @@ STATIC void compile_load_id(compiler_t *comp, qstr qst) {
  2201. }
  2202. }
  2203. -STATIC void compile_store_id(compiler_t *comp, qstr qst) {
  2204. +static void compile_store_id(compiler_t *comp, qstr qst) {
  2205. if (comp->pass == MP_PASS_SCOPE) {
  2206. mp_emit_common_get_id_for_modification(comp->scope_cur, qst);
  2207. } else {
  2208. @@ -363,7 +365,7 @@ STATIC void compile_store_id(compiler_t *comp, qstr qst) {
  2209. }
  2210. }
  2211. -STATIC void compile_delete_id(compiler_t *comp, qstr qst) {
  2212. +static void compile_delete_id(compiler_t *comp, qstr qst) {
  2213. if (comp->pass == MP_PASS_SCOPE) {
  2214. mp_emit_common_get_id_for_modification(comp->scope_cur, qst);
  2215. } else {
  2216. @@ -375,7 +377,7 @@ STATIC void compile_delete_id(compiler_t *comp, qstr qst) {
  2217. }
  2218. }
  2219. -STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2220. +static void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2221. // a simple tuple expression
  2222. size_t num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
  2223. for (size_t i = 0; i < num_nodes; i++) {
  2224. @@ -384,7 +386,7 @@ STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns)
  2225. EMIT_ARG(build, num_nodes, MP_EMIT_BUILD_TUPLE);
  2226. }
  2227. -STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) {
  2228. +static void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) {
  2229. if (mp_parse_node_is_const_false(pn)) {
  2230. if (jump_if == false) {
  2231. EMIT_ARG(jump, label);
  2232. @@ -432,9 +434,9 @@ STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int la
  2233. }
  2234. typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_kind_t;
  2235. -STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind);
  2236. +static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t kind);
  2237. -STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) {
  2238. +static void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, assign_kind_t assign_kind) {
  2239. if (assign_kind != ASSIGN_AUG_STORE) {
  2240. compile_node(comp, pns->nodes[0]);
  2241. }
  2242. @@ -483,7 +485,7 @@ STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, as
  2243. compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("can't assign to expression"));
  2244. }
  2245. -STATIC void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) {
  2246. +static void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) {
  2247. // look for star expression
  2248. uint have_star_index = -1;
  2249. for (uint i = 0; i < num_tail; i++) {
  2250. @@ -510,7 +512,7 @@ STATIC void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nod
  2251. }
  2252. // assigns top of stack to pn
  2253. -STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) {
  2254. +static void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) {
  2255. assert(!MP_PARSE_NODE_IS_NULL(pn));
  2256. if (MP_PARSE_NODE_IS_LEAF(pn)) {
  2257. if (MP_PARSE_NODE_IS_ID(pn)) {
  2258. @@ -601,7 +603,7 @@ cannot_assign:
  2259. // if n_pos_defaults > 0 then there is a tuple on the stack with the positional defaults
  2260. // if n_kw_defaults > 0 then there is a dictionary on the stack with the keyword defaults
  2261. // if both exist, the tuple is above the dictionary (ie the first pop gets the tuple)
  2262. -STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) {
  2263. +static void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) {
  2264. assert(n_pos_defaults >= 0);
  2265. assert(n_kw_defaults >= 0);
  2266. @@ -643,7 +645,7 @@ STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int
  2267. }
  2268. }
  2269. -STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) {
  2270. +static void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn) {
  2271. // For efficiency of the code below we extract the parse-node kind here
  2272. int pn_kind;
  2273. if (MP_PARSE_NODE_IS_ID(pn)) {
  2274. @@ -734,7 +736,7 @@ STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_node_t pn)
  2275. }
  2276. }
  2277. -STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) {
  2278. +static void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_node_t pn_params, pn_kind_t pn_list_kind) {
  2279. // When we call compile_funcdef_lambdef_param below it can compile an arbitrary
  2280. // expression for default arguments, which may contain a lambda. The lambda will
  2281. // call here in a nested way, so we must save and restore the relevant state.
  2282. @@ -770,7 +772,7 @@ STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp_parse_n
  2283. // leaves function object on stack
  2284. // returns function name
  2285. -STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
  2286. +static qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
  2287. if (comp->pass == MP_PASS_SCOPE) {
  2288. // create a new scope for this function
  2289. scope_t *s = scope_new_and_link(comp, SCOPE_FUNCTION, (mp_parse_node_t)pns, emit_options);
  2290. @@ -790,7 +792,7 @@ STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns
  2291. // leaves class object on stack
  2292. // returns class name
  2293. -STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
  2294. +static qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint emit_options) {
  2295. if (comp->pass == MP_PASS_SCOPE) {
  2296. // create a new scope for this class
  2297. scope_t *s = scope_new_and_link(comp, SCOPE_CLASS, (mp_parse_node_t)pns, emit_options);
  2298. @@ -822,7 +824,7 @@ STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pn
  2299. }
  2300. // returns true if it was a built-in decorator (even if the built-in had an error)
  2301. -STATIC bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_parse_node_t *name_nodes, uint *emit_options) {
  2302. +static bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_parse_node_t *name_nodes, uint *emit_options) {
  2303. if (MP_PARSE_NODE_LEAF_ARG(name_nodes[0]) != MP_QSTR_micropython) {
  2304. return false;
  2305. }
  2306. @@ -871,7 +873,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, size_t name_len, mp_par
  2307. return true;
  2308. }
  2309. -STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2310. +static void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2311. // get the list of decorators
  2312. mp_parse_node_t *nodes;
  2313. size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_decorators, &nodes);
  2314. @@ -939,13 +941,13 @@ STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2315. compile_store_id(comp, body_name);
  2316. }
  2317. -STATIC void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2318. +static void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2319. qstr fname = compile_funcdef_helper(comp, pns, comp->scope_cur->emit_options);
  2320. // store function object into function name
  2321. compile_store_id(comp, fname);
  2322. }
  2323. -STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
  2324. +static void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
  2325. if (MP_PARSE_NODE_IS_ID(pn)) {
  2326. compile_delete_id(comp, MP_PARSE_NODE_LEAF_ARG(pn));
  2327. } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_expr_normal)) {
  2328. @@ -1001,11 +1003,11 @@ cannot_delete:
  2329. compile_syntax_error(comp, (mp_parse_node_t)pn, MP_ERROR_TEXT("can't delete expression"));
  2330. }
  2331. -STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2332. +static void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2333. apply_to_single_or_list(comp, pns->nodes[0], PN_exprlist, c_del_stmt);
  2334. }
  2335. -STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2336. +static void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2337. uint16_t label;
  2338. if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_break_stmt) {
  2339. label = comp->break_label;
  2340. @@ -1019,7 +1021,7 @@ STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
  2341. EMIT_ARG(unwind_jump, label, comp->cur_except_level - comp->break_continue_except_level);
  2342. }
  2343. -STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2344. +static void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2345. #if MICROPY_CPYTHON_COMPAT
  2346. if (comp->scope_cur->kind != SCOPE_FUNCTION) {
  2347. compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'return' outside function"));
  2348. @@ -1047,12 +1049,12 @@ STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2349. EMIT(return_value);
  2350. }
  2351. -STATIC void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2352. +static void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2353. compile_node(comp, pns->nodes[0]);
  2354. EMIT(pop_top);
  2355. }
  2356. -STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2357. +static void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2358. if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
  2359. // raise
  2360. EMIT_ARG(raise_varargs, 0);
  2361. @@ -1072,7 +1074,7 @@ STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2362. // q_base holds the base of the name
  2363. // eg a -> q_base=a
  2364. // a.b.c -> q_base=a
  2365. -STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
  2366. +static void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
  2367. bool is_as = false;
  2368. if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_as_name)) {
  2369. mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
  2370. @@ -1133,7 +1135,7 @@ STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
  2371. }
  2372. }
  2373. -STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
  2374. +static void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
  2375. EMIT_ARG(load_const_small_int, 0); // level 0 import
  2376. EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE); // not importing from anything
  2377. qstr q_base;
  2378. @@ -1141,11 +1143,11 @@ STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
  2379. compile_store_id(comp, q_base);
  2380. }
  2381. -STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2382. +static void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2383. apply_to_single_or_list(comp, pns->nodes[0], PN_dotted_as_names, compile_dotted_as_name);
  2384. }
  2385. -STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2386. +static void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2387. mp_parse_node_t pn_import_source = pns->nodes[0];
  2388. // extract the preceding .'s (if any) for a relative import, to compute the import level
  2389. @@ -1233,7 +1235,7 @@ STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2390. }
  2391. }
  2392. -STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
  2393. +static void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
  2394. if (id_info->kind != ID_INFO_KIND_UNDECIDED && id_info->kind != ID_INFO_KIND_GLOBAL_EXPLICIT) {
  2395. compile_syntax_error(comp, pn, MP_ERROR_TEXT("identifier redefined as global"));
  2396. return;
  2397. @@ -1247,7 +1249,7 @@ STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn, id_info
  2398. }
  2399. }
  2400. -STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
  2401. +static void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info) {
  2402. if (id_info->kind == ID_INFO_KIND_UNDECIDED) {
  2403. id_info->kind = ID_INFO_KIND_GLOBAL_IMPLICIT;
  2404. scope_check_to_close_over(comp->scope_cur, id_info);
  2405. @@ -1259,7 +1261,7 @@ STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_in
  2406. }
  2407. }
  2408. -STATIC void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info, bool is_global) {
  2409. +static void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t pn, id_info_t *id_info, bool is_global) {
  2410. if (is_global) {
  2411. compile_declare_global(comp, pn, id_info);
  2412. } else {
  2413. @@ -1267,7 +1269,7 @@ STATIC void compile_declare_global_or_nonlocal(compiler_t *comp, mp_parse_node_t
  2414. }
  2415. }
  2416. -STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2417. +static void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2418. if (comp->pass == MP_PASS_SCOPE) {
  2419. bool is_global = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_global_stmt;
  2420. @@ -1286,7 +1288,7 @@ STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_
  2421. }
  2422. }
  2423. -STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2424. +static void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2425. // with optimisations enabled we don't compile assertions
  2426. if (MP_STATE_VM(mp_optimise_value) != 0) {
  2427. return;
  2428. @@ -1304,7 +1306,7 @@ STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2429. EMIT_ARG(label_assign, l_end);
  2430. }
  2431. -STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2432. +static void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2433. uint l_end = comp_next_label(comp);
  2434. // optimisation: don't emit anything when "if False"
  2435. @@ -1374,7 +1376,7 @@ done:
  2436. comp->continue_label = old_continue_label; \
  2437. comp->break_continue_except_level = old_break_continue_except_level;
  2438. -STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2439. +static void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2440. START_BREAK_CONTINUE_BLOCK
  2441. if (!mp_parse_node_is_const_false(pns->nodes[0])) { // optimisation: don't emit anything for "while False"
  2442. @@ -1412,7 +1414,7 @@ STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2443. // If <end> is a small-int, then the stack during the for-loop contains just
  2444. // the current value of <var>. Otherwise, the stack contains <end> then the
  2445. // current value of <var>.
  2446. -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) {
  2447. +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) {
  2448. START_BREAK_CONTINUE_BLOCK
  2449. uint top_label = comp_next_label(comp);
  2450. @@ -1494,7 +1496,7 @@ STATIC void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t p
  2451. }
  2452. }
  2453. -STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2454. +static void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2455. // this bit optimises: for <x> in range(...), turning it into an explicitly incremented variable
  2456. // this is actually slower, but uses no heap memory
  2457. // for viper it will be much, much faster
  2458. @@ -1574,7 +1576,7 @@ STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2459. EMIT_ARG(label_assign, break_label);
  2460. }
  2461. -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) {
  2462. +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) {
  2463. // setup code
  2464. uint l1 = comp_next_label(comp);
  2465. uint success_label = comp_next_label(comp);
  2466. @@ -1671,7 +1673,7 @@ STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_
  2467. EMIT_ARG(label_assign, l2);
  2468. }
  2469. -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) {
  2470. +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) {
  2471. uint l_finally_block = comp_next_label(comp);
  2472. compile_increase_except_level(comp, l_finally_block, MP_EMIT_SETUP_BLOCK_FINALLY);
  2473. @@ -1700,7 +1702,7 @@ STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n
  2474. compile_decrease_except_level(comp);
  2475. }
  2476. -STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2477. +static void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2478. assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should be
  2479. {
  2480. mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1];
  2481. @@ -1727,7 +1729,7 @@ STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2482. }
  2483. }
  2484. -STATIC void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
  2485. +static void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
  2486. if (n == 0) {
  2487. // no more pre-bits, compile the body of the with
  2488. compile_node(comp, body);
  2489. @@ -1754,7 +1756,7 @@ STATIC void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t
  2490. }
  2491. }
  2492. -STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2493. +static void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2494. // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
  2495. mp_parse_node_t *nodes;
  2496. size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes);
  2497. @@ -1764,7 +1766,7 @@ STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2498. compile_with_stmt_helper(comp, n, nodes, pns->nodes[1]);
  2499. }
  2500. -STATIC void compile_yield_from(compiler_t *comp) {
  2501. +static void compile_yield_from(compiler_t *comp) {
  2502. EMIT_ARG(get_iter, false);
  2503. EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
  2504. EMIT_ARG(yield, MP_EMIT_YIELD_FROM);
  2505. @@ -1772,13 +1774,13 @@ STATIC void compile_yield_from(compiler_t *comp) {
  2506. }
  2507. #if MICROPY_PY_ASYNC_AWAIT
  2508. -STATIC void compile_await_object_method(compiler_t *comp, qstr method) {
  2509. +static void compile_await_object_method(compiler_t *comp, qstr method) {
  2510. EMIT_ARG(load_method, method, false);
  2511. EMIT_ARG(call_method, 0, 0, 0);
  2512. compile_yield_from(comp);
  2513. }
  2514. -STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2515. +static void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2516. // Allocate labels.
  2517. uint while_else_label = comp_next_label(comp);
  2518. uint try_exception_label = comp_next_label(comp);
  2519. @@ -1845,7 +1847,7 @@ STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns
  2520. // Stack: (...)
  2521. }
  2522. -STATIC void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
  2523. +static void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_node_t *nodes, mp_parse_node_t body) {
  2524. if (n == 0) {
  2525. // no more pre-bits, compile the body of the with
  2526. compile_node(comp, body);
  2527. @@ -1957,7 +1959,7 @@ STATIC void compile_async_with_stmt_helper(compiler_t *comp, size_t n, mp_parse_
  2528. }
  2529. }
  2530. -STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2531. +static void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2532. // get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
  2533. mp_parse_node_t *nodes;
  2534. size_t n = mp_parse_node_extract_list(&pns->nodes[0], PN_with_stmt_list, &nodes);
  2535. @@ -1967,7 +1969,7 @@ STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_struct_t *pn
  2536. compile_async_with_stmt_helper(comp, n, nodes, pns->nodes[1]);
  2537. }
  2538. -STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2539. +static void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2540. assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[0]));
  2541. mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t *)pns->nodes[0];
  2542. if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_funcdef) {
  2543. @@ -1996,7 +1998,7 @@ STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2544. }
  2545. #endif
  2546. -STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2547. +static void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2548. mp_parse_node_t pn_rhs = pns->nodes[1];
  2549. if (MP_PARSE_NODE_IS_NULL(pn_rhs)) {
  2550. if (comp->is_repl && comp->scope_cur->kind == SCOPE_MODULE) {
  2551. @@ -2111,7 +2113,7 @@ STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2552. }
  2553. }
  2554. -STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2555. +static void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2556. assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else));
  2557. mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t *)pns->nodes[1];
  2558. @@ -2126,7 +2128,7 @@ STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns)
  2559. EMIT_ARG(label_assign, l_end);
  2560. }
  2561. -STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2562. +static void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2563. if (comp->pass == MP_PASS_SCOPE) {
  2564. // create a new scope for this lambda
  2565. scope_t *s = scope_new_and_link(comp, SCOPE_LAMBDA, (mp_parse_node_t)pns, comp->scope_cur->emit_options);
  2566. @@ -2142,7 +2144,7 @@ STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2567. }
  2568. #if MICROPY_PY_ASSIGN_EXPR
  2569. -STATIC void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name, mp_parse_node_t pn_expr) {
  2570. +static void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name, mp_parse_node_t pn_expr) {
  2571. if (!MP_PARSE_NODE_IS_ID(pn_name)) {
  2572. compile_syntax_error(comp, (mp_parse_node_t)pn_name, MP_ERROR_TEXT("can't assign to expression"));
  2573. }
  2574. @@ -2174,12 +2176,12 @@ STATIC void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t pn_name,
  2575. compile_store_id(comp, target);
  2576. }
  2577. -STATIC void compile_namedexpr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2578. +static void compile_namedexpr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2579. compile_namedexpr_helper(comp, pns->nodes[0], pns->nodes[1]);
  2580. }
  2581. #endif
  2582. -STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2583. +static void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2584. bool cond = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_or_test;
  2585. uint l_end = comp_next_label(comp);
  2586. int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
  2587. @@ -2192,12 +2194,12 @@ STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2588. EMIT_ARG(label_assign, l_end);
  2589. }
  2590. -STATIC void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2591. +static void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2592. compile_node(comp, pns->nodes[0]);
  2593. EMIT_ARG(unary_op, MP_UNARY_OP_NOT);
  2594. }
  2595. -STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2596. +static void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2597. int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
  2598. compile_node(comp, pns->nodes[0]);
  2599. bool multi = (num_nodes > 3);
  2600. @@ -2250,11 +2252,11 @@ STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2601. }
  2602. }
  2603. -STATIC void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2604. +static void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2605. compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("*x must be assignment target"));
  2606. }
  2607. -STATIC void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2608. +static void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2609. MP_STATIC_ASSERT(MP_BINARY_OP_OR + PN_xor_expr - PN_expr == MP_BINARY_OP_XOR);
  2610. MP_STATIC_ASSERT(MP_BINARY_OP_OR + PN_and_expr - PN_expr == MP_BINARY_OP_AND);
  2611. mp_binary_op_t binary_op = MP_BINARY_OP_OR + MP_PARSE_NODE_STRUCT_KIND(pns) - PN_expr;
  2612. @@ -2266,7 +2268,7 @@ STATIC void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2613. }
  2614. }
  2615. -STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2616. +static void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2617. int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
  2618. compile_node(comp, pns->nodes[0]);
  2619. for (int i = 1; i + 1 < num_nodes; i += 2) {
  2620. @@ -2277,7 +2279,7 @@ STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2621. }
  2622. }
  2623. -STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2624. +static void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2625. compile_node(comp, pns->nodes[1]);
  2626. mp_token_kind_t tok = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]);
  2627. mp_unary_op_t op;
  2628. @@ -2290,7 +2292,7 @@ STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2629. EMIT_ARG(unary_op, op);
  2630. }
  2631. -STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2632. +static void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2633. // compile the subject of the expression
  2634. compile_node(comp, pns->nodes[0]);
  2635. @@ -2386,12 +2388,12 @@ STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_struct_t *p
  2636. }
  2637. }
  2638. -STATIC void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2639. +static void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2640. compile_generic_all_nodes(comp, pns); // 2 nodes, arguments of power
  2641. EMIT_ARG(binary_op, MP_BINARY_OP_POWER);
  2642. }
  2643. -STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) {
  2644. +static void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) {
  2645. // function to call is on top of stack
  2646. // get the list of arguments
  2647. @@ -2486,7 +2488,7 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
  2648. }
  2649. // pns needs to have 2 nodes, first is lhs of comprehension, second is PN_comp_for node
  2650. -STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) {
  2651. +static void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) {
  2652. assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2);
  2653. assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for));
  2654. mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t *)pns->nodes[1];
  2655. @@ -2511,7 +2513,7 @@ STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns,
  2656. EMIT_ARG(call_function, 1, 0, 0);
  2657. }
  2658. -STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2659. +static void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2660. if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
  2661. // an empty tuple
  2662. EMIT_ARG(build, 0, MP_EMIT_BUILD_TUPLE);
  2663. @@ -2528,7 +2530,7 @@ STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2664. }
  2665. }
  2666. -STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2667. +static void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2668. if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
  2669. // empty list
  2670. EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST);
  2671. @@ -2549,7 +2551,7 @@ STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns)
  2672. }
  2673. }
  2674. -STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map) {
  2675. +static void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *pns, bool create_map) {
  2676. mp_parse_node_t pn = pns->nodes[0];
  2677. if (MP_PARSE_NODE_IS_NULL(pn)) {
  2678. // empty dict
  2679. @@ -2651,27 +2653,27 @@ STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *
  2680. }
  2681. }
  2682. -STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2683. +static void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2684. compile_atom_brace_helper(comp, pns, true);
  2685. }
  2686. -STATIC void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2687. +static void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2688. compile_trailer_paren_helper(comp, pns->nodes[0], false, 0);
  2689. }
  2690. -STATIC void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2691. +static void compile_trailer_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2692. // object who's index we want is on top of stack
  2693. compile_node(comp, pns->nodes[0]); // the index
  2694. EMIT_ARG(subscr, MP_EMIT_SUBSCR_LOAD);
  2695. }
  2696. -STATIC void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2697. +static void compile_trailer_period(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2698. // object who's attribute we want is on top of stack
  2699. EMIT_ARG(attr, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]), MP_EMIT_ATTR_LOAD); // attribute to get
  2700. }
  2701. #if MICROPY_PY_BUILTINS_SLICE
  2702. -STATIC void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2703. +static void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2704. if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_2) {
  2705. compile_node(comp, pns->nodes[0]); // start of slice
  2706. assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be
  2707. @@ -2726,19 +2728,19 @@ STATIC void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2708. }
  2709. #endif // MICROPY_PY_BUILTINS_SLICE
  2710. -STATIC void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2711. +static void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2712. // if this is called then we are compiling a dict key:value pair
  2713. compile_node(comp, pns->nodes[1]); // value
  2714. compile_node(comp, pns->nodes[0]); // key
  2715. }
  2716. -STATIC void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2717. +static void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2718. qstr cname = compile_classdef_helper(comp, pns, comp->scope_cur->emit_options);
  2719. // store class object into class name
  2720. compile_store_id(comp, cname);
  2721. }
  2722. -STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2723. +static void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2724. if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
  2725. compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'yield' outside function"));
  2726. return;
  2727. @@ -2759,26 +2761,31 @@ STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2728. }
  2729. #if MICROPY_PY_ASYNC_AWAIT
  2730. -STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2731. +static void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2732. if (comp->scope_cur->kind != SCOPE_FUNCTION && comp->scope_cur->kind != SCOPE_LAMBDA) {
  2733. - compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'await' outside function"));
  2734. - return;
  2735. + #if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
  2736. + if (!mp_compile_allow_top_level_await)
  2737. + #endif
  2738. + {
  2739. + compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("'await' outside function"));
  2740. + return;
  2741. + }
  2742. }
  2743. compile_atom_expr_normal(comp, pns);
  2744. compile_yield_from(comp);
  2745. }
  2746. #endif
  2747. -STATIC mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
  2748. +static mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
  2749. return mp_parse_node_extract_const_object(pns);
  2750. }
  2751. -STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2752. +static void compile_const_object(compiler_t *comp, mp_parse_node_struct_t *pns) {
  2753. EMIT_ARG(load_const_obj, get_const_object(pns));
  2754. }
  2755. typedef void (*compile_function_t)(compiler_t *, mp_parse_node_struct_t *);
  2756. -STATIC const compile_function_t compile_function[] = {
  2757. +static const compile_function_t compile_function[] = {
  2758. // only define rules with a compile function
  2759. #define c(f) compile_##f
  2760. #define DEF_RULE(rule, comp, kind, ...) comp,
  2761. @@ -2790,7 +2797,7 @@ STATIC const compile_function_t compile_function[] = {
  2762. compile_const_object,
  2763. };
  2764. -STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
  2765. +static void compile_node(compiler_t *comp, mp_parse_node_t pn) {
  2766. if (MP_PARSE_NODE_IS_NULL(pn)) {
  2767. // pass
  2768. } else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
  2769. @@ -2826,7 +2833,7 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
  2770. }
  2771. #if MICROPY_EMIT_NATIVE
  2772. -STATIC int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_annotation) {
  2773. +static int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_annotation) {
  2774. int native_type = MP_NATIVE_TYPE_OBJ;
  2775. if (MP_PARSE_NODE_IS_NULL(pn_annotation)) {
  2776. // No annotation, type defaults to object
  2777. @@ -2844,7 +2851,7 @@ STATIC int compile_viper_type_annotation(compiler_t *comp, mp_parse_node_t pn_an
  2778. }
  2779. #endif
  2780. -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) {
  2781. +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) {
  2782. (void)pn_dbl_star;
  2783. // check that **kw is last
  2784. @@ -2931,15 +2938,15 @@ STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_node_t pn
  2785. }
  2786. }
  2787. -STATIC void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) {
  2788. +static void compile_scope_func_param(compiler_t *comp, mp_parse_node_t pn) {
  2789. compile_scope_func_lambda_param(comp, pn, PN_typedargslist_name, PN_typedargslist_star, PN_typedargslist_dbl_star);
  2790. }
  2791. -STATIC void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) {
  2792. +static void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t pn) {
  2793. compile_scope_func_lambda_param(comp, pn, PN_varargslist_name, PN_varargslist_star, PN_varargslist_dbl_star);
  2794. }
  2795. -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) {
  2796. +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) {
  2797. uint l_top = comp_next_label(comp);
  2798. uint l_end = comp_next_label(comp);
  2799. EMIT_ARG(label_assign, l_top);
  2800. @@ -2978,7 +2985,7 @@ tail_recursion:
  2801. EMIT(for_iter_end);
  2802. }
  2803. -STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
  2804. +static void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
  2805. #if MICROPY_ENABLE_DOC_STRING
  2806. // see http://www.python.org/dev/peps/pep-0257/
  2807. @@ -3023,7 +3030,7 @@ STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
  2808. #endif
  2809. }
  2810. -STATIC bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
  2811. +static bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
  2812. comp->pass = pass;
  2813. comp->scope_cur = scope;
  2814. comp->next_label = 0;
  2815. @@ -3188,7 +3195,7 @@ STATIC bool compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
  2816. #if MICROPY_EMIT_INLINE_ASM
  2817. // requires 3 passes: SCOPE, CODE_SIZE, EMIT
  2818. -STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
  2819. +static void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
  2820. comp->pass = pass;
  2821. comp->scope_cur = scope;
  2822. comp->next_label = 0;
  2823. @@ -3363,7 +3370,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
  2824. }
  2825. #endif
  2826. -STATIC void scope_compute_things(scope_t *scope) {
  2827. +static void scope_compute_things(scope_t *scope) {
  2828. // in MicroPython we put the *x parameter after all other parameters (except **y)
  2829. if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) {
  2830. id_info_t *id_param = NULL;
  2831. @@ -3457,7 +3464,7 @@ STATIC void scope_compute_things(scope_t *scope) {
  2832. }
  2833. #if !MICROPY_PERSISTENT_CODE_SAVE
  2834. -STATIC
  2835. +static
  2836. #endif
  2837. void mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl, mp_compiled_module_t *cm) {
  2838. // put compiler state on the stack, it's relatively small
  2839. @@ -3625,7 +3632,7 @@ void mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, bool
  2840. for (scope_t *s = comp->scope_head; s != NULL; s = s->next) {
  2841. mp_raw_code_t *rc = s->raw_code;
  2842. if (rc->kind == MP_CODE_BYTECODE) {
  2843. - mp_bytecode_print(&mp_plat_print, rc, &cm->context->constants);
  2844. + mp_bytecode_print(&mp_plat_print, rc, s->raw_code_data_len, &cm->context->constants);
  2845. }
  2846. }
  2847. }
  2848. @@ -3667,7 +3674,7 @@ mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl)
  2849. cm.context->module.globals = mp_globals_get();
  2850. mp_compile_to_raw_code(parse_tree, source_file, is_repl, &cm);
  2851. // return function that executes the outer module
  2852. - return mp_make_function_from_raw_code(cm.rc, cm.context, NULL);
  2853. + return mp_make_function_from_proto_fun(cm.rc, cm.context, NULL);
  2854. }
  2855. #endif // MICROPY_ENABLE_COMPILER
  2856. diff --git a/py/compile.h b/py/compile.h
  2857. index 5e0fd8b31..f9970a521 100644
  2858. --- a/py/compile.h
  2859. +++ b/py/compile.h
  2860. @@ -30,6 +30,11 @@
  2861. #include "py/parse.h"
  2862. #include "py/emitglue.h"
  2863. +#if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
  2864. +// set to `true` to allow top-level await expressions
  2865. +extern bool mp_compile_allow_top_level_await;
  2866. +#endif
  2867. +
  2868. // the compiler will raise an exception if an error occurred
  2869. // the compiler will clear the parse tree before it returns
  2870. // mp_globals_get() will be used for the context
  2871. diff --git a/py/dynruntime.h b/py/dynruntime.h
  2872. index de9c93c65..d07b1dce2 100644
  2873. --- a/py/dynruntime.h
  2874. +++ b/py/dynruntime.h
  2875. @@ -29,6 +29,7 @@
  2876. // This header file contains definitions to dynamically implement the static
  2877. // MicroPython runtime API defined in py/obj.h and py/runtime.h.
  2878. +#include "py/binary.h"
  2879. #include "py/nativeglue.h"
  2880. #include "py/objfun.h"
  2881. #include "py/objstr.h"
  2882. @@ -184,6 +185,10 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
  2883. /******************************************************************************/
  2884. // General runtime functions
  2885. +#define mp_binary_get_size(struct_type, val_type, palign) (mp_fun_table.binary_get_size((struct_type), (val_type), (palign)))
  2886. +#define mp_binary_get_val_array(typecode, p, index) (mp_fun_table.binary_get_val_array((typecode), (p), (index)))
  2887. +#define mp_binary_set_val_array(typecode, p, index, val_in) (mp_fun_table.binary_set_val_array((typecode), (p), (index), (val_in)))
  2888. +
  2889. #define mp_load_name(qst) (mp_fun_table.load_name((qst)))
  2890. #define mp_load_global(qst) (mp_fun_table.load_global((qst)))
  2891. #define mp_load_attr(base, attr) (mp_fun_table.load_attr((base), (attr)))
  2892. @@ -196,8 +201,8 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
  2893. #define mp_unary_op(op, obj) (mp_fun_table.unary_op((op), (obj)))
  2894. #define mp_binary_op(op, lhs, rhs) (mp_fun_table.binary_op((op), (lhs), (rhs)))
  2895. -#define mp_make_function_from_raw_code(rc, context, def_args) \
  2896. - (mp_fun_table.make_function_from_raw_code((rc), (context), (def_args)))
  2897. +#define mp_make_function_from_proto_fun(rc, context, def_args) \
  2898. + (mp_fun_table.make_function_from_proto_fun((rc), (context), (def_args)))
  2899. #define mp_call_function_n_kw(fun, n_args, n_kw, args) \
  2900. (mp_fun_table.call_function_n_kw((fun), (n_args) | ((n_kw) << 8), args))
  2901. @@ -207,9 +212,11 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
  2902. #define MP_DYNRUNTIME_INIT_ENTRY \
  2903. mp_obj_t old_globals = mp_fun_table.swap_globals(self->context->module.globals); \
  2904. - mp_raw_code_t rc; \
  2905. + mp_raw_code_truncated_t rc; \
  2906. + rc.proto_fun_indicator[0] = MP_PROTO_FUN_INDICATOR_RAW_CODE_0; \
  2907. + rc.proto_fun_indicator[1] = MP_PROTO_FUN_INDICATOR_RAW_CODE_1; \
  2908. rc.kind = MP_CODE_NATIVE_VIPER; \
  2909. - rc.scope_flags = 0; \
  2910. + rc.is_generator = 0; \
  2911. (void)rc;
  2912. #define MP_DYNRUNTIME_INIT_EXIT \
  2913. @@ -217,7 +224,7 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
  2914. return mp_const_none;
  2915. #define MP_DYNRUNTIME_MAKE_FUNCTION(f) \
  2916. - (mp_make_function_from_raw_code((rc.fun_data = (f), &rc), self->context, NULL))
  2917. + (mp_make_function_from_proto_fun((rc.fun_data = (f), (const mp_raw_code_t *)&rc), self->context, NULL))
  2918. #define mp_import_name(name, fromlist, level) \
  2919. (mp_fun_table.import_name((name), (fromlist), (level)))
  2920. diff --git a/py/emitbc.c b/py/emitbc.c
  2921. index a07657408..05754cfab 100644
  2922. --- a/py/emitbc.c
  2923. +++ b/py/emitbc.c
  2924. @@ -92,7 +92,7 @@ void emit_bc_free(emit_t *emit) {
  2925. }
  2926. // all functions must go through this one to emit code info
  2927. -STATIC uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_to_write) {
  2928. +static uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_to_write) {
  2929. emit_t *emit = emit_in;
  2930. if (emit->pass < MP_PASS_EMIT) {
  2931. emit->code_info_offset += num_bytes_to_write;
  2932. @@ -105,16 +105,16 @@ STATIC uint8_t *emit_get_cur_to_write_code_info(void *emit_in, size_t num_bytes_
  2933. }
  2934. }
  2935. -STATIC void emit_write_code_info_byte(emit_t *emit, byte val) {
  2936. +static void emit_write_code_info_byte(emit_t *emit, byte val) {
  2937. *emit_get_cur_to_write_code_info(emit, 1) = val;
  2938. }
  2939. -STATIC void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
  2940. +static void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
  2941. mp_encode_uint(emit, emit_get_cur_to_write_code_info, mp_emit_common_use_qstr(emit->emit_common, qst));
  2942. }
  2943. #if MICROPY_ENABLE_SOURCE_LINE
  2944. -STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) {
  2945. +static void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) {
  2946. assert(bytes_to_skip > 0 || lines_to_skip > 0);
  2947. while (bytes_to_skip > 0 || lines_to_skip > 0) {
  2948. mp_uint_t b, l;
  2949. @@ -143,7 +143,7 @@ STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_sk
  2950. #endif
  2951. // all functions must go through this one to emit byte code
  2952. -STATIC uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_to_write) {
  2953. +static uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_to_write) {
  2954. emit_t *emit = emit_in;
  2955. if (emit->suppress) {
  2956. return emit->dummy_data;
  2957. @@ -159,19 +159,19 @@ STATIC uint8_t *emit_get_cur_to_write_bytecode(void *emit_in, size_t num_bytes_t
  2958. }
  2959. }
  2960. -STATIC void emit_write_bytecode_raw_byte(emit_t *emit, byte b1) {
  2961. +static void emit_write_bytecode_raw_byte(emit_t *emit, byte b1) {
  2962. byte *c = emit_get_cur_to_write_bytecode(emit, 1);
  2963. c[0] = b1;
  2964. }
  2965. -STATIC void emit_write_bytecode_byte(emit_t *emit, int stack_adj, byte b1) {
  2966. +static void emit_write_bytecode_byte(emit_t *emit, int stack_adj, byte b1) {
  2967. mp_emit_bc_adjust_stack_size(emit, stack_adj);
  2968. byte *c = emit_get_cur_to_write_bytecode(emit, 1);
  2969. c[0] = b1;
  2970. }
  2971. // Similar to mp_encode_uint(), just some extra handling to encode sign
  2972. -STATIC void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, mp_int_t num) {
  2973. +static void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, mp_int_t num) {
  2974. emit_write_bytecode_byte(emit, stack_adj, b1);
  2975. // We store each 7 bits in a separate byte, and that's how many bytes needed
  2976. @@ -197,24 +197,24 @@ STATIC void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, byte b1, m
  2977. *c = *p;
  2978. }
  2979. -STATIC void emit_write_bytecode_byte_uint(emit_t *emit, int stack_adj, byte b, mp_uint_t val) {
  2980. +static void emit_write_bytecode_byte_uint(emit_t *emit, int stack_adj, byte b, mp_uint_t val) {
  2981. emit_write_bytecode_byte(emit, stack_adj, b);
  2982. mp_encode_uint(emit, emit_get_cur_to_write_bytecode, val);
  2983. }
  2984. -STATIC void emit_write_bytecode_byte_const(emit_t *emit, int stack_adj, byte b, mp_uint_t n) {
  2985. +static void emit_write_bytecode_byte_const(emit_t *emit, int stack_adj, byte b, mp_uint_t n) {
  2986. emit_write_bytecode_byte_uint(emit, stack_adj, b, n);
  2987. }
  2988. -STATIC void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, byte b, qstr qst) {
  2989. +static void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, byte b, qstr qst) {
  2990. emit_write_bytecode_byte_uint(emit, stack_adj, b, mp_emit_common_use_qstr(emit->emit_common, qst));
  2991. }
  2992. -STATIC void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, byte b, mp_obj_t obj) {
  2993. +static void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, byte b, mp_obj_t obj) {
  2994. emit_write_bytecode_byte_const(emit, stack_adj, b, mp_emit_common_use_const_obj(emit->emit_common, obj));
  2995. }
  2996. -STATIC void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b, mp_raw_code_t *rc) {
  2997. +static void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b, mp_raw_code_t *rc) {
  2998. emit_write_bytecode_byte_const(emit, stack_adj, b,
  2999. mp_emit_common_alloc_const_child(emit->emit_common, rc));
  3000. #if MICROPY_PY_SYS_SETTRACE
  3001. @@ -227,7 +227,7 @@ STATIC void emit_write_bytecode_byte_child(emit_t *emit, int stack_adj, byte b,
  3002. // The offset is encoded as either 1 or 2 bytes, depending on how big it is.
  3003. // The encoding of this jump opcode can change size from one pass to the next,
  3004. // but it must only ever decrease in size on successive passes.
  3005. -STATIC void emit_write_bytecode_byte_label(emit_t *emit, int stack_adj, byte b1, mp_uint_t label) {
  3006. +static void emit_write_bytecode_byte_label(emit_t *emit, int stack_adj, byte b1, mp_uint_t label) {
  3007. mp_emit_bc_adjust_stack_size(emit, stack_adj);
  3008. if (emit->suppress) {
  3009. @@ -393,13 +393,18 @@ bool mp_emit_bc_end_pass(emit_t *emit) {
  3010. mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("bytecode overflow"));
  3011. }
  3012. + #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  3013. + size_t bytecode_len = emit->code_info_size + emit->bytecode_size;
  3014. + #if MICROPY_DEBUG_PRINTERS
  3015. + emit->scope->raw_code_data_len = bytecode_len;
  3016. + #endif
  3017. + #endif
  3018. +
  3019. // Bytecode is finalised, assign it to the raw code object.
  3020. mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base,
  3021. - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  3022. - emit->code_info_size + emit->bytecode_size,
  3023. - #endif
  3024. emit->emit_common->children,
  3025. #if MICROPY_PERSISTENT_CODE_SAVE
  3026. + bytecode_len,
  3027. emit->emit_common->ct_cur_child,
  3028. #endif
  3029. emit->scope->scope_flags);
  3030. @@ -443,7 +448,6 @@ void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) {
  3031. // should be emitted (until another unconditional flow control).
  3032. emit->suppress = false;
  3033. - mp_emit_bc_adjust_stack_size(emit, 0);
  3034. if (emit->pass == MP_PASS_SCOPE) {
  3035. return;
  3036. }
  3037. @@ -764,7 +768,7 @@ void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_ov
  3038. }
  3039. }
  3040. -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) {
  3041. +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) {
  3042. if (star_flags) {
  3043. // each positional arg is one object, each kwarg is two objects, the key
  3044. // and the value and one extra object for the star args bitmap.
  3045. diff --git a/py/emitglue.c b/py/emitglue.c
  3046. index 6ec6d6b88..6b6d5ccba 100644
  3047. --- a/py/emitglue.c
  3048. +++ b/py/emitglue.c
  3049. @@ -61,24 +61,20 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
  3050. }
  3051. void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
  3052. - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  3053. - size_t len,
  3054. - #endif
  3055. mp_raw_code_t **children,
  3056. #if MICROPY_PERSISTENT_CODE_SAVE
  3057. - size_t n_children,
  3058. + size_t len,
  3059. + uint16_t n_children,
  3060. #endif
  3061. - mp_uint_t scope_flags) {
  3062. + uint16_t scope_flags) {
  3063. rc->kind = MP_CODE_BYTECODE;
  3064. - rc->scope_flags = scope_flags;
  3065. + rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
  3066. rc->fun_data = code;
  3067. - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  3068. - rc->fun_data_len = len;
  3069. - #endif
  3070. rc->children = children;
  3071. #if MICROPY_PERSISTENT_CODE_SAVE
  3072. + rc->fun_data_len = len;
  3073. rc->n_children = n_children;
  3074. #endif
  3075. @@ -88,7 +84,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
  3076. #endif
  3077. #if DEBUG_PRINT
  3078. - #if !(MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS)
  3079. + #if !MICROPY_PERSISTENT_CODE_SAVE
  3080. const size_t len = 0;
  3081. #endif
  3082. DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags);
  3083. @@ -96,13 +92,14 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
  3084. }
  3085. #if MICROPY_EMIT_MACHINE_CODE
  3086. -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,
  3087. +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,
  3088. mp_raw_code_t **children,
  3089. #if MICROPY_PERSISTENT_CODE_SAVE
  3090. - size_t n_children,
  3091. + uint16_t n_children,
  3092. uint16_t prelude_offset,
  3093. #endif
  3094. - mp_uint_t scope_flags, mp_uint_t n_pos_args, mp_uint_t type_sig) {
  3095. + uint16_t scope_flags, uint32_t asm_n_pos_args, uint32_t asm_type_sig
  3096. + ) {
  3097. assert(kind == MP_CODE_NATIVE_PY || kind == MP_CODE_NATIVE_VIPER || kind == MP_CODE_NATIVE_ASM);
  3098. @@ -118,7 +115,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
  3099. #endif
  3100. #elif MICROPY_EMIT_ARM
  3101. #if (defined(__linux__) && defined(__GNUC__)) || __ARM_ARCH == 7
  3102. - __builtin___clear_cache(fun_data, (uint8_t *)fun_data + fun_len);
  3103. + __builtin___clear_cache((void *)fun_data, (uint8_t *)fun_data + fun_len);
  3104. #elif defined(__arm__)
  3105. // Flush I-cache and D-cache.
  3106. asm volatile (
  3107. @@ -132,10 +129,10 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
  3108. #endif
  3109. rc->kind = kind;
  3110. - rc->scope_flags = scope_flags;
  3111. + rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
  3112. rc->fun_data = fun_data;
  3113. - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  3114. + #if MICROPY_PERSISTENT_CODE_SAVE
  3115. rc->fun_data_len = fun_len;
  3116. #endif
  3117. rc->children = children;
  3118. @@ -145,17 +142,19 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
  3119. rc->prelude_offset = prelude_offset;
  3120. #endif
  3121. + #if MICROPY_EMIT_INLINE_ASM
  3122. // These two entries are only needed for MP_CODE_NATIVE_ASM.
  3123. - rc->n_pos_args = n_pos_args;
  3124. - rc->type_sig = type_sig;
  3125. + rc->asm_n_pos_args = asm_n_pos_args;
  3126. + rc->asm_type_sig = asm_type_sig;
  3127. + #endif
  3128. #if DEBUG_PRINT
  3129. - 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);
  3130. + DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, (uint)scope_flags);
  3131. for (mp_uint_t i = 0; i < fun_len; i++) {
  3132. if (i > 0 && i % 16 == 0) {
  3133. DEBUG_printf("\n");
  3134. }
  3135. - DEBUG_printf(" %02x", ((byte *)fun_data)[i]);
  3136. + DEBUG_printf(" %02x", ((const byte *)fun_data)[i]);
  3137. }
  3138. DEBUG_printf("\n");
  3139. @@ -170,9 +169,9 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
  3140. }
  3141. #endif
  3142. -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) {
  3143. - DEBUG_OP_printf("make_function_from_raw_code %p\n", rc);
  3144. - assert(rc != NULL);
  3145. +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) {
  3146. + DEBUG_OP_printf("make_function_from_proto_fun %p\n", proto_fun);
  3147. + assert(proto_fun != NULL);
  3148. // def_args must be MP_OBJ_NULL or a tuple
  3149. assert(def_args == NULL || def_args[0] == MP_OBJ_NULL || mp_obj_is_type(def_args[0], &mp_type_tuple));
  3150. @@ -180,22 +179,39 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
  3151. // def_kw_args must be MP_OBJ_NULL or a dict
  3152. assert(def_args == NULL || def_args[1] == MP_OBJ_NULL || mp_obj_is_type(def_args[1], &mp_type_dict));
  3153. + #if MICROPY_MODULE_FROZEN_MPY
  3154. + if (mp_proto_fun_is_bytecode(proto_fun)) {
  3155. + const uint8_t *bc = proto_fun;
  3156. + mp_obj_t fun = mp_obj_new_fun_bc(def_args, bc, context, NULL);
  3157. + MP_BC_PRELUDE_SIG_DECODE(bc);
  3158. + if (scope_flags & MP_SCOPE_FLAG_GENERATOR) {
  3159. + ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
  3160. + }
  3161. + return fun;
  3162. + }
  3163. + #endif
  3164. +
  3165. + // the proto-function is a mp_raw_code_t
  3166. + const mp_raw_code_t *rc = proto_fun;
  3167. +
  3168. // make the function, depending on the raw code kind
  3169. mp_obj_t fun;
  3170. switch (rc->kind) {
  3171. #if MICROPY_EMIT_NATIVE
  3172. case MP_CODE_NATIVE_PY:
  3173. - case MP_CODE_NATIVE_VIPER:
  3174. fun = mp_obj_new_fun_native(def_args, rc->fun_data, context, rc->children);
  3175. // Check for a generator function, and if so change the type of the object
  3176. - if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
  3177. + if (rc->is_generator) {
  3178. ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_gen_wrap;
  3179. }
  3180. break;
  3181. + case MP_CODE_NATIVE_VIPER:
  3182. + fun = mp_obj_new_fun_viper(rc->fun_data, context, rc->children);
  3183. + break;
  3184. #endif
  3185. #if MICROPY_EMIT_INLINE_ASM
  3186. case MP_CODE_NATIVE_ASM:
  3187. - fun = mp_obj_new_fun_asm(rc->n_pos_args, rc->fun_data, rc->type_sig);
  3188. + fun = mp_obj_new_fun_asm(rc->asm_n_pos_args, rc->fun_data, rc->asm_type_sig);
  3189. break;
  3190. #endif
  3191. default:
  3192. @@ -203,7 +219,7 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
  3193. assert(rc->kind == MP_CODE_BYTECODE);
  3194. fun = mp_obj_new_fun_bc(def_args, rc->fun_data, context, rc->children);
  3195. // check for generator functions and if so change the type of the object
  3196. - if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
  3197. + if (rc->is_generator) {
  3198. ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
  3199. }
  3200. @@ -218,16 +234,16 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
  3201. return fun;
  3202. }
  3203. -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) {
  3204. - DEBUG_OP_printf("make_closure_from_raw_code %p " UINT_FMT " %p\n", rc, n_closed_over, args);
  3205. +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) {
  3206. + DEBUG_OP_printf("make_closure_from_proto_fun %p " UINT_FMT " %p\n", proto_fun, n_closed_over, args);
  3207. // make function object
  3208. mp_obj_t ffun;
  3209. if (n_closed_over & 0x100) {
  3210. // default positional and keyword args given
  3211. - ffun = mp_make_function_from_raw_code(rc, context, args);
  3212. + ffun = mp_make_function_from_proto_fun(proto_fun, context, args);
  3213. } else {
  3214. // default positional and keyword args not given
  3215. - ffun = mp_make_function_from_raw_code(rc, context, NULL);
  3216. + ffun = mp_make_function_from_proto_fun(proto_fun, context, NULL);
  3217. }
  3218. // wrap function in closure object
  3219. return mp_obj_new_closure(ffun, n_closed_over & 0xff, args + ((n_closed_over >> 7) & 2));
  3220. diff --git a/py/emitglue.h b/py/emitglue.h
  3221. index 4ddf74011..126462671 100644
  3222. --- a/py/emitglue.h
  3223. +++ b/py/emitglue.h
  3224. @@ -31,6 +31,11 @@
  3225. // These variables and functions glue the code emitters to the runtime.
  3226. +// Used with mp_raw_code_t::proto_fun_indicator to detect if a mp_proto_fun_t is a
  3227. +// mp_raw_code_t struct or a direct pointer to bytecode.
  3228. +#define MP_PROTO_FUN_INDICATOR_RAW_CODE_0 (0)
  3229. +#define MP_PROTO_FUN_INDICATOR_RAW_CODE_1 (0)
  3230. +
  3231. // These must fit in 8 bits; see scope.h
  3232. enum {
  3233. MP_EMIT_OPT_NONE,
  3234. @@ -49,58 +54,91 @@ typedef enum {
  3235. MP_CODE_NATIVE_ASM,
  3236. } mp_raw_code_kind_t;
  3237. +// An mp_proto_fun_t points to static information about a non-instantiated function.
  3238. +// A function object is created from this information, and that object can then be executed.
  3239. +// It points either to bytecode, or an mp_raw_code_t struct.
  3240. +typedef const void *mp_proto_fun_t;
  3241. +
  3242. +// Bytecode is distinguished from an mp_raw_code_t struct by the first two bytes: bytecode
  3243. +// is guaranteed to have either its first or second byte non-zero. So if both bytes are
  3244. +// zero then the mp_proto_fun_t pointer must be an mp_raw_code_t.
  3245. +static inline bool mp_proto_fun_is_bytecode(mp_proto_fun_t proto_fun) {
  3246. + const uint8_t *header = (const uint8_t *)proto_fun;
  3247. + return (header[0] | (header[1] << 8)) != (MP_PROTO_FUN_INDICATOR_RAW_CODE_0 | (MP_PROTO_FUN_INDICATOR_RAW_CODE_1 << 8));
  3248. +}
  3249. +
  3250. +// The mp_raw_code_t struct appears in the following places:
  3251. // compiled bytecode: instance in RAM, referenced by outer scope, usually freed after first (and only) use
  3252. // mpy file: instance in RAM, created when .mpy file is loaded (same comments as above)
  3253. // frozen: instance in ROM
  3254. typedef struct _mp_raw_code_t {
  3255. - mp_uint_t kind : 3; // of type mp_raw_code_kind_t
  3256. - mp_uint_t scope_flags : 7;
  3257. - mp_uint_t n_pos_args : 11;
  3258. + uint8_t proto_fun_indicator[2];
  3259. + uint8_t kind; // of type mp_raw_code_kind_t; only 3 bits used
  3260. + bool is_generator;
  3261. const void *fun_data;
  3262. - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  3263. - size_t fun_data_len; // so mp_raw_code_save and mp_bytecode_print work
  3264. - #endif
  3265. struct _mp_raw_code_t **children;
  3266. #if MICROPY_PERSISTENT_CODE_SAVE
  3267. - size_t n_children;
  3268. + uint32_t fun_data_len; // for mp_raw_code_save
  3269. + uint16_t n_children;
  3270. + #if MICROPY_EMIT_MACHINE_CODE
  3271. + uint16_t prelude_offset;
  3272. + #endif
  3273. #if MICROPY_PY_SYS_SETTRACE
  3274. - mp_bytecode_prelude_t prelude;
  3275. // line_of_definition is a Python source line where the raw_code was
  3276. // created e.g. MP_BC_MAKE_FUNCTION. This is different from lineno info
  3277. // stored in prelude, which provides line number for first statement of
  3278. // a function. Required to properly implement "call" trace event.
  3279. - mp_uint_t line_of_definition;
  3280. + uint32_t line_of_definition;
  3281. + mp_bytecode_prelude_t prelude;
  3282. #endif
  3283. + #endif
  3284. + #if MICROPY_EMIT_INLINE_ASM
  3285. + uint32_t asm_n_pos_args : 8;
  3286. + uint32_t asm_type_sig : 24; // compressed as 2-bit types; ret is MSB, then arg0, arg1, etc
  3287. + #endif
  3288. +} mp_raw_code_t;
  3289. +
  3290. +// Version of mp_raw_code_t but without the asm_n_pos_args/asm_type_sig entries, which are
  3291. +// only needed when the kind is MP_CODE_NATIVE_ASM. So this struct can be used when the
  3292. +// kind is MP_CODE_BYTECODE, MP_CODE_NATIVE_PY or MP_CODE_NATIVE_VIPER, to reduce its size.
  3293. +typedef struct _mp_raw_code_truncated_t {
  3294. + uint8_t proto_fun_indicator[2];
  3295. + uint8_t kind;
  3296. + bool is_generator;
  3297. + const void *fun_data;
  3298. + struct _mp_raw_code_t **children;
  3299. + #if MICROPY_PERSISTENT_CODE_SAVE
  3300. + uint32_t fun_data_len;
  3301. + uint16_t n_children;
  3302. #if MICROPY_EMIT_MACHINE_CODE
  3303. uint16_t prelude_offset;
  3304. #endif
  3305. + #if MICROPY_PY_SYS_SETTRACE
  3306. + uint32_t line_of_definition;
  3307. + mp_bytecode_prelude_t prelude;
  3308. #endif
  3309. - #if MICROPY_EMIT_MACHINE_CODE
  3310. - mp_uint_t type_sig; // for viper, compressed as 2-bit types; ret is MSB, then arg0, arg1, etc
  3311. #endif
  3312. -} mp_raw_code_t;
  3313. +} mp_raw_code_truncated_t;
  3314. mp_raw_code_t *mp_emit_glue_new_raw_code(void);
  3315. void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
  3316. - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  3317. - size_t len,
  3318. - #endif
  3319. mp_raw_code_t **children,
  3320. #if MICROPY_PERSISTENT_CODE_SAVE
  3321. - size_t n_children,
  3322. + size_t len,
  3323. + uint16_t n_children,
  3324. #endif
  3325. - mp_uint_t scope_flags);
  3326. + uint16_t scope_flags);
  3327. -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,
  3328. +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,
  3329. mp_raw_code_t **children,
  3330. #if MICROPY_PERSISTENT_CODE_SAVE
  3331. - size_t n_children,
  3332. + uint16_t n_children,
  3333. uint16_t prelude_offset,
  3334. #endif
  3335. - mp_uint_t scope_flags, mp_uint_t n_pos_args, mp_uint_t type_sig);
  3336. + uint16_t scope_flags, uint32_t asm_n_pos_args, uint32_t asm_type_sig);
  3337. -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);
  3338. -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);
  3339. +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);
  3340. +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);
  3341. #endif // MICROPY_INCLUDED_PY_EMITGLUE_H
  3342. diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
  3343. index 29487f104..7818bb4f4 100644
  3344. --- a/py/emitinlinethumb.c
  3345. +++ b/py/emitinlinethumb.c
  3346. @@ -74,11 +74,11 @@ static inline bool emit_inline_thumb_allow_float(emit_inline_asm_t *emit) {
  3347. #endif
  3348. -STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
  3349. +static void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
  3350. *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
  3351. }
  3352. -STATIC void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
  3353. +static void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
  3354. *emit->error_slot = exc;
  3355. }
  3356. @@ -97,7 +97,7 @@ void emit_inline_thumb_free(emit_inline_asm_t *emit) {
  3357. m_del_obj(emit_inline_asm_t, emit);
  3358. }
  3359. -STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
  3360. +static void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
  3361. emit->pass = pass;
  3362. emit->error_slot = error_slot;
  3363. if (emit->pass == MP_PASS_CODE_SIZE) {
  3364. @@ -107,12 +107,12 @@ STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_kind_t pa
  3365. asm_thumb_entry(&emit->as, 0);
  3366. }
  3367. -STATIC void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
  3368. +static void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
  3369. asm_thumb_exit(&emit->as);
  3370. asm_thumb_end_pass(&emit->as);
  3371. }
  3372. -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) {
  3373. +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) {
  3374. if (n_params > 4) {
  3375. emit_inline_thumb_error_msg(emit, MP_ERROR_TEXT("can only have up to 4 parameters to Thumb assembly"));
  3376. return 0;
  3377. @@ -131,7 +131,7 @@ STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit, mp_uint
  3378. return n_params;
  3379. }
  3380. -STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
  3381. +static bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
  3382. assert(label_num < emit->max_num_labels);
  3383. if (emit->pass == MP_PASS_CODE_SIZE) {
  3384. // check for duplicate label on first pass
  3385. @@ -149,7 +149,7 @@ STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t label_num
  3386. typedef struct _reg_name_t { byte reg;
  3387. byte name[3];
  3388. } reg_name_t;
  3389. -STATIC const reg_name_t reg_name_table[] = {
  3390. +static const reg_name_t reg_name_table[] = {
  3391. {0, "r0\0"},
  3392. {1, "r1\0"},
  3393. {2, "r2\0"},
  3394. @@ -177,14 +177,14 @@ STATIC const reg_name_t reg_name_table[] = {
  3395. typedef struct _special_reg_name_t { byte reg;
  3396. char name[MAX_SPECIAL_REGISTER_NAME_LENGTH + 1];
  3397. } special_reg_name_t;
  3398. -STATIC const special_reg_name_t special_reg_name_table[] = {
  3399. +static const special_reg_name_t special_reg_name_table[] = {
  3400. {5, "IPSR"},
  3401. {17, "BASEPRI"},
  3402. };
  3403. // return empty string in case of error, so we can attempt to parse the string
  3404. // without a special check if it was in fact a string
  3405. -STATIC const char *get_arg_str(mp_parse_node_t pn) {
  3406. +static const char *get_arg_str(mp_parse_node_t pn) {
  3407. if (MP_PARSE_NODE_IS_ID(pn)) {
  3408. qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
  3409. return qstr_str(qst);
  3410. @@ -193,7 +193,7 @@ STATIC const char *get_arg_str(mp_parse_node_t pn) {
  3411. }
  3412. }
  3413. -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) {
  3414. +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) {
  3415. const char *reg_str = get_arg_str(pn);
  3416. for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
  3417. const reg_name_t *r = &reg_name_table[i];
  3418. @@ -217,7 +217,7 @@ STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_n
  3419. return 0;
  3420. }
  3421. -STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3422. +static mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3423. const char *reg_str = get_arg_str(pn);
  3424. for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(special_reg_name_table); i++) {
  3425. const special_reg_name_t *r = &special_reg_name_table[i];
  3426. @@ -231,7 +231,7 @@ STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char *op, mp
  3427. return 0;
  3428. }
  3429. -STATIC mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3430. +static mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3431. const char *reg_str = get_arg_str(pn);
  3432. if (reg_str[0] == 's' && reg_str[1] != '\0') {
  3433. mp_uint_t regno = 0;
  3434. @@ -258,7 +258,7 @@ malformed:
  3435. return 0;
  3436. }
  3437. -STATIC mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3438. +static mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3439. // a register list looks like {r0, r1, r2} and is parsed as a Python set
  3440. if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_brace)) {
  3441. @@ -310,7 +310,7 @@ bad_arg:
  3442. return 0;
  3443. }
  3444. -STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) {
  3445. +static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, uint32_t fit_mask) {
  3446. mp_obj_t o;
  3447. if (!mp_parse_node_get_int_maybe(pn, &o)) {
  3448. emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects an integer"), op));
  3449. @@ -324,7 +324,7 @@ STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
  3450. return i;
  3451. }
  3452. -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) {
  3453. +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) {
  3454. if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_bracket)) {
  3455. goto bad_arg;
  3456. }
  3457. @@ -346,7 +346,7 @@ bad_arg:
  3458. return false;
  3459. }
  3460. -STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3461. +static int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3462. if (!MP_PARSE_NODE_IS_ID(pn)) {
  3463. emit_inline_thumb_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects a label"), op));
  3464. return 0;
  3465. @@ -367,7 +367,7 @@ STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_
  3466. typedef struct _cc_name_t { byte cc;
  3467. byte name[2];
  3468. } cc_name_t;
  3469. -STATIC const cc_name_t cc_name_table[] = {
  3470. +static const cc_name_t cc_name_table[] = {
  3471. { ASM_THUMB_CC_EQ, "eq" },
  3472. { ASM_THUMB_CC_NE, "ne" },
  3473. { ASM_THUMB_CC_CS, "cs" },
  3474. @@ -388,7 +388,7 @@ typedef struct _format_4_op_t { byte op;
  3475. char name[3];
  3476. } format_4_op_t;
  3477. #define X(x) (((x) >> 4) & 0xff) // only need 1 byte to distinguish these ops
  3478. -STATIC const format_4_op_t format_4_op_table[] = {
  3479. +static const format_4_op_t format_4_op_table[] = {
  3480. { X(ASM_THUMB_FORMAT_4_EOR), "eor" },
  3481. { X(ASM_THUMB_FORMAT_4_LSL), "lsl" },
  3482. { X(ASM_THUMB_FORMAT_4_LSR), "lsr" },
  3483. @@ -412,7 +412,7 @@ typedef struct _format_9_10_op_t { uint16_t op;
  3484. uint16_t name;
  3485. } format_9_10_op_t;
  3486. #define X(x) (x)
  3487. -STATIC const format_9_10_op_t format_9_10_op_table[] = {
  3488. +static const format_9_10_op_t format_9_10_op_table[] = {
  3489. { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_ldr },
  3490. { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER), MP_QSTR_ldrb },
  3491. { X(ASM_THUMB_FORMAT_10_LDRH), MP_QSTR_ldrh },
  3492. @@ -427,7 +427,7 @@ typedef struct _format_vfp_op_t {
  3493. byte op;
  3494. char name[3];
  3495. } format_vfp_op_t;
  3496. -STATIC const format_vfp_op_t format_vfp_op_table[] = {
  3497. +static const format_vfp_op_t format_vfp_op_table[] = {
  3498. { 0x30, "add" },
  3499. { 0x34, "sub" },
  3500. { 0x20, "mul" },
  3501. @@ -437,7 +437,7 @@ STATIC const format_vfp_op_t format_vfp_op_table[] = {
  3502. // shorthand alias for whether we allow ARMv7-M instructions
  3503. #define ARMV7M asm_thumb_allow_armv7m(&emit->as)
  3504. -STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
  3505. +static void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
  3506. // TODO perhaps make two tables:
  3507. // one_args =
  3508. // "b", LAB, asm_thumb_b_n,
  3509. diff --git a/py/emitinlinextensa.c b/py/emitinlinextensa.c
  3510. index 5dac2ae39..57056d597 100644
  3511. --- a/py/emitinlinextensa.c
  3512. +++ b/py/emitinlinextensa.c
  3513. @@ -43,11 +43,11 @@ struct _emit_inline_asm_t {
  3514. qstr *label_lookup;
  3515. };
  3516. -STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
  3517. +static void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
  3518. *emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
  3519. }
  3520. -STATIC void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
  3521. +static void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj_t exc) {
  3522. *emit->error_slot = exc;
  3523. }
  3524. @@ -66,7 +66,7 @@ void emit_inline_xtensa_free(emit_inline_asm_t *emit) {
  3525. m_del_obj(emit_inline_asm_t, emit);
  3526. }
  3527. -STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
  3528. +static void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t pass, mp_obj_t *error_slot) {
  3529. emit->pass = pass;
  3530. emit->error_slot = error_slot;
  3531. if (emit->pass == MP_PASS_CODE_SIZE) {
  3532. @@ -76,12 +76,12 @@ STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_kind_t p
  3533. asm_xtensa_entry(&emit->as, 0);
  3534. }
  3535. -STATIC void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
  3536. +static void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint_t type_sig) {
  3537. asm_xtensa_exit(&emit->as);
  3538. asm_xtensa_end_pass(&emit->as);
  3539. }
  3540. -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) {
  3541. +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) {
  3542. if (n_params > 4) {
  3543. emit_inline_xtensa_error_msg(emit, MP_ERROR_TEXT("can only have up to 4 parameters to Xtensa assembly"));
  3544. return 0;
  3545. @@ -100,7 +100,7 @@ STATIC mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit, mp_uin
  3546. return n_params;
  3547. }
  3548. -STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
  3549. +static bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id) {
  3550. assert(label_num < emit->max_num_labels);
  3551. if (emit->pass == MP_PASS_CODE_SIZE) {
  3552. // check for duplicate label on first pass
  3553. @@ -118,7 +118,7 @@ STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t label_nu
  3554. typedef struct _reg_name_t { byte reg;
  3555. byte name[3];
  3556. } reg_name_t;
  3557. -STATIC const reg_name_t reg_name_table[] = {
  3558. +static const reg_name_t reg_name_table[] = {
  3559. {0, "a0\0"},
  3560. {1, "a1\0"},
  3561. {2, "a2\0"},
  3562. @@ -139,7 +139,7 @@ STATIC const reg_name_t reg_name_table[] = {
  3563. // return empty string in case of error, so we can attempt to parse the string
  3564. // without a special check if it was in fact a string
  3565. -STATIC const char *get_arg_str(mp_parse_node_t pn) {
  3566. +static const char *get_arg_str(mp_parse_node_t pn) {
  3567. if (MP_PARSE_NODE_IS_ID(pn)) {
  3568. qstr qst = MP_PARSE_NODE_LEAF_ARG(pn);
  3569. return qstr_str(qst);
  3570. @@ -148,7 +148,7 @@ STATIC const char *get_arg_str(mp_parse_node_t pn) {
  3571. }
  3572. }
  3573. -STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3574. +static mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3575. const char *reg_str = get_arg_str(pn);
  3576. for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
  3577. const reg_name_t *r = &reg_name_table[i];
  3578. @@ -165,7 +165,7 @@ STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_n
  3579. return 0;
  3580. }
  3581. -STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) {
  3582. +static uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn, int min, int max) {
  3583. mp_obj_t o;
  3584. if (!mp_parse_node_get_int_maybe(pn, &o)) {
  3585. emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects an integer"), op));
  3586. @@ -179,7 +179,7 @@ STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_parse_node
  3587. return i;
  3588. }
  3589. -STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3590. +static int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_parse_node_t pn) {
  3591. if (!MP_PARSE_NODE_IS_ID(pn)) {
  3592. emit_inline_xtensa_error_exc(emit, mp_obj_new_exception_msg_varg(&mp_type_SyntaxError, MP_ERROR_TEXT("'%s' expects a label"), op));
  3593. return 0;
  3594. @@ -208,7 +208,7 @@ typedef struct _opcode_table_3arg_t {
  3595. uint8_t a1 : 4;
  3596. } opcode_table_3arg_t;
  3597. -STATIC const opcode_table_3arg_t opcode_table_3arg[] = {
  3598. +static const opcode_table_3arg_t opcode_table_3arg[] = {
  3599. // arithmetic opcodes: reg, reg, reg
  3600. {MP_QSTR_and_, RRR, 0, 1},
  3601. {MP_QSTR_or_, RRR, 0, 2},
  3602. @@ -242,7 +242,7 @@ STATIC const opcode_table_3arg_t opcode_table_3arg[] = {
  3603. {MP_QSTR_bnone, RRI8_B, ASM_XTENSA_CC_NONE, 0},
  3604. };
  3605. -STATIC void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
  3606. +static void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
  3607. size_t op_len;
  3608. const char *op_str = (const char *)qstr_data(op, &op_len);
  3609. diff --git a/py/emitnative.c b/py/emitnative.c
  3610. index e6357b3f9..0b84a2ec8 100644
  3611. --- a/py/emitnative.c
  3612. +++ b/py/emitnative.c
  3613. @@ -156,7 +156,7 @@
  3614. #define REG_QSTR_TABLE (REG_LOCAL_3)
  3615. #define MAX_REGS_FOR_LOCAL_VARS (2)
  3616. -STATIC const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2};
  3617. +static const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2};
  3618. #else
  3619. @@ -168,7 +168,7 @@ STATIC const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, RE
  3620. #define REG_GENERATOR_STATE (REG_LOCAL_3)
  3621. #define MAX_REGS_FOR_LOCAL_VARS (3)
  3622. -STATIC const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2, REG_LOCAL_3};
  3623. +static const uint8_t reg_local_table[MAX_REGS_FOR_LOCAL_VARS] = {REG_LOCAL_1, REG_LOCAL_2, REG_LOCAL_3};
  3624. #endif
  3625. @@ -202,7 +202,7 @@ typedef enum {
  3626. VTYPE_BUILTIN_CAST = 0x70 | MP_NATIVE_TYPE_OBJ,
  3627. } vtype_kind_t;
  3628. -STATIC qstr vtype_to_qstr(vtype_kind_t vtype) {
  3629. +static qstr vtype_to_qstr(vtype_kind_t vtype) {
  3630. switch (vtype) {
  3631. case VTYPE_PYOBJ:
  3632. return MP_QSTR_object;
  3633. @@ -253,7 +253,6 @@ struct _emit_t {
  3634. int pass;
  3635. bool do_viper_types;
  3636. - bool prelude_offset_uses_u16_encoding;
  3637. mp_uint_t local_vtype_alloc;
  3638. vtype_kind_t *local_vtype;
  3639. @@ -281,10 +280,10 @@ struct _emit_t {
  3640. ASM_T *as;
  3641. };
  3642. -STATIC void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj);
  3643. -STATIC void emit_native_global_exc_entry(emit_t *emit);
  3644. -STATIC void emit_native_global_exc_exit(emit_t *emit);
  3645. -STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj);
  3646. +static void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj);
  3647. +static void emit_native_global_exc_entry(emit_t *emit);
  3648. +static void emit_native_global_exc_exit(emit_t *emit);
  3649. +static void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj);
  3650. 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) {
  3651. emit_t *emit = m_new0(emit_t, 1);
  3652. @@ -309,13 +308,13 @@ void EXPORT_FUN(free)(emit_t * emit) {
  3653. m_del_obj(emit_t, emit);
  3654. }
  3655. -STATIC void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg);
  3656. +static void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg);
  3657. -STATIC void emit_native_mov_reg_const(emit_t *emit, int reg_dest, int const_val) {
  3658. +static void emit_native_mov_reg_const(emit_t *emit, int reg_dest, int const_val) {
  3659. ASM_LOAD_REG_REG_OFFSET(emit->as, reg_dest, REG_FUN_TABLE, const_val);
  3660. }
  3661. -STATIC void emit_native_mov_state_reg(emit_t *emit, int local_num, int reg_src) {
  3662. +static void emit_native_mov_state_reg(emit_t *emit, int local_num, int reg_src) {
  3663. if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
  3664. ASM_STORE_REG_REG_OFFSET(emit->as, reg_src, REG_GENERATOR_STATE, local_num);
  3665. } else {
  3666. @@ -323,7 +322,7 @@ STATIC void emit_native_mov_state_reg(emit_t *emit, int local_num, int reg_src)
  3667. }
  3668. }
  3669. -STATIC void emit_native_mov_reg_state(emit_t *emit, int reg_dest, int local_num) {
  3670. +static void emit_native_mov_reg_state(emit_t *emit, int reg_dest, int local_num) {
  3671. if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
  3672. ASM_LOAD_REG_REG_OFFSET(emit->as, reg_dest, REG_GENERATOR_STATE, local_num);
  3673. } else {
  3674. @@ -331,7 +330,7 @@ STATIC void emit_native_mov_reg_state(emit_t *emit, int reg_dest, int local_num)
  3675. }
  3676. }
  3677. -STATIC void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, int local_num) {
  3678. +static void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, int local_num) {
  3679. if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
  3680. ASM_MOV_REG_IMM(emit->as, reg_dest, local_num * ASM_WORD_SIZE);
  3681. ASM_ADD_REG_REG(emit->as, reg_dest, REG_GENERATOR_STATE);
  3682. @@ -340,7 +339,7 @@ STATIC void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, int local
  3683. }
  3684. }
  3685. -STATIC void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
  3686. +static void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
  3687. #if MICROPY_PERSISTENT_CODE_SAVE
  3688. ASM_LOAD16_REG_REG_OFFSET(emit->as, arg_reg, REG_QSTR_TABLE, mp_emit_common_use_qstr(emit->emit_common, qst));
  3689. #else
  3690. @@ -348,7 +347,7 @@ STATIC void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
  3691. #endif
  3692. }
  3693. -STATIC void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qstr qst) {
  3694. +static void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qstr qst) {
  3695. #if MICROPY_PERSISTENT_CODE_SAVE
  3696. emit_load_reg_with_object(emit, reg_dest, MP_OBJ_NEW_QSTR(qst));
  3697. #else
  3698. @@ -362,7 +361,7 @@ STATIC void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qstr qst) {
  3699. emit_native_mov_state_reg((emit), (local_num), (reg_temp)); \
  3700. } while (false)
  3701. -STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
  3702. +static void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
  3703. DEBUG_printf("start_pass(pass=%u, scope=%p)\n", pass, scope);
  3704. emit->pass = pass;
  3705. @@ -519,8 +518,11 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
  3706. // work out size of state (locals plus stack)
  3707. emit->n_state = scope->num_locals + scope->stack_size;
  3708. + // Store in the first machine-word an index used to the function's prelude.
  3709. + // This is used at runtime by mp_obj_fun_native_get_prelude_ptr().
  3710. + mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (uintptr_t)emit->prelude_ptr_index);
  3711. +
  3712. if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
  3713. - mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (uintptr_t)emit->prelude_ptr_index);
  3714. mp_asm_base_data(&emit->as->base, ASM_WORD_SIZE, (uintptr_t)emit->start_offset);
  3715. ASM_ENTRY(emit->as, emit->code_state_start);
  3716. @@ -576,15 +578,6 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
  3717. // Set code_state.fun_bc
  3718. ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_FUN_OBJ(emit), REG_PARENT_ARG_1);
  3719. - // Set code_state.ip, a pointer to the beginning of the prelude. This pointer is found
  3720. - // either directly in mp_obj_fun_bc_t.child_table (if there are no children), or in
  3721. - // mp_obj_fun_bc_t.child_table[num_children] (if num_children > 0).
  3722. - ASM_LOAD_REG_REG_OFFSET(emit->as, REG_PARENT_ARG_1, REG_PARENT_ARG_1, OFFSETOF_OBJ_FUN_BC_CHILD_TABLE);
  3723. - if (emit->prelude_ptr_index != 0) {
  3724. - ASM_LOAD_REG_REG_OFFSET(emit->as, REG_PARENT_ARG_1, REG_PARENT_ARG_1, emit->prelude_ptr_index);
  3725. - }
  3726. - emit_native_mov_state_reg(emit, emit->code_state_start + OFFSETOF_CODE_STATE_IP, REG_PARENT_ARG_1);
  3727. -
  3728. // Set code_state.n_state (only works on little endian targets due to n_state being uint16_t)
  3729. emit_native_mov_state_imm_via(emit, emit->code_state_start + OFFSETOF_CODE_STATE_N_STATE, emit->n_state, REG_ARG_1);
  3730. @@ -639,7 +632,7 @@ static inline void emit_native_write_code_info_qstr(emit_t *emit, qstr qst) {
  3731. mp_encode_uint(&emit->as->base, mp_asm_base_get_cur_to_write_bytes, mp_emit_common_use_qstr(emit->emit_common, qst));
  3732. }
  3733. -STATIC bool emit_native_end_pass(emit_t *emit) {
  3734. +static bool emit_native_end_pass(emit_t *emit) {
  3735. emit_native_global_exc_exit(emit);
  3736. if (!emit->do_viper_types) {
  3737. @@ -730,7 +723,7 @@ STATIC bool emit_native_end_pass(emit_t *emit) {
  3738. return true;
  3739. }
  3740. -STATIC void ensure_extra_stack(emit_t *emit, size_t delta) {
  3741. +static void ensure_extra_stack(emit_t *emit, size_t delta) {
  3742. if (emit->stack_size + delta > emit->stack_info_alloc) {
  3743. size_t new_alloc = (emit->stack_size + delta + 8) & ~3;
  3744. emit->stack_info = m_renew(stack_info_t, emit->stack_info, emit->stack_info_alloc, new_alloc);
  3745. @@ -738,7 +731,7 @@ STATIC void ensure_extra_stack(emit_t *emit, size_t delta) {
  3746. }
  3747. }
  3748. -STATIC void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) {
  3749. +static void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) {
  3750. assert((mp_int_t)emit->stack_size + stack_size_delta >= 0);
  3751. assert((mp_int_t)emit->stack_size + stack_size_delta <= (mp_int_t)emit->stack_info_alloc);
  3752. emit->stack_size += stack_size_delta;
  3753. @@ -755,7 +748,7 @@ STATIC void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) {
  3754. #endif
  3755. }
  3756. -STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
  3757. +static void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
  3758. DEBUG_printf("adjust_stack_size(" INT_FMT ")\n", delta);
  3759. if (delta > 0) {
  3760. ensure_extra_stack(emit, delta);
  3761. @@ -779,23 +772,23 @@ STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
  3762. adjust_stack(emit, delta);
  3763. }
  3764. -STATIC void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) {
  3765. +static void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) {
  3766. (void)emit;
  3767. (void)source_line;
  3768. }
  3769. // this must be called at start of emit functions
  3770. -STATIC void emit_native_pre(emit_t *emit) {
  3771. +static void emit_native_pre(emit_t *emit) {
  3772. (void)emit;
  3773. }
  3774. // depth==0 is top, depth==1 is before top, etc
  3775. -STATIC stack_info_t *peek_stack(emit_t *emit, mp_uint_t depth) {
  3776. +static stack_info_t *peek_stack(emit_t *emit, mp_uint_t depth) {
  3777. return &emit->stack_info[emit->stack_size - 1 - depth];
  3778. }
  3779. // depth==0 is top, depth==1 is before top, etc
  3780. -STATIC vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) {
  3781. +static vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) {
  3782. if (emit->do_viper_types) {
  3783. return peek_stack(emit, depth)->vtype;
  3784. } else {
  3785. @@ -806,7 +799,7 @@ STATIC vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) {
  3786. // pos=1 is TOS, pos=2 is next, etc
  3787. // use pos=0 for no skipping
  3788. -STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) {
  3789. +static void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) {
  3790. skip_stack_pos = emit->stack_size - skip_stack_pos;
  3791. for (int i = 0; i < emit->stack_size; i++) {
  3792. if (i != skip_stack_pos) {
  3793. @@ -821,7 +814,7 @@ STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) {
  3794. // Ensures all unsettled registers that hold Python values are copied to the
  3795. // concrete Python stack. All registers are then free to use.
  3796. -STATIC void need_reg_all(emit_t *emit) {
  3797. +static void need_reg_all(emit_t *emit) {
  3798. for (int i = 0; i < emit->stack_size; i++) {
  3799. stack_info_t *si = &emit->stack_info[i];
  3800. if (si->kind == STACK_REG) {
  3801. @@ -832,7 +825,7 @@ STATIC void need_reg_all(emit_t *emit) {
  3802. }
  3803. }
  3804. -STATIC vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_info_t *si, bool convert_to_pyobj) {
  3805. +static vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_info_t *si, bool convert_to_pyobj) {
  3806. if (!convert_to_pyobj && emit->do_viper_types) {
  3807. ASM_MOV_REG_IMM(emit->as, reg_dest, si->data.u_imm);
  3808. return si->vtype;
  3809. @@ -856,7 +849,7 @@ STATIC vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_i
  3810. // concrete Python stack. This ensures the concrete Python stack holds valid
  3811. // values for the current stack_size.
  3812. // This function may clobber REG_TEMP1.
  3813. -STATIC void need_stack_settled(emit_t *emit) {
  3814. +static void need_stack_settled(emit_t *emit) {
  3815. DEBUG_printf(" need_stack_settled; stack_size=%d\n", emit->stack_size);
  3816. need_reg_all(emit);
  3817. for (int i = 0; i < emit->stack_size; i++) {
  3818. @@ -872,7 +865,7 @@ STATIC void need_stack_settled(emit_t *emit) {
  3819. }
  3820. // pos=1 is TOS, pos=2 is next, etc
  3821. -STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int reg_dest) {
  3822. +static void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int reg_dest) {
  3823. need_reg_single(emit, reg_dest, pos);
  3824. stack_info_t *si = &emit->stack_info[emit->stack_size - pos];
  3825. *vtype = si->vtype;
  3826. @@ -895,7 +888,7 @@ STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype, int re
  3827. // does an efficient X=pop(); discard(); push(X)
  3828. // needs a (non-temp) register in case the popped element was stored in the stack
  3829. -STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) {
  3830. +static void emit_fold_stack_top(emit_t *emit, int reg_dest) {
  3831. stack_info_t *si = &emit->stack_info[emit->stack_size - 2];
  3832. si[0] = si[1];
  3833. if (si->kind == STACK_VALUE) {
  3834. @@ -909,7 +902,7 @@ STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) {
  3835. // If stacked value is in a register and the register is not r1 or r2, then
  3836. // *reg_dest is set to that register. Otherwise the value is put in *reg_dest.
  3837. -STATIC void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *reg_dest, int not_r1, int not_r2) {
  3838. +static void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *reg_dest, int not_r1, int not_r2) {
  3839. stack_info_t *si = peek_stack(emit, 0);
  3840. if (si->kind == STACK_REG && si->data.u_reg != not_r1 && si->data.u_reg != not_r2) {
  3841. *vtype = si->vtype;
  3842. @@ -921,36 +914,36 @@ STATIC void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype, int *re
  3843. adjust_stack(emit, -1);
  3844. }
  3845. -STATIC void emit_pre_pop_discard(emit_t *emit) {
  3846. +static void emit_pre_pop_discard(emit_t *emit) {
  3847. adjust_stack(emit, -1);
  3848. }
  3849. -STATIC void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest) {
  3850. +static void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_dest) {
  3851. emit_access_stack(emit, 1, vtype, reg_dest);
  3852. adjust_stack(emit, -1);
  3853. }
  3854. -STATIC void emit_pre_pop_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb) {
  3855. +static void emit_pre_pop_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int rega, vtype_kind_t *vtypeb, int regb) {
  3856. emit_pre_pop_reg(emit, vtypea, rega);
  3857. emit_pre_pop_reg(emit, vtypeb, regb);
  3858. }
  3859. -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) {
  3860. +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) {
  3861. emit_pre_pop_reg(emit, vtypea, rega);
  3862. emit_pre_pop_reg(emit, vtypeb, regb);
  3863. emit_pre_pop_reg(emit, vtypec, regc);
  3864. }
  3865. -STATIC void emit_post(emit_t *emit) {
  3866. +static void emit_post(emit_t *emit) {
  3867. (void)emit;
  3868. }
  3869. -STATIC void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) {
  3870. +static void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) {
  3871. stack_info_t *si = &emit->stack_info[emit->stack_size - 1];
  3872. si->vtype = new_vtype;
  3873. }
  3874. -STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) {
  3875. +static void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) {
  3876. ensure_extra_stack(emit, 1);
  3877. stack_info_t *si = &emit->stack_info[emit->stack_size];
  3878. si->vtype = vtype;
  3879. @@ -959,7 +952,7 @@ STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) {
  3880. adjust_stack(emit, 1);
  3881. }
  3882. -STATIC void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) {
  3883. +static void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) {
  3884. ensure_extra_stack(emit, 1);
  3885. stack_info_t *si = &emit->stack_info[emit->stack_size];
  3886. si->vtype = vtype;
  3887. @@ -968,43 +961,43 @@ STATIC void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_t imm) {
  3888. adjust_stack(emit, 1);
  3889. }
  3890. -STATIC void emit_post_push_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb) {
  3891. +static void emit_post_push_reg_reg(emit_t *emit, vtype_kind_t vtypea, int rega, vtype_kind_t vtypeb, int regb) {
  3892. emit_post_push_reg(emit, vtypea, rega);
  3893. emit_post_push_reg(emit, vtypeb, regb);
  3894. }
  3895. -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) {
  3896. +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) {
  3897. emit_post_push_reg(emit, vtypea, rega);
  3898. emit_post_push_reg(emit, vtypeb, regb);
  3899. emit_post_push_reg(emit, vtypec, regc);
  3900. }
  3901. -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) {
  3902. +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) {
  3903. emit_post_push_reg(emit, vtypea, rega);
  3904. emit_post_push_reg(emit, vtypeb, regb);
  3905. emit_post_push_reg(emit, vtypec, regc);
  3906. emit_post_push_reg(emit, vtyped, regd);
  3907. }
  3908. -STATIC void emit_call(emit_t *emit, mp_fun_kind_t fun_kind) {
  3909. +static void emit_call(emit_t *emit, mp_fun_kind_t fun_kind) {
  3910. need_reg_all(emit);
  3911. ASM_CALL_IND(emit->as, fun_kind);
  3912. }
  3913. -STATIC void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) {
  3914. +static void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind, mp_int_t arg_val, int arg_reg) {
  3915. need_reg_all(emit);
  3916. ASM_MOV_REG_IMM(emit->as, arg_reg, arg_val);
  3917. ASM_CALL_IND(emit->as, fun_kind);
  3918. }
  3919. -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) {
  3920. +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) {
  3921. need_reg_all(emit);
  3922. ASM_MOV_REG_IMM(emit->as, arg_reg1, arg_val1);
  3923. ASM_MOV_REG_IMM(emit->as, arg_reg2, arg_val2);
  3924. ASM_CALL_IND(emit->as, fun_kind);
  3925. }
  3926. -STATIC void emit_call_with_qstr_arg(emit_t *emit, mp_fun_kind_t fun_kind, qstr qst, int arg_reg) {
  3927. +static void emit_call_with_qstr_arg(emit_t *emit, mp_fun_kind_t fun_kind, qstr qst, int arg_reg) {
  3928. need_reg_all(emit);
  3929. emit_native_mov_reg_qstr(emit, arg_reg, qst);
  3930. ASM_CALL_IND(emit->as, fun_kind);
  3931. @@ -1014,7 +1007,7 @@ STATIC void emit_call_with_qstr_arg(emit_t *emit, mp_fun_kind_t fun_kind, qstr q
  3932. // Will convert any items that are not VTYPE_PYOBJ to this type and put them back on the stack.
  3933. // If any conversions of non-immediate values are needed, then it uses REG_ARG_1, REG_ARG_2 and REG_RET.
  3934. // Otherwise, it does not use any temporary registers (but may use reg_dest before loading it with stack pointer).
  3935. -STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_pop) {
  3936. +static void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_pop) {
  3937. need_reg_all(emit);
  3938. // First, store any immediate values to their respective place on the stack.
  3939. @@ -1051,7 +1044,7 @@ STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_t reg_de
  3940. }
  3941. // vtype of all n_push objects is VTYPE_PYOBJ
  3942. -STATIC void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_push) {
  3943. +static void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_dest, mp_uint_t n_push) {
  3944. need_reg_all(emit);
  3945. ensure_extra_stack(emit, n_push);
  3946. for (mp_uint_t i = 0; i < n_push; i++) {
  3947. @@ -1062,7 +1055,7 @@ STATIC void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint_t reg_d
  3948. adjust_stack(emit, n_push);
  3949. }
  3950. -STATIC void emit_native_push_exc_stack(emit_t *emit, uint label, bool is_finally) {
  3951. +static void emit_native_push_exc_stack(emit_t *emit, uint label, bool is_finally) {
  3952. if (emit->exc_stack_size + 1 > emit->exc_stack_alloc) {
  3953. size_t new_alloc = emit->exc_stack_alloc + 4;
  3954. emit->exc_stack = m_renew(exc_stack_entry_t, emit->exc_stack, emit->exc_stack_alloc, new_alloc);
  3955. @@ -1079,7 +1072,7 @@ STATIC void emit_native_push_exc_stack(emit_t *emit, uint label, bool is_finally
  3956. ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_RET);
  3957. }
  3958. -STATIC void emit_native_leave_exc_stack(emit_t *emit, bool start_of_handler) {
  3959. +static void emit_native_leave_exc_stack(emit_t *emit, bool start_of_handler) {
  3960. assert(emit->exc_stack_size > 0);
  3961. // Get current exception handler and deactivate it
  3962. @@ -1105,14 +1098,14 @@ STATIC void emit_native_leave_exc_stack(emit_t *emit, bool start_of_handler) {
  3963. ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_PC(emit), REG_RET);
  3964. }
  3965. -STATIC exc_stack_entry_t *emit_native_pop_exc_stack(emit_t *emit) {
  3966. +static exc_stack_entry_t *emit_native_pop_exc_stack(emit_t *emit) {
  3967. assert(emit->exc_stack_size > 0);
  3968. exc_stack_entry_t *e = &emit->exc_stack[--emit->exc_stack_size];
  3969. assert(e->is_active == false);
  3970. return e;
  3971. }
  3972. -STATIC void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj) {
  3973. +static void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj) {
  3974. emit->scope->scope_flags |= MP_SCOPE_FLAG_HASCONSTS;
  3975. size_t table_off = mp_emit_common_use_const_obj(emit->emit_common, obj);
  3976. emit_native_mov_reg_state(emit, REG_TEMP0, LOCAL_IDX_FUN_OBJ(emit));
  3977. @@ -1121,14 +1114,14 @@ STATIC void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj) {
  3978. ASM_LOAD_REG_REG_OFFSET(emit->as, reg, REG_TEMP0, table_off);
  3979. }
  3980. -STATIC void emit_load_reg_with_child(emit_t *emit, int reg, mp_raw_code_t *rc) {
  3981. +static void emit_load_reg_with_child(emit_t *emit, int reg, mp_raw_code_t *rc) {
  3982. size_t table_off = mp_emit_common_alloc_const_child(emit->emit_common, rc);
  3983. emit_native_mov_reg_state(emit, REG_TEMP0, LOCAL_IDX_FUN_OBJ(emit));
  3984. ASM_LOAD_REG_REG_OFFSET(emit->as, REG_TEMP0, REG_TEMP0, OFFSETOF_OBJ_FUN_BC_CHILD_TABLE);
  3985. ASM_LOAD_REG_REG_OFFSET(emit->as, reg, REG_TEMP0, table_off);
  3986. }
  3987. -STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
  3988. +static void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
  3989. DEBUG_printf("label_assign(" UINT_FMT ")\n", l);
  3990. bool is_finally = false;
  3991. @@ -1156,7 +1149,7 @@ STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
  3992. }
  3993. }
  3994. -STATIC void emit_native_global_exc_entry(emit_t *emit) {
  3995. +static void emit_native_global_exc_entry(emit_t *emit) {
  3996. // Note: 4 labels are reserved for this function, starting at *emit->label_slot
  3997. emit->exit_label = *emit->label_slot;
  3998. @@ -1258,7 +1251,7 @@ STATIC void emit_native_global_exc_entry(emit_t *emit) {
  3999. }
  4000. }
  4001. -STATIC void emit_native_global_exc_exit(emit_t *emit) {
  4002. +static void emit_native_global_exc_exit(emit_t *emit) {
  4003. // Label for end of function
  4004. emit_native_label_assign(emit, emit->exit_label);
  4005. @@ -1293,7 +1286,7 @@ STATIC void emit_native_global_exc_exit(emit_t *emit) {
  4006. ASM_EXIT(emit->as);
  4007. }
  4008. -STATIC void emit_native_import_name(emit_t *emit, qstr qst) {
  4009. +static void emit_native_import_name(emit_t *emit, qstr qst) {
  4010. DEBUG_printf("import_name %s\n", qstr_str(qst));
  4011. // get arguments from stack: arg2 = fromlist, arg3 = level
  4012. @@ -1312,7 +1305,7 @@ STATIC void emit_native_import_name(emit_t *emit, qstr qst) {
  4013. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4014. }
  4015. -STATIC void emit_native_import_from(emit_t *emit, qstr qst) {
  4016. +static void emit_native_import_from(emit_t *emit, qstr qst) {
  4017. DEBUG_printf("import_from %s\n", qstr_str(qst));
  4018. emit_native_pre(emit);
  4019. vtype_kind_t vtype_module;
  4020. @@ -1322,7 +1315,7 @@ STATIC void emit_native_import_from(emit_t *emit, qstr qst) {
  4021. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4022. }
  4023. -STATIC void emit_native_import_star(emit_t *emit) {
  4024. +static void emit_native_import_star(emit_t *emit) {
  4025. DEBUG_printf("import_star\n");
  4026. vtype_kind_t vtype_module;
  4027. emit_pre_pop_reg(emit, &vtype_module, REG_ARG_1); // arg1 = module
  4028. @@ -1331,7 +1324,7 @@ STATIC void emit_native_import_star(emit_t *emit) {
  4029. emit_post(emit);
  4030. }
  4031. -STATIC void emit_native_import(emit_t *emit, qstr qst, int kind) {
  4032. +static void emit_native_import(emit_t *emit, qstr qst, int kind) {
  4033. if (kind == MP_EMIT_IMPORT_NAME) {
  4034. emit_native_import_name(emit, qst);
  4035. } else if (kind == MP_EMIT_IMPORT_FROM) {
  4036. @@ -1341,7 +1334,7 @@ STATIC void emit_native_import(emit_t *emit, qstr qst, int kind) {
  4037. }
  4038. }
  4039. -STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
  4040. +static void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
  4041. DEBUG_printf("load_const_tok(tok=%u)\n", tok);
  4042. if (tok == MP_TOKEN_ELLIPSIS) {
  4043. emit_native_load_const_obj(emit, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj));
  4044. @@ -1355,13 +1348,13 @@ STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
  4045. }
  4046. }
  4047. -STATIC void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) {
  4048. +static void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) {
  4049. DEBUG_printf("load_const_small_int(int=" INT_FMT ")\n", arg);
  4050. emit_native_pre(emit);
  4051. emit_post_push_imm(emit, VTYPE_INT, arg);
  4052. }
  4053. -STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) {
  4054. +static void emit_native_load_const_str(emit_t *emit, qstr qst) {
  4055. emit_native_pre(emit);
  4056. // TODO: Eventually we want to be able to work with raw pointers in viper to
  4057. // do native array access. For now we just load them as any other object.
  4058. @@ -1378,19 +1371,19 @@ STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) {
  4059. }
  4060. }
  4061. -STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) {
  4062. +static void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) {
  4063. emit_native_pre(emit);
  4064. need_reg_single(emit, REG_RET, 0);
  4065. emit_load_reg_with_object(emit, REG_RET, obj);
  4066. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4067. }
  4068. -STATIC void emit_native_load_null(emit_t *emit) {
  4069. +static void emit_native_load_null(emit_t *emit) {
  4070. emit_native_pre(emit);
  4071. emit_post_push_imm(emit, VTYPE_PYOBJ, 0);
  4072. }
  4073. -STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4074. +static void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4075. DEBUG_printf("load_fast(%s, " UINT_FMT ")\n", qstr_str(qst), local_num);
  4076. vtype_kind_t vtype = emit->local_vtype[local_num];
  4077. if (vtype == VTYPE_UNBOUND) {
  4078. @@ -1406,7 +1399,7 @@ STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4079. }
  4080. }
  4081. -STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4082. +static void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4083. DEBUG_printf("load_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num);
  4084. need_reg_single(emit, REG_RET, 0);
  4085. emit_native_load_fast(emit, qst, local_num);
  4086. @@ -1418,7 +1411,7 @@ STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num)
  4087. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4088. }
  4089. -STATIC void emit_native_load_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
  4090. +static void emit_native_load_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
  4091. if (kind == MP_EMIT_IDOP_LOCAL_FAST) {
  4092. emit_native_load_fast(emit, qst, local_num);
  4093. } else {
  4094. @@ -1426,7 +1419,7 @@ STATIC void emit_native_load_local(emit_t *emit, qstr qst, mp_uint_t local_num,
  4095. }
  4096. }
  4097. -STATIC void emit_native_load_global(emit_t *emit, qstr qst, int kind) {
  4098. +static void emit_native_load_global(emit_t *emit, qstr qst, int kind) {
  4099. MP_STATIC_ASSERT(MP_F_LOAD_NAME + MP_EMIT_IDOP_GLOBAL_NAME == MP_F_LOAD_NAME);
  4100. MP_STATIC_ASSERT(MP_F_LOAD_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_F_LOAD_GLOBAL);
  4101. emit_native_pre(emit);
  4102. @@ -1447,7 +1440,7 @@ STATIC void emit_native_load_global(emit_t *emit, qstr qst, int kind) {
  4103. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4104. }
  4105. -STATIC void emit_native_load_attr(emit_t *emit, qstr qst) {
  4106. +static void emit_native_load_attr(emit_t *emit, qstr qst) {
  4107. // depends on type of subject:
  4108. // - integer, function, pointer to integers: error
  4109. // - pointer to structure: get member, quite easy
  4110. @@ -1459,7 +1452,7 @@ STATIC void emit_native_load_attr(emit_t *emit, qstr qst) {
  4111. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4112. }
  4113. -STATIC void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) {
  4114. +static void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) {
  4115. if (is_super) {
  4116. emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, 3); // arg2 = dest ptr
  4117. emit_get_stack_pointer_to_reg_for_push(emit, REG_ARG_2, 2); // arg2 = dest ptr
  4118. @@ -1473,13 +1466,13 @@ STATIC void emit_native_load_method(emit_t *emit, qstr qst, bool is_super) {
  4119. }
  4120. }
  4121. -STATIC void emit_native_load_build_class(emit_t *emit) {
  4122. +static void emit_native_load_build_class(emit_t *emit) {
  4123. emit_native_pre(emit);
  4124. emit_call(emit, MP_F_LOAD_BUILD_CLASS);
  4125. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4126. }
  4127. -STATIC void emit_native_load_subscr(emit_t *emit) {
  4128. +static void emit_native_load_subscr(emit_t *emit) {
  4129. DEBUG_printf("load_subscr\n");
  4130. // need to compile: base[index]
  4131. @@ -1619,7 +1612,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) {
  4132. }
  4133. }
  4134. -STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4135. +static void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4136. vtype_kind_t vtype;
  4137. if (local_num < MAX_REGS_FOR_LOCAL_VARS && CAN_USE_REGS_FOR_LOCALS(emit)) {
  4138. emit_pre_pop_reg(emit, &vtype, reg_local_table[local_num]);
  4139. @@ -1641,7 +1634,7 @@ STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num)
  4140. }
  4141. }
  4142. -STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4143. +static void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
  4144. DEBUG_printf("store_deref(%s, " UINT_FMT ")\n", qstr_str(qst), local_num);
  4145. need_reg_single(emit, REG_TEMP0, 0);
  4146. need_reg_single(emit, REG_TEMP1, 0);
  4147. @@ -1655,7 +1648,7 @@ STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num)
  4148. emit_post(emit);
  4149. }
  4150. -STATIC void emit_native_store_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
  4151. +static void emit_native_store_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
  4152. if (kind == MP_EMIT_IDOP_LOCAL_FAST) {
  4153. emit_native_store_fast(emit, qst, local_num);
  4154. } else {
  4155. @@ -1663,7 +1656,7 @@ STATIC void emit_native_store_local(emit_t *emit, qstr qst, mp_uint_t local_num,
  4156. }
  4157. }
  4158. -STATIC void emit_native_store_global(emit_t *emit, qstr qst, int kind) {
  4159. +static void emit_native_store_global(emit_t *emit, qstr qst, int kind) {
  4160. MP_STATIC_ASSERT(MP_F_STORE_NAME + MP_EMIT_IDOP_GLOBAL_NAME == MP_F_STORE_NAME);
  4161. MP_STATIC_ASSERT(MP_F_STORE_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_F_STORE_GLOBAL);
  4162. if (kind == MP_EMIT_IDOP_GLOBAL_NAME) {
  4163. @@ -1685,7 +1678,7 @@ STATIC void emit_native_store_global(emit_t *emit, qstr qst, int kind) {
  4164. emit_post(emit);
  4165. }
  4166. -STATIC void emit_native_store_attr(emit_t *emit, qstr qst) {
  4167. +static void emit_native_store_attr(emit_t *emit, qstr qst) {
  4168. vtype_kind_t vtype_base;
  4169. vtype_kind_t vtype_val = peek_vtype(emit, 1);
  4170. if (vtype_val == VTYPE_PYOBJ) {
  4171. @@ -1702,7 +1695,7 @@ STATIC void emit_native_store_attr(emit_t *emit, qstr qst) {
  4172. emit_post(emit);
  4173. }
  4174. -STATIC void emit_native_store_subscr(emit_t *emit) {
  4175. +static void emit_native_store_subscr(emit_t *emit) {
  4176. DEBUG_printf("store_subscr\n");
  4177. // need to compile: base[index] = value
  4178. @@ -1879,7 +1872,7 @@ STATIC void emit_native_store_subscr(emit_t *emit) {
  4179. }
  4180. }
  4181. -STATIC void emit_native_delete_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
  4182. +static void emit_native_delete_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) {
  4183. if (kind == MP_EMIT_IDOP_LOCAL_FAST) {
  4184. // TODO: This is not compliant implementation. We could use MP_OBJ_SENTINEL
  4185. // to mark deleted vars but then every var would need to be checked on
  4186. @@ -1891,7 +1884,7 @@ STATIC void emit_native_delete_local(emit_t *emit, qstr qst, mp_uint_t local_num
  4187. }
  4188. }
  4189. -STATIC void emit_native_delete_global(emit_t *emit, qstr qst, int kind) {
  4190. +static void emit_native_delete_global(emit_t *emit, qstr qst, int kind) {
  4191. MP_STATIC_ASSERT(MP_F_DELETE_NAME + MP_EMIT_IDOP_GLOBAL_NAME == MP_F_DELETE_NAME);
  4192. MP_STATIC_ASSERT(MP_F_DELETE_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_F_DELETE_GLOBAL);
  4193. emit_native_pre(emit);
  4194. @@ -1899,7 +1892,7 @@ STATIC void emit_native_delete_global(emit_t *emit, qstr qst, int kind) {
  4195. emit_post(emit);
  4196. }
  4197. -STATIC void emit_native_delete_attr(emit_t *emit, qstr qst) {
  4198. +static void emit_native_delete_attr(emit_t *emit, qstr qst) {
  4199. vtype_kind_t vtype_base;
  4200. emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = base
  4201. assert(vtype_base == VTYPE_PYOBJ);
  4202. @@ -1908,7 +1901,7 @@ STATIC void emit_native_delete_attr(emit_t *emit, qstr qst) {
  4203. emit_post(emit);
  4204. }
  4205. -STATIC void emit_native_delete_subscr(emit_t *emit) {
  4206. +static void emit_native_delete_subscr(emit_t *emit) {
  4207. vtype_kind_t vtype_index, vtype_base;
  4208. emit_pre_pop_reg_reg(emit, &vtype_index, REG_ARG_2, &vtype_base, REG_ARG_1); // index, base
  4209. assert(vtype_index == VTYPE_PYOBJ);
  4210. @@ -1916,7 +1909,7 @@ STATIC void emit_native_delete_subscr(emit_t *emit) {
  4211. emit_call_with_imm_arg(emit, MP_F_OBJ_SUBSCR, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3);
  4212. }
  4213. -STATIC void emit_native_subscr(emit_t *emit, int kind) {
  4214. +static void emit_native_subscr(emit_t *emit, int kind) {
  4215. if (kind == MP_EMIT_SUBSCR_LOAD) {
  4216. emit_native_load_subscr(emit);
  4217. } else if (kind == MP_EMIT_SUBSCR_STORE) {
  4218. @@ -1926,7 +1919,7 @@ STATIC void emit_native_subscr(emit_t *emit, int kind) {
  4219. }
  4220. }
  4221. -STATIC void emit_native_attr(emit_t *emit, qstr qst, int kind) {
  4222. +static void emit_native_attr(emit_t *emit, qstr qst, int kind) {
  4223. if (kind == MP_EMIT_ATTR_LOAD) {
  4224. emit_native_load_attr(emit, qst);
  4225. } else if (kind == MP_EMIT_ATTR_STORE) {
  4226. @@ -1936,7 +1929,7 @@ STATIC void emit_native_attr(emit_t *emit, qstr qst, int kind) {
  4227. }
  4228. }
  4229. -STATIC void emit_native_dup_top(emit_t *emit) {
  4230. +static void emit_native_dup_top(emit_t *emit) {
  4231. DEBUG_printf("dup_top\n");
  4232. vtype_kind_t vtype;
  4233. int reg = REG_TEMP0;
  4234. @@ -1944,33 +1937,33 @@ STATIC void emit_native_dup_top(emit_t *emit) {
  4235. emit_post_push_reg_reg(emit, vtype, reg, vtype, reg);
  4236. }
  4237. -STATIC void emit_native_dup_top_two(emit_t *emit) {
  4238. +static void emit_native_dup_top_two(emit_t *emit) {
  4239. vtype_kind_t vtype0, vtype1;
  4240. emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1);
  4241. emit_post_push_reg_reg_reg_reg(emit, vtype1, REG_TEMP1, vtype0, REG_TEMP0, vtype1, REG_TEMP1, vtype0, REG_TEMP0);
  4242. }
  4243. -STATIC void emit_native_pop_top(emit_t *emit) {
  4244. +static void emit_native_pop_top(emit_t *emit) {
  4245. DEBUG_printf("pop_top\n");
  4246. emit_pre_pop_discard(emit);
  4247. emit_post(emit);
  4248. }
  4249. -STATIC void emit_native_rot_two(emit_t *emit) {
  4250. +static void emit_native_rot_two(emit_t *emit) {
  4251. DEBUG_printf("rot_two\n");
  4252. vtype_kind_t vtype0, vtype1;
  4253. emit_pre_pop_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1);
  4254. emit_post_push_reg_reg(emit, vtype0, REG_TEMP0, vtype1, REG_TEMP1);
  4255. }
  4256. -STATIC void emit_native_rot_three(emit_t *emit) {
  4257. +static void emit_native_rot_three(emit_t *emit) {
  4258. DEBUG_printf("rot_three\n");
  4259. vtype_kind_t vtype0, vtype1, vtype2;
  4260. emit_pre_pop_reg_reg_reg(emit, &vtype0, REG_TEMP0, &vtype1, REG_TEMP1, &vtype2, REG_TEMP2);
  4261. emit_post_push_reg_reg_reg(emit, vtype0, REG_TEMP0, vtype2, REG_TEMP2, vtype1, REG_TEMP1);
  4262. }
  4263. -STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) {
  4264. +static void emit_native_jump(emit_t *emit, mp_uint_t label) {
  4265. DEBUG_printf("jump(label=" UINT_FMT ")\n", label);
  4266. emit_native_pre(emit);
  4267. // need to commit stack because we are jumping elsewhere
  4268. @@ -1980,7 +1973,7 @@ STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) {
  4269. mp_asm_base_suppress_code(&emit->as->base);
  4270. }
  4271. -STATIC void emit_native_jump_helper(emit_t *emit, bool cond, mp_uint_t label, bool pop) {
  4272. +static void emit_native_jump_helper(emit_t *emit, bool cond, mp_uint_t label, bool pop) {
  4273. vtype_kind_t vtype = peek_vtype(emit, 0);
  4274. if (vtype == VTYPE_PYOBJ) {
  4275. emit_pre_pop_reg(emit, &vtype, REG_ARG_1);
  4276. @@ -2017,17 +2010,17 @@ STATIC void emit_native_jump_helper(emit_t *emit, bool cond, mp_uint_t label, bo
  4277. emit_post(emit);
  4278. }
  4279. -STATIC void emit_native_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) {
  4280. +static void emit_native_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) {
  4281. DEBUG_printf("pop_jump_if(cond=%u, label=" UINT_FMT ")\n", cond, label);
  4282. emit_native_jump_helper(emit, cond, label, true);
  4283. }
  4284. -STATIC void emit_native_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) {
  4285. +static void emit_native_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) {
  4286. DEBUG_printf("jump_if_or_pop(cond=%u, label=" UINT_FMT ")\n", cond, label);
  4287. emit_native_jump_helper(emit, cond, label, false);
  4288. }
  4289. -STATIC void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
  4290. +static void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
  4291. if (except_depth > 0) {
  4292. exc_stack_entry_t *first_finally = NULL;
  4293. exc_stack_entry_t *prev_finally = NULL;
  4294. @@ -2070,7 +2063,7 @@ STATIC void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t exc
  4295. emit_native_jump(emit, label & ~MP_EMIT_BREAK_FROM_FOR);
  4296. }
  4297. -STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
  4298. +static void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
  4299. // the context manager is on the top of the stack
  4300. // stack: (..., ctx_mgr)
  4301. @@ -2109,7 +2102,7 @@ STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
  4302. // stack: (..., __exit__, self, as_value, as_value)
  4303. }
  4304. -STATIC void emit_native_setup_block(emit_t *emit, mp_uint_t label, int kind) {
  4305. +static void emit_native_setup_block(emit_t *emit, mp_uint_t label, int kind) {
  4306. if (kind == MP_EMIT_SETUP_BLOCK_WITH) {
  4307. emit_native_setup_with(emit, label);
  4308. } else {
  4309. @@ -2121,7 +2114,7 @@ STATIC void emit_native_setup_block(emit_t *emit, mp_uint_t label, int kind) {
  4310. }
  4311. }
  4312. -STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
  4313. +static void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
  4314. // Note: 3 labels are reserved for this function, starting at *emit->label_slot
  4315. // stack: (..., __exit__, self, as_value)
  4316. @@ -2188,7 +2181,7 @@ STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
  4317. // Exception is in nlr_buf.ret_val slot
  4318. }
  4319. -STATIC void emit_native_end_finally(emit_t *emit) {
  4320. +static void emit_native_end_finally(emit_t *emit) {
  4321. // logic:
  4322. // exc = pop_stack
  4323. // if exc == None: pass
  4324. @@ -2214,7 +2207,7 @@ STATIC void emit_native_end_finally(emit_t *emit) {
  4325. emit_post(emit);
  4326. }
  4327. -STATIC void emit_native_get_iter(emit_t *emit, bool use_stack) {
  4328. +static void emit_native_get_iter(emit_t *emit, bool use_stack) {
  4329. // perhaps the difficult one, as we want to rewrite for loops using native code
  4330. // in cases where we iterate over a Python object, can we use normal runtime calls?
  4331. @@ -2232,7 +2225,7 @@ STATIC void emit_native_get_iter(emit_t *emit, bool use_stack) {
  4332. }
  4333. }
  4334. -STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
  4335. +static void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
  4336. emit_native_pre(emit);
  4337. emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, MP_OBJ_ITER_BUF_NSLOTS);
  4338. adjust_stack(emit, MP_OBJ_ITER_BUF_NSLOTS);
  4339. @@ -2247,14 +2240,14 @@ STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
  4340. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4341. }
  4342. -STATIC void emit_native_for_iter_end(emit_t *emit) {
  4343. +static void emit_native_for_iter_end(emit_t *emit) {
  4344. // adjust stack counter (we get here from for_iter ending, which popped the value for us)
  4345. emit_native_pre(emit);
  4346. adjust_stack(emit, -MP_OBJ_ITER_BUF_NSLOTS);
  4347. emit_post(emit);
  4348. }
  4349. -STATIC void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, bool within_exc_handler) {
  4350. +static void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, bool within_exc_handler) {
  4351. if (within_exc_handler) {
  4352. // Cancel any active exception so subsequent handlers don't see it
  4353. ASM_MOV_REG_IMM(emit->as, REG_TEMP0, (mp_uint_t)MP_OBJ_NULL);
  4354. @@ -2265,20 +2258,43 @@ STATIC void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, bool with
  4355. emit_native_jump(emit, label);
  4356. }
  4357. -STATIC void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) {
  4358. - vtype_kind_t vtype;
  4359. - emit_pre_pop_reg(emit, &vtype, REG_ARG_2);
  4360. - if (vtype == VTYPE_PYOBJ) {
  4361. +static void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) {
  4362. + vtype_kind_t vtype = peek_vtype(emit, 0);
  4363. + if (vtype == VTYPE_INT || vtype == VTYPE_UINT) {
  4364. + if (op == MP_UNARY_OP_POSITIVE) {
  4365. + // No-operation, just leave the argument on the stack.
  4366. + } else if (op == MP_UNARY_OP_NEGATIVE) {
  4367. + int reg = REG_RET;
  4368. + emit_pre_pop_reg_flexible(emit, &vtype, &reg, reg, reg);
  4369. + ASM_NEG_REG(emit->as, reg);
  4370. + emit_post_push_reg(emit, vtype, reg);
  4371. + } else if (op == MP_UNARY_OP_INVERT) {
  4372. + #ifdef ASM_NOT_REG
  4373. + int reg = REG_RET;
  4374. + emit_pre_pop_reg_flexible(emit, &vtype, &reg, reg, reg);
  4375. + ASM_NOT_REG(emit->as, reg);
  4376. + #else
  4377. + int reg = REG_RET;
  4378. + emit_pre_pop_reg_flexible(emit, &vtype, &reg, REG_ARG_1, reg);
  4379. + ASM_MOV_REG_IMM(emit->as, REG_ARG_1, -1);
  4380. + ASM_XOR_REG_REG(emit->as, reg, REG_ARG_1);
  4381. + #endif
  4382. + emit_post_push_reg(emit, vtype, reg);
  4383. + } else {
  4384. + EMIT_NATIVE_VIPER_TYPE_ERROR(emit,
  4385. + MP_ERROR_TEXT("'not' not implemented"), mp_binary_op_method_name[op]);
  4386. + }
  4387. + } else if (vtype == VTYPE_PYOBJ) {
  4388. + emit_pre_pop_reg(emit, &vtype, REG_ARG_2);
  4389. emit_call_with_imm_arg(emit, MP_F_UNARY_OP, op, REG_ARG_1);
  4390. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4391. } else {
  4392. - adjust_stack(emit, 1);
  4393. EMIT_NATIVE_VIPER_TYPE_ERROR(emit,
  4394. - MP_ERROR_TEXT("unary op %q not implemented"), mp_unary_op_method_name[op]);
  4395. + MP_ERROR_TEXT("can't do unary op of '%q'"), vtype_to_qstr(vtype));
  4396. }
  4397. }
  4398. -STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
  4399. +static void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
  4400. DEBUG_printf("binary_op(" UINT_FMT ")\n", op);
  4401. vtype_kind_t vtype_lhs = peek_vtype(emit, 1);
  4402. vtype_kind_t vtype_rhs = peek_vtype(emit, 0);
  4403. @@ -2541,10 +2557,10 @@ STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
  4404. }
  4405. #if MICROPY_PY_BUILTINS_SLICE
  4406. -STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args);
  4407. +static void emit_native_build_slice(emit_t *emit, mp_uint_t n_args);
  4408. #endif
  4409. -STATIC void emit_native_build(emit_t *emit, mp_uint_t n_args, int kind) {
  4410. +static void emit_native_build(emit_t *emit, mp_uint_t n_args, int kind) {
  4411. // for viper: call runtime, with types of args
  4412. // if wrapped in byte_array, or something, allocates memory and fills it
  4413. MP_STATIC_ASSERT(MP_F_BUILD_TUPLE + MP_EMIT_BUILD_TUPLE == MP_F_BUILD_TUPLE);
  4414. @@ -2565,7 +2581,7 @@ STATIC void emit_native_build(emit_t *emit, mp_uint_t n_args, int kind) {
  4415. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new tuple/list/map/set
  4416. }
  4417. -STATIC void emit_native_store_map(emit_t *emit) {
  4418. +static void emit_native_store_map(emit_t *emit) {
  4419. vtype_kind_t vtype_key, vtype_value, vtype_map;
  4420. 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
  4421. assert(vtype_key == VTYPE_PYOBJ);
  4422. @@ -2576,7 +2592,7 @@ STATIC void emit_native_store_map(emit_t *emit) {
  4423. }
  4424. #if MICROPY_PY_BUILTINS_SLICE
  4425. -STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) {
  4426. +static void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) {
  4427. DEBUG_printf("build_slice %d\n", n_args);
  4428. if (n_args == 2) {
  4429. vtype_kind_t vtype_start, vtype_stop;
  4430. @@ -2597,7 +2613,7 @@ STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) {
  4431. }
  4432. #endif
  4433. -STATIC void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_index) {
  4434. +static void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t collection_index) {
  4435. mp_fun_kind_t f;
  4436. if (kind == SCOPE_LIST_COMP) {
  4437. vtype_kind_t vtype_item;
  4438. @@ -2626,7 +2642,7 @@ STATIC void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t co
  4439. emit_post(emit);
  4440. }
  4441. -STATIC void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
  4442. +static void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
  4443. DEBUG_printf("unpack_sequence %d\n", n_args);
  4444. vtype_kind_t vtype_base;
  4445. emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq
  4446. @@ -2635,7 +2651,7 @@ STATIC void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
  4447. emit_call_with_imm_arg(emit, MP_F_UNPACK_SEQUENCE, n_args, REG_ARG_2); // arg2 = n_args
  4448. }
  4449. -STATIC void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) {
  4450. +static void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right) {
  4451. DEBUG_printf("unpack_ex %d %d\n", n_left, n_right);
  4452. vtype_kind_t vtype_base;
  4453. emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); // arg1 = seq
  4454. @@ -2644,7 +2660,7 @@ STATIC void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_ri
  4455. emit_call_with_imm_arg(emit, MP_F_UNPACK_EX, n_left | (n_right << 8), REG_ARG_2); // arg2 = n_left + n_right
  4456. }
  4457. -STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
  4458. +static void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
  4459. // call runtime, with type info for args, or don't support dict/default params, or only support Python objects for them
  4460. emit_native_pre(emit);
  4461. emit_native_mov_reg_state(emit, REG_ARG_2, LOCAL_IDX_FUN_OBJ(emit));
  4462. @@ -2657,11 +2673,11 @@ STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_
  4463. need_reg_all(emit);
  4464. }
  4465. emit_load_reg_with_child(emit, REG_ARG_1, scope->raw_code);
  4466. - ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_RAW_CODE);
  4467. + ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_PROTO_FUN);
  4468. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4469. }
  4470. -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) {
  4471. +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) {
  4472. // make function
  4473. emit_native_pre(emit);
  4474. emit_native_mov_reg_state(emit, REG_ARG_2, LOCAL_IDX_FUN_OBJ(emit));
  4475. @@ -2675,7 +2691,7 @@ STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_c
  4476. need_reg_all(emit);
  4477. }
  4478. emit_load_reg_with_child(emit, REG_ARG_1, scope->raw_code);
  4479. - ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_RAW_CODE);
  4480. + ASM_CALL_IND(emit->as, MP_F_MAKE_FUNCTION_FROM_PROTO_FUN);
  4481. // make closure
  4482. #if REG_ARG_1 != REG_RET
  4483. @@ -2690,7 +2706,7 @@ STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_c
  4484. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
  4485. }
  4486. -STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
  4487. +static void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
  4488. DEBUG_printf("call_function(n_pos=" UINT_FMT ", n_kw=" UINT_FMT ", star_flags=" UINT_FMT ")\n", n_positional, n_keyword, star_flags);
  4489. // TODO: in viper mode, call special runtime routine with type info for args,
  4490. @@ -2745,7 +2761,7 @@ STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_positional, mp_u
  4491. }
  4492. }
  4493. -STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
  4494. +static void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags) {
  4495. if (star_flags) {
  4496. emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2 * n_keyword + 3); // pointer to args
  4497. 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);
  4498. @@ -2758,7 +2774,7 @@ STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional, mp_uin
  4499. }
  4500. }
  4501. -STATIC void emit_native_return_value(emit_t *emit) {
  4502. +static void emit_native_return_value(emit_t *emit) {
  4503. DEBUG_printf("return_value\n");
  4504. if (emit->scope->scope_flags & MP_SCOPE_FLAG_GENERATOR) {
  4505. @@ -2811,7 +2827,7 @@ STATIC void emit_native_return_value(emit_t *emit) {
  4506. emit_native_unwind_jump(emit, emit->exit_label, emit->exc_stack_size);
  4507. }
  4508. -STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
  4509. +static void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
  4510. (void)n_args;
  4511. assert(n_args == 1);
  4512. vtype_kind_t vtype_exc;
  4513. @@ -2824,7 +2840,7 @@ STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
  4514. mp_asm_base_suppress_code(&emit->as->base);
  4515. }
  4516. -STATIC void emit_native_yield(emit_t *emit, int kind) {
  4517. +static void emit_native_yield(emit_t *emit, int kind) {
  4518. // Note: 1 (yield) or 3 (yield from) labels are reserved for this function, starting at *emit->label_slot
  4519. if (emit->do_viper_types) {
  4520. @@ -2907,7 +2923,7 @@ STATIC void emit_native_yield(emit_t *emit, int kind) {
  4521. }
  4522. }
  4523. -STATIC void emit_native_start_except_handler(emit_t *emit) {
  4524. +static void emit_native_start_except_handler(emit_t *emit) {
  4525. // Protected block has finished so leave the current exception handler
  4526. emit_native_leave_exc_stack(emit, true);
  4527. @@ -2916,7 +2932,7 @@ STATIC void emit_native_start_except_handler(emit_t *emit) {
  4528. emit_post_push_reg(emit, VTYPE_PYOBJ, REG_TEMP0);
  4529. }
  4530. -STATIC void emit_native_end_except_handler(emit_t *emit) {
  4531. +static void emit_native_end_except_handler(emit_t *emit) {
  4532. adjust_stack(emit, -1); // pop the exception (end_finally didn't use it)
  4533. }
  4534. diff --git a/py/emitnx86.c b/py/emitnx86.c
  4535. index a9050c65d..1d2aefa79 100644
  4536. --- a/py/emitnx86.c
  4537. +++ b/py/emitnx86.c
  4538. @@ -13,7 +13,7 @@
  4539. #define NLR_BUF_IDX_LOCAL_1 (5) // ebx
  4540. // x86 needs a table to know how many args a given function has
  4541. -STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
  4542. +static byte mp_f_n_args[MP_F_NUMBER_OF] = {
  4543. [MP_F_CONVERT_OBJ_TO_NATIVE] = 2,
  4544. [MP_F_CONVERT_NATIVE_TO_OBJ] = 2,
  4545. [MP_F_NATIVE_SWAP_GLOBALS] = 1,
  4546. @@ -37,7 +37,7 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
  4547. [MP_F_STORE_SET] = 2,
  4548. [MP_F_LIST_APPEND] = 2,
  4549. [MP_F_STORE_MAP] = 3,
  4550. - [MP_F_MAKE_FUNCTION_FROM_RAW_CODE] = 3,
  4551. + [MP_F_MAKE_FUNCTION_FROM_PROTO_FUN] = 3,
  4552. [MP_F_NATIVE_CALL_FUNCTION_N_KW] = 3,
  4553. [MP_F_CALL_METHOD_N_KW] = 3,
  4554. [MP_F_CALL_METHOD_N_KW_VAR] = 3,
  4555. diff --git a/py/gc.c b/py/gc.c
  4556. index b6969dfd4..8a03ce526 100644
  4557. --- a/py/gc.c
  4558. +++ b/py/gc.c
  4559. @@ -121,7 +121,7 @@
  4560. #endif
  4561. // TODO waste less memory; currently requires that all entries in alloc_table have a corresponding block in pool
  4562. -STATIC void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
  4563. +static void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
  4564. // calculate parameters for GC (T=total, A=alloc table, F=finaliser table, P=pool; all in bytes):
  4565. // T = A + F + P
  4566. // F = A * BLOCKS_PER_ATB / BLOCKS_PER_FTB
  4567. @@ -239,7 +239,7 @@ void gc_add(void *start, void *end) {
  4568. #if MICROPY_GC_SPLIT_HEAP_AUTO
  4569. // Try to automatically add a heap area large enough to fulfill 'failed_alloc'.
  4570. -STATIC bool gc_try_add_heap(size_t failed_alloc) {
  4571. +static bool gc_try_add_heap(size_t failed_alloc) {
  4572. // 'needed' is the size of a heap large enough to hold failed_alloc, with
  4573. // the additional metadata overheads as calculated in gc_setup_area().
  4574. //
  4575. @@ -349,7 +349,7 @@ bool gc_is_locked(void) {
  4576. #if MICROPY_GC_SPLIT_HEAP
  4577. // Returns the area to which this pointer belongs, or NULL if it isn't
  4578. // allocated on the GC-managed heap.
  4579. -STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
  4580. +static inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
  4581. if (((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) != 0) { // must be aligned on a block
  4582. return NULL;
  4583. }
  4584. @@ -383,9 +383,9 @@ STATIC inline mp_state_mem_area_t *gc_get_ptr_area(const void *ptr) {
  4585. // blocks on the stack. When all children have been checked, pop off the
  4586. // topmost block on the stack and repeat with that one.
  4587. #if MICROPY_GC_SPLIT_HEAP
  4588. -STATIC void gc_mark_subtree(mp_state_mem_area_t *area, size_t block)
  4589. +static void gc_mark_subtree(mp_state_mem_area_t *area, size_t block)
  4590. #else
  4591. -STATIC void gc_mark_subtree(size_t block)
  4592. +static void gc_mark_subtree(size_t block)
  4593. #endif
  4594. {
  4595. // Start with the block passed in the argument.
  4596. @@ -456,7 +456,7 @@ STATIC void gc_mark_subtree(size_t block)
  4597. }
  4598. }
  4599. -STATIC void gc_deal_with_stack_overflow(void) {
  4600. +static void gc_deal_with_stack_overflow(void) {
  4601. while (MP_STATE_MEM(gc_stack_overflow)) {
  4602. MP_STATE_MEM(gc_stack_overflow) = 0;
  4603. @@ -477,7 +477,7 @@ STATIC void gc_deal_with_stack_overflow(void) {
  4604. }
  4605. }
  4606. -STATIC void gc_sweep(void) {
  4607. +static void gc_sweep(void) {
  4608. #if MICROPY_PY_GC_COLLECT_RETVAL
  4609. MP_STATE_MEM(gc_collected) = 0;
  4610. #endif
  4611. diff --git a/py/lexer.c b/py/lexer.c
  4612. index 5e911a1a2..bff8e6376 100644
  4613. --- a/py/lexer.c
  4614. +++ b/py/lexer.c
  4615. @@ -42,74 +42,74 @@
  4616. #define MP_LEXER_EOF ((unichar)MP_READER_EOF)
  4617. #define CUR_CHAR(lex) ((lex)->chr0)
  4618. -STATIC bool is_end(mp_lexer_t *lex) {
  4619. +static bool is_end(mp_lexer_t *lex) {
  4620. return lex->chr0 == MP_LEXER_EOF;
  4621. }
  4622. -STATIC bool is_physical_newline(mp_lexer_t *lex) {
  4623. +static bool is_physical_newline(mp_lexer_t *lex) {
  4624. return lex->chr0 == '\n';
  4625. }
  4626. -STATIC bool is_char(mp_lexer_t *lex, byte c) {
  4627. +static bool is_char(mp_lexer_t *lex, byte c) {
  4628. return lex->chr0 == c;
  4629. }
  4630. -STATIC bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
  4631. +static bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
  4632. return lex->chr0 == c1 || lex->chr0 == c2;
  4633. }
  4634. -STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
  4635. +static bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
  4636. return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3;
  4637. }
  4638. #if MICROPY_PY_FSTRINGS
  4639. -STATIC bool is_char_or4(mp_lexer_t *lex, byte c1, byte c2, byte c3, byte c4) {
  4640. +static bool is_char_or4(mp_lexer_t *lex, byte c1, byte c2, byte c3, byte c4) {
  4641. return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3 || lex->chr0 == c4;
  4642. }
  4643. #endif
  4644. -STATIC bool is_char_following(mp_lexer_t *lex, byte c) {
  4645. +static bool is_char_following(mp_lexer_t *lex, byte c) {
  4646. return lex->chr1 == c;
  4647. }
  4648. -STATIC bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
  4649. +static bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
  4650. return lex->chr1 == c1 || lex->chr1 == c2;
  4651. }
  4652. -STATIC bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) {
  4653. +static bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) {
  4654. return lex->chr2 == c1 || lex->chr2 == c2;
  4655. }
  4656. -STATIC bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
  4657. +static bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
  4658. return lex->chr0 == c1 && lex->chr1 == c2;
  4659. }
  4660. -STATIC bool is_whitespace(mp_lexer_t *lex) {
  4661. +static bool is_whitespace(mp_lexer_t *lex) {
  4662. return unichar_isspace(lex->chr0);
  4663. }
  4664. -STATIC bool is_letter(mp_lexer_t *lex) {
  4665. +static bool is_letter(mp_lexer_t *lex) {
  4666. return unichar_isalpha(lex->chr0);
  4667. }
  4668. -STATIC bool is_digit(mp_lexer_t *lex) {
  4669. +static bool is_digit(mp_lexer_t *lex) {
  4670. return unichar_isdigit(lex->chr0);
  4671. }
  4672. -STATIC bool is_following_digit(mp_lexer_t *lex) {
  4673. +static bool is_following_digit(mp_lexer_t *lex) {
  4674. return unichar_isdigit(lex->chr1);
  4675. }
  4676. -STATIC bool is_following_base_char(mp_lexer_t *lex) {
  4677. +static bool is_following_base_char(mp_lexer_t *lex) {
  4678. const unichar chr1 = lex->chr1 | 0x20;
  4679. return chr1 == 'b' || chr1 == 'o' || chr1 == 'x';
  4680. }
  4681. -STATIC bool is_following_odigit(mp_lexer_t *lex) {
  4682. +static bool is_following_odigit(mp_lexer_t *lex) {
  4683. return lex->chr1 >= '0' && lex->chr1 <= '7';
  4684. }
  4685. -STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
  4686. +static bool is_string_or_bytes(mp_lexer_t *lex) {
  4687. return is_char_or(lex, '\'', '\"')
  4688. #if MICROPY_PY_FSTRINGS
  4689. || (is_char_or4(lex, 'r', 'u', 'b', 'f') && is_char_following_or(lex, '\'', '\"'))
  4690. @@ -123,15 +123,15 @@ STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
  4691. }
  4692. // to easily parse utf-8 identifiers we allow any raw byte with high bit set
  4693. -STATIC bool is_head_of_identifier(mp_lexer_t *lex) {
  4694. +static bool is_head_of_identifier(mp_lexer_t *lex) {
  4695. return is_letter(lex) || lex->chr0 == '_' || lex->chr0 >= 0x80;
  4696. }
  4697. -STATIC bool is_tail_of_identifier(mp_lexer_t *lex) {
  4698. +static bool is_tail_of_identifier(mp_lexer_t *lex) {
  4699. return is_head_of_identifier(lex) || is_digit(lex);
  4700. }
  4701. -STATIC void next_char(mp_lexer_t *lex) {
  4702. +static void next_char(mp_lexer_t *lex) {
  4703. if (lex->chr0 == '\n') {
  4704. // a new line
  4705. ++lex->line;
  4706. @@ -189,7 +189,7 @@ STATIC void next_char(mp_lexer_t *lex) {
  4707. }
  4708. }
  4709. -STATIC void indent_push(mp_lexer_t *lex, size_t indent) {
  4710. +static void indent_push(mp_lexer_t *lex, size_t indent) {
  4711. if (lex->num_indent_level >= lex->alloc_indent_level) {
  4712. lex->indent_level = m_renew(uint16_t, lex->indent_level, lex->alloc_indent_level, lex->alloc_indent_level + MICROPY_ALLOC_LEXEL_INDENT_INC);
  4713. lex->alloc_indent_level += MICROPY_ALLOC_LEXEL_INDENT_INC;
  4714. @@ -197,11 +197,11 @@ STATIC void indent_push(mp_lexer_t *lex, size_t indent) {
  4715. lex->indent_level[lex->num_indent_level++] = indent;
  4716. }
  4717. -STATIC size_t indent_top(mp_lexer_t *lex) {
  4718. +static size_t indent_top(mp_lexer_t *lex) {
  4719. return lex->indent_level[lex->num_indent_level - 1];
  4720. }
  4721. -STATIC void indent_pop(mp_lexer_t *lex) {
  4722. +static void indent_pop(mp_lexer_t *lex) {
  4723. lex->num_indent_level -= 1;
  4724. }
  4725. @@ -211,7 +211,7 @@ STATIC void indent_pop(mp_lexer_t *lex) {
  4726. // c<op> = continue with <op>, if this opchar matches then continue matching
  4727. // this means if the start of two ops are the same then they are equal til the last char
  4728. -STATIC const char *const tok_enc =
  4729. +static const char *const tok_enc =
  4730. "()[]{},;~" // singles
  4731. ":e=" // : :=
  4732. "<e=c<e=" // < <= << <<=
  4733. @@ -229,7 +229,7 @@ STATIC const char *const tok_enc =
  4734. "!."; // start of special cases: != . ...
  4735. // TODO static assert that number of tokens is less than 256 so we can safely make this table with byte sized entries
  4736. -STATIC const uint8_t tok_enc_kind[] = {
  4737. +static const uint8_t tok_enc_kind[] = {
  4738. MP_TOKEN_DEL_PAREN_OPEN, MP_TOKEN_DEL_PAREN_CLOSE,
  4739. MP_TOKEN_DEL_BRACKET_OPEN, MP_TOKEN_DEL_BRACKET_CLOSE,
  4740. MP_TOKEN_DEL_BRACE_OPEN, MP_TOKEN_DEL_BRACE_CLOSE,
  4741. @@ -252,7 +252,7 @@ STATIC const uint8_t tok_enc_kind[] = {
  4742. // must have the same order as enum in lexer.h
  4743. // must be sorted according to strcmp
  4744. -STATIC const char *const tok_kw[] = {
  4745. +static const char *const tok_kw[] = {
  4746. "False",
  4747. "None",
  4748. "True",
  4749. @@ -296,7 +296,7 @@ STATIC const char *const tok_kw[] = {
  4750. // This is called with CUR_CHAR() before first hex digit, and should return with
  4751. // it pointing to last hex digit
  4752. // num_digits must be greater than zero
  4753. -STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
  4754. +static bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
  4755. mp_uint_t num = 0;
  4756. while (num_digits-- != 0) {
  4757. next_char(lex);
  4758. @@ -310,7 +310,7 @@ STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *result) {
  4759. return true;
  4760. }
  4761. -STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) {
  4762. +static void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) {
  4763. // get first quoting character
  4764. char quote_char = '\'';
  4765. if (is_char(lex, '\"')) {
  4766. @@ -529,7 +529,7 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring)
  4767. // This function returns whether it has crossed a newline or not.
  4768. // It therefore always return true if stop_at_newline is true
  4769. -STATIC bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) {
  4770. +static bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) {
  4771. while (!is_end(lex)) {
  4772. if (is_physical_newline(lex)) {
  4773. if (stop_at_newline && lex->nested_bracket_level == 0) {
  4774. diff --git a/py/malloc.c b/py/malloc.c
  4775. index ddf139e38..f557ade44 100644
  4776. --- a/py/malloc.c
  4777. +++ b/py/malloc.c
  4778. @@ -69,7 +69,7 @@
  4779. #error MICROPY_ENABLE_FINALISER requires MICROPY_ENABLE_GC
  4780. #endif
  4781. -STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
  4782. +static void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
  4783. if (allow_move) {
  4784. return realloc(ptr, n_bytes);
  4785. } else {
  4786. @@ -221,7 +221,7 @@ typedef struct _m_tracked_node_t {
  4787. } m_tracked_node_t;
  4788. #if MICROPY_DEBUG_VERBOSE
  4789. -STATIC size_t m_tracked_count_links(size_t *nb) {
  4790. +static size_t m_tracked_count_links(size_t *nb) {
  4791. m_tracked_node_t *node = MP_STATE_VM(m_tracked_head);
  4792. size_t n = 0;
  4793. *nb = 0;
  4794. diff --git a/py/map.c b/py/map.c
  4795. index c18df5a9f..d40e3dc4d 100644
  4796. --- a/py/map.c
  4797. +++ b/py/map.c
  4798. @@ -65,14 +65,14 @@
  4799. // The first set of sizes are chosen so the allocation fits exactly in a
  4800. // 4-word GC block, and it's not so important for these small values to be
  4801. // prime. The latter sizes are prime and increase at an increasing rate.
  4802. -STATIC const uint16_t hash_allocation_sizes[] = {
  4803. +static const uint16_t hash_allocation_sizes[] = {
  4804. 0, 2, 4, 6, 8, 10, 12, // +2
  4805. 17, 23, 29, 37, 47, 59, 73, // *1.25
  4806. 97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161, // *1.33
  4807. 3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907, // *1.5
  4808. };
  4809. -STATIC size_t get_hash_alloc_greater_or_equal_to(size_t x) {
  4810. +static size_t get_hash_alloc_greater_or_equal_to(size_t x) {
  4811. for (size_t i = 0; i < MP_ARRAY_SIZE(hash_allocation_sizes); i++) {
  4812. if (hash_allocation_sizes[i] >= x) {
  4813. return hash_allocation_sizes[i];
  4814. @@ -128,7 +128,7 @@ void mp_map_clear(mp_map_t *map) {
  4815. map->table = NULL;
  4816. }
  4817. -STATIC void mp_map_rehash(mp_map_t *map) {
  4818. +static void mp_map_rehash(mp_map_t *map) {
  4819. size_t old_alloc = map->alloc;
  4820. size_t new_alloc = get_hash_alloc_greater_or_equal_to(map->alloc + 1);
  4821. DEBUG_printf("mp_map_rehash(%p): " UINT_FMT " -> " UINT_FMT "\n", map, old_alloc, new_alloc);
  4822. @@ -332,7 +332,7 @@ void mp_set_init(mp_set_t *set, size_t n) {
  4823. set->table = m_new0(mp_obj_t, set->alloc);
  4824. }
  4825. -STATIC void mp_set_rehash(mp_set_t *set) {
  4826. +static void mp_set_rehash(mp_set_t *set) {
  4827. size_t old_alloc = set->alloc;
  4828. mp_obj_t *old_table = set->table;
  4829. set->alloc = get_hash_alloc_greater_or_equal_to(set->alloc + 1);
  4830. diff --git a/py/misc.h b/py/misc.h
  4831. index e19a53572..eea3e8b0f 100644
  4832. --- a/py/misc.h
  4833. +++ b/py/misc.h
  4834. @@ -79,13 +79,6 @@ typedef unsigned int uint;
  4835. #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)))
  4836. #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)))
  4837. #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)))
  4838. -#if MICROPY_ENABLE_FINALISER
  4839. -#define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type))))
  4840. -#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)))
  4841. -#else
  4842. -#define m_new_obj_with_finaliser(type) m_new_obj(type)
  4843. -#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)
  4844. -#endif
  4845. #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
  4846. #define m_renew(type, ptr, old_num, new_num) ((type *)(m_realloc((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num))))
  4847. #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))))
  4848. diff --git a/py/modarray.c b/py/modarray.c
  4849. index ac2e56ed3..116c844e8 100644
  4850. --- a/py/modarray.c
  4851. +++ b/py/modarray.c
  4852. @@ -28,12 +28,12 @@
  4853. #if MICROPY_PY_ARRAY
  4854. -STATIC const mp_rom_map_elem_t mp_module_array_globals_table[] = {
  4855. +static const mp_rom_map_elem_t mp_module_array_globals_table[] = {
  4856. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_array) },
  4857. { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_type_array) },
  4858. };
  4859. -STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table);
  4860. +static MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table);
  4861. const mp_obj_module_t mp_module_array = {
  4862. .base = { &mp_type_module },
  4863. diff --git a/py/modbuiltins.c b/py/modbuiltins.c
  4864. index 4ff7d4450..51cf3137b 100644
  4865. --- a/py/modbuiltins.c
  4866. +++ b/py/modbuiltins.c
  4867. @@ -46,7 +46,7 @@ extern struct _mp_dummy_t mp_sys_stdout_obj; // type is irrelevant, just need po
  4868. // args[0] is function from class body
  4869. // args[1] is class name
  4870. // args[2:] are base objects
  4871. -STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) {
  4872. +static mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args) {
  4873. assert(2 <= n_args);
  4874. // set the new classes __locals__ object
  4875. @@ -88,12 +88,12 @@ STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args)
  4876. }
  4877. MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__);
  4878. -STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
  4879. +static mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
  4880. return mp_unary_op(MP_UNARY_OP_ABS, o_in);
  4881. }
  4882. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
  4883. -STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
  4884. +static mp_obj_t mp_builtin_all(mp_obj_t o_in) {
  4885. mp_obj_iter_buf_t iter_buf;
  4886. mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
  4887. mp_obj_t item;
  4888. @@ -106,7 +106,7 @@ STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
  4889. }
  4890. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
  4891. -STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
  4892. +static mp_obj_t mp_builtin_any(mp_obj_t o_in) {
  4893. mp_obj_iter_buf_t iter_buf;
  4894. mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
  4895. mp_obj_t item;
  4896. @@ -119,13 +119,13 @@ STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
  4897. }
  4898. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);
  4899. -STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
  4900. +static mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
  4901. mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in };
  4902. return mp_obj_str_format(MP_ARRAY_SIZE(args), args, NULL);
  4903. }
  4904. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin);
  4905. -STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
  4906. +static mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
  4907. if (mp_obj_is_callable(o_in)) {
  4908. return mp_const_true;
  4909. } else {
  4910. @@ -134,7 +134,7 @@ STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
  4911. }
  4912. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
  4913. -STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
  4914. +static mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
  4915. #if MICROPY_PY_BUILTINS_STR_UNICODE
  4916. mp_uint_t c = mp_obj_get_int(o_in);
  4917. if (c >= 0x110000) {
  4918. @@ -155,7 +155,7 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
  4919. }
  4920. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);
  4921. -STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
  4922. +static mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
  4923. mp_obj_t dir = mp_obj_new_list(0, NULL);
  4924. if (n_args == 0) {
  4925. // Make a list of names in the local namespace
  4926. @@ -188,18 +188,18 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
  4927. }
  4928. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir);
  4929. -STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
  4930. +static mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
  4931. return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in);
  4932. }
  4933. MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod);
  4934. -STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
  4935. +static mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
  4936. // result is guaranteed to be a (small) int
  4937. return mp_unary_op(MP_UNARY_OP_HASH, o_in);
  4938. }
  4939. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
  4940. -STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
  4941. +static mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
  4942. #if MICROPY_PY_BUILTINS_STR_OP_MODULO
  4943. return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in);
  4944. #else
  4945. @@ -219,7 +219,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
  4946. #define mp_hal_readline readline
  4947. #endif
  4948. -STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
  4949. +static mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
  4950. if (n_args == 1) {
  4951. mp_obj_print(args[0], PRINT_STR);
  4952. }
  4953. @@ -238,14 +238,14 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input
  4954. #endif
  4955. -STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
  4956. +static mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
  4957. return mp_getiter(o_in, NULL);
  4958. }
  4959. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
  4960. #if MICROPY_PY_BUILTINS_MIN_MAX
  4961. -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) {
  4962. +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) {
  4963. mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP);
  4964. mp_map_elem_t *default_elem;
  4965. mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value;
  4966. @@ -287,12 +287,12 @@ STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t
  4967. }
  4968. }
  4969. -STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  4970. +static mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  4971. return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE);
  4972. }
  4973. MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max);
  4974. -STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  4975. +static mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  4976. return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS);
  4977. }
  4978. MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
  4979. @@ -300,7 +300,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
  4980. #endif
  4981. #if MICROPY_PY_BUILTINS_NEXT2
  4982. -STATIC mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
  4983. +static mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
  4984. if (n_args == 1) {
  4985. mp_obj_t ret = mp_iternext_allow_raise(args[0]);
  4986. if (ret == MP_OBJ_STOP_ITERATION) {
  4987. @@ -315,7 +315,7 @@ STATIC mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
  4988. }
  4989. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_next_obj, 1, 2, mp_builtin_next);
  4990. #else
  4991. -STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
  4992. +static mp_obj_t mp_builtin_next(mp_obj_t o) {
  4993. mp_obj_t ret = mp_iternext_allow_raise(o);
  4994. if (ret == MP_OBJ_STOP_ITERATION) {
  4995. mp_raise_StopIteration(MP_STATE_THREAD(stop_iteration_arg));
  4996. @@ -326,7 +326,7 @@ STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
  4997. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
  4998. #endif
  4999. -STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
  5000. +static mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
  5001. #if MICROPY_PY_BUILTINS_STR_OP_MODULO
  5002. return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in);
  5003. #else
  5004. @@ -336,7 +336,7 @@ STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
  5005. }
  5006. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
  5007. -STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
  5008. +static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
  5009. size_t len;
  5010. const byte *str = (const byte *)mp_obj_str_get_data(o_in, &len);
  5011. #if MICROPY_PY_BUILTINS_STR_UNICODE
  5012. @@ -363,7 +363,7 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
  5013. }
  5014. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
  5015. -STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
  5016. +static mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
  5017. switch (n_args) {
  5018. case 2:
  5019. return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
  5020. @@ -379,7 +379,7 @@ STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
  5021. }
  5022. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
  5023. -STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  5024. +static mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  5025. enum { ARG_sep, ARG_end, ARG_file };
  5026. static const mp_arg_t allowed_args[] = {
  5027. { MP_QSTR_sep, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR__space_)} },
  5028. @@ -430,7 +430,7 @@ STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args, mp_map
  5029. }
  5030. MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print);
  5031. -STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
  5032. +static mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
  5033. if (o != mp_const_none) {
  5034. mp_obj_print_helper(MP_PYTHON_PRINTER, o, PRINT_REPR);
  5035. mp_print_str(MP_PYTHON_PRINTER, "\n");
  5036. @@ -444,7 +444,7 @@ STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
  5037. }
  5038. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__);
  5039. -STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
  5040. +static mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
  5041. vstr_t vstr;
  5042. mp_print_t print;
  5043. vstr_init_print(&vstr, 16, &print);
  5044. @@ -453,7 +453,7 @@ STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
  5045. }
  5046. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);
  5047. -STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
  5048. +static mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
  5049. mp_obj_t o_in = args[0];
  5050. if (mp_obj_is_int(o_in)) {
  5051. if (n_args <= 1) {
  5052. @@ -505,7 +505,7 @@ STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
  5053. }
  5054. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round);
  5055. -STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
  5056. +static mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
  5057. mp_obj_t value;
  5058. switch (n_args) {
  5059. case 1:
  5060. @@ -525,7 +525,7 @@ STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
  5061. }
  5062. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);
  5063. -STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  5064. +static mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  5065. if (n_args > 1) {
  5066. mp_raise_TypeError(MP_ERROR_TEXT("must use keyword argument for key function"));
  5067. }
  5068. @@ -556,7 +556,7 @@ static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t d
  5069. }
  5070. }
  5071. -STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
  5072. +static mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
  5073. mp_obj_t defval = MP_OBJ_NULL;
  5074. if (n_args > 2) {
  5075. defval = args[2];
  5076. @@ -565,20 +565,20 @@ STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
  5077. }
  5078. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr);
  5079. -STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) {
  5080. +static mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) {
  5081. mp_store_attr(base, mp_obj_str_get_qstr(attr), value);
  5082. return mp_const_none;
  5083. }
  5084. MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr);
  5085. #if MICROPY_CPYTHON_COMPAT
  5086. -STATIC mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
  5087. +static mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
  5088. return mp_builtin_setattr(base, attr, MP_OBJ_NULL);
  5089. }
  5090. MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj, mp_builtin_delattr);
  5091. #endif
  5092. -STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
  5093. +static mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
  5094. qstr attr = mp_obj_str_get_qstr(attr_in);
  5095. mp_obj_t dest[2];
  5096. mp_load_method_protected(object_in, attr, dest, false);
  5097. @@ -586,12 +586,12 @@ STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
  5098. }
  5099. MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr);
  5100. -STATIC mp_obj_t mp_builtin_globals(void) {
  5101. +static mp_obj_t mp_builtin_globals(void) {
  5102. return MP_OBJ_FROM_PTR(mp_globals_get());
  5103. }
  5104. MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_globals_obj, mp_builtin_globals);
  5105. -STATIC mp_obj_t mp_builtin_locals(void) {
  5106. +static mp_obj_t mp_builtin_locals(void) {
  5107. return MP_OBJ_FROM_PTR(mp_locals_get());
  5108. }
  5109. MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals);
  5110. @@ -600,7 +600,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals);
  5111. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_obj_id);
  5112. MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_obj_len);
  5113. -STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
  5114. +static const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
  5115. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_builtins) },
  5116. // built-in core functions
  5117. diff --git a/py/modcmath.c b/py/modcmath.c
  5118. index 1418362ad..33cb00cbe 100644
  5119. --- a/py/modcmath.c
  5120. +++ b/py/modcmath.c
  5121. @@ -31,15 +31,15 @@
  5122. #include <math.h>
  5123. // phase(z): returns the phase of the number z in the range (-pi, +pi]
  5124. -STATIC mp_obj_t mp_cmath_phase(mp_obj_t z_obj) {
  5125. +static mp_obj_t mp_cmath_phase(mp_obj_t z_obj) {
  5126. mp_float_t real, imag;
  5127. mp_obj_get_complex(z_obj, &real, &imag);
  5128. return mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real));
  5129. }
  5130. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase);
  5131. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_phase_obj, mp_cmath_phase);
  5132. // polar(z): returns the polar form of z as a tuple
  5133. -STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
  5134. +static mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
  5135. mp_float_t real, imag;
  5136. mp_obj_get_complex(z_obj, &real, &imag);
  5137. mp_obj_t tuple[2] = {
  5138. @@ -48,71 +48,71 @@ STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
  5139. };
  5140. return mp_obj_new_tuple(2, tuple);
  5141. }
  5142. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar);
  5143. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_polar_obj, mp_cmath_polar);
  5144. // rect(r, phi): returns the complex number with modulus r and phase phi
  5145. -STATIC mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) {
  5146. +static mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) {
  5147. mp_float_t r = mp_obj_get_float(r_obj);
  5148. mp_float_t phi = mp_obj_get_float(phi_obj);
  5149. return mp_obj_new_complex(r * MICROPY_FLOAT_C_FUN(cos)(phi), r * MICROPY_FLOAT_C_FUN(sin)(phi));
  5150. }
  5151. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect);
  5152. +static MP_DEFINE_CONST_FUN_OBJ_2(mp_cmath_rect_obj, mp_cmath_rect);
  5153. // exp(z): return the exponential of z
  5154. -STATIC mp_obj_t mp_cmath_exp(mp_obj_t z_obj) {
  5155. +static mp_obj_t mp_cmath_exp(mp_obj_t z_obj) {
  5156. mp_float_t real, imag;
  5157. mp_obj_get_complex(z_obj, &real, &imag);
  5158. mp_float_t exp_real = MICROPY_FLOAT_C_FUN(exp)(real);
  5159. return mp_obj_new_complex(exp_real * MICROPY_FLOAT_C_FUN(cos)(imag), exp_real * MICROPY_FLOAT_C_FUN(sin)(imag));
  5160. }
  5161. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp);
  5162. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_exp_obj, mp_cmath_exp);
  5163. // log(z): return the natural logarithm of z, with branch cut along the negative real axis
  5164. // TODO can take second argument, being the base
  5165. -STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
  5166. +static mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
  5167. mp_float_t real, imag;
  5168. mp_obj_get_complex(z_obj, &real, &imag);
  5169. 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));
  5170. }
  5171. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
  5172. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
  5173. #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
  5174. // log10(z): return the base-10 logarithm of z, with branch cut along the negative real axis
  5175. -STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
  5176. +static mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
  5177. mp_float_t real, imag;
  5178. mp_obj_get_complex(z_obj, &real, &imag);
  5179. 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));
  5180. }
  5181. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
  5182. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
  5183. #endif
  5184. // sqrt(z): return the square-root of z
  5185. -STATIC mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
  5186. +static mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
  5187. mp_float_t real, imag;
  5188. mp_obj_get_complex(z_obj, &real, &imag);
  5189. mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real * real + imag * imag, MICROPY_FLOAT_CONST(0.25));
  5190. mp_float_t theta = MICROPY_FLOAT_CONST(0.5) * MICROPY_FLOAT_C_FUN(atan2)(imag, real);
  5191. return mp_obj_new_complex(sqrt_abs * MICROPY_FLOAT_C_FUN(cos)(theta), sqrt_abs * MICROPY_FLOAT_C_FUN(sin)(theta));
  5192. }
  5193. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt);
  5194. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt);
  5195. // cos(z): return the cosine of z
  5196. -STATIC mp_obj_t mp_cmath_cos(mp_obj_t z_obj) {
  5197. +static mp_obj_t mp_cmath_cos(mp_obj_t z_obj) {
  5198. mp_float_t real, imag;
  5199. mp_obj_get_complex(z_obj, &real, &imag);
  5200. 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));
  5201. }
  5202. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos);
  5203. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_cos_obj, mp_cmath_cos);
  5204. // sin(z): return the sine of z
  5205. -STATIC mp_obj_t mp_cmath_sin(mp_obj_t z_obj) {
  5206. +static mp_obj_t mp_cmath_sin(mp_obj_t z_obj) {
  5207. mp_float_t real, imag;
  5208. mp_obj_get_complex(z_obj, &real, &imag);
  5209. 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));
  5210. }
  5211. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin);
  5212. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sin_obj, mp_cmath_sin);
  5213. -STATIC const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
  5214. +static const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
  5215. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_cmath) },
  5216. { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e },
  5217. { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi },
  5218. @@ -142,7 +142,7 @@ STATIC const mp_rom_map_elem_t mp_module_cmath_globals_table[] = {
  5219. // { MP_ROM_QSTR(MP_QSTR_isnan), MP_ROM_PTR(&mp_cmath_isnan_obj) },
  5220. };
  5221. -STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table);
  5222. +static MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table);
  5223. const mp_obj_module_t mp_module_cmath = {
  5224. .base = { &mp_type_module },
  5225. diff --git a/py/modcollections.c b/py/modcollections.c
  5226. index 30a5881bc..46326d13e 100644
  5227. --- a/py/modcollections.c
  5228. +++ b/py/modcollections.c
  5229. @@ -28,7 +28,7 @@
  5230. #if MICROPY_PY_COLLECTIONS
  5231. -STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
  5232. +static const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
  5233. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_collections) },
  5234. #if MICROPY_PY_COLLECTIONS_DEQUE
  5235. { MP_ROM_QSTR(MP_QSTR_deque), MP_ROM_PTR(&mp_type_deque) },
  5236. @@ -39,7 +39,7 @@ STATIC const mp_rom_map_elem_t mp_module_collections_globals_table[] = {
  5237. #endif
  5238. };
  5239. -STATIC MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table);
  5240. +static MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table);
  5241. const mp_obj_module_t mp_module_collections = {
  5242. .base = { &mp_type_module },
  5243. diff --git a/py/moderrno.c b/py/moderrno.c
  5244. index 4f0673a23..58a141c10 100644
  5245. --- a/py/moderrno.c
  5246. +++ b/py/moderrno.c
  5247. @@ -62,13 +62,13 @@
  5248. #endif
  5249. #if MICROPY_PY_ERRNO_ERRORCODE
  5250. -STATIC const mp_rom_map_elem_t errorcode_table[] = {
  5251. +static const mp_rom_map_elem_t errorcode_table[] = {
  5252. #define X(e) { MP_ROM_INT(MP_##e), MP_ROM_QSTR(MP_QSTR_##e) },
  5253. MICROPY_PY_ERRNO_LIST
  5254. #undef X
  5255. };
  5256. -STATIC const mp_obj_dict_t errorcode_dict = {
  5257. +static const mp_obj_dict_t errorcode_dict = {
  5258. .base = {&mp_type_dict},
  5259. .map = {
  5260. .all_keys_are_qstrs = 0, // keys are integers
  5261. @@ -81,7 +81,7 @@ STATIC const mp_obj_dict_t errorcode_dict = {
  5262. };
  5263. #endif
  5264. -STATIC const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
  5265. +static const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
  5266. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_errno) },
  5267. #if MICROPY_PY_ERRNO_ERRORCODE
  5268. { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) },
  5269. @@ -92,7 +92,7 @@ STATIC const mp_rom_map_elem_t mp_module_errno_globals_table[] = {
  5270. #undef X
  5271. };
  5272. -STATIC MP_DEFINE_CONST_DICT(mp_module_errno_globals, mp_module_errno_globals_table);
  5273. +static MP_DEFINE_CONST_DICT(mp_module_errno_globals, mp_module_errno_globals_table);
  5274. const mp_obj_module_t mp_module_errno = {
  5275. .base = { &mp_type_module },
  5276. diff --git a/py/modgc.c b/py/modgc.c
  5277. index 7b18045b0..47902d8c9 100644
  5278. --- a/py/modgc.c
  5279. +++ b/py/modgc.c
  5280. @@ -31,7 +31,7 @@
  5281. #if MICROPY_PY_GC && MICROPY_ENABLE_GC
  5282. // collect(): run a garbage collection
  5283. -STATIC mp_obj_t py_gc_collect(void) {
  5284. +static mp_obj_t py_gc_collect(void) {
  5285. gc_collect();
  5286. #if MICROPY_PY_GC_COLLECT_RETVAL
  5287. return MP_OBJ_NEW_SMALL_INT(MP_STATE_MEM(gc_collected));
  5288. @@ -42,26 +42,26 @@ STATIC mp_obj_t py_gc_collect(void) {
  5289. MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect);
  5290. // disable(): disable the garbage collector
  5291. -STATIC mp_obj_t gc_disable(void) {
  5292. +static mp_obj_t gc_disable(void) {
  5293. MP_STATE_MEM(gc_auto_collect_enabled) = 0;
  5294. return mp_const_none;
  5295. }
  5296. MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable);
  5297. // enable(): enable the garbage collector
  5298. -STATIC mp_obj_t gc_enable(void) {
  5299. +static mp_obj_t gc_enable(void) {
  5300. MP_STATE_MEM(gc_auto_collect_enabled) = 1;
  5301. return mp_const_none;
  5302. }
  5303. MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable);
  5304. -STATIC mp_obj_t gc_isenabled(void) {
  5305. +static mp_obj_t gc_isenabled(void) {
  5306. return mp_obj_new_bool(MP_STATE_MEM(gc_auto_collect_enabled));
  5307. }
  5308. MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled);
  5309. // mem_free(): return the number of bytes of available heap RAM
  5310. -STATIC mp_obj_t gc_mem_free(void) {
  5311. +static mp_obj_t gc_mem_free(void) {
  5312. gc_info_t info;
  5313. gc_info(&info);
  5314. #if MICROPY_GC_SPLIT_HEAP_AUTO
  5315. @@ -74,7 +74,7 @@ STATIC mp_obj_t gc_mem_free(void) {
  5316. MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_free_obj, gc_mem_free);
  5317. // mem_alloc(): return the number of bytes of heap RAM that are allocated
  5318. -STATIC mp_obj_t gc_mem_alloc(void) {
  5319. +static mp_obj_t gc_mem_alloc(void) {
  5320. gc_info_t info;
  5321. gc_info(&info);
  5322. return MP_OBJ_NEW_SMALL_INT(info.used);
  5323. @@ -82,7 +82,7 @@ STATIC mp_obj_t gc_mem_alloc(void) {
  5324. MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_alloc_obj, gc_mem_alloc);
  5325. #if MICROPY_GC_ALLOC_THRESHOLD
  5326. -STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
  5327. +static mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
  5328. if (n_args == 0) {
  5329. if (MP_STATE_MEM(gc_alloc_threshold) == (size_t)-1) {
  5330. return MP_OBJ_NEW_SMALL_INT(-1);
  5331. @@ -100,7 +100,7 @@ STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
  5332. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gc_threshold_obj, 0, 1, gc_threshold);
  5333. #endif
  5334. -STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
  5335. +static const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
  5336. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gc) },
  5337. { MP_ROM_QSTR(MP_QSTR_collect), MP_ROM_PTR(&gc_collect_obj) },
  5338. { MP_ROM_QSTR(MP_QSTR_disable), MP_ROM_PTR(&gc_disable_obj) },
  5339. @@ -113,7 +113,7 @@ STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
  5340. #endif
  5341. };
  5342. -STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
  5343. +static MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
  5344. const mp_obj_module_t mp_module_gc = {
  5345. .base = { &mp_type_module },
  5346. diff --git a/py/modio.c b/py/modio.c
  5347. index 39317c52d..d3e563dbc 100644
  5348. --- a/py/modio.c
  5349. +++ b/py/modio.c
  5350. @@ -39,11 +39,11 @@
  5351. #if MICROPY_PY_IO_IOBASE
  5352. -STATIC const mp_obj_type_t mp_type_iobase;
  5353. +static const mp_obj_type_t mp_type_iobase;
  5354. -STATIC const mp_obj_base_t iobase_singleton = {&mp_type_iobase};
  5355. +static const mp_obj_base_t iobase_singleton = {&mp_type_iobase};
  5356. -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) {
  5357. +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) {
  5358. (void)type;
  5359. (void)n_args;
  5360. (void)n_kw;
  5361. @@ -51,7 +51,7 @@ STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t
  5362. return MP_OBJ_FROM_PTR(&iobase_singleton);
  5363. }
  5364. -STATIC mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode, qstr qst) {
  5365. +static mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode, qstr qst) {
  5366. mp_obj_t dest[3];
  5367. mp_load_method(obj, qst, dest);
  5368. mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, size, buf};
  5369. @@ -69,15 +69,15 @@ STATIC mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int
  5370. return MP_STREAM_ERROR;
  5371. }
  5372. }
  5373. -STATIC mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
  5374. +static mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
  5375. return iobase_read_write(obj, buf, size, errcode, MP_QSTR_readinto);
  5376. }
  5377. -STATIC mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
  5378. +static mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
  5379. return iobase_read_write(obj, (void *)buf, size, errcode, MP_QSTR_write);
  5380. }
  5381. -STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
  5382. +static mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
  5383. mp_obj_t dest[4];
  5384. mp_load_method(obj, MP_QSTR_ioctl, dest);
  5385. dest[2] = mp_obj_new_int_from_uint(request);
  5386. @@ -91,13 +91,13 @@ STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, in
  5387. }
  5388. }
  5389. -STATIC const mp_stream_p_t iobase_p = {
  5390. +static const mp_stream_p_t iobase_p = {
  5391. .read = iobase_read,
  5392. .write = iobase_write,
  5393. .ioctl = iobase_ioctl,
  5394. };
  5395. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  5396. +static MP_DEFINE_CONST_OBJ_TYPE(
  5397. mp_type_iobase,
  5398. MP_QSTR_IOBase,
  5399. MP_TYPE_FLAG_NONE,
  5400. @@ -116,17 +116,17 @@ typedef struct _mp_obj_bufwriter_t {
  5401. byte buf[0];
  5402. } mp_obj_bufwriter_t;
  5403. -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) {
  5404. +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) {
  5405. mp_arg_check_num(n_args, n_kw, 2, 2, false);
  5406. size_t alloc = mp_obj_get_int(args[1]);
  5407. - mp_obj_bufwriter_t *o = mp_obj_malloc_var(mp_obj_bufwriter_t, byte, alloc, type);
  5408. + mp_obj_bufwriter_t *o = mp_obj_malloc_var(mp_obj_bufwriter_t, buf, byte, alloc, type);
  5409. o->stream = args[0];
  5410. o->alloc = alloc;
  5411. o->len = 0;
  5412. return o;
  5413. }
  5414. -STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
  5415. +static mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
  5416. mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in);
  5417. mp_uint_t org_size = size;
  5418. @@ -162,7 +162,7 @@ STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t si
  5419. return org_size;
  5420. }
  5421. -STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) {
  5422. +static mp_obj_t bufwriter_flush(mp_obj_t self_in) {
  5423. mp_obj_bufwriter_t *self = MP_OBJ_TO_PTR(self_in);
  5424. if (self->len != 0) {
  5425. @@ -180,19 +180,19 @@ STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) {
  5426. return mp_const_none;
  5427. }
  5428. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush);
  5429. +static MP_DEFINE_CONST_FUN_OBJ_1(bufwriter_flush_obj, bufwriter_flush);
  5430. -STATIC const mp_rom_map_elem_t bufwriter_locals_dict_table[] = {
  5431. +static const mp_rom_map_elem_t bufwriter_locals_dict_table[] = {
  5432. { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
  5433. { MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&bufwriter_flush_obj) },
  5434. };
  5435. -STATIC MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table);
  5436. +static MP_DEFINE_CONST_DICT(bufwriter_locals_dict, bufwriter_locals_dict_table);
  5437. -STATIC const mp_stream_p_t bufwriter_stream_p = {
  5438. +static const mp_stream_p_t bufwriter_stream_p = {
  5439. .write = bufwriter_write,
  5440. };
  5441. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  5442. +static MP_DEFINE_CONST_OBJ_TYPE(
  5443. mp_type_bufwriter,
  5444. MP_QSTR_BufferedWriter,
  5445. MP_TYPE_FLAG_NONE,
  5446. @@ -202,7 +202,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
  5447. );
  5448. #endif // MICROPY_PY_IO_BUFFEREDWRITER
  5449. -STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = {
  5450. +static const mp_rom_map_elem_t mp_module_io_globals_table[] = {
  5451. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io) },
  5452. // Note: mp_builtin_open_obj should be defined by port, it's not
  5453. // part of the core.
  5454. @@ -219,7 +219,7 @@ STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = {
  5455. #endif
  5456. };
  5457. -STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
  5458. +static MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
  5459. const mp_obj_module_t mp_module_io = {
  5460. .base = { &mp_type_module },
  5461. diff --git a/py/modmath.c b/py/modmath.c
  5462. index 861a23b48..db30f0e62 100644
  5463. --- a/py/modmath.c
  5464. +++ b/py/modmath.c
  5465. @@ -37,11 +37,11 @@
  5466. #define MP_PI_4 MICROPY_FLOAT_CONST(0.78539816339744830962)
  5467. #define MP_3_PI_4 MICROPY_FLOAT_CONST(2.35619449019234492885)
  5468. -STATIC NORETURN void math_error(void) {
  5469. +static NORETURN void math_error(void) {
  5470. mp_raise_ValueError(MP_ERROR_TEXT("math domain error"));
  5471. }
  5472. -STATIC mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
  5473. +static mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
  5474. mp_float_t x = mp_obj_get_float(x_obj);
  5475. mp_float_t ans = f(x);
  5476. if ((isnan(ans) && !isnan(x)) || (isinf(ans) && !isinf(x))) {
  5477. @@ -50,7 +50,7 @@ STATIC mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_t)) {
  5478. return mp_obj_new_float(ans);
  5479. }
  5480. -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)) {
  5481. +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)) {
  5482. mp_float_t x = mp_obj_get_float(x_obj);
  5483. mp_float_t y = mp_obj_get_float(y_obj);
  5484. mp_float_t ans = f(x, y);
  5485. @@ -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
  5486. }
  5487. #define MATH_FUN_1(py_name, c_name) \
  5488. - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \
  5489. + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \
  5490. return math_generic_1(x_obj, MICROPY_FLOAT_C_FUN(c_name)); \
  5491. } \
  5492. - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
  5493. + static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
  5494. #define MATH_FUN_1_TO_BOOL(py_name, c_name) \
  5495. - 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))); } \
  5496. - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
  5497. + 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))); } \
  5498. + static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
  5499. #define MATH_FUN_1_TO_INT(py_name, c_name) \
  5500. - 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))); } \
  5501. - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
  5502. + 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))); } \
  5503. + static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
  5504. #define MATH_FUN_2(py_name, c_name) \
  5505. - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
  5506. + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
  5507. return math_generic_2(x_obj, y_obj, MICROPY_FLOAT_C_FUN(c_name)); \
  5508. } \
  5509. - STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
  5510. + static MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
  5511. #define MATH_FUN_2_FLT_INT(py_name, c_name) \
  5512. - STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
  5513. + static mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
  5514. return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_int(y_obj))); \
  5515. } \
  5516. - STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
  5517. + static MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
  5518. #if MP_NEED_LOG2
  5519. #undef log2
  5520. @@ -160,12 +160,12 @@ MATH_FUN_2(atan2, atan2)
  5521. // ceil(x)
  5522. MATH_FUN_1_TO_INT(ceil, ceil)
  5523. // copysign(x, y)
  5524. -STATIC mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
  5525. +static mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
  5526. return MICROPY_FLOAT_C_FUN(copysign)(x, y);
  5527. }
  5528. MATH_FUN_2(copysign, copysign_func)
  5529. // fabs(x)
  5530. -STATIC mp_float_t MICROPY_FLOAT_C_FUN(fabs_func)(mp_float_t x) {
  5531. +static mp_float_t MICROPY_FLOAT_C_FUN(fabs_func)(mp_float_t x) {
  5532. return MICROPY_FLOAT_C_FUN(fabs)(x);
  5533. }
  5534. MATH_FUN_1(fabs, fabs_func)
  5535. @@ -203,7 +203,7 @@ MATH_FUN_1(lgamma, lgamma)
  5536. // TODO: fsum
  5537. #if MICROPY_PY_MATH_ISCLOSE
  5538. -STATIC mp_obj_t mp_math_isclose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  5539. +static mp_obj_t mp_math_isclose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  5540. enum { ARG_rel_tol, ARG_abs_tol };
  5541. static const mp_arg_t allowed_args[] = {
  5542. {MP_QSTR_rel_tol, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}},
  5543. @@ -239,7 +239,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_math_isclose_obj, 2, mp_math_isclose);
  5544. // Function that takes a variable number of arguments
  5545. // log(x[, base])
  5546. -STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
  5547. +static mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
  5548. mp_float_t x = mp_obj_get_float(args[0]);
  5549. if (x <= (mp_float_t)0.0) {
  5550. math_error();
  5551. @@ -257,12 +257,12 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
  5552. return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base));
  5553. }
  5554. }
  5555. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log);
  5556. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_math_log_obj, 1, 2, mp_math_log);
  5557. // Functions that return a tuple
  5558. // frexp(x): converts a floating-point number to fractional and integral components
  5559. -STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
  5560. +static mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
  5561. int int_exponent = 0;
  5562. mp_float_t significand = MICROPY_FLOAT_C_FUN(frexp)(mp_obj_get_float(x_obj), &int_exponent);
  5563. mp_obj_t tuple[2];
  5564. @@ -270,10 +270,10 @@ STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
  5565. tuple[1] = mp_obj_new_int(int_exponent);
  5566. return mp_obj_new_tuple(2, tuple);
  5567. }
  5568. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp);
  5569. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_frexp_obj, mp_math_frexp);
  5570. // modf(x)
  5571. -STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) {
  5572. +static mp_obj_t mp_math_modf(mp_obj_t x_obj) {
  5573. mp_float_t int_part = 0.0;
  5574. mp_float_t x = mp_obj_get_float(x_obj);
  5575. mp_float_t fractional_part = MICROPY_FLOAT_C_FUN(modf)(x, &int_part);
  5576. @@ -287,28 +287,28 @@ STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) {
  5577. tuple[1] = mp_obj_new_float(int_part);
  5578. return mp_obj_new_tuple(2, tuple);
  5579. }
  5580. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf);
  5581. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_modf_obj, mp_math_modf);
  5582. // Angular conversions
  5583. // radians(x)
  5584. -STATIC mp_obj_t mp_math_radians(mp_obj_t x_obj) {
  5585. +static mp_obj_t mp_math_radians(mp_obj_t x_obj) {
  5586. return mp_obj_new_float(mp_obj_get_float(x_obj) * (MP_PI / MICROPY_FLOAT_CONST(180.0)));
  5587. }
  5588. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians);
  5589. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_radians_obj, mp_math_radians);
  5590. // degrees(x)
  5591. -STATIC mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
  5592. +static mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
  5593. return mp_obj_new_float(mp_obj_get_float(x_obj) * (MICROPY_FLOAT_CONST(180.0) / MP_PI));
  5594. }
  5595. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees);
  5596. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_degrees_obj, mp_math_degrees);
  5597. #if MICROPY_PY_MATH_FACTORIAL
  5598. #if MICROPY_OPT_MATH_FACTORIAL
  5599. // factorial(x): slightly efficient recursive implementation
  5600. -STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
  5601. +static mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
  5602. if (start == end) {
  5603. return mp_obj_new_int(start);
  5604. } else if (end - start == 1) {
  5605. @@ -326,7 +326,7 @@ STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
  5606. return mp_binary_op(MP_BINARY_OP_MULTIPLY, left, right);
  5607. }
  5608. }
  5609. -STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
  5610. +static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
  5611. mp_int_t max = mp_obj_get_int(x_obj);
  5612. if (max < 0) {
  5613. mp_raise_ValueError(MP_ERROR_TEXT("negative factorial"));
  5614. @@ -340,7 +340,7 @@ STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
  5615. // factorial(x): squared difference implementation
  5616. // based on http://www.luschny.de/math/factorial/index.html
  5617. -STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
  5618. +static mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
  5619. mp_int_t max = mp_obj_get_int(x_obj);
  5620. if (max < 0) {
  5621. mp_raise_ValueError(MP_ERROR_TEXT("negative factorial"));
  5622. @@ -363,11 +363,11 @@ STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
  5623. #endif
  5624. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_factorial_obj, mp_math_factorial);
  5625. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_math_factorial_obj, mp_math_factorial);
  5626. #endif
  5627. -STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = {
  5628. +static const mp_rom_map_elem_t mp_module_math_globals_table[] = {
  5629. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_math) },
  5630. { MP_ROM_QSTR(MP_QSTR_e), mp_const_float_e },
  5631. { MP_ROM_QSTR(MP_QSTR_pi), mp_const_float_pi },
  5632. @@ -428,7 +428,7 @@ STATIC const mp_rom_map_elem_t mp_module_math_globals_table[] = {
  5633. #endif
  5634. };
  5635. -STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table);
  5636. +static MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table);
  5637. const mp_obj_module_t mp_module_math = {
  5638. .base = { &mp_type_module },
  5639. diff --git a/py/modmicropython.c b/py/modmicropython.c
  5640. index bdb1e8b9b..af6ad0179 100644
  5641. --- a/py/modmicropython.c
  5642. +++ b/py/modmicropython.c
  5643. @@ -38,7 +38,7 @@
  5644. // living in micropython module
  5645. #if MICROPY_ENABLE_COMPILER
  5646. -STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
  5647. +static mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
  5648. if (n_args == 0) {
  5649. return MP_OBJ_NEW_SMALL_INT(MP_STATE_VM(mp_optimise_value));
  5650. } else {
  5651. @@ -46,26 +46,26 @@ STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *args) {
  5652. return mp_const_none;
  5653. }
  5654. }
  5655. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level);
  5656. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_opt_level_obj, 0, 1, mp_micropython_opt_level);
  5657. #endif
  5658. #if MICROPY_PY_MICROPYTHON_MEM_INFO
  5659. #if MICROPY_MEM_STATS
  5660. -STATIC mp_obj_t mp_micropython_mem_total(void) {
  5661. +static mp_obj_t mp_micropython_mem_total(void) {
  5662. return MP_OBJ_NEW_SMALL_INT(m_get_total_bytes_allocated());
  5663. }
  5664. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total);
  5665. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_total_obj, mp_micropython_mem_total);
  5666. -STATIC mp_obj_t mp_micropython_mem_current(void) {
  5667. +static mp_obj_t mp_micropython_mem_current(void) {
  5668. return MP_OBJ_NEW_SMALL_INT(m_get_current_bytes_allocated());
  5669. }
  5670. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current);
  5671. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_current_obj, mp_micropython_mem_current);
  5672. -STATIC mp_obj_t mp_micropython_mem_peak(void) {
  5673. +static mp_obj_t mp_micropython_mem_peak(void) {
  5674. return MP_OBJ_NEW_SMALL_INT(m_get_peak_bytes_allocated());
  5675. }
  5676. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak);
  5677. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem_peak);
  5678. #endif
  5679. mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
  5680. @@ -91,9 +91,9 @@ mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
  5681. #endif
  5682. return mp_const_none;
  5683. }
  5684. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info);
  5685. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info);
  5686. -STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
  5687. +static mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
  5688. (void)args;
  5689. size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
  5690. qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
  5691. @@ -105,68 +105,68 @@ STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *args) {
  5692. }
  5693. return mp_const_none;
  5694. }
  5695. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info);
  5696. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_qstr_info_obj, 0, 1, mp_micropython_qstr_info);
  5697. #endif // MICROPY_PY_MICROPYTHON_MEM_INFO
  5698. #if MICROPY_PY_MICROPYTHON_STACK_USE
  5699. -STATIC mp_obj_t mp_micropython_stack_use(void) {
  5700. +static mp_obj_t mp_micropython_stack_use(void) {
  5701. return MP_OBJ_NEW_SMALL_INT(mp_stack_usage());
  5702. }
  5703. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use);
  5704. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_stack_use_obj, mp_micropython_stack_use);
  5705. #endif
  5706. #if MICROPY_ENABLE_PYSTACK
  5707. -STATIC mp_obj_t mp_micropython_pystack_use(void) {
  5708. +static mp_obj_t mp_micropython_pystack_use(void) {
  5709. return MP_OBJ_NEW_SMALL_INT(mp_pystack_usage());
  5710. }
  5711. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_pystack_use_obj, mp_micropython_pystack_use);
  5712. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_pystack_use_obj, mp_micropython_pystack_use);
  5713. #endif
  5714. #if MICROPY_ENABLE_GC
  5715. -STATIC mp_obj_t mp_micropython_heap_lock(void) {
  5716. +static mp_obj_t mp_micropython_heap_lock(void) {
  5717. gc_lock();
  5718. return mp_const_none;
  5719. }
  5720. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock);
  5721. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_lock_obj, mp_micropython_heap_lock);
  5722. -STATIC mp_obj_t mp_micropython_heap_unlock(void) {
  5723. +static mp_obj_t mp_micropython_heap_unlock(void) {
  5724. gc_unlock();
  5725. return MP_OBJ_NEW_SMALL_INT(MP_STATE_THREAD(gc_lock_depth));
  5726. }
  5727. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock);
  5728. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_unlock_obj, mp_micropython_heap_unlock);
  5729. #if MICROPY_PY_MICROPYTHON_HEAP_LOCKED
  5730. -STATIC mp_obj_t mp_micropython_heap_locked(void) {
  5731. +static mp_obj_t mp_micropython_heap_locked(void) {
  5732. return MP_OBJ_NEW_SMALL_INT(MP_STATE_THREAD(gc_lock_depth));
  5733. }
  5734. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_locked_obj, mp_micropython_heap_locked);
  5735. +static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_heap_locked_obj, mp_micropython_heap_locked);
  5736. #endif
  5737. #endif
  5738. #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0)
  5739. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf);
  5740. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_alloc_emergency_exception_buf_obj, mp_alloc_emergency_exception_buf);
  5741. #endif
  5742. #if MICROPY_KBD_EXCEPTION
  5743. -STATIC mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) {
  5744. +static mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) {
  5745. mp_hal_set_interrupt_char(mp_obj_get_int(int_chr_in));
  5746. return mp_const_none;
  5747. }
  5748. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr);
  5749. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_micropython_kbd_intr_obj, mp_micropython_kbd_intr);
  5750. #endif
  5751. #if MICROPY_ENABLE_SCHEDULER
  5752. -STATIC mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
  5753. +static mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
  5754. if (!mp_sched_schedule(function, arg)) {
  5755. mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("schedule queue full"));
  5756. }
  5757. return mp_const_none;
  5758. }
  5759. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
  5760. +static MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
  5761. #endif
  5762. -STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
  5763. +static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
  5764. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_micropython) },
  5765. { MP_ROM_QSTR(MP_QSTR_const), MP_ROM_PTR(&mp_identity_obj) },
  5766. #if MICROPY_ENABLE_COMPILER
  5767. @@ -205,7 +205,7 @@ STATIC const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
  5768. #endif
  5769. };
  5770. -STATIC MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table);
  5771. +static MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table);
  5772. const mp_obj_module_t mp_module_micropython = {
  5773. .base = { &mp_type_module },
  5774. diff --git a/py/modstruct.c b/py/modstruct.c
  5775. index b3edc9632..3b9dd30aa 100644
  5776. --- a/py/modstruct.c
  5777. +++ b/py/modstruct.c
  5778. @@ -52,7 +52,7 @@
  5779. character data".
  5780. */
  5781. -STATIC char get_fmt_type(const char **fmt) {
  5782. +static char get_fmt_type(const char **fmt) {
  5783. char t = **fmt;
  5784. switch (t) {
  5785. case '!':
  5786. @@ -71,7 +71,7 @@ STATIC char get_fmt_type(const char **fmt) {
  5787. return t;
  5788. }
  5789. -STATIC mp_uint_t get_fmt_num(const char **p) {
  5790. +static mp_uint_t get_fmt_num(const char **p) {
  5791. const char *num = *p;
  5792. uint len = 1;
  5793. while (unichar_isdigit(*++num)) {
  5794. @@ -82,7 +82,7 @@ STATIC mp_uint_t get_fmt_num(const char **p) {
  5795. return val;
  5796. }
  5797. -STATIC size_t calc_size_items(const char *fmt, size_t *total_sz) {
  5798. +static size_t calc_size_items(const char *fmt, size_t *total_sz) {
  5799. char fmt_type = get_fmt_type(&fmt);
  5800. size_t total_cnt = 0;
  5801. size_t size;
  5802. @@ -112,7 +112,7 @@ STATIC size_t calc_size_items(const char *fmt, size_t *total_sz) {
  5803. return total_cnt;
  5804. }
  5805. -STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
  5806. +static mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
  5807. const char *fmt = mp_obj_str_get_str(fmt_in);
  5808. size_t size;
  5809. calc_size_items(fmt, &size);
  5810. @@ -120,7 +120,7 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
  5811. }
  5812. MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
  5813. -STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
  5814. +static mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
  5815. // unpack requires that the buffer be exactly the right size.
  5816. // unpack_from requires that the buffer be "big enough".
  5817. // Since we implement unpack and unpack_from using the same function
  5818. @@ -180,7 +180,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
  5819. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_from);
  5820. // This function assumes there is enough room in p to store all the values
  5821. -STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
  5822. +static void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, const mp_obj_t *args) {
  5823. const char *fmt = mp_obj_str_get_str(fmt_in);
  5824. char fmt_type = get_fmt_type(&fmt);
  5825. @@ -219,7 +219,7 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c
  5826. }
  5827. }
  5828. -STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
  5829. +static mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
  5830. // TODO: "The arguments must match the values required by the format exactly."
  5831. mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0]));
  5832. vstr_t vstr;
  5833. @@ -231,7 +231,7 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
  5834. }
  5835. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack);
  5836. -STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
  5837. +static mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
  5838. mp_buffer_info_t bufinfo;
  5839. mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
  5840. mp_int_t offset = mp_obj_get_int(args[2]);
  5841. @@ -257,7 +257,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
  5842. }
  5843. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into);
  5844. -STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
  5845. +static const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
  5846. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_struct) },
  5847. { MP_ROM_QSTR(MP_QSTR_calcsize), MP_ROM_PTR(&struct_calcsize_obj) },
  5848. { MP_ROM_QSTR(MP_QSTR_pack), MP_ROM_PTR(&struct_pack_obj) },
  5849. @@ -266,7 +266,7 @@ STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
  5850. { MP_ROM_QSTR(MP_QSTR_unpack_from), MP_ROM_PTR(&struct_unpack_from_obj) },
  5851. };
  5852. -STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table);
  5853. +static MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table);
  5854. const mp_obj_module_t mp_module_struct = {
  5855. .base = { &mp_type_module },
  5856. diff --git a/py/modsys.c b/py/modsys.c
  5857. index 2af81046f..e90ea2233 100644
  5858. --- a/py/modsys.c
  5859. +++ b/py/modsys.c
  5860. @@ -56,15 +56,15 @@ const mp_print_t mp_sys_stdout_print = {&mp_sys_stdout_obj, mp_stream_write_adap
  5861. #endif
  5862. // version - Python language version that this implementation conforms to, as a string
  5863. -STATIC const MP_DEFINE_STR_OBJ(mp_sys_version_obj, "3.4.0; " MICROPY_BANNER_NAME_AND_VERSION);
  5864. +static const MP_DEFINE_STR_OBJ(mp_sys_version_obj, "3.4.0; " MICROPY_BANNER_NAME_AND_VERSION);
  5865. // version_info - Python language version that this implementation conforms to, as a tuple of ints
  5866. // TODO: CPython is now at 5-element array (major, minor, micro, releaselevel, serial), but save 2 els so far...
  5867. -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)}};
  5868. +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)}};
  5869. // sys.implementation object
  5870. // this holds the MicroPython version
  5871. -STATIC const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
  5872. +static const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
  5873. {&mp_type_tuple},
  5874. 4,
  5875. {
  5876. @@ -78,7 +78,7 @@ STATIC const mp_rom_obj_tuple_t mp_sys_implementation_version_info_obj = {
  5877. #endif
  5878. }
  5879. };
  5880. -STATIC const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER_MACHINE);
  5881. +static const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER_MACHINE);
  5882. #define SYS_IMPLEMENTATION_ELEMS_BASE \
  5883. MP_ROM_QSTR(MP_QSTR_micropython), \
  5884. MP_ROM_PTR(&mp_sys_implementation_version_info_obj), \
  5885. @@ -99,7 +99,7 @@ STATIC const MP_DEFINE_STR_OBJ(mp_sys_implementation_machine_obj, MICROPY_BANNER
  5886. #define SYS_IMPLEMENTATION_ELEMS__V2
  5887. #endif
  5888. -STATIC const qstr impl_fields[] = {
  5889. +static const qstr impl_fields[] = {
  5890. MP_QSTR_name,
  5891. MP_QSTR_version,
  5892. MP_QSTR__machine,
  5893. @@ -110,7 +110,7 @@ STATIC const qstr impl_fields[] = {
  5894. MP_QSTR__v2,
  5895. #endif
  5896. };
  5897. -STATIC MP_DEFINE_ATTRTUPLE(
  5898. +static MP_DEFINE_ATTRTUPLE(
  5899. mp_sys_implementation_obj,
  5900. impl_fields,
  5901. 3 + MICROPY_PERSISTENT_CODE_LOAD + MICROPY_PREVIEW_VERSION_2,
  5902. @@ -119,7 +119,7 @@ STATIC MP_DEFINE_ATTRTUPLE(
  5903. SYS_IMPLEMENTATION_ELEMS__V2
  5904. );
  5905. #else
  5906. -STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
  5907. +static const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
  5908. {&mp_type_tuple},
  5909. 3 + MICROPY_PERSISTENT_CODE_LOAD,
  5910. // Do not include SYS_IMPLEMENTATION_ELEMS__V2 because
  5911. @@ -138,7 +138,7 @@ STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
  5912. #ifdef MICROPY_PY_SYS_PLATFORM
  5913. // platform - the platform that MicroPython is running on
  5914. -STATIC const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM);
  5915. +static const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM);
  5916. #endif
  5917. #ifdef MICROPY_PY_SYS_EXECUTABLE
  5918. @@ -152,7 +152,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_intern_obj, mp_obj_str_intern_checked);
  5919. #endif
  5920. // exit([retval]): raise SystemExit, with optional argument given to the exception
  5921. -STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
  5922. +static mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
  5923. if (n_args == 0) {
  5924. mp_raise_type(&mp_type_SystemExit);
  5925. } else {
  5926. @@ -161,7 +161,7 @@ STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
  5927. }
  5928. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit);
  5929. -STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
  5930. +static mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
  5931. #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
  5932. void *stream_obj = &mp_sys_stdout_obj;
  5933. if (n_args > 1) {
  5934. @@ -181,7 +181,7 @@ STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *args) {
  5935. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_print_exception_obj, 1, 2, mp_sys_print_exception);
  5936. #if MICROPY_PY_SYS_EXC_INFO
  5937. -STATIC mp_obj_t mp_sys_exc_info(void) {
  5938. +static mp_obj_t mp_sys_exc_info(void) {
  5939. mp_obj_t cur_exc = MP_OBJ_FROM_PTR(MP_STATE_VM(cur_exception));
  5940. mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
  5941. @@ -201,25 +201,25 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_exc_info_obj, mp_sys_exc_info);
  5942. #endif
  5943. #if MICROPY_PY_SYS_GETSIZEOF
  5944. -STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
  5945. +static mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
  5946. return mp_unary_op(MP_UNARY_OP_SIZEOF, obj);
  5947. }
  5948. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
  5949. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
  5950. #endif
  5951. #if MICROPY_PY_SYS_ATEXIT
  5952. // atexit(callback): Callback is called when sys.exit is called.
  5953. -STATIC mp_obj_t mp_sys_atexit(mp_obj_t obj) {
  5954. +static mp_obj_t mp_sys_atexit(mp_obj_t obj) {
  5955. mp_obj_t old = MP_STATE_VM(sys_exitfunc);
  5956. MP_STATE_VM(sys_exitfunc) = obj;
  5957. return old;
  5958. }
  5959. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit);
  5960. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit);
  5961. #endif
  5962. #if MICROPY_PY_SYS_SETTRACE
  5963. // settrace(tracefunc): Set the system's trace function.
  5964. -STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) {
  5965. +static mp_obj_t mp_sys_settrace(mp_obj_t obj) {
  5966. return mp_prof_settrace(obj);
  5967. }
  5968. MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace);
  5969. @@ -243,7 +243,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace);
  5970. #if MICROPY_PY_SYS_ATTR_DELEGATION
  5971. // Must be kept in sync with the enum at the top of mpstate.h.
  5972. -STATIC const uint16_t sys_mutable_keys[] = {
  5973. +static const uint16_t sys_mutable_keys[] = {
  5974. #if MICROPY_PY_SYS_PATH
  5975. // Code should access this (as an mp_obj_t) for use with e.g.
  5976. // mp_obj_list_append by using the `mp_sys_path` macro defined in runtime.h.
  5977. @@ -266,7 +266,7 @@ void mp_module_sys_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  5978. }
  5979. #endif
  5980. -STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
  5981. +static const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
  5982. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys) },
  5983. #if MICROPY_PY_SYS_ARGV
  5984. @@ -339,7 +339,7 @@ STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
  5985. #endif
  5986. };
  5987. -STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);
  5988. +static MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table);
  5989. const mp_obj_module_t mp_module_sys = {
  5990. .base = { &mp_type_module },
  5991. diff --git a/py/modthread.c b/py/modthread.c
  5992. index 3a8a1e03c..2826fadea 100644
  5993. --- a/py/modthread.c
  5994. +++ b/py/modthread.c
  5995. @@ -45,7 +45,7 @@
  5996. /****************************************************************/
  5997. // Lock object
  5998. -STATIC const mp_obj_type_t mp_type_thread_lock;
  5999. +static const mp_obj_type_t mp_type_thread_lock;
  6000. typedef struct _mp_obj_thread_lock_t {
  6001. mp_obj_base_t base;
  6002. @@ -53,14 +53,14 @@ typedef struct _mp_obj_thread_lock_t {
  6003. volatile bool locked;
  6004. } mp_obj_thread_lock_t;
  6005. -STATIC mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) {
  6006. +static mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) {
  6007. mp_obj_thread_lock_t *self = mp_obj_malloc(mp_obj_thread_lock_t, &mp_type_thread_lock);
  6008. mp_thread_mutex_init(&self->mutex);
  6009. self->locked = false;
  6010. return self;
  6011. }
  6012. -STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
  6013. +static mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
  6014. mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(args[0]);
  6015. bool wait = true;
  6016. if (n_args > 1) {
  6017. @@ -79,9 +79,9 @@ STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
  6018. mp_raise_OSError(-ret);
  6019. }
  6020. }
  6021. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire);
  6022. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread_lock_acquire);
  6023. -STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) {
  6024. +static mp_obj_t thread_lock_release(mp_obj_t self_in) {
  6025. mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in);
  6026. if (!self->locked) {
  6027. mp_raise_msg(&mp_type_RuntimeError, NULL);
  6028. @@ -92,21 +92,21 @@ STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) {
  6029. MP_THREAD_GIL_ENTER();
  6030. return mp_const_none;
  6031. }
  6032. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release);
  6033. +static MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_release_obj, thread_lock_release);
  6034. -STATIC mp_obj_t thread_lock_locked(mp_obj_t self_in) {
  6035. +static mp_obj_t thread_lock_locked(mp_obj_t self_in) {
  6036. mp_obj_thread_lock_t *self = MP_OBJ_TO_PTR(self_in);
  6037. return mp_obj_new_bool(self->locked);
  6038. }
  6039. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked);
  6040. +static MP_DEFINE_CONST_FUN_OBJ_1(thread_lock_locked_obj, thread_lock_locked);
  6041. -STATIC mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) {
  6042. +static mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) {
  6043. (void)n_args; // unused
  6044. return thread_lock_release(args[0]);
  6045. }
  6046. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__);
  6047. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock___exit___obj, 4, 4, thread_lock___exit__);
  6048. -STATIC const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
  6049. +static const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
  6050. { MP_ROM_QSTR(MP_QSTR_acquire), MP_ROM_PTR(&thread_lock_acquire_obj) },
  6051. { MP_ROM_QSTR(MP_QSTR_release), MP_ROM_PTR(&thread_lock_release_obj) },
  6052. { MP_ROM_QSTR(MP_QSTR_locked), MP_ROM_PTR(&thread_lock_locked_obj) },
  6053. @@ -114,9 +114,9 @@ STATIC const mp_rom_map_elem_t thread_lock_locals_dict_table[] = {
  6054. { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&thread_lock___exit___obj) },
  6055. };
  6056. -STATIC MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table);
  6057. +static MP_DEFINE_CONST_DICT(thread_lock_locals_dict, thread_lock_locals_dict_table);
  6058. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  6059. +static MP_DEFINE_CONST_OBJ_TYPE(
  6060. mp_type_thread_lock,
  6061. MP_QSTR_lock,
  6062. MP_TYPE_FLAG_NONE,
  6063. @@ -126,14 +126,14 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
  6064. /****************************************************************/
  6065. // _thread module
  6066. -STATIC size_t thread_stack_size = 0;
  6067. +static size_t thread_stack_size = 0;
  6068. -STATIC mp_obj_t mod_thread_get_ident(void) {
  6069. +static mp_obj_t mod_thread_get_ident(void) {
  6070. return mp_obj_new_int_from_uint(mp_thread_get_id());
  6071. }
  6072. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);
  6073. +static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_get_ident_obj, mod_thread_get_ident);
  6074. -STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
  6075. +static mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
  6076. mp_obj_t ret = mp_obj_new_int_from_uint(thread_stack_size);
  6077. if (n_args == 0) {
  6078. thread_stack_size = 0;
  6079. @@ -142,7 +142,7 @@ STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *args) {
  6080. }
  6081. return ret;
  6082. }
  6083. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size);
  6084. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_stack_size_obj, 0, 1, mod_thread_stack_size);
  6085. typedef struct _thread_entry_args_t {
  6086. mp_obj_dict_t *dict_locals;
  6087. @@ -154,16 +154,13 @@ typedef struct _thread_entry_args_t {
  6088. mp_obj_t args[];
  6089. } thread_entry_args_t;
  6090. -STATIC void *thread_entry(void *args_in) {
  6091. +static void *thread_entry(void *args_in) {
  6092. // Execution begins here for a new thread. We do not have the GIL.
  6093. thread_entry_args_t *args = (thread_entry_args_t *)args_in;
  6094. mp_state_thread_t ts;
  6095. - mp_thread_set_state(&ts);
  6096. -
  6097. - mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan
  6098. - mp_stack_set_limit(args->stack_size);
  6099. + mp_thread_init_state(&ts, args->stack_size, args->dict_locals, args->dict_globals);
  6100. #if MICROPY_ENABLE_PYSTACK
  6101. // TODO threading and pystack is not fully supported, for now just make a small stack
  6102. @@ -171,16 +168,6 @@ STATIC void *thread_entry(void *args_in) {
  6103. mp_pystack_init(mini_pystack, &mini_pystack[128]);
  6104. #endif
  6105. - // The GC starts off unlocked on this thread.
  6106. - ts.gc_lock_depth = 0;
  6107. -
  6108. - ts.nlr_jump_callback_top = NULL;
  6109. - ts.mp_pending_exception = MP_OBJ_NULL;
  6110. -
  6111. - // set locals and globals from the calling context
  6112. - mp_locals_set(args->dict_locals);
  6113. - mp_globals_set(args->dict_globals);
  6114. -
  6115. MP_THREAD_GIL_ENTER();
  6116. // signal that we are set up and running
  6117. @@ -220,7 +207,7 @@ STATIC void *thread_entry(void *args_in) {
  6118. return NULL;
  6119. }
  6120. -STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) {
  6121. +static mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args) {
  6122. // This structure holds the Python function and arguments for thread entry.
  6123. // We copy all arguments into this structure to keep ownership of them.
  6124. // We must be very careful about root pointers because this pointer may
  6125. @@ -271,19 +258,19 @@ STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args)
  6126. // spawn the thread!
  6127. return mp_obj_new_int_from_uint(mp_thread_create(thread_entry, th_args, &th_args->stack_size));
  6128. }
  6129. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread);
  6130. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread);
  6131. -STATIC mp_obj_t mod_thread_exit(void) {
  6132. +static mp_obj_t mod_thread_exit(void) {
  6133. mp_raise_type(&mp_type_SystemExit);
  6134. }
  6135. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit);
  6136. +static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit);
  6137. -STATIC mp_obj_t mod_thread_allocate_lock(void) {
  6138. +static mp_obj_t mod_thread_allocate_lock(void) {
  6139. return MP_OBJ_FROM_PTR(mp_obj_new_thread_lock());
  6140. }
  6141. -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock);
  6142. +static MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_allocate_lock_obj, mod_thread_allocate_lock);
  6143. -STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
  6144. +static const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
  6145. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__thread) },
  6146. { MP_ROM_QSTR(MP_QSTR_LockType), MP_ROM_PTR(&mp_type_thread_lock) },
  6147. { MP_ROM_QSTR(MP_QSTR_get_ident), MP_ROM_PTR(&mod_thread_get_ident_obj) },
  6148. @@ -293,7 +280,7 @@ STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
  6149. { MP_ROM_QSTR(MP_QSTR_allocate_lock), MP_ROM_PTR(&mod_thread_allocate_lock_obj) },
  6150. };
  6151. -STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table);
  6152. +static MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table);
  6153. const mp_obj_module_t mp_module_thread = {
  6154. .base = { &mp_type_module },
  6155. diff --git a/py/mpconfig.h b/py/mpconfig.h
  6156. index 627388c67..af2480266 100644
  6157. --- a/py/mpconfig.h
  6158. +++ b/py/mpconfig.h
  6159. @@ -30,9 +30,9 @@
  6160. // as well as a fallback to generate MICROPY_GIT_TAG if the git repo or tags
  6161. // are unavailable.
  6162. #define MICROPY_VERSION_MAJOR 1
  6163. -#define MICROPY_VERSION_MINOR 22
  6164. -#define MICROPY_VERSION_MICRO 2
  6165. -#define MICROPY_VERSION_PRERELEASE 0
  6166. +#define MICROPY_VERSION_MINOR 23
  6167. +#define MICROPY_VERSION_MICRO 0
  6168. +#define MICROPY_VERSION_PRERELEASE 1
  6169. // Combined version as a 32-bit number for convenience to allow version
  6170. // comparison. Doesn't include prerelease state.
  6171. @@ -290,10 +290,12 @@
  6172. // Number of bytes used to store qstr hash
  6173. #ifndef MICROPY_QSTR_BYTES_IN_HASH
  6174. -#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
  6175. +#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES
  6176. #define MICROPY_QSTR_BYTES_IN_HASH (2)
  6177. -#else
  6178. +#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
  6179. #define MICROPY_QSTR_BYTES_IN_HASH (1)
  6180. +#else
  6181. +#define MICROPY_QSTR_BYTES_IN_HASH (0)
  6182. #endif
  6183. #endif
  6184. @@ -444,6 +446,11 @@
  6185. #define MICROPY_DYNAMIC_COMPILER (0)
  6186. #endif
  6187. +// Whether the compiler allows compiling top-level await expressions
  6188. +#ifndef MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
  6189. +#define MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT (0)
  6190. +#endif
  6191. +
  6192. // Whether to enable constant folding; eg 1+2 rewritten as 3
  6193. #ifndef MICROPY_COMP_CONST_FOLDING
  6194. #define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
  6195. @@ -828,6 +835,15 @@ typedef double mp_float_t;
  6196. #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
  6197. #endif
  6198. +// Whether to use the native _Float16 for 16-bit float support
  6199. +#ifndef MICROPY_FLOAT_USE_NATIVE_FLT16
  6200. +#ifdef __FLT16_MAX__
  6201. +#define MICROPY_FLOAT_USE_NATIVE_FLT16 (1)
  6202. +#else
  6203. +#define MICROPY_FLOAT_USE_NATIVE_FLT16 (0)
  6204. +#endif
  6205. +#endif
  6206. +
  6207. // Whether to provide a high-quality hash for float and complex numbers.
  6208. // Otherwise the default is a very simple but correct hashing function.
  6209. #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
  6210. @@ -1301,6 +1317,16 @@ typedef double mp_float_t;
  6211. #define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
  6212. #endif
  6213. +// Whether "collections.deque" supports iteration
  6214. +#ifndef MICROPY_PY_COLLECTIONS_DEQUE_ITER
  6215. +#define MICROPY_PY_COLLECTIONS_DEQUE_ITER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
  6216. +#endif
  6217. +
  6218. +// Whether "collections.deque" supports subscription
  6219. +#ifndef MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
  6220. +#define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
  6221. +#endif
  6222. +
  6223. // Whether to provide "collections.OrderedDict" type
  6224. #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
  6225. #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
  6226. @@ -1690,6 +1716,11 @@ typedef double mp_float_t;
  6227. #define MICROPY_PY_MACHINE (0)
  6228. #endif
  6229. +// Whether to include: reset, reset_cause
  6230. +#ifndef MICROPY_PY_MACHINE_RESET
  6231. +#define MICROPY_PY_MACHINE_RESET (0)
  6232. +#endif
  6233. +
  6234. // Whether to include: bitstream
  6235. #ifndef MICROPY_PY_MACHINE_BITSTREAM
  6236. #define MICROPY_PY_MACHINE_BITSTREAM (0)
  6237. @@ -1700,6 +1731,16 @@ typedef double mp_float_t;
  6238. #define MICROPY_PY_MACHINE_PULSE (0)
  6239. #endif
  6240. +// Whether to provide the "machine.mem8/16/32" objects
  6241. +#ifndef MICROPY_PY_MACHINE_MEMX
  6242. +#define MICROPY_PY_MACHINE_MEMX (MICROPY_PY_MACHINE)
  6243. +#endif
  6244. +
  6245. +// Whether to provide the "machine.Signal" class
  6246. +#ifndef MICROPY_PY_MACHINE_SIGNAL
  6247. +#define MICROPY_PY_MACHINE_SIGNAL (MICROPY_PY_MACHINE)
  6248. +#endif
  6249. +
  6250. #ifndef MICROPY_PY_MACHINE_I2C
  6251. #define MICROPY_PY_MACHINE_I2C (0)
  6252. #endif
  6253. @@ -1742,6 +1783,11 @@ typedef double mp_float_t;
  6254. #define MICROPY_PY_SSL_FINALISER (MICROPY_ENABLE_FINALISER)
  6255. #endif
  6256. +// Whether to provide the "vfs" module
  6257. +#ifndef MICROPY_PY_VFS
  6258. +#define MICROPY_PY_VFS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES && MICROPY_VFS)
  6259. +#endif
  6260. +
  6261. #ifndef MICROPY_PY_WEBSOCKET
  6262. #define MICROPY_PY_WEBSOCKET (0)
  6263. #endif
  6264. @@ -1855,12 +1901,6 @@ typedef double mp_float_t;
  6265. #endif
  6266. #endif
  6267. -// Allow to override static modifier for global objects, e.g. to use with
  6268. -// object code analysis tools which don't support static symbols.
  6269. -#ifndef STATIC
  6270. -#define STATIC static
  6271. -#endif
  6272. -
  6273. // Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t
  6274. #ifndef MP_BYTES_PER_OBJ_WORD
  6275. #define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t))
  6276. diff --git a/py/mpprint.c b/py/mpprint.c
  6277. index 3218bd2f4..291e4145f 100644
  6278. --- a/py/mpprint.c
  6279. +++ b/py/mpprint.c
  6280. @@ -43,7 +43,7 @@
  6281. static const char pad_spaces[] = " ";
  6282. static const char pad_zeroes[] = "0000000000000000";
  6283. -STATIC void plat_print_strn(void *env, const char *str, size_t len) {
  6284. +static void plat_print_strn(void *env, const char *str, size_t len) {
  6285. (void)env;
  6286. MP_PLAT_PRINT_STRN(str, len);
  6287. }
  6288. @@ -127,7 +127,7 @@ int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flag
  6289. // This function is used exclusively by mp_vprintf to format ints.
  6290. // It needs to be a separate function to mp_print_mp_int, since converting to a mp_int looses the MSB.
  6291. -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) {
  6292. +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) {
  6293. char sign = 0;
  6294. if (sgn) {
  6295. if ((mp_int_t)x < 0) {
  6296. diff --git a/py/mpstate.h b/py/mpstate.h
  6297. index 0e0388e41..af55e764f 100644
  6298. --- a/py/mpstate.h
  6299. +++ b/py/mpstate.h
  6300. @@ -310,7 +310,6 @@ extern mp_state_ctx_t mp_state_ctx;
  6301. #define MP_STATE_MAIN_THREAD(x) (mp_state_ctx.thread.x)
  6302. #if MICROPY_PY_THREAD
  6303. -extern mp_state_thread_t *mp_thread_get_state(void);
  6304. #define MP_STATE_THREAD(x) (mp_thread_get_state()->x)
  6305. #define mp_thread_is_main_thread() (mp_thread_get_state() == &mp_state_ctx.thread)
  6306. #else
  6307. diff --git a/py/mpz.c b/py/mpz.c
  6308. index b61997e2f..502d4e1c1 100644
  6309. --- a/py/mpz.c
  6310. +++ b/py/mpz.c
  6311. @@ -49,7 +49,7 @@
  6312. Definition of normalise: ?
  6313. */
  6314. -STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
  6315. +static size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
  6316. for (--idig; idig >= oidig && *idig == 0; --idig) {
  6317. }
  6318. return idig + 1 - oidig;
  6319. @@ -59,7 +59,7 @@ STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idig) {
  6320. returns sign(i - j)
  6321. assumes i, j are normalised
  6322. */
  6323. -STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) {
  6324. +static int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) {
  6325. if (ilen < jlen) {
  6326. return -1;
  6327. }
  6328. @@ -85,7 +85,7 @@ STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, si
  6329. assumes enough memory in i; assumes normalised j; assumes n > 0
  6330. can have i, j pointing to same memory
  6331. */
  6332. -STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
  6333. +static size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
  6334. mp_uint_t n_whole = (n + DIG_SIZE - 1) / DIG_SIZE;
  6335. mp_uint_t n_part = n % DIG_SIZE;
  6336. if (n_part == 0) {
  6337. @@ -124,7 +124,7 @@ STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n
  6338. assumes enough memory in i; assumes normalised j; assumes n > 0
  6339. can have i, j pointing to same memory
  6340. */
  6341. -STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
  6342. +static size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n) {
  6343. mp_uint_t n_whole = n / DIG_SIZE;
  6344. mp_uint_t n_part = n % DIG_SIZE;
  6345. @@ -156,7 +156,7 @@ STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n
  6346. assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
  6347. can have i, j, k pointing to same memory
  6348. */
  6349. -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) {
  6350. +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) {
  6351. mpz_dig_t *oidig = idig;
  6352. mpz_dbl_dig_t carry = 0;
  6353. @@ -186,7 +186,7 @@ STATIC size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
  6354. assumes enough memory in i; assumes normalised j, k; assumes j >= k
  6355. can have i, j, k pointing to same memory
  6356. */
  6357. -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) {
  6358. +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) {
  6359. mpz_dig_t *oidig = idig;
  6360. mpz_dbl_dig_signed_t borrow = 0;
  6361. @@ -214,7 +214,7 @@ STATIC size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
  6362. assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen (jlen argument not needed)
  6363. can have i, j, k pointing to same memory
  6364. */
  6365. -STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) {
  6366. +static size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, size_t klen) {
  6367. mpz_dig_t *oidig = idig;
  6368. for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) {
  6369. @@ -235,7 +235,7 @@ STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *k
  6370. assumes enough memory in i; assumes normalised j, k; assumes length j >= length k
  6371. can have i, j, k pointing to same memory
  6372. */
  6373. -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,
  6374. +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,
  6375. mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
  6376. mpz_dig_t *oidig = idig;
  6377. mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
  6378. @@ -266,7 +266,7 @@ STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, c
  6379. assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
  6380. can have i, j, k pointing to same memory
  6381. */
  6382. -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) {
  6383. +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) {
  6384. mpz_dig_t *oidig = idig;
  6385. jlen -= klen;
  6386. @@ -296,7 +296,7 @@ STATIC size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
  6387. #if MICROPY_OPT_MPZ_BITWISE
  6388. -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,
  6389. +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,
  6390. mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
  6391. mpz_dig_t *oidig = idig;
  6392. mpz_dbl_dig_t carryi = 1;
  6393. @@ -326,7 +326,7 @@ STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, co
  6394. #else
  6395. -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,
  6396. +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,
  6397. mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
  6398. mpz_dig_t *oidig = idig;
  6399. mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
  6400. @@ -358,7 +358,7 @@ STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, co
  6401. assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
  6402. can have i, j, k pointing to same memory
  6403. */
  6404. -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) {
  6405. +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) {
  6406. mpz_dig_t *oidig = idig;
  6407. jlen -= klen;
  6408. @@ -385,7 +385,7 @@ STATIC size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const
  6409. assumes enough memory in i; assumes normalised j, k; assumes length j >= length k
  6410. can have i, j, k pointing to same memory
  6411. */
  6412. -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,
  6413. +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,
  6414. mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
  6415. mpz_dig_t *oidig = idig;
  6416. @@ -410,7 +410,7 @@ STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, c
  6417. returns number of digits in i
  6418. assumes enough memory in i; assumes normalised i; assumes dmul != 0
  6419. */
  6420. -STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) {
  6421. +static size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd) {
  6422. mpz_dig_t *oidig = idig;
  6423. mpz_dbl_dig_t carry = dadd;
  6424. @@ -432,7 +432,7 @@ STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul,
  6425. assumes enough memory in i; assumes i is zeroed; assumes normalised j, k
  6426. can have j, k point to same memory
  6427. */
  6428. -STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) {
  6429. +static size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen) {
  6430. mpz_dig_t *oidig = idig;
  6431. size_t ilen = 0;
  6432. @@ -463,7 +463,7 @@ STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *
  6433. assumes quo_dig has enough memory (as many digits as num)
  6434. assumes quo_dig is filled with zeros
  6435. */
  6436. -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) {
  6437. +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) {
  6438. mpz_dig_t *orig_num_dig = num_dig;
  6439. mpz_dig_t *orig_quo_dig = quo_dig;
  6440. mpz_dig_t norm_shift = 0;
  6441. @@ -668,14 +668,14 @@ mpz_t *mpz_from_str(const char *str, size_t len, bool neg, unsigned int base) {
  6442. }
  6443. #endif
  6444. -STATIC void mpz_free(mpz_t *z) {
  6445. +static void mpz_free(mpz_t *z) {
  6446. if (z != NULL) {
  6447. m_del(mpz_dig_t, z->dig, z->alloc);
  6448. m_del_obj(mpz_t, z);
  6449. }
  6450. }
  6451. -STATIC void mpz_need_dig(mpz_t *z, size_t need) {
  6452. +static void mpz_need_dig(mpz_t *z, size_t need) {
  6453. if (need < MIN_ALLOC) {
  6454. need = MIN_ALLOC;
  6455. }
  6456. @@ -689,7 +689,7 @@ STATIC void mpz_need_dig(mpz_t *z, size_t need) {
  6457. }
  6458. }
  6459. -STATIC mpz_t *mpz_clone(const mpz_t *src) {
  6460. +static mpz_t *mpz_clone(const mpz_t *src) {
  6461. assert(src->alloc != 0);
  6462. mpz_t *z = m_new_obj(mpz_t);
  6463. z->neg = src->neg;
  6464. diff --git a/py/nativeglue.c b/py/nativeglue.c
  6465. index 217c6b3df..ba3d93f76 100644
  6466. --- a/py/nativeglue.c
  6467. +++ b/py/nativeglue.c
  6468. @@ -29,6 +29,7 @@
  6469. #include <string.h>
  6470. #include <assert.h>
  6471. +#include "py/binary.h"
  6472. #include "py/runtime.h"
  6473. #include "py/smallint.h"
  6474. #include "py/nativeglue.h"
  6475. @@ -139,7 +140,7 @@ mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
  6476. }
  6477. #endif
  6478. -STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
  6479. +static mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
  6480. if (new_globals == NULL) {
  6481. // Globals were the originally the same so don't restore them
  6482. return NULL;
  6483. @@ -155,20 +156,20 @@ STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
  6484. // wrapper that accepts n_args and n_kw in one argument
  6485. // (native emitter can only pass at most 3 arguments to a function)
  6486. -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) {
  6487. +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) {
  6488. return mp_call_function_n_kw(fun_in, n_args_kw & 0xff, (n_args_kw >> 8) & 0xff, args);
  6489. }
  6490. // wrapper that makes raise obj and raises it
  6491. // END_FINALLY opcode requires that we don't raise if o==None
  6492. -STATIC void mp_native_raise(mp_obj_t o) {
  6493. +static void mp_native_raise(mp_obj_t o) {
  6494. if (o != MP_OBJ_NULL && o != mp_const_none) {
  6495. nlr_raise(mp_make_raise_obj(o));
  6496. }
  6497. }
  6498. // wrapper that handles iterator buffer
  6499. -STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
  6500. +static mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
  6501. if (iter == NULL) {
  6502. return mp_getiter(obj, NULL);
  6503. } else {
  6504. @@ -183,7 +184,7 @@ STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
  6505. }
  6506. // wrapper that handles iterator buffer
  6507. -STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
  6508. +static mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
  6509. mp_obj_t obj;
  6510. if (iter->base.type == MP_OBJ_NULL) {
  6511. obj = iter->buf[0];
  6512. @@ -193,7 +194,7 @@ STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
  6513. return mp_iternext(obj);
  6514. }
  6515. -STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
  6516. +static bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
  6517. mp_vm_return_kind_t ret_kind;
  6518. nlr_buf_t nlr_buf;
  6519. mp_obj_t throw_value = *ret_value;
  6520. @@ -231,22 +232,22 @@ STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *re
  6521. #if !MICROPY_PY_BUILTINS_FLOAT
  6522. -STATIC mp_obj_t mp_obj_new_float_from_f(float f) {
  6523. +static mp_obj_t mp_obj_new_float_from_f(float f) {
  6524. (void)f;
  6525. mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
  6526. }
  6527. -STATIC mp_obj_t mp_obj_new_float_from_d(double d) {
  6528. +static mp_obj_t mp_obj_new_float_from_d(double d) {
  6529. (void)d;
  6530. mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
  6531. }
  6532. -STATIC float mp_obj_get_float_to_f(mp_obj_t o) {
  6533. +static float mp_obj_get_float_to_f(mp_obj_t o) {
  6534. (void)o;
  6535. mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
  6536. }
  6537. -STATIC double mp_obj_get_float_to_d(mp_obj_t o) {
  6538. +static double mp_obj_get_float_to_d(mp_obj_t o) {
  6539. (void)o;
  6540. mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
  6541. }
  6542. @@ -281,7 +282,7 @@ const mp_fun_table_t mp_fun_table = {
  6543. mp_obj_set_store,
  6544. mp_obj_list_append,
  6545. mp_obj_dict_store,
  6546. - mp_make_function_from_raw_code,
  6547. + mp_make_function_from_proto_fun,
  6548. mp_native_call_function_n_kw,
  6549. mp_call_method_n_kw,
  6550. mp_call_method_n_kw_var,
  6551. @@ -330,6 +331,9 @@ const mp_fun_table_t mp_fun_table = {
  6552. mp_obj_get_float_to_d,
  6553. mp_get_buffer,
  6554. mp_get_stream_raise,
  6555. + mp_binary_get_size,
  6556. + mp_binary_get_val_array,
  6557. + mp_binary_set_val_array,
  6558. &mp_plat_print,
  6559. &mp_type_type,
  6560. &mp_type_str,
  6561. diff --git a/py/nativeglue.h b/py/nativeglue.h
  6562. index cf73ffbfc..1fa859334 100644
  6563. --- a/py/nativeglue.h
  6564. +++ b/py/nativeglue.h
  6565. @@ -58,7 +58,7 @@ typedef enum {
  6566. MP_F_STORE_SET,
  6567. MP_F_LIST_APPEND,
  6568. MP_F_STORE_MAP,
  6569. - MP_F_MAKE_FUNCTION_FROM_RAW_CODE,
  6570. + MP_F_MAKE_FUNCTION_FROM_PROTO_FUN,
  6571. MP_F_NATIVE_CALL_FUNCTION_N_KW,
  6572. MP_F_CALL_METHOD_N_KW,
  6573. MP_F_CALL_METHOD_N_KW_VAR,
  6574. @@ -112,7 +112,7 @@ typedef struct _mp_fun_table_t {
  6575. void (*set_store)(mp_obj_t self_in, mp_obj_t item);
  6576. mp_obj_t (*list_append)(mp_obj_t self_in, mp_obj_t arg);
  6577. mp_obj_t (*dict_store)(mp_obj_t self_in, mp_obj_t key, mp_obj_t value);
  6578. - 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);
  6579. + 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);
  6580. mp_obj_t (*call_function_n_kw)(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args);
  6581. mp_obj_t (*call_method_n_kw)(size_t n_args, size_t n_kw, const mp_obj_t *args);
  6582. mp_obj_t (*call_method_n_kw_var)(bool have_self, size_t n_args_n_kw, const mp_obj_t *args);
  6583. @@ -156,7 +156,12 @@ typedef struct _mp_fun_table_t {
  6584. double (*obj_get_float_to_d)(mp_obj_t o);
  6585. bool (*get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
  6586. const mp_stream_p_t *(*get_stream_raise)(mp_obj_t self_in, int flags);
  6587. + size_t (*binary_get_size)(char struct_type, char val_type, size_t *palign);
  6588. + mp_obj_t (*binary_get_val_array)(char typecode, void *p, size_t index);
  6589. + void (*binary_set_val_array)(char typecode, void *p, size_t index, mp_obj_t val_in);
  6590. const mp_print_t *plat_print;
  6591. + // The following entries start at index 70 and are referenced by tools-mpy_ld.py,
  6592. + // see constant MP_FUN_TABLE_MP_TYPE_TYPE_OFFSET.
  6593. const mp_obj_type_t *type_type;
  6594. const mp_obj_type_t *type_str;
  6595. const mp_obj_type_t *type_list;
  6596. diff --git a/py/nlraarch64.c b/py/nlraarch64.c
  6597. index fcc318f2d..d6d87ebc5 100644
  6598. --- a/py/nlraarch64.c
  6599. +++ b/py/nlraarch64.c
  6600. @@ -75,7 +75,7 @@ NORETURN void nlr_jump(void *val) {
  6601. "ret \n"
  6602. :
  6603. : "r" (top)
  6604. - :
  6605. + : "memory"
  6606. );
  6607. MP_UNREACHABLE
  6608. diff --git a/py/nlrmips.c b/py/nlrmips.c
  6609. index bd5d73b6f..cba52b16a 100644
  6610. --- a/py/nlrmips.c
  6611. +++ b/py/nlrmips.c
  6612. @@ -78,7 +78,7 @@ NORETURN void nlr_jump(void *val) {
  6613. "nop \n"
  6614. :
  6615. : "r" (top)
  6616. - :
  6617. + : "memory"
  6618. );
  6619. MP_UNREACHABLE
  6620. }
  6621. diff --git a/py/nlrpowerpc.c b/py/nlrpowerpc.c
  6622. index 448459216..8a69fe1ee 100644
  6623. --- a/py/nlrpowerpc.c
  6624. +++ b/py/nlrpowerpc.c
  6625. @@ -114,7 +114,7 @@ NORETURN void nlr_jump(void *val) {
  6626. "blr ;"
  6627. :
  6628. : "r" (&top->regs)
  6629. - :
  6630. + : "memory"
  6631. );
  6632. MP_UNREACHABLE;
  6633. @@ -203,7 +203,7 @@ NORETURN void nlr_jump(void *val) {
  6634. "blr ;"
  6635. :
  6636. : "r" (&top->regs)
  6637. - :
  6638. + : "memory"
  6639. );
  6640. MP_UNREACHABLE;
  6641. diff --git a/py/nlrthumb.c b/py/nlrthumb.c
  6642. index a8ffecc47..a22c5df5b 100644
  6643. --- a/py/nlrthumb.c
  6644. +++ b/py/nlrthumb.c
  6645. @@ -132,7 +132,7 @@ NORETURN void nlr_jump(void *val) {
  6646. "bx lr \n" // return
  6647. : // output operands
  6648. : "r" (top) // input operands
  6649. - : // clobbered registers
  6650. + : "memory" // clobbered registers
  6651. );
  6652. MP_UNREACHABLE
  6653. diff --git a/py/nlrx64.c b/py/nlrx64.c
  6654. index 6b7d0262f..d1ad91ff7 100644
  6655. --- a/py/nlrx64.c
  6656. +++ b/py/nlrx64.c
  6657. @@ -123,7 +123,7 @@ NORETURN void nlr_jump(void *val) {
  6658. "ret \n" // return
  6659. : // output operands
  6660. : "r" (top) // input operands
  6661. - : // clobbered registers
  6662. + : "memory" // clobbered registers
  6663. );
  6664. MP_UNREACHABLE
  6665. diff --git a/py/nlrx86.c b/py/nlrx86.c
  6666. index f658d4191..085e30d20 100644
  6667. --- a/py/nlrx86.c
  6668. +++ b/py/nlrx86.c
  6669. @@ -95,7 +95,7 @@ NORETURN void nlr_jump(void *val) {
  6670. "ret \n" // return
  6671. : // output operands
  6672. : "r" (top) // input operands
  6673. - : // clobbered registers
  6674. + : "memory" // clobbered registers
  6675. );
  6676. MP_UNREACHABLE
  6677. diff --git a/py/nlrxtensa.c b/py/nlrxtensa.c
  6678. index abe9042af..ff7af6ede 100644
  6679. --- a/py/nlrxtensa.c
  6680. +++ b/py/nlrxtensa.c
  6681. @@ -74,7 +74,7 @@ NORETURN void nlr_jump(void *val) {
  6682. "ret.n \n" // return
  6683. : // output operands
  6684. : "r" (top) // input operands
  6685. - : // clobbered registers
  6686. + : "memory" // clobbered registers
  6687. );
  6688. MP_UNREACHABLE
  6689. diff --git a/py/obj.c b/py/obj.c
  6690. index 5e01198b6..e43451dad 100644
  6691. --- a/py/obj.c
  6692. +++ b/py/obj.c
  6693. @@ -44,6 +44,15 @@ MP_NOINLINE void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *ty
  6694. return base;
  6695. }
  6696. +#if MICROPY_ENABLE_FINALISER
  6697. +// Allocates an object and also sets type, for mp_obj_malloc{,_var}_with_finaliser macros.
  6698. +MP_NOINLINE void *mp_obj_malloc_with_finaliser_helper(size_t num_bytes, const mp_obj_type_t *type) {
  6699. + mp_obj_base_t *base = (mp_obj_base_t *)m_malloc_with_finaliser(num_bytes);
  6700. + base->type = type;
  6701. + return base;
  6702. +}
  6703. +#endif
  6704. +
  6705. const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_t o_in) {
  6706. #if MICROPY_OBJ_IMMEDIATE_OBJS && MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A
  6707. diff --git a/py/obj.h b/py/obj.h
  6708. index c7b7db0c3..9f2bb46e4 100644
  6709. --- a/py/obj.h
  6710. +++ b/py/obj.h
  6711. @@ -833,6 +833,9 @@ extern const mp_obj_type_t mp_type_fun_builtin_2;
  6712. extern const mp_obj_type_t mp_type_fun_builtin_3;
  6713. extern const mp_obj_type_t mp_type_fun_builtin_var;
  6714. extern const mp_obj_type_t mp_type_fun_bc;
  6715. +extern const mp_obj_type_t mp_type_fun_native;
  6716. +extern const mp_obj_type_t mp_type_fun_viper;
  6717. +extern const mp_obj_type_t mp_type_fun_asm;
  6718. extern const mp_obj_type_t mp_type_module;
  6719. extern const mp_obj_type_t mp_type_staticmethod;
  6720. extern const mp_obj_type_t mp_type_classmethod;
  6721. @@ -913,9 +916,19 @@ extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj;
  6722. // Helper versions of m_new_obj when you need to immediately set base.type.
  6723. // Implementing this as a call rather than inline saves 8 bytes per usage.
  6724. #define mp_obj_malloc(struct_type, obj_type) ((struct_type *)mp_obj_malloc_helper(sizeof(struct_type), obj_type))
  6725. -#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))
  6726. +#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))
  6727. void *mp_obj_malloc_helper(size_t num_bytes, const mp_obj_type_t *type);
  6728. +// Object allocation macros for allocating objects that have a finaliser.
  6729. +#if MICROPY_ENABLE_FINALISER
  6730. +#define mp_obj_malloc_with_finaliser(struct_type, obj_type) ((struct_type *)mp_obj_malloc_with_finaliser_helper(sizeof(struct_type), obj_type))
  6731. +#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))
  6732. +void *mp_obj_malloc_with_finaliser_helper(size_t num_bytes, const mp_obj_type_t *type);
  6733. +#else
  6734. +#define mp_obj_malloc_with_finaliser(struct_type, obj_type) mp_obj_malloc(struct_type, obj_type)
  6735. +#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)
  6736. +#endif
  6737. +
  6738. // These macros are derived from more primitive ones and are used to
  6739. // check for more specific object types.
  6740. // Note: these are kept as macros because inline functions sometimes use much
  6741. diff --git a/py/objarray.c b/py/objarray.c
  6742. index a3adb255e..1fff23482 100644
  6743. --- a/py/objarray.c
  6744. +++ b/py/objarray.c
  6745. @@ -61,16 +61,16 @@
  6746. // so not defined to catch errors
  6747. #endif
  6748. -STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf);
  6749. -STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
  6750. -STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
  6751. -STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
  6752. +static mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf);
  6753. +static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
  6754. +static mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in);
  6755. +static mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
  6756. /******************************************************************************/
  6757. // array
  6758. #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
  6759. -STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  6760. +static void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  6761. (void)kind;
  6762. mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
  6763. if (o->typecode == BYTEARRAY_TYPECODE) {
  6764. @@ -94,7 +94,7 @@ STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
  6765. #endif
  6766. #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
  6767. -STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
  6768. +static mp_obj_array_t *array_new(char typecode, size_t n) {
  6769. int typecode_size = mp_binary_get_size('@', typecode, NULL);
  6770. mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
  6771. #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY
  6772. @@ -113,7 +113,7 @@ STATIC mp_obj_array_t *array_new(char typecode, size_t n) {
  6773. #endif
  6774. #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
  6775. -STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
  6776. +static mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
  6777. // bytearrays can be raw-initialised from anything with the buffer protocol
  6778. // other arrays can only be raw-initialised from bytes and bytearray objects
  6779. mp_buffer_info_t bufinfo;
  6780. @@ -159,7 +159,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
  6781. #endif
  6782. #if MICROPY_PY_ARRAY
  6783. -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) {
  6784. +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) {
  6785. (void)type_in;
  6786. mp_arg_check_num(n_args, n_kw, 1, 2, false);
  6787. @@ -177,7 +177,7 @@ STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size
  6788. #endif
  6789. #if MICROPY_PY_BUILTINS_BYTEARRAY
  6790. -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) {
  6791. +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) {
  6792. (void)type_in;
  6793. // Can take 2nd/3rd arg if constructs from str
  6794. mp_arg_check_num(n_args, n_kw, 0, 3, false);
  6795. @@ -214,7 +214,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) {
  6796. return MP_OBJ_FROM_PTR(self);
  6797. }
  6798. -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) {
  6799. +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) {
  6800. (void)type_in;
  6801. // TODO possibly allow memoryview constructor to take start/stop so that one
  6802. @@ -246,7 +246,7 @@ STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args,
  6803. }
  6804. #if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
  6805. -STATIC void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6806. +static void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6807. if (dest[0] != MP_OBJ_NULL) {
  6808. return;
  6809. }
  6810. @@ -265,7 +265,7 @@ STATIC void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6811. #endif
  6812. -STATIC mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  6813. +static mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  6814. mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
  6815. switch (op) {
  6816. case MP_UNARY_OP_BOOL:
  6817. @@ -277,7 +277,7 @@ STATIC mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  6818. }
  6819. }
  6820. -STATIC int typecode_for_comparison(int typecode, bool *is_unsigned) {
  6821. +static int typecode_for_comparison(int typecode, bool *is_unsigned) {
  6822. if (typecode == BYTEARRAY_TYPECODE) {
  6823. typecode = 'B';
  6824. }
  6825. @@ -288,7 +288,7 @@ STATIC int typecode_for_comparison(int typecode, bool *is_unsigned) {
  6826. return typecode;
  6827. }
  6828. -STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  6829. +static mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  6830. mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
  6831. switch (op) {
  6832. case MP_BINARY_OP_ADD: {
  6833. @@ -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
  6834. }
  6835. #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
  6836. -STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
  6837. +static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
  6838. // self is not a memoryview, so we don't need to use (& TYPECODE_MASK)
  6839. assert((MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(self_in, &mp_type_bytearray))
  6840. || (MICROPY_PY_ARRAY && mp_obj_is_type(self_in, &mp_type_array)));
  6841. @@ -404,7 +404,7 @@ STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
  6842. }
  6843. MP_DEFINE_CONST_FUN_OBJ_2(mp_obj_array_append_obj, array_append);
  6844. -STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
  6845. +static mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
  6846. // self is not a memoryview, so we don't need to use (& TYPECODE_MASK)
  6847. assert((MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(self_in, &mp_type_bytearray))
  6848. || (MICROPY_PY_ARRAY && mp_obj_is_type(self_in, &mp_type_array)));
  6849. @@ -437,7 +437,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
  6850. MP_DEFINE_CONST_FUN_OBJ_2(mp_obj_array_extend_obj, array_extend);
  6851. #endif
  6852. -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
  6853. +static mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
  6854. if (value == MP_OBJ_NULL) {
  6855. // delete item
  6856. // TODO implement
  6857. @@ -568,7 +568,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
  6858. }
  6859. }
  6860. -STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
  6861. +static mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
  6862. mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
  6863. size_t sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL);
  6864. bufinfo->buf = o->items;
  6865. @@ -682,7 +682,7 @@ typedef struct _mp_obj_array_it_t {
  6866. size_t cur;
  6867. } mp_obj_array_it_t;
  6868. -STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
  6869. +static mp_obj_t array_it_iternext(mp_obj_t self_in) {
  6870. mp_obj_array_it_t *self = MP_OBJ_TO_PTR(self_in);
  6871. if (self->cur < self->array->len) {
  6872. return mp_binary_get_val_array(self->array->typecode & TYPECODE_MASK, self->array->items, self->offset + self->cur++);
  6873. @@ -691,14 +691,14 @@ STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
  6874. }
  6875. }
  6876. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  6877. +static MP_DEFINE_CONST_OBJ_TYPE(
  6878. mp_type_array_it,
  6879. MP_QSTR_iterator,
  6880. MP_TYPE_FLAG_ITER_IS_ITERNEXT,
  6881. iter, array_it_iternext
  6882. );
  6883. -STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {
  6884. +static mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {
  6885. assert(sizeof(mp_obj_array_t) <= sizeof(mp_obj_iter_buf_t));
  6886. mp_obj_array_t *array = MP_OBJ_TO_PTR(array_in);
  6887. mp_obj_array_it_t *o = (mp_obj_array_it_t *)iter_buf;
  6888. diff --git a/py/objattrtuple.c b/py/objattrtuple.c
  6889. index fbe04bedb..1280e3308 100644
  6890. --- a/py/objattrtuple.c
  6891. +++ b/py/objattrtuple.c
  6892. @@ -30,7 +30,7 @@
  6893. // this helper function is used by collections.namedtuple
  6894. #if !MICROPY_PY_COLLECTIONS
  6895. -STATIC
  6896. +static
  6897. #endif
  6898. void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o) {
  6899. mp_print_str(print, "(");
  6900. @@ -48,14 +48,14 @@ void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields,
  6901. #if MICROPY_PY_ATTRTUPLE
  6902. -STATIC void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  6903. +static void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  6904. (void)kind;
  6905. mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in);
  6906. const qstr *fields = (const qstr *)MP_OBJ_TO_PTR(o->items[o->len]);
  6907. mp_obj_attrtuple_print_helper(print, fields, o);
  6908. }
  6909. -STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6910. +static void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6911. if (dest[0] == MP_OBJ_NULL) {
  6912. // load attribute
  6913. mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
  6914. @@ -71,7 +71,7 @@ STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6915. }
  6916. mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items) {
  6917. - mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, n + 1, &mp_type_attrtuple);
  6918. + mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, n + 1, &mp_type_attrtuple);
  6919. o->len = n;
  6920. for (size_t i = 0; i < n; i++) {
  6921. o->items[i] = items[i];
  6922. diff --git a/py/objbool.c b/py/objbool.c
  6923. index 96f0e60dd..5b3e3660e 100644
  6924. --- a/py/objbool.c
  6925. +++ b/py/objbool.c
  6926. @@ -43,7 +43,7 @@ typedef struct _mp_obj_bool_t {
  6927. #endif
  6928. -STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  6929. +static void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  6930. bool value = BOOL_VALUE(self_in);
  6931. if (MICROPY_PY_JSON && kind == PRINT_JSON) {
  6932. if (value) {
  6933. @@ -60,7 +60,7 @@ STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
  6934. }
  6935. }
  6936. -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) {
  6937. +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) {
  6938. (void)type_in;
  6939. mp_arg_check_num(n_args, n_kw, 0, 1, false);
  6940. @@ -71,7 +71,7 @@ STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
  6941. }
  6942. }
  6943. -STATIC mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  6944. +static mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  6945. if (op == MP_UNARY_OP_LEN) {
  6946. return MP_OBJ_NULL;
  6947. }
  6948. @@ -79,7 +79,7 @@ STATIC mp_obj_t bool_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  6949. return mp_unary_op(op, MP_OBJ_NEW_SMALL_INT(value));
  6950. }
  6951. -STATIC mp_obj_t bool_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  6952. +static mp_obj_t bool_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  6953. bool value = BOOL_VALUE(lhs_in);
  6954. return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(value), rhs_in);
  6955. }
  6956. diff --git a/py/objboundmeth.c b/py/objboundmeth.c
  6957. index b0be810c5..e3503ff15 100644
  6958. --- a/py/objboundmeth.c
  6959. +++ b/py/objboundmeth.c
  6960. @@ -36,7 +36,7 @@ typedef struct _mp_obj_bound_meth_t {
  6961. } mp_obj_bound_meth_t;
  6962. #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
  6963. -STATIC void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  6964. +static void bound_meth_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  6965. (void)kind;
  6966. mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(o_in);
  6967. mp_printf(print, "<bound_method %p ", o);
  6968. @@ -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
  6969. return res;
  6970. }
  6971. -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) {
  6972. +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) {
  6973. mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in);
  6974. return mp_call_method_self_n_kw(self->meth, self->self, n_args, n_kw, args);
  6975. }
  6976. -STATIC mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  6977. +static mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  6978. mp_obj_bound_meth_t *self = MP_OBJ_TO_PTR(self_in);
  6979. switch (op) {
  6980. case MP_UNARY_OP_HASH:
  6981. @@ -93,7 +93,7 @@ STATIC mp_obj_t bound_meth_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  6982. }
  6983. }
  6984. -STATIC mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  6985. +static mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  6986. // The MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE flag is clear for this type, so if this
  6987. // function is called with MP_BINARY_OP_EQUAL then lhs_in and rhs_in must have the
  6988. // same type, which is mp_type_bound_meth.
  6989. @@ -106,7 +106,7 @@ STATIC mp_obj_t bound_meth_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_
  6990. }
  6991. #if MICROPY_PY_FUNCTION_ATTRS
  6992. -STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6993. +static void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  6994. if (dest[0] != MP_OBJ_NULL) {
  6995. // not load attribute
  6996. return;
  6997. diff --git a/py/objcell.c b/py/objcell.c
  6998. index 0a74e29d2..95966c791 100644
  6999. --- a/py/objcell.c
  7000. +++ b/py/objcell.c
  7001. @@ -27,7 +27,7 @@
  7002. #include "py/obj.h"
  7003. #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
  7004. -STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7005. +static void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7006. (void)kind;
  7007. mp_obj_cell_t *o = MP_OBJ_TO_PTR(o_in);
  7008. mp_printf(print, "<cell %p ", o->obj);
  7009. @@ -46,7 +46,7 @@ STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
  7010. #define CELL_TYPE_PRINT
  7011. #endif
  7012. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  7013. +static MP_DEFINE_CONST_OBJ_TYPE(
  7014. // cell representation is just value in < >
  7015. mp_type_cell, MP_QSTR_, MP_TYPE_FLAG_NONE
  7016. CELL_TYPE_PRINT
  7017. diff --git a/py/objclosure.c b/py/objclosure.c
  7018. index 6059d1810..3ba507b95 100644
  7019. --- a/py/objclosure.c
  7020. +++ b/py/objclosure.c
  7021. @@ -36,7 +36,7 @@ typedef struct _mp_obj_closure_t {
  7022. mp_obj_t closed[];
  7023. } mp_obj_closure_t;
  7024. -STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
  7025. +static mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
  7026. mp_obj_closure_t *self = MP_OBJ_TO_PTR(self_in);
  7027. // need to concatenate closed-over-vars and args
  7028. @@ -60,7 +60,7 @@ STATIC mp_obj_t closure_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
  7029. }
  7030. #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
  7031. -STATIC void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7032. +static void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7033. (void)kind;
  7034. mp_obj_closure_t *o = MP_OBJ_TO_PTR(o_in);
  7035. mp_print_str(print, "<closure ");
  7036. @@ -79,7 +79,7 @@ STATIC void closure_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_
  7037. #endif
  7038. #if MICROPY_PY_FUNCTION_ATTRS
  7039. -STATIC void mp_obj_closure_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  7040. +static void mp_obj_closure_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  7041. // forward to self_in->fun
  7042. mp_obj_closure_t *o = MP_OBJ_TO_PTR(self_in);
  7043. mp_load_method_maybe(o->fun, attr, dest);
  7044. @@ -105,7 +105,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  7045. );
  7046. mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed_over, const mp_obj_t *closed) {
  7047. - mp_obj_closure_t *o = mp_obj_malloc_var(mp_obj_closure_t, mp_obj_t, n_closed_over, &mp_type_closure);
  7048. + mp_obj_closure_t *o = mp_obj_malloc_var(mp_obj_closure_t, closed, mp_obj_t, n_closed_over, &mp_type_closure);
  7049. o->fun = fun;
  7050. o->n_closed = n_closed_over;
  7051. memcpy(o->closed, closed, n_closed_over * sizeof(mp_obj_t));
  7052. diff --git a/py/objcomplex.c b/py/objcomplex.c
  7053. index ddd103eeb..85b585284 100644
  7054. --- a/py/objcomplex.c
  7055. +++ b/py/objcomplex.c
  7056. @@ -42,7 +42,7 @@ typedef struct _mp_obj_complex_t {
  7057. mp_float_t imag;
  7058. } mp_obj_complex_t;
  7059. -STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7060. +static void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7061. (void)kind;
  7062. mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
  7063. #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
  7064. @@ -70,7 +70,7 @@ STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_
  7065. }
  7066. }
  7067. -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) {
  7068. +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) {
  7069. (void)type_in;
  7070. mp_arg_check_num(n_args, n_kw, 0, 2, false);
  7071. @@ -115,7 +115,7 @@ STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, si
  7072. }
  7073. }
  7074. -STATIC mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7075. +static mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7076. mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
  7077. switch (op) {
  7078. case MP_UNARY_OP_BOOL:
  7079. @@ -133,12 +133,12 @@ STATIC mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7080. }
  7081. }
  7082. -STATIC mp_obj_t complex_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7083. +static mp_obj_t complex_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7084. mp_obj_complex_t *lhs = MP_OBJ_TO_PTR(lhs_in);
  7085. return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
  7086. }
  7087. -STATIC void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  7088. +static void complex_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  7089. if (dest[0] != MP_OBJ_NULL) {
  7090. // not load attribute
  7091. return;
  7092. diff --git a/py/objdeque.c b/py/objdeque.c
  7093. index 8b52b8d38..583537017 100644
  7094. --- a/py/objdeque.c
  7095. +++ b/py/objdeque.c
  7096. @@ -25,13 +25,11 @@
  7097. */
  7098. #include <unistd.h> // for ssize_t
  7099. -#include <string.h>
  7100. -
  7101. -#include "py/mpconfig.h"
  7102. -#if MICROPY_PY_COLLECTIONS_DEQUE
  7103. #include "py/runtime.h"
  7104. +#if MICROPY_PY_COLLECTIONS_DEQUE
  7105. +
  7106. typedef struct _mp_obj_deque_t {
  7107. mp_obj_base_t base;
  7108. size_t alloc;
  7109. @@ -42,14 +40,14 @@ typedef struct _mp_obj_deque_t {
  7110. #define FLAG_CHECK_OVERFLOW 1
  7111. } mp_obj_deque_t;
  7112. -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) {
  7113. - mp_arg_check_num(n_args, n_kw, 2, 3, false);
  7114. +static mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg);
  7115. +static mp_obj_t mp_obj_deque_extend(mp_obj_t self_in, mp_obj_t arg_in);
  7116. +#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
  7117. +static mp_obj_t mp_obj_new_deque_it(mp_obj_t deque, mp_obj_iter_buf_t *iter_buf);
  7118. +#endif
  7119. - /* Initialization from existing sequence is not supported, so an empty
  7120. - tuple must be passed as such. */
  7121. - if (args[0] != mp_const_empty_tuple) {
  7122. - mp_raise_ValueError(NULL);
  7123. - }
  7124. +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) {
  7125. + mp_arg_check_num(n_args, n_kw, 2, 3, false);
  7126. // Protect against -1 leading to zero-length allocation and bad array access
  7127. mp_int_t maxlen = mp_obj_get_int(args[1]);
  7128. @@ -66,21 +64,27 @@ STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t
  7129. o->flags = mp_obj_get_int(args[2]);
  7130. }
  7131. + mp_obj_deque_extend(MP_OBJ_FROM_PTR(o), args[0]);
  7132. +
  7133. return MP_OBJ_FROM_PTR(o);
  7134. }
  7135. -STATIC mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  7136. +static size_t deque_len(mp_obj_deque_t *self) {
  7137. + ssize_t len = self->i_put - self->i_get;
  7138. + if (len < 0) {
  7139. + len += self->alloc;
  7140. + }
  7141. + return len;
  7142. +}
  7143. +
  7144. +static mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  7145. mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
  7146. switch (op) {
  7147. case MP_UNARY_OP_BOOL:
  7148. return mp_obj_new_bool(self->i_get != self->i_put);
  7149. - case MP_UNARY_OP_LEN: {
  7150. - ssize_t len = self->i_put - self->i_get;
  7151. - if (len < 0) {
  7152. - len += self->alloc;
  7153. - }
  7154. - return MP_OBJ_NEW_SMALL_INT(len);
  7155. - }
  7156. + case MP_UNARY_OP_LEN:
  7157. + return MP_OBJ_NEW_SMALL_INT(deque_len(self));
  7158. +
  7159. #if MICROPY_PY_SYS_GETSIZEOF
  7160. case MP_UNARY_OP_SIZEOF: {
  7161. size_t sz = sizeof(*self) + sizeof(mp_obj_t) * self->alloc;
  7162. @@ -92,7 +96,7 @@ STATIC mp_obj_t deque_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  7163. }
  7164. }
  7165. -STATIC mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
  7166. +static mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
  7167. mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
  7168. size_t new_i_put = self->i_put + 1;
  7169. @@ -115,9 +119,48 @@ STATIC mp_obj_t mp_obj_deque_append(mp_obj_t self_in, mp_obj_t arg) {
  7170. return mp_const_none;
  7171. }
  7172. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(deque_append_obj, mp_obj_deque_append);
  7173. +static MP_DEFINE_CONST_FUN_OBJ_2(deque_append_obj, mp_obj_deque_append);
  7174. +
  7175. +static mp_obj_t mp_obj_deque_appendleft(mp_obj_t self_in, mp_obj_t arg) {
  7176. + mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
  7177. +
  7178. + size_t new_i_get = self->i_get - 1;
  7179. + if (self->i_get == 0) {
  7180. + new_i_get = self->alloc - 1;
  7181. + }
  7182. +
  7183. + if (self->flags & FLAG_CHECK_OVERFLOW && new_i_get == self->i_put) {
  7184. + mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("full"));
  7185. + }
  7186. +
  7187. + self->i_get = new_i_get;
  7188. + self->items[self->i_get] = arg;
  7189. +
  7190. + // overwriting first element in deque
  7191. + if (self->i_put == new_i_get) {
  7192. + if (self->i_put == 0) {
  7193. + self->i_put = self->alloc - 1;
  7194. + } else {
  7195. + self->i_put--;
  7196. + }
  7197. + }
  7198. +
  7199. + return mp_const_none;
  7200. +}
  7201. +static MP_DEFINE_CONST_FUN_OBJ_2(deque_appendleft_obj, mp_obj_deque_appendleft);
  7202. -STATIC mp_obj_t deque_popleft(mp_obj_t self_in) {
  7203. +static mp_obj_t mp_obj_deque_extend(mp_obj_t self_in, mp_obj_t arg_in) {
  7204. + mp_obj_iter_buf_t iter_buf;
  7205. + mp_obj_t iter = mp_getiter(arg_in, &iter_buf);
  7206. + mp_obj_t item;
  7207. + while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
  7208. + mp_obj_deque_append(self_in, item);
  7209. + }
  7210. + return mp_const_none;
  7211. +}
  7212. +static MP_DEFINE_CONST_FUN_OBJ_2(deque_extend_obj, mp_obj_deque_extend);
  7213. +
  7214. +static mp_obj_t deque_popleft(mp_obj_t self_in) {
  7215. mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
  7216. if (self->i_get == self->i_put) {
  7217. @@ -133,35 +176,139 @@ STATIC mp_obj_t deque_popleft(mp_obj_t self_in) {
  7218. return ret;
  7219. }
  7220. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(deque_popleft_obj, deque_popleft);
  7221. +static MP_DEFINE_CONST_FUN_OBJ_1(deque_popleft_obj, deque_popleft);
  7222. +
  7223. +static mp_obj_t deque_pop(mp_obj_t self_in) {
  7224. + mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
  7225. +
  7226. + if (self->i_get == self->i_put) {
  7227. + mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("empty"));
  7228. + }
  7229. +
  7230. + if (self->i_put == 0) {
  7231. + self->i_put = self->alloc - 1;
  7232. + } else {
  7233. + self->i_put--;
  7234. + }
  7235. +
  7236. + mp_obj_t ret = self->items[self->i_put];
  7237. + self->items[self->i_put] = MP_OBJ_NULL;
  7238. +
  7239. + return ret;
  7240. +}
  7241. +static MP_DEFINE_CONST_FUN_OBJ_1(deque_pop_obj, deque_pop);
  7242. +
  7243. +#if MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
  7244. +static mp_obj_t deque_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  7245. + if (value == MP_OBJ_NULL) {
  7246. + // delete not supported, fall back to mp_obj_subscr() error message
  7247. + return MP_OBJ_NULL;
  7248. + }
  7249. + mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
  7250. +
  7251. + size_t offset = mp_get_index(self->base.type, deque_len(self), index, false);
  7252. + size_t index_val = self->i_get + offset;
  7253. + if (index_val > self->alloc) {
  7254. + index_val -= self->alloc;
  7255. + }
  7256. +
  7257. + if (value == MP_OBJ_SENTINEL) {
  7258. + // load
  7259. + return self->items[index_val];
  7260. + } else {
  7261. + // store into deque
  7262. + self->items[index_val] = value;
  7263. + return mp_const_none;
  7264. + }
  7265. +}
  7266. +#endif
  7267. #if 0
  7268. -STATIC mp_obj_t deque_clear(mp_obj_t self_in) {
  7269. +static mp_obj_t deque_clear(mp_obj_t self_in) {
  7270. mp_obj_deque_t *self = MP_OBJ_TO_PTR(self_in);
  7271. self->i_get = self->i_put = 0;
  7272. mp_seq_clear(self->items, 0, self->alloc, sizeof(*self->items));
  7273. return mp_const_none;
  7274. }
  7275. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(deque_clear_obj, deque_clear);
  7276. +static MP_DEFINE_CONST_FUN_OBJ_1(deque_clear_obj, deque_clear);
  7277. #endif
  7278. -STATIC const mp_rom_map_elem_t deque_locals_dict_table[] = {
  7279. +static const mp_rom_map_elem_t deque_locals_dict_table[] = {
  7280. { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&deque_append_obj) },
  7281. + { MP_ROM_QSTR(MP_QSTR_appendleft), MP_ROM_PTR(&deque_appendleft_obj) },
  7282. + { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&deque_extend_obj) },
  7283. #if 0
  7284. { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&deque_clear_obj) },
  7285. #endif
  7286. + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&deque_pop_obj) },
  7287. { MP_ROM_QSTR(MP_QSTR_popleft), MP_ROM_PTR(&deque_popleft_obj) },
  7288. };
  7289. -STATIC MP_DEFINE_CONST_DICT(deque_locals_dict, deque_locals_dict_table);
  7290. +static MP_DEFINE_CONST_DICT(deque_locals_dict, deque_locals_dict_table);
  7291. +
  7292. +#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
  7293. +#define DEQUE_TYPE_FLAGS MP_TYPE_FLAG_ITER_IS_GETITER
  7294. +#define DEQUE_TYPE_ITER iter, mp_obj_new_deque_it,
  7295. +#else
  7296. +#define DEQUE_TYPE_FLAGS MP_TYPE_FLAG_NONE
  7297. +#define DEQUE_TYPE_ITER
  7298. +#endif
  7299. +
  7300. +#if MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR
  7301. +#define DEQUE_TYPE_SUBSCR subscr, deque_subscr,
  7302. +#else
  7303. +#define DEQUE_TYPE_SUBSCR
  7304. +#endif
  7305. MP_DEFINE_CONST_OBJ_TYPE(
  7306. mp_type_deque,
  7307. MP_QSTR_deque,
  7308. - MP_TYPE_FLAG_NONE,
  7309. + MP_TYPE_FLAG_ITER_IS_GETITER,
  7310. make_new, deque_make_new,
  7311. unary_op, deque_unary_op,
  7312. + DEQUE_TYPE_SUBSCR
  7313. + DEQUE_TYPE_ITER
  7314. locals_dict, &deque_locals_dict
  7315. );
  7316. +/******************************************************************************/
  7317. +/* deque iterator */
  7318. +
  7319. +#if MICROPY_PY_COLLECTIONS_DEQUE_ITER
  7320. +
  7321. +typedef struct _mp_obj_deque_it_t {
  7322. + mp_obj_base_t base;
  7323. + mp_fun_1_t iternext;
  7324. + mp_obj_t deque;
  7325. + size_t cur;
  7326. +} mp_obj_deque_it_t;
  7327. +
  7328. +static mp_obj_t deque_it_iternext(mp_obj_t self_in) {
  7329. + mp_obj_deque_it_t *self = MP_OBJ_TO_PTR(self_in);
  7330. + mp_obj_deque_t *deque = MP_OBJ_TO_PTR(self->deque);
  7331. + if (self->cur != deque->i_put) {
  7332. + mp_obj_t o_out = deque->items[self->cur];
  7333. + if (++self->cur == deque->alloc) {
  7334. + self->cur = 0;
  7335. + }
  7336. + return o_out;
  7337. + } else {
  7338. + return MP_OBJ_STOP_ITERATION;
  7339. + }
  7340. +}
  7341. +
  7342. +static mp_obj_t mp_obj_new_deque_it(mp_obj_t deque, mp_obj_iter_buf_t *iter_buf) {
  7343. + mp_obj_deque_t *deque_ = MP_OBJ_TO_PTR(deque);
  7344. + size_t i_get = deque_->i_get;
  7345. + assert(sizeof(mp_obj_deque_it_t) <= sizeof(mp_obj_iter_buf_t));
  7346. + mp_obj_deque_it_t *o = (mp_obj_deque_it_t *)iter_buf;
  7347. + o->base.type = &mp_type_polymorph_iter;
  7348. + o->iternext = deque_it_iternext;
  7349. + o->deque = deque;
  7350. + o->cur = i_get;
  7351. + return MP_OBJ_FROM_PTR(o);
  7352. +}
  7353. +
  7354. +#endif
  7355. +
  7356. #endif // MICROPY_PY_COLLECTIONS_DEQUE
  7357. diff --git a/py/objdict.c b/py/objdict.c
  7358. index 8aafe607d..cf64fa955 100644
  7359. --- a/py/objdict.c
  7360. +++ b/py/objdict.c
  7361. @@ -49,12 +49,12 @@ const mp_obj_dict_t mp_const_empty_dict_obj = {
  7362. }
  7363. };
  7364. -STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
  7365. +static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
  7366. // This is a helper function to iterate through a dictionary. The state of
  7367. // the iteration is held in *cur and should be initialised with zero for the
  7368. // first call. Will return NULL when no more elements are available.
  7369. -STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
  7370. +static mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
  7371. size_t max = dict->map.alloc;
  7372. mp_map_t *map = &dict->map;
  7373. @@ -70,7 +70,7 @@ STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) {
  7374. return NULL;
  7375. }
  7376. -STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  7377. +static void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  7378. mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
  7379. bool first = true;
  7380. const char *item_separator = ", ";
  7381. @@ -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
  7382. return dict_out;
  7383. }
  7384. -STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  7385. +static mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  7386. mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
  7387. switch (op) {
  7388. case MP_UNARY_OP_BOOL:
  7389. @@ -147,7 +147,7 @@ STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  7390. }
  7391. }
  7392. -STATIC mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7393. +static mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7394. mp_obj_dict_t *o = MP_OBJ_TO_PTR(lhs_in);
  7395. switch (op) {
  7396. case MP_BINARY_OP_CONTAINS: {
  7397. @@ -218,7 +218,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) {
  7398. }
  7399. }
  7400. -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  7401. +static mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  7402. if (value == MP_OBJ_NULL) {
  7403. // delete
  7404. mp_obj_dict_delete(self_in, index);
  7405. @@ -242,13 +242,13 @@ STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  7406. /******************************************************************************/
  7407. /* dict methods */
  7408. -STATIC void mp_ensure_not_fixed(const mp_obj_dict_t *dict) {
  7409. +static void mp_ensure_not_fixed(const mp_obj_dict_t *dict) {
  7410. if (dict->map.is_fixed) {
  7411. mp_raise_TypeError(NULL);
  7412. }
  7413. }
  7414. -STATIC mp_obj_t dict_clear(mp_obj_t self_in) {
  7415. +static mp_obj_t dict_clear(mp_obj_t self_in) {
  7416. mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
  7417. mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
  7418. mp_ensure_not_fixed(self);
  7419. @@ -257,7 +257,7 @@ STATIC mp_obj_t dict_clear(mp_obj_t self_in) {
  7420. return mp_const_none;
  7421. }
  7422. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
  7423. +static MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
  7424. mp_obj_t mp_obj_dict_copy(mp_obj_t self_in) {
  7425. mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
  7426. @@ -272,11 +272,11 @@ mp_obj_t mp_obj_dict_copy(mp_obj_t self_in) {
  7427. memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t));
  7428. return other_out;
  7429. }
  7430. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, mp_obj_dict_copy);
  7431. +static MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, mp_obj_dict_copy);
  7432. #if MICROPY_PY_BUILTINS_DICT_FROMKEYS
  7433. // this is a classmethod
  7434. -STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
  7435. +static mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
  7436. mp_obj_t iter = mp_getiter(args[1], NULL);
  7437. mp_obj_t value = mp_const_none;
  7438. mp_obj_t next = MP_OBJ_NULL;
  7439. @@ -302,11 +302,11 @@ STATIC mp_obj_t dict_fromkeys(size_t n_args, const mp_obj_t *args) {
  7440. return self_out;
  7441. }
  7442. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys);
  7443. -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj));
  7444. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys);
  7445. +static MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj));
  7446. #endif
  7447. -STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) {
  7448. +static mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) {
  7449. mp_check_self(mp_obj_is_dict_or_ordereddict(args[0]));
  7450. mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
  7451. if (lookup_kind != MP_MAP_LOOKUP) {
  7452. @@ -336,22 +336,22 @@ STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_look
  7453. return value;
  7454. }
  7455. -STATIC mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) {
  7456. +static mp_obj_t dict_get(size_t n_args, const mp_obj_t *args) {
  7457. return dict_get_helper(n_args, args, MP_MAP_LOOKUP);
  7458. }
  7459. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get);
  7460. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get);
  7461. -STATIC mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) {
  7462. +static mp_obj_t dict_pop(size_t n_args, const mp_obj_t *args) {
  7463. return dict_get_helper(n_args, args, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
  7464. }
  7465. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop);
  7466. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop);
  7467. -STATIC mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) {
  7468. +static mp_obj_t dict_setdefault(size_t n_args, const mp_obj_t *args) {
  7469. return dict_get_helper(n_args, args, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
  7470. }
  7471. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault);
  7472. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault);
  7473. -STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
  7474. +static mp_obj_t dict_popitem(mp_obj_t self_in) {
  7475. mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
  7476. mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
  7477. mp_ensure_not_fixed(self);
  7478. @@ -374,9 +374,9 @@ STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
  7479. return tuple;
  7480. }
  7481. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem);
  7482. +static MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem);
  7483. -STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  7484. +static mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
  7485. mp_check_self(mp_obj_is_dict_or_ordereddict(args[0]));
  7486. mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
  7487. mp_ensure_not_fixed(self);
  7488. @@ -424,14 +424,14 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
  7489. return mp_const_none;
  7490. }
  7491. -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
  7492. +static MP_DEFINE_CONST_FUN_OBJ_KW(dict_update_obj, 1, dict_update);
  7493. /******************************************************************************/
  7494. /* dict views */
  7495. -STATIC const mp_obj_type_t mp_type_dict_view;
  7496. -STATIC const mp_obj_type_t mp_type_dict_view_it;
  7497. +static const mp_obj_type_t mp_type_dict_view;
  7498. +static const mp_obj_type_t mp_type_dict_view_it;
  7499. typedef enum _mp_dict_view_kind_t {
  7500. MP_DICT_VIEW_ITEMS,
  7501. @@ -439,7 +439,7 @@ typedef enum _mp_dict_view_kind_t {
  7502. MP_DICT_VIEW_VALUES,
  7503. } mp_dict_view_kind_t;
  7504. -STATIC const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
  7505. +static const char *const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
  7506. typedef struct _mp_obj_dict_view_it_t {
  7507. mp_obj_base_t base;
  7508. @@ -454,7 +454,7 @@ typedef struct _mp_obj_dict_view_t {
  7509. mp_dict_view_kind_t kind;
  7510. } mp_obj_dict_view_t;
  7511. -STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
  7512. +static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
  7513. mp_check_self(mp_obj_is_type(self_in, &mp_type_dict_view_it));
  7514. mp_obj_dict_view_it_t *self = MP_OBJ_TO_PTR(self_in);
  7515. mp_map_elem_t *next = dict_iter_next(MP_OBJ_TO_PTR(self->dict), &self->cur);
  7516. @@ -476,14 +476,14 @@ STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
  7517. }
  7518. }
  7519. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  7520. +static MP_DEFINE_CONST_OBJ_TYPE(
  7521. mp_type_dict_view_it,
  7522. MP_QSTR_iterator,
  7523. MP_TYPE_FLAG_ITER_IS_ITERNEXT,
  7524. iter, dict_view_it_iternext
  7525. );
  7526. -STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) {
  7527. +static mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf) {
  7528. assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
  7529. mp_check_self(mp_obj_is_type(view_in, &mp_type_dict_view));
  7530. mp_obj_dict_view_t *view = MP_OBJ_TO_PTR(view_in);
  7531. @@ -495,7 +495,7 @@ STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf)
  7532. return MP_OBJ_FROM_PTR(o);
  7533. }
  7534. -STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  7535. +static void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  7536. (void)kind;
  7537. mp_check_self(mp_obj_is_type(self_in, &mp_type_dict_view));
  7538. mp_obj_dict_view_t *self = MP_OBJ_TO_PTR(self_in);
  7539. @@ -515,7 +515,7 @@ STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
  7540. mp_print_str(print, "])");
  7541. }
  7542. -STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7543. +static mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7544. mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(o_in);
  7545. // only dict.values() supports __hash__.
  7546. if (op == MP_UNARY_OP_HASH && o->kind == MP_DICT_VIEW_VALUES) {
  7547. @@ -524,7 +524,7 @@ STATIC mp_obj_t dict_view_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7548. return MP_OBJ_NULL;
  7549. }
  7550. -STATIC mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7551. +static mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7552. // only supported for the 'keys' kind until sets and dicts are refactored
  7553. mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(lhs_in);
  7554. if (o->kind != MP_DICT_VIEW_KEYS) {
  7555. @@ -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
  7556. return dict_binary_op(op, o->dict, rhs_in);
  7557. }
  7558. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  7559. +static MP_DEFINE_CONST_OBJ_TYPE(
  7560. mp_type_dict_view,
  7561. MP_QSTR_dict_view,
  7562. MP_TYPE_FLAG_ITER_IS_GETITER,
  7563. @@ -546,37 +546,37 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
  7564. iter, dict_view_getiter
  7565. );
  7566. -STATIC mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) {
  7567. +static mp_obj_t mp_obj_new_dict_view(mp_obj_t dict, mp_dict_view_kind_t kind) {
  7568. mp_obj_dict_view_t *o = mp_obj_malloc(mp_obj_dict_view_t, &mp_type_dict_view);
  7569. o->dict = dict;
  7570. o->kind = kind;
  7571. return MP_OBJ_FROM_PTR(o);
  7572. }
  7573. -STATIC mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
  7574. +static mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
  7575. mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
  7576. return mp_obj_new_dict_view(self_in, kind);
  7577. }
  7578. -STATIC mp_obj_t dict_items(mp_obj_t self_in) {
  7579. +static mp_obj_t dict_items(mp_obj_t self_in) {
  7580. return dict_view(self_in, MP_DICT_VIEW_ITEMS);
  7581. }
  7582. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
  7583. +static MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
  7584. -STATIC mp_obj_t dict_keys(mp_obj_t self_in) {
  7585. +static mp_obj_t dict_keys(mp_obj_t self_in) {
  7586. return dict_view(self_in, MP_DICT_VIEW_KEYS);
  7587. }
  7588. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
  7589. +static MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
  7590. -STATIC mp_obj_t dict_values(mp_obj_t self_in) {
  7591. +static mp_obj_t dict_values(mp_obj_t self_in) {
  7592. return dict_view(self_in, MP_DICT_VIEW_VALUES);
  7593. }
  7594. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
  7595. +static MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
  7596. /******************************************************************************/
  7597. /* dict iterator */
  7598. -STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
  7599. +static mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
  7600. assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
  7601. mp_check_self(mp_obj_is_dict_or_ordereddict(self_in));
  7602. mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t *)iter_buf;
  7603. @@ -590,7 +590,7 @@ STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
  7604. /******************************************************************************/
  7605. /* dict constructors & public C API */
  7606. -STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = {
  7607. +static const mp_rom_map_elem_t dict_locals_dict_table[] = {
  7608. { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&dict_clear_obj) },
  7609. { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&dict_copy_obj) },
  7610. #if MICROPY_PY_BUILTINS_DICT_FROMKEYS
  7611. @@ -609,7 +609,7 @@ STATIC const mp_rom_map_elem_t dict_locals_dict_table[] = {
  7612. { MP_ROM_QSTR(MP_QSTR___delitem__), MP_ROM_PTR(&mp_op_delitem_obj) },
  7613. };
  7614. -STATIC MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table);
  7615. +static MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table);
  7616. MP_DEFINE_CONST_OBJ_TYPE(
  7617. mp_type_dict,
  7618. diff --git a/py/objenumerate.c b/py/objenumerate.c
  7619. index 40bed919e..8217a0d4f 100644
  7620. --- a/py/objenumerate.c
  7621. +++ b/py/objenumerate.c
  7622. @@ -37,9 +37,9 @@ typedef struct _mp_obj_enumerate_t {
  7623. mp_int_t cur;
  7624. } mp_obj_enumerate_t;
  7625. -STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in);
  7626. +static mp_obj_t enumerate_iternext(mp_obj_t self_in);
  7627. -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) {
  7628. +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) {
  7629. #if MICROPY_CPYTHON_COMPAT
  7630. static const mp_arg_t allowed_args[] = {
  7631. { MP_QSTR_iterable, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
  7632. @@ -75,7 +75,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  7633. iter, enumerate_iternext
  7634. );
  7635. -STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) {
  7636. +static mp_obj_t enumerate_iternext(mp_obj_t self_in) {
  7637. assert(mp_obj_is_type(self_in, &mp_type_enumerate));
  7638. mp_obj_enumerate_t *self = MP_OBJ_TO_PTR(self_in);
  7639. mp_obj_t next = mp_iternext(self->iter);
  7640. diff --git a/py/objexcept.c b/py/objexcept.c
  7641. index fe74458ca..5bf4e672b 100644
  7642. --- a/py/objexcept.c
  7643. +++ b/py/objexcept.c
  7644. @@ -117,7 +117,7 @@ bool mp_obj_is_native_exception_instance(mp_obj_t self_in) {
  7645. return MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(self_in), make_new) == mp_obj_exception_make_new;
  7646. }
  7647. -STATIC mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
  7648. +static mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
  7649. assert(mp_obj_is_exception_instance(self_in));
  7650. if (mp_obj_is_native_exception_instance(self_in)) {
  7651. return MP_OBJ_TO_PTR(self_in);
  7652. @@ -126,7 +126,7 @@ STATIC mp_obj_exception_t *get_native_exception(mp_obj_t self_in) {
  7653. }
  7654. }
  7655. -STATIC void decompress_error_text_maybe(mp_obj_exception_t *o) {
  7656. +static void decompress_error_text_maybe(mp_obj_exception_t *o) {
  7657. #if MICROPY_ROM_TEXT_COMPRESSION
  7658. if (o->args->len == 1 && mp_obj_is_exact_type(o->args->items[0], &mp_type_str)) {
  7659. mp_obj_str_t *o_str = MP_OBJ_TO_PTR(o->args->items[0]);
  7660. @@ -439,7 +439,7 @@ struct _exc_printer_t {
  7661. byte *buf;
  7662. };
  7663. -STATIC void exc_add_strn(void *data, const char *str, size_t len) {
  7664. +static void exc_add_strn(void *data, const char *str, size_t len) {
  7665. struct _exc_printer_t *pr = data;
  7666. if (pr->len + len >= pr->alloc) {
  7667. // Not enough room for data plus a null byte so try to grow the buffer
  7668. diff --git a/py/objfilter.c b/py/objfilter.c
  7669. index 2a657fde4..7f1f700f6 100644
  7670. --- a/py/objfilter.c
  7671. +++ b/py/objfilter.c
  7672. @@ -34,7 +34,7 @@ typedef struct _mp_obj_filter_t {
  7673. mp_obj_t iter;
  7674. } mp_obj_filter_t;
  7675. -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) {
  7676. +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) {
  7677. mp_arg_check_num(n_args, n_kw, 2, 2, false);
  7678. mp_obj_filter_t *o = mp_obj_malloc(mp_obj_filter_t, type);
  7679. o->fun = args[0];
  7680. @@ -42,7 +42,7 @@ STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t
  7681. return MP_OBJ_FROM_PTR(o);
  7682. }
  7683. -STATIC mp_obj_t filter_iternext(mp_obj_t self_in) {
  7684. +static mp_obj_t filter_iternext(mp_obj_t self_in) {
  7685. mp_check_self(mp_obj_is_type(self_in, &mp_type_filter));
  7686. mp_obj_filter_t *self = MP_OBJ_TO_PTR(self_in);
  7687. mp_obj_t next;
  7688. diff --git a/py/objfloat.c b/py/objfloat.c
  7689. index c862b4843..5c90b1491 100644
  7690. --- a/py/objfloat.c
  7691. +++ b/py/objfloat.c
  7692. @@ -102,7 +102,7 @@ mp_int_t mp_float_hash(mp_float_t src) {
  7693. }
  7694. #endif
  7695. -STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7696. +static void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7697. (void)kind;
  7698. mp_float_t o_val = mp_obj_float_get(o_in);
  7699. #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
  7700. @@ -124,7 +124,7 @@ STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
  7701. }
  7702. }
  7703. -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) {
  7704. +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) {
  7705. (void)type_in;
  7706. mp_arg_check_num(n_args, n_kw, 0, 1, false);
  7707. @@ -149,7 +149,7 @@ STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size
  7708. }
  7709. }
  7710. -STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7711. +static mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7712. mp_float_t val = mp_obj_float_get(o_in);
  7713. switch (op) {
  7714. case MP_UNARY_OP_BOOL:
  7715. @@ -172,7 +172,7 @@ STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  7716. }
  7717. }
  7718. -STATIC mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7719. +static mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  7720. mp_float_t lhs_val = mp_obj_float_get(lhs_in);
  7721. #if MICROPY_PY_BUILTINS_COMPLEX
  7722. if (mp_obj_is_type(rhs_in, &mp_type_complex)) {
  7723. @@ -208,7 +208,7 @@ mp_float_t mp_obj_float_get(mp_obj_t self_in) {
  7724. #endif
  7725. -STATIC void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) {
  7726. +static void mp_obj_float_divmod(mp_float_t *x, mp_float_t *y) {
  7727. // logic here follows that of CPython
  7728. // https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
  7729. // x == (x//y)*y + (x%y)
  7730. diff --git a/py/objfun.c b/py/objfun.c
  7731. index e2136968b..1ebfa3d5a 100644
  7732. --- a/py/objfun.c
  7733. +++ b/py/objfun.c
  7734. @@ -48,7 +48,7 @@
  7735. /******************************************************************************/
  7736. /* builtin functions */
  7737. -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) {
  7738. +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) {
  7739. (void)args;
  7740. assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_0));
  7741. mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
  7742. @@ -61,7 +61,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  7743. call, fun_builtin_0_call
  7744. );
  7745. -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) {
  7746. +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) {
  7747. assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_1));
  7748. mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
  7749. mp_arg_check_num(n_args, n_kw, 1, 1, false);
  7750. @@ -73,7 +73,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  7751. call, fun_builtin_1_call
  7752. );
  7753. -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) {
  7754. +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) {
  7755. assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_2));
  7756. mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
  7757. mp_arg_check_num(n_args, n_kw, 2, 2, false);
  7758. @@ -85,7 +85,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  7759. call, fun_builtin_2_call
  7760. );
  7761. -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) {
  7762. +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) {
  7763. assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_3));
  7764. mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in);
  7765. mp_arg_check_num(n_args, n_kw, 3, 3, false);
  7766. @@ -97,7 +97,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  7767. call, fun_builtin_3_call
  7768. );
  7769. -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) {
  7770. +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) {
  7771. assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_var));
  7772. mp_obj_fun_builtin_var_t *self = MP_OBJ_TO_PTR(self_in);
  7773. @@ -128,35 +128,29 @@ MP_DEFINE_CONST_OBJ_TYPE(
  7774. /******************************************************************************/
  7775. /* byte code functions */
  7776. -STATIC qstr mp_obj_code_get_name(const mp_obj_fun_bc_t *fun, const byte *code_info) {
  7777. - MP_BC_PRELUDE_SIZE_DECODE(code_info);
  7778. - mp_uint_t name = mp_decode_uint_value(code_info);
  7779. - #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
  7780. - name = fun->context->constants.qstr_table[name];
  7781. - #endif
  7782. - return name;
  7783. -}
  7784. -
  7785. -#if MICROPY_EMIT_NATIVE
  7786. -STATIC const mp_obj_type_t mp_type_fun_native;
  7787. -#endif
  7788. -
  7789. qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
  7790. const mp_obj_fun_bc_t *fun = MP_OBJ_TO_PTR(fun_in);
  7791. + const byte *bc = fun->bytecode;
  7792. +
  7793. #if MICROPY_EMIT_NATIVE
  7794. if (fun->base.type == &mp_type_fun_native || fun->base.type == &mp_type_native_gen_wrap) {
  7795. - // TODO native functions don't have name stored
  7796. - return MP_QSTR_;
  7797. + bc = mp_obj_fun_native_get_prelude_ptr(fun);
  7798. }
  7799. #endif
  7800. - const byte *bc = fun->bytecode;
  7801. MP_BC_PRELUDE_SIG_DECODE(bc);
  7802. - return mp_obj_code_get_name(fun, bc);
  7803. + MP_BC_PRELUDE_SIZE_DECODE(bc);
  7804. +
  7805. + mp_uint_t name = mp_decode_uint_value(bc);
  7806. + #if MICROPY_EMIT_BYTECODE_USES_QSTR_TABLE
  7807. + name = fun->context->constants.qstr_table[name];
  7808. + #endif
  7809. +
  7810. + return name;
  7811. }
  7812. #if MICROPY_CPYTHON_COMPAT
  7813. -STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7814. +static void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  7815. (void)kind;
  7816. mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(o_in);
  7817. mp_printf(print, "<function %q at 0x%p>", mp_obj_fun_get_name(o_in), o);
  7818. @@ -164,7 +158,7 @@ STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
  7819. #endif
  7820. #if DEBUG_PRINT
  7821. -STATIC void dump_args(const mp_obj_t *a, size_t sz) {
  7822. +static void dump_args(const mp_obj_t *a, size_t sz) {
  7823. DEBUG_printf("%p: ", a);
  7824. for (size_t i = 0; i < sz; i++) {
  7825. DEBUG_printf("%p ", a[i]);
  7826. @@ -230,7 +224,7 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args
  7827. }
  7828. #endif
  7829. -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) {
  7830. +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) {
  7831. MP_STACK_CHECK();
  7832. DEBUG_printf("Input n_args: " UINT_FMT ", n_kw: " UINT_FMT "\n", n_args, n_kw);
  7833. @@ -384,7 +378,7 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
  7834. def_kw_args = def_args[1];
  7835. n_extra_args += 1;
  7836. }
  7837. - 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);
  7838. + 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);
  7839. o->bytecode = code;
  7840. o->context = context;
  7841. o->child_table = child_table;
  7842. @@ -402,10 +396,10 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
  7843. #if MICROPY_EMIT_NATIVE
  7844. -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) {
  7845. +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) {
  7846. MP_STACK_CHECK();
  7847. mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
  7848. - mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
  7849. + mp_call_fun_t fun = mp_obj_fun_native_get_function_start(self);
  7850. return fun(self_in, n_args, n_kw, args);
  7851. }
  7852. @@ -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
  7853. #define FUN_BC_TYPE_ATTR
  7854. #endif
  7855. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  7856. +MP_DEFINE_CONST_OBJ_TYPE(
  7857. mp_type_fun_native,
  7858. MP_QSTR_function,
  7859. MP_TYPE_FLAG_BINDS_SELF,
  7860. @@ -429,12 +423,27 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
  7861. call, fun_native_call
  7862. );
  7863. -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) {
  7864. - mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
  7865. - o->base.type = &mp_type_fun_native;
  7866. - return MP_OBJ_FROM_PTR(o);
  7867. +#endif // MICROPY_EMIT_NATIVE
  7868. +
  7869. +/******************************************************************************/
  7870. +/* viper functions */
  7871. +
  7872. +#if MICROPY_EMIT_NATIVE
  7873. +
  7874. +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) {
  7875. + MP_STACK_CHECK();
  7876. + mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
  7877. + mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
  7878. + return fun(self_in, n_args, n_kw, args);
  7879. }
  7880. +MP_DEFINE_CONST_OBJ_TYPE(
  7881. + mp_type_fun_viper,
  7882. + MP_QSTR_function,
  7883. + MP_TYPE_FLAG_BINDS_SELF,
  7884. + call, fun_viper_call
  7885. + );
  7886. +
  7887. #endif // MICROPY_EMIT_NATIVE
  7888. /******************************************************************************/
  7889. @@ -442,13 +451,6 @@ mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, c
  7890. #if MICROPY_EMIT_INLINE_ASM
  7891. -typedef struct _mp_obj_fun_asm_t {
  7892. - mp_obj_base_t base;
  7893. - size_t n_args;
  7894. - const void *fun_data; // GC must be able to trace this pointer
  7895. - mp_uint_t type_sig;
  7896. -} mp_obj_fun_asm_t;
  7897. -
  7898. typedef mp_uint_t (*inline_asm_fun_0_t)(void);
  7899. typedef mp_uint_t (*inline_asm_fun_1_t)(mp_uint_t);
  7900. typedef mp_uint_t (*inline_asm_fun_2_t)(mp_uint_t, mp_uint_t);
  7901. @@ -456,7 +458,7 @@ typedef mp_uint_t (*inline_asm_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t);
  7902. typedef mp_uint_t (*inline_asm_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t);
  7903. // convert a MicroPython object to a sensible value for inline asm
  7904. -STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
  7905. +static mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
  7906. // TODO for byte_array, pass pointer to the array
  7907. if (mp_obj_is_small_int(obj)) {
  7908. return MP_OBJ_SMALL_INT_VALUE(obj);
  7909. @@ -499,7 +501,7 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
  7910. }
  7911. }
  7912. -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) {
  7913. +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) {
  7914. mp_obj_fun_asm_t *self = MP_OBJ_TO_PTR(self_in);
  7915. mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
  7916. @@ -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
  7917. return mp_native_to_obj(ret, self->type_sig);
  7918. }
  7919. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  7920. +MP_DEFINE_CONST_OBJ_TYPE(
  7921. mp_type_fun_asm,
  7922. MP_QSTR_function,
  7923. MP_TYPE_FLAG_BINDS_SELF,
  7924. call, fun_asm_call
  7925. );
  7926. -mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
  7927. - mp_obj_fun_asm_t *o = mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
  7928. - o->n_args = n_args;
  7929. - o->fun_data = fun_data;
  7930. - o->type_sig = type_sig;
  7931. - return MP_OBJ_FROM_PTR(o);
  7932. -}
  7933. -
  7934. #endif // MICROPY_EMIT_INLINE_ASM
  7935. diff --git a/py/objfun.h b/py/objfun.h
  7936. index 9de15b884..af7c33485 100644
  7937. --- a/py/objfun.h
  7938. +++ b/py/objfun.h
  7939. @@ -43,9 +43,70 @@ typedef struct _mp_obj_fun_bc_t {
  7940. mp_obj_t extra_args[];
  7941. } mp_obj_fun_bc_t;
  7942. +typedef struct _mp_obj_fun_asm_t {
  7943. + mp_obj_base_t base;
  7944. + size_t n_args;
  7945. + const void *fun_data; // GC must be able to trace this pointer
  7946. + mp_uint_t type_sig;
  7947. +} mp_obj_fun_asm_t;
  7948. +
  7949. 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);
  7950. -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);
  7951. -mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig);
  7952. void mp_obj_fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
  7953. +#if MICROPY_EMIT_NATIVE
  7954. +
  7955. +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) {
  7956. + mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
  7957. + o->base.type = &mp_type_fun_native;
  7958. + return MP_OBJ_FROM_PTR(o);
  7959. +}
  7960. +
  7961. +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) {
  7962. + mp_obj_fun_bc_t *o = mp_obj_malloc(mp_obj_fun_bc_t, &mp_type_fun_viper);
  7963. + o->bytecode = fun_data;
  7964. + o->context = mc;
  7965. + o->child_table = child_table;
  7966. + return MP_OBJ_FROM_PTR(o);
  7967. +}
  7968. +
  7969. +static inline const uint8_t *mp_obj_fun_native_get_prelude_ptr(const mp_obj_fun_bc_t *fun_native) {
  7970. + // Obtain a pointer to the start of the function prelude, based on prelude_ptr_index.
  7971. + uintptr_t prelude_ptr_index = ((uintptr_t *)fun_native->bytecode)[0];
  7972. + const uint8_t *prelude_ptr;
  7973. + if (prelude_ptr_index == 0) {
  7974. + prelude_ptr = (const uint8_t *)fun_native->child_table;
  7975. + } else {
  7976. + prelude_ptr = (const uint8_t *)fun_native->child_table[prelude_ptr_index];
  7977. + }
  7978. + return prelude_ptr;
  7979. +}
  7980. +
  7981. +static inline void *mp_obj_fun_native_get_function_start(const mp_obj_fun_bc_t *fun_native) {
  7982. + // Obtain a pointer to the start of the function executable machine code.
  7983. + return MICROPY_MAKE_POINTER_CALLABLE((void *)(fun_native->bytecode + sizeof(uintptr_t)));
  7984. +}
  7985. +
  7986. +static inline void *mp_obj_fun_native_get_generator_start(const mp_obj_fun_bc_t *fun_native) {
  7987. + // Obtain a pointer to the start of the generator executable machine code.
  7988. + uintptr_t start_offset = ((uintptr_t *)fun_native->bytecode)[1];
  7989. + return MICROPY_MAKE_POINTER_CALLABLE((void *)(fun_native->bytecode + start_offset));
  7990. +}
  7991. +
  7992. +static inline void *mp_obj_fun_native_get_generator_resume(const mp_obj_fun_bc_t *fun_native) {
  7993. + // Obtain a pointer to the resume location of the generator executable machine code.
  7994. + return MICROPY_MAKE_POINTER_CALLABLE((void *)&((uintptr_t *)fun_native->bytecode)[2]);
  7995. +}
  7996. +
  7997. +#endif
  7998. +
  7999. +#if MICROPY_EMIT_INLINE_ASM
  8000. +static inline mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
  8001. + mp_obj_fun_asm_t *o = mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
  8002. + o->n_args = n_args;
  8003. + o->fun_data = fun_data;
  8004. + o->type_sig = type_sig;
  8005. + return MP_OBJ_FROM_PTR(o);
  8006. +}
  8007. +#endif
  8008. +
  8009. #endif // MICROPY_INCLUDED_PY_OBJFUN_H
  8010. diff --git a/py/objgenerator.c b/py/objgenerator.c
  8011. index ecd1f583e..431cbad5a 100644
  8012. --- a/py/objgenerator.c
  8013. +++ b/py/objgenerator.c
  8014. @@ -50,7 +50,7 @@ typedef struct _mp_obj_gen_instance_t {
  8015. mp_code_state_t code_state;
  8016. } mp_obj_gen_instance_t;
  8017. -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) {
  8018. +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) {
  8019. // A generating function is just a bytecode function with type mp_type_gen_wrap
  8020. mp_obj_fun_bc_t *self_fun = MP_OBJ_TO_PTR(self_in);
  8021. @@ -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
  8022. MP_BC_PRELUDE_SIG_DECODE(ip);
  8023. // allocate the generator object, with room for local stack and exception stack
  8024. - mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, byte,
  8025. + mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, code_state.state, byte,
  8026. n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t),
  8027. &mp_type_gen_instance);
  8028. @@ -96,40 +96,31 @@ typedef struct _mp_obj_gen_instance_native_t {
  8029. mp_code_state_native_t code_state;
  8030. } mp_obj_gen_instance_native_t;
  8031. -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) {
  8032. +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) {
  8033. // The state for a native generating function is held in the same struct as a bytecode function
  8034. mp_obj_fun_bc_t *self_fun = MP_OBJ_TO_PTR(self_in);
  8035. // Determine start of prelude.
  8036. - uintptr_t prelude_ptr_index = ((uintptr_t *)self_fun->bytecode)[0];
  8037. - const uint8_t *prelude_ptr;
  8038. - if (prelude_ptr_index == 0) {
  8039. - prelude_ptr = (void *)self_fun->child_table;
  8040. - } else {
  8041. - prelude_ptr = (void *)self_fun->child_table[prelude_ptr_index];
  8042. - }
  8043. + const uint8_t *prelude_ptr = mp_obj_fun_native_get_prelude_ptr(self_fun);
  8044. // Extract n_state from the prelude.
  8045. const uint8_t *ip = prelude_ptr;
  8046. MP_BC_PRELUDE_SIG_DECODE(ip);
  8047. // Allocate the generator object, with room for local stack (exception stack not needed).
  8048. - 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);
  8049. + 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);
  8050. // Parse the input arguments and set up the code state
  8051. o->pend_exc = mp_const_none;
  8052. o->code_state.fun_bc = self_fun;
  8053. - o->code_state.ip = prelude_ptr;
  8054. o->code_state.n_state = n_state;
  8055. - o->code_state.sp = &o->code_state.state[0] - 1;
  8056. mp_setup_code_state_native(&o->code_state, n_args, n_kw, args);
  8057. // Indicate we are a native function, which doesn't use this variable
  8058. o->code_state.exc_sp_idx = MP_CODE_STATE_EXC_SP_IDX_SENTINEL;
  8059. // Prepare the generator instance for execution
  8060. - uintptr_t start_offset = ((uintptr_t *)self_fun->bytecode)[1];
  8061. - o->code_state.ip = MICROPY_MAKE_POINTER_CALLABLE((void *)(self_fun->bytecode + start_offset));
  8062. + o->code_state.ip = mp_obj_fun_native_get_generator_start(self_fun);
  8063. return MP_OBJ_FROM_PTR(o);
  8064. }
  8065. @@ -153,7 +144,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  8066. /******************************************************************************/
  8067. /* generator instance */
  8068. -STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8069. +static void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8070. (void)kind;
  8071. mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
  8072. mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
  8073. @@ -208,9 +199,9 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
  8074. #if MICROPY_EMIT_NATIVE
  8075. if (self->code_state.exc_sp_idx == MP_CODE_STATE_EXC_SP_IDX_SENTINEL) {
  8076. - // A native generator, with entry point 2 words into the "bytecode" pointer
  8077. + // A native generator.
  8078. typedef uintptr_t (*mp_fun_native_gen_t)(void *, mp_obj_t);
  8079. - mp_fun_native_gen_t fun = MICROPY_MAKE_POINTER_CALLABLE((const void *)(self->code_state.fun_bc->bytecode + 2 * sizeof(uintptr_t)));
  8080. + mp_fun_native_gen_t fun = mp_obj_fun_native_get_generator_resume(self->code_state.fun_bc);
  8081. ret_kind = fun((void *)&self->code_state, throw_value);
  8082. } else
  8083. #endif
  8084. @@ -263,7 +254,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
  8085. return ret_kind;
  8086. }
  8087. -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) {
  8088. +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) {
  8089. mp_obj_t ret;
  8090. switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) {
  8091. case MP_VM_RETURN_NORMAL:
  8092. @@ -287,16 +278,16 @@ STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_o
  8093. }
  8094. }
  8095. -STATIC mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
  8096. +static mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
  8097. return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL, false);
  8098. }
  8099. -STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
  8100. +static mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
  8101. return gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL, true);
  8102. }
  8103. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
  8104. +static MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
  8105. -STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
  8106. +static mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
  8107. // The signature of this function is: throw(type[, value[, traceback]])
  8108. // CPython will pass all given arguments through the call chain and process them
  8109. // at the point they are used (native generators will handle them differently to
  8110. @@ -316,9 +307,9 @@ STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) {
  8111. return gen_resume_and_raise(args[0], mp_const_none, exc, true);
  8112. }
  8113. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw);
  8114. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw);
  8115. -STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {
  8116. +static mp_obj_t gen_instance_close(mp_obj_t self_in) {
  8117. mp_obj_t ret;
  8118. switch (mp_obj_gen_resume(self_in, mp_const_none, MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj), &ret)) {
  8119. case MP_VM_RETURN_YIELD:
  8120. @@ -337,10 +328,10 @@ STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {
  8121. return mp_const_none;
  8122. }
  8123. }
  8124. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close);
  8125. +static MP_DEFINE_CONST_FUN_OBJ_1(gen_instance_close_obj, gen_instance_close);
  8126. #if MICROPY_PY_GENERATOR_PEND_THROW
  8127. -STATIC mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
  8128. +static mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
  8129. mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
  8130. if (self->pend_exc == MP_OBJ_NULL) {
  8131. mp_raise_ValueError(MP_ERROR_TEXT("generator already executing"));
  8132. @@ -349,10 +340,10 @@ STATIC mp_obj_t gen_instance_pend_throw(mp_obj_t self_in, mp_obj_t exc_in) {
  8133. self->pend_exc = exc_in;
  8134. return prev;
  8135. }
  8136. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_pend_throw_obj, gen_instance_pend_throw);
  8137. +static MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_pend_throw_obj, gen_instance_pend_throw);
  8138. #endif
  8139. -STATIC const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
  8140. +static const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
  8141. { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&gen_instance_close_obj) },
  8142. { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&gen_instance_send_obj) },
  8143. { MP_ROM_QSTR(MP_QSTR_throw), MP_ROM_PTR(&gen_instance_throw_obj) },
  8144. @@ -361,7 +352,7 @@ STATIC const mp_rom_map_elem_t gen_instance_locals_dict_table[] = {
  8145. #endif
  8146. };
  8147. -STATIC MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table);
  8148. +static MP_DEFINE_CONST_DICT(gen_instance_locals_dict, gen_instance_locals_dict_table);
  8149. MP_DEFINE_CONST_OBJ_TYPE(
  8150. mp_type_gen_instance,
  8151. diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c
  8152. index c598d1daa..c735c65b6 100644
  8153. --- a/py/objgetitemiter.c
  8154. +++ b/py/objgetitemiter.c
  8155. @@ -35,7 +35,7 @@ typedef struct _mp_obj_getitem_iter_t {
  8156. mp_obj_t args[3];
  8157. } mp_obj_getitem_iter_t;
  8158. -STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
  8159. +static mp_obj_t it_iternext(mp_obj_t self_in) {
  8160. mp_obj_getitem_iter_t *self = MP_OBJ_TO_PTR(self_in);
  8161. nlr_buf_t nlr;
  8162. if (nlr_push(&nlr) == 0) {
  8163. @@ -56,7 +56,7 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
  8164. }
  8165. }
  8166. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  8167. +static MP_DEFINE_CONST_OBJ_TYPE(
  8168. mp_type_it,
  8169. MP_QSTR_iterator,
  8170. MP_TYPE_FLAG_ITER_IS_ITERNEXT,
  8171. diff --git a/py/objint.c b/py/objint.c
  8172. index be5f4653a..6caa608f3 100644
  8173. --- a/py/objint.c
  8174. +++ b/py/objint.c
  8175. @@ -40,7 +40,7 @@
  8176. #endif
  8177. // This dispatcher function is expected to be independent of the implementation of long int
  8178. -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) {
  8179. +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) {
  8180. (void)type_in;
  8181. mp_arg_check_num(n_args, n_kw, 0, 2, false);
  8182. @@ -83,7 +83,7 @@ typedef enum {
  8183. MP_FP_CLASS_OVERFLOW
  8184. } mp_fp_as_int_class_t;
  8185. -STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
  8186. +static mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
  8187. union {
  8188. mp_float_t f;
  8189. #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
  8190. @@ -193,7 +193,7 @@ void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
  8191. }
  8192. }
  8193. -STATIC const uint8_t log_base2_floor[] = {
  8194. +static const uint8_t log_base2_floor[] = {
  8195. 0, 1, 1, 2,
  8196. 2, 2, 2, 3,
  8197. 3, 3, 3, 3,
  8198. @@ -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
  8199. }
  8200. // this is a classmethod
  8201. -STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
  8202. +static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
  8203. // TODO: Support signed param (assumes signed=False at the moment)
  8204. (void)n_args;
  8205. @@ -417,10 +417,10 @@ STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
  8206. return mp_obj_new_int_from_uint(value);
  8207. }
  8208. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);
  8209. -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj));
  8210. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);
  8211. +static MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj));
  8212. -STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
  8213. +static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
  8214. // TODO: Support signed param (assumes signed=False)
  8215. (void)n_args;
  8216. @@ -448,14 +448,14 @@ STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
  8217. return mp_obj_new_bytes_from_vstr(&vstr);
  8218. }
  8219. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes);
  8220. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 3, 4, int_to_bytes);
  8221. -STATIC const mp_rom_map_elem_t int_locals_dict_table[] = {
  8222. +static const mp_rom_map_elem_t int_locals_dict_table[] = {
  8223. { MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) },
  8224. { MP_ROM_QSTR(MP_QSTR_to_bytes), MP_ROM_PTR(&int_to_bytes_obj) },
  8225. };
  8226. -STATIC MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table);
  8227. +static MP_DEFINE_CONST_DICT(int_locals_dict, int_locals_dict_table);
  8228. MP_DEFINE_CONST_OBJ_TYPE(
  8229. mp_type_int,
  8230. diff --git a/py/objint_mpz.c b/py/objint_mpz.c
  8231. index 8078441d6..600316a42 100644
  8232. --- a/py/objint_mpz.c
  8233. +++ b/py/objint_mpz.c
  8234. @@ -43,7 +43,7 @@
  8235. // Export value for sys.maxsize
  8236. // *FORMAT-OFF*
  8237. #define DIG_MASK ((MPZ_LONG_1 << MPZ_DIG_SIZE) - 1)
  8238. -STATIC const mpz_dig_t maxsize_dig[] = {
  8239. +static const mpz_dig_t maxsize_dig[] = {
  8240. #define NUM_DIG 1
  8241. (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) & DIG_MASK,
  8242. #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) > DIG_MASK
  8243. @@ -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
  8244. }
  8245. #if MICROPY_PY_BUILTINS_POW3
  8246. -STATIC mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
  8247. +static mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
  8248. if (mp_obj_is_small_int(arg)) {
  8249. mpz_init_from_int(temp, MP_OBJ_SMALL_INT_VALUE(arg));
  8250. return temp;
  8251. diff --git a/py/objlist.c b/py/objlist.c
  8252. index 1423cb1de..2198beb83 100644
  8253. --- a/py/objlist.c
  8254. +++ b/py/objlist.c
  8255. @@ -31,10 +31,10 @@
  8256. #include "py/runtime.h"
  8257. #include "py/stackctrl.h"
  8258. -STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf);
  8259. -STATIC mp_obj_list_t *list_new(size_t n);
  8260. -STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
  8261. -STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
  8262. +static mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf);
  8263. +static mp_obj_list_t *list_new(size_t n);
  8264. +static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
  8265. +static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
  8266. // TODO: Move to mpconfig.h
  8267. #define LIST_MIN_ALLOC 4
  8268. @@ -42,7 +42,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args);
  8269. /******************************************************************************/
  8270. /* list */
  8271. -STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  8272. +static void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  8273. mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in);
  8274. const char *item_separator = ", ";
  8275. if (!(MICROPY_PY_JSON && kind == PRINT_JSON)) {
  8276. @@ -62,7 +62,7 @@ STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
  8277. mp_print_str(print, "]");
  8278. }
  8279. -STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
  8280. +static mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
  8281. mp_obj_t iter = mp_getiter(iterable, NULL);
  8282. mp_obj_t item;
  8283. while ((item = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
  8284. @@ -90,7 +90,7 @@ mp_obj_t mp_obj_list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
  8285. }
  8286. }
  8287. -STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  8288. +static mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  8289. mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
  8290. switch (op) {
  8291. case MP_UNARY_OP_BOOL:
  8292. @@ -108,7 +108,7 @@ STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  8293. }
  8294. }
  8295. -STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
  8296. +static mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
  8297. mp_obj_list_t *o = MP_OBJ_TO_PTR(lhs);
  8298. switch (op) {
  8299. case MP_BINARY_OP_ADD: {
  8300. @@ -158,7 +158,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
  8301. }
  8302. }
  8303. -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  8304. +static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  8305. if (value == MP_OBJ_NULL) {
  8306. // delete
  8307. #if MICROPY_PY_BUILTINS_SLICE
  8308. @@ -234,7 +234,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  8309. }
  8310. }
  8311. -STATIC mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
  8312. +static mp_obj_t list_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
  8313. return mp_obj_new_list_iterator(o_in, 0, iter_buf);
  8314. }
  8315. @@ -250,7 +250,7 @@ mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) {
  8316. return mp_const_none; // return None, as per CPython
  8317. }
  8318. -STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
  8319. +static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
  8320. mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
  8321. if (mp_obj_is_type(arg_in, &mp_type_list)) {
  8322. mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
  8323. @@ -271,7 +271,7 @@ STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
  8324. return mp_const_none; // return None, as per CPython
  8325. }
  8326. -STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
  8327. +static mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
  8328. mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
  8329. mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]);
  8330. if (self->len == 0) {
  8331. @@ -290,7 +290,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
  8332. return ret;
  8333. }
  8334. -STATIC void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) {
  8335. +static void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, mp_obj_t binop_less_result) {
  8336. MP_STACK_CHECK();
  8337. while (head < tail) {
  8338. mp_obj_t *h = head - 1;
  8339. @@ -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_
  8340. return mp_const_none;
  8341. }
  8342. -STATIC mp_obj_t list_clear(mp_obj_t self_in) {
  8343. +static mp_obj_t list_clear(mp_obj_t self_in) {
  8344. mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
  8345. mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
  8346. self->len = 0;
  8347. @@ -358,25 +358,25 @@ STATIC mp_obj_t list_clear(mp_obj_t self_in) {
  8348. return mp_const_none;
  8349. }
  8350. -STATIC mp_obj_t list_copy(mp_obj_t self_in) {
  8351. +static mp_obj_t list_copy(mp_obj_t self_in) {
  8352. mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
  8353. mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
  8354. return mp_obj_new_list(self->len, self->items);
  8355. }
  8356. -STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
  8357. +static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
  8358. mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
  8359. mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
  8360. return mp_seq_count_obj(self->items, self->len, value);
  8361. }
  8362. -STATIC mp_obj_t list_index(size_t n_args, const mp_obj_t *args) {
  8363. +static mp_obj_t list_index(size_t n_args, const mp_obj_t *args) {
  8364. mp_check_self(mp_obj_is_type(args[0], &mp_type_list));
  8365. mp_obj_list_t *self = MP_OBJ_TO_PTR(args[0]);
  8366. return mp_seq_index_obj(self->items, self->len, n_args, args);
  8367. }
  8368. -STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
  8369. +static mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
  8370. mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
  8371. mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
  8372. // insert has its own strange index logic
  8373. @@ -410,7 +410,7 @@ mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value) {
  8374. return mp_const_none;
  8375. }
  8376. -STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
  8377. +static mp_obj_t list_reverse(mp_obj_t self_in) {
  8378. mp_check_self(mp_obj_is_type(self_in, &mp_type_list));
  8379. mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
  8380. @@ -424,19 +424,19 @@ STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
  8381. return mp_const_none;
  8382. }
  8383. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
  8384. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
  8385. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
  8386. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
  8387. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
  8388. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
  8389. -STATIC MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
  8390. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
  8391. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove);
  8392. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
  8393. -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort);
  8394. -
  8395. -STATIC const mp_rom_map_elem_t list_locals_dict_table[] = {
  8396. +static MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
  8397. +static MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
  8398. +static MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
  8399. +static MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
  8400. +static MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
  8401. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
  8402. +static MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
  8403. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
  8404. +static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, mp_obj_list_remove);
  8405. +static MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
  8406. +static MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 1, mp_obj_list_sort);
  8407. +
  8408. +static const mp_rom_map_elem_t list_locals_dict_table[] = {
  8409. { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&list_append_obj) },
  8410. { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&list_clear_obj) },
  8411. { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&list_copy_obj) },
  8412. @@ -450,7 +450,7 @@ STATIC const mp_rom_map_elem_t list_locals_dict_table[] = {
  8413. { MP_ROM_QSTR(MP_QSTR_sort), MP_ROM_PTR(&list_sort_obj) },
  8414. };
  8415. -STATIC MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table);
  8416. +static MP_DEFINE_CONST_DICT(list_locals_dict, list_locals_dict_table);
  8417. MP_DEFINE_CONST_OBJ_TYPE(
  8418. mp_type_list,
  8419. @@ -474,7 +474,7 @@ void mp_obj_list_init(mp_obj_list_t *o, size_t n) {
  8420. mp_seq_clear(o->items, n, o->alloc, sizeof(*o->items));
  8421. }
  8422. -STATIC mp_obj_list_t *list_new(size_t n) {
  8423. +static mp_obj_list_t *list_new(size_t n) {
  8424. mp_obj_list_t *o = m_new_obj(mp_obj_list_t);
  8425. mp_obj_list_init(o, n);
  8426. return o;
  8427. @@ -519,7 +519,7 @@ typedef struct _mp_obj_list_it_t {
  8428. size_t cur;
  8429. } mp_obj_list_it_t;
  8430. -STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) {
  8431. +static mp_obj_t list_it_iternext(mp_obj_t self_in) {
  8432. mp_obj_list_it_t *self = MP_OBJ_TO_PTR(self_in);
  8433. mp_obj_list_t *list = MP_OBJ_TO_PTR(self->list);
  8434. if (self->cur < list->len) {
  8435. diff --git a/py/objmap.c b/py/objmap.c
  8436. index e7e594cd2..1911a7510 100644
  8437. --- a/py/objmap.c
  8438. +++ b/py/objmap.c
  8439. @@ -36,9 +36,9 @@ typedef struct _mp_obj_map_t {
  8440. mp_obj_t iters[];
  8441. } mp_obj_map_t;
  8442. -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) {
  8443. +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) {
  8444. mp_arg_check_num(n_args, n_kw, 2, MP_OBJ_FUN_ARGS_MAX, false);
  8445. - mp_obj_map_t *o = mp_obj_malloc_var(mp_obj_map_t, mp_obj_t, n_args - 1, type);
  8446. + mp_obj_map_t *o = mp_obj_malloc_var(mp_obj_map_t, iters, mp_obj_t, n_args - 1, type);
  8447. o->n_iters = n_args - 1;
  8448. o->fun = args[0];
  8449. for (size_t i = 0; i < n_args - 1; i++) {
  8450. @@ -47,7 +47,7 @@ STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
  8451. return MP_OBJ_FROM_PTR(o);
  8452. }
  8453. -STATIC mp_obj_t map_iternext(mp_obj_t self_in) {
  8454. +static mp_obj_t map_iternext(mp_obj_t self_in) {
  8455. mp_check_self(mp_obj_is_type(self_in, &mp_type_map));
  8456. mp_obj_map_t *self = MP_OBJ_TO_PTR(self_in);
  8457. mp_obj_t *nextses = m_new(mp_obj_t, self->n_iters);
  8458. diff --git a/py/objmodule.c b/py/objmodule.c
  8459. index 5266421b7..5ce373b83 100644
  8460. --- a/py/objmodule.c
  8461. +++ b/py/objmodule.c
  8462. @@ -34,7 +34,7 @@
  8463. #include "py/runtime.h"
  8464. #include "py/builtin.h"
  8465. -STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8466. +static void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8467. (void)kind;
  8468. mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
  8469. @@ -57,9 +57,9 @@ STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin
  8470. mp_printf(print, "<module '%s'>", module_name);
  8471. }
  8472. -STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
  8473. +static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
  8474. -STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  8475. +static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  8476. mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
  8477. if (dest[0] == MP_OBJ_NULL) {
  8478. // load attribute
  8479. @@ -146,13 +146,13 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
  8480. /******************************************************************************/
  8481. // Global module table and related functions
  8482. -STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
  8483. +static const mp_rom_map_elem_t mp_builtin_module_table[] = {
  8484. // built-in modules declared with MP_REGISTER_MODULE()
  8485. MICROPY_REGISTERED_MODULES
  8486. };
  8487. MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table);
  8488. -STATIC const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = {
  8489. +static const mp_rom_map_elem_t mp_builtin_extensible_module_table[] = {
  8490. // built-in modules declared with MP_REGISTER_EXTENSIBLE_MODULE()
  8491. MICROPY_REGISTERED_EXTENSIBLE_MODULES
  8492. };
  8493. @@ -164,7 +164,7 @@ typedef struct _mp_module_delegation_entry_t {
  8494. mp_attr_fun_t fun;
  8495. } mp_module_delegation_entry_t;
  8496. -STATIC const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = {
  8497. +static const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = {
  8498. // delegation entries declared with MP_REGISTER_MODULE_DELEGATION()
  8499. MICROPY_MODULE_DELEGATIONS
  8500. };
  8501. @@ -223,7 +223,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
  8502. return elem->value;
  8503. }
  8504. -STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  8505. +static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  8506. #if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS)
  8507. // Delegate lookup to a module's custom attr method.
  8508. size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table);
  8509. diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
  8510. index e586f0894..f019604d5 100644
  8511. --- a/py/objnamedtuple.c
  8512. +++ b/py/objnamedtuple.c
  8513. @@ -44,7 +44,7 @@ size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr n
  8514. }
  8515. #if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
  8516. -STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
  8517. +static mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
  8518. mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
  8519. const qstr *fields = ((mp_obj_namedtuple_type_t *)self->tuple.base.type)->fields;
  8520. mp_obj_t dict = mp_obj_new_dict(self->tuple.len);
  8521. @@ -60,7 +60,7 @@ STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
  8522. MP_DEFINE_CONST_FUN_OBJ_1(namedtuple_asdict_obj, namedtuple_asdict);
  8523. #endif
  8524. -STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  8525. +static void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  8526. (void)kind;
  8527. mp_obj_namedtuple_t *o = MP_OBJ_TO_PTR(o_in);
  8528. mp_printf(print, "%q", o->tuple.base.type->name);
  8529. @@ -68,7 +68,7 @@ STATIC void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_ki
  8530. mp_obj_attrtuple_print_helper(print, fields, &o->tuple);
  8531. }
  8532. -STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  8533. +static void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  8534. if (dest[0] == MP_OBJ_NULL) {
  8535. // load attribute
  8536. mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
  8537. @@ -91,7 +91,7 @@ STATIC void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  8538. }
  8539. }
  8540. -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) {
  8541. +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) {
  8542. const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t *)type_in;
  8543. size_t num_fields = type->n_fields;
  8544. if (n_args + n_kw != num_fields) {
  8545. @@ -110,7 +110,7 @@ STATIC mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args,
  8546. // Create a namedtuple with explicit malloc. Calling mp_obj_new_tuple
  8547. // with num_fields=0 returns a read-only object.
  8548. - mp_obj_tuple_t *tuple = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, num_fields, type_in);
  8549. + mp_obj_tuple_t *tuple = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, num_fields, type_in);
  8550. tuple->len = num_fields;
  8551. // Copy the positional args into the first slots of the namedtuple
  8552. @@ -151,7 +151,7 @@ mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *
  8553. return o;
  8554. }
  8555. -STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) {
  8556. +static mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t *fields) {
  8557. mp_obj_namedtuple_type_t *o = mp_obj_new_namedtuple_base(n_fields, fields);
  8558. mp_obj_type_t *type = (mp_obj_type_t *)&o->base;
  8559. type->base.type = &mp_type_type;
  8560. @@ -168,7 +168,7 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t
  8561. return MP_OBJ_FROM_PTR(o);
  8562. }
  8563. -STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
  8564. +static mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
  8565. qstr name = mp_obj_str_get_qstr(name_in);
  8566. size_t n_fields;
  8567. mp_obj_t *fields;
  8568. diff --git a/py/objnone.c b/py/objnone.c
  8569. index 5b25cd38c..a8ce8ebfe 100644
  8570. --- a/py/objnone.c
  8571. +++ b/py/objnone.c
  8572. @@ -34,7 +34,7 @@ typedef struct _mp_obj_none_t {
  8573. } mp_obj_none_t;
  8574. #endif
  8575. -STATIC void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8576. +static void none_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8577. (void)self_in;
  8578. if (MICROPY_PY_JSON && kind == PRINT_JSON) {
  8579. mp_print_str(print, "null");
  8580. diff --git a/py/objobject.c b/py/objobject.c
  8581. index 1acae6d00..ff93fd082 100644
  8582. --- a/py/objobject.c
  8583. +++ b/py/objobject.c
  8584. @@ -33,7 +33,7 @@ typedef struct _mp_obj_object_t {
  8585. mp_obj_base_t base;
  8586. } mp_obj_object_t;
  8587. -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) {
  8588. +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) {
  8589. (void)args;
  8590. mp_arg_check_num(n_args, n_kw, 0, 0, false);
  8591. mp_obj_object_t *o = mp_obj_malloc(mp_obj_object_t, type);
  8592. @@ -41,13 +41,13 @@ STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t
  8593. }
  8594. #if MICROPY_CPYTHON_COMPAT
  8595. -STATIC mp_obj_t object___init__(mp_obj_t self) {
  8596. +static mp_obj_t object___init__(mp_obj_t self) {
  8597. (void)self;
  8598. return mp_const_none;
  8599. }
  8600. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
  8601. +static MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
  8602. -STATIC mp_obj_t object___new__(mp_obj_t cls) {
  8603. +static mp_obj_t object___new__(mp_obj_t cls) {
  8604. if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) {
  8605. mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
  8606. }
  8607. @@ -58,11 +58,11 @@ STATIC mp_obj_t object___new__(mp_obj_t cls) {
  8608. const mp_obj_type_t *native_base;
  8609. return MP_OBJ_FROM_PTR(mp_obj_new_instance(MP_OBJ_TO_PTR(cls), &native_base));
  8610. }
  8611. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
  8612. -STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));
  8613. +static MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
  8614. +static MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));
  8615. #if MICROPY_PY_DELATTR_SETATTR
  8616. -STATIC mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) {
  8617. +static mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t value) {
  8618. if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) {
  8619. mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
  8620. }
  8621. @@ -75,9 +75,9 @@ STATIC mp_obj_t object___setattr__(mp_obj_t self_in, mp_obj_t attr, mp_obj_t val
  8622. mp_map_lookup(&self->members, attr, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
  8623. return mp_const_none;
  8624. }
  8625. -STATIC MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__);
  8626. +static MP_DEFINE_CONST_FUN_OBJ_3(object___setattr___obj, object___setattr__);
  8627. -STATIC mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
  8628. +static mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
  8629. if (!mp_obj_is_instance_type(mp_obj_get_type(self_in))) {
  8630. mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
  8631. }
  8632. @@ -92,10 +92,10 @@ STATIC mp_obj_t object___delattr__(mp_obj_t self_in, mp_obj_t attr) {
  8633. }
  8634. return mp_const_none;
  8635. }
  8636. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__);
  8637. +static MP_DEFINE_CONST_FUN_OBJ_2(object___delattr___obj, object___delattr__);
  8638. #endif
  8639. -STATIC const mp_rom_map_elem_t object_locals_dict_table[] = {
  8640. +static const mp_rom_map_elem_t object_locals_dict_table[] = {
  8641. #if MICROPY_CPYTHON_COMPAT
  8642. { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&object___init___obj) },
  8643. #endif
  8644. @@ -108,7 +108,7 @@ STATIC const mp_rom_map_elem_t object_locals_dict_table[] = {
  8645. #endif
  8646. };
  8647. -STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
  8648. +static MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
  8649. #endif
  8650. #if MICROPY_CPYTHON_COMPAT
  8651. diff --git a/py/objpolyiter.c b/py/objpolyiter.c
  8652. index 78b600aba..65c1f182e 100644
  8653. --- a/py/objpolyiter.c
  8654. +++ b/py/objpolyiter.c
  8655. @@ -39,7 +39,7 @@ typedef struct _mp_obj_polymorph_iter_t {
  8656. mp_fun_1_t iternext;
  8657. } mp_obj_polymorph_iter_t;
  8658. -STATIC mp_obj_t polymorph_it_iternext(mp_obj_t self_in) {
  8659. +static mp_obj_t polymorph_it_iternext(mp_obj_t self_in) {
  8660. mp_obj_polymorph_iter_t *self = MP_OBJ_TO_PTR(self_in);
  8661. // Redirect call to object instance's iternext method
  8662. return self->iternext(self_in);
  8663. @@ -64,17 +64,17 @@ typedef struct _mp_obj_polymorph_iter_with_finaliser_t {
  8664. mp_fun_1_t finaliser;
  8665. } mp_obj_polymorph_with_finaliser_iter_t;
  8666. -STATIC mp_obj_t mp_obj_polymorph_iter_del(mp_obj_t self_in) {
  8667. +static mp_obj_t mp_obj_polymorph_iter_del(mp_obj_t self_in) {
  8668. mp_obj_polymorph_with_finaliser_iter_t *self = MP_OBJ_TO_PTR(self_in);
  8669. // Redirect call to object instance's finaliser method
  8670. return self->finaliser(self_in);
  8671. }
  8672. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_obj_polymorph_iter_del_obj, mp_obj_polymorph_iter_del);
  8673. +static MP_DEFINE_CONST_FUN_OBJ_1(mp_obj_polymorph_iter_del_obj, mp_obj_polymorph_iter_del);
  8674. -STATIC const mp_rom_map_elem_t mp_obj_polymorph_iter_locals_dict_table[] = {
  8675. +static const mp_rom_map_elem_t mp_obj_polymorph_iter_locals_dict_table[] = {
  8676. { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_obj_polymorph_iter_del_obj) },
  8677. };
  8678. -STATIC MP_DEFINE_CONST_DICT(mp_obj_polymorph_iter_locals_dict, mp_obj_polymorph_iter_locals_dict_table);
  8679. +static MP_DEFINE_CONST_DICT(mp_obj_polymorph_iter_locals_dict, mp_obj_polymorph_iter_locals_dict_table);
  8680. MP_DEFINE_CONST_OBJ_TYPE(
  8681. mp_type_polymorph_iter_with_finaliser,
  8682. diff --git a/py/objproperty.c b/py/objproperty.c
  8683. index 2d3af10e8..155ffb16b 100644
  8684. --- a/py/objproperty.c
  8685. +++ b/py/objproperty.c
  8686. @@ -36,7 +36,7 @@ typedef struct _mp_obj_property_t {
  8687. mp_obj_t proxy[3]; // getter, setter, deleter
  8688. } mp_obj_property_t;
  8689. -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) {
  8690. +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) {
  8691. enum { ARG_fget, ARG_fset, ARG_fdel, ARG_doc };
  8692. static const mp_arg_t allowed_args[] = {
  8693. { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
  8694. @@ -55,40 +55,40 @@ STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size
  8695. return MP_OBJ_FROM_PTR(o);
  8696. }
  8697. -STATIC mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) {
  8698. +static mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) {
  8699. mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
  8700. *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
  8701. p2->proxy[0] = getter;
  8702. return MP_OBJ_FROM_PTR(p2);
  8703. }
  8704. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter);
  8705. +static MP_DEFINE_CONST_FUN_OBJ_2(property_getter_obj, property_getter);
  8706. -STATIC mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) {
  8707. +static mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) {
  8708. mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
  8709. *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
  8710. p2->proxy[1] = setter;
  8711. return MP_OBJ_FROM_PTR(p2);
  8712. }
  8713. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter);
  8714. +static MP_DEFINE_CONST_FUN_OBJ_2(property_setter_obj, property_setter);
  8715. -STATIC mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) {
  8716. +static mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) {
  8717. mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
  8718. *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
  8719. p2->proxy[2] = deleter;
  8720. return MP_OBJ_FROM_PTR(p2);
  8721. }
  8722. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter);
  8723. +static MP_DEFINE_CONST_FUN_OBJ_2(property_deleter_obj, property_deleter);
  8724. -STATIC const mp_rom_map_elem_t property_locals_dict_table[] = {
  8725. +static const mp_rom_map_elem_t property_locals_dict_table[] = {
  8726. { MP_ROM_QSTR(MP_QSTR_getter), MP_ROM_PTR(&property_getter_obj) },
  8727. { MP_ROM_QSTR(MP_QSTR_setter), MP_ROM_PTR(&property_setter_obj) },
  8728. { MP_ROM_QSTR(MP_QSTR_deleter), MP_ROM_PTR(&property_deleter_obj) },
  8729. };
  8730. -STATIC MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table);
  8731. +static MP_DEFINE_CONST_DICT(property_locals_dict, property_locals_dict_table);
  8732. MP_DEFINE_CONST_OBJ_TYPE(
  8733. mp_type_property,
  8734. diff --git a/py/objrange.c b/py/objrange.c
  8735. index f0fe56d9d..9a4ecd3fc 100644
  8736. --- a/py/objrange.c
  8737. +++ b/py/objrange.c
  8738. @@ -39,7 +39,7 @@ typedef struct _mp_obj_range_it_t {
  8739. mp_int_t step;
  8740. } mp_obj_range_it_t;
  8741. -STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
  8742. +static mp_obj_t range_it_iternext(mp_obj_t o_in) {
  8743. mp_obj_range_it_t *o = MP_OBJ_TO_PTR(o_in);
  8744. if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) {
  8745. mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(o->cur);
  8746. @@ -50,14 +50,14 @@ STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
  8747. }
  8748. }
  8749. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  8750. +static MP_DEFINE_CONST_OBJ_TYPE(
  8751. mp_type_range_it,
  8752. MP_QSTR_iterator,
  8753. MP_TYPE_FLAG_ITER_IS_ITERNEXT,
  8754. iter, range_it_iternext
  8755. );
  8756. -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) {
  8757. +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) {
  8758. assert(sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t));
  8759. mp_obj_range_it_t *o = (mp_obj_range_it_t *)iter_buf;
  8760. o->base.type = &mp_type_range_it;
  8761. @@ -78,7 +78,7 @@ typedef struct _mp_obj_range_t {
  8762. mp_int_t step;
  8763. } mp_obj_range_t;
  8764. -STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8765. +static void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8766. (void)kind;
  8767. mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
  8768. mp_printf(print, "range(" INT_FMT ", " INT_FMT "", self->start, self->stop);
  8769. @@ -89,7 +89,7 @@ STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind
  8770. }
  8771. }
  8772. -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) {
  8773. +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) {
  8774. mp_arg_check_num(n_args, n_kw, 1, 3, false);
  8775. mp_obj_range_t *o = mp_obj_malloc(mp_obj_range_t, type);
  8776. @@ -112,7 +112,7 @@ STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t
  8777. return MP_OBJ_FROM_PTR(o);
  8778. }
  8779. -STATIC mp_int_t range_len(mp_obj_range_t *self) {
  8780. +static mp_int_t range_len(mp_obj_range_t *self) {
  8781. // When computing length, need to take into account step!=1 and step<0.
  8782. mp_int_t len = self->stop - self->start + self->step;
  8783. if (self->step > 0) {
  8784. @@ -127,7 +127,7 @@ STATIC mp_int_t range_len(mp_obj_range_t *self) {
  8785. return len;
  8786. }
  8787. -STATIC mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  8788. +static mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  8789. mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
  8790. mp_int_t len = range_len(self);
  8791. switch (op) {
  8792. @@ -141,7 +141,7 @@ STATIC mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  8793. }
  8794. #if MICROPY_PY_BUILTINS_RANGE_BINOP
  8795. -STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  8796. +static mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  8797. if (!mp_obj_is_type(rhs_in, &mp_type_range) || op != MP_BINARY_OP_EQUAL) {
  8798. return MP_OBJ_NULL; // op not supported
  8799. }
  8800. @@ -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
  8801. }
  8802. #endif
  8803. -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  8804. +static mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  8805. if (value == MP_OBJ_SENTINEL) {
  8806. // load
  8807. mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
  8808. @@ -185,14 +185,14 @@ STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  8809. }
  8810. }
  8811. -STATIC mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
  8812. +static mp_obj_t range_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
  8813. mp_obj_range_t *o = MP_OBJ_TO_PTR(o_in);
  8814. return mp_obj_new_range_iterator(o->start, o->stop, o->step, iter_buf);
  8815. }
  8816. #if MICROPY_PY_BUILTINS_RANGE_ATTRS
  8817. -STATIC void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
  8818. +static void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
  8819. if (dest[0] != MP_OBJ_NULL) {
  8820. // not load attribute
  8821. return;
  8822. diff --git a/py/objreversed.c b/py/objreversed.c
  8823. index c66698f02..c580ee286 100644
  8824. --- a/py/objreversed.c
  8825. +++ b/py/objreversed.c
  8826. @@ -37,7 +37,7 @@ typedef struct _mp_obj_reversed_t {
  8827. mp_uint_t cur_index; // current index, plus 1; 0=no more, 1=last one (index 0)
  8828. } mp_obj_reversed_t;
  8829. -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) {
  8830. +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) {
  8831. mp_arg_check_num(n_args, n_kw, 1, 1, false);
  8832. // check if __reversed__ exists, and if so delegate to it
  8833. @@ -54,7 +54,7 @@ STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size
  8834. return MP_OBJ_FROM_PTR(o);
  8835. }
  8836. -STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) {
  8837. +static mp_obj_t reversed_iternext(mp_obj_t self_in) {
  8838. mp_check_self(mp_obj_is_type(self_in, &mp_type_reversed));
  8839. mp_obj_reversed_t *self = MP_OBJ_TO_PTR(self_in);
  8840. diff --git a/py/objset.c b/py/objset.c
  8841. index 906807889..c8fa12a7e 100644
  8842. --- a/py/objset.c
  8843. +++ b/py/objset.c
  8844. @@ -45,7 +45,7 @@ typedef struct _mp_obj_set_it_t {
  8845. size_t cur;
  8846. } mp_obj_set_it_t;
  8847. -STATIC bool is_set_or_frozenset(mp_obj_t o) {
  8848. +static bool is_set_or_frozenset(mp_obj_t o) {
  8849. return mp_obj_is_type(o, &mp_type_set)
  8850. #if MICROPY_PY_BUILTINS_FROZENSET
  8851. || mp_obj_is_type(o, &mp_type_frozenset)
  8852. @@ -60,7 +60,7 @@ STATIC bool is_set_or_frozenset(mp_obj_t o) {
  8853. // set or frozenset for methods that operate on both of these types.
  8854. #define check_set_or_frozenset(o) mp_check_self(is_set_or_frozenset(o))
  8855. -STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8856. +static void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  8857. (void)kind;
  8858. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  8859. #if MICROPY_PY_BUILTINS_FROZENSET
  8860. @@ -99,7 +99,7 @@ STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
  8861. #endif
  8862. }
  8863. -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) {
  8864. +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) {
  8865. mp_arg_check_num(n_args, n_kw, 0, 1, false);
  8866. switch (n_args) {
  8867. @@ -127,7 +127,7 @@ STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
  8868. }
  8869. }
  8870. -STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
  8871. +static mp_obj_t set_it_iternext(mp_obj_t self_in) {
  8872. mp_obj_set_it_t *self = MP_OBJ_TO_PTR(self_in);
  8873. size_t max = self->set->set.alloc;
  8874. mp_set_t *set = &self->set->set;
  8875. @@ -142,7 +142,7 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
  8876. return MP_OBJ_STOP_ITERATION;
  8877. }
  8878. -STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
  8879. +static mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
  8880. assert(sizeof(mp_obj_set_it_t) <= sizeof(mp_obj_iter_buf_t));
  8881. mp_obj_set_it_t *o = (mp_obj_set_it_t *)iter_buf;
  8882. o->base.type = &mp_type_polymorph_iter;
  8883. @@ -155,23 +155,23 @@ STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
  8884. /******************************************************************************/
  8885. /* set methods */
  8886. -STATIC mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
  8887. +static mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
  8888. check_set(self_in);
  8889. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  8890. mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
  8891. return mp_const_none;
  8892. }
  8893. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
  8894. +static MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
  8895. -STATIC mp_obj_t set_clear(mp_obj_t self_in) {
  8896. +static mp_obj_t set_clear(mp_obj_t self_in) {
  8897. check_set(self_in);
  8898. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  8899. mp_set_clear(&self->set);
  8900. return mp_const_none;
  8901. }
  8902. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
  8903. +static MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
  8904. -STATIC mp_obj_t set_copy(mp_obj_t self_in) {
  8905. +static mp_obj_t set_copy(mp_obj_t self_in) {
  8906. check_set_or_frozenset(self_in);
  8907. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  8908. mp_obj_set_t *other = mp_obj_malloc(mp_obj_set_t, self->base.type);
  8909. @@ -180,17 +180,17 @@ STATIC mp_obj_t set_copy(mp_obj_t self_in) {
  8910. memcpy(other->set.table, self->set.table, self->set.alloc * sizeof(mp_obj_t));
  8911. return MP_OBJ_FROM_PTR(other);
  8912. }
  8913. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
  8914. +static MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
  8915. -STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
  8916. +static mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
  8917. check_set(self_in);
  8918. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  8919. mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
  8920. return mp_const_none;
  8921. }
  8922. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
  8923. +static MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
  8924. -STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
  8925. +static mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
  8926. mp_obj_t self;
  8927. if (update) {
  8928. check_set(args[0]);
  8929. @@ -216,18 +216,18 @@ STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
  8930. return self;
  8931. }
  8932. -STATIC mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) {
  8933. +static mp_obj_t set_diff(size_t n_args, const mp_obj_t *args) {
  8934. return set_diff_int(n_args, args, false);
  8935. }
  8936. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
  8937. +static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
  8938. -STATIC mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) {
  8939. +static mp_obj_t set_diff_update(size_t n_args, const mp_obj_t *args) {
  8940. set_diff_int(n_args, args, true);
  8941. return mp_const_none;
  8942. }
  8943. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
  8944. +static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
  8945. -STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
  8946. +static mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
  8947. if (update) {
  8948. check_set(self_in);
  8949. } else {
  8950. @@ -259,17 +259,17 @@ STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update)
  8951. return update ? mp_const_none : MP_OBJ_FROM_PTR(out);
  8952. }
  8953. -STATIC mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
  8954. +static mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
  8955. return set_intersect_int(self_in, other, false);
  8956. }
  8957. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
  8958. +static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
  8959. -STATIC mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
  8960. +static mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
  8961. return set_intersect_int(self_in, other, true);
  8962. }
  8963. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
  8964. +static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
  8965. -STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
  8966. +static mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
  8967. check_set_or_frozenset(self_in);
  8968. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  8969. @@ -283,9 +283,9 @@ STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
  8970. }
  8971. return mp_const_true;
  8972. }
  8973. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
  8974. +static MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
  8975. -STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
  8976. +static mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
  8977. mp_obj_set_t *self;
  8978. bool cleanup_self = false;
  8979. if (is_set_or_frozenset(self_in)) {
  8980. @@ -327,25 +327,25 @@ STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool
  8981. return out;
  8982. }
  8983. -STATIC mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
  8984. +static mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
  8985. return set_issubset_internal(self_in, other_in, false);
  8986. }
  8987. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
  8988. +static MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
  8989. -STATIC mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
  8990. +static mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
  8991. return set_issubset_internal(self_in, other_in, true);
  8992. }
  8993. -STATIC mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
  8994. +static mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
  8995. return set_issubset_internal(other_in, self_in, false);
  8996. }
  8997. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
  8998. +static MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
  8999. -STATIC mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
  9000. +static mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
  9001. return set_issubset_internal(other_in, self_in, true);
  9002. }
  9003. -STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
  9004. +static mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
  9005. assert(is_set_or_frozenset(other_in));
  9006. check_set_or_frozenset(self_in);
  9007. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  9008. @@ -356,7 +356,7 @@ STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
  9009. return set_issubset(self_in, other_in);
  9010. }
  9011. -STATIC mp_obj_t set_pop(mp_obj_t self_in) {
  9012. +static mp_obj_t set_pop(mp_obj_t self_in) {
  9013. check_set(self_in);
  9014. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  9015. mp_obj_t obj = mp_set_remove_first(&self->set);
  9016. @@ -365,9 +365,9 @@ STATIC mp_obj_t set_pop(mp_obj_t self_in) {
  9017. }
  9018. return obj;
  9019. }
  9020. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
  9021. +static MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
  9022. -STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
  9023. +static mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
  9024. check_set(self_in);
  9025. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  9026. if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) {
  9027. @@ -375,9 +375,9 @@ STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
  9028. }
  9029. return mp_const_none;
  9030. }
  9031. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
  9032. +static MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
  9033. -STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
  9034. +static mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
  9035. check_set_or_frozenset(self_in); // can be frozenset due to call from set_symmetric_difference
  9036. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  9037. mp_obj_t iter = mp_getiter(other_in, NULL);
  9038. @@ -387,16 +387,16 @@ STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other
  9039. }
  9040. return mp_const_none;
  9041. }
  9042. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
  9043. +static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
  9044. -STATIC mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
  9045. +static mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
  9046. mp_obj_t self_out = set_copy(self_in);
  9047. set_symmetric_difference_update(self_out, other_in);
  9048. return self_out;
  9049. }
  9050. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
  9051. +static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
  9052. -STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
  9053. +static void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
  9054. mp_obj_t iter = mp_getiter(other_in, NULL);
  9055. mp_obj_t next;
  9056. while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
  9057. @@ -404,7 +404,7 @@ STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
  9058. }
  9059. }
  9060. -STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
  9061. +static mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
  9062. check_set(args[0]);
  9063. for (size_t i = 1; i < n_args; i++) {
  9064. set_update_int(MP_OBJ_TO_PTR(args[0]), args[i]);
  9065. @@ -412,17 +412,17 @@ STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
  9066. return mp_const_none;
  9067. }
  9068. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
  9069. +static MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
  9070. -STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
  9071. +static mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
  9072. check_set_or_frozenset(self_in);
  9073. mp_obj_t self = set_copy(self_in);
  9074. set_update_int(MP_OBJ_TO_PTR(self), other_in);
  9075. return self;
  9076. }
  9077. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
  9078. +static MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
  9079. -STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9080. +static mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9081. mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
  9082. switch (op) {
  9083. case MP_UNARY_OP_BOOL:
  9084. @@ -451,7 +451,7 @@ STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9085. }
  9086. }
  9087. -STATIC mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
  9088. +static mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
  9089. mp_obj_t args[] = {lhs, rhs};
  9090. #if MICROPY_PY_BUILTINS_FROZENSET
  9091. bool update = mp_obj_is_type(lhs, &mp_type_set);
  9092. @@ -517,7 +517,7 @@ STATIC mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
  9093. /******************************************************************************/
  9094. /* set constructors & public C API */
  9095. -STATIC const mp_rom_map_elem_t set_locals_dict_table[] = {
  9096. +static const mp_rom_map_elem_t set_locals_dict_table[] = {
  9097. { MP_ROM_QSTR(MP_QSTR_add), MP_ROM_PTR(&set_add_obj) },
  9098. { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&set_clear_obj) },
  9099. { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) },
  9100. @@ -537,7 +537,7 @@ STATIC const mp_rom_map_elem_t set_locals_dict_table[] = {
  9101. { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&set_update_obj) },
  9102. { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) },
  9103. };
  9104. -STATIC MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table);
  9105. +static MP_DEFINE_CONST_DICT(set_locals_dict, set_locals_dict_table);
  9106. MP_DEFINE_CONST_OBJ_TYPE(
  9107. mp_type_set,
  9108. @@ -552,7 +552,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  9109. );
  9110. #if MICROPY_PY_BUILTINS_FROZENSET
  9111. -STATIC const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
  9112. +static const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
  9113. { MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&set_copy_obj) },
  9114. { MP_ROM_QSTR(MP_QSTR_difference), MP_ROM_PTR(&set_diff_obj) },
  9115. { MP_ROM_QSTR(MP_QSTR_intersection), MP_ROM_PTR(&set_intersect_obj) },
  9116. @@ -563,7 +563,7 @@ STATIC const mp_rom_map_elem_t frozenset_locals_dict_table[] = {
  9117. { MP_ROM_QSTR(MP_QSTR_union), MP_ROM_PTR(&set_union_obj) },
  9118. { MP_ROM_QSTR(MP_QSTR___contains__), MP_ROM_PTR(&mp_op_contains_obj) },
  9119. };
  9120. -STATIC MP_DEFINE_CONST_DICT(frozenset_locals_dict, frozenset_locals_dict_table);
  9121. +static MP_DEFINE_CONST_DICT(frozenset_locals_dict, frozenset_locals_dict_table);
  9122. MP_DEFINE_CONST_OBJ_TYPE(
  9123. mp_type_frozenset,
  9124. diff --git a/py/objsingleton.c b/py/objsingleton.c
  9125. index 6537676c5..c1f102c94 100644
  9126. --- a/py/objsingleton.c
  9127. +++ b/py/objsingleton.c
  9128. @@ -37,7 +37,7 @@ typedef struct _mp_obj_singleton_t {
  9129. qstr name;
  9130. } mp_obj_singleton_t;
  9131. -STATIC void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9132. +static void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9133. (void)kind;
  9134. mp_obj_singleton_t *self = MP_OBJ_TO_PTR(self_in);
  9135. mp_printf(print, "%q", self->name);
  9136. diff --git a/py/objslice.c b/py/objslice.c
  9137. index dcd6af8b2..3e7575522 100644
  9138. --- a/py/objslice.c
  9139. +++ b/py/objslice.c
  9140. @@ -34,7 +34,7 @@
  9141. #if MICROPY_PY_BUILTINS_SLICE
  9142. -STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  9143. +static void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  9144. (void)kind;
  9145. mp_obj_slice_t *o = MP_OBJ_TO_PTR(o_in);
  9146. mp_print_str(print, "slice(");
  9147. @@ -46,14 +46,14 @@ STATIC void slice_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
  9148. mp_print_str(print, ")");
  9149. }
  9150. -STATIC mp_obj_t slice_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  9151. +static mp_obj_t slice_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
  9152. // Needed to explicitly opt out of default __hash__.
  9153. // REVISIT: CPython implements comparison operators for slice.
  9154. return MP_OBJ_NULL;
  9155. }
  9156. #if MICROPY_PY_BUILTINS_SLICE_INDICES
  9157. -STATIC mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
  9158. +static mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
  9159. mp_int_t length = mp_obj_get_int(length_obj);
  9160. mp_bound_slice_t bound_indices;
  9161. mp_obj_slice_indices(self_in, length, &bound_indices);
  9162. @@ -65,11 +65,11 @@ STATIC mp_obj_t slice_indices(mp_obj_t self_in, mp_obj_t length_obj) {
  9163. };
  9164. return mp_obj_new_tuple(3, results);
  9165. }
  9166. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(slice_indices_obj, slice_indices);
  9167. +static MP_DEFINE_CONST_FUN_OBJ_2(slice_indices_obj, slice_indices);
  9168. #endif
  9169. #if MICROPY_PY_BUILTINS_SLICE_ATTRS
  9170. -STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9171. +static void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9172. if (dest[0] != MP_OBJ_NULL) {
  9173. // not load attribute
  9174. return;
  9175. @@ -92,10 +92,10 @@ STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9176. #endif
  9177. #if MICROPY_PY_BUILTINS_SLICE_INDICES && !MICROPY_PY_BUILTINS_SLICE_ATTRS
  9178. -STATIC const mp_rom_map_elem_t slice_locals_dict_table[] = {
  9179. +static const mp_rom_map_elem_t slice_locals_dict_table[] = {
  9180. { MP_ROM_QSTR(MP_QSTR_indices), MP_ROM_PTR(&slice_indices_obj) },
  9181. };
  9182. -STATIC MP_DEFINE_CONST_DICT(slice_locals_dict, slice_locals_dict_table);
  9183. +static MP_DEFINE_CONST_DICT(slice_locals_dict, slice_locals_dict_table);
  9184. #endif
  9185. #if MICROPY_PY_BUILTINS_SLICE_ATTRS
  9186. diff --git a/py/objstr.c b/py/objstr.c
  9187. index 5dfe94ac4..c7e4ebf53 100644
  9188. --- a/py/objstr.c
  9189. +++ b/py/objstr.c
  9190. @@ -35,15 +35,15 @@
  9191. #include "py/stackctrl.h"
  9192. #if MICROPY_PY_BUILTINS_STR_OP_MODULO
  9193. -STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
  9194. +static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict);
  9195. #endif
  9196. -STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
  9197. -STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in);
  9198. +static mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
  9199. +static NORETURN void bad_implicit_conversion(mp_obj_t self_in);
  9200. -STATIC mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
  9201. +static mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
  9202. -STATIC void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t arg) {
  9203. +static void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t arg) {
  9204. // String operations generally need the args type to match the object they're called on,
  9205. // e.g. str.find(str), byte.startswith(byte)
  9206. // with the exception that bytes may be used for bytearray and vice versa.
  9207. @@ -63,7 +63,7 @@ STATIC void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t ar
  9208. }
  9209. }
  9210. -STATIC void check_is_str_or_bytes(mp_obj_t self_in) {
  9211. +static void check_is_str_or_bytes(mp_obj_t self_in) {
  9212. mp_check_self(mp_obj_is_str_or_bytes(self_in));
  9213. }
  9214. @@ -135,7 +135,7 @@ void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str
  9215. }
  9216. #endif
  9217. -STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9218. +static void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9219. GET_STR_DATA_LEN(self_in, str_data, str_len);
  9220. #if MICROPY_PY_JSON
  9221. if (kind == PRINT_JSON) {
  9222. @@ -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_
  9223. }
  9224. }
  9225. -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) {
  9226. +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) {
  9227. (void)type_in;
  9228. #if MICROPY_CPYTHON_COMPAT
  9229. @@ -458,7 +458,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
  9230. #endif
  9231. // This is used for both bytes and 8-bit strings. This is not used for unicode strings.
  9232. -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9233. +static mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9234. const mp_obj_type_t *type = mp_obj_get_type(self_in);
  9235. GET_STR_DATA_LEN(self_in, self_data, self_len);
  9236. if (value == MP_OBJ_SENTINEL) {
  9237. @@ -484,7 +484,7 @@ STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9238. }
  9239. }
  9240. -STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
  9241. +static mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
  9242. check_is_str_or_bytes(self_in);
  9243. const mp_obj_type_t *self_type = mp_obj_get_type(self_in);
  9244. const mp_obj_type_t *ret_type = self_type;
  9245. @@ -628,7 +628,7 @@ mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) {
  9246. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, mp_obj_str_split);
  9247. #if MICROPY_PY_BUILTINS_STR_SPLITLINES
  9248. -STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  9249. +static mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  9250. enum { ARG_keepends };
  9251. static const mp_arg_t allowed_args[] = {
  9252. { MP_QSTR_keepends, MP_ARG_BOOL, {.u_bool = false} },
  9253. @@ -674,7 +674,7 @@ STATIC mp_obj_t str_splitlines(size_t n_args, const mp_obj_t *pos_args, mp_map_t
  9254. MP_DEFINE_CONST_FUN_OBJ_KW(str_splitlines_obj, 1, str_splitlines);
  9255. #endif
  9256. -STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
  9257. +static mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
  9258. if (n_args < 3) {
  9259. // If we don't have split limit, it doesn't matter from which side
  9260. // we split.
  9261. @@ -739,7 +739,7 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
  9262. }
  9263. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj, 1, 3, str_rsplit);
  9264. -STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) {
  9265. +static mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) {
  9266. const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
  9267. check_is_str_or_bytes(args[0]);
  9268. @@ -782,28 +782,28 @@ STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, b
  9269. }
  9270. }
  9271. -STATIC mp_obj_t str_find(size_t n_args, const mp_obj_t *args) {
  9272. +static mp_obj_t str_find(size_t n_args, const mp_obj_t *args) {
  9273. return str_finder(n_args, args, 1, false);
  9274. }
  9275. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj, 2, 4, str_find);
  9276. -STATIC mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) {
  9277. +static mp_obj_t str_rfind(size_t n_args, const mp_obj_t *args) {
  9278. return str_finder(n_args, args, -1, false);
  9279. }
  9280. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rfind_obj, 2, 4, str_rfind);
  9281. -STATIC mp_obj_t str_index(size_t n_args, const mp_obj_t *args) {
  9282. +static mp_obj_t str_index(size_t n_args, const mp_obj_t *args) {
  9283. return str_finder(n_args, args, 1, true);
  9284. }
  9285. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_index_obj, 2, 4, str_index);
  9286. -STATIC mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) {
  9287. +static mp_obj_t str_rindex(size_t n_args, const mp_obj_t *args) {
  9288. return str_finder(n_args, args, -1, true);
  9289. }
  9290. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rindex_obj, 2, 4, str_rindex);
  9291. // TODO: (Much) more variety in args
  9292. -STATIC mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
  9293. +static mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
  9294. const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
  9295. GET_STR_DATA_LEN(args[0], str, str_len);
  9296. size_t prefix_len;
  9297. @@ -819,7 +819,7 @@ STATIC mp_obj_t str_startswith(size_t n_args, const mp_obj_t *args) {
  9298. }
  9299. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_startswith_obj, 2, 3, str_startswith);
  9300. -STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
  9301. +static mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) {
  9302. GET_STR_DATA_LEN(args[0], str, str_len);
  9303. size_t suffix_len;
  9304. const char *suffix = mp_obj_str_get_data(args[1], &suffix_len);
  9305. @@ -836,7 +836,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj, 2, 3, str_endswith);
  9306. enum { LSTRIP, RSTRIP, STRIP };
  9307. -STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
  9308. +static mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
  9309. check_is_str_or_bytes(args[0]);
  9310. const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
  9311. @@ -905,23 +905,23 @@ STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
  9312. return mp_obj_new_str_of_type(self_type, orig_str + first_good_char_pos, stripped_len);
  9313. }
  9314. -STATIC mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) {
  9315. +static mp_obj_t str_strip(size_t n_args, const mp_obj_t *args) {
  9316. return str_uni_strip(STRIP, n_args, args);
  9317. }
  9318. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj, 1, 2, str_strip);
  9319. -STATIC mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) {
  9320. +static mp_obj_t str_lstrip(size_t n_args, const mp_obj_t *args) {
  9321. return str_uni_strip(LSTRIP, n_args, args);
  9322. }
  9323. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_lstrip_obj, 1, 2, str_lstrip);
  9324. -STATIC mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) {
  9325. +static mp_obj_t str_rstrip(size_t n_args, const mp_obj_t *args) {
  9326. return str_uni_strip(RSTRIP, n_args, args);
  9327. }
  9328. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rstrip_obj, 1, 2, str_rstrip);
  9329. #if MICROPY_PY_BUILTINS_STR_CENTER
  9330. -STATIC mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) {
  9331. +static mp_obj_t str_center(mp_obj_t str_in, mp_obj_t width_in) {
  9332. GET_STR_DATA_LEN(str_in, str, str_len);
  9333. mp_uint_t width = mp_obj_get_int(width_in);
  9334. if (str_len >= width) {
  9335. @@ -940,7 +940,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(str_center_obj, str_center);
  9336. // Takes an int arg, but only parses unsigned numbers, and only changes
  9337. // *num if at least one digit was parsed.
  9338. -STATIC const char *str_to_int(const char *str, const char *top, int *num) {
  9339. +static const char *str_to_int(const char *str, const char *top, int *num) {
  9340. if (str < top && '0' <= *str && *str <= '9') {
  9341. *num = 0;
  9342. do {
  9343. @@ -952,19 +952,19 @@ STATIC const char *str_to_int(const char *str, const char *top, int *num) {
  9344. return str;
  9345. }
  9346. -STATIC bool isalignment(char ch) {
  9347. +static bool isalignment(char ch) {
  9348. return ch && strchr("<>=^", ch) != NULL;
  9349. }
  9350. -STATIC bool istype(char ch) {
  9351. +static bool istype(char ch) {
  9352. return ch && strchr("bcdeEfFgGnosxX%", ch) != NULL;
  9353. }
  9354. -STATIC bool arg_looks_integer(mp_obj_t arg) {
  9355. +static bool arg_looks_integer(mp_obj_t arg) {
  9356. return mp_obj_is_bool(arg) || mp_obj_is_int(arg);
  9357. }
  9358. -STATIC bool arg_looks_numeric(mp_obj_t arg) {
  9359. +static bool arg_looks_numeric(mp_obj_t arg) {
  9360. return arg_looks_integer(arg)
  9361. #if MICROPY_PY_BUILTINS_FLOAT
  9362. || mp_obj_is_float(arg)
  9363. @@ -973,7 +973,7 @@ STATIC bool arg_looks_numeric(mp_obj_t arg) {
  9364. }
  9365. #if MICROPY_PY_BUILTINS_STR_OP_MODULO
  9366. -STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
  9367. +static mp_obj_t arg_as_int(mp_obj_t arg) {
  9368. #if MICROPY_PY_BUILTINS_FLOAT
  9369. if (mp_obj_is_float(arg)) {
  9370. return mp_obj_new_int_from_float(mp_obj_float_get(arg));
  9371. @@ -984,7 +984,7 @@ STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
  9372. #endif
  9373. #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
  9374. -STATIC NORETURN void terse_str_format_value_error(void) {
  9375. +static NORETURN void terse_str_format_value_error(void) {
  9376. mp_raise_ValueError(MP_ERROR_TEXT("bad format string"));
  9377. }
  9378. #else
  9379. @@ -992,7 +992,7 @@ STATIC NORETURN void terse_str_format_value_error(void) {
  9380. #define terse_str_format_value_error()
  9381. #endif
  9382. -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) {
  9383. +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) {
  9384. vstr_t vstr;
  9385. mp_print_t print;
  9386. vstr_init_print(&vstr, 16, &print);
  9387. @@ -1449,7 +1449,7 @@ mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
  9388. MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format);
  9389. #if MICROPY_PY_BUILTINS_STR_OP_MODULO
  9390. -STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) {
  9391. +static mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict) {
  9392. check_is_str_or_bytes(pattern);
  9393. GET_STR_DATA_LEN(pattern, str, len);
  9394. @@ -1657,7 +1657,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
  9395. // The implementation is optimized, returning the original string if there's
  9396. // nothing to replace.
  9397. -STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
  9398. +static mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
  9399. check_is_str_or_bytes(args[0]);
  9400. mp_int_t max_rep = -1;
  9401. @@ -1759,7 +1759,7 @@ STATIC mp_obj_t str_replace(size_t n_args, const mp_obj_t *args) {
  9402. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace);
  9403. #if MICROPY_PY_BUILTINS_STR_COUNT
  9404. -STATIC mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
  9405. +static mp_obj_t str_count(size_t n_args, const mp_obj_t *args) {
  9406. const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
  9407. check_is_str_or_bytes(args[0]);
  9408. @@ -1802,7 +1802,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj, 2, 4, str_count);
  9409. #endif
  9410. #if MICROPY_PY_BUILTINS_STR_PARTITION
  9411. -STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
  9412. +static mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
  9413. check_is_str_or_bytes(self_in);
  9414. const mp_obj_type_t *self_type = mp_obj_get_type(self_in);
  9415. str_check_arg_type(self_type, arg);
  9416. @@ -1848,19 +1848,19 @@ STATIC mp_obj_t str_partitioner(mp_obj_t self_in, mp_obj_t arg, int direction) {
  9417. return mp_obj_new_tuple(3, result);
  9418. }
  9419. -STATIC mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) {
  9420. +static mp_obj_t str_partition(mp_obj_t self_in, mp_obj_t arg) {
  9421. return str_partitioner(self_in, arg, 1);
  9422. }
  9423. MP_DEFINE_CONST_FUN_OBJ_2(str_partition_obj, str_partition);
  9424. -STATIC mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) {
  9425. +static mp_obj_t str_rpartition(mp_obj_t self_in, mp_obj_t arg) {
  9426. return str_partitioner(self_in, arg, -1);
  9427. }
  9428. MP_DEFINE_CONST_FUN_OBJ_2(str_rpartition_obj, str_rpartition);
  9429. #endif
  9430. // Supposedly not too critical operations, so optimize for code size
  9431. -STATIC mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
  9432. +static mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
  9433. GET_STR_DATA_LEN(self_in, self_data, self_len);
  9434. vstr_t vstr;
  9435. vstr_init_len(&vstr, self_len);
  9436. @@ -1871,17 +1871,17 @@ STATIC mp_obj_t str_caseconv(unichar (*op)(unichar), mp_obj_t self_in) {
  9437. return mp_obj_new_str_type_from_vstr(mp_obj_get_type(self_in), &vstr);
  9438. }
  9439. -STATIC mp_obj_t str_lower(mp_obj_t self_in) {
  9440. +static mp_obj_t str_lower(mp_obj_t self_in) {
  9441. return str_caseconv(unichar_tolower, self_in);
  9442. }
  9443. MP_DEFINE_CONST_FUN_OBJ_1(str_lower_obj, str_lower);
  9444. -STATIC mp_obj_t str_upper(mp_obj_t self_in) {
  9445. +static mp_obj_t str_upper(mp_obj_t self_in) {
  9446. return str_caseconv(unichar_toupper, self_in);
  9447. }
  9448. MP_DEFINE_CONST_FUN_OBJ_1(str_upper_obj, str_upper);
  9449. -STATIC mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
  9450. +static mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
  9451. GET_STR_DATA_LEN(self_in, self_data, self_len);
  9452. if (self_len == 0) {
  9453. @@ -1914,27 +1914,27 @@ STATIC mp_obj_t str_uni_istype(bool (*f)(unichar), mp_obj_t self_in) {
  9454. return mp_const_true;
  9455. }
  9456. -STATIC mp_obj_t str_isspace(mp_obj_t self_in) {
  9457. +static mp_obj_t str_isspace(mp_obj_t self_in) {
  9458. return str_uni_istype(unichar_isspace, self_in);
  9459. }
  9460. MP_DEFINE_CONST_FUN_OBJ_1(str_isspace_obj, str_isspace);
  9461. -STATIC mp_obj_t str_isalpha(mp_obj_t self_in) {
  9462. +static mp_obj_t str_isalpha(mp_obj_t self_in) {
  9463. return str_uni_istype(unichar_isalpha, self_in);
  9464. }
  9465. MP_DEFINE_CONST_FUN_OBJ_1(str_isalpha_obj, str_isalpha);
  9466. -STATIC mp_obj_t str_isdigit(mp_obj_t self_in) {
  9467. +static mp_obj_t str_isdigit(mp_obj_t self_in) {
  9468. return str_uni_istype(unichar_isdigit, self_in);
  9469. }
  9470. MP_DEFINE_CONST_FUN_OBJ_1(str_isdigit_obj, str_isdigit);
  9471. -STATIC mp_obj_t str_isupper(mp_obj_t self_in) {
  9472. +static mp_obj_t str_isupper(mp_obj_t self_in) {
  9473. return str_uni_istype(unichar_isupper, self_in);
  9474. }
  9475. MP_DEFINE_CONST_FUN_OBJ_1(str_isupper_obj, str_isupper);
  9476. -STATIC mp_obj_t str_islower(mp_obj_t self_in) {
  9477. +static mp_obj_t str_islower(mp_obj_t self_in) {
  9478. return str_uni_istype(unichar_islower, self_in);
  9479. }
  9480. MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower);
  9481. @@ -1943,7 +1943,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(str_islower_obj, str_islower);
  9482. // These methods are superfluous in the presence of str() and bytes()
  9483. // constructors.
  9484. // TODO: should accept kwargs too
  9485. -STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
  9486. +static mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
  9487. mp_obj_t new_args[2];
  9488. if (n_args == 1) {
  9489. new_args[0] = args[0];
  9490. @@ -1956,7 +1956,7 @@ STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
  9491. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj, 1, 3, bytes_decode);
  9492. // TODO: should accept kwargs too
  9493. -STATIC mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) {
  9494. +static mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) {
  9495. mp_obj_t new_args[2];
  9496. if (n_args == 1) {
  9497. new_args[0] = args[0];
  9498. @@ -2038,13 +2038,13 @@ mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data) {
  9499. return mp_obj_new_str_type_from_vstr(MP_OBJ_TO_PTR(type_in), &vstr);
  9500. }
  9501. -STATIC mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) {
  9502. +static mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) {
  9503. return mp_obj_bytes_hex(n_args, args, &mp_type_str);
  9504. }
  9505. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str);
  9506. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str);
  9507. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex);
  9508. -STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj));
  9509. +static MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex);
  9510. +static MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj));
  9511. #endif // MICROPY_PY_BUILTINS_BYTES_HEX
  9512. mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
  9513. @@ -2068,7 +2068,7 @@ void mp_obj_str_set_data(mp_obj_str_t *str, const byte *data, size_t len) {
  9514. // This locals table is used for the following types: str, bytes, bytearray, array.array.
  9515. // Each type takes a different section (start to end offset) of this table.
  9516. -STATIC const mp_rom_map_elem_t array_bytearray_str_bytes_locals_table[] = {
  9517. +static const mp_rom_map_elem_t array_bytearray_str_bytes_locals_table[] = {
  9518. #if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY
  9519. { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&mp_obj_array_append_obj) },
  9520. { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&mp_obj_array_extend_obj) },
  9521. @@ -2168,7 +2168,7 @@ MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict,
  9522. #endif
  9523. #if !MICROPY_PY_BUILTINS_STR_UNICODE
  9524. -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
  9525. +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
  9526. MP_DEFINE_CONST_OBJ_TYPE(
  9527. mp_type_str,
  9528. @@ -2240,7 +2240,7 @@ mp_obj_t mp_obj_new_str_via_qstr(const char *data, size_t len) {
  9529. // Create a str/bytes object from the given vstr. The vstr buffer is resized to
  9530. // the exact length required and then reused for the str/bytes object. The vstr
  9531. // is cleared and can safely be passed to vstr_free if it was heap allocated.
  9532. -STATIC mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) {
  9533. +static mp_obj_t mp_obj_new_str_type_from_vstr(const mp_obj_type_t *type, vstr_t *vstr) {
  9534. // if not a bytes object, look if a qstr with this data already exists
  9535. if (type == &mp_type_str) {
  9536. qstr q = qstr_find_strn(vstr->buf, vstr->len);
  9537. @@ -2342,7 +2342,7 @@ bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) {
  9538. }
  9539. }
  9540. -STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
  9541. +static NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
  9542. #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
  9543. mp_raise_TypeError(MP_ERROR_TEXT("can't convert to str implicitly"));
  9544. #else
  9545. @@ -2411,7 +2411,7 @@ typedef struct _mp_obj_str8_it_t {
  9546. } mp_obj_str8_it_t;
  9547. #if !MICROPY_PY_BUILTINS_STR_UNICODE
  9548. -STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
  9549. +static mp_obj_t str_it_iternext(mp_obj_t self_in) {
  9550. mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
  9551. GET_STR_DATA_LEN(self->str, str, len);
  9552. if (self->cur < len) {
  9553. @@ -2423,7 +2423,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
  9554. }
  9555. }
  9556. -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
  9557. +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
  9558. assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t));
  9559. mp_obj_str8_it_t *o = (mp_obj_str8_it_t *)iter_buf;
  9560. o->base.type = &mp_type_polymorph_iter;
  9561. @@ -2434,7 +2434,7 @@ STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_bu
  9562. }
  9563. #endif
  9564. -STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
  9565. +static mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
  9566. mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
  9567. GET_STR_DATA_LEN(self->str, str, len);
  9568. if (self->cur < len) {
  9569. diff --git a/py/objstr.h b/py/objstr.h
  9570. index 72fe1cfef..028fc9597 100644
  9571. --- a/py/objstr.h
  9572. +++ b/py/objstr.h
  9573. @@ -100,6 +100,8 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
  9574. mp_obj_t index, bool is_slice);
  9575. const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction);
  9576. +#define MP_DEFINE_BYTES_OBJ(obj_name, target, len) mp_obj_str_t obj_name = {{&mp_type_bytes}, 0, (len), (const byte *)(target)}
  9577. +
  9578. mp_obj_t mp_obj_bytes_hex(size_t n_args, const mp_obj_t *args, const mp_obj_type_t *type);
  9579. mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data);
  9580. diff --git a/py/objstringio.c b/py/objstringio.c
  9581. index a3c66ed01..a4dc8cfc9 100644
  9582. --- a/py/objstringio.c
  9583. +++ b/py/objstringio.c
  9584. @@ -36,7 +36,7 @@
  9585. #if MICROPY_PY_IO
  9586. #if MICROPY_CPYTHON_COMPAT
  9587. -STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) {
  9588. +static void check_stringio_is_open(const mp_obj_stringio_t *o) {
  9589. if (o->vstr == NULL) {
  9590. mp_raise_ValueError(MP_ERROR_TEXT("I/O operation on closed file"));
  9591. }
  9592. @@ -45,13 +45,13 @@ STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) {
  9593. #define check_stringio_is_open(o)
  9594. #endif
  9595. -STATIC void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9596. +static void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9597. (void)kind;
  9598. mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in);
  9599. mp_printf(print, self->base.type == &mp_type_stringio ? "<io.StringIO 0x%x>" : "<io.BytesIO 0x%x>", self);
  9600. }
  9601. -STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
  9602. +static mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
  9603. (void)errcode;
  9604. mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
  9605. check_stringio_is_open(o);
  9606. @@ -67,7 +67,7 @@ STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
  9607. return size;
  9608. }
  9609. -STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
  9610. +static void stringio_copy_on_write(mp_obj_stringio_t *o) {
  9611. const void *buf = o->vstr->buf;
  9612. o->vstr->buf = m_new(char, o->vstr->len);
  9613. o->vstr->fixed_buf = false;
  9614. @@ -75,7 +75,7 @@ STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
  9615. memcpy(o->vstr->buf, buf, o->vstr->len);
  9616. }
  9617. -STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
  9618. +static mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
  9619. (void)errcode;
  9620. mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
  9621. check_stringio_is_open(o);
  9622. @@ -109,7 +109,7 @@ STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size,
  9623. return size;
  9624. }
  9625. -STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
  9626. +static mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
  9627. (void)errcode;
  9628. mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
  9629. switch (request) {
  9630. @@ -162,22 +162,22 @@ STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg,
  9631. #define STREAM_TO_CONTENT_TYPE(o) (((o)->base.type == &mp_type_stringio) ? &mp_type_str : &mp_type_bytes)
  9632. -STATIC mp_obj_t stringio_getvalue(mp_obj_t self_in) {
  9633. +static mp_obj_t stringio_getvalue(mp_obj_t self_in) {
  9634. mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in);
  9635. check_stringio_is_open(self);
  9636. // TODO: Try to avoid copying string
  9637. return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte *)self->vstr->buf, self->vstr->len);
  9638. }
  9639. -STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue);
  9640. +static MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue);
  9641. -STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
  9642. +static mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
  9643. mp_obj_stringio_t *o = mp_obj_malloc(mp_obj_stringio_t, type);
  9644. o->pos = 0;
  9645. o->ref_obj = MP_OBJ_NULL;
  9646. return o;
  9647. }
  9648. -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) {
  9649. +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) {
  9650. (void)n_kw; // TODO check n_kw==0
  9651. mp_uint_t sz = 16;
  9652. @@ -215,7 +215,7 @@ STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, s
  9653. return MP_OBJ_FROM_PTR(o);
  9654. }
  9655. -STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = {
  9656. +static const mp_rom_map_elem_t stringio_locals_dict_table[] = {
  9657. { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
  9658. { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
  9659. { MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
  9660. @@ -229,9 +229,9 @@ STATIC const mp_rom_map_elem_t stringio_locals_dict_table[] = {
  9661. { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&mp_stream___exit___obj) },
  9662. };
  9663. -STATIC MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table);
  9664. +static MP_DEFINE_CONST_DICT(stringio_locals_dict, stringio_locals_dict_table);
  9665. -STATIC const mp_stream_p_t stringio_stream_p = {
  9666. +static const mp_stream_p_t stringio_stream_p = {
  9667. .read = stringio_read,
  9668. .write = stringio_write,
  9669. .ioctl = stringio_ioctl,
  9670. @@ -249,7 +249,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
  9671. );
  9672. #if MICROPY_PY_IO_BYTESIO
  9673. -STATIC const mp_stream_p_t bytesio_stream_p = {
  9674. +static const mp_stream_p_t bytesio_stream_p = {
  9675. .read = stringio_read,
  9676. .write = stringio_write,
  9677. .ioctl = stringio_ioctl,
  9678. diff --git a/py/objstrunicode.c b/py/objstrunicode.c
  9679. index cbc797de2..d7ce4fca0 100644
  9680. --- a/py/objstrunicode.c
  9681. +++ b/py/objstrunicode.c
  9682. @@ -34,12 +34,12 @@
  9683. #if MICROPY_PY_BUILTINS_STR_UNICODE
  9684. -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
  9685. +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf);
  9686. /******************************************************************************/
  9687. /* str */
  9688. -STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
  9689. +static void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint str_len) {
  9690. // this escapes characters, but it will be very slow to print (calling print many times)
  9691. bool has_single_quote = false;
  9692. bool has_double_quote = false;
  9693. @@ -83,7 +83,7 @@ STATIC void uni_print_quoted(const mp_print_t *print, const byte *str_data, uint
  9694. mp_printf(print, "%c", quote_char);
  9695. }
  9696. -STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9697. +static void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9698. GET_STR_DATA_LEN(self_in, str_data, str_len);
  9699. #if MICROPY_PY_JSON
  9700. if (kind == PRINT_JSON) {
  9701. @@ -98,7 +98,7 @@ STATIC void uni_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
  9702. }
  9703. }
  9704. -STATIC mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9705. +static mp_obj_t uni_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9706. GET_STR_DATA_LEN(self_in, str_data, str_len);
  9707. switch (op) {
  9708. case MP_UNARY_OP_BOOL:
  9709. @@ -178,7 +178,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
  9710. return s;
  9711. }
  9712. -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9713. +static mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9714. const mp_obj_type_t *type = mp_obj_get_type(self_in);
  9715. assert(type == &mp_type_str);
  9716. GET_STR_DATA_LEN(self_in, self_data, self_len);
  9717. @@ -253,7 +253,7 @@ typedef struct _mp_obj_str_it_t {
  9718. size_t cur;
  9719. } mp_obj_str_it_t;
  9720. -STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
  9721. +static mp_obj_t str_it_iternext(mp_obj_t self_in) {
  9722. mp_obj_str_it_t *self = MP_OBJ_TO_PTR(self_in);
  9723. GET_STR_DATA_LEN(self->str, str, len);
  9724. if (self->cur < len) {
  9725. @@ -267,7 +267,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
  9726. }
  9727. }
  9728. -STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
  9729. +static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
  9730. assert(sizeof(mp_obj_str_it_t) <= sizeof(mp_obj_iter_buf_t));
  9731. mp_obj_str_it_t *o = (mp_obj_str_it_t *)iter_buf;
  9732. o->base.type = &mp_type_polymorph_iter;
  9733. diff --git a/py/objtuple.c b/py/objtuple.c
  9734. index 969c488ee..2cbcc0e50 100644
  9735. --- a/py/objtuple.c
  9736. +++ b/py/objtuple.c
  9737. @@ -65,7 +65,7 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
  9738. }
  9739. }
  9740. -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) {
  9741. +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) {
  9742. (void)type_in;
  9743. mp_arg_check_num(n_args, n_kw, 0, 1, false);
  9744. @@ -107,7 +107,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
  9745. }
  9746. // Don't pass MP_BINARY_OP_NOT_EQUAL here
  9747. -STATIC mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
  9748. +static mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
  9749. mp_check_self(mp_obj_is_tuple_compatible(self_in));
  9750. const mp_obj_type_t *another_type = mp_obj_get_type(another_in);
  9751. mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
  9752. @@ -203,26 +203,26 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9753. }
  9754. }
  9755. -STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
  9756. +static mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
  9757. mp_check_self(mp_obj_is_type(self_in, &mp_type_tuple));
  9758. mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
  9759. return mp_seq_count_obj(self->items, self->len, value);
  9760. }
  9761. -STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
  9762. +static MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
  9763. -STATIC mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
  9764. +static mp_obj_t tuple_index(size_t n_args, const mp_obj_t *args) {
  9765. mp_check_self(mp_obj_is_type(args[0], &mp_type_tuple));
  9766. mp_obj_tuple_t *self = MP_OBJ_TO_PTR(args[0]);
  9767. return mp_seq_index_obj(self->items, self->len, n_args, args);
  9768. }
  9769. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
  9770. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
  9771. -STATIC const mp_rom_map_elem_t tuple_locals_dict_table[] = {
  9772. +static const mp_rom_map_elem_t tuple_locals_dict_table[] = {
  9773. { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&tuple_count_obj) },
  9774. { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&tuple_index_obj) },
  9775. };
  9776. -STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
  9777. +static MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
  9778. MP_DEFINE_CONST_OBJ_TYPE(
  9779. mp_type_tuple,
  9780. @@ -244,7 +244,7 @@ mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items) {
  9781. if (n == 0) {
  9782. return mp_const_empty_tuple;
  9783. }
  9784. - mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, n, &mp_type_tuple);
  9785. + mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, n, &mp_type_tuple);
  9786. o->len = n;
  9787. if (items) {
  9788. for (size_t i = 0; i < n; i++) {
  9789. @@ -277,7 +277,7 @@ typedef struct _mp_obj_tuple_it_t {
  9790. size_t cur;
  9791. } mp_obj_tuple_it_t;
  9792. -STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
  9793. +static mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
  9794. mp_obj_tuple_it_t *self = MP_OBJ_TO_PTR(self_in);
  9795. if (self->cur < self->tuple->len) {
  9796. mp_obj_t o_out = self->tuple->items[self->cur];
  9797. diff --git a/py/objtype.c b/py/objtype.c
  9798. index d21c2a4b5..b6d600e94 100644
  9799. --- a/py/objtype.c
  9800. +++ b/py/objtype.c
  9801. @@ -44,12 +44,12 @@
  9802. #define ENABLE_SPECIAL_ACCESSORS \
  9803. (MICROPY_PY_DESCRIPTORS || MICROPY_PY_DELATTR_SETATTR || MICROPY_PY_BUILTINS_PROPERTY)
  9804. -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);
  9805. +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);
  9806. /******************************************************************************/
  9807. // instance object
  9808. -STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) {
  9809. +static int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_type_t **last_native_base) {
  9810. int count = 0;
  9811. for (;;) {
  9812. if (type == &mp_type_object) {
  9813. @@ -84,22 +84,22 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
  9814. // This wrapper function is allows a subclass of a native type to call the
  9815. // __init__() method (corresponding to type->make_new) of the native type.
  9816. -STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *args) {
  9817. +static mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *args) {
  9818. mp_obj_instance_t *self = MP_OBJ_TO_PTR(args[0]);
  9819. const mp_obj_type_t *native_base = NULL;
  9820. instance_count_native_bases(self->base.type, &native_base);
  9821. self->subobj[0] = MP_OBJ_TYPE_GET_SLOT(native_base, make_new)(native_base, n_args - 1, 0, args + 1);
  9822. return mp_const_none;
  9823. }
  9824. -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(native_base_init_wrapper_obj, 1, MP_OBJ_FUN_ARGS_MAX, native_base_init_wrapper);
  9825. +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(native_base_init_wrapper_obj, 1, MP_OBJ_FUN_ARGS_MAX, native_base_init_wrapper);
  9826. #if !MICROPY_CPYTHON_COMPAT
  9827. -STATIC
  9828. +static
  9829. #endif
  9830. mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *class, const mp_obj_type_t **native_base) {
  9831. size_t num_native_bases = instance_count_native_bases(class, native_base);
  9832. assert(num_native_bases < 2);
  9833. - mp_obj_instance_t *o = mp_obj_malloc_var(mp_obj_instance_t, mp_obj_t, num_native_bases, class);
  9834. + mp_obj_instance_t *o = mp_obj_malloc_var(mp_obj_instance_t, subobj, mp_obj_t, num_native_bases, class);
  9835. mp_map_init(&o->members, 0);
  9836. // Initialise the native base-class slot (should be 1 at most) with a valid
  9837. // object. It doesn't matter which object, so long as it can be uniquely
  9838. @@ -132,7 +132,7 @@ struct class_lookup_data {
  9839. bool is_type;
  9840. };
  9841. -STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) {
  9842. +static void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) {
  9843. assert(lookup->dest[0] == MP_OBJ_NULL);
  9844. assert(lookup->dest[1] == MP_OBJ_NULL);
  9845. for (;;) {
  9846. @@ -235,7 +235,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_t
  9847. }
  9848. }
  9849. -STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9850. +static void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9851. mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
  9852. qstr meth = (kind == PRINT_STR) ? MP_QSTR___str__ : MP_QSTR___repr__;
  9853. mp_obj_t member[2] = {MP_OBJ_NULL};
  9854. @@ -277,7 +277,7 @@ STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k
  9855. mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self);
  9856. }
  9857. -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) {
  9858. +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) {
  9859. assert(mp_obj_is_instance_type(self));
  9860. // look for __new__ function
  9861. @@ -370,6 +370,8 @@ STATIC mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_arg
  9862. // Qstrs for special methods are guaranteed to have a small value, so we use byte
  9863. // type to represent them.
  9864. +// The (unescaped) names appear in `unsorted_str_list` in the QSTR
  9865. +// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
  9866. const byte mp_unary_op_method_name[MP_UNARY_OP_NUM_RUNTIME] = {
  9867. [MP_UNARY_OP_BOOL] = MP_QSTR___bool__,
  9868. [MP_UNARY_OP_LEN] = MP_QSTR___len__,
  9869. @@ -392,7 +394,7 @@ const byte mp_unary_op_method_name[MP_UNARY_OP_NUM_RUNTIME] = {
  9870. #endif
  9871. };
  9872. -STATIC mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9873. +static mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9874. mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
  9875. #if MICROPY_PY_SYS_GETSIZEOF
  9876. @@ -468,6 +470,8 @@ STATIC mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
  9877. // fail). They can be added at the expense of code size for the qstr.
  9878. // Qstrs for special methods are guaranteed to have a small value, so we use byte
  9879. // type to represent them.
  9880. +// The (unescaped) names appear in `unsorted_str_list` in the QSTR
  9881. +// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
  9882. const byte mp_binary_op_method_name[MP_BINARY_OP_NUM_RUNTIME] = {
  9883. [MP_BINARY_OP_LESS] = MP_QSTR___lt__,
  9884. [MP_BINARY_OP_MORE] = MP_QSTR___gt__,
  9885. @@ -530,7 +534,7 @@ const byte mp_binary_op_method_name[MP_BINARY_OP_NUM_RUNTIME] = {
  9886. #endif
  9887. };
  9888. -STATIC mp_obj_t instance_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  9889. +static mp_obj_t instance_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
  9890. // Note: For ducktyping, CPython does not look in the instance members or use
  9891. // __getattr__ or __getattribute__. It only looks in the class dictionary.
  9892. mp_obj_instance_t *lhs = MP_OBJ_TO_PTR(lhs_in);
  9893. @@ -572,7 +576,7 @@ STATIC mp_obj_t instance_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t
  9894. return res;
  9895. }
  9896. -STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9897. +static void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9898. // logic: look in instance members then class locals
  9899. assert(mp_obj_is_instance_type(mp_obj_get_type(self_in)));
  9900. mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
  9901. @@ -669,7 +673,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
  9902. }
  9903. }
  9904. -STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
  9905. +static bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
  9906. mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
  9907. if (!(self->base.type->flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS)) {
  9908. @@ -792,7 +796,7 @@ skip_special_accessors:
  9909. }
  9910. }
  9911. -STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9912. +static void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9913. if (dest[0] == MP_OBJ_NULL) {
  9914. mp_obj_instance_load_attr(self_in, attr, dest);
  9915. } else {
  9916. @@ -802,7 +806,7 @@ STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9917. }
  9918. }
  9919. -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9920. +static mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
  9921. mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
  9922. mp_obj_t member[4] = {MP_OBJ_NULL, MP_OBJ_NULL, index, value};
  9923. struct class_lookup_data lookup = {
  9924. @@ -837,7 +841,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
  9925. }
  9926. }
  9927. -STATIC mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) {
  9928. +static mp_obj_t mp_obj_instance_get_call(mp_obj_t self_in, mp_obj_t *member) {
  9929. mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
  9930. struct class_lookup_data lookup = {
  9931. .obj = self,
  9932. @@ -903,7 +907,7 @@ mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf)
  9933. }
  9934. }
  9935. -STATIC mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
  9936. +static mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
  9937. mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
  9938. mp_obj_t member[2] = {MP_OBJ_NULL};
  9939. struct class_lookup_data lookup = {
  9940. @@ -929,7 +933,7 @@ STATIC mp_int_t instance_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo,
  9941. // - creating a new class (a new type) creates a new mp_obj_type_t
  9942. #if ENABLE_SPECIAL_ACCESSORS
  9943. -STATIC bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
  9944. +static bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
  9945. #if MICROPY_PY_DELATTR_SETATTR
  9946. if (key == MP_OBJ_NEW_QSTR(MP_QSTR___setattr__) || key == MP_OBJ_NEW_QSTR(MP_QSTR___delattr__)) {
  9947. return true;
  9948. @@ -956,13 +960,13 @@ STATIC bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
  9949. }
  9950. #endif
  9951. -STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9952. +static void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9953. (void)kind;
  9954. mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in);
  9955. mp_printf(print, "<class '%q'>", self->name);
  9956. }
  9957. -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) {
  9958. +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) {
  9959. (void)type_in;
  9960. mp_arg_check_num(n_args, n_kw, 1, 3, false);
  9961. @@ -982,7 +986,7 @@ STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_
  9962. }
  9963. }
  9964. -STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
  9965. +static mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
  9966. // instantiate an instance of a class
  9967. mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in);
  9968. @@ -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
  9969. return o;
  9970. }
  9971. -STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9972. +static void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9973. assert(mp_obj_is_type(self_in, &mp_type_type));
  9974. mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in);
  9975. @@ -1235,7 +1239,7 @@ typedef struct _mp_obj_super_t {
  9976. mp_obj_t obj;
  9977. } mp_obj_super_t;
  9978. -STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9979. +static void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
  9980. (void)kind;
  9981. mp_obj_super_t *self = MP_OBJ_TO_PTR(self_in);
  9982. mp_print_str(print, "<super: ");
  9983. @@ -1245,7 +1249,7 @@ STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind
  9984. mp_print_str(print, ">");
  9985. }
  9986. -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) {
  9987. +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) {
  9988. (void)type_in;
  9989. // 0 arguments are turned into 2 in the compiler
  9990. // 1 argument is not yet implemented
  9991. @@ -1258,7 +1262,7 @@ STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size
  9992. return MP_OBJ_FROM_PTR(o);
  9993. }
  9994. -STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9995. +static void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  9996. if (dest[0] != MP_OBJ_NULL) {
  9997. // not load attribute
  9998. return;
  9999. @@ -1386,7 +1390,7 @@ bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) {
  10000. }
  10001. }
  10002. -STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
  10003. +static mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
  10004. size_t len;
  10005. mp_obj_t *items;
  10006. if (mp_obj_is_type(classinfo, &mp_type_type)) {
  10007. @@ -1407,7 +1411,7 @@ STATIC mp_obj_t mp_obj_is_subclass(mp_obj_t object, mp_obj_t classinfo) {
  10008. return mp_const_false;
  10009. }
  10010. -STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
  10011. +static mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
  10012. if (!mp_obj_is_type(object, &mp_type_type)) {
  10013. mp_raise_TypeError(MP_ERROR_TEXT("issubclass() arg 1 must be a class"));
  10014. }
  10015. @@ -1416,7 +1420,7 @@ STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
  10016. MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_issubclass_obj, mp_builtin_issubclass);
  10017. -STATIC mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) {
  10018. +static mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) {
  10019. return mp_obj_is_subclass(MP_OBJ_FROM_PTR(mp_obj_get_type(object)), classinfo);
  10020. }
  10021. @@ -1438,7 +1442,7 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type
  10022. /******************************************************************************/
  10023. // staticmethod and classmethod types (probably should go in a different file)
  10024. -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) {
  10025. +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) {
  10026. assert(self == &mp_type_staticmethod || self == &mp_type_classmethod);
  10027. mp_arg_check_num(n_args, n_kw, 1, 1, false);
  10028. diff --git a/py/objzip.c b/py/objzip.c
  10029. index 3c3138180..dd2b39ee0 100644
  10030. --- a/py/objzip.c
  10031. +++ b/py/objzip.c
  10032. @@ -36,10 +36,10 @@ typedef struct _mp_obj_zip_t {
  10033. mp_obj_t iters[];
  10034. } mp_obj_zip_t;
  10035. -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) {
  10036. +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) {
  10037. mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false);
  10038. - mp_obj_zip_t *o = mp_obj_malloc_var(mp_obj_zip_t, mp_obj_t, n_args, type);
  10039. + mp_obj_zip_t *o = mp_obj_malloc_var(mp_obj_zip_t, iters, mp_obj_t, n_args, type);
  10040. o->n_iters = n_args;
  10041. for (size_t i = 0; i < n_args; i++) {
  10042. o->iters[i] = mp_getiter(args[i], NULL);
  10043. @@ -47,7 +47,7 @@ STATIC mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
  10044. return MP_OBJ_FROM_PTR(o);
  10045. }
  10046. -STATIC mp_obj_t zip_iternext(mp_obj_t self_in) {
  10047. +static mp_obj_t zip_iternext(mp_obj_t self_in) {
  10048. mp_check_self(mp_obj_is_type(self_in, &mp_type_zip));
  10049. mp_obj_zip_t *self = MP_OBJ_TO_PTR(self_in);
  10050. if (self->n_iters == 0) {
  10051. diff --git a/py/opmethods.c b/py/opmethods.c
  10052. index c3931fd35..32ab187b0 100644
  10053. --- a/py/opmethods.c
  10054. +++ b/py/opmethods.c
  10055. @@ -27,28 +27,28 @@
  10056. #include "py/obj.h"
  10057. #include "py/builtin.h"
  10058. -STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) {
  10059. +static mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) {
  10060. const mp_obj_type_t *type = mp_obj_get_type(self_in);
  10061. // Note: assumes type must have subscr (only used by dict).
  10062. return MP_OBJ_TYPE_GET_SLOT(type, subscr)(self_in, key_in, MP_OBJ_SENTINEL);
  10063. }
  10064. MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem);
  10065. -STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) {
  10066. +static mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) {
  10067. const mp_obj_type_t *type = mp_obj_get_type(self_in);
  10068. // Note: assumes type must have subscr (only used by dict).
  10069. return MP_OBJ_TYPE_GET_SLOT(type, subscr)(self_in, key_in, value_in);
  10070. }
  10071. MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem);
  10072. -STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) {
  10073. +static mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) {
  10074. const mp_obj_type_t *type = mp_obj_get_type(self_in);
  10075. // Note: assumes type must have subscr (only used by dict).
  10076. return MP_OBJ_TYPE_GET_SLOT(type, subscr)(self_in, key_in, MP_OBJ_NULL);
  10077. }
  10078. MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem);
  10079. -STATIC mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) {
  10080. +static mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) {
  10081. const mp_obj_type_t *type = mp_obj_get_type(lhs_in);
  10082. // Note: assumes type must have binary_op (only used by set/frozenset).
  10083. return MP_OBJ_TYPE_GET_SLOT(type, binary_op)(MP_BINARY_OP_CONTAINS, lhs_in, rhs_in);
  10084. diff --git a/py/parse.c b/py/parse.c
  10085. index e86103ed8..1392303e6 100644
  10086. --- a/py/parse.c
  10087. +++ b/py/parse.c
  10088. @@ -75,7 +75,7 @@ enum {
  10089. };
  10090. // Define an array of actions corresponding to each rule
  10091. -STATIC const uint8_t rule_act_table[] = {
  10092. +static const uint8_t rule_act_table[] = {
  10093. #define or(n) (RULE_ACT_OR | n)
  10094. #define and(n) (RULE_ACT_AND | n)
  10095. #define and_ident(n) (RULE_ACT_AND | n | RULE_ACT_ALLOW_IDENT)
  10096. @@ -108,7 +108,7 @@ STATIC const uint8_t rule_act_table[] = {
  10097. };
  10098. // Define the argument data for each rule, as a combined array
  10099. -STATIC const uint16_t rule_arg_combined_table[] = {
  10100. +static const uint16_t rule_arg_combined_table[] = {
  10101. #define tok(t) (RULE_ARG_TOK | MP_TOKEN_##t)
  10102. #define rule(r) (RULE_ARG_RULE | RULE_##r)
  10103. #define opt_rule(r) (RULE_ARG_OPT_RULE | RULE_##r)
  10104. @@ -161,7 +161,7 @@ enum {
  10105. // data, which indexes rule_arg_combined_table. The offsets require 9 bits of
  10106. // storage but only the lower 8 bits are stored here. The 9th bit is computed
  10107. // in get_rule_arg using the FIRST_RULE_WITH_OFFSET_ABOVE_255 constant.
  10108. -STATIC const uint8_t rule_arg_offset_table[] = {
  10109. +static const uint8_t rule_arg_offset_table[] = {
  10110. #define DEF_RULE(rule, comp, kind, ...) RULE_ARG_OFFSET(rule, __VA_ARGS__) & 0xff,
  10111. #define DEF_RULE_NC(rule, kind, ...)
  10112. #include "py/grammar.h"
  10113. @@ -191,7 +191,7 @@ static const size_t FIRST_RULE_WITH_OFFSET_ABOVE_255 =
  10114. #if MICROPY_DEBUG_PARSE_RULE_NAME
  10115. // Define an array of rule names corresponding to each rule
  10116. -STATIC const char *const rule_name_table[] = {
  10117. +static const char *const rule_name_table[] = {
  10118. #define DEF_RULE(rule, comp, kind, ...) #rule,
  10119. #define DEF_RULE_NC(rule, kind, ...)
  10120. #include "py/grammar.h"
  10121. @@ -242,9 +242,9 @@ typedef struct _parser_t {
  10122. #endif
  10123. } parser_t;
  10124. -STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args);
  10125. +static void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args);
  10126. -STATIC const uint16_t *get_rule_arg(uint8_t r_id) {
  10127. +static const uint16_t *get_rule_arg(uint8_t r_id) {
  10128. size_t off = rule_arg_offset_table[r_id];
  10129. if (r_id >= FIRST_RULE_WITH_OFFSET_ABOVE_255) {
  10130. off |= 0x100;
  10131. @@ -252,7 +252,7 @@ STATIC const uint16_t *get_rule_arg(uint8_t r_id) {
  10132. return &rule_arg_combined_table[off];
  10133. }
  10134. -STATIC void *parser_alloc(parser_t *parser, size_t num_bytes) {
  10135. +static void *parser_alloc(parser_t *parser, size_t num_bytes) {
  10136. // use a custom memory allocator to store parse nodes sequentially in large chunks
  10137. mp_parse_chunk_t *chunk = parser->cur_chunk;
  10138. @@ -294,7 +294,7 @@ STATIC void *parser_alloc(parser_t *parser, size_t num_bytes) {
  10139. }
  10140. #if MICROPY_COMP_CONST_TUPLE
  10141. -STATIC void parser_free_parse_node_struct(parser_t *parser, mp_parse_node_struct_t *pns) {
  10142. +static void parser_free_parse_node_struct(parser_t *parser, mp_parse_node_struct_t *pns) {
  10143. mp_parse_chunk_t *chunk = parser->cur_chunk;
  10144. if (chunk->data <= (byte *)pns && (byte *)pns < chunk->data + chunk->union_.used) {
  10145. size_t num_bytes = sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
  10146. @@ -303,7 +303,7 @@ STATIC void parser_free_parse_node_struct(parser_t *parser, mp_parse_node_struct
  10147. }
  10148. #endif
  10149. -STATIC void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t arg_i) {
  10150. +static void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t arg_i) {
  10151. if (parser->rule_stack_top >= parser->rule_stack_alloc) {
  10152. 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);
  10153. parser->rule_stack = rs;
  10154. @@ -315,13 +315,13 @@ STATIC void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t
  10155. rs->arg_i = arg_i;
  10156. }
  10157. -STATIC void push_rule_from_arg(parser_t *parser, size_t arg) {
  10158. +static void push_rule_from_arg(parser_t *parser, size_t arg) {
  10159. assert((arg & RULE_ARG_KIND_MASK) == RULE_ARG_RULE || (arg & RULE_ARG_KIND_MASK) == RULE_ARG_OPT_RULE);
  10160. size_t rule_id = arg & RULE_ARG_ARG_MASK;
  10161. push_rule(parser, parser->lexer->tok_line, rule_id, 0);
  10162. }
  10163. -STATIC uint8_t pop_rule(parser_t *parser, size_t *arg_i, size_t *src_line) {
  10164. +static uint8_t pop_rule(parser_t *parser, size_t *arg_i, size_t *src_line) {
  10165. parser->rule_stack_top -= 1;
  10166. uint8_t rule_id = parser->rule_stack[parser->rule_stack_top].rule_id;
  10167. *arg_i = parser->rule_stack[parser->rule_stack_top].arg_i;
  10168. @@ -330,7 +330,7 @@ STATIC uint8_t pop_rule(parser_t *parser, size_t *arg_i, size_t *src_line) {
  10169. }
  10170. #if MICROPY_COMP_CONST_TUPLE
  10171. -STATIC uint8_t peek_rule(parser_t *parser, size_t n) {
  10172. +static uint8_t peek_rule(parser_t *parser, size_t n) {
  10173. assert(parser->rule_stack_top > n);
  10174. return parser->rule_stack[parser->rule_stack_top - 1 - n].rule_id;
  10175. }
  10176. @@ -350,7 +350,7 @@ bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) {
  10177. }
  10178. #if MICROPY_COMP_CONST_TUPLE || MICROPY_COMP_CONST
  10179. -STATIC bool mp_parse_node_is_const(mp_parse_node_t pn) {
  10180. +static bool mp_parse_node_is_const(mp_parse_node_t pn) {
  10181. if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
  10182. // Small integer.
  10183. return true;
  10184. @@ -377,7 +377,7 @@ STATIC bool mp_parse_node_is_const(mp_parse_node_t pn) {
  10185. return false;
  10186. }
  10187. -STATIC mp_obj_t mp_parse_node_convert_to_obj(mp_parse_node_t pn) {
  10188. +static mp_obj_t mp_parse_node_convert_to_obj(mp_parse_node_t pn) {
  10189. assert(mp_parse_node_is_const(pn));
  10190. if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
  10191. mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn);
  10192. @@ -419,7 +419,7 @@ STATIC mp_obj_t mp_parse_node_convert_to_obj(mp_parse_node_t pn) {
  10193. }
  10194. #endif
  10195. -STATIC bool parse_node_is_const_bool(mp_parse_node_t pn, bool value) {
  10196. +static bool parse_node_is_const_bool(mp_parse_node_t pn, bool value) {
  10197. // Returns true if 'pn' is a constant whose boolean value is equivalent to 'value'
  10198. #if MICROPY_COMP_CONST_TUPLE || MICROPY_COMP_CONST
  10199. return mp_parse_node_is_const(pn) && mp_obj_is_true(mp_parse_node_convert_to_obj(pn)) == value;
  10200. @@ -513,7 +513,7 @@ void mp_parse_node_print(const mp_print_t *print, mp_parse_node_t pn, size_t ind
  10201. #endif // MICROPY_DEBUG_PRINTERS
  10202. /*
  10203. -STATIC void result_stack_show(const mp_print_t *print, parser_t *parser) {
  10204. +static void result_stack_show(const mp_print_t *print, parser_t *parser) {
  10205. mp_printf(print, "result stack, most recent first\n");
  10206. for (ssize_t i = parser->result_stack_top - 1; i >= 0; i--) {
  10207. mp_parse_node_print(print, parser->result_stack[i], 0);
  10208. @@ -521,17 +521,17 @@ STATIC void result_stack_show(const mp_print_t *print, parser_t *parser) {
  10209. }
  10210. */
  10211. -STATIC mp_parse_node_t pop_result(parser_t *parser) {
  10212. +static mp_parse_node_t pop_result(parser_t *parser) {
  10213. assert(parser->result_stack_top > 0);
  10214. return parser->result_stack[--parser->result_stack_top];
  10215. }
  10216. -STATIC mp_parse_node_t peek_result(parser_t *parser, size_t pos) {
  10217. +static mp_parse_node_t peek_result(parser_t *parser, size_t pos) {
  10218. assert(parser->result_stack_top > pos);
  10219. return parser->result_stack[parser->result_stack_top - 1 - pos];
  10220. }
  10221. -STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
  10222. +static void push_result_node(parser_t *parser, mp_parse_node_t pn) {
  10223. if (parser->result_stack_top >= parser->result_stack_alloc) {
  10224. 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);
  10225. parser->result_stack = stack;
  10226. @@ -540,7 +540,7 @@ STATIC void push_result_node(parser_t *parser, mp_parse_node_t pn) {
  10227. parser->result_stack[parser->result_stack_top++] = pn;
  10228. }
  10229. -STATIC mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) {
  10230. +static mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line, mp_obj_t obj) {
  10231. mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_obj_t));
  10232. pn->source_line = src_line;
  10233. #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
  10234. @@ -557,7 +557,7 @@ STATIC mp_parse_node_t make_node_const_object(parser_t *parser, size_t src_line,
  10235. // Create a parse node representing a constant object, possibly optimising the case of
  10236. // an integer, by putting the (small) integer value directly in the parse node itself.
  10237. -STATIC mp_parse_node_t make_node_const_object_optimised(parser_t *parser, size_t src_line, mp_obj_t obj) {
  10238. +static mp_parse_node_t make_node_const_object_optimised(parser_t *parser, size_t src_line, mp_obj_t obj) {
  10239. if (mp_obj_is_small_int(obj)) {
  10240. mp_int_t val = MP_OBJ_SMALL_INT_VALUE(obj);
  10241. #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
  10242. @@ -579,7 +579,7 @@ STATIC mp_parse_node_t make_node_const_object_optimised(parser_t *parser, size_t
  10243. }
  10244. }
  10245. -STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
  10246. +static void push_result_token(parser_t *parser, uint8_t rule_id) {
  10247. mp_parse_node_t pn;
  10248. mp_lexer_t *lex = parser->lexer;
  10249. if (lex->tok_kind == MP_TOKEN_NAME) {
  10250. @@ -635,7 +635,7 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
  10251. #if MICROPY_COMP_CONST_FOLDING
  10252. #if MICROPY_COMP_MODULE_CONST
  10253. -STATIC const mp_rom_map_elem_t mp_constants_table[] = {
  10254. +static const mp_rom_map_elem_t mp_constants_table[] = {
  10255. #if MICROPY_PY_ERRNO
  10256. { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_errno) },
  10257. #endif
  10258. @@ -645,7 +645,7 @@ STATIC const mp_rom_map_elem_t mp_constants_table[] = {
  10259. // Extra constants as defined by a port
  10260. MICROPY_PORT_CONSTANTS
  10261. };
  10262. -STATIC MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table);
  10263. +static MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table);
  10264. #endif
  10265. #if MICROPY_COMP_CONST_FOLDING_COMPILER_WORKAROUND
  10266. @@ -653,7 +653,7 @@ STATIC MP_DEFINE_CONST_MAP(mp_constants_map, mp_constants_table);
  10267. // function is static, so provide a hook for them to work around this problem.
  10268. MP_NOINLINE
  10269. #endif
  10270. -STATIC bool fold_logical_constants(parser_t *parser, uint8_t rule_id, size_t *num_args) {
  10271. +static bool fold_logical_constants(parser_t *parser, uint8_t rule_id, size_t *num_args) {
  10272. if (rule_id == RULE_or_test
  10273. || rule_id == RULE_and_test) {
  10274. // folding for binary logical ops: or and
  10275. @@ -710,7 +710,7 @@ STATIC bool fold_logical_constants(parser_t *parser, uint8_t rule_id, size_t *nu
  10276. return false;
  10277. }
  10278. -STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
  10279. +static bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
  10280. // this code does folding of arbitrary integer expressions, eg 1 + 2 * 3 + 4
  10281. // it does not do partial folding, eg 1 + 2 + x -> 3 + x
  10282. @@ -894,7 +894,7 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
  10283. #endif // MICROPY_COMP_CONST_FOLDING
  10284. #if MICROPY_COMP_CONST_TUPLE
  10285. -STATIC bool build_tuple_from_stack(parser_t *parser, size_t src_line, size_t num_args) {
  10286. +static bool build_tuple_from_stack(parser_t *parser, size_t src_line, size_t num_args) {
  10287. for (size_t i = num_args; i > 0;) {
  10288. mp_parse_node_t pn = peek_result(parser, --i);
  10289. if (!mp_parse_node_is_const(pn)) {
  10290. @@ -913,7 +913,7 @@ STATIC bool build_tuple_from_stack(parser_t *parser, size_t src_line, size_t num
  10291. return true;
  10292. }
  10293. -STATIC bool build_tuple(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
  10294. +static bool build_tuple(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
  10295. if (rule_id == RULE_testlist_comp) {
  10296. if (peek_rule(parser, 0) == RULE_atom_paren) {
  10297. // Tuple of the form "(a,)".
  10298. @@ -946,7 +946,7 @@ STATIC bool build_tuple(parser_t *parser, size_t src_line, uint8_t rule_id, size
  10299. }
  10300. #endif
  10301. -STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
  10302. +static void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
  10303. // Simplify and optimise certain rules, to reduce memory usage and simplify the compiler.
  10304. if (rule_id == RULE_atom_paren) {
  10305. // Remove parenthesis around a single expression if possible.
  10306. @@ -1386,6 +1386,7 @@ void mp_parse_tree_clear(mp_parse_tree_t *tree) {
  10307. m_del(byte, chunk, sizeof(mp_parse_chunk_t) + chunk->alloc);
  10308. chunk = next;
  10309. }
  10310. + tree->chunk = NULL; // Avoid dangling pointer that may live on stack
  10311. }
  10312. #endif // MICROPY_ENABLE_COMPILER
  10313. diff --git a/py/parsenum.c b/py/parsenum.c
  10314. index e3ad8070c..b33ffb6ff 100644
  10315. --- a/py/parsenum.c
  10316. +++ b/py/parsenum.c
  10317. @@ -36,7 +36,7 @@
  10318. #include <math.h>
  10319. #endif
  10320. -STATIC NORETURN void raise_exc(mp_obj_t exc, mp_lexer_t *lex) {
  10321. +static NORETURN void raise_exc(mp_obj_t exc, mp_lexer_t *lex) {
  10322. // if lex!=NULL then the parser called us and we need to convert the
  10323. // exception's type from ValueError to SyntaxError and add traceback info
  10324. if (lex != NULL) {
  10325. diff --git a/py/persistentcode.c b/py/persistentcode.c
  10326. index df1003bab..5088c05f0 100644
  10327. --- a/py/persistentcode.c
  10328. +++ b/py/persistentcode.c
  10329. @@ -69,8 +69,8 @@ typedef struct _bytecode_prelude_t {
  10330. #include "py/parsenum.h"
  10331. -STATIC int read_byte(mp_reader_t *reader);
  10332. -STATIC size_t read_uint(mp_reader_t *reader);
  10333. +static int read_byte(mp_reader_t *reader);
  10334. +static size_t read_uint(mp_reader_t *reader);
  10335. #if MICROPY_EMIT_MACHINE_CODE
  10336. @@ -138,17 +138,17 @@ void mp_native_relocate(void *ri_in, uint8_t *text, uintptr_t reloc_text) {
  10337. #endif
  10338. -STATIC int read_byte(mp_reader_t *reader) {
  10339. +static int read_byte(mp_reader_t *reader) {
  10340. return reader->readbyte(reader->data);
  10341. }
  10342. -STATIC void read_bytes(mp_reader_t *reader, byte *buf, size_t len) {
  10343. +static void read_bytes(mp_reader_t *reader, byte *buf, size_t len) {
  10344. while (len-- > 0) {
  10345. *buf++ = reader->readbyte(reader->data);
  10346. }
  10347. }
  10348. -STATIC size_t read_uint(mp_reader_t *reader) {
  10349. +static size_t read_uint(mp_reader_t *reader) {
  10350. size_t unum = 0;
  10351. for (;;) {
  10352. byte b = reader->readbyte(reader->data);
  10353. @@ -160,7 +160,7 @@ STATIC size_t read_uint(mp_reader_t *reader) {
  10354. return unum;
  10355. }
  10356. -STATIC qstr load_qstr(mp_reader_t *reader) {
  10357. +static qstr load_qstr(mp_reader_t *reader) {
  10358. size_t len = read_uint(reader);
  10359. if (len & 1) {
  10360. // static qstr
  10361. @@ -175,7 +175,7 @@ STATIC qstr load_qstr(mp_reader_t *reader) {
  10362. return qst;
  10363. }
  10364. -STATIC mp_obj_t load_obj(mp_reader_t *reader) {
  10365. +static mp_obj_t load_obj(mp_reader_t *reader) {
  10366. byte obj_type = read_byte(reader);
  10367. #if MICROPY_EMIT_MACHINE_CODE
  10368. if (obj_type == MP_PERSISTENT_OBJ_FUN_TABLE) {
  10369. @@ -221,7 +221,7 @@ STATIC mp_obj_t load_obj(mp_reader_t *reader) {
  10370. }
  10371. }
  10372. -STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader, mp_module_context_t *context) {
  10373. +static mp_raw_code_t *load_raw_code(mp_reader_t *reader, mp_module_context_t *context) {
  10374. // Load function kind and data length
  10375. size_t kind_len = read_uint(reader);
  10376. int kind = (kind_len & 3) + MP_CODE_BYTECODE;
  10377. @@ -324,11 +324,9 @@ STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader, mp_module_context_t *co
  10378. MP_BC_PRELUDE_SIG_DECODE(ip);
  10379. // Assign bytecode to raw code object
  10380. mp_emit_glue_assign_bytecode(rc, fun_data,
  10381. - #if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
  10382. - fun_data_len,
  10383. - #endif
  10384. children,
  10385. #if MICROPY_PERSISTENT_CODE_SAVE
  10386. + fun_data_len,
  10387. n_children,
  10388. #endif
  10389. scope_flags);
  10390. @@ -470,12 +468,12 @@ void mp_raw_code_load_file(qstr filename, mp_compiled_module_t *context) {
  10391. #include "py/objstr.h"
  10392. -STATIC void mp_print_bytes(mp_print_t *print, const byte *data, size_t len) {
  10393. +static void mp_print_bytes(mp_print_t *print, const byte *data, size_t len) {
  10394. print->print_strn(print->data, (const char *)data, len);
  10395. }
  10396. #define BYTES_FOR_INT ((MP_BYTES_PER_OBJ_WORD * 8 + 6) / 7)
  10397. -STATIC void mp_print_uint(mp_print_t *print, size_t n) {
  10398. +static void mp_print_uint(mp_print_t *print, size_t n) {
  10399. byte buf[BYTES_FOR_INT];
  10400. byte *p = buf + sizeof(buf);
  10401. *--p = n & 0x7f;
  10402. @@ -486,7 +484,7 @@ STATIC void mp_print_uint(mp_print_t *print, size_t n) {
  10403. print->print_strn(print->data, (char *)p, buf + sizeof(buf) - p);
  10404. }
  10405. -STATIC void save_qstr(mp_print_t *print, qstr qst) {
  10406. +static void save_qstr(mp_print_t *print, qstr qst) {
  10407. if (qst <= QSTR_LAST_STATIC) {
  10408. // encode static qstr
  10409. mp_print_uint(print, qst << 1 | 1);
  10410. @@ -498,7 +496,7 @@ STATIC void save_qstr(mp_print_t *print, qstr qst) {
  10411. mp_print_bytes(print, str, len + 1); // +1 to store null terminator
  10412. }
  10413. -STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
  10414. +static void save_obj(mp_print_t *print, mp_obj_t o) {
  10415. #if MICROPY_EMIT_MACHINE_CODE
  10416. if (o == MP_OBJ_FROM_PTR(&mp_fun_table)) {
  10417. byte obj_type = MP_PERSISTENT_OBJ_FUN_TABLE;
  10418. @@ -564,7 +562,7 @@ STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
  10419. }
  10420. }
  10421. -STATIC void save_raw_code(mp_print_t *print, const mp_raw_code_t *rc) {
  10422. +static void save_raw_code(mp_print_t *print, const mp_raw_code_t *rc) {
  10423. // Save function kind and data length
  10424. mp_print_uint(print, (rc->fun_data_len << 3) | ((rc->n_children != 0) << 2) | (rc->kind - MP_CODE_BYTECODE));
  10425. @@ -577,11 +575,15 @@ STATIC void save_raw_code(mp_print_t *print, const mp_raw_code_t *rc) {
  10426. mp_print_uint(print, rc->prelude_offset);
  10427. } else if (rc->kind == MP_CODE_NATIVE_VIPER || rc->kind == MP_CODE_NATIVE_ASM) {
  10428. // Save basic scope info for viper and asm
  10429. - mp_print_uint(print, rc->scope_flags & MP_SCOPE_FLAG_ALL_SIG);
  10430. + // Viper/asm functions don't support generator, variable args, or default keyword args
  10431. + // so (scope_flags & MP_SCOPE_FLAG_ALL_SIG) for these functions is always 0.
  10432. + mp_print_uint(print, 0);
  10433. + #if MICROPY_EMIT_INLINE_ASM
  10434. if (rc->kind == MP_CODE_NATIVE_ASM) {
  10435. - mp_print_uint(print, rc->n_pos_args);
  10436. - mp_print_uint(print, rc->type_sig);
  10437. + mp_print_uint(print, rc->asm_n_pos_args);
  10438. + mp_print_uint(print, rc->asm_type_sig);
  10439. }
  10440. + #endif
  10441. }
  10442. #endif
  10443. @@ -635,7 +637,7 @@ void mp_raw_code_save(mp_compiled_module_t *cm, mp_print_t *print) {
  10444. #include <sys/stat.h>
  10445. #include <fcntl.h>
  10446. -STATIC void fd_print_strn(void *env, const char *str, size_t len) {
  10447. +static void fd_print_strn(void *env, const char *str, size_t len) {
  10448. int fd = (intptr_t)env;
  10449. MP_THREAD_GIL_EXIT();
  10450. ssize_t ret = write(fd, str, len);
  10451. diff --git a/py/persistentcode.h b/py/persistentcode.h
  10452. index 45a268d63..d2b310f24 100644
  10453. --- a/py/persistentcode.h
  10454. +++ b/py/persistentcode.h
  10455. @@ -35,7 +35,7 @@
  10456. // set) must also match MPY_SUB_VERSION. This allows 3 additional updates to
  10457. // the native ABI per bytecode revision.
  10458. #define MPY_VERSION 6
  10459. -#define MPY_SUB_VERSION 2
  10460. +#define MPY_SUB_VERSION 3
  10461. // Macros to encode/decode sub-version to/from the feature byte. This replaces
  10462. // the bits previously used to encode the flags (map caching and unicode)
  10463. diff --git a/py/profile.c b/py/profile.c
  10464. index 274089d70..92f414ace 100644
  10465. --- a/py/profile.c
  10466. +++ b/py/profile.c
  10467. @@ -40,7 +40,7 @@
  10468. #define prof_trace_cb MP_STATE_THREAD(prof_trace_callback)
  10469. #define QSTR_MAP(context, idx) (context->constants.qstr_table[idx])
  10470. -STATIC uint mp_prof_bytecode_lineno(const mp_raw_code_t *rc, size_t bc) {
  10471. +static uint mp_prof_bytecode_lineno(const mp_raw_code_t *rc, size_t bc) {
  10472. const mp_bytecode_prelude_t *prelude = &rc->prelude;
  10473. return mp_bytecode_get_source_line(prelude->line_info, prelude->line_info_top, bc);
  10474. }
  10475. @@ -71,7 +71,7 @@ void mp_prof_extract_prelude(const byte *bytecode, mp_bytecode_prelude_t *prelud
  10476. /******************************************************************************/
  10477. // code object
  10478. -STATIC void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  10479. +static void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  10480. (void)kind;
  10481. mp_obj_code_t *o = MP_OBJ_TO_PTR(o_in);
  10482. const mp_raw_code_t *rc = o->rc;
  10483. @@ -85,7 +85,7 @@ STATIC void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
  10484. );
  10485. }
  10486. -STATIC mp_obj_tuple_t *code_consts(const mp_module_context_t *context, const mp_raw_code_t *rc) {
  10487. +static mp_obj_tuple_t *code_consts(const mp_module_context_t *context, const mp_raw_code_t *rc) {
  10488. mp_obj_tuple_t *consts = MP_OBJ_TO_PTR(mp_obj_new_tuple(rc->n_children + 1, NULL));
  10489. size_t const_no = 0;
  10490. @@ -101,7 +101,7 @@ STATIC mp_obj_tuple_t *code_consts(const mp_module_context_t *context, const mp_
  10491. return consts;
  10492. }
  10493. -STATIC mp_obj_t raw_code_lnotab(const mp_raw_code_t *rc) {
  10494. +static mp_obj_t raw_code_lnotab(const mp_raw_code_t *rc) {
  10495. // const mp_bytecode_prelude_t *prelude = &rc->prelude;
  10496. uint start = 0;
  10497. uint stop = rc->fun_data_len - start;
  10498. @@ -139,7 +139,7 @@ STATIC mp_obj_t raw_code_lnotab(const mp_raw_code_t *rc) {
  10499. return o;
  10500. }
  10501. -STATIC void code_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  10502. +static void code_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  10503. if (dest[0] != MP_OBJ_NULL) {
  10504. // not load attribute
  10505. return;
  10506. @@ -202,7 +202,7 @@ mp_obj_t mp_obj_new_code(const mp_module_context_t *context, const mp_raw_code_t
  10507. /******************************************************************************/
  10508. // frame object
  10509. -STATIC void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  10510. +static void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
  10511. (void)kind;
  10512. mp_obj_frame_t *frame = MP_OBJ_TO_PTR(o_in);
  10513. mp_obj_code_t *code = frame->code;
  10514. @@ -217,7 +217,7 @@ STATIC void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
  10515. );
  10516. }
  10517. -STATIC void frame_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  10518. +static void frame_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
  10519. if (dest[0] != MP_OBJ_NULL) {
  10520. // not load attribute
  10521. return;
  10522. @@ -294,7 +294,7 @@ typedef struct {
  10523. mp_obj_t arg;
  10524. } prof_callback_args_t;
  10525. -STATIC mp_obj_t mp_prof_callback_invoke(mp_obj_t callback, prof_callback_args_t *args) {
  10526. +static mp_obj_t mp_prof_callback_invoke(mp_obj_t callback, prof_callback_args_t *args) {
  10527. assert(mp_obj_is_callable(callback));
  10528. mp_prof_is_executing = true;
  10529. @@ -474,7 +474,7 @@ typedef struct _mp_dis_instruction_t {
  10530. mp_obj_t argobjex_cache;
  10531. } mp_dis_instruction_t;
  10532. -STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_table, mp_dis_instruction_t *instruction) {
  10533. +static const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_table, mp_dis_instruction_t *instruction) {
  10534. mp_uint_t unum;
  10535. const byte *ptr;
  10536. mp_obj_t obj;
  10537. diff --git a/py/qstr.c b/py/qstr.c
  10538. index dc89013f8..fea7f44fe 100644
  10539. --- a/py/qstr.c
  10540. +++ b/py/qstr.c
  10541. @@ -42,7 +42,11 @@
  10542. // A qstr is an index into the qstr pool.
  10543. // The data for a qstr is \0 terminated (so they can be printed using printf)
  10544. +#if MICROPY_QSTR_BYTES_IN_HASH
  10545. #define Q_HASH_MASK ((1 << (8 * MICROPY_QSTR_BYTES_IN_HASH)) - 1)
  10546. +#else
  10547. +#define Q_HASH_MASK (0xffff)
  10548. +#endif
  10549. #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
  10550. #define QSTR_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(qstr_mutex), 1)
  10551. @@ -75,8 +79,9 @@ size_t qstr_compute_hash(const byte *data, size_t len) {
  10552. // it is part of the .mpy ABI. See the top of py/persistentcode.c and
  10553. // static_qstr_list in makeqstrdata.py. This pool is unsorted (although in a
  10554. // future .mpy version we could re-order them and make it sorted). It also
  10555. -// contains additional qstrs that must have IDs <256, see operator_qstr_list
  10556. +// contains additional qstrs that must have IDs <256, see unsorted_qstr_list
  10557. // in makeqstrdata.py.
  10558. +#if MICROPY_QSTR_BYTES_IN_HASH
  10559. const qstr_hash_t mp_qstr_const_hashes_static[] = {
  10560. #ifndef NO_QSTR
  10561. #define QDEF0(id, hash, len, str) hash,
  10562. @@ -86,6 +91,7 @@ const qstr_hash_t mp_qstr_const_hashes_static[] = {
  10563. #undef QDEF1
  10564. #endif
  10565. };
  10566. +#endif
  10567. const qstr_len_t mp_qstr_const_lengths_static[] = {
  10568. #ifndef NO_QSTR
  10569. @@ -103,7 +109,9 @@ const qstr_pool_t mp_qstr_const_pool_static = {
  10570. false, // is_sorted
  10571. MICROPY_ALLOC_QSTR_ENTRIES_INIT,
  10572. MP_QSTRnumber_of_static, // corresponds to number of strings in array just below
  10573. + #if MICROPY_QSTR_BYTES_IN_HASH
  10574. (qstr_hash_t *)mp_qstr_const_hashes_static,
  10575. + #endif
  10576. (qstr_len_t *)mp_qstr_const_lengths_static,
  10577. {
  10578. #ifndef NO_QSTR
  10579. @@ -118,6 +126,7 @@ const qstr_pool_t mp_qstr_const_pool_static = {
  10580. // The next pool is the remainder of the qstrs defined in the firmware. This
  10581. // is sorted.
  10582. +#if MICROPY_QSTR_BYTES_IN_HASH
  10583. const qstr_hash_t mp_qstr_const_hashes[] = {
  10584. #ifndef NO_QSTR
  10585. #define QDEF0(id, hash, len, str)
  10586. @@ -127,6 +136,7 @@ const qstr_hash_t mp_qstr_const_hashes[] = {
  10587. #undef QDEF1
  10588. #endif
  10589. };
  10590. +#endif
  10591. const qstr_len_t mp_qstr_const_lengths[] = {
  10592. #ifndef NO_QSTR
  10593. @@ -144,7 +154,9 @@ const qstr_pool_t mp_qstr_const_pool = {
  10594. true, // is_sorted
  10595. MICROPY_ALLOC_QSTR_ENTRIES_INIT,
  10596. MP_QSTRnumber_of - MP_QSTRnumber_of_static, // corresponds to number of strings in array just below
  10597. + #if MICROPY_QSTR_BYTES_IN_HASH
  10598. (qstr_hash_t *)mp_qstr_const_hashes,
  10599. + #endif
  10600. (qstr_len_t *)mp_qstr_const_lengths,
  10601. {
  10602. #ifndef NO_QSTR
  10603. @@ -175,7 +187,7 @@ void qstr_init(void) {
  10604. #endif
  10605. }
  10606. -STATIC const qstr_pool_t *find_qstr(qstr *q) {
  10607. +static const qstr_pool_t *find_qstr(qstr *q) {
  10608. // search pool for this qstr
  10609. // total_prev_len==0 in the final pool, so the loop will always terminate
  10610. const qstr_pool_t *pool = MP_STATE_VM(last_pool);
  10611. @@ -188,8 +200,13 @@ STATIC const qstr_pool_t *find_qstr(qstr *q) {
  10612. }
  10613. // qstr_mutex must be taken while in this function
  10614. -STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
  10615. +static qstr qstr_add(mp_uint_t len, const char *q_ptr) {
  10616. + #if MICROPY_QSTR_BYTES_IN_HASH
  10617. + mp_uint_t hash = qstr_compute_hash((const byte *)q_ptr, len);
  10618. DEBUG_printf("QSTR: add hash=%d len=%d data=%.*s\n", hash, len, len, q_ptr);
  10619. + #else
  10620. + DEBUG_printf("QSTR: add len=%d data=%.*s\n", len, len, q_ptr);
  10621. + #endif
  10622. // make sure we have room in the pool for a new qstr
  10623. if (MP_STATE_VM(last_pool)->len >= MP_STATE_VM(last_pool)->alloc) {
  10624. @@ -199,7 +216,11 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
  10625. new_alloc = MAX(MICROPY_ALLOC_QSTR_ENTRIES_INIT, new_alloc);
  10626. #endif
  10627. mp_uint_t pool_size = sizeof(qstr_pool_t)
  10628. - + (sizeof(const char *) + sizeof(qstr_hash_t) + sizeof(qstr_len_t)) * new_alloc;
  10629. + + (sizeof(const char *)
  10630. + #if MICROPY_QSTR_BYTES_IN_HASH
  10631. + + sizeof(qstr_hash_t)
  10632. + #endif
  10633. + + sizeof(qstr_len_t)) * new_alloc;
  10634. qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size);
  10635. if (pool == NULL) {
  10636. // Keep qstr_last_chunk consistent with qstr_pool_t: qstr_last_chunk is not scanned
  10637. @@ -211,8 +232,12 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
  10638. QSTR_EXIT();
  10639. m_malloc_fail(new_alloc);
  10640. }
  10641. + #if MICROPY_QSTR_BYTES_IN_HASH
  10642. pool->hashes = (qstr_hash_t *)(pool->qstrs + new_alloc);
  10643. pool->lengths = (qstr_len_t *)(pool->hashes + new_alloc);
  10644. + #else
  10645. + pool->lengths = (qstr_len_t *)(pool->qstrs + new_alloc);
  10646. + #endif
  10647. pool->prev = MP_STATE_VM(last_pool);
  10648. pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len;
  10649. pool->alloc = new_alloc;
  10650. @@ -223,7 +248,9 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
  10651. // add the new qstr
  10652. mp_uint_t at = MP_STATE_VM(last_pool)->len;
  10653. + #if MICROPY_QSTR_BYTES_IN_HASH
  10654. MP_STATE_VM(last_pool)->hashes[at] = hash;
  10655. + #endif
  10656. MP_STATE_VM(last_pool)->lengths[at] = len;
  10657. MP_STATE_VM(last_pool)->qstrs[at] = q_ptr;
  10658. MP_STATE_VM(last_pool)->len++;
  10659. @@ -238,8 +265,10 @@ qstr qstr_find_strn(const char *str, size_t str_len) {
  10660. return MP_QSTR_;
  10661. }
  10662. + #if MICROPY_QSTR_BYTES_IN_HASH
  10663. // work out hash of str
  10664. size_t str_hash = qstr_compute_hash((const byte *)str, str_len);
  10665. + #endif
  10666. // search pools for the data
  10667. for (const qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) {
  10668. @@ -261,7 +290,11 @@ qstr qstr_find_strn(const char *str, size_t str_len) {
  10669. // sequential search for the remaining strings
  10670. for (mp_uint_t at = low; at < high + 1; at++) {
  10671. - if (pool->hashes[at] == str_hash && pool->lengths[at] == str_len
  10672. + if (
  10673. + #if MICROPY_QSTR_BYTES_IN_HASH
  10674. + pool->hashes[at] == str_hash &&
  10675. + #endif
  10676. + pool->lengths[at] == str_len
  10677. && memcmp(pool->qstrs[at], str, str_len) == 0) {
  10678. return pool->total_prev_len + at;
  10679. }
  10680. @@ -329,10 +362,9 @@ qstr qstr_from_strn(const char *str, size_t len) {
  10681. MP_STATE_VM(qstr_last_used) += n_bytes;
  10682. // store the interned strings' data
  10683. - size_t hash = qstr_compute_hash((const byte *)str, len);
  10684. memcpy(q_ptr, str, len);
  10685. q_ptr[len] = '\0';
  10686. - q = qstr_add(hash, len, q_ptr);
  10687. + q = qstr_add(len, q_ptr);
  10688. }
  10689. QSTR_EXIT();
  10690. return q;
  10691. @@ -340,7 +372,11 @@ qstr qstr_from_strn(const char *str, size_t len) {
  10692. mp_uint_t qstr_hash(qstr q) {
  10693. const qstr_pool_t *pool = find_qstr(&q);
  10694. + #if MICROPY_QSTR_BYTES_IN_HASH
  10695. return pool->hashes[q];
  10696. + #else
  10697. + return qstr_compute_hash((byte *)pool->qstrs[q], pool->lengths[q]);
  10698. + #endif
  10699. }
  10700. size_t qstr_len(qstr q) {
  10701. @@ -375,7 +411,11 @@ void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, si
  10702. *n_total_bytes += gc_nbytes(pool); // this counts actual bytes used in heap
  10703. #else
  10704. *n_total_bytes += sizeof(qstr_pool_t)
  10705. - + (sizeof(const char *) + sizeof(qstr_hash_t) + sizeof(qstr_len_t)) * pool->alloc;
  10706. + + (sizeof(const char *)
  10707. + #if MICROPY_QSTR_BYTES_IN_HASH
  10708. + + sizeof(qstr_hash_t)
  10709. + #endif
  10710. + + sizeof(qstr_len_t)) * pool->alloc;
  10711. #endif
  10712. }
  10713. *n_total_bytes += *n_str_data_bytes;
  10714. @@ -404,7 +444,7 @@ void qstr_dump_data(void) {
  10715. #else
  10716. // Emit the compressed_string_data string.
  10717. -#define MP_COMPRESSED_DATA(x) STATIC const char *compressed_string_data = x;
  10718. +#define MP_COMPRESSED_DATA(x) static const char *compressed_string_data = x;
  10719. #define MP_MATCH_COMPRESSED(a, b)
  10720. #include "genhdr/compressed.data.h"
  10721. #undef MP_COMPRESSED_DATA
  10722. @@ -418,7 +458,7 @@ void qstr_dump_data(void) {
  10723. // The compressed string data is delimited by setting high bit in the final char of each word.
  10724. // e.g. aaaa<0x80|a>bbbbbb<0x80|b>....
  10725. // This method finds the n'th string.
  10726. -STATIC const byte *find_uncompressed_string(uint8_t n) {
  10727. +static const byte *find_uncompressed_string(uint8_t n) {
  10728. const byte *c = (byte *)compressed_string_data;
  10729. while (n > 0) {
  10730. while ((*c & 0x80) == 0) {
  10731. diff --git a/py/qstr.h b/py/qstr.h
  10732. index 0c4fc4632..58ce285fd 100644
  10733. --- a/py/qstr.h
  10734. +++ b/py/qstr.h
  10735. @@ -60,7 +60,9 @@ enum {
  10736. typedef size_t qstr;
  10737. typedef uint16_t qstr_short_t;
  10738. -#if MICROPY_QSTR_BYTES_IN_HASH == 1
  10739. +#if MICROPY_QSTR_BYTES_IN_HASH == 0
  10740. +// No qstr_hash_t type needed.
  10741. +#elif MICROPY_QSTR_BYTES_IN_HASH == 1
  10742. typedef uint8_t qstr_hash_t;
  10743. #elif MICROPY_QSTR_BYTES_IN_HASH == 2
  10744. typedef uint16_t qstr_hash_t;
  10745. @@ -82,7 +84,9 @@ typedef struct _qstr_pool_t {
  10746. size_t is_sorted : 1;
  10747. size_t alloc;
  10748. size_t len;
  10749. + #if MICROPY_QSTR_BYTES_IN_HASH
  10750. qstr_hash_t *hashes;
  10751. + #endif
  10752. qstr_len_t *lengths;
  10753. const char *qstrs[];
  10754. } qstr_pool_t;
  10755. @@ -92,6 +96,7 @@ typedef struct _qstr_pool_t {
  10756. void qstr_init(void);
  10757. size_t qstr_compute_hash(const byte *data, size_t len);
  10758. +
  10759. qstr qstr_find_strn(const char *str, size_t str_len); // returns MP_QSTRnull if not found
  10760. qstr qstr_from_str(const char *str);
  10761. diff --git a/py/reader.c b/py/reader.c
  10762. index d2af62cfb..151e04cac 100644
  10763. --- a/py/reader.c
  10764. +++ b/py/reader.c
  10765. @@ -39,7 +39,7 @@ typedef struct _mp_reader_mem_t {
  10766. const byte *end;
  10767. } mp_reader_mem_t;
  10768. -STATIC mp_uint_t mp_reader_mem_readbyte(void *data) {
  10769. +static mp_uint_t mp_reader_mem_readbyte(void *data) {
  10770. mp_reader_mem_t *reader = (mp_reader_mem_t *)data;
  10771. if (reader->cur < reader->end) {
  10772. return *reader->cur++;
  10773. @@ -48,7 +48,7 @@ STATIC mp_uint_t mp_reader_mem_readbyte(void *data) {
  10774. }
  10775. }
  10776. -STATIC void mp_reader_mem_close(void *data) {
  10777. +static void mp_reader_mem_close(void *data) {
  10778. mp_reader_mem_t *reader = (mp_reader_mem_t *)data;
  10779. if (reader->free_len > 0) {
  10780. m_del(char, (char *)reader->beg, reader->free_len);
  10781. @@ -81,7 +81,7 @@ typedef struct _mp_reader_posix_t {
  10782. byte buf[20];
  10783. } mp_reader_posix_t;
  10784. -STATIC mp_uint_t mp_reader_posix_readbyte(void *data) {
  10785. +static mp_uint_t mp_reader_posix_readbyte(void *data) {
  10786. mp_reader_posix_t *reader = (mp_reader_posix_t *)data;
  10787. if (reader->pos >= reader->len) {
  10788. if (reader->len == 0) {
  10789. @@ -101,7 +101,7 @@ STATIC mp_uint_t mp_reader_posix_readbyte(void *data) {
  10790. return reader->buf[reader->pos++];
  10791. }
  10792. -STATIC void mp_reader_posix_close(void *data) {
  10793. +static void mp_reader_posix_close(void *data) {
  10794. mp_reader_posix_t *reader = (mp_reader_posix_t *)data;
  10795. if (reader->close_fd) {
  10796. MP_THREAD_GIL_EXIT();
  10797. diff --git a/py/repl.c b/py/repl.c
  10798. index cf69d3d89..b79a2d3c4 100644
  10799. --- a/py/repl.c
  10800. +++ b/py/repl.c
  10801. @@ -43,7 +43,7 @@ const char *mp_repl_get_psx(unsigned int entry) {
  10802. }
  10803. #endif
  10804. -STATIC bool str_startswith_word(const char *str, const char *head) {
  10805. +static bool str_startswith_word(const char *str, const char *head) {
  10806. size_t i;
  10807. for (i = 0; str[i] && head[i]; i++) {
  10808. if (str[i] != head[i]) {
  10809. @@ -154,7 +154,7 @@ bool mp_repl_continue_with_input(const char *input) {
  10810. return false;
  10811. }
  10812. -STATIC bool test_qstr(mp_obj_t obj, qstr name) {
  10813. +static bool test_qstr(mp_obj_t obj, qstr name) {
  10814. if (obj) {
  10815. // try object member
  10816. mp_obj_t dest[2];
  10817. @@ -167,7 +167,7 @@ STATIC bool test_qstr(mp_obj_t obj, qstr name) {
  10818. }
  10819. }
  10820. -STATIC const char *find_completions(const char *s_start, size_t s_len,
  10821. +static const char *find_completions(const char *s_start, size_t s_len,
  10822. mp_obj_t obj, size_t *match_len, qstr *q_first, qstr *q_last) {
  10823. const char *match_str = NULL;
  10824. @@ -207,7 +207,7 @@ STATIC const char *find_completions(const char *s_start, size_t s_len,
  10825. return match_str;
  10826. }
  10827. -STATIC void print_completions(const mp_print_t *print,
  10828. +static void print_completions(const mp_print_t *print,
  10829. const char *s_start, size_t s_len,
  10830. mp_obj_t obj, qstr q_first, qstr q_last) {
  10831. diff --git a/py/runtime.c b/py/runtime.c
  10832. index 6d8eddedc..1836f5d92 100644
  10833. --- a/py/runtime.c
  10834. +++ b/py/runtime.c
  10835. @@ -171,6 +171,10 @@ void mp_init(void) {
  10836. MP_STATE_VM(bluetooth) = MP_OBJ_NULL;
  10837. #endif
  10838. + #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
  10839. + MP_STATE_VM(usbd) = MP_OBJ_NULL;
  10840. + #endif
  10841. +
  10842. #if MICROPY_PY_THREAD_GIL
  10843. mp_thread_mutex_init(&MP_STATE_VM(gil_mutex));
  10844. #endif
  10845. @@ -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) {
  10846. // This function only needs to be exposed externally when in stackless mode.
  10847. #if !MICROPY_STACKLESS
  10848. -STATIC
  10849. +static
  10850. #endif
  10851. 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) {
  10852. mp_obj_t fun = *args++;
  10853. @@ -1074,7 +1078,7 @@ typedef struct _mp_obj_checked_fun_t {
  10854. mp_obj_t fun;
  10855. } mp_obj_checked_fun_t;
  10856. -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) {
  10857. +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) {
  10858. mp_obj_checked_fun_t *self = MP_OBJ_TO_PTR(self_in);
  10859. if (n_args > 0) {
  10860. const mp_obj_type_t *arg0_type = mp_obj_get_type(args[0]);
  10861. @@ -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
  10862. return mp_call_function_n_kw(self->fun, n_args, n_kw, args);
  10863. }
  10864. -STATIC MP_DEFINE_CONST_OBJ_TYPE(
  10865. +static MP_DEFINE_CONST_OBJ_TYPE(
  10866. mp_type_checked_fun,
  10867. MP_QSTR_function,
  10868. MP_TYPE_FLAG_BINDS_SELF,
  10869. call, checked_fun_call
  10870. );
  10871. -STATIC mp_obj_t mp_obj_new_checked_fun(const mp_obj_type_t *type, mp_obj_t fun) {
  10872. +static mp_obj_t mp_obj_new_checked_fun(const mp_obj_type_t *type, mp_obj_t fun) {
  10873. mp_obj_checked_fun_t *o = mp_obj_malloc(mp_obj_checked_fun_t, &mp_type_checked_fun);
  10874. o->type = type;
  10875. o->fun = fun;
  10876. @@ -1326,7 +1330,7 @@ mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
  10877. }
  10878. -STATIC mp_fun_1_t type_get_iternext(const mp_obj_type_t *type) {
  10879. +static mp_fun_1_t type_get_iternext(const mp_obj_type_t *type) {
  10880. if ((type->flags & MP_TYPE_FLAG_ITER_IS_STREAM) == MP_TYPE_FLAG_ITER_IS_STREAM) {
  10881. return mp_stream_unbuffered_iter;
  10882. } else if (type->flags & MP_TYPE_FLAG_ITER_IS_ITERNEXT) {
  10883. diff --git a/py/runtime.h b/py/runtime.h
  10884. index a04d4584f..5465c06d8 100644
  10885. --- a/py/runtime.h
  10886. +++ b/py/runtime.h
  10887. @@ -28,6 +28,7 @@
  10888. #include "py/mpstate.h"
  10889. #include "py/pystack.h"
  10890. +#include "py/stackctrl.h"
  10891. // For use with mp_call_function_1_from_nlr_jump_callback.
  10892. #define MP_DEFINE_NLR_JUMP_CALLBACK_FUNCTION_1(ctx, f, a) \
  10893. @@ -154,6 +155,32 @@ static inline void mp_globals_set(mp_obj_dict_t *d) {
  10894. void mp_globals_locals_set_from_nlr_jump_callback(void *ctx_in);
  10895. void mp_call_function_1_from_nlr_jump_callback(void *ctx_in);
  10896. +#if MICROPY_PY_THREAD
  10897. +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) {
  10898. + mp_thread_set_state(ts);
  10899. +
  10900. + mp_stack_set_top(ts + 1); // need to include ts in root-pointer scan
  10901. + mp_stack_set_limit(stack_size);
  10902. +
  10903. + // GC starts off unlocked
  10904. + ts->gc_lock_depth = 0;
  10905. +
  10906. + // There are no pending jump callbacks or exceptions yet
  10907. + ts->nlr_jump_callback_top = NULL;
  10908. + ts->mp_pending_exception = MP_OBJ_NULL;
  10909. +
  10910. + // If locals/globals are not given, inherit from main thread
  10911. + if (locals == NULL) {
  10912. + locals = mp_state_ctx.thread.dict_locals;
  10913. + }
  10914. + if (globals == NULL) {
  10915. + globals = mp_state_ctx.thread.dict_globals;
  10916. + }
  10917. + mp_locals_set(locals);
  10918. + mp_globals_set(globals);
  10919. +}
  10920. +#endif
  10921. +
  10922. mp_obj_t mp_load_name(qstr qst);
  10923. mp_obj_t mp_load_global(qstr qst);
  10924. mp_obj_t mp_load_build_class(void);
  10925. diff --git a/py/runtime0.h b/py/runtime0.h
  10926. index 69af38ddc..9c6f0e079 100644
  10927. --- a/py/runtime0.h
  10928. +++ b/py/runtime0.h
  10929. @@ -26,8 +26,11 @@
  10930. #ifndef MICROPY_INCLUDED_PY_RUNTIME0_H
  10931. #define MICROPY_INCLUDED_PY_RUNTIME0_H
  10932. -// The first four must fit in 8 bits, see emitbc.c
  10933. -// The remaining must fit in 16 bits, see scope.h
  10934. +// These constants are used by:
  10935. +// - mp_raw_code_t::is_generator (only MP_SCOPE_FLAG_GENERATOR)
  10936. +// - scope_t::scope_flags (16 bits)
  10937. +// - MP_BC_PRELUDE_SIG_ENCODE macro, masked by MP_SCOPE_FLAG_ALL_SIG (4 bits)
  10938. +// - tools/mpy_ld.py, when generating mpy files (maximum 7 bits)
  10939. #define MP_SCOPE_FLAG_ALL_SIG (0x0f)
  10940. #define MP_SCOPE_FLAG_GENERATOR (0x01)
  10941. #define MP_SCOPE_FLAG_VARKEYWORDS (0x02)
  10942. diff --git a/py/scope.c b/py/scope.c
  10943. index 8fc094328..4893e7cc4 100644
  10944. --- a/py/scope.c
  10945. +++ b/py/scope.c
  10946. @@ -31,7 +31,9 @@
  10947. #if MICROPY_ENABLE_COMPILER
  10948. // These low numbered qstrs should fit in 8 bits. See assertions below.
  10949. -STATIC const uint8_t scope_simple_name_table[] = {
  10950. +// The (unescaped) names appear in `unsorted_str_list` in the QSTR
  10951. +// generator script py/makeqstrdata.py to ensure they are assigned low numbers.
  10952. +static const uint8_t scope_simple_name_table[] = {
  10953. [SCOPE_MODULE] = MP_QSTR__lt_module_gt_,
  10954. [SCOPE_LAMBDA] = MP_QSTR__lt_lambda_gt_,
  10955. [SCOPE_LIST_COMP] = MP_QSTR__lt_listcomp_gt_,
  10956. @@ -111,7 +113,7 @@ id_info_t *scope_find_global(scope_t *scope, qstr qst) {
  10957. return scope_find(scope, qst);
  10958. }
  10959. -STATIC void scope_close_over_in_parents(scope_t *scope, qstr qst) {
  10960. +static void scope_close_over_in_parents(scope_t *scope, qstr qst) {
  10961. assert(scope->parent != NULL); // we should have at least 1 parent
  10962. for (scope_t *s = scope->parent;; s = s->parent) {
  10963. assert(s->parent != NULL); // we should not get to the outer scope
  10964. diff --git a/py/scope.h b/py/scope.h
  10965. index e7d2a304f..927c4a7b9 100644
  10966. --- a/py/scope.h
  10967. +++ b/py/scope.h
  10968. @@ -76,6 +76,9 @@ typedef struct _scope_t {
  10969. struct _scope_t *next;
  10970. mp_parse_node_t pn;
  10971. mp_raw_code_t *raw_code;
  10972. + #if MICROPY_DEBUG_PRINTERS
  10973. + size_t raw_code_data_len; // for mp_bytecode_print
  10974. + #endif
  10975. uint16_t simple_name; // a qstr
  10976. uint16_t scope_flags; // see runtime0.h
  10977. uint16_t emit_options; // see emitglue.h
  10978. diff --git a/py/showbc.c b/py/showbc.c
  10979. index f9c334b93..6913d18c1 100644
  10980. --- a/py/showbc.c
  10981. +++ b/py/showbc.c
  10982. @@ -83,7 +83,7 @@
  10983. DECODE_UINT; \
  10984. unum = (mp_uint_t)obj_table[unum]
  10985. -void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, const mp_module_constants_t *cm) {
  10986. +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) {
  10987. const byte *ip_start = rc->fun_data;
  10988. const byte *ip = rc->fun_data;
  10989. @@ -100,13 +100,13 @@ void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, const m
  10990. qstr source_file = cm->source_file;
  10991. #endif
  10992. mp_printf(print, "File %s, code block '%s' (descriptor: %p, bytecode @%p %u bytes)\n",
  10993. - qstr_str(source_file), qstr_str(block_name), rc, ip_start, (unsigned)rc->fun_data_len);
  10994. + qstr_str(source_file), qstr_str(block_name), rc, ip_start, (unsigned)fun_data_len);
  10995. // raw bytecode dump
  10996. size_t prelude_size = ip - ip_start + n_info + n_cell;
  10997. mp_printf(print, "Raw bytecode (code_info_size=%u, bytecode_size=%u):\n",
  10998. - (unsigned)prelude_size, (unsigned)(rc->fun_data_len - prelude_size));
  10999. - for (size_t i = 0; i < rc->fun_data_len; i++) {
  11000. + (unsigned)prelude_size, (unsigned)(fun_data_len - prelude_size));
  11001. + for (size_t i = 0; i < fun_data_len; i++) {
  11002. if (i > 0 && i % 16 == 0) {
  11003. mp_printf(print, "\n");
  11004. }
  11005. @@ -158,7 +158,7 @@ void mp_bytecode_print(const mp_print_t *print, const mp_raw_code_t *rc, const m
  11006. mp_printf(print, " bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
  11007. }
  11008. }
  11009. - mp_bytecode_print2(print, ip, rc->fun_data_len - prelude_size, rc->children, cm);
  11010. + mp_bytecode_print2(print, ip, fun_data_len - prelude_size, rc->children, cm);
  11011. }
  11012. 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) {
  11013. diff --git a/py/stream.c b/py/stream.c
  11014. index ac0234ac1..d7a8881e1 100644
  11015. --- a/py/stream.c
  11016. +++ b/py/stream.c
  11017. @@ -38,7 +38,7 @@
  11018. // TODO: should be in mpconfig.h
  11019. #define DEFAULT_BUFFER_SIZE 256
  11020. -STATIC mp_obj_t stream_readall(mp_obj_t self_in);
  11021. +static mp_obj_t stream_readall(mp_obj_t self_in);
  11022. // Returns error condition in *errcode, if non-zero, return value is number of bytes written
  11023. // before error condition occurred. If *errcode == 0, returns total bytes written (which will
  11024. @@ -82,6 +82,18 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode
  11025. return done;
  11026. }
  11027. +mp_off_t mp_stream_seek(mp_obj_t stream, mp_off_t offset, int whence, int *errcode) {
  11028. + struct mp_stream_seek_t seek_s;
  11029. + seek_s.offset = offset;
  11030. + seek_s.whence = whence;
  11031. + const mp_stream_p_t *stream_p = mp_get_stream(stream);
  11032. + mp_uint_t res = stream_p->ioctl(MP_OBJ_FROM_PTR(stream), MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, errcode);
  11033. + if (res == MP_STREAM_ERROR) {
  11034. + return (mp_off_t)-1;
  11035. + }
  11036. + return seek_s.offset;
  11037. +}
  11038. +
  11039. const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
  11040. const mp_obj_type_t *type = mp_obj_get_type(self_in);
  11041. if (MP_OBJ_TYPE_HAS_SLOT(type, protocol)) {
  11042. @@ -96,7 +108,7 @@ const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
  11043. mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("stream operation not supported"));
  11044. }
  11045. -STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) {
  11046. +static mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte flags) {
  11047. // What to do if sz < -1? Python docs don't specify this case.
  11048. // CPython does a readall, but here we silently let negatives through,
  11049. // and they will cause a MemoryError.
  11050. @@ -218,12 +230,12 @@ STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte fl
  11051. }
  11052. }
  11053. -STATIC mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) {
  11054. +static mp_obj_t stream_read(size_t n_args, const mp_obj_t *args) {
  11055. return stream_read_generic(n_args, args, MP_STREAM_RW_READ);
  11056. }
  11057. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj, 1, 2, stream_read);
  11058. -STATIC mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) {
  11059. +static mp_obj_t stream_read1(size_t n_args, const mp_obj_t *args) {
  11060. return stream_read_generic(n_args, args, MP_STREAM_RW_READ | MP_STREAM_RW_ONCE);
  11061. }
  11062. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read1_obj, 1, 2, stream_read1);
  11063. @@ -249,7 +261,7 @@ void mp_stream_write_adaptor(void *self, const char *buf, size_t len) {
  11064. mp_stream_write(MP_OBJ_FROM_PTR(self), buf, len, MP_STREAM_RW_WRITE);
  11065. }
  11066. -STATIC mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) {
  11067. +static mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) {
  11068. mp_buffer_info_t bufinfo;
  11069. mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
  11070. size_t max_len = (size_t)-1;
  11071. @@ -268,14 +280,14 @@ STATIC mp_obj_t stream_write_method(size_t n_args, const mp_obj_t *args) {
  11072. }
  11073. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_write_obj, 2, 4, stream_write_method);
  11074. -STATIC mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) {
  11075. +static mp_obj_t stream_write1_method(mp_obj_t self_in, mp_obj_t arg) {
  11076. mp_buffer_info_t bufinfo;
  11077. mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ);
  11078. return mp_stream_write(self_in, bufinfo.buf, bufinfo.len, MP_STREAM_RW_WRITE | MP_STREAM_RW_ONCE);
  11079. }
  11080. MP_DEFINE_CONST_FUN_OBJ_2(mp_stream_write1_obj, stream_write1_method);
  11081. -STATIC mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) {
  11082. +static mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) {
  11083. mp_buffer_info_t bufinfo;
  11084. mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
  11085. @@ -303,7 +315,7 @@ STATIC mp_obj_t stream_readinto(size_t n_args, const mp_obj_t *args) {
  11086. }
  11087. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_readinto_obj, 2, 3, stream_readinto);
  11088. -STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
  11089. +static mp_obj_t stream_readall(mp_obj_t self_in) {
  11090. const mp_stream_p_t *stream_p = mp_get_stream(self_in);
  11091. mp_uint_t total_size = 0;
  11092. @@ -348,7 +360,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
  11093. }
  11094. // Unbuffered, inefficient implementation of readline() for raw I/O files.
  11095. -STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) {
  11096. +static mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args) {
  11097. const mp_stream_p_t *stream_p = mp_get_stream(args[0]);
  11098. mp_int_t max_size = -1;
  11099. @@ -406,7 +418,7 @@ STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args)
  11100. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_unbuffered_readline_obj, 1, 2, stream_unbuffered_readline);
  11101. // TODO take an optional extra argument (what does it do exactly?)
  11102. -STATIC mp_obj_t stream_unbuffered_readlines(mp_obj_t self) {
  11103. +static mp_obj_t stream_unbuffered_readlines(mp_obj_t self) {
  11104. mp_obj_t lines = mp_obj_new_list(0, NULL);
  11105. for (;;) {
  11106. mp_obj_t line = stream_unbuffered_readline(1, &self);
  11107. @@ -438,39 +450,37 @@ mp_obj_t mp_stream_close(mp_obj_t stream) {
  11108. }
  11109. MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_close_obj, mp_stream_close);
  11110. -STATIC mp_obj_t mp_stream___exit__(size_t n_args, const mp_obj_t *args) {
  11111. +static mp_obj_t mp_stream___exit__(size_t n_args, const mp_obj_t *args) {
  11112. (void)n_args;
  11113. return mp_stream_close(args[0]);
  11114. }
  11115. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream___exit___obj, 4, 4, mp_stream___exit__);
  11116. -STATIC mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) {
  11117. - struct mp_stream_seek_t seek_s;
  11118. +static mp_obj_t stream_seek(size_t n_args, const mp_obj_t *args) {
  11119. // TODO: Could be uint64
  11120. - seek_s.offset = mp_obj_get_int(args[1]);
  11121. - seek_s.whence = SEEK_SET;
  11122. + mp_off_t offset = mp_obj_get_int(args[1]);
  11123. + int whence = SEEK_SET;
  11124. if (n_args == 3) {
  11125. - seek_s.whence = mp_obj_get_int(args[2]);
  11126. + whence = mp_obj_get_int(args[2]);
  11127. }
  11128. // In POSIX, it's error to seek before end of stream, we enforce it here.
  11129. - if (seek_s.whence == SEEK_SET && seek_s.offset < 0) {
  11130. + if (whence == SEEK_SET && offset < 0) {
  11131. mp_raise_OSError(MP_EINVAL);
  11132. }
  11133. - const mp_stream_p_t *stream_p = mp_get_stream(args[0]);
  11134. int error;
  11135. - mp_uint_t res = stream_p->ioctl(args[0], MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error);
  11136. - if (res == MP_STREAM_ERROR) {
  11137. + mp_off_t res = mp_stream_seek(args[0], offset, whence, &error);
  11138. + if (res == (mp_off_t)-1) {
  11139. mp_raise_OSError(error);
  11140. }
  11141. // TODO: Could be uint64
  11142. - return mp_obj_new_int_from_uint(seek_s.offset);
  11143. + return mp_obj_new_int_from_uint(res);
  11144. }
  11145. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_seek_obj, 2, 3, stream_seek);
  11146. -STATIC mp_obj_t stream_tell(mp_obj_t self) {
  11147. +static mp_obj_t stream_tell(mp_obj_t self) {
  11148. mp_obj_t offset = MP_OBJ_NEW_SMALL_INT(0);
  11149. mp_obj_t whence = MP_OBJ_NEW_SMALL_INT(SEEK_CUR);
  11150. const mp_obj_t args[3] = {self, offset, whence};
  11151. @@ -478,7 +488,7 @@ STATIC mp_obj_t stream_tell(mp_obj_t self) {
  11152. }
  11153. MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_tell_obj, stream_tell);
  11154. -STATIC mp_obj_t stream_flush(mp_obj_t self) {
  11155. +static mp_obj_t stream_flush(mp_obj_t self) {
  11156. const mp_stream_p_t *stream_p = mp_get_stream(self);
  11157. int error;
  11158. mp_uint_t res = stream_p->ioctl(self, MP_STREAM_FLUSH, 0, &error);
  11159. @@ -489,7 +499,7 @@ STATIC mp_obj_t stream_flush(mp_obj_t self) {
  11160. }
  11161. MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_flush_obj, stream_flush);
  11162. -STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
  11163. +static mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
  11164. mp_buffer_info_t bufinfo;
  11165. uintptr_t val = 0;
  11166. if (n_args > 2) {
  11167. @@ -545,16 +555,11 @@ ssize_t mp_stream_posix_read(void *stream, void *buf, size_t len) {
  11168. }
  11169. off_t mp_stream_posix_lseek(void *stream, off_t offset, int whence) {
  11170. - const mp_obj_base_t *o = stream;
  11171. - const mp_stream_p_t *stream_p = MP_OBJ_TYPE_GET_SLOT(o->type, protocol);
  11172. - struct mp_stream_seek_t seek_s;
  11173. - seek_s.offset = offset;
  11174. - seek_s.whence = whence;
  11175. - mp_uint_t res = stream_p->ioctl(MP_OBJ_FROM_PTR(stream), MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &errno);
  11176. - if (res == MP_STREAM_ERROR) {
  11177. + mp_off_t res = mp_stream_seek(MP_OBJ_FROM_PTR(stream), offset, whence, &errno);
  11178. + if (res == (mp_off_t)-1) {
  11179. return -1;
  11180. }
  11181. - return seek_s.offset;
  11182. + return res;
  11183. }
  11184. int mp_stream_posix_fsync(void *stream) {
  11185. diff --git a/py/stream.h b/py/stream.h
  11186. index e6e6f283d..7c4d38afa 100644
  11187. --- a/py/stream.h
  11188. +++ b/py/stream.h
  11189. @@ -115,6 +115,7 @@ mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte fla
  11190. mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags);
  11191. #define mp_stream_write_exactly(stream, buf, size, err) mp_stream_rw(stream, (byte *)buf, size, err, MP_STREAM_RW_WRITE)
  11192. #define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ)
  11193. +mp_off_t mp_stream_seek(mp_obj_t stream, mp_off_t offset, int whence, int *errcode);
  11194. void mp_stream_write_adaptor(void *self, const char *buf, size_t len);
  11195. diff --git a/py/unicode.c b/py/unicode.c
  11196. index 5acaad378..81a37880f 100644
  11197. --- a/py/unicode.c
  11198. +++ b/py/unicode.c
  11199. @@ -48,7 +48,7 @@
  11200. #define AT_LX (FL_LOWER | FL_ALPHA | FL_PRINT | FL_XDIGIT)
  11201. // table of attributes for ascii characters
  11202. -STATIC const uint8_t attr[] = {
  11203. +static const uint8_t attr[] = {
  11204. 0, 0, 0, 0, 0, 0, 0, 0,
  11205. 0, AT_SP, AT_SP, AT_SP, AT_SP, AT_SP, 0, 0,
  11206. 0, 0, 0, 0, 0, 0, 0, 0,
  11207. diff --git a/py/vm.c b/py/vm.c
  11208. index a7902d927..f87e52c92 100644
  11209. --- a/py/vm.c
  11210. +++ b/py/vm.c
  11211. @@ -893,7 +893,7 @@ unwind_jump:;
  11212. ENTRY(MP_BC_MAKE_FUNCTION): {
  11213. DECODE_PTR;
  11214. - PUSH(mp_make_function_from_raw_code(ptr, code_state->fun_bc->context, NULL));
  11215. + PUSH(mp_make_function_from_proto_fun(ptr, code_state->fun_bc->context, NULL));
  11216. DISPATCH();
  11217. }
  11218. @@ -901,7 +901,7 @@ unwind_jump:;
  11219. DECODE_PTR;
  11220. // Stack layout: def_tuple def_dict <- TOS
  11221. sp -= 1;
  11222. - SET_TOP(mp_make_function_from_raw_code(ptr, code_state->fun_bc->context, sp));
  11223. + SET_TOP(mp_make_function_from_proto_fun(ptr, code_state->fun_bc->context, sp));
  11224. DISPATCH();
  11225. }
  11226. @@ -910,7 +910,7 @@ unwind_jump:;
  11227. size_t n_closed_over = *ip++;
  11228. // Stack layout: closed_overs <- TOS
  11229. sp -= n_closed_over - 1;
  11230. - SET_TOP(mp_make_closure_from_raw_code(ptr, code_state->fun_bc->context, n_closed_over, sp));
  11231. + SET_TOP(mp_make_closure_from_proto_fun(ptr, code_state->fun_bc->context, n_closed_over, sp));
  11232. DISPATCH();
  11233. }
  11234. @@ -919,7 +919,7 @@ unwind_jump:;
  11235. size_t n_closed_over = *ip++;
  11236. // Stack layout: def_tuple def_dict closed_overs <- TOS
  11237. sp -= 2 + n_closed_over - 1;
  11238. - SET_TOP(mp_make_closure_from_raw_code(ptr, code_state->fun_bc->context, 0x100 | n_closed_over, sp));
  11239. + SET_TOP(mp_make_closure_from_proto_fun(ptr, code_state->fun_bc->context, 0x100 | n_closed_over, sp));
  11240. DISPATCH();
  11241. }
  11242. diff --git a/py/vstr.c b/py/vstr.c
  11243. index 56327b5f7..fc55d6948 100644
  11244. --- a/py/vstr.c
  11245. +++ b/py/vstr.c
  11246. @@ -104,7 +104,7 @@ char *vstr_extend(vstr_t *vstr, size_t size) {
  11247. return p;
  11248. }
  11249. -STATIC void vstr_ensure_extra(vstr_t *vstr, size_t size) {
  11250. +static void vstr_ensure_extra(vstr_t *vstr, size_t size) {
  11251. if (vstr->len + size > vstr->alloc) {
  11252. if (vstr->fixed_buf) {
  11253. // We can't reallocate, and the caller is expecting the space to
  11254. @@ -183,7 +183,7 @@ void vstr_add_strn(vstr_t *vstr, const char *str, size_t len) {
  11255. vstr->len += len;
  11256. }
  11257. -STATIC char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) {
  11258. +static char *vstr_ins_blank_bytes(vstr_t *vstr, size_t byte_pos, size_t byte_len) {
  11259. size_t l = vstr->len;
  11260. if (byte_pos > l) {
  11261. byte_pos = l;
  11262. diff --git a/shared/runtime/gchelper_generic.c b/shared/runtime/gchelper_generic.c
  11263. index 272e37056..4ef2e73f7 100644
  11264. --- a/shared/runtime/gchelper_generic.c
  11265. +++ b/shared/runtime/gchelper_generic.c
  11266. @@ -42,7 +42,7 @@
  11267. // stack already by the caller.
  11268. #if defined(__x86_64__)
  11269. -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11270. +static void gc_helper_get_regs(gc_helper_regs_t arr) {
  11271. register long rbx asm ("rbx");
  11272. register long rbp asm ("rbp");
  11273. register long r12 asm ("r12");
  11274. @@ -73,7 +73,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11275. #elif defined(__i386__)
  11276. -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11277. +static void gc_helper_get_regs(gc_helper_regs_t arr) {
  11278. register long ebx asm ("ebx");
  11279. register long esi asm ("esi");
  11280. register long edi asm ("edi");
  11281. @@ -100,7 +100,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11282. // Fallback implementation, prefer gchelper_thumb1.s or gchelper_thumb2.s
  11283. -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11284. +static void gc_helper_get_regs(gc_helper_regs_t arr) {
  11285. register long r4 asm ("r4");
  11286. register long r5 asm ("r5");
  11287. register long r6 asm ("r6");
  11288. @@ -125,7 +125,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11289. #elif defined(__aarch64__)
  11290. -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11291. +static void gc_helper_get_regs(gc_helper_regs_t arr) {
  11292. const register long x19 asm ("x19");
  11293. const register long x20 asm ("x20");
  11294. const register long x21 asm ("x21");
  11295. @@ -161,7 +161,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11296. // Even if we have specific support for an architecture, it is
  11297. // possible to force use of setjmp-based implementation.
  11298. -STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
  11299. +static void gc_helper_get_regs(gc_helper_regs_t arr) {
  11300. setjmp(arr);
  11301. }