mbc4.bas 345 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547
  1. '******************************************************************************
  2. '******************************************************************************
  3. ' BCX Universal - The Cross Platform Basic To C/C++ Translator Version 2.0d
  4. '******************************************************************************
  5. ' (c) 1999 - 2009 Kevin Diggins
  6. '******************************************************************************
  7. '********************************
  8. '** OSX 10.5+ UNIVERSAL BINARY **
  9. '********************************
  10. '$OSX
  11. '*****************
  12. '** GTK Support **
  13. '*****************
  14. '$GTK
  15. '*****************
  16. '** GLIB Support *
  17. '*****************
  18. '$GLIB
  19. '****************************
  20. '** WX WIDGETS GUI SUPPORT **
  21. '****************************
  22. '$WX
  23. '********************************
  24. '** WX WIDGETS CONSOLE SUPPORT **
  25. '********************************
  26. '$WXC
  27. '***********************
  28. '** Apple IOS SUPPORT **
  29. '***********************
  30. '$IOS
  31. '**********************************
  32. '** AUTO BUILD TRANSLATOR BINARY **
  33. '**********************************
  34. $EXECON
  35. '**********************
  36. '** STRIP EXECUTABLE **
  37. '**********************
  38. ' $EXESTRIP
  39. '
  40. CONST Version$ = "4.0-Beta3 (2018/12/09)" 'BCX version number and date (YYYY/MM/DD)
  41. '*******************************************************************************
  42. '
  43. 'BCX is distributed under the terms of the GNU General Public License Ver.(2).
  44. 'The complete source code that is PRODUCED BY BCX is subject to a License
  45. 'Exception to the GPL, which allows you to produce commercial applications.
  46. '
  47. '******************************************************************************
  48. ' BCX LICENSE EXCEPTION
  49. '******************************************************************************
  50. '
  51. 'As a special exception, the BCX license gives permission for additional uses
  52. 'of the text contained in its release of BCX. The exception is that, if you use
  53. 'BCX to create source code that will link the BCX libraries with other files to
  54. 'produce an executable, this does not by itself cause the resulting executable
  55. 'to be covered by the GNU GPL. Your use of that executable is in no way
  56. 'restricted on account of using BCX to produce source code that will link the
  57. 'BCX library code into it.
  58. '
  59. 'This exception does not invalidate any other reasons why the executable file
  60. 'might be covered by the GNU General Public License. This exception applies
  61. 'only to the code released with this BCX explicit exception. If you add or copy
  62. 'code from other sources, as the General Public License permits, the above
  63. 'exception does not apply to the code that you add in this way.
  64. '
  65. 'To avoid misleading anyone as to the status of such modified files, you must
  66. 'delete this exception notice from them. If you write modifications of your
  67. 'own for BCX, it is your choice whether to permit this exception to apply to
  68. 'your modifications.
  69. 'This program is distributed in the hope that it will be useful, but WITHOUT
  70. 'ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
  71. 'FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  72. '
  73. ' You should have received a copy of the GNU General Public License along with
  74. ' this program; if not, write to the Free Software Foundation, Inc.,
  75. '59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or visit
  76. 'http://www.gnu.org/copyleft/gpl.html#SEC1
  77. $COMMENT - Comment section added 10/20/2004 05:00AM by Vic McClung
  78. *******************************************************************************
  79. Developer Guidelines
  80. *******************************************************************************
  81. Code should be written in BCX Basic. If it can not be written in BCX Basic for
  82. some reason or results in code that seems too inefficient then this may be a
  83. cue that a new Basic function is needed.
  84. * All KEYWORDS should be capitalized
  85. * Use two space indentation
  86. * Use spaces not tabs
  87. * Record all notes in reverse chronological order
  88. * And most importantly....Have fun!
  89. ******************************************************************************************
  90. This section is used to communicate to-do 's, changes, ideas, suggestions, etc.
  91. ******************************************************************************************
  92. -------------------------------------------
  93. 2018-12-12 Armando Rivera
  94. * Changed BcxRegEx function to REGMATCH
  95. * Changed BcxRegEx keyword to REGMATCH
  96. * Added $MODULE as alias to $INCLUDE to support external modules. ** MUST BE AT TOP OF MAIN SOURCE FILE **
  97. * Added $LDFLAGS directive to support external modules
  98. -------------------------------------------
  99. -------------------------------------------
  100. 2016-02-15 Armando Rivera
  101. -------------------------------------------
  102. * Changed default string size to 65K from
  103. 2k, which was limiting.
  104. * Updated output of PRINT command, eliminating
  105. leading spaces from numbers.
  106. -------------------------------------------
  107. 2015-07-03 Armando Rivera
  108. -------------------------------------------
  109. * Changed $OSX flag to use Cocoa instead of Carbon in MacOS
  110. This is in preparation of the new custom libcocoa library
  111. that I'm currently creating that will allow mbc
  112. to create 64bit GUI applications in OSX
  113. -------------------------------------------
  114. 2013-06-26 Armando Rivera
  115. -------------------------------------------
  116. * Added BcxRegex keyword, based on Posix Regex in Libc
  117. * Broke up main source file into files containing Runtime, Declarations, etc.
  118. * Added BYTE type
  119. -------------------------------------------
  120. 2013-06-17 Armando Rivera
  121. -------------------------------------------
  122. * Tweaked HEX$ so that it will emit 2-digit hex numbers
  123. * Added PUCHAR (unsigned char*) typedef
  124. -------------------------------------------
  125. 2011-03-11 Armando Rivera
  126. -------------------------------------------
  127. * Added Wayne's suggestion to support Reference Variables as return types.
  128. -------------------------------------------
  129. 2011-03-10 Armando Rivera
  130. -------------------------------------------
  131. * Ported $PROJECT directive from ConsoleBC. This doesn't emit the RTL yet, but it's a start.
  132. It's the first step towards re-writing the RT code to leverage CPP/WX.
  133. * Fixed bug where BCX_TmpStr sometimes wasn't emitted when returning a string from a function
  134. * Added Named Enum support. Syntax:
  135. myenum AS ENUM
  136. END ENUM
  137. This required moving the Enum emit code to before the User Prototype emit code
  138. to allow passing the named enum to user defined functions.
  139. -------------------------------------------
  140. 2011-01-23 Armando Rivera
  141. -------------------------------------------
  142. * Initial Beta1 Release
  143. * Fixed bug in INPUT statement to remove trailing newlines (James Fuller)
  144. * Removed COLOR statements to avoid terminal output issues with redirected
  145. translator output (James Fuller)
  146. * Added CONST keyword when declaring variables (Global, Local, and as Function/Sub parameters)
  147. At the moment, this is experimental (meaning I haven't fully tested it) but it seems to work
  148. * Added PRIVATE keyword for CPP classes
  149. -------------------------------------------
  150. 2010/12/21 Armando Rivera
  151. -------------------------------------------
  152. * Cleaned up code emission so that unneeded defines/global vars are not emitted
  153. * Added new $IOS directive, which is MAC ONLY, to compile source for iDevices (iPhone/iTouch/AppleTV2)
  154. At this point in time, running binaries built this way requires a jailbroken iDevice.
  155. This is experimental, and for console apps only for now.
  156. A simple console example is in the Examples/IOS folder
  157. -------------------------------------------
  158. 2010/12/11 Armando Rivera
  159. -------------------------------------------
  160. * Add new Socket keywords: BcxSocket, BcxSocketSend, BcxSocketRead, and BcxSocketClose
  161. See the BcxSocket.bas demo in the Examples/Socket folder for info.
  162. * Added kbhit() , which doesn't exist outside of Windows
  163. This is a custom sub which emulates what kbhit() does
  164. * Changed the conditional emission of term.h to only be emitted when
  165. Use_Keypress is TRUE (InKey)
  166. -------------------------------------------
  167. 2010/12/01 Armando Rivera
  168. -------------------------------------------
  169. * Changed wxApp emission to use BCXPLITHPATH$, per James Fuller's suggestion.
  170. * Added support for Abstract Classes (gcc doesn't have the INTERFACE keyword)
  171. Example:
  172. Class MyAbstractClass
  173. public
  174. virtual sub Proc1() = 0
  175. Virtual sub Proc2()=0
  176. virtual function Proc3(a$,b$) as integer = 0
  177. End Class
  178. -------------------------------------------
  179. 2010/11/30 Armando Rivera
  180. -------------------------------------------
  181. * Removed $CLASS/$ENDCLASS $NAMESPACE/$ENDNAMESPACE
  182. Using either will emit a message stating that they have been replaced.
  183. * Addded NAMESPACE / END NAMESPACE
  184. This allows creating methods within the NAMESPACE like so:
  185. $CPP
  186. $NOMAIN
  187. $EXECON
  188. '==============================================================================
  189. NAMESPACE Dlg_01
  190. Sub DoIt()
  191. Print "Dlg_01"
  192. End Sub
  193. Function GetString$(A$) as string
  194. function = "The String you Passed Was: " + enc$(A$)
  195. end function
  196. END NAMESPACE
  197. '==============================================================================
  198. Function main(argc as INTEGER, argv as PCHAR ptr) as INTEGER
  199. Print "James"
  200. Dlg_01::DoIt()
  201. print Dlg_01::GetString$("Hello, World!")
  202. End Function
  203. * If using $WX, the #define for Clear() will not be emitted due to conflict
  204. with Classes that have that method defined
  205. * Made the inclusion of "term.h" conditional based on whether $WX/$WXC
  206. is used. "term.h" is required for the implementation of
  207. the PAUSE keyword in CONSOLE apps.
  208. -------------------------------------------
  209. 2010/11/25 Armando Rivera
  210. -------------------------------------------
  211. * Changed code so that in $CPP mode, the case of the emitted
  212. .cpp filename is preserved (James Fuller bug report)
  213. -------------------------------------------
  214. 2010/11/24 Armando Rivera
  215. -------------------------------------------
  216. * Minor change in StripCode() to correct
  217. possible overflow issue under 64bit Linux (James Fuller bug report)
  218. * Added $WXC Directive to support WX Console-Based Apps
  219. Using this switch, neither a wxApp or the IMPLEMENT_APP() macro are
  220. auto added to the translated source (James Fuller request)
  221. -------------------------------------------
  222. 2010/11/20 Armando Rivera
  223. -------------------------------------------
  224. * Changed $DLL directive so that it would generate *nix Shared Libraries.
  225. * Added $DLL support to $EXECON
  226. * Added required flags to LD_FLAGS$ for creating *nix Shared Libraries
  227. Example:
  228. $dll
  229. $execon
  230. function printdemo() export
  231. print "This was called from a Dynamic Library"
  232. end function
  233. Note that this is currently only useful for creating shared libraries
  234. for **OTHER** languages; it won't work with MBC created apps because of
  235. duplicate naming conflicts.
  236. -------------------------------------------
  237. 2010/11/18 Armando Rivera
  238. -------------------------------------------
  239. * Removed "-Os" compiler optimization flag from $EXECON for fastest tranlator compliation
  240. during Alpha testing stage.
  241. This will be re-added when translator is not longer in Alpha status
  242. * Added USE_CTOR global as flag for supporting Constructor/Destructor syntax
  243. * Added "USING" keyword for CONSTRUCTOR/DESTRUCTOR methods. It is used like this:
  244. CONSTRUCTOR MainWin::MainWin(title as wxString, winStyle as long) USING wxFrame( 0, -1, title, wxPoint(50,50), wxSize(490,296), winStyle )
  245. Which will emit:
  246. MainWin::MainWin (wxString title, long winStyle)
  247. : wxFrame( 0, -1, title, wxPoint(50,50), wxSize(490,296), winStyle )
  248. {
  249. * Added code to extract and emit derived class methods
  250. -------------------------------------------
  251. 2010/11/17 Armando Rivera
  252. -------------------------------------------
  253. * Added new CLASS / END CLASS / PUBLIC / PROTECTED / CONSTRUCTOR / DESTRUCTOR keywords.
  254. These additions flesh out Basic-Like C++ CLASS support, superceding $CLASS/$ENDCLASS,
  255. and now allows syntax like the following:
  256. $CPP
  257. $NOMAIN
  258. $execon
  259. class MyClass
  260. protected
  261. first as string
  262. secnd$
  263. third%
  264. public
  265. type ATest
  266. a as PCHAR
  267. b as long
  268. c as single
  269. d as float
  270. end type
  271. Constructor MyClass(a$, b)
  272. Destructor MyClass()
  273. end class
  274. FUNCTION main(argc as INTEGER, argv as PCHAR ptr) as INTEGER
  275. RAW theClass as MyClass PTR
  276. theClass = new MyClass("Hello", 12)
  277. print (char*)theClass->ATest.a
  278. print theClass->ATest.b
  279. END FUNCTION
  280. Constructor MyClass::MyClass(a$,b)
  281. ATest.a = a$
  282. ATest.b = b
  283. END Constructor
  284. '
  285. Destructor MyClass::~MyClass()
  286. END Destructor
  287. -------------------------------------------
  288. 2010/11/12 Armando Rivera
  289. -------------------------------------------
  290. * Added code that (mostly) eliminates the need for a trailing ";" in $class/$endclass
  291. * Added code to allow the use of "SUB" in $class/$endclass. It just substitutes "void" for "sub"
  292. at this point.
  293. * Fixed "THIS" keyword code so that it emits a lowercase "this". Linux/OSX aren't affected
  294. by this breaking COM statements. :-P Thanks to JCFULLER for the tip!
  295. * For $CPP mode, added typedefs for std::string (CSTRING) and std::fstream (CFILE)
  296. These are direct replacements for STRING and FILE, and allows the full use of each
  297. C++ object/class.
  298. So instead of "dim mystring as string", for example, you would do "dim mystring as CSTRING".
  299. You would then have access to all of std::string's methods like .replace, .substr, .compare, etc.
  300. I'm considering doing the same with the other toolkit directives ($OSX, $GTK, etc) but we'll see...
  301. * Added "inherits" in $CPP mode so that subclassing can be done like so:
  302. $class MyClass inherits AnotherClass
  303. * For $WX mode, added code to automatically emit the required derived wxApp class.
  304. Note that it will be named the same as your sourcefile (minus the extension), and you MUST provide
  305. a "FUNCTION ::OnInit() as bool" for it:
  306. FUNCTION TestApp::OnInit() as bool
  307. <initialize app here>
  308. END FUNCTION
  309. * For $WX mode, made "$NOMAIN" the default, so no need to pass that directive
  310. * Colorized some of the compiler output text. Just because I can.
  311. * Back-ported Wayne's changes to "WITH" to allow the use of "->" syntax
  312. * TODO:
  313. Finish off the $class/$endclass code to allow full basic syntax for method and variable
  314. declarations.
  315. Remove ALL remaining WIN32 related code and ifdefs.
  316. No need for that stuff under Linux/OSX, the Windows version of BCX can handle all
  317. of the Windows stuff one might need.
  318. Other stuff I can't remember right now…..
  319. -------------------------------------------
  320. 2010/03/31 Armando Rivera
  321. Beginning with this version of the console compiler,
  322. the goal is to have a 100% unified code-base, because
  323. I'm fracking tired of trying to maintain separate builds
  324. for different Operating Systems.
  325. -------------------------------------------
  326. * Added $OSX, $GTK¸$GLIB and $WX Directives
  327. (Use_Osx, Use_Wx, Use_Gtk, Use_Glib and LD_FLAGS$ Globals added)
  328. $OSX will automatically enable Carbon GUI support, and if $EXECON is invoked
  329. will also build a Universal Binary with 32bit and 64bit support
  330. $GTK will automatically enable GTK/GLIB support, and if $EXECON is invoked
  331. will build the executable linking in libgtk and it's support libraries.
  332. $GLIB will automatically enable >GLIB ONLY< support, and if $EXECON is invoked
  333. will build the executable linking in libglib and it's support libraries.
  334. $WX will automatically enable wxWidgets with $CPP set to "TRUE", and if $EXECON
  335. is invoked will build the executable linking in libwx and it's support libraries
  336. This is, in part, in preparation for moving the GTK support from the core of the
  337. LinuxBC translator to an external library which will be linked in as required. This
  338. will GREATLY simplify maintenence of the translator core once the lib is ready.
  339. * Changed alls instances of byte* to UCHAR* in SWAP() Function
  340. * Added internal return values for PUT/GET to get rid of ALL compiler warnings.
  341. * Updated runtime functions calling PUT()/GET()/fread()/fwrite so that they
  342. will not trigger compiler warnings
  343. * Reworked the way functions declared using C_DECLARE with the LIB and ALIAS keywords
  344. are emitted. This is so that you can dynamically load functions from a shared
  345. library at runtime via dlopen/dlsym.
  346. The syntax is:
  347. C_DECLARE FUNCTION <YOUR FUNCTION NAME> LIB <shared library> ALIAS <quoted name of actual function (<parameters>) AS <return type>
  348. For example:
  349. C_DECLARE FUNCTION b64encode LIB "libglib-2.0.so" ALIAS "g_base64_encode" (txt AS char*, length AS integer) AS string
  350. C_DECLARE FUNCTION g_base64_decode LIB "libglib-2.0.so" ALIAS "g_base64_decode" (txt AS char*, length AS INTEGER PTR) AS string
  351. NOTE that the ALIAS is the actual name of the function you want to call from the shared library.
  352. This is so you avoid redeclaration errors if you attempt to link to a library (libm is a good example)
  353. that is already compile-time linked with g++.
  354. NOTE 2: There is currently no checking whether the function was loaded without error. It is on the TODO list.
  355. * Changed compiler invocation to include -Wformat and -D_FORTIFY_SOURCE=2 (Ubuntu Standard)
  356. * Fixed User Include File handling in order to support mixed case filenames
  357. * Updated the CURDIR$, TEMPDIR$, AND SHELL code to eliminate warnings emitted when compiling on
  358. a system that has "_FORTIFY_SOURCE=2" enabled by default in GCC/G++ (Ubuntu)
  359. * Fixed a potential overflow problem with LINE INPUT that would also cause G++ to emit
  360. warnings as above.
  361. *Re-coded the $RESOURCE directive and the GETRESOURCE$ function to allow
  362. linking of Resources under Linux/Unix. Using $RESOURCE generates a #define
  363. allowing you to reference the embedded resource using an arbitrary IDENTIFIER.
  364. For example:
  365. DIRECTIVE FILE IDENTIFIER
  366. -------------------------------
  367. $RESOURCE "file.txt" "myres"
  368. Note that you reference the resource using the identifier you passed as the
  369. SECOND parameter to the $RESOURCE directive, minus the quotes.
  370. "file.txt" above can be any arbitrary file on one's system
  371. At the moment, the resource is returned as a string with the GETRESOURCE$ function.
  372. *****************************************************************************************************
  373. ** YOU WILL HAVE TO ENSURE THAT A BUFFER WITH ENOUGH SPACE TO HOLD THE RESOURCE HAS BEEN ALLOCATED **
  374. *****************************************************************************************************
  375. To aid in this, a constant is automatically created with the size of the resource. It will have the
  376. name you specified as the second parameter to $RESOURCE, with _SIZE appended.
  377. Using the example above, the constant would be defined as: myres_SIZE
  378. You should be able to manually cast the reference *itself* to what you require, since it is
  379. merely a pointer to the location of the resource itself.
  380. The resource will be converted to an object file, named using the filename provided with ".o" apppended.
  381. "file.txt" will be converted to "file.txt.o" in the above example, which can then be linked
  382. to the final executable via $EXECON "file.txt.o" or $EXEGUI "file.txt.o"
  383. * Tweaked $GUI directive and GUI keyword so that one can use the directive without
  384. having all of the support for BCX_* form objects automatically added to one's app.
  385. This is usefull when using GtkBuilder or Glade to build the user interface.
  386. -------------------------------------------
  387. 2010-01-17 Armando Rivera
  388. -------------------------------------------
  389. modified the $CLASS/$ENDCLASS directives to allow creation and inheritance of C++ Classes
  390. modified the Function/Sub prototype emitter so that it would not emit prototypes
  391. for C++ Class Methods, which are supposed to be prototyped within the Class itself
  392. made the inclusion of <term.h> conditional based on whether UseCPP is true/false
  393. it will not be included if UseCpp is "true" because some C++ toolkits (wxWidgets)
  394. throw a "redefined" error when it's included
  395. -------------------------------------------
  396. 2010-01-15 Armando Rivera
  397. -------------------------------------------
  398. per wmhalsdorf's recommendation, modified SplitLines and Emit procs to support
  399. C++ Method syntax (CLASSNAME::METHOD) [see Yahoo group Message #40282]
  400. -------------------------------------------
  401. 2010-01-10 Armando Rivera
  402. -------------------------------------------
  403. changed $CPP directive to output lowercase filenames
  404. -------------------------------------------
  405. 2009-10-18 Armando Rivera
  406. -------------------------------------------
  407. added Carbon.h as a default include, to support Carbon/CoreFoundation calls
  408. added Carbon framework to $execon section
  409. removed TRUE and FALSE defines, which are now provided by Carbon.h
  410. changed Handle$ to Handl$ to resolve conflict with Carbon.h
  411. -------------------------------------------
  412. 2009-10-13 Armando Rivera
  413. -------------------------------------------
  414. added typedef for "byte" type (typedef unsigned char byte;)
  415. $COMMENT ================== END OF COMMENT SECTION ============================
  416. CONST __BCX__ = 1 ' define BCX so we know we are in bc.bas
  417. $NOMAIN
  418. $GENFREE
  419. $IPRINT_OFF
  420. $NOINI
  421. $TURBO
  422. $HEADER
  423. typedef long (*CPP_FARPROC)(char *);
  424. $HEADER
  425. ENUM
  426. vt_UNKNOWN ' Not a Variable
  427. vt_STRLIT ' "Quoted String Literal"
  428. vt_INTEGER ' Integer%
  429. vt_SINGLE ' Single!
  430. vt_DOUBLE ' Double#
  431. vt_LDOUBLE ' Long Double¦
  432. VT_LLONG ' Long Long
  433. vt_STRVAR ' StringVariable$
  434. vt_DECFUNC ' Translated Decimal Func: Strlen,Asin
  435. vt_NUMBER ' A Pure Literal Number
  436. vt_FILEPTR ' @ FILE*
  437. vt_UDT ' User ( or Windows ) Defined Type
  438. vt_STRUCT ' Structures
  439. vt_UNION ' Unions
  440. vt_BOOL
  441. vt_CHAR
  442. vt_LPSTRPTR
  443. vt_PCHAR
  444. vt_CHARPTR
  445. vt_VOID
  446. vt_LONG
  447. vt_DWORD
  448. vt_FARPROC
  449. vt_LPBYTE
  450. vt_LRESULT
  451. vt_BYTE
  452. vt_SHORT
  453. vt_USHORT
  454. vt_UINT
  455. vt_ULONG
  456. vt_HWND
  457. vt_HDC
  458. vt_COLORREF
  459. vt_HANDLE
  460. vt_HINSTANCE
  461. vt_WNDCLASSEX
  462. vt_HFONT
  463. vt_VARIANT
  464. END ENUM
  465. '*********************************
  466. CONST vt_VarMin = 2
  467. CONST vt_VarMax = vt_VARIANT
  468. '*********************************
  469. ENUM
  470. mt_ProcessSetCommand
  471. mt_FuncSubDecC_Dec
  472. mt_FuncSubDecC_Dec2
  473. mt_Opts
  474. mt_Opts2
  475. mt_Opts3
  476. mt_OverLoad
  477. mt_OverLoad2
  478. mt_FuncSubx1
  479. mt_FuncSubx2
  480. END ENUM
  481. CONST fprintf = ReDirectFPrint
  482. '******************************
  483. ' User Defined Type Support
  484. '******************************
  485. CONST MaxElements = 128
  486. CONST MaxTypes = 512
  487. CONST MaxLocalVars = 512
  488. CONST MaxGlobalVars = 4096 'max size 233000
  489. '******************************
  490. ' Library Support
  491. '******************************
  492. CONST MaxLib = 64 ' max no of libraries
  493. '***********************
  494. ' Bracket Handling
  495. '***********************
  496. CONST c_SglQt = 39
  497. CONST c_DblQt = 34
  498. CONST c_LPar = 40
  499. CONST c_RPar = 41
  500. CONST c_Komma = 44
  501. CONST c_LtBkt = 91
  502. CONST c_RtBkt = 93
  503. '**************************************************************
  504. ' Runtime Library support
  505. ' These are used to keep Modifiers of BCX source code
  506. ' from accidently changing certain output lines of
  507. ' code that are used by the $PROJECT/Library code
  508. '**************************************************************
  509. CONST BCX_STR_RUNTIME = "Runtime Functions"
  510. CONST BCX_STR_MAIN_PROG = "Main Program"
  511. CONST BCX_STR_SYS_VARS = "System Variables"
  512. CONST BCX_STR_STD_MACROS = "Standard Macros"
  513. CONST BCX_STR_STD_PROTOS = "Standard Prototypes"
  514. CONST BCX_STR_USR_PROCS = "User Subs and Functions"
  515. CONST BCX_STR_USR_VARS = "User Global Variables"
  516. CONST BCX_STR_USR_PROTOS = "User Prototypes"
  517. CONST BCX_STR_USR_CONST = "User Defined Constants"
  518. CONST BCX_STR_USR_TYPES = "User Defined Types, Classes (CPP Mode), And Unions"
  519. '**************************************************************
  520. TYPE functionParse
  521. NumArgs
  522. CommaPos[128]
  523. END TYPE
  524. '**************************************************************
  525. ' These need to always stay in sync
  526. '**************************************************************
  527. CONST VarTypes$ = "%$#!@¦"
  528. SET VarTypeLookup[] AS CHAR PTR
  529. "int", "int", "char *", "double", "float", "FILE *", "long double"
  530. END SET
  531. '**************************************************************
  532. TYPE ARGTYPE
  533. Arg$
  534. ArgType
  535. END TYPE
  536. TYPE ProtoStore
  537. Prototype$[2048] AS CHAR
  538. Condition$[512] AS CHAR
  539. CondLevel AS INTEGER
  540. END TYPE
  541. TYPE Element
  542. ElementType AS INTEGER
  543. ElementID AS INTEGER
  544. ElementDynaPtr AS INTEGER
  545. ElementName$[64] AS CHAR
  546. END TYPE
  547. TYPE UserTypeDefs
  548. TypeofDef AS INTEGER
  549. EleCnt AS INTEGER
  550. Elements[MaxElements] AS Element
  551. VarName$[64] AS CHAR
  552. END TYPE
  553. TYPE VarInfo
  554. VarLine AS INTEGER
  555. VarType AS INTEGER
  556. VarDef AS INTEGER
  557. VarPntr AS INTEGER
  558. VarSF AS INTEGER
  559. VarExtn AS INTEGER
  560. VarCondLevel AS INTEGER
  561. VarEmitFlag AS INTEGER
  562. VarConstant AS INTEGER
  563. VarName$[64] AS CHAR
  564. VarDim$[128] AS CHAR
  565. VarModule[300] AS CHAR
  566. VarCondDef[128] AS CHAR
  567. END TYPE
  568. TYPE VARCODE
  569. VarNo AS INTEGER
  570. Method AS INTEGER
  571. IsPtrFlag AS INTEGER
  572. Header$
  573. Proto$
  574. Functype$
  575. StaticOut$
  576. Token$
  577. AsToken$
  578. END TYPE
  579. '*************************************************************************
  580. ' GLOBAL VARIABLES
  581. '*************************************************************************
  582. GLOBAL NoRT
  583. GLOBAL ByrefVars$[1024]
  584. GLOBAL ByrefCnt
  585. GLOBAL CurLine$
  586. GLOBAL gLinesWritten
  587. GLOBAL LoopLocalVar[256]
  588. GLOBAL LoopLocalCnt
  589. GLOBAL GlobalVarCnt
  590. GLOBAL BaseTypeDefsCnt[16]
  591. GLOBAL TypeDefsCnt
  592. GLOBAL LocalVarCnt
  593. GLOBAL LocalDynArrCount ' Local Dynamic String Array Stack Counter
  594. GLOBAL LocalDynaCnt ' Queue Stack Counter
  595. GLOBAL GlobalDynaCnt
  596. GLOBAL Modules$[256] ' array of source filenames
  597. GLOBAL ModuleNdx ' index of source files
  598. GLOBAL ModuleLineNos[256] ' line no in source files, uses ModuleNdx also
  599. GLOBAL FPtrNdx ' Controls $Include Files
  600. GLOBAL FPtr [256] AS FILE ' Controls $Include Files
  601. GLOBAL Stk$ [4096] ' Parse array
  602. GLOBAL ProtoType [1024] AS ProtoStore ' C prototype declarations of user func's
  603. GLOBAL SrcStk$ [128] ' used in parsing single line if-THEN-else
  604. GLOBAL SplitStk$ [128] ' used in parsing ":" separated lines
  605. GLOBAL SplitCnt
  606. GLOBAL SplitCur
  607. GLOBAL SrcTmp$ ' used for storing string to use as parameter to Parse()
  608. GLOBAL CaseStk$ [256] ' Stack For Nested "Select Case" variable
  609. GLOBAL CaseElseFlag [256] ' Set if Select Case contains a Case Else
  610. GLOBAL Entry$ [256] ' Controls the $OnEntry
  611. GLOBAL Xit$ [256] ' Controls the $OnExit
  612. GLOBAL LocalDynArrName$ [256] ' Queues LOCAL dynamic string arrays
  613. GLOBAL GlobalDynaStr$ [256]
  614. GLOBAL DynaStr$ [256] ' Queues Dynamic strings in SUBS/FUNCTIONS
  615. GLOBAL StartSub$ [32] ' user's startup code subs
  616. GLOBAL StartNdx ' index for StartSub$
  617. GLOBAL ExitSub$ [32] ' user's exit code subs
  618. GLOBAL ExitNdx ' index for ExitSub$
  619. GLOBAL Library$ [MaxLib] ' stores libraries to used
  620. GLOBAL GlobalVarHash[MaxGlobalVars]
  621. GLOBAL GlobalVars[MaxGlobalVars] AS VarInfo ' Holds global variables
  622. GLOBAL LocalVars[MaxLocalVars] AS VarInfo ' Holds local variables
  623. GLOBAL TypeDefs [MaxTypes] AS UserTypeDefs ' Holds typedefs
  624. GLOBAL VarCode AS VARCODE
  625. GLOBAL UmQt 'Handles quoted lines split with a contination _
  626. GLOBAL LD_FLAGS$ ' Holds Linker Flags for GUI Toolkits/OS (GTK, OSX, WXWIDGETS)
  627. '************************************************************************************************
  628. GLOBAL Accelerator$
  629. GLOBAL CallType$ ' Calling convention cdecl, stdcall ...
  630. GLOBAL CaseFlag
  631. GLOBAL CaseVar$
  632. GLOBAL Cmd$
  633. GLOBAL Compiler$
  634. GLOBAL CmdLineConst$
  635. GLOBAL CmdLineFileOut$
  636. GLOBAL CurrentFuncType
  637. GLOBAL DimType$
  638. GLOBAL DllDecl$ [800][512] AS CHAR
  639. GLOBAL DllCnt
  640. GLOBAL Loadlibs$ [128][512] AS CHAR
  641. GLOBAL LoadLibsCnt
  642. GLOBAL Elapsed AS SINGLE
  643. GLOBAL EndOfProgram
  644. GLOBAL EntryCnt
  645. GLOBAL ErrFile
  646. GLOBAL szFile$
  647. GLOBAL Filnam$
  648. GLOBAL ForceMainToFunc
  649. GLOBAL Funcname$
  650. GLOBAL Handl$
  651. GLOBAL HFileCnt
  652. GLOBAL HFiles$[128]
  653. GLOBAL HFile$
  654. GLOBAL InConditional
  655. GLOBAL InIfDef$
  656. GLOBAL Indent
  657. GLOBAL InFunc
  658. GLOBAL InMain
  659. GLOBAL IsCallBack
  660. GLOBAL TurboSize
  661. GLOBAL UseCProto
  662. GLOBAL InTypeDef
  663. GLOBAL IsAuto
  664. GLOBAL NoTypeDeclare
  665. GLOBAL IsDim
  666. GLOBAL IsExported
  667. GLOBAL IsRegister
  668. GLOBAL IsStatic
  669. GLOBAL IsStdFunc
  670. GLOBAL IsLocal
  671. GLOBAL IsRaw
  672. GLOBAL IsApple
  673. GLOBAL KillCFile
  674. GLOBAL Keyword1$
  675. GLOBAL LastCmd
  676. GLOBAL LinesRead
  677. GLOBAL Linker$
  678. GLOBAL Lookup$
  679. GLOBAL MakeDLL
  680. GLOBAL Ndx
  681. GLOBAL NoMain
  682. GLOBAL NoDllMain
  683. GLOBAL OkayToSend
  684. GLOBAL Op$
  685. GLOBAL OptionBase
  686. GLOBAL OutfileClone$
  687. GLOBAL PassOne
  688. GLOBAL ProtoCnt
  689. GLOBAL Pusher
  690. GLOBAL Quiet ' no output to screen, for use with BCX Builder
  691. GLOBAL ReDirect
  692. GLOBAL SaveOutfileNum AS FILE
  693. GLOBAL Scoot$
  694. GLOBAL ShowStatus
  695. GLOBAL SrcCnt
  696. GLOBAL SrcFlag
  697. GLOBAL TrcFlag
  698. GLOBAL TestForBcxIni
  699. GLOBAL FileIn$
  700. GLOBAL FileOut$
  701. GLOBAL FileErr$
  702. GLOBAL T$
  703. GLOBAL Test
  704. GLOBAL Statements
  705. GLOBAL TestState
  706. GLOBAL Tipe$
  707. GLOBAL TranslateSlash
  708. GLOBAL TypeName$[16]
  709. GLOBAL UseCpp
  710. GLOBAL UseFlag '= true
  711. '/** 2010/11/30 Added to support NameSpace - AIR 88/
  712. GLOBAL InNameSpace
  713. '/***** 2010-12-01 Added to support Abstract Classes -AIR *****/
  714. GLOBAL Use_Virtual
  715. GLOBAL vproc$
  716. GLOBAL UseStdCall
  717. GLOBAL UseLCaseTbl
  718. GLOBAL Var$
  719. GLOBAL XitCount
  720. GLOBAL Z$
  721. GLOBAL ConstLastDef$
  722. '**********************
  723. GLOBAL Use_AnsiToWide
  724. GLOBAL Use_Asc
  725. GLOBAL Use_AppExeName
  726. GLOBAL Use_AppExePath
  727. GLOBAL Use_Boolstr
  728. GLOBAL Use_Bor
  729. GLOBAL Use_Band
  730. GLOBAL Use_Bnot
  731. GLOBAL Use_BcxSplitPath
  732. GLOBAL Use_Bin
  733. GLOBAL Use_Bin2dec
  734. GLOBAL Use_Osx ' Used for OSX build - AIR
  735. GLOBAL Use_Cvd
  736. GLOBAL Use_Cvld
  737. GLOBAL Use_Cvi
  738. GLOBAL Use_Cvl
  739. GLOBAL Use_Cvs
  740. GLOBAL Use_Chr
  741. GLOBAL Use_Cdbl
  742. GLOBAL Use_Cldbl
  743. GLOBAL Use_Csng
  744. GLOBAL Use_Clear
  745. GLOBAL Use_Cbool
  746. GLOBAL Use_Cint
  747. GLOBAL Use_Clng
  748. GLOBAL Use_Cls
  749. GLOBAL Use_Color
  750. GLOBAL Use_Command
  751. GLOBAL Use_ContainedIn
  752. GLOBAL Use_Console
  753. GLOBAL Use_CopyFile
  754. GLOBAL Use_Static
  755. GLOBAL Use_Crlf
  756. GLOBAL Use_Curdir
  757. GLOBAL Use_Del
  758. GLOBAL Use_Download
  759. GLOBAL Use_Dynacall
  760. GLOBAL Use_DynamicA
  761. GLOBAL Use_Embed
  762. GLOBAL Use_Enclose
  763. GLOBAL Use_Environ
  764. GLOBAL Use_EnumFile
  765. GLOBAL Use_Eof
  766. GLOBAL Use_Exist
  767. GLOBAL Use_ExitCode
  768. GLOBAL Use_Extract
  769. GLOBAL Use_LoadFile
  770. GLOBAL Use_FillArray
  771. GLOBAL Use_Findfirst
  772. GLOBAL Use_Findnext
  773. GLOBAL Use_FindInType
  774. GLOBAL Use_Fint
  775. GLOBAL Use_Fix
  776. GLOBAL Use_FileLocked
  777. GLOBAL Use_Frac
  778. GLOBAL Use_Fracl
  779. GLOBAL Use_Freefile
  780. GLOBAL Use_Get
  781. GLOBAL Use_GetCh
  782. GLOBAL Use_GenFree
  783. GLOBAL Use_Gosub
  784. GLOBAL Use_Gtk ' GTK SUPPORT - AIR
  785. GLOBAL Use_Glib ' GLIB SUPPORT - AIR
  786. GLOBAL Use_Hex
  787. GLOBAL Use_Hex2Dec
  788. GLOBAL Use_Iif
  789. GLOBAL Use_Imod
  790. GLOBAL Use_Inkey
  791. GLOBAL Use_InkeyD
  792. GLOBAL Use_Ins
  793. GLOBAL Use_Instr
  794. GLOBAL Use_Inchr
  795. GLOBAL Use_Isptr
  796. GLOBAL Use_iReplace
  797. GLOBAL Use_IRemove
  798. GLOBAL Use_Instrrev
  799. GLOBAL Use_Join
  800. GLOBAL Use_Keypress
  801. GLOBAL Use_Lcase
  802. GLOBAL Use_Ldouble
  803. GLOBAL Use_Left
  804. GLOBAL Use_Like
  805. GLOBAL Use_Lineinput
  806. GLOBAL Use_Loc
  807. GLOBAL Use_Locate
  808. GLOBAL Use_Lof
  809. GLOBAL Use_Lpad
  810. GLOBAL Use_Ltrim
  811. GLOBAL Use_Mcase
  812. GLOBAL Use_Mid
  813. GLOBAL Use_Midstr
  814. GLOBAL Use_Mkd
  815. GLOBAL Use_Mkld
  816. GLOBAL Use_Mki
  817. GLOBAL Use_Mkl
  818. GLOBAL Use_Mks
  819. GLOBAL Use_Min
  820. GLOBAL Use_Max
  821. GLOBAL Use_Now
  822. GLOBAL Use_Numqsortdint
  823. GLOBAL Use_Numqsortaint
  824. GLOBAL Use_Numqsortdfloat
  825. GLOBAL Use_Numqsortafloat
  826. GLOBAL Use_Numqsortddouble
  827. GLOBAL Use_Numqsortadouble
  828. GLOBAL Use_Idxqsort
  829. GLOBAL Use_IdxqsortSt
  830. GLOBAL Use_PtrqsortSt
  831. GLOBAL Use_Oct
  832. GLOBAL Use_Overloaded
  833. GLOBAL Use_OSVersion
  834. GLOBAL Use_Pause
  835. GLOBAL Use_PeekStr
  836. GLOBAL Use_Put
  837. GLOBAL Use_QBColor
  838. GLOBAL Use_Randomize
  839. GLOBAL Use_Rec
  840. GLOBAL Use_RecCount
  841. GLOBAL Use_Remain
  842. GLOBAL Use_Remove
  843. GLOBAL Use_Repeat
  844. GLOBAL Use_Replace
  845. GLOBAL Use_Reverse
  846. GLOBAL Use_Right
  847. GLOBAL Use_Rpad
  848. GLOBAL Use_Rnd
  849. GLOBAL Use_Exp
  850. GLOBAL Use_Retain
  851. GLOBAL Use_Round
  852. GLOBAL Use_Rtrim
  853. GLOBAL Use_Run
  854. GLOBAL Use_Scan
  855. GLOBAL Use_Inputbuffer
  856. GLOBAL Use_SearchPath
  857. GLOBAL Use_StrUpLow
  858. GLOBAL Use_Shell
  859. '$HEADER
  860. 'static int Use_Shell;
  861. '$HEADER
  862. GLOBAL Use_Sgn
  863. GLOBAL Use_SingleFile
  864. GLOBAL Use_Space
  865. GLOBAL Use_Split
  866. GLOBAL Use_DSplit
  867. GLOBAL Use_StartupCode
  868. GLOBAL Use_Stristr
  869. GLOBAL Use_StrStr
  870. GLOBAL Use_Str
  871. GLOBAL Use_Strl
  872. GLOBAL Use_Str_Cmp
  873. GLOBAL Use_Strim
  874. GLOBAL Use_String
  875. GLOBAL Use_Strptr
  876. GLOBAL Use_Strqsorta
  877. GLOBAL Use_Strqsortd
  878. GLOBAL Use_Strtoken
  879. GLOBAL Use_DynStrqsorta
  880. GLOBAL Use_DynStrqsortd
  881. GLOBAL Use_Swap
  882. GLOBAL Use_Sysdir
  883. GLOBAL Use_SysStr
  884. GLOBAL Use_sziif
  885. GLOBAL Use_Tally
  886. GLOBAL Use_Tempdir
  887. GLOBAL Use_TempFileName
  888. GLOBAL Use_Threads
  889. GLOBAL Use_Time
  890. GLOBAL Use_Timer
  891. GLOBAL Use_Trim
  892. GLOBAL Use_Turbo
  893. GLOBAL Use_Ubound
  894. GLOBAL Use_Ucase
  895. GLOBAL Use_Using
  896. GLOBAL Use_VChr
  897. GLOBAL Use_Verify
  898. GLOBAL Use_Val
  899. GLOBAL Use_Vall
  900. GLOBAL Use_WideToAnsi
  901. GLOBAL Use_Wx ' WxWidgets GUI Support -AIR
  902. GLOBAL Use_WxC '/***** 2010-11-24 WxWidgets CONSOLE ONLY support -AIR *****/
  903. GLOBAL Use_Ctor '/***** 2010-11-17 Added to support Constructor/Destructor Method Syntax - AIR *****/
  904. GLOBAL Use_Instat '/***** 2010-12-08 Added to support INSTAT keyword - AIR *****/
  905. GLOBAL Use_Socket '/***** 2010-12-10 Added to support Sockets -AIR *****/
  906. GLOBAL Use_IOS '/***** 2010-12-17 Added to support IOS -AIR *****/
  907. GLOBAL Use_RegEx '/***** 2013-06-26 New REGEX Keywords -AIR *****/
  908. '*********************
  909. 'GLOBAL S1$ ' "%s"
  910. 'GLOBAL S2$ ' "%s%s"
  911. 'GLOBAL U1$
  912. '********************************
  913. ' PB Compatible String Constants
  914. '********************************
  915. GLOBAL Use_BEL
  916. GLOBAL Use_BS
  917. GLOBAL Use_CR
  918. GLOBAL Use_DDQ
  919. GLOBAL Use_DQ
  920. GLOBAL Use_EOF
  921. GLOBAL Use_ESC
  922. GLOBAL Use_FF
  923. GLOBAL Use_LF
  924. GLOBAL Use_NUL
  925. GLOBAL Use_SPC
  926. GLOBAL Use_TAB
  927. GLOBAL Use_VT
  928. '*********************
  929. '**************************************************************
  930. GLOBAL prcFile$ ' translated subs and functions
  931. GLOBAL udtFile$ ' translated User Defined Types
  932. GLOBAL datFile$ ' translated DATA statements
  933. GLOBAL cstFile$ ' translated CONSTants
  934. GLOBAL ovrFile$ ' translated overloaded subs and functions
  935. GLOBAL hdrFile$ ' user specified .h directives
  936. GLOBAL setFile$ ' translated GLOBAL set statements
  937. GLOBAL enuFile$ ' user GLOBAL enum blocks
  938. SET VarConst[2][8] AS CHAR
  939. "",
  940. "const "
  941. END SET
  942. SET VarStorage[6][18] AS CHAR
  943. "static ",
  944. "extern ",
  945. "",
  946. "static volatile ",
  947. "extern volatile ",
  948. "volatile "
  949. END SET
  950. '*************************************************************************
  951. ' CODE BEGINS
  952. '*************************************************************************
  953. FUNCTION main(ARGC AS INTEGER, ARGV AS PCHAR PTR)
  954. GLOBAL szTmp$ * 1048576 'This is a problem, cannot exceed 2047+1 or bad things *WILL* happen.
  955. GLOBAL Src$ * 1048576 'This is a problem, cannot exceed 2047+1 or bad things *WILL* happen.
  956. GLOBAL AbortSrc$ * 1048576 'This must be at least the size of Src$
  957. GLOBAL WarnMsg$ * 32767 'This must be MORE than the size of Src$
  958. GLOBAL RmLibs$ * 32767 ' libraries to remove
  959. LOCAL bitz as INTEGER ' is OS 32/64 bit
  960. ProtoCnt = 0 ' Prototypes counter
  961. TranslateSlash = TRUE ' Default TO changing "\" TO "\\"
  962. OkayToSend = TRUE
  963. Use_SingleFile = TRUE
  964. Use_StartupCode = FALSE
  965. StartNdx = 0
  966. Use_ExitCode = FALSE
  967. ExitNdx = 0
  968. HFile$ = ""
  969. CmdLineFileOut$ = ""
  970. RmLibs$ = ""
  971. InMain = TRUE
  972. TestState = FALSE
  973. CmdLineConst$ = ""
  974. '/***** 64BIT Check -AIR *****/
  975. bitz=SIZEOF(long)*8
  976. '**************************************************************************
  977. ' $IF __APPLE__
  978. ' Use_Carbon = TRUE
  979. ' SPRINT LD_FLAGS$, "-framework Carbon"
  980. '' LD_FLAGS = "-framework Carbon"
  981. ' $ENDIF
  982. IF COMMAND$ = "" THEN
  983. !#if defined (__APPLE__)
  984. PRINT "MBC4: Ported to Mac OSX by Armando Rivera (c) 2009-2018"
  985. !#else
  986. PRINT "MBC4: Based on Linux BCX by Mike Henning (c) 2009"
  987. PRINT "(c) 2009-2018 Armando Rivera with additional code (c) 2009 John Jacques",LF$
  988. !#endif
  989. PRINT "Version ", Version$, " Compiled with ";
  990. $IF __BCPLUSPLUS__
  991. PRINT "Borland C++"
  992. $ELSEIF __BORLANDC__
  993. PRINT "Borland C"
  994. $ELSEIF __POCC__
  995. PRINT "Pelles C"
  996. $ELSEIF __GNUG__
  997. PRINT "GNU G++"
  998. $ELSE
  999. PRINT "Unknown"
  1000. $ENDIF
  1001. '/***** 64BIT Check -AIR *****/
  1002. IF bitz=64 THEN
  1003. PRINT
  1004. PRINT "********************"
  1005. PRINT "** 64 BIT VERSION **"
  1006. PRINT "********************",LF$
  1007. END IF
  1008. PRINT " Usage: ";APPEXENAME$;" infile [.bas] [options]"
  1009. PRINT " [-c] Generate C++ Compatible code"
  1010. PRINT " [-d] DEFINE a constant ... ex. ";APPEXENAME$;" MyFile -D:MyConst[=SomeValue]"
  1011. PRINT " [-e] Write ERRORS to BCX.ERR file"
  1012. PRINT " [-f] Output FILENAME... ex. ";APPEXENAME$;" MyFile -f:/MyFiles/MyFile.c"
  1013. PRINT " [-k] KILL the generated BCX generated 'C' file"
  1014. PRINT " [-o] OUTPUT a copy of the generated C file to STDOUT"
  1015. PRINT " [-q] QUIET - No output to screen during translation"
  1016. PRINT " [-s] Show STATUS of translation by line number"
  1017. PRINT " [-w] Enable WARNINGS during translation"
  1018. PRINT " [-t] TURBO Mode ON w/optional size ... ex. ";APPEXENAME$;" MyFile -t[:1024]"
  1019. PRINT " [-u] Turn UNICODE Support ON"
  1020. CALL FREEGLOBALS
  1021. END
  1022. END IF
  1023. Quiet = FALSE
  1024. FOR INTEGER i = 2 TO ARGC-1
  1025. IF INSTR(LCASE$(ARGV$[i]),"-f") THEN CmdLineFileOut$ = MID$(ARGV$[i],4)
  1026. IF INSTR(LCASE$(ARGV$[i]),"-d") THEN CmdLineConst$ = CmdLineConst$ + MID$(ARGV$[i],4) + CHR$(1)
  1027. IF LCASE$(ARGV$[i]) = "-c" THEN UseCpp = TRUE
  1028. IF LCASE$(ARGV$[i]) = "-e" THEN ErrFile = TRUE
  1029. IF LCASE$(ARGV$[i]) = "-q" THEN Quiet = TRUE
  1030. IF LCASE$(ARGV$[i]) = "-k" THEN KillCFile = TRUE
  1031. IF LCASE$(ARGV$[i]) = "-o" THEN ReDirect = TRUE
  1032. IF LCASE$(ARGV$[i]) = "-s" THEN ShowStatus = TRUE
  1033. IF LCASE$(ARGV$[i]) = "-w" THEN TestState = TRUE
  1034. IF INSTR(LCASE$(ARGV$[i]),"-t") THEN
  1035. Use_Turbo = TRUE
  1036. TurboSize = VAL(MID$(ARGV$[i],4))
  1037. IF TurboSize <> 0 THEN
  1038. IF (TurboSize & (TurboSize-1)) <> 0 THEN
  1039. TurboSize = 512
  1040. Warning("Invalid $Turbo size - defaulting to 512")
  1041. END IF
  1042. ELSE
  1043. TurboSize = 512
  1044. END IF
  1045. END IF
  1046. NEXT
  1047. '****************************** [ Announce Program ] ********************************
  1048. IF ShowStatus THEN CLS
  1049. IF NOT Quiet THEN
  1050. CLS
  1051. PRINT "MBC Version ", Version$
  1052. !#if defined (__APPLE__)
  1053. IsApple = TRUE
  1054. PRINT "MBC4: Ported to Mac OSX by Armando Rivera (c) 2009-2018",LF$
  1055. !#else
  1056. PRINT "MBC4: Based on Linux BCX by Mike Henning (c) 2009"
  1057. PRINT "(c) 2009-2018 Armando Rivera with additional code (c) 2009 John Jacques",LF$
  1058. !#endif
  1059. '/***** 64BIT Check -AIR *****/
  1060. IF bitz=64 THEN
  1061. PRINT
  1062. PRINT "********************"
  1063. PRINT "** 64 BIT VERSION **"
  1064. PRINT "********************",LF$
  1065. END IF
  1066. END IF
  1067. '************************************************************************************
  1068. IF INCHR(COMMAND$(1),".") THEN 'Is there a period in the filename?
  1069. Cmd$ = COMMAND$(1) ' yes, allow ANY extension
  1070. ELSE 'no period in filename
  1071. IF EXIST(COMMAND$(1) + ".bas") THEN ' check for .bas
  1072. Cmd$ = COMMAND$(1) + ".bas"
  1073. ELSEIF EXIST(COMMAND$(1) + ".BAS") THEN ' check for .BAS
  1074. Cmd$ = COMMAND$(1) + ".BAS"
  1075. END IF
  1076. END IF
  1077. IF NOT EXIST (Cmd$) THEN
  1078. PRINT
  1079. PRINT "FILE NOT FOUND: ",COMMAND$(1)
  1080. CALL FREEGLOBALS 'file not found, exit gracefully
  1081. END
  1082. END IF
  1083. FileIn$ = Cmd
  1084. IF CmdLineFileOut$ = "" THEN
  1085. '/***** 2018-12-09 Changed default output extension to ".cc" -AIR *****/
  1086. FileOut$ = LEFT$(Cmd$, INSTRREV(Cmd$,".",0)-1) + ".cc"
  1087. ELSE
  1088. FileOut$ = CmdLineFileOut$
  1089. END IF
  1090. FileErr$ = LEFT$(Cmd$, INSTRREV(Cmd$,".",0)-1) + ".ERR"
  1091. IF EXIST(FileErr$) THEN
  1092. KILL FileErr$
  1093. END IF
  1094. '*******************************************************
  1095. prcFile$ = TEMPFILENAME$(TEMPDIR$,"prc")
  1096. udtFile$ = TEMPFILENAME$(TEMPDIR$,"udt")
  1097. datFile$ = TEMPFILENAME$(TEMPDIR$,"dat")
  1098. cstFile$ = TEMPFILENAME$(TEMPDIR$,"cst")
  1099. ovrFile$ = TEMPFILENAME$(TEMPDIR$,"ovr")
  1100. hdrFile$ = TEMPFILENAME$(TEMPDIR$,"hdr")
  1101. setFile$ = TEMPFILENAME$(TEMPDIR$,"set")
  1102. 'resFile$ = TEMPFILENAME$(TEMPDIR$,"res")
  1103. enuFile$ = TEMPFILENAME$(TEMPDIR$,"enu")
  1104. '**************************************************************************
  1105. OPEN FileIn$ FOR INPUT AS SourceFile
  1106. OPEN FileOut$ FOR OUTPUT AS FP2 ' THE FINAL C FILE <<<<<<<<
  1107. '**************************************************************************
  1108. Outfile = FP2 ' Outfile = FP3 when in a SUB or FUNCTION
  1109. '**************************************************************************
  1110. OPEN prcFile$ FOR OUTPUT AS FP3 ' Temp File FOR Storing User Functions
  1111. OPEN udtFile$ FOR OUTPUT AS FP4 ' Temp File FOR Storing User Def Types
  1112. OPEN datFile$ FOR OUTPUT AS FP5 ' Temp File FOR Storing User "Data"
  1113. OPEN cstFile$ FOR OUTPUT AS FP6 ' Temp File FOR Storing User CONST
  1114. OPEN hdrFile$ FOR OUTPUT AS FP7 ' Temp File FOR Storing User .H files
  1115. OPEN ovrFile$ FOR OUTPUT AS FP8 ' Temp File FOR Storing overloaded funcs
  1116. OPEN setFile$ FOR OUTPUT AS FP9 ' Temp File FOR Storing GLOBAL SET Vars
  1117. 'OPEN resFile$ FOR OUTPUT AS FP10 ' Temp File FOR Storing User .rc files
  1118. OPEN enuFile$ FOR OUTPUT AS FP11 ' Temp File FOR Storing User global enums
  1119. '*************************************************************************
  1120. ModuleNdx = 1
  1121. Modules$[ModuleNdx] = FileIn$ ' store the current module name
  1122. ModuleLineNos[ModuleNdx] = 0
  1123. '**************************************************************************
  1124. CALL EmitProlog
  1125. CALL ClearIfThenStacks
  1126. CALL EmitCmdLineConst
  1127. CALL AddGlobal("G_argv",vt_PCHAR, 0,"",1,0,0,0)
  1128. CALL AddGlobal("G_argc",vt_INTEGER, 0,"",0,0,0,0)
  1129. '*****************
  1130. ' The Main LOOP
  1131. '*****************
  1132. ReadSrcLine:
  1133. '*****************
  1134. WHILE NOT EOF(SourceFile) OR SplitCnt
  1135. IF SplitCnt = 0 THEN 'Process separated lines before
  1136. LINE INPUT SourceFile,Src$ 'getting next line from file.
  1137. ModuleLineNos[ModuleNdx]++
  1138. CALL StripCode(Src$) 'Remove spaces, tabs, comments
  1139. IF *Src = 0 THEN ITERATE
  1140. IF JoinLines(Src$) = 1 THEN ITERATE 'Join continuation lines " _"
  1141. IF INCHR(Src$,"[") THEN CALL BracketHandler(Src$,0) 'Fix Brackets
  1142. IF SplitLines(Src$) THEN Src$ = SplitStk$[++SplitCur] 'Split statements separated by
  1143. ELSE 'colons and single line if/then
  1144. Src$ = SplitStk$[++SplitCur]
  1145. END IF
  1146. IF SplitCur = SplitCnt THEN SplitCur = SplitCnt = 0
  1147. IF *Src = 0 THEN ITERATE
  1148. AbortSrc$ = Src$
  1149. '***************************************************************************
  1150. ' ReProcess: ' label added for use with BCX User-Defined PreProcessor
  1151. ' so line could be changed and be run back thru BCX from start
  1152. '***************************************************************************
  1153. IF TrcFlag AND InFunc THEN
  1154. IF NOT iMatchLft(Src$,"$trace") THEN
  1155. IF NOT iMatchLft(Src$,"end ") AND INSTR(Src$,"FUNCTION",0,1) = 0 THEN
  1156. FPRINT Outfile,"// [", TRIM$(Modules$[ModuleNdx]), " - ", TRIM$(STR$(ModuleLineNos[ModuleNdx])), "] ", Src$
  1157. Z$ = TRIM$(Modules$[ModuleNdx])
  1158. Z$ = REPLACE$(Z$,"\\","\\\\")
  1159. Z$ = " " + Z$ + " - " + STR$(ModuleLineNos[ModuleNdx]) + " \\n"
  1160. Z$ = "printf(" + ENC$(Z$) + ");"
  1161. FPRINT Outfile,Z$
  1162. END IF
  1163. END IF
  1164. END IF
  1165. '******************************
  1166. IF SrcFlag THEN
  1167. IF NOT iMatchLft(Src$,"$sourc") AND *Src <> 33 THEN '33 = !
  1168. FPRINT Outfile,"// [", TRIM$(Modules$[ModuleNdx]), " - ", TRIM$(STR$(ModuleLineNos[ModuleNdx])), "] ", Src$
  1169. END IF
  1170. END IF
  1171. '******************************
  1172. IF ShowStatus THEN
  1173. LOCATE 2,1,0
  1174. PRINT "Processing Module: ", TRIM$(Modules$[ModuleNdx]), " - Line:", ModuleLineNos[ModuleNdx]
  1175. END IF
  1176. '******************************
  1177. IF Src[0] = 33 THEN 'Test for ! symbol -- inline C
  1178. Src[0] = 32
  1179. FPRINT Outfile,Src$
  1180. Src$ = ""
  1181. END IF
  1182. '******************************
  1183. IF *Src$ = 0 THEN ITERATE
  1184. DIM RAW di
  1185. di = Directives()
  1186. IF di = 0 THEN GOTO ReadNextLine
  1187. IF di = 1 THEN GOTO ReadSrcLine
  1188. IF iMatchLft(Src$,"set ") THEN
  1189. CALL ProcessSetCommand(0)
  1190. END IF
  1191. IF iMatchLft(Src$,"sharedset ") THEN
  1192. CALL ProcessSetCommand(1)
  1193. END IF
  1194. PassOne = TRUE
  1195. '****************
  1196. ' CallParse:
  1197. '****************
  1198. CALL CheckParQuotes
  1199. IF SpecialCaseHandler(Src$) THEN ITERATE
  1200. CALL Parse(Src$)
  1201. PassOne = FALSE
  1202. IF Ndx THEN
  1203. CALL Emit
  1204. END IF
  1205. '****************
  1206. ReadNextLine:
  1207. '****************
  1208. WEND
  1209. '***************************************************
  1210. ' END OF MAIN LOOP -- All Source code has been read
  1211. '***************************************************
  1212. ' everything from here below must be stopped from
  1213. ' executing more than once
  1214. IF CmdLineConst$ > "" THEN
  1215. Src$ = "CONST " + CmdLineConst$
  1216. CALL Parse (Src$)
  1217. CALL Emit
  1218. CmdLineConst$ = ""
  1219. END IF
  1220. IF TestForBcxIni = FALSE THEN
  1221. TestForBcxIni = TRUE
  1222. szFile$ = CURDIR$ + "\\bcx.ini"
  1223. IF NOT EXIST(szFile$) THEN
  1224. szFile$ = APPEXEPATH$ + "bcx.ini"
  1225. END IF
  1226. IF EXIST(szFile$) THEN
  1227. CALL PushFileIO
  1228. OPEN szFile$ FOR INPUT AS SourceFile
  1229. Modules$[++ModuleNdx] = szFile$
  1230. ModuleLineNos[ModuleNdx] = 0
  1231. GOTO ReadSrcLine
  1232. END IF
  1233. END IF
  1234. FLUSH (Outfile) '*************************************
  1235. IF FPtrNdx THEN ' Pop out the $Include File Handles
  1236. CALL PopFileIO ' and close them in sequence until
  1237. GOTO ReadSrcLine ' we end up back in the main file
  1238. END IF '*************************************
  1239. IF Use_GenFree AND GlobalDynaCnt THEN
  1240. CALL MakeFreeGlobals
  1241. END IF
  1242. CALL ExportInternalConst
  1243. CALL EmitEpilog
  1244. CALL CloseAll
  1245. CALL AddProtos
  1246. CALL DeclareVariables
  1247. CALL AddFuncs
  1248. CALL CloseAll
  1249. '***************************
  1250. ' Final Disk Gymnastics
  1251. '***************************
  1252. IF UseCpp AND CmdLineFileOut$ = "" THEN
  1253. szTmp$ = EXTRACT$(FileOut$,".") + ".cpp"
  1254. KILL szTmp$
  1255. RENAME FileOut$, szTmp$
  1256. FileOut$ = szTmp$
  1257. END IF
  1258. '/***** 2015-07-03 Added to support OSX Cocoa -AIR *****/
  1259. IF Use_Osx AND CmdLineFileOut$ = "" THEN
  1260. szTmp$ = EXTRACT$(FileOut$,".") + ".mm"
  1261. KILL szTmp$
  1262. RENAME FileOut$, szTmp$
  1263. FileOut$ = szTmp$
  1264. END IF
  1265. OPEN FileOut$ FOR INPUT AS FP1
  1266. OPEN hdrFile$ FOR INPUT AS FP2
  1267. OPEN "$temp$" FOR OUTPUT AS FP3
  1268. GLOBAL DoCountLines
  1269. DoCountLines = TRUE
  1270. FPRINT FP3,"// *********************************************************************"
  1271. FPRINT FP3,"// Created with MBC (V) ", Version$, "Ported to OSX by Armando Rivera"
  1272. FPRINT FP3,"// Ported from BCX32 BASIC To C/C++ Translator (V) 5.12"
  1273. FPRINT FP3,"// BCX (c) 1999 - 2018 by Kevin Diggins"
  1274. FPRINT FP3,"// LinuxBC (c) 2009 by Mike Henning "
  1275. FPRINT FP3,"// MBC (c) 2009 - 2018 by Armando Rivera"
  1276. FPRINT FP3,"// *********************************************************************"
  1277. FPRINT FP3,"// Translated for compiling with the g++ Compiler"
  1278. IF UseCpp THEN
  1279. FPRINT FP3,"// g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$.cpp -ldl -o $FILE$"
  1280. ELSE
  1281. '/***** 2018-12-09 Changed default output extension to ".cc" -AIR *****/
  1282. FPRINT FP3,"// g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$.cc -ldl -o $FILE$"
  1283. END IF
  1284. FPRINT FP3,"// *********************************************************************"
  1285. IF NoRT=FALSE THEN
  1286. '********* CARBON OSX SUPPORT *********
  1287. IF Use_Osx THEN
  1288. FPRINT FP3,"#import <Cocoa/Cocoa.h>"
  1289. END IF
  1290. '**************************************
  1291. '********* WX WIDGETS SUPPORT *********
  1292. /***** 2010-11-24 Added WxC FOR WX CONSOLE Apps -AIR *****/
  1293. IF Use_Wx OR Use_WxC THEN
  1294. FPRINT FP3,"// WXWIDGETS HEADER FILES //"
  1295. FPRINT FP3,"#include <wx/wx.h>"
  1296. FPRINT FP3,"#include <wx/process.h>"
  1297. FPRINT FP3,"#include <wx/txtstrm.h>"
  1298. FPRINT FP3,"#include <wx/msgdlg.h>"
  1299. FPRINT FP3,"#include <wx/stdpaths.h>"
  1300. FPRINT FP3,"#include <wx/event.h>"
  1301. FPRINT FP3,"// ******************* //"
  1302. FPRINT FP3,""
  1303. END IF
  1304. '**************************************
  1305. '*********** GTK SUPPORT ***********
  1306. IF Use_Gtk THEN
  1307. FPRINT FP3,"#include <gtk/gtk.h>"
  1308. END IF
  1309. '**************************************
  1310. '*********** GLIB SUPPORT **********
  1311. IF Use_Glib THEN
  1312. FPRINT FP3,"#include <glib.h>"
  1313. END IF
  1314. '**************************************
  1315. FPRINT FP3,"#include <stdbool.h>"
  1316. FPRINT FP3,"#include <ctype.h>"
  1317. FPRINT FP3,"#include <math.h>"
  1318. FPRINT FP3,"#include <stdio.h>"
  1319. FPRINT FP3,"#include <iostream>"
  1320. FPRINT FP3,"#include <fstream>"
  1321. FPRINT FP3,"#include <string.h>"
  1322. FPRINT FP3,"#include <stddef.h>"
  1323. FPRINT FP3,"#include <stdlib.h>"
  1324. FPRINT FP3,"#include <setjmp.h>"
  1325. FPRINT FP3,"#include <time.h>"
  1326. FPRINT FP3,"#include <stdarg.h>"
  1327. FPRINT FP3,"#include <dirent.h>"
  1328. FPRINT FP3,"#include <sys/types.h>"
  1329. FPRINT FP3,"#include <sys/stat.h>"
  1330. FPRINT FP3,"#include <sys/wait.h>"
  1331. FPRINT FP3,"#include <unistd.h>"
  1332. FPRINT FP3,"#include <dlfcn.h>"
  1333. !#if defined (__APPLE__)
  1334. FPRINT FP3,"#include <libproc.h>"
  1335. !#endif
  1336. IF UseCpp THEN
  1337. FPRINT FP3,"#include <iostream>"
  1338. FPRINT FP3,"#include <fstream>"
  1339. END IF
  1340. '/***** 2010-12-08 Added to support INSTAT Keyword-AIR *****/
  1341. IF Use_Instat THEN
  1342. Use_Keypress = true
  1343. FPRINT FP3,"#include <fcntl.h>"
  1344. END IF
  1345. '/***** 2010-12-08 Changed to fix minor issue -AIR *****/
  1346. IF Use_Keypress THEN
  1347. FPRINT FP3,"#include <term.h>"
  1348. END IF
  1349. '/***** 2010-12-10 Added to support Sockets -AIR *****/
  1350. if Use_Socket then
  1351. FPRINT FP3,"#include <sys/socket.h>"
  1352. FPRINT FP3,"#include <netinet/in.h>"
  1353. FPRINT FP3,"#include <netdb.h>"
  1354. FPRINT FP3,"#include <errno.h>"
  1355. FPRINT FP3,"#include <arpa/inet.h>"
  1356. end if
  1357. '/***** 2013-06-26 New REGEX supprt -AIR *****/
  1358. IF Use_RegEx then
  1359. FPRINT FP3,"#include <regex.h>"
  1360. END IF
  1361. FPRINT FP3,""
  1362. CALL EmitCompilerDefines
  1363. END IF 'NoRT
  1364. WHILE NOT EOF(FP2)
  1365. LINE INPUT FP2,Z$ ' Read from BCX.HDR
  1366. FPRINT FP3,Z$ ' Write to $temp$
  1367. WEND
  1368. DIM RAW Lastlyne$
  1369. Lastlyne$ = ""
  1370. WHILE NOT EOF(FP1)
  1371. STATIC bMainOut = 0
  1372. LINE INPUT FP1,Z$ ' Read from "C" FileOut$
  1373. IF iMatchLft(Lastlyne$, "#if") THEN
  1374. IF iMatchLft(Z$, "#endif") THEN
  1375. Lastlyne$ = ""
  1376. ITERATE
  1377. ELSE
  1378. FPRINT FP3, Lastlyne$
  1379. END IF
  1380. END IF
  1381. Lastlyne$ = Z$
  1382. IF iMatchLft(Lastlyne$, "#if") THEN ITERATE
  1383. FPRINT FP3,Z$ ' Write to $temp$
  1384. IF bMainOut THEN ITERATE
  1385. IF LEFT$(LTRIM$(Z$),8) = "int main" THEN
  1386. WHILE TRIM$(Z$) <> "{"
  1387. LINE INPUT FP1,Z$
  1388. FPRINT FP3,Z$
  1389. WEND
  1390. IF Use_StartupCode THEN
  1391. FPRINT FP3,Scoot$,"int BCX_SUCode = BCX_StartupCode_(); // execute user's startup code"
  1392. END IF
  1393. IF Use_ExitCode THEN
  1394. FPRINT FP3,Scoot$,"int BCX_EXCode = BCX_ExitCode_(); // Prepare for user's exit code"
  1395. END IF
  1396. bMainOut++
  1397. END IF
  1398. WEND
  1399. DoCountLines = FALSE
  1400. CALL CloseAll
  1401. KILL hdrFile$
  1402. KILL FileOut$
  1403. '***************************************************************
  1404. RENAME "$temp$", FileOut$ ' This is our FINAL "C" File
  1405. '***************************************************************
  1406. '*******************************
  1407. IF ShowStatus THEN LOCATE 2,1,1
  1408. '*******************************
  1409. IF NOT Quiet THEN
  1410. INCR LinesRead, ModuleLineNos[1]
  1411. Elapsed! = ROUND((float)clock()/(float)CLOCKS_PER_SEC,2)
  1412. PRINT "[Lines In:" ; LinesRead ; "] [Lines Out:" ; gLinesWritten ; "] ";
  1413. PRINT "[Statements:" ; Statements ; "] [Time:" ; Elapsed! ; " sec's]"
  1414. Z$ = "BCX translated " + REMOVE$(FileIn$," ") + " to " + REMOVE$(FileOut$," ")
  1415. PRINT Z$
  1416. END IF
  1417. CALL PostProcess
  1418. IF WarnMsg$ > "" THEN
  1419. PRINT "Warnings! :", CRLF$, WarnMsg$
  1420. END IF
  1421. IF KillCFile THEN KILL FileOut$ ' -k switch issued ?
  1422. CALL FREEGLOBALS
  1423. END FUNCTION ' Function main (END of BCX Translator)
  1424. SUB EmitCmdLineConst()
  1425. IF CmdLineConst$ > "" THEN
  1426. RAW Ftmp AS FILE
  1427. FPRINT FP7, ""
  1428. FPRINT FP7, "// ***************************************************"
  1429. FPRINT FP7, "// Commandline Defines"
  1430. FPRINT FP7, "// ***************************************************"
  1431. FPRINT FP7, ""
  1432. ' Save FILE Ptr to SourceFile
  1433. Ftmp = FP6
  1434. ' Direct output to HeaderFile
  1435. FP6 = FP7
  1436. FOR INTEGER i = 1 TO TALLY( CmdLineConst$, CHR$(1) )
  1437. Src$ = STRTOKEN$( CmdLineConst$, CHR$(1), i )
  1438. IF Src$ = "" THEN EXIT
  1439. Src$ = "CONST " + Src$ ' CmdLineConst$
  1440. CALL Parse (Src$)
  1441. CALL Emit
  1442. NEXT
  1443. CmdLineConst$ = ""
  1444. ' Restore Ptr to SourceFile
  1445. FP6 = Ftmp
  1446. FPRINT FP7, ""
  1447. END IF
  1448. END SUB 'EmitCmdLineConst
  1449. SUB EmitCompilerDefines()
  1450. FPRINT FP3,""
  1451. FPRINT FP3,"// ***************************************************"
  1452. FPRINT FP3,"// Compiler Defines"
  1453. FPRINT FP3,"// ***************************************************"
  1454. FPRINT FP3," #define C_EXPORT extern ", ENC$("C")
  1455. FPRINT FP3," #define C_IMPORT extern ", ENC$("C")
  1456. FPRINT FP3,""
  1457. FPRINT FP3,"#ifndef stat"
  1458. FPRINT FP3," #define lstat stat"
  1459. FPRINT FP3,"#endif"
  1460. FPRINT FP3,"#ifndef _fcloseall"
  1461. FPRINT FP3," #define _fcloseall _fcloseall"
  1462. FPRINT FP3,"#endif"
  1463. FPRINT FP3,"#ifndef HWND"
  1464. FPRINT FP3," #define HWND GHWND"
  1465. FPRINT FP3,"#endif"
  1466. FPRINT FP3,"#ifndef MAX_PATH"
  1467. FPRINT FP3," #define MAX_PATH 2048"
  1468. FPRINT FP3,"#endif"
  1469. FPRINT FP3,"#ifndef CALLBACK"
  1470. FPRINT FP3," #define CALLBACK"
  1471. FPRINT FP3,"#endif"
  1472. FPRINT FP3,"typedef unsigned int HINSTANCE;"
  1473. 'FPRINT FP3, typedef const char CCHAR;"
  1474. FPRINT FP3,"typedef void* LPVOID;"
  1475. FPRINT FP3,"typedef char* PCHAR;"
  1476. FPRINT FP3,"typedef unsigned char BYTE;"
  1477. FPRINT FP3,"typedef unsigned int UINT;"
  1478. FPRINT FP3,"typedef unsigned char UCHAR;"
  1479. FPRINT FP3,"typedef unsigned char* PUCHAR;"
  1480. FPRINT FP3,"typedef unsigned long ULONG;"
  1481. FPRINT FP3,"typedef unsigned long* ULONG_PTR;"
  1482. FPRINT FP3,"typedef unsigned long DWORD;"
  1483. FPRINT FP3,""
  1484. FPRINT FP3,"#ifndef TRUE"
  1485. FPRINT FP3," #define TRUE 1"
  1486. FPRINT FP3,"#endif"
  1487. FPRINT FP3,""
  1488. FPRINT FP3,"#ifndef FALSE"
  1489. FPRINT FP3," #define FALSE 0"
  1490. FPRINT FP3,"#endif"
  1491. IF NOT Use_Osx THEN
  1492. FPRINT FP3,"#define BOOL bool"
  1493. END IF
  1494. FPRINT FP3,""
  1495. IF UseCpp THEN
  1496. FPRINT FP3,"#define println(a) (std::cout << a << std::endl)"
  1497. 'FPRINT FP3,"#define stdstring std::string"
  1498. 'FPRINT FP3,"#define stdfile std::fstream"
  1499. FPRINT FP3," typedef std::string CSTRING;"
  1500. FPRINT FP3," typedef std::fstream CFILE;"
  1501. END IF
  1502. END SUB 'EmitCompilerDefines
  1503. SUB MakeFreeGlobals
  1504. Src$ = "SUB FreeGlobals"
  1505. PassOne = 1
  1506. CALL Parse(Src$)
  1507. CALL Emit
  1508. WHILE GlobalDynaCnt
  1509. FPRINT Outfile," ", GlobalDynaStr$[GlobalDynaCnt]
  1510. GlobalDynaCnt--
  1511. WEND
  1512. Src$ = "END SUB"
  1513. PassOne = 1
  1514. CALL Parse(Src$)
  1515. CALL Emit
  1516. END SUB ' MakeFreeGlobals
  1517. SUB ProcessSetCommand(GS)
  1518. DIM RAW i, ii, j, SetString=0
  1519. DIM RAW CVar$
  1520. DIM RAW vt
  1521. LOCAL SaveFP AS FILE
  1522. SaveFP = Outfile
  1523. IF NOT InFunc THEN Outfile = FP9 ' Global context
  1524. IF INCHR(Src$,"$") AND TALLY(Src$,"[") >1 THEN
  1525. Src$ = STRIM$(Src$)
  1526. IREMOVE "as string" FROM Src$
  1527. IREMOVE "as char" FROM Src$
  1528. CONCAT(Src$," AS char")
  1529. END IF
  1530. CONCAT(Src$,"=")
  1531. PassOne = 1
  1532. CALL Parse(Src$)
  1533. Tipe$ = ""
  1534. FOR i = 1 TO Ndx
  1535. IF iMatchWrd(Stk$[i],"as") THEN
  1536. Tipe$ = Stk$[i+1]
  1537. Stk$[i] = ""
  1538. Stk$[i+1] = ""
  1539. EXIT FOR
  1540. END IF
  1541. NEXT
  1542. IF Tipe$ = "" THEN
  1543. szTmp$ = Stk$[2]
  1544. SetString = DataType(Stk$[2])
  1545. j = SetString
  1546. VarCode.Method% = mt_ProcessSetCommand
  1547. VarCode.Token$ = szTmp$
  1548. VarCode.VarNo% = j
  1549. CALL GetVarCode(&VarCode)
  1550. IF GS THEN
  1551. FPRINT Outfile,Scoot$,REMOVE$(VarCode.StaticOut$,"static ");
  1552. ELSE
  1553. FPRINT Outfile,Scoot$,VarCode.StaticOut$;
  1554. END IF
  1555. DIM RAW lszTmp as string
  1556. lszTmp$ = ""
  1557. CVar$ = Clean$(Stk$[2])
  1558. CALL ValidVar(CVar$)
  1559. vt = DataType(Stk$[2])
  1560. FOR i = 3 TO Ndx
  1561. CONCAT (lszTmp$, Stk$[i])
  1562. NEXT
  1563. IF vt = vt_STRVAR AND lszTmp$ <> "" THEN
  1564. CONCAT (lszTmp$, "[65535]")
  1565. END IF
  1566. IF NOT InFunc THEN
  1567. CALL AddGlobal(CVar$, vt, 0,lszTmp$,0,0,0,1)
  1568. ELSE
  1569. CALL AddLocal(CVar$, vt, 0,lszTmp$,0,0,1)
  1570. END IF
  1571. ELSE
  1572. CVar$ = Clean$(Stk$[2])
  1573. IF GS THEN
  1574. FPRINT Outfile,Scoot$ ; Tipe$;" ";CVar$;
  1575. ELSE
  1576. FPRINT Outfile,Scoot$ ; "static ";Tipe$;" ";CVar$;
  1577. END IF
  1578. DIM RAW DimType$
  1579. DIM RAW IsPointer
  1580. DIM RAW id
  1581. DimType$ = REMOVE$(Tipe$,"*") ' *mh - 3/9/09
  1582. GetTypeInfo(Tipe$, &IsPointer, &id, &vt)
  1583. IF vt = vt_STRVAR THEN
  1584. CONCAT(DimType$, "[65535]")
  1585. END IF
  1586. IF NOT InFunc THEN
  1587. CALL AddGlobal(CVar$, vt, id, DimType$,IsPointer,0,0,1)
  1588. ELSE
  1589. CALL AddLocal(CVar$, vt, id, DimType$,IsPointer,0,1)
  1590. END IF
  1591. END IF
  1592. i = 2
  1593. j = 0
  1594. DO
  1595. i++
  1596. IF Stk$[i]= "=" THEN j = 1
  1597. IF SetString = vt_STRVAR AND j = 1 THEN
  1598. FPRINT Outfile,"[65535]=";
  1599. ELSE
  1600. FPRINT Outfile,Stk$[i];
  1601. END IF
  1602. IF Stk$[i]= "=" THEN EXIT LOOP
  1603. IF i = Ndx THEN EXIT LOOP
  1604. LOOP
  1605. FPRINT Outfile,""
  1606. FPRINT Outfile,"{"
  1607. WHILE NOT EOF(SourceFile)
  1608. LINE INPUT SourceFile,Src$
  1609. ModuleLineNos[ModuleNdx]++
  1610. CALL StripCode(Src$)
  1611. IF JoinLines(Src$) = 1 THEN ITERATE
  1612. PassOne = TRUE
  1613. CALL XParse(Src$)
  1614. PassOne = FALSE
  1615. CALL TokenSubstitutions
  1616. IF iMatchLft(Src$,"end ") THEN EXIT LOOP
  1617. IF LEN (Src$) THEN
  1618. FPRINT Outfile," ";
  1619. FOR ii = 1 TO Ndx
  1620. FPRINT Outfile, Clean$(Stk$[ii]);
  1621. NEXT ii
  1622. FPRINT Outfile,""
  1623. END IF
  1624. WEND
  1625. FPRINT Outfile,"};\n"
  1626. Src$ = ""
  1627. Outfile = SaveFP
  1628. END SUB 'ProcessSetCommand
  1629. FUNCTION Directives
  1630. DIM RAW lszTmp$, i
  1631. DIM RAW COutputFile$
  1632. ' = # = $
  1633. IF *Src = 35 OR *Src = 36 THEN
  1634. Z$ = RTRIM$(LCASE$(LEFT$(Src$,6)))
  1635. '******************************
  1636. SELECT CASE Z$
  1637. '****************************
  1638. CASE "$proje"
  1639. '****************************
  1640. NoRT=TRUE
  1641. Src$ = ""
  1642. EXIT FUNCTION
  1643. '****************************
  1644. CASE "$accel"
  1645. '****************************
  1646. CALL XParse(Src$)
  1647. Accelerator$ = REMOVE$(Stk$[2],DQ$)
  1648. Src$ = ""
  1649. EXIT FUNCTION
  1650. '****************************
  1651. CASE "$bcxve"
  1652. '****************************
  1653. Src$ = TRIM$(MID$(Src$,12))
  1654. REMOVE DQ$ FROM Src$
  1655. IF LCASE$(Version$) < LCASE$(Src$) THEN
  1656. Abort (CRLF$ + "Your Translator needs updating." + CRLF$ + _
  1657. "This program " + ENC$(Modules$[ModuleNdx]) + " requires BCX Version: " + Src$ + " or later." + CRLF$ + CRLF$)
  1658. ELSE
  1659. PRINT ""
  1660. PRINT "Program written for BCX Version ", Src$
  1661. PRINT ""
  1662. END IF
  1663. EXIT FUNCTION
  1664. '****************************
  1665. CASE "$compi"
  1666. '****************************
  1667. PassOne = 1
  1668. CALL XParse(Src$)
  1669. PassOne = 0
  1670. Compiler$ = Stk$[2]
  1671. Src$ = ""
  1672. EXIT FUNCTION
  1673. '****************************
  1674. CASE "$execo"
  1675. '****************************
  1676. LOCAL SrcExt$
  1677. PassOne = 1
  1678. CALL XParse(Src$)
  1679. PassOne = 0
  1680. XitCount++
  1681. IF UseCpp THEN
  1682. SrcExt$=".cpp"
  1683. '/***** 2015-07-03 Added to support OSX Cocoa -AIR *****/
  1684. ELSEIF Use_Osx THEN
  1685. SrcExt$=".mm"
  1686. ELSE
  1687. '/***** 2018-12-09 Changed default output extension to ".cc" -AIR *****/
  1688. SrcExt$=".cc"
  1689. END IF
  1690. IF MakeDLL THEN
  1691. Xit$[XitCount]= "g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$" + SrcExt$ + " -ldl " + LD_FLAGS$ + SPC$ + Stk$[2] + " -o lib$FILE$.so"
  1692. SrcExt$ = ""
  1693. Src$ = ""
  1694. EXIT FUNCTION
  1695. END IF
  1696. '/***** 2010-12-17 Added to support IOS -AIR *****/
  1697. IF Use_IOS THEN
  1698. LOCAL IOS_COMPILER$
  1699. IOS_COMPILER$ = "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++"
  1700. IF LEN(Stk$[2])>0 THEN
  1701. Xit$[XitCount]= IOS_COMPILER$ & " -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$" + SrcExt$ + " -ldl " + LD_FLAGS$ + SPC$ + Stk$[2] + " -o $FILE$"
  1702. ELSE
  1703. Xit$[XitCount]= IOS_COMPILER$ & " -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$" + SrcExt$ + " -ldl " + LD_FLAGS$ + " -o $FILE$"
  1704. END IF
  1705. SrcExt$ = ""
  1706. Src$ = ""
  1707. EXIT FUNCTION
  1708. END IF
  1709. IF LEN(Stk$[2])>0 THEN
  1710. Xit$[XitCount]= "g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$" + SrcExt$ + " -ldl " + LD_FLAGS$ + SPC$ + Stk$[2] + " -o $FILE$"
  1711. ELSE
  1712. Xit$[XitCount]= "g++ -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$" + SrcExt$ + " -ldl " + LD_FLAGS$ + " -o $FILE$"
  1713. END IF
  1714. SrcExt$ = ""
  1715. Src$ = ""
  1716. EXIT FUNCTION
  1717. '****************************
  1718. CASE "$exest"
  1719. '****************************
  1720. PassOne = 1
  1721. CALL XParse(Src$)
  1722. PassOne = 0
  1723. XitCount++
  1724. IF IsApple then
  1725. Xit$[XitCount]= "strip $FILE$"
  1726. ELSE
  1727. Xit$[XitCount]= "strip -s -R .comment -R .note -R .note.ABI-tag $FILE$"
  1728. END IF
  1729. Src$ = ""
  1730. EXIT FUNCTION
  1731. '****************************
  1732. CASE "$genfr"
  1733. '****************************
  1734. Use_GenFree = TRUE
  1735. Src$ = ""
  1736. EXIT FUNCTION
  1737. '****************************
  1738. CASE "$osx"
  1739. Use_Osx = TRUE
  1740. '/***** 2015-07-03 Changed Carbon to Cocoa, added Objc flag -AIR *****/
  1741. '/***** 2018-12-12 Added ARC flag -AIR *****/
  1742. LD_FLAGS$ = JOIN$(2, LD_FLAGS$," -fobjc-arc -framework Cocoa")
  1743. EXIT FUNCTION
  1744. '/***** 2010-12-17 Added to support IOS -AIR *****/
  1745. CASE "$ios"
  1746. !#if !defined __APPLE__
  1747. Abort(CRLF$+"The $IOS Directive REQUIRES an Apple OSX Operating System"+CRLF$)
  1748. !#endif
  1749. Use_IOS = TRUE
  1750. PassOne = 1
  1751. CALL XParse(Src$)
  1752. PassOne = 0
  1753. LD_FLAGS$ = JOIN$(2, LD_FLAGS$," -arch armv6 -arch armv7 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk -framework Foundation -framework CoreFoundation")
  1754. EXIT FUNCTION
  1755. CASE "$gtk"
  1756. Use_Gtk = TRUE
  1757. LD_FLAGS$ = JOIN$(2, LD_FLAGS$," $(pkg-config --libs --cflags gtk+-2.0)")
  1758. EXIT FUNCTION
  1759. '/***** 2018-12-12 Added to support passing ldflags -AIR *****/
  1760. CASE "$ldfla"
  1761. LD_FLAGS$ = JOIN$(2, LD_FLAGS$, REMAIN$(Src$," "))
  1762. EXIT FUNCTION
  1763. '****************************
  1764. /***** 2010-11-24 Added WxC FOR WX CONSOLE Apps -AIR *****/
  1765. '****************************
  1766. CASE "$wxc"
  1767. Use_WxC = UseCpp = NoMain = TRUE
  1768. LD_FLAGS$ = JOIN$(2, LD_FLAGS$, " $(wx-config --libs --cppflags)")
  1769. EXIT FUNCTION
  1770. '****************************
  1771. CASE "$wx"
  1772. Use_Wx = UseCpp = NoMain = TRUE
  1773. LD_FLAGS$ = JOIN$(2, LD_FLAGS$, " $(wx-config --libs --cppflags)")
  1774. EXIT FUNCTION
  1775. '****************************
  1776. CASE "$glib"
  1777. Use_Glib = TRUE
  1778. LD_FLAGS$ = JOIN$(2, LD_FLAGS$," $(pkg-config --libs --cflags glib-2.0)")
  1779. EXIT FUNCTION
  1780. '****************************
  1781. CASE "$noini"
  1782. '****************************
  1783. Src$ = ""
  1784. TestForBcxIni = TRUE
  1785. EXIT FUNCTION
  1786. '****************************
  1787. CASE "$linke"
  1788. '****************************
  1789. PassOne = 1
  1790. CALL XParse(Src$)
  1791. PassOne = 0
  1792. Linker$ = Stk$[2]
  1793. Src$ = ""
  1794. EXIT FUNCTION
  1795. '****************************
  1796. CASE "$onexi"
  1797. '****************************
  1798. PassOne = 1
  1799. CALL XParse(Src$)
  1800. PassOne = 0
  1801. XitCount++
  1802. Xit$[XitCount]= Stk$[2]
  1803. Src$ = ""
  1804. EXIT FUNCTION
  1805. '****************************
  1806. CASE "$onent"
  1807. '****************************
  1808. PassOne = 1
  1809. CALL XParse(Src$)
  1810. PassOne = 0
  1811. EntryCnt++
  1812. Entry$[EntryCnt]= Stk$[2]
  1813. Src$ = ""
  1814. EXIT FUNCTION
  1815. '****************************
  1816. CASE "$pack","$pack("
  1817. '****************************
  1818. 'Src$ = EXTRACT$(Src$,"'") ' allow Basic comments
  1819. Src$ = MID$(Src$,6)
  1820. FPRINT FP4,"#pragma pack ",LTRIM$(Src$)
  1821. Src$ = ""
  1822. EXIT FUNCTION
  1823. '****************************
  1824. CASE "$nodll"
  1825. '****************************
  1826. NoDllMain = TRUE
  1827. Src$ = ""
  1828. EXIT FUNCTION
  1829. '****************************
  1830. CASE "$pelle"
  1831. '****************************
  1832. Src$ = ""
  1833. EXIT FUNCTION
  1834. '****************************
  1835. CASE "$stdca"
  1836. '****************************
  1837. UseStdCall = TRUE
  1838. Src$ = ""
  1839. EXIT FUNCTION
  1840. '****************************
  1841. CASE "$iprin"
  1842. '****************************
  1843. IF INSTR(LCASE$(Src$),"_on") THEN
  1844. TranslateSlash = TRUE
  1845. ELSE
  1846. TranslateSlash = FALSE
  1847. END IF
  1848. Src$ = ""
  1849. EXIT FUNCTION
  1850. '****************************
  1851. CASE "$nomai"
  1852. '****************************
  1853. NoMain = TRUE
  1854. Src$ = ""
  1855. EXIT FUNCTION
  1856. '****************************
  1857. CASE "$test"
  1858. '****************************
  1859. TestState = NOT TestState
  1860. Src$ = ""
  1861. EXIT FUNCTION
  1862. '****************************
  1863. CASE "$typed"
  1864. '****************************
  1865. FPRINT FP7,"typedef " + REMAIN$(Src$," "),";"
  1866. Src$ = ""
  1867. EXIT FUNCTION
  1868. '****************************
  1869. CASE "$resou"
  1870. '****************************
  1871. LOCAL resAlias$,resFile$
  1872. Use_Embed = TRUE
  1873. PassOne = 1
  1874. CALL XParse(Src$)
  1875. PassOne = 0
  1876. EntryCnt++
  1877. Entry$[EntryCnt]= "ld -r -b binary "+ Stk$[2] +" -o "+Stk$[2]+".o"
  1878. REPLACE "." WITH "_" IN Stk$[2]
  1879. resFile$=REMOVE$(Stk$[2],DQ$)
  1880. resAlias$=REMOVE$(Stk$[3],DQ$)
  1881. CALL AddGlobal("_binary_"+resFile$+"_start",vt_INTEGER, 0,"",0,0,1,0)
  1882. CALL AddGlobal("_binary_"+resFile$+"_size",vt_INTEGER, 0,"",0,0,1,0)
  1883. Src$="CONST " +resAlias$ + "= &_binary_"+resFile$+"_start"
  1884. CALL Parse(Src$)
  1885. CALL Emit
  1886. Src$="CONST " +resAlias$ + "_SIZE = (int)&_binary_"+resFile$+"_size"
  1887. CALL Parse(Src$)
  1888. CALL Emit
  1889. Src$ = ""
  1890. EXIT FUNCTION
  1891. '****************************
  1892. CASE "$turbo"
  1893. '****************************
  1894. Src$ = LTRIM$(MID$(Src$,7))
  1895. IF *Src$ <> 0 THEN
  1896. TurboSize = VAL(Src$)
  1897. IF (TurboSize & (TurboSize-1)) <> 0 THEN
  1898. TurboSize = 512
  1899. Warning("Invalid $Turbo size - defaulting to 512")
  1900. END IF
  1901. ELSE
  1902. TurboSize = 512
  1903. END IF
  1904. Use_Turbo = TRUE
  1905. Src$ = ""
  1906. EXIT FUNCTION
  1907. '****************************
  1908. CASE "$sourc"
  1909. '****************************
  1910. SrcFlag = NOT SrcFlag
  1911. Src$ = ""
  1912. EXIT FUNCTION
  1913. '****************************
  1914. CASE "$fssta"
  1915. '****************************
  1916. Use_Static = NOT Use_Static
  1917. Src$ = ""
  1918. EXIT FUNCTION
  1919. '****************************
  1920. CASE "$trace"
  1921. '****************************
  1922. TrcFlag = NOT TrcFlag
  1923. Src$ = ""
  1924. EXIT FUNCTION
  1925. '****************************
  1926. CASE "$inclu","$modul"
  1927. '****************************
  1928. DIM RAW orgfileName$
  1929. szFile$ = TRIM$(REMOVE$(MID$(Src$,9),DQ$))
  1930. orgfileName$ = szFile$
  1931. IF LEFT$(szFile$,1) = "<" THEN
  1932. szFile$ = MID$(szFile$, 2, LEN(szFile$)-2)
  1933. szFile$ = ENVIRON$("BCXLIB") + szFile$
  1934. END IF
  1935. IF NOT EXIST(szFile$) THEN
  1936. szFile$ = BcxSplitPath$(szFile$, FNAME|FEXT)
  1937. szFile$ = BcxSplitPath$(FileIn$, FDRV|FPATH) + szFile$
  1938. END IF
  1939. IF NOT EXIST(szFile$) THEN Abort("Unable to locate " + orgfileName$)
  1940. CALL PushFileIO
  1941. OPEN szFile$ FOR INPUT AS SourceFile
  1942. Modules$[++ModuleNdx] = szFile$
  1943. ModuleLineNos[ModuleNdx] = 0
  1944. FUNCTION = 1
  1945. '****************************
  1946. ' Beginning of Temporary Directives
  1947. ' in support of C++ Classes
  1948. '****************************
  1949. CASE "$try"
  1950. '****************************
  1951. FPRINT Outfile,"try {"
  1952. Src$ = ""
  1953. EXIT FUNCTION
  1954. '****************************
  1955. CASE "$throw"
  1956. szTmp$ = MID$(Src$,8)
  1957. IF szTmp$ = "" THEN szTmp$ = ENC$("An Exception has occured!")
  1958. FPRINT Outfile,Scoot$,"throw " + szTmp$ + ";"
  1959. Src$ = ""
  1960. EXIT FUNCTION
  1961. '****************************
  1962. CASE "$catch"
  1963. '****************************
  1964. szTmp$ = MID$(Src$,8)
  1965. IF szTmp$ = "" THEN szTmp$ = "char *str"
  1966. FPRINT Outfile,"}"
  1967. FPRINT Outfile,"catch (" + szTmp$ + ")" ' catch (char *str)
  1968. FPRINT Outfile,"{"
  1969. Src$ = ""
  1970. EXIT FUNCTION
  1971. '****************************
  1972. CASE "$endtr"
  1973. '****************************
  1974. FPRINT Outfile,"}"
  1975. Src$ = ""
  1976. EXIT FUNCTION
  1977. '/** 2010/11/30 Added -AIR **/
  1978. '****************************
  1979. CASE "$endna"
  1980. '****************************
  1981. InNameSpace--
  1982. CALL BumpDown
  1983. FPRINT Outfile,Scoot$,"}"
  1984. Src$ = ""
  1985. EXIT FUNCTION
  1986. '****************************
  1987. CASE "$names"
  1988. '****************************
  1989. '// 2010/11/30 REMOVED $NAMESPACE
  1990. Abort("$NAMESPACE/$ENDNAMESPACE have been removed from this version. Use NAMESPACE / END NAMESPACE instead.")
  1991. '~ UseCpp = TRUE
  1992. '~ szTmp$ = MID$(Src$,INCHR(Src$," ")+1)
  1993. '~ FPRINT Outfile,"namespace " + LTRIM$(szTmp$)
  1994. '~ FPRINT Outfile,"{"
  1995. '~ '/** 2010/11/30 Added -AIR **/
  1996. '~ InNameSpace++
  1997. '~ CALL BumpUp
  1998. '~ Src$ = ""
  1999. '~ EXIT FUNCTION
  2000. '****************************
  2001. CASE "$usena"
  2002. '****************************
  2003. UseCpp = TRUE
  2004. szTmp$ = MID$(Src$, INCHR(Src$, " ") + 1)
  2005. IF RIGHT$(TRIM$(szTmp$),1) <> ";" THEN
  2006. FPRINT Outfile,"using namespace ", szTmp$, ";"
  2007. ELSE
  2008. FPRINT Outfile,"using namespace ", szTmp$
  2009. END IF
  2010. Src$ = ""
  2011. EXIT FUNCTION
  2012. '****************************
  2013. CASE "$class"
  2014. '****************************
  2015. '/** 2010/11/30 REMOVED $CLASS KEYWORD/FUNCTIONALITY -AIR **/
  2016. Abort("$CLASS has been removed from this version. Use CLASS instead.")
  2017. '~ LOCAL tmpSrc$
  2018. '~ STATIC BeenHere
  2019. '~ UseCpp = TRUE
  2020. '~ szTmp$ = MID$(Src$, INCHR(Src$, " ") + 1)
  2021. '~ IF NOT BeenHere THEN
  2022. '~ BeenHere++
  2023. '~ FPRINT FP4,"#ifndef __cplusplus"
  2024. '~ FPRINT FP4," #error A C++ compiler is required"
  2025. '~ FPRINT FP4,"#endif"
  2026. '~ FPRINT FP4,""
  2027. '~ END IF
  2028. '~ '--------- BEGIN INSERT ----------------
  2029. '~ IF INSTR(szTmp$,"inherits",0,1) THEN IREPLACE "inherits" WITH ": public" IN szTmp$
  2030. '~ FPRINT FP4,"class ";szTmp$;" {"
  2031. '~ '--------- END INSERT ----------------
  2032. '~
  2033. '~ '************
  2034. '~ WHILE NOT iMatchLft(Src$,"$endclass")
  2035. '~ IF EOF(SourceFile) THEN Abort ("$Class Without $EndClass")
  2036. '~ LINE INPUT SourceFile,Src$
  2037. '~ tmpSrc$=TRIM$(Src$)
  2038. '~ ModuleLineNos[ModuleNdx]++
  2039. '~ 'StripCode(Src$)
  2040. '~ '--------- BEGIN INSERT ----------------
  2041. '~ IF iMatchLft(Src$,"$endclass") THEN
  2042. '~ FPRINT FP4,"};"
  2043. '~ '--------- END INSERT ----------------
  2044. '~ EXIT LOOP
  2045. '~ END IF
  2046. '~ ' IF iMatchLft(tmpSrc$,"sub") THEN IREPLACE "sub" with "void" in Src$
  2047. '~ ' IF iMatchLft(tmpSrc$,"public:") OR iMatchLft(tmpSrc$,"private:") OR iMatchLft(tmpSrc$,"DECLARE_EVENT_TABLE()") OR iMatchLft(tmpSrc$,"'") OR LEN(tmpSrc$)=0 THEN
  2048. '~ ' FPRINT FP4,Src$
  2049. '~ ' ELSE
  2050. '~ ' FPRINT FP4,Src$;";"
  2051. '~ ' END IF
  2052. '~ WEND
  2053. '~ Src$ = ""
  2054. '~ tmpSrc$ = ""
  2055. EXIT FUNCTION
  2056. '****************************
  2057. CASE "$inter"
  2058. '****************************
  2059. STATIC BeenHere
  2060. UseCpp = TRUE
  2061. szTmp$ = REMAIN$(Src$, SPC$)
  2062. IF NOT BeenHere THEN
  2063. BeenHere++
  2064. FPRINT FP4,"#ifndef __cplusplus"
  2065. FPRINT FP4," #error A C++ compiler is required"
  2066. FPRINT FP4,"#endif"
  2067. END IF
  2068. FPRINT FP4,"interface ";szTmp$;" {" '<--------------
  2069. DO '//; changed/added by whatsup
  2070. IF EOF(SourceFile) THEN Abort ("$Interface Without $EndInterface")
  2071. LINE INPUT SourceFile,Src$
  2072. ModuleLineNos[ModuleNdx]++
  2073. 'StripCode(Src$)
  2074. IF iMatchLft(LTRIM$(Src$),"$endinterface") THEN
  2075. EXIT LOOP
  2076. END IF
  2077. FPRINT FP4,Src$
  2078. LOOP
  2079. FPRINT FP4,"}";TRIM$(Src$ + 13);";" '<-------------- '//; changed/added by whatsup
  2080. '//;Src$ = ""
  2081. EXIT FUNCTION
  2082. '****************************
  2083. ' END of Temporary Directives
  2084. ' in support of C++ Classes
  2085. '****************************
  2086. CASE "$comme"
  2087. '****************************
  2088. Src$ = ""
  2089. DO
  2090. IF EOF(SourceFile) THEN Abort ("Unbalanced $Comment")
  2091. LINE INPUT SourceFile,Src$
  2092. ModuleLineNos[ModuleNdx]++
  2093. CALL StripTabs
  2094. IF iMatchLft(LTRIM$(Src$),"$comment") THEN EXIT LOOP
  2095. FPRINT Outfile,"// ",Src$
  2096. LOOP
  2097. Src$ = ""
  2098. EXIT FUNCTION
  2099. '****************************
  2100. CASE "$ccode"
  2101. '****************************
  2102. Src$ = ""
  2103. DO
  2104. IF EOF(SourceFile) THEN Abort ("Unbalanced $Ccode")
  2105. LINE INPUT SourceFile,Src$
  2106. ModuleLineNos[ModuleNdx]++
  2107. CALL StripTabs
  2108. IF iMatchLft(LTRIM$(Src$) ,"$ccode") THEN
  2109. IF SrcFlag THEN 'comments seem to interfere with C line continuations '\'
  2110. FPRINT Outfile,"// [", TRIM$(Modules$[ModuleNdx]), " - ", _
  2111. TRIM$(STR$(ModuleLineNos[ModuleNdx])), "] End of $CCODE Block"
  2112. END IF
  2113. EXIT LOOP
  2114. END IF
  2115. FPRINT Outfile,RTRIM$(Src$)
  2116. LOOP
  2117. Src$ = ""
  2118. EXIT FUNCTION
  2119. '****************************
  2120. CASE "$cprot"
  2121. '****************************
  2122. FastLexer(Src$, SPC$, "!")
  2123. IF iMatchWrd(Stk$[2], "!") THEN
  2124. ProtoCnt++
  2125. ProtoType[ProtoCnt].Prototype$ = REMAIN$(Src$, "!")
  2126. ProtoType[ProtoCnt].Condition$ = ""
  2127. ProtoType[ProtoCnt].CondLevel = 0
  2128. ELSE
  2129. i = iMatchNQ(Src$, "function")
  2130. IF i = 0 THEN
  2131. i = iMatchNQ(Src$, "sub")
  2132. END IF
  2133. IF i THEN
  2134. Src$ = "c_declare " + MID$(Src$, i)
  2135. ELSE
  2136. i = iMatchNQ(Src$, "$cproto")
  2137. Src$ = "c_declare function " + MID$(Src$, i+7)
  2138. END IF
  2139. UseCProto = TRUE
  2140. FUNCTION = 2
  2141. END IF
  2142. Src$ = ""
  2143. EXIT FUNCTION
  2144. '****************************
  2145. CASE "$heade"
  2146. '****************************
  2147. Src$ = ""
  2148. FPRINT FP7, "// ***************************************************"
  2149. FPRINT FP7, ""
  2150. DO
  2151. IF EOF(SourceFile) THEN Abort ("Unbalanced $Header")
  2152. LINE INPUT SourceFile,Src$
  2153. ModuleLineNos[ModuleNdx]++
  2154. CALL StripTabs
  2155. Src$ = TRIM$(Src$)
  2156. IF iMatchLft(Src$,"$heade") THEN EXIT LOOP
  2157. FPRINT FP7,Src$
  2158. LOOP
  2159. Src$ = ""
  2160. FPRINT FP7, ""
  2161. EXIT FUNCTION
  2162. '****************************
  2163. CASE "$asm"
  2164. '****************************
  2165. IF NOT iMatchLft(Src$,"$asm") THEN
  2166. Abort ("Unknown metastatement: " + Src$)
  2167. END IF
  2168. Src$ = ""
  2169. DO
  2170. IF EOF(SourceFile) THEN Abort ("Unbalanced $Asm")
  2171. LINE INPUT SourceFile,Src$
  2172. ModuleLineNos[ModuleNdx]++
  2173. IF SrcFlag THEN
  2174. FPRINT Outfile,"// ",Src$
  2175. END IF
  2176. CALL StripTabs
  2177. Src$ = TRIM$(Src$)
  2178. DIM meta_asm_loop
  2179. DIM meta_asm_comment_present AS bool
  2180. DIM Src_Len
  2181. Src_Len = LEN(Src$)
  2182. meta_asm_comment_present = FALSE
  2183. FOR meta_asm_loop = 0 TO Src_Len
  2184. '******************************************
  2185. ' Extracts both the Basic Single Quote
  2186. ' and the Assembly Semicolon
  2187. '******************************************
  2188. IF Src[meta_asm_loop] = 39 OR Src[meta_asm_loop] = 59 THEN
  2189. lszTmp$ = RIGHT$(Src$,Src_Len - meta_asm_loop - 1)
  2190. Src[meta_asm_loop] = 0
  2191. meta_asm_comment_present = TRUE
  2192. EXIT LOOP
  2193. END IF
  2194. NEXT
  2195. Src$ = TRIM$(Src$)
  2196. IF iMatchLft(Src$,"$asm") THEN EXIT LOOP
  2197. REPLACE "$" WITH "0x" IN Src$
  2198. IREPLACE "&h" WITH "0x" IN Src$
  2199. IF Src$ <> "" THEN
  2200. Src$ = "_asm(" + ENC$(Src$) + CHR$(1)
  2201. IF meta_asm_comment_present THEN
  2202. Src$ = Src$ + TAB$ + "//" + lszTmp$
  2203. END IF
  2204. SrcTmp$ = Src$
  2205. FPRINT Outfile,"#if !defined( __POCC__ ) && !defined (__cplusplus )"
  2206. REPLACE CHR$(1) WITH ")" IN Src$
  2207. FPRINT Outfile,Src$
  2208. FPRINT Outfile,"#else"
  2209. REPLACE "_asm(" WITH "__asm{" IN SrcTmp$
  2210. REPLACE CHR$(1) WITH "}" IN SrcTmp$
  2211. FPRINT Outfile,REMOVE$(SrcTmp$,DQ$)
  2212. FPRINT Outfile,"#endif"
  2213. END IF
  2214. LOOP
  2215. Src$ = ""
  2216. EXIT FUNCTION
  2217. '****************************
  2218. CASE "#inclu"
  2219. '****************************
  2220. '/***** 2010-11-18 Fixed this to always emit lowercase "#include" -AIR *****/
  2221. Src$ = REMOVE$(LCASE$(Src$),"#include")
  2222. Src$ = TRIM$(Src$)
  2223. FPRINT FP7, "#include ",Src$
  2224. Src$ = ""
  2225. EXIT FUNCTION
  2226. '****************************
  2227. CASE "$libra"
  2228. '****************************
  2229. 'Src$ = EXTRACT$(Src$,"'") ' allow comments
  2230. REPLACE "\\" WITH "\\\\" IN Src$
  2231. Src$ = REMOVE$(LCASE$(Src$),"$library")
  2232. Src$ = TRIM$(Src$)
  2233. AddLibrary(Src$)
  2234. Src$ = ""
  2235. EXIT FUNCTION
  2236. '****************************
  2237. CASE "$nolib"
  2238. '****************************
  2239. 'Src$ = EXTRACT$(Src$,"'") ' allow comments
  2240. REPLACE "\\" WITH "\\\\" IN Src$
  2241. Src$ = REMOVE$(LCASE$(Src$),"$nolibrary")
  2242. RemoveLibrary(Src$)
  2243. Src$ = ""
  2244. EXIT FUNCTION
  2245. END SELECT
  2246. END IF
  2247. FUNCTION = 2
  2248. END FUNCTION ' Directives
  2249. FUNCTION SubVarType(TokenNum)
  2250. DIM RAW k, j = 0
  2251. k = CheckLocal(Stk$[TokenNum], &j)
  2252. IF k = vt_CHAR THEN
  2253. IF *LocalVars[j].VarDim$ <> ASC("[") AND LocalVars[j].VarPntr = 0 THEN
  2254. k = vt_INTEGER
  2255. ENDIF
  2256. ELSEIF k = vt_UNKNOWN THEN
  2257. k = CheckGlobal(Stk$[TokenNum], &j)
  2258. IF k = vt_CHAR THEN
  2259. IF *GlobalVars[j].VarDim$ <> ASC("[") AND GlobalVars[j].VarPntr = 0 THEN
  2260. k = vt_INTEGER
  2261. ENDIF
  2262. ENDIF
  2263. END IF
  2264. j = ASC(RIGHT$(Stk$[TokenNum],1))
  2265. SELECT CASE k
  2266. CASE vt_STRVAR, vt_CHAR
  2267. IF j <> 36 THEN
  2268. CONCAT (Stk$[TokenNum], "$")
  2269. END IF
  2270. CASE vt_INTEGER
  2271. IF j <> 37 THEN
  2272. CONCAT (Stk$[TokenNum], "%")
  2273. END IF
  2274. CASE vt_SINGLE
  2275. IF j <> 33 THEN
  2276. CONCAT (Stk$[TokenNum], "!")
  2277. END IF
  2278. CASE vt_DOUBLE
  2279. IF j <> 35 THEN
  2280. CONCAT (Stk$[TokenNum], "#")
  2281. END IF
  2282. CASE vt_LDOUBLE
  2283. IF j <> 166 THEN
  2284. CONCAT (Stk$[TokenNum], "¦")
  2285. END IF
  2286. END SELECT
  2287. FUNCTION = k
  2288. END FUNCTION ' SubVarType
  2289. FUNCTION PrintWriteFormat$(DoWrite)
  2290. DIM RAW Stak[128] AS ARGTYPE
  2291. DIM RAW Frmat$
  2292. DIM RAW Arg$
  2293. DIM RAW ZZ$
  2294. DIM RAW Cast$
  2295. DIM RAW NewLineFlag = 0
  2296. DIM RAW Argcount = 0
  2297. DIM RAW i = 0
  2298. DIM RAW j = 0
  2299. DIM RAW k = 0
  2300. Frmat$ = ""
  2301. Arg$ = ""
  2302. ZZ$ = ""
  2303. IF Stk$[Ndx]= ";" THEN
  2304. NewLineFlag = TRUE
  2305. Ndx--
  2306. END IF
  2307. IF Ndx = 1 THEN GOTO PrintWriteLabel
  2308. Stak[1].ArgType = -1
  2309. j = 2
  2310. WHILE j <= Ndx
  2311. IF Clean$(Stk$[j]) <> "BCX_DynaCall" THEN
  2312. i = SubVarType(j)
  2313. IF Stak[Argcount+1].ArgType = -1 THEN
  2314. IF i = vt_CHAR OR i = vt_STRVAR OR i = vt_INTEGER OR i = vt_SINGLE OR i = vt_DOUBLE OR i = vt_LDOUBLE THEN
  2315. Stak[Argcount+1].ArgType = i
  2316. END IF
  2317. END IF
  2318. IF Stk$[j] = "(" THEN
  2319. i = 0
  2320. DO
  2321. IF Stk$[j] = "(" THEN i++
  2322. IF Stk$[j] = ")" THEN i--
  2323. CONCAT (Arg$,Stk$[j])
  2324. j++
  2325. LOOP UNTIL i <= 0 OR j >= Ndx
  2326. END IF
  2327. IF Stk$[j] = "[" THEN
  2328. i = 0
  2329. DO
  2330. IF Stk$[j] = "[" THEN i++
  2331. IF Stk$[j] = "]" THEN i--
  2332. CONCAT (Arg$,Stk$[j])
  2333. j++
  2334. IF Stk$[j] = "[" AND i = 0 THEN ITERATE
  2335. LOOP UNTIL i <= 0 OR j >= Ndx
  2336. END IF
  2337. IF Stk$[j] = ";" OR Stk$[j] = "," OR Stk$[j] = "&" THEN
  2338. Argcount++
  2339. Stak[Argcount].Arg$ = Arg$
  2340. Stak[Argcount+1].ArgType = -1
  2341. Arg$ = ""
  2342. j++
  2343. ELSE
  2344. CONCAT (Arg$,Stk$[j])
  2345. j++
  2346. END IF
  2347. ELSE
  2348. CONCAT(Arg$,Stk$[j])
  2349. j++
  2350. END IF
  2351. WEND
  2352. Argcount++
  2353. Stak[Argcount].Arg$ = Arg$
  2354. Arg$ = ""
  2355. FOR i = 1 TO Argcount
  2356. j = Stak[i].ArgType
  2357. IF j = -1 THEN
  2358. ZZ$ = EXTRACT$(Stak[i].Arg$,"(")
  2359. j = DataType(ZZ$)
  2360. END IF
  2361. SELECT CASE j
  2362. CASE vt_STRLIT, vt_STRVAR, vt_CHAR
  2363. IF DoWrite THEN
  2364. Frmat$ = Frmat$ + "\\" + DQ$ + "%s" + "\\" + DQ$ + ","
  2365. ELSE
  2366. CONCAT (Frmat$,"%s")
  2367. END IF
  2368. IF LEFT$(ZZ$, 12) = "BCX_DynaCall" THEN
  2369. Arg$ = Arg$ + ",(char*)" + Stak[i].Arg$
  2370. ELSE
  2371. Arg$ = Arg$ + "," + Stak[i].Arg$
  2372. END IF
  2373. CASE vt_INTEGER, vt_DECFUNC
  2374. IF DoWrite THEN
  2375. Frmat$ = Frmat$ + "%d" + ","
  2376. ELSE
  2377. CONCAT (Frmat$,"%d")
  2378. END IF
  2379. Arg$ = Arg$ + ",(int)" + Stak[i].Arg$
  2380. CASE vt_SINGLE
  2381. IF DoWrite THEN
  2382. Frmat$ = Frmat$ + "%.7G" + ","
  2383. ELSE
  2384. CONCAT (Frmat$,"%.7G")
  2385. END IF
  2386. Arg$ = Arg$ + ",(float)" + Stak[i].Arg$
  2387. CASE vt_DOUBLE,vt_NUMBER
  2388. IF DoWrite THEN
  2389. Frmat$ = Frmat$ + "%.15G" + ","
  2390. ELSE
  2391. CONCAT (Frmat$,"%.15G")
  2392. END IF
  2393. Arg$ = Arg$ + ",(double)" + Stak[i].Arg$
  2394. CASE vt_LDOUBLE
  2395. IF DoWrite THEN
  2396. Frmat$ = Frmat$ + "%.19LG" + ","
  2397. ELSE
  2398. CONCAT (Frmat$,"%.19LG")
  2399. END IF
  2400. Arg$ = Arg$ + ",(LDOUBLE)" + Stak[i].Arg$
  2401. CASE ELSE
  2402. IF ASC(Stak[i].Arg$) = ASC("(") THEN
  2403. ZZ$ = ""
  2404. CONCAT(Arg$,",")
  2405. DO
  2406. k = INSTR(Stak[i].Arg$,")")
  2407. Cast$ = MID$(Stak[i].Arg$ ,1 ,k)
  2408. Stak[i].Arg$ = TRIM$(MID$(Stak[i].Arg$,k+1))
  2409. IREPLACE "char*" WITH "char *" IN Cast$
  2410. IREPLACE "integer" WITH "int" IN Cast$
  2411. IREPLACE "single" WITH "float" IN Cast$
  2412. IREPLACE "ldouble" WITH "LDOUBLE" IN Cast$
  2413. IF ZZ$ = "" THEN
  2414. IF Cast$ = "(char *)" OR Cast$ = "(int)" OR Cast$ = "(float)" OR Cast$ = "(double)" OR Cast$ = "(LDOUBLE)" THEN
  2415. ZZ$ = Cast$
  2416. ELSE
  2417. ZZ$ = "(double)"
  2418. Cast$ = ZZ$ + Cast$
  2419. END IF
  2420. RemoveAll(ZZ$,"()")
  2421. IREPLACE "char *" WITH "%s" IN ZZ$
  2422. IREPLACE "int" WITH "%d" IN ZZ$
  2423. IREPLACE "float" WITH "%.7G" IN ZZ$
  2424. IREPLACE "ldouble" WITH "%.19LG" IN ZZ$
  2425. IREPLACE "double" WITH "%.15G" IN ZZ$
  2426. END IF
  2427. CONCAT(Arg$,Cast$)
  2428. LOOP WHILE ASC(Stak[i].Arg$) = 40
  2429. CONCAT(Arg$, Stak[i].Arg$)
  2430. CONCAT (Frmat$,ZZ$)
  2431. IF DoWrite THEN CONCAT (Frmat$,",")
  2432. ELSE
  2433. IF DoWrite THEN
  2434. Frmat$ = Frmat$ + "%G" + ","
  2435. ELSE
  2436. CONCAT (Frmat$,"%G")
  2437. Arg$ = Arg$ + ",(float)" + Stak[i].Arg$
  2438. END IF
  2439. END IF
  2440. END SELECT
  2441. NEXT
  2442. IF DoWrite THEN Frmat$ = LEFT$(Frmat$,LEN(Frmat$)-1)
  2443. '*********************
  2444. PrintWriteLabel:
  2445. '*********************
  2446. IF NewLineFlag = 0 THEN
  2447. CONCAT (Frmat$,"\\n")
  2448. END IF
  2449. FUNCTION = "printf(" + ENC$(Frmat$) + Clean$(Arg$) + ");"
  2450. END FUNCTION ' PrintWriteFormat$
  2451. SUB EmitInputCode
  2452. DIM RAW Argcount = 0
  2453. DIM RAW VarCnt = 0
  2454. DIM RAW i = 0
  2455. DIM RAW j = 0
  2456. DIM RAW l = 0
  2457. DIM RAW Arg$
  2458. DIM RAW Tmp$
  2459. DIM RAW Frmat$
  2460. DIM Stak$[128]
  2461. DIM RAW Y$
  2462. DIM RAW ZZ$
  2463. Use_Inputbuffer = TRUE
  2464. Use_Scan = TRUE
  2465. Use_Split = TRUE
  2466. Use_Remove = TRUE
  2467. Use_StrStr = TRUE
  2468. Use_Mid = TRUE
  2469. Use_Left = TRUE
  2470. Use_Instr = TRUE
  2471. Use_Stristr = TRUE
  2472. UseLCaseTbl = TRUE
  2473. UseFlag = TRUE
  2474. Use_Lineinput = TRUE
  2475. Arg$ = ""
  2476. ZZ$ = ""
  2477. Frmat$ = ""
  2478. Tmp$ = DQ$ + "," + DQ$ + "," + DQ$ + " " + DQ$
  2479. IF DataType(Stk$[2]) = vt_STRLIT THEN
  2480. FPRINT Outfile,Scoot$,"printf(" ; Clean$(Stk$[2]) ; ");"
  2481. END IF
  2482. IF DataType(Stk$[2]) = vt_STRLIT THEN
  2483. j = 4
  2484. ELSE
  2485. j = 2
  2486. END IF
  2487. l = j
  2488. WHILE j <= Ndx
  2489. IF j = l THEN
  2490. i = SubVarType(j)
  2491. END IF
  2492. IF Stk$[j] = "," THEN l = j + 1
  2493. CONCAT(ZZ$, Stk$[j])
  2494. j++
  2495. WEND
  2496. FastLexer(ZZ$, "", ",")
  2497. j = 1 '0
  2498. WHILE j <= Ndx
  2499. IF Stk$[j] = "," THEN
  2500. Argcount++
  2501. Stak$[Argcount]= Arg$
  2502. Arg$ = ""
  2503. j++
  2504. ELSE
  2505. CONCAT (Arg$, Stk$[j])
  2506. j++
  2507. IF j < Ndx THEN
  2508. IF Stk$[j] = "[" THEN
  2509. i = 0
  2510. DO
  2511. DoAgain:
  2512. IF Stk$[j] = "[" THEN i++
  2513. IF Stk$[j] = "]" THEN i--
  2514. CONCAT (Arg$,Stk$[j])
  2515. j++
  2516. IF Stk$[j] = "[" AND i = 0 THEN GOTO DoAgain
  2517. LOOP UNTIL i <= 0 OR j >= Ndx
  2518. END IF
  2519. END IF
  2520. END IF
  2521. WEND
  2522. Argcount++
  2523. Stak$[Argcount] = Arg$
  2524. Arg$ = ""
  2525. FOR i = 1 TO Argcount
  2526. Y$ = Stak$[i]
  2527. j = DataType(Y$)
  2528. SELECT CASE j
  2529. CASE vt_STRVAR
  2530. CONCAT (Frmat$,"%s")
  2531. Arg$ = Arg$ + "," + Clean$(Stak$[i])
  2532. FPRINT Outfile,Scoot$, "*" + TRIM$(Clean$(Stak$[i])) + "=0;"
  2533. VarCnt++
  2534. CASE vt_INTEGER
  2535. CONCAT (Frmat$,"%d")
  2536. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2537. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2538. VarCnt++
  2539. CASE vt_SINGLE
  2540. CONCAT (Frmat$,"%g")
  2541. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2542. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2543. VarCnt++
  2544. CASE vt_DOUBLE
  2545. CONCAT (Frmat$,"%lG")
  2546. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2547. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2548. VarCnt++
  2549. CASE vt_LDOUBLE
  2550. CONCAT (Frmat$,"%lG")
  2551. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2552. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2553. VarCnt++
  2554. CASE ELSE
  2555. CONCAT (Frmat$,"%d")
  2556. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2557. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2558. VarCnt++
  2559. END SELECT
  2560. NEXT
  2561. FPRINT Outfile,Scoot$, "AR_fgets_retval=fgets(InputBuffer,sizeof(InputBuffer),stdin);"
  2562. FPRINT Outfile,Scoot$, "InputBuffer[strlen(InputBuffer)-1]=0;"
  2563. FPRINT Outfile,Scoot$, "ScanError = scan(InputBuffer," + ENC$(Frmat$) + Arg$ + ");\n"
  2564. FPRINT Outfile,Scoot$, "*InputBuffer=0;"
  2565. END SUB ' EmitInputCode
  2566. SUB EmitFileInputCode
  2567. DIM RAW Argcount = 0
  2568. DIM RAW VarCnt = 0
  2569. DIM RAW i
  2570. DIM RAW j
  2571. DIM RAW Arg$
  2572. DIM RAW Frmat$
  2573. DIM RAW FHandle$
  2574. DIM RAW Y$
  2575. DIM RAW ZZ$
  2576. DIM Stak$[128]
  2577. Arg$ = ""
  2578. Frmat$ = ""
  2579. ZZ$ = ""
  2580. FHandle$ = ""
  2581. Use_Inputbuffer = TRUE
  2582. Use_Scan = TRUE
  2583. Use_Split = TRUE
  2584. Use_Remove= TRUE
  2585. Use_StrStr= TRUE
  2586. Use_Mid = TRUE
  2587. Use_Left = TRUE
  2588. Use_Instr = TRUE
  2589. Use_Stristr = TRUE
  2590. UseLCaseTbl = TRUE
  2591. i = 4 ' Extract the file handle
  2592. FOR j = 2 TO Ndx
  2593. IF *Stk$[j] = ASC(",") THEN i=j+1 : EXIT FOR
  2594. FHandle$ = FHandle$ + Stk$[j]
  2595. NEXT j
  2596. FOR j = i TO Ndx ' build the variable list
  2597. IF j = i THEN SubVarType(j)
  2598. IF Stk$[j] = "," THEN SubVarType(j+1)
  2599. CONCAT(ZZ$, Stk$[j])
  2600. NEXT
  2601. FastLexer(ZZ$, "", ",")
  2602. j = 1 '0
  2603. WHILE j <= Ndx
  2604. IF Stk$[j] = "," THEN
  2605. Argcount++
  2606. Stak$[Argcount]= Arg$
  2607. Arg$ = ""
  2608. j++
  2609. ELSE
  2610. CONCAT (Arg$, Stk$[j])
  2611. j++
  2612. IF j < Ndx THEN
  2613. IF Stk$[j] = "[" THEN
  2614. i = 0
  2615. DO
  2616. DoAgain:
  2617. IF Stk$[j] = "[" THEN i++
  2618. IF Stk$[j] = "]" THEN i--
  2619. CONCAT (Arg$,Stk$[j])
  2620. j++
  2621. IF Stk$[j] = "[" AND i = 0 THEN GOTO DoAgain
  2622. LOOP UNTIL i <= 0 OR j >= Ndx
  2623. END IF
  2624. END IF
  2625. END IF
  2626. WEND
  2627. Argcount++
  2628. Stak$[Argcount] = Arg$
  2629. Arg$ = ""
  2630. FOR i = 1 TO Argcount
  2631. Y$ = Stak$[i]
  2632. j = DataType(Y$)
  2633. SELECT CASE j
  2634. CASE vt_STRVAR
  2635. CONCAT (Frmat$, "%s")
  2636. Arg$ = Arg$ + "," + Clean$(Stak$[i])
  2637. FPRINT Outfile,Scoot$, "*" + TRIM$(Clean$(Stak$[i])) + "=0;"
  2638. VarCnt++
  2639. CASE vt_INTEGER
  2640. CONCAT (Frmat$, "%d")
  2641. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2642. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2643. VarCnt++
  2644. CASE vt_SINGLE
  2645. CONCAT (Frmat$, "%g")
  2646. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2647. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2648. VarCnt++
  2649. CASE vt_DOUBLE
  2650. CONCAT (Frmat$, "%lG")
  2651. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2652. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2653. VarCnt++
  2654. CASE vt_LDOUBLE
  2655. CONCAT (Frmat$, "%lG")
  2656. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2657. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2658. VarCnt++
  2659. CASE ELSE
  2660. CONCAT (Frmat$, "%d")
  2661. Arg$ = Arg$ + ",&" + Clean$(Stak$[i])
  2662. FPRINT Outfile,Scoot$, Clean$(Stak$[i]) + "=0;"
  2663. VarCnt++
  2664. END SELECT
  2665. NEXT
  2666. FPRINT Outfile,Scoot$, "AR_fgets_retval=fgets(InputBuffer,1048576," ; FHandle$ ; ");"
  2667. FPRINT Outfile,Scoot$, "if(InputBuffer[strlen(InputBuffer)-1]== 10)"
  2668. FPRINT Outfile,Scoot$, " InputBuffer[strlen(InputBuffer)-1]=0;"
  2669. FPRINT Outfile,Scoot$, "ScanError = scan(InputBuffer," + ENC$(Frmat$) + Arg$ + ");\n"
  2670. FPRINT Outfile,Scoot$, "*InputBuffer=0;"
  2671. END SUB ' EmitFileInputCode
  2672. SUB AddFuncs
  2673. DIM RAW ZZ$
  2674. DIM RAW Last$
  2675. Last$ = ""
  2676. CALL CloseAll
  2677. OPEN prcFile$ FOR INPUT AS FP1
  2678. OPEN FileOut$ FOR APPEND AS Outfile
  2679. IF ProtoType[1].Prototype$ > "" THEN
  2680. FPRINT Outfile,""
  2681. FPRINT Outfile,"// ************************************"
  2682. FPRINT Outfile,"// " + $BCX_STR_USR_PROCS
  2683. FPRINT Outfile,"// ************************************"
  2684. FPRINT Outfile,"\n"
  2685. END IF
  2686. WHILE NOT EOF(FP1)
  2687. LINE INPUT FP1,ZZ$
  2688. '================== strip out dead callback code ======================
  2689. IF INSTR(ZZ$,"DefWindowProc") THEN
  2690. IF INSTR(Last$,"return ") OR _
  2691. INSTR(Last$,"CallWindowProc") OR _
  2692. INSTR(Last$,"DefWindowProc") OR _
  2693. INSTR(Last$,"DefMDIChildProc") OR _
  2694. INSTR(Last$,"DefFrameProc") THEN
  2695. Last$ = ""
  2696. ITERATE
  2697. END IF
  2698. END IF
  2699. '======================================================================
  2700. FPRINT Outfile,ZZ$
  2701. IF LEFT$(ZZ$,2) <> "//" THEN
  2702. Last$ = ZZ$
  2703. END IF
  2704. WEND
  2705. CALL CloseAll
  2706. KILL prcFile$ ' translated subs and functions
  2707. KILL udtFile$ ' translated User Defined Types
  2708. KILL datFile$ ' translated DATA statements
  2709. KILL cstFile$ ' translated CONSTants
  2710. KILL ovrFile$ ' translated overloaded subs and functions
  2711. KILL setFile$ ' translated KILL set statements
  2712. KILL enuFile$ ' translated GLOBAL enum blocks
  2713. END SUB ' AddFuncs
  2714. FUNCTION CheckLocal(ZZ$, BYREF varidx)
  2715. DIM RAW TT$
  2716. IF LocalVarCnt THEN
  2717. TT$ = Clean$(ZZ$)
  2718. RemoveAll(TT$, " &*()", 1)
  2719. IF INSTR(TT$,"[") THEN TT$ = LEFT$(TT$,INSTR(TT$,"[")-1)
  2720. FOR INTEGER i = 1 TO LocalVarCnt
  2721. IF TT$ = LocalVars[i].VarName$ THEN
  2722. varidx = i
  2723. FUNCTION = LocalVars[i].VarType
  2724. END IF
  2725. NEXT
  2726. END IF
  2727. FUNCTION = vt_UNKNOWN
  2728. END FUNCTION ' CheckLocal
  2729. FUNCTION CheckGlobal(ZZ$, BYREF varidx)
  2730. DIM RAW hn
  2731. DIM RAW s
  2732. DIM RAW TT$
  2733. TT$ = Clean$(ZZ$)
  2734. RemoveAll(TT$, " &*()", 1)
  2735. IF INSTR(TT$,"[") THEN TT$ = LEFT$(TT$,INSTR(TT$,"[")-1)
  2736. hn = HashNumber(TT$)
  2737. WHILE GlobalVarHash[hn]
  2738. s = GlobalVarHash[hn]
  2739. IF TT$ = GlobalVars[s].VarName$ THEN
  2740. varidx = s
  2741. FUNCTION = GlobalVars[s].VarType
  2742. END IF
  2743. hn = IMOD(hn + 1,MaxGlobalVars)
  2744. WEND
  2745. FUNCTION = vt_UNKNOWN
  2746. END FUNCTION ' CheckGlobal
  2747. FUNCTION CheckType(ZZ$)
  2748. DIM RAW Keyword$
  2749. DIM RAW varid = 0
  2750. DIM RAW i
  2751. Keyword$ = LCASE$(ZZ$)
  2752. SELECT CASE Keyword$
  2753. CASE "int"
  2754. FUNCTION = vt_INTEGER
  2755. CASE "string"
  2756. FUNCTION = vt_STRVAR
  2757. CASE "char"
  2758. FUNCTION = vt_CHAR
  2759. CASE "pchar"
  2760. FUNCTION = vt_PCHAR
  2761. CASE "byte"
  2762. FUNCTION = vt_BYTE
  2763. CASE "double"
  2764. FUNCTION = vt_DOUBLE
  2765. CASE "ldouble"
  2766. FUNCTION = vt_LDOUBLE
  2767. CASE "file"
  2768. FUNCTION = vt_FILEPTR
  2769. CASE "float"
  2770. FUNCTION = vt_SINGLE
  2771. CASE "bool", "boolean"
  2772. FUNCTION = vt_BOOL
  2773. CASE "long"
  2774. FUNCTION = vt_LONG
  2775. CASE "dword"
  2776. FUNCTION = vt_DWORD
  2777. CASE "farproc"
  2778. FUNCTION = vt_FARPROC
  2779. CASE "void"
  2780. FUNCTION = vt_VOID
  2781. CASE "lpbyte"
  2782. FUNCTION = vt_LPBYTE
  2783. CASE "lresult"
  2784. FUNCTION = vt_LRESULT
  2785. CASE "short"
  2786. FUNCTION = vt_SHORT
  2787. CASE "ushort"
  2788. FUNCTION = vt_USHORT
  2789. CASE "uint"
  2790. FUNCTION = vt_UINT
  2791. CASE "ulong"
  2792. FUNCTION = vt_ULONG
  2793. CASE "colorref"
  2794. FUNCTION = vt_COLORREF
  2795. CASE "handle"
  2796. FUNCTION = vt_HANDLE
  2797. CASE "hdc"
  2798. FUNCTION = vt_HDC
  2799. CASE "variant"
  2800. FUNCTION = vt_VARIANT
  2801. END SELECT
  2802. i = CheckLocal(ZZ$, &varid)
  2803. IF i = vt_UNKNOWN THEN
  2804. i = DefsID(ZZ$)
  2805. IF i THEN FUNCTION = TypeDefs[i].TypeofDef
  2806. ELSE
  2807. FUNCTION = i
  2808. END IF
  2809. FUNCTION = CheckGlobal(ZZ$, &varid)
  2810. END FUNCTION ' CheckType
  2811. SUB ExportInternalConst
  2812. IF Use_FillArray THEN
  2813. Src$="CONST vt_INTEGER = 2"
  2814. PassOne = 1
  2815. CALL Parse(Src$)
  2816. CALL Emit
  2817. Src$="CONST vt_SINGLE = 3"
  2818. PassOne = 1
  2819. CALL Parse(Src$)
  2820. CALL Emit
  2821. Src$="CONST vt_DOUBLE = 4"
  2822. PassOne = 1
  2823. CALL Parse(Src$)
  2824. CALL Emit
  2825. Src$="CONST vt_LDOUBLE = 5"
  2826. PassOne = 1
  2827. CALL Parse(Src$)
  2828. CALL Emit
  2829. END IF
  2830. END SUB ' ExportInternalConst
  2831. FUNCTION RestrictedWords(ZZ$)
  2832. IF ZZ$ = "CmdLine" THEN FUNCTION = 1
  2833. IF ZZ$ = "CmdShow" THEN FUNCTION = 1
  2834. IF ZZ$ = "hInst" THEN FUNCTION = 1
  2835. IF ZZ$ = "hPrev" THEN FUNCTION = 1
  2836. IF ZZ$ = "hWnd" THEN FUNCTION = 1
  2837. IF ZZ$ = "lParam" THEN FUNCTION = 1
  2838. IF ZZ$ = "Msg" THEN FUNCTION = 1
  2839. IF ZZ$ = "wParam" THEN FUNCTION = 1
  2840. IF ZZ$ = "vt_INTEGER" THEN FUNCTION = 1
  2841. IF ZZ$ = "vt_SINGLE" THEN FUNCTION = 1
  2842. IF ZZ$ = "vt_DOUBLE" THEN FUNCTION = 1
  2843. IF ZZ$ = "vt_LDOUBLE" THEN FUNCTION = 1
  2844. FUNCTION = 0
  2845. END FUNCTION ' RestrictedWords
  2846. FUNCTION DataType(ZZ$)
  2847. DIM RAW Keyword$
  2848. DIM RAW i
  2849. IF ZZ[0] = 34 THEN
  2850. FUNCTION = vt_STRLIT
  2851. END IF
  2852. IF INCHR(ZZ$,"$") THEN
  2853. FUNCTION = vt_STRVAR
  2854. END IF
  2855. IF IsNumber(ZZ$) THEN
  2856. FUNCTION = vt_NUMBER
  2857. END IF
  2858. i = DefsID(ZZ$)
  2859. IF i THEN FUNCTION = TypeDefs[i].TypeofDef
  2860. '****************
  2861. ' Functions
  2862. '****************
  2863. Keyword$ = LCASE$(ZZ$)
  2864. IF Keyword$ = "strlen" THEN
  2865. FUNCTION = vt_DECFUNC
  2866. END IF
  2867. IF Keyword$ = "instr" THEN
  2868. FUNCTION = vt_DECFUNC
  2869. END IF
  2870. IF Keyword$ = "inchr" THEN
  2871. FUNCTION = vt_DECFUNC
  2872. END IF
  2873. IF Keyword$ = "sizeof" THEN
  2874. FUNCTION = vt_DECFUNC
  2875. END IF
  2876. IF Keyword$ = "tally" THEN
  2877. FUNCTION = vt_DECFUNC
  2878. END IF
  2879. IF Keyword$ = "band" THEN
  2880. FUNCTION = vt_DECFUNC
  2881. END IF
  2882. IF Keyword$ = "bor" THEN
  2883. FUNCTION = vt_DECFUNC
  2884. END IF
  2885. IF Keyword$ = "lof" THEN
  2886. FUNCTION = vt_DOUBLE
  2887. END IF
  2888. IF Keyword$ = "pos" THEN
  2889. FUNCTION = vt_DECFUNC
  2890. END IF
  2891. IF Keyword$ = "qbcolor" THEN
  2892. FUNCTION = vt_DECFUNC
  2893. END IF
  2894. IF Keyword$ = "split" THEN
  2895. FUNCTION = vt_DECFUNC
  2896. END IF
  2897. IF Keyword$ = "dsplit" THEN
  2898. FUNCTION = vt_DECFUNC
  2899. END IF
  2900. IF Keyword$ = "sgn" THEN
  2901. FUNCTION = vt_DECFUNC
  2902. END IF
  2903. IF Keyword$ = "timer" THEN
  2904. FUNCTION = vt_SINGLE
  2905. END IF
  2906. IF Keyword$ = "keypress()" THEN
  2907. FUNCTION = vt_DECFUNC
  2908. END IF
  2909. IF Keyword$ = "getattr" THEN
  2910. FUNCTION = vt_DECFUNC
  2911. END IF
  2912. IF Keyword$ = "fix" THEN
  2913. FUNCTION = vt_DECFUNC
  2914. END IF
  2915. IF Keyword$ = "instrrev" THEN
  2916. FUNCTION = vt_DECFUNC
  2917. END IF
  2918. IF Keyword$ = "kbhit" THEN
  2919. FUNCTION = vt_DECFUNC
  2920. END IF
  2921. IF Keyword$ = "exp" THEN
  2922. FUNCTION = vt_DOUBLE
  2923. END IF
  2924. IF Keyword$ = "expl" THEN
  2925. FUNCTION = vt_LDOUBLE
  2926. END IF
  2927. IF Keyword$ = "sinh" THEN
  2928. FUNCTION = vt_DOUBLE
  2929. END IF
  2930. IF Keyword$ = "cosh" THEN
  2931. FUNCTION = vt_DOUBLE
  2932. END IF
  2933. IF Keyword$ = "tanh" THEN
  2934. FUNCTION = vt_DOUBLE
  2935. END IF
  2936. IF Keyword$ = "asinh" THEN
  2937. FUNCTION = vt_DOUBLE
  2938. END IF
  2939. IF Keyword$ = "acosh" THEN
  2940. FUNCTION = vt_DOUBLE
  2941. END IF
  2942. IF Keyword$ = "atanh" THEN
  2943. FUNCTION = vt_DOUBLE
  2944. END IF
  2945. IF Keyword$ = "round" THEN
  2946. FUNCTION = vt_DOUBLE
  2947. END IF
  2948. IF Keyword$ = "val" THEN
  2949. FUNCTION = vt_DOUBLE
  2950. END IF
  2951. IF Keyword$ = "vall" THEN
  2952. FUNCTION = vt_LDOUBLE
  2953. END IF
  2954. IF Keyword$ = "iif" THEN
  2955. FUNCTION = vt_DOUBLE
  2956. END IF
  2957. IF Keyword$ = "bin2dec" THEN
  2958. FUNCTION = vt_INTEGER
  2959. END IF
  2960. IF Keyword$ = "hex2dec" THEN
  2961. FUNCTION = vt_INTEGER
  2962. END IF
  2963. IF Keyword$ = "rnd" THEN
  2964. FUNCTION = vt_SINGLE
  2965. END IF
  2966. IF Keyword$ = "frac" THEN
  2967. FUNCTION = vt_DOUBLE
  2968. END IF
  2969. IF Keyword$ = "fracl" THEN
  2970. FUNCTION = vt_LDOUBLE
  2971. END IF
  2972. IF Keyword$ = "asin" THEN
  2973. FUNCTION = vt_DOUBLE
  2974. END IF
  2975. IF Keyword$ = "asinl" THEN
  2976. FUNCTION = vt_LDOUBLE
  2977. END IF
  2978. IF Keyword$ = "hypot" THEN
  2979. FUNCTION = vt_DOUBLE
  2980. END IF
  2981. IF Keyword$ = "hypotl" THEN
  2982. FUNCTION = vt_LDOUBLE
  2983. END IF
  2984. IF Keyword$ = "log" THEN
  2985. FUNCTION = vt_DOUBLE
  2986. END IF
  2987. IF Keyword$ = "logl" THEN
  2988. FUNCTION = vt_LDOUBLE
  2989. END IF
  2990. IF Keyword$ = "log10" THEN
  2991. FUNCTION = vt_DOUBLE
  2992. END IF
  2993. IF Keyword$ = "log10l" THEN
  2994. FUNCTION = vt_LDOUBLE
  2995. END IF
  2996. IF Keyword$ = "acos" THEN
  2997. FUNCTION = vt_DOUBLE
  2998. END IF
  2999. IF Keyword$ = "acosl" THEN
  3000. FUNCTION = vt_LDOUBLE
  3001. END IF
  3002. IF Keyword$ = "atan" THEN
  3003. FUNCTION = vt_DOUBLE
  3004. END IF
  3005. IF Keyword$ = "atanl" THEN
  3006. FUNCTION = vt_DOUBLE
  3007. END IF
  3008. IF Keyword$ = "sin" THEN
  3009. FUNCTION = vt_DOUBLE
  3010. END IF
  3011. IF Keyword$ = "sinl" THEN
  3012. FUNCTION = vt_LDOUBLE
  3013. END IF
  3014. IF Keyword$ = "cos" THEN
  3015. FUNCTION = vt_DOUBLE
  3016. END IF
  3017. IF Keyword$ = "cosl" THEN
  3018. FUNCTION = vt_LDOUBLE
  3019. END IF
  3020. IF Keyword$ = "tan" THEN
  3021. FUNCTION = vt_DOUBLE
  3022. END IF
  3023. IF Keyword$ = "tanl" THEN
  3024. FUNCTION = vt_LDOUBLE
  3025. END IF
  3026. IF Keyword$ = "pow" THEN
  3027. FUNCTION = vt_DOUBLE
  3028. END IF
  3029. IF Keyword$ = "powl" THEN
  3030. FUNCTION = vt_LDOUBLE
  3031. END IF
  3032. IF Keyword$ = "sqrt" THEN
  3033. FUNCTION = vt_DOUBLE
  3034. END IF
  3035. IF Keyword$ = "sqrtl" THEN
  3036. FUNCTION = vt_LDOUBLE
  3037. END IF
  3038. IF Keyword$ = "min" THEN
  3039. FUNCTION = vt_DOUBLE
  3040. END IF
  3041. IF Keyword$ = "max" THEN
  3042. FUNCTION = vt_DOUBLE
  3043. END IF
  3044. IF Keyword$ = "exist" THEN
  3045. FUNCTION = vt_DECFUNC
  3046. END IF
  3047. IF Keyword$ = "abs" THEN
  3048. FUNCTION = vt_DOUBLE
  3049. END IF
  3050. IF Keyword$ = "absl" THEN
  3051. FUNCTION = vt_LDOUBLE
  3052. END IF
  3053. IF Keyword$ = "freefile" THEN
  3054. FUNCTION = vt_FILEPTR
  3055. END IF
  3056. IF Keyword$ = "fint" THEN
  3057. FUNCTION = vt_INTEGER
  3058. END IF
  3059. IF INCHR(ZZ$,"%") THEN
  3060. FUNCTION = vt_INTEGER
  3061. END IF
  3062. IF INCHR(ZZ$,"!") THEN
  3063. FUNCTION = vt_SINGLE
  3064. END IF
  3065. IF INCHR(ZZ$,"#") THEN
  3066. FUNCTION = vt_DOUBLE
  3067. END IF
  3068. IF INCHR(ZZ$,"^") THEN
  3069. FUNCTION = vt_DOUBLE
  3070. END IF
  3071. IF INCHR(ZZ$,"¦") THEN
  3072. FUNCTION = vt_LDOUBLE
  3073. END IF
  3074. IF iMatchRgt(ZZ$,"@") THEN
  3075. FUNCTION = vt_FILEPTR
  3076. END IF
  3077. IF INCHR(ZZ$," ") THEN
  3078. FUNCTION = vt_UDT
  3079. END IF
  3080. IF isalpha(*ZZ$) THEN
  3081. FUNCTION = vt_INTEGER
  3082. END IF
  3083. FUNCTION = vt_UNKNOWN
  3084. END FUNCTION ' DataType
  3085. SUB CloseAll
  3086. !#if defined (__APPLE__)
  3087. CLOSE SourceFile
  3088. CLOSE FP2
  3089. CLOSE FP3
  3090. CLOSE FP4
  3091. CLOSE FP5
  3092. CLOSE FP6
  3093. CLOSE FP7
  3094. CLOSE FP8
  3095. CLOSE FP9
  3096. CLOSE FP10
  3097. CLOSE FP11
  3098. CLOSE Outfile
  3099. CLOSE FP1
  3100. CLOSE ResIn
  3101. CLOSE ResOut
  3102. CLOSE UserResIn
  3103. CLOSE fpErr
  3104. CLOSE fpHFile
  3105. CLOSE FP68
  3106. CLOSE fpdef
  3107. CLOSE SaveOutfileNum
  3108. !#else
  3109. CLOSE ' Flush and Close all open files
  3110. !#endif
  3111. END SUB ' CloseAll
  3112. FUNCTION Clean$(ZZ$)
  3113. DIM RAW Tmp$
  3114. IF INCHR(ZZ$,"%") THEN
  3115. IF TRIM$(ZZ$) = "%" THEN FUNCTION = " % "
  3116. END IF
  3117. IF iMatchNQ(ZZ$,"!=") THEN FUNCTION = ZZ$
  3118. Tmp$ = ZZ$
  3119. RemoveAll(Tmp$,"%$#!@¦",1) '1 = ignore anything in quotes
  3120. FUNCTION = Tmp$
  3121. END FUNCTION ' Clean$
  3122. SUB RemoveAll OPTIONAL(Arg$, MatchChars$, qtflag=0)
  3123. DIM RAW C = Arg AS PCHAR
  3124. DIM RAW pmc AS PCHAR
  3125. WHILE *Arg
  3126. IF qtflag THEN
  3127. IF *Arg = 34 THEN
  3128. *(C++) = *Arg
  3129. WHILE *(++Arg) <> 34
  3130. *(C++) = *Arg
  3131. IF *Arg = 0 THEN EXIT SUB
  3132. WEND
  3133. *(C++) = *(Arg++)
  3134. ITERATE
  3135. END IF
  3136. END IF
  3137. pmc = MatchChars
  3138. WHILE *pmc
  3139. IF *(pmc++) = *Arg THEN GOTO SKIP
  3140. WEND
  3141. *(C++) = *Arg
  3142. SKIP:
  3143. INCR Arg
  3144. WEND
  3145. *C = 0
  3146. END SUB
  3147. SUB Warning OPTIONAL(ZZ$, WarnLvl=0)
  3148. LOCAL fErr AS FILE
  3149. IF WarnLvl THEN
  3150. WarnMsg$ = WarnMsg$ + " Line" + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + " - " + ZZ$
  3151. ELSE
  3152. WarnMsg$ = WarnMsg$ + ZZ$
  3153. END IF
  3154. WarnMsg$ = WarnMsg$ + CRLF$
  3155. IF ErrFile THEN
  3156. OPEN FileErr$ FOR APPEND AS fErr
  3157. FPRINT fErr, "WARNING ";ZZ$
  3158. CLOSE fErr
  3159. END IF
  3160. END SUB ' Warnings
  3161. FUNCTION GetVarTypeName(i) AS PCHAR
  3162. DIM STATIC A$
  3163. SELECT CASE i
  3164. CASE vt_INTEGER : A$ = "int"
  3165. CASE vt_STRVAR : A$ = "char *"
  3166. CASE vt_STRLIT : A$ = "STRLIT"
  3167. CASE vt_UNKNOWN : A$ = "UNKNOWN"
  3168. CASE vt_SINGLE : A$ = "float"
  3169. CASE vt_DOUBLE : A$ = "double"
  3170. CASE vt_LDOUBLE : A$ = "LDOUBLE"
  3171. CASE vt_DECFUNC : A$ = "DECFUNC"
  3172. CASE vt_NUMBER : A$ = "NUMBER"
  3173. CASE vt_FILEPTR : A$ = "FILE*"
  3174. CASE vt_UDT : A$ = "struct"
  3175. CASE vt_STRUCT : A$ = "struct"
  3176. CASE vt_UNION : A$ = "union"
  3177. CASE vt_BOOL : A$ = "bool"
  3178. CASE vt_CHAR : A$ = "char"
  3179. CASE vt_CHARPTR : A$ = "char"
  3180. CASE vt_PCHAR : A$ = "PCHAR"
  3181. CASE vt_VOID : A$ = "void"
  3182. CASE vt_LONG : A$ = "long"
  3183. CASE vt_DWORD : A$ = "DWORD"
  3184. CASE vt_FARPROC : A$ = "FARPROC"
  3185. CASE vt_LPBYTE : A$ = "LPBYTE"
  3186. CASE vt_LRESULT : A$ = "LRESULT"
  3187. CASE vt_BYTE : A$ = "BYTE"
  3188. CASE vt_SHORT : A$ = "short"
  3189. CASE vt_USHORT : A$ = "USHORT"
  3190. CASE vt_COLORREF : A$ = "COLORREF"
  3191. CASE vt_UINT : A$ = "UINT"
  3192. CASE vt_ULONG : A$ = "ULONG"
  3193. CASE vt_HANDLE : A$ = "HANDLE"
  3194. CASE vt_HINSTANCE : A$ = "HINSTANCE"
  3195. CASE vt_HDC : A$ = "HDC"
  3196. CASE vt_VARIANT : A$ = "VARIANT"
  3197. CASE ELSE : A$ = ""
  3198. END SELECT
  3199. FUNCTION = A
  3200. END FUNCTION ' GetVarTypeName$
  3201. FUNCTION HashNumber(HT$)
  3202. DIM RAW TT AS CHAR PTR
  3203. DIM RAW i = 0 AS ULONG
  3204. TT = HT
  3205. WHILE *TT
  3206. i <<= 1
  3207. ! i ^= *TT;
  3208. TT++
  3209. WEND
  3210. FUNCTION = IMOD(i,MaxGlobalVars)
  3211. END FUNCTION 'HashNumber
  3212. SUB AddLibrary( LibName$ )
  3213. STATIC nTimes
  3214. LOCAL nLibNdx
  3215. DIM RAW TempLibName$
  3216. TempLibName$ = LCASE$(LibName$)
  3217. IF NOT INCHR(TempLibName$,DQ$) AND NOT INCHR(TempLibName$,"<") THEN
  3218. TempLibName$ = ENC$(TempLibName$,60,62)
  3219. END IF
  3220. IF nTimes = 0 THEN
  3221. FOR INTEGER i = 0 TO MaxLib - 1
  3222. Library$[i] = ""
  3223. NEXT
  3224. nTimes++
  3225. Library$[0] = TempLibName$
  3226. EXIT SUB
  3227. END IF
  3228. nLibNdx = 0
  3229. WHILE Library$[nLibNdx] <> ""
  3230. IF Library$[nLibNdx] = TempLibName$ THEN EXIT SUB
  3231. INCR nLibNdx
  3232. WEND
  3233. IF nLibNdx < MaxLib - 1 THEN
  3234. Library$[nLibNdx] = TempLibName$
  3235. END IF
  3236. END SUB ' AddLibrary
  3237. SUB RemoveLibrary( LibName$ )
  3238. IF NOT INSTR( RmLibs$, LibName$, 1, 1 ) THEN
  3239. RmLibs$ = RmLibs$ + "," + LCASE$(LibName$)
  3240. END IF
  3241. END SUB ' RemoveLibrary
  3242. SUB EmitLibs()
  3243. STATIC nTimes
  3244. STATIC nCount
  3245. DIM RAW ltmp$
  3246. IF nTimes > 0 THEN EXIT SUB
  3247. INCR nTimes
  3248. IF Library$[0] = "" THEN EXIT SUB
  3249. FPRINT FP7,""
  3250. FPRINT FP7,"#ifndef LINUXBCX"
  3251. FPRINT FP7,"#if !defined( __LCC__ )"
  3252. FOR INTEGER i = 0 TO MaxLib - 1
  3253. IF Library$[i] = "" AND nCount > 0 THEN
  3254. GOTO NEXTLIB
  3255. ELSEIF Library$[i] = "" THEN
  3256. GOTO NEXTLIB
  3257. END IF
  3258. ltmp$ = Library$[i]
  3259. RemoveAll(ltmp$,"<>" & DQ$)
  3260. IF INSTR( RmLibs$, ltmp$ ) THEN ITERATE ' skip libraries that have been removed
  3261. IF nCount = 0 THEN
  3262. INCR nCount
  3263. FPRINT FP7,"// *************************************************"
  3264. FPRINT FP7,"// Instruct Linker to Search Object/Import Libraries"
  3265. FPRINT FP7,"// *************************************************"
  3266. END IF
  3267. FPRINT FP7,"#pragma comment(lib,",ENC$(ltmp$), ")"
  3268. NEXT
  3269. NEXTLIB:
  3270. FPRINT FP7, "#else"
  3271. ' add lccwin32's default libraries to the remove library list so they won't be emitted
  3272. RmLibs$ = RmLibs$ + ",<libc.lib>,<kernel32.lib>,<comdlg32.lib>,<user32.lib>,<gdi32.lib>,<advapi32.lib>,<comctl32.lib>,<crtdll.lib>"
  3273. FOR INTEGER i = 0 TO MaxLib - 1
  3274. IF Library$[i] = "" AND nCount > 0 THEN
  3275. FPRINT FP7,"// *************************************************"
  3276. FPRINT FP7,"// End of Object/Import Libraries To Search"
  3277. FPRINT FP7,"// *************************************************"
  3278. GOTO LIBEND
  3279. ELSEIF Library$[i] = "" THEN
  3280. GOTO LIBEND
  3281. END IF
  3282. IF INSTR( RmLibs$, Library$[i] ) THEN ITERATE ' skip libraries that have been removed
  3283. IF nCount = 0 THEN
  3284. INCR nCount
  3285. FPRINT FP7,""
  3286. FPRINT FP7,"// *************************************************"
  3287. FPRINT FP7,"// Instruct Linker to Search Object/Import Libraries"
  3288. FPRINT FP7,"// *************************************************"
  3289. END IF
  3290. FPRINT FP7,"#pragma lib ",Library$[i]
  3291. NEXT
  3292. LIBEND:
  3293. FPRINT FP7,"#endif"
  3294. FPRINT FP7,"#endif // LINUXBCX not defined"
  3295. END SUB ' EmitLibs
  3296. SUB AddGlobal OPTIONAL(GlobalName$, GlobalType, GlobalDef, GlobalDim$, GlobalPtr, GlobalFS, GlobalExtn, iEmitted, iConst=0)
  3297. DIM RAW FirstVar$
  3298. DIM RAW SecondVar$
  3299. DIM RAW Warn$
  3300. DIM RAW ss
  3301. DIM RAW s
  3302. IF RestrictedWords(GlobalName$) AND TestState THEN
  3303. Warn$ = "Restricted Word " + GlobalName$ + " on Line"
  3304. Warn$ = Warn$ + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx])
  3305. CALL Warning(Warn$)
  3306. END IF
  3307. ss = HashNumber(GlobalName$)
  3308. WHILE GlobalVarHash[ss]
  3309. s = GlobalVarHash[ss]
  3310. IF GlobalName$ = GlobalVars[s].VarName$ THEN
  3311. IF InConditional = 0 OR (InConditional > 0 AND InIfDef$ = GlobalVars[s].VarCondDef$) THEN
  3312. IF GlobalVars[s].VarType <> GlobalType OR _
  3313. GlobalDim$ <> GlobalVars[s].VarDim$ OR _
  3314. GlobalVars[s].VarDef <> GlobalDef THEN
  3315. FirstVar$ = "Line" + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + " : " + GlobalName$ + GlobalDim$ + " as " + GetVarTypeName$(GlobalType) + " " + TypeDefs[GlobalDef].VarName$
  3316. SecondVar$ = "Line" + STR$(GlobalVars[s].VarLine) + " in Module: " + GlobalVars[s].VarModule + " : " + GlobalName$ + GlobalVars[s].VarDim$ + " as " + GetVarTypeName$(GlobalVars[s].VarType) + " " + TypeDefs[GlobalVars[s].VarDef].VarName$
  3317. Warn$ = "Two Variables " + FirstVar$ + " previously defined at " + SecondVar$
  3318. CALL Warning(Warn$)
  3319. END IF
  3320. EXIT SUB
  3321. END IF
  3322. END IF
  3323. ss = IMOD(ss + 1,MaxGlobalVars)
  3324. WEND
  3325. GlobalVarCnt++
  3326. IF GlobalVarCnt = MaxGlobalVars THEN Abort("Maximum Global Variables reached.")
  3327. GlobalVars[GlobalVarCnt].VarName$ = GlobalName$
  3328. GlobalVars[GlobalVarCnt].VarType = GlobalType
  3329. GlobalVars[GlobalVarCnt].VarDef = GlobalDef
  3330. GlobalVars[GlobalVarCnt].VarDim$ = GlobalDim$
  3331. GlobalVars[GlobalVarCnt].VarLine = ModuleLineNos[ModuleNdx]
  3332. GlobalVars[GlobalVarCnt].VarPntr = GlobalPtr
  3333. GlobalVars[GlobalVarCnt].VarSF = GlobalFS
  3334. GlobalVars[GlobalVarCnt].VarEmitFlag = iEmitted
  3335. GlobalVars[GlobalVarCnt].VarModule$ = TRIM$(Modules$[ModuleNdx])
  3336. GlobalVars[GlobalVarCnt].VarExtn = GlobalExtn
  3337. GlobalVars[GlobalVarCnt].VarCondLevel = InConditional
  3338. GlobalVars[GlobalVarCnt].VarConstant = iConst
  3339. GlobalVars[GlobalVarCnt].VarCondDef$ = InIfDef$
  3340. GlobalVarHash[ss] = GlobalVarCnt
  3341. END SUB ' AddGlobal
  3342. SUB AddLocal OPTIONAL(LocalName$, LocalType, LocalDef, LocalDim$, LocalPtr, LocalFS, iEmitted, iConst=0)
  3343. DIM RAW varid = 0
  3344. DIM RAW FirstVar$
  3345. DIM RAW SecondVar$
  3346. DIM RAW Warn$
  3347. DIM RAW s
  3348. IF LocalVarCnt AND TestState THEN
  3349. IF CheckGlobal(LocalName$, &varid) <> vt_UNKNOWN THEN
  3350. IF LocalDef THEN
  3351. FirstVar$ = "Line" + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + " : " + LocalName$ + LocalDim$ + " as " + TypeDefs[LocalDef].VarName$
  3352. ELSE
  3353. FirstVar$ = "Line" + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + " : " + LocalName$ + LocalDim$ + " as " + GetVarTypeName$(LocalType)
  3354. END IF
  3355. IF GlobalVars[varid].VarDef THEN
  3356. SecondVar$ = "Line" + STR$(GlobalVars[varid].VarLine) + " in Module: " + GlobalVars[varid].VarModule + " : " + LocalName$ + GlobalVars[varid].VarDim$ + " as " + TypeDefs[GlobalVars[varid].VarDef].VarName$
  3357. ELSE
  3358. SecondVar$ = "Line" + STR$(GlobalVars[varid].VarLine) + " in Module: " + GlobalVars[varid].VarModule + " : " + LocalName$ + GlobalVars[varid].VarDim$ + " as " + GetVarTypeName$(GlobalVars[varid].VarType)
  3359. END IF
  3360. Warn$ = "Local Variable " + FirstVar$ + CRLF$ + "Has Same Name as Global " + SecondVar$
  3361. CALL Warning(Warn$)
  3362. END IF
  3363. FOR s = 1 TO LocalVarCnt
  3364. IF LocalName$ = LocalVars[s].VarName$ THEN
  3365. IF LocalVars[s].VarType <> LocalType OR LocalDim$ <> LocalVars[s].VarDim$ OR LocalVars[s].VarDef <> LocalDef THEN
  3366. FirstVar$ = "Line" + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + " : " + LocalName$ + LocalDim$ + " as " + GetVarTypeName$(LocalType) + " " + TypeDefs[LocalDef].VarName$
  3367. SecondVar$ = "Line" + STR$(LocalVars[s].VarLine) + " in Module: " + LocalVars[s].VarModule + " : " + LocalName$ + LocalVars[s].VarDim$ + " as " + GetVarTypeName$(LocalVars[s].VarType) + " " + TypeDefs[LocalVars[s].VarDef].VarName$
  3368. Warn$ = "Two Variables " + FirstVar$ + " previously defined at " + SecondVar$
  3369. CALL Warning(Warn$)
  3370. END IF
  3371. EXIT SUB
  3372. END IF
  3373. NEXT
  3374. END IF
  3375. LocalVarCnt++
  3376. IF LocalVarCnt = MaxLocalVars THEN
  3377. Warn$ = "Maximum Local Variables reached."
  3378. Abort(Warn$)
  3379. END IF
  3380. LocalVars[LocalVarCnt].VarName$ = LocalName$
  3381. LocalVars[LocalVarCnt].VarType = LocalType
  3382. LocalVars[LocalVarCnt].VarDef = LocalDef
  3383. LocalVars[LocalVarCnt].VarDim$ = LocalDim$
  3384. LocalVars[LocalVarCnt].VarLine = ModuleLineNos[ModuleNdx]
  3385. LocalVars[LocalVarCnt].VarPntr = LocalPtr
  3386. LocalVars[LocalVarCnt].VarSF = LocalFS
  3387. LocalVars[LocalVarCnt].VarEmitFlag = iEmitted
  3388. LocalVars[LocalVarCnt].VarConstant = iConst
  3389. LocalVars[LocalVarCnt].VarModule$= TRIM$(Modules$[ModuleNdx])
  3390. END SUB ' AddLocal
  3391. FUNCTION IsNumber(a$)
  3392. DIM RAW i = 0
  3393. IF NOT *a THEN FUNCTION = FALSE ' Handle null arguments
  3394. WHILE a[i] ' While NOT null terminator
  3395. IF a[i]>47 AND a[i]<58 THEN ' Test for 0123456789
  3396. i++ ' bump our index
  3397. ELSE
  3398. FUNCTION = FALSE ' a$ is not a number
  3399. END IF '
  3400. WEND '
  3401. FUNCTION = TRUE ' a$ is a number
  3402. END FUNCTION ' IsNumber
  3403. FUNCTION IsNumberEx(a$)
  3404. DIM RAW i = 0
  3405. IF NOT *a THEN FUNCTION = FALSE ' Handle null arguments
  3406. WHILE a[i] ' While NOT null terminator
  3407. IF a[i]>44 AND a[i]<58 THEN ' Test FOR -+.0123456789
  3408. i++ ' bump our index
  3409. ELSE
  3410. FUNCTION = FALSE ' a$ is not a number
  3411. END IF '
  3412. WEND '
  3413. FUNCTION = TRUE ' a$ is a number
  3414. END FUNCTION ' IsNumberEx
  3415. SUB StripTabs
  3416. DIM RAW i = 0
  3417. WHILE Src[i]
  3418. IF Src[i] = 9 THEN Src[i] = 32
  3419. i++
  3420. WEND
  3421. END SUB ' StripTabs
  3422. SUB PushFileIO
  3423. FPtr[++FPtrNdx] = SourceFile
  3424. END SUB 'PushFileIO
  3425. SUB PopFileIO
  3426. IF FPtrNdx = 0 THEN EXIT SUB
  3427. CLOSE SourceFile
  3428. INCR LinesRead, ModuleLineNos[ModuleNdx--]
  3429. SourceFile = FPtr[FPtrNdx--]
  3430. END SUB 'PopFileIO
  3431. FUNCTION Inset(Mane$,Match$)
  3432. DIM RAW i = -1, j = -1
  3433. WHILE Match[++i]
  3434. WHILE Mane[++j]
  3435. IF Match[i] = Mane[j] THEN FUNCTION = TRUE
  3436. WEND
  3437. j = -1
  3438. WEND
  3439. FUNCTION = FALSE
  3440. END FUNCTION 'Inset
  3441. SUB CheckParQuotes
  3442. DIM RAW CountR=0 'Round bracket counter
  3443. DIM RAW CountS=0 'Square bracket counter
  3444. DIM RAW i=0
  3445. DIM RAW DoCount = TRUE AS bool
  3446. WHILE Src[i]
  3447. IF Src[i]=34 THEN
  3448. DoCount = NOT DoCount
  3449. END IF
  3450. IF DoCount THEN
  3451. IF Src[i]=40 THEN
  3452. CountR++
  3453. ELSEIF Src[i]=41 THEN
  3454. CountR--
  3455. ELSEIF Src[i]=91 THEN
  3456. CountS++
  3457. ELSEIF Src[i]=93 THEN
  3458. CountS--
  3459. END IF
  3460. END IF
  3461. i++
  3462. WEND
  3463. IF NOT DoCount THEN
  3464. Abort ("Unmatched Quotes")
  3465. ELSEIF CountS THEN
  3466. Abort ("Unmatched []")
  3467. ELSEIF CountR THEN
  3468. Abort ("Unmatched ()")
  3469. END IF
  3470. END SUB ' CheckParQuotes
  3471. SUB ClearIfThenStacks
  3472. FOR INTEGER i = 0 TO 127
  3473. SrcStk$[i] = ""
  3474. NEXT
  3475. SrcCnt = 0
  3476. END SUB ' ClearIfThenStacks
  3477. FUNCTION IsQuoted(ZZ$)
  3478. IF NOT iMatchLft(LTRIM$(ZZ$),DQ$) THEN EXIT FUNCTION
  3479. IF NOT iMatchRgt(RTRIM$(ZZ$),DQ$) THEN EXIT FUNCTION
  3480. FUNCTION = TRUE
  3481. END FUNCTION ' IsQuoted
  3482. SUB PostProcess
  3483. DIM RAW A
  3484. IF ReDirect = TRUE THEN
  3485. OPEN FileOut$ FOR INPUT AS FP1
  3486. WHILE NOT EOF(FP1)
  3487. LINE INPUT FP1,Z$
  3488. PRINT Z$
  3489. WEND
  3490. CALL CloseAll
  3491. END IF
  3492. '**************************
  3493. OutfileClone$ = FileOut$
  3494. FOR A = 1 TO EntryCnt
  3495. OutfileClone$ = EXTRACT$(OutfileClone$,".")
  3496. Cmd$ = REMOVE$(Entry$[A],DQ$)
  3497. REPLACE "\\\\" WITH "\\" IN Cmd$
  3498. IREPLACE "$file$" WITH EXTRACT$(OutfileClone$,".") IN Cmd$
  3499. PRINT "Shelling Out To: ", Cmd$
  3500. SHELL Cmd$
  3501. NEXT
  3502. IF Compiler$ > "" THEN
  3503. Compiler$ = TRIM$(REMOVE$(Compiler$,DQ$))
  3504. IF INCHR(Compiler$, " ") THEN
  3505. Compiler$ = ENC$(EXTRACT$(Compiler$," ")) + " " + REMAIN$(Compiler$," ")
  3506. ELSE
  3507. Compiler$ = ENC$(Compiler$)
  3508. END IF
  3509. '/***** 2018-12-09 Changed default output extension to ".cc" -AIR *****/
  3510. FileOut$ = EXTRACT$(FileOut$,".") + ".cc"
  3511. Compiler$ = Compiler$ + " " + FileOut$
  3512. IREPLACE "$FILE$" WITH EXTRACT$(OutfileClone$,".") IN Compiler$
  3513. REPLACE "\\\\" WITH "\\" IN Compiler$
  3514. REPLACE DDQ$ WITH DQ$ IN Compiler$
  3515. PRINT "Shelling Out To: ", Compiler$
  3516. SHELL Compiler$
  3517. END IF
  3518. '**************************
  3519. IF Linker$ > "" THEN
  3520. Linker$ = TRIM$(REMOVE$(Linker$,DQ$))
  3521. IF INCHR(Linker$, " ") THEN
  3522. Linker$ = DQ$ + EXTRACT$(Linker$," ") + DQ$ + " " + REMAIN$(Linker$," ")
  3523. ELSE
  3524. Linker$ = ENC$(Linker$)
  3525. END IF
  3526. FileOut$ = EXTRACT$(FileOut$,".") + ".obj"
  3527. Linker$ = Linker$ + " " + FileOut$
  3528. IREPLACE "$FILE$" WITH EXTRACT$(OutfileClone$,".") IN Linker$
  3529. REPLACE "\\\\" WITH "\\" IN Linker$
  3530. REPLACE DDQ$ WITH DQ$ IN Linker$
  3531. PRINT "Shelling Out To:", Linker$
  3532. SHELL Linker$
  3533. END IF
  3534. '**************************
  3535. FOR A = 1 TO XitCount
  3536. FileOut$ = EXTRACT$(FileOut$,".")
  3537. Cmd$ = REMOVE$(Xit$[A],DQ$)
  3538. IREPLACE "$FILE$" WITH EXTRACT$(OutfileClone$,".") IN Cmd$
  3539. REPLACE "\\\\" WITH "\\" IN Cmd$
  3540. REPLACE DDQ$ WITH DQ$ IN Cmd$
  3541. PRINT "Shelling Out To: ", Cmd$
  3542. SHELL Cmd$
  3543. NEXT
  3544. END SUB ' PostProcess
  3545. SUB XParse(Arg$)
  3546. DIM RAW lszTmp$
  3547. DIM RAW j, i = 0, Gapflag = 0
  3548. DIM RAW InIF = 0
  3549. IF TRIM$(Arg$) = "" THEN
  3550. Ndx = 0
  3551. EXIT SUB
  3552. END IF
  3553. '-----------------------------------------------
  3554. ' A temporary cure to allow the C '&&' operator
  3555. '-----------------------------------------------
  3556. i = iMatchNQ(Arg$, "&&")
  3557. WHILE i
  3558. Arg$ = DEL$(Arg$, i, 2)
  3559. Arg$ = INS$(Arg$, i, " and ")
  3560. i = iMatchNQ(Arg$, "&&")
  3561. WEND
  3562. '-----------------------------------------------
  3563. FastLexer(Arg$, SPC$, "=&()[]{}',+-*/<>?;.|:^")
  3564. '****************************************
  3565. ' Pre Parse
  3566. '****************************************
  3567. WHILE ++i < 17
  3568. Stk$[i+Ndx] = ""
  3569. WEND
  3570. FOR i = 1 TO Ndx
  3571. Keyword1$ = LCASE$(Stk$[i])
  3572. IF Keyword1[1] <> 0 THEN
  3573. SELECT CASE Keyword1$
  3574. CASE "and" : Stk$[i] = "&&"
  3575. CASE "or" : Stk$[i] = "||"
  3576. CASE "not" : Stk$[i] = "!"
  3577. CASE "is" : Stk$[i] = "="
  3578. CASE "xor" : Stk$[i] = "xor"
  3579. CASE "if","iif","iif$","case","elseif","while"
  3580. InIF = 1
  3581. CASE "then"
  3582. InIF = 0
  3583. CASE "byval"
  3584. Stk$[i] = ""
  3585. Gapflag = TRUE
  3586. CASE "byref"
  3587. IF NOT iMatchWrd(Stk$[1], "declare") AND _
  3588. NOT iMatchWrd(Stk$[1], "c_declare") THEN
  3589. ByrefVars$[++ByrefCnt] = Stk$[i+1]
  3590. END IF
  3591. FOR j = i TO Ndx
  3592. IF Stk$[j+1] = "," OR Stk$[j+1] = ")" THEN
  3593. Stk$[j] = "PTR"
  3594. EXIT FOR
  3595. END IF
  3596. Stk$[j] = Stk$[j+1]
  3597. NEXT
  3598. CASE ELSE
  3599. IF PassOne THEN
  3600. IF Keyword1$ = ENC$(CHR$(92)) THEN
  3601. Stk$[i] = "chr$"
  3602. InsertTokens(i, 3, "(", "92", ")")
  3603. INCR i,3
  3604. ELSEIF TranslateSlash THEN
  3605. REPLACE "\\" WITH "\\\\" IN Stk$[i]
  3606. END IF
  3607. END IF
  3608. END SELECT
  3609. '*******************************************************************
  3610. ' Allow logical 'OR/AND' to be used as 'binary BOR/BAND'
  3611. '*******************************************************************
  3612. IF NOT InIF THEN
  3613. IF Stk$[i] = "&&" THEN
  3614. Stk$[i] = "BAND"
  3615. ELSEIF Stk$[i] = "||" THEN
  3616. Stk$[i] = "BOR"
  3617. END IF
  3618. END IF
  3619. ELSE
  3620. SELECT CASE ASC(Keyword1$)
  3621. ' --------------------------------
  3622. ' Connect (&)addressof operator.
  3623. ' --------------------------------
  3624. CASE ASC("&")
  3625. IF i < 3 OR INCHR("+&,(=", Stk$[i-1]) THEN
  3626. Stk$[i+1] = " &" + Stk$[i+1]
  3627. Stk$[i] = "" : Gapflag=TRUE
  3628. END IF
  3629. CASE ASC("?")
  3630. Stk$[i] = "print"
  3631. CASE ASC("-")
  3632. IF ASC(Stk$[i+1]) = ASC(">") THEN
  3633. Stk$[i] = "->" & Stk$[i+2]
  3634. Stk$[++i] = "" : Stk$[++i] = ""
  3635. Gapflag=TRUE
  3636. END IF
  3637. CASE ASC(".")
  3638. IF IsNumber(Stk$[i-1]) THEN
  3639. Stk$[i] = Stk$[i-1] & "."
  3640. Stk$[i-1] = "" : Gapflag=TRUE
  3641. END IF
  3642. IF NOT INCHR( ",)=<>*/+-^" , Stk[i+1]) THEN
  3643. Stk$[i] = Stk$[i] & Stk$[i+1]
  3644. Stk$[++i] = "" : Gapflag=TRUE
  3645. END IF
  3646. END SELECT
  3647. END IF
  3648. NEXT i
  3649. IF Gapflag THEN
  3650. FOR i = 1 TO Ndx
  3651. IF NOT *Stk[i] THEN
  3652. j = i + 1
  3653. WHILE NOT *Stk[j] AND (j < Ndx)
  3654. INCR j
  3655. WEND
  3656. IF NOT *Stk[j] THEN EXIT FOR
  3657. Stk$[i] = Stk$[j] : Stk$[j] = ""
  3658. END IF
  3659. NEXT i
  3660. Ndx = i-1
  3661. END IF
  3662. ' *******************************************************************
  3663. ' Special Case Handler: BYREF - BCX prepends * to BYREF'd Variables
  3664. ' *******************************************************************
  3665. IF PassOne = 1 THEN
  3666. IF InFunc THEN ' Must be in a SUB or FUNCTION
  3667. FOR i = 1 TO Ndx
  3668. FOR j = 1 TO ByrefCnt
  3669. IF iMatchLft(Stk$[i], " &") THEN lszTmp$ = Stk$[i] + 2 ELSE lszTmp$ = Stk$[i]
  3670. IF Clean$(lszTmp$) = Clean$(ByrefVars[j]) THEN
  3671. IF i > 2 THEN
  3672. IF INCHR("+-^%*/|&<=>,", Stk$[i-2]) AND Stk$[i-1] = "*" THEN
  3673. Stk$[i-1] = ""
  3674. END IF
  3675. IF iMatchLft(Stk$[i], " &") THEN
  3676. Stk$[i] = Stk$[i] + 2
  3677. EXIT FOR
  3678. END IF
  3679. ELSEIF i = 2 THEN
  3680. IF Stk$[i-1] = "*" THEN Stk$[i-1] = ""
  3681. END IF
  3682. Stk$[i] = "*" & Stk$[i]
  3683. IF Stk$[i-1] <> "(" OR Stk$[i+1] <> ")" THEN
  3684. Stk$[i] = ENC$(Stk$[i], ASC("("), ASC(")"))
  3685. END IF
  3686. EXIT FOR
  3687. END IF
  3688. NEXT
  3689. NEXT
  3690. END IF
  3691. END IF
  3692. ' *******************************************************************
  3693. ' Special Case Handler: DIM BLAHBLAH[22][33] AS STATIC INTEGER
  3694. ' *******************************************************************
  3695. IF iMatchWrd(Stk$[1],"dim") THEN
  3696. IF iMatchWrd(Stk$[Ndx-1],"static") THEN
  3697. Stk$[1] = "static"
  3698. Stk$[Ndx-1] = Stk$[Ndx]
  3699. Ndx--
  3700. END IF
  3701. END IF
  3702. ' ***************************************************************************
  3703. ' Special Case Handler: In the contexts of UDT,s this handler transforms:
  3704. ' FUNCTION Foo (a as integer) AS INTEGER to:
  3705. ' DIM FUNCTION Foo (a as integer) AS INTEGER
  3706. '
  3707. ' Change "as string" to "as char *" for UDTs and Declarations
  3708. ' ***************************************************************************
  3709. Keyword1$ = LCASE$(Stk$[1])
  3710. IF InTypeDef THEN
  3711. IF Keyword1$ <> "end" AND Keyword1$ <> "dim" AND Keyword1$ <> "declare" AND Keyword1$ <> "type" AND Keyword1$ <> "union" THEN
  3712. InsertTokens(0, 1, "dim")
  3713. END IF
  3714. END IF
  3715. '******************************
  3716. '
  3717. '******************************
  3718. IF NOT InTypeDef THEN
  3719. DIM RAW lsz$, Res = 1
  3720. lsz$ = SPC$ & Keyword1$ & SPC$
  3721. IF iMatchNQ(" dim , local , global , raw , static , shared , dynamic , auto , register , extern ", lsz$) THEN
  3722. Res = 1
  3723. END IF
  3724. lsz$ = SPC$ & LCASE$(Stk$[2]) & SPC$
  3725. IF iMatchNQ(" dim , local , global , raw , static , shared , dynamic , auto , register , extern ", lsz$) THEN
  3726. Res = 2
  3727. END IF
  3728. IF Res > 0 THEN
  3729. i = Ndx
  3730. WHILE i > 1 AND Stk$[i] <> ")"
  3731. IF iMatchWrd(Stk$[i], "as") THEN
  3732. IF iMatchWrd(Stk$[i+1], "function") THEN
  3733. IF i+1 = Ndx THEN Stk$[i] = "" ' remove "as"
  3734. Stk$[i+1] = ""
  3735. InsertTokens(Res, 1, "function")
  3736. ELSEIF iMatchWrd(Stk$[i+1], "sub") THEN
  3737. IF i+1 = Ndx THEN Stk$[i] = "" ' remove "as"
  3738. Stk$[i+1] = ""
  3739. InsertTokens(Res, 1, "sub")
  3740. END IF
  3741. CALL RemEmptyTokens
  3742. EXIT WHILE
  3743. END IF
  3744. DECR i
  3745. WEND
  3746. END IF
  3747. END IF
  3748. IF InTypeDef OR iMatchWrd(Stk$[1], "declare") OR iMatchWrd(Stk$[1], "c_declare") THEN
  3749. IF iMatchWrd(Stk$[2],"sub") OR iMatchWrd(Stk$[2],"function") THEN
  3750. FOR INTEGER i = 2 TO Ndx
  3751. IF iMatchLft(Stk$[i],"as") AND iMatchWrd(Stk$[i+1],"string") THEN
  3752. IF *Stk$[i+2] <> ASC("*") THEN Stk$[i+1] = "char *"
  3753. END IF
  3754. NEXT
  3755. END IF
  3756. END IF
  3757. END SUB 'XParse
  3758. SUB TokenSubstitutions
  3759. '*****************************
  3760. ' Start Doing Text Substitutions
  3761. '*****************************
  3762. DIM RAW A
  3763. DIM RAW CompPtr
  3764. DIM RAW CompToken
  3765. DIM RAW Keyword$
  3766. DIM RAW a, i, j, Tmp
  3767. '******************************************************************************************
  3768. ' Following block added in 4.13 -- Dim XXX as string * 12345
  3769. ' Works in UDT, GLOBALS, LOCALS, and RAW
  3770. '******************************************************************************************
  3771. FOR i = 1 TO Ndx
  3772. IF iMatchWrd(Stk$[i],"as") THEN
  3773. IF iMatchWrd(Stk$[i+1],"string") THEN
  3774. IF Stk$[i+2] = "*" THEN
  3775. Stk$[i] = "["
  3776. Stk$[i+1] = Stk$[i+3]
  3777. Stk$[i+2] = "]"
  3778. Stk$[i+3] = "as"
  3779. INCR Ndx
  3780. Stk$[Ndx] = "char"
  3781. EXIT FOR
  3782. END IF
  3783. END IF
  3784. END IF
  3785. NEXT
  3786. '******************************************************************************************
  3787. FOR i = 1 TO Ndx
  3788. IF NOT InFunc THEN
  3789. IF iMatchWrd(Stk$[i],"global") THEN Stk$[i] = "dim"
  3790. END IF
  3791. NEXT
  3792. A = FALSE
  3793. FOR Tmp = 1 TO Ndx
  3794. IF *Stk[Tmp] = ASC("0") AND Stk[Tmp][1] <> ASC("x") AND Stk[Tmp][1] <> ASC("l") THEN
  3795. Stk$[Tmp] = LTRIM$(Stk$[Tmp],48) 'allow leading zero's in numbers
  3796. IF Stk$[Tmp] = "" THEN Stk$[Tmp] = "0"
  3797. END IF
  3798. IF iMatchWrd(Stk$[Tmp],"xor") THEN
  3799. Stk$[Tmp] = "^"
  3800. ELSEIF Stk$[Tmp] = "=" AND Stk$[Tmp+1]= ">" THEN
  3801. Stk$[Tmp] = ">"
  3802. Stk$[Tmp+1]= "="
  3803. ELSEIF Stk$[Tmp] = "=" AND Stk$[Tmp+1]= "<" THEN
  3804. Stk$[Tmp] = "<"
  3805. Stk$[Tmp+1] = "="
  3806. ELSEIF Stk$[Tmp] = "<" AND Stk$[Tmp+1]= ">" THEN
  3807. Stk$[Tmp] = "!="
  3808. Stk$[Tmp+1] = ""
  3809. A = TRUE
  3810. ELSEIF Stk$[Tmp] = ">" AND Stk$[Tmp+1]= "<" THEN
  3811. Stk$[Tmp] = "!="
  3812. Stk$[Tmp+1] = ""
  3813. A = TRUE
  3814. ELSEIF Stk$[Tmp]= "!" AND Stk$[Tmp+1]= "=" THEN
  3815. Stk$[Tmp]= "!="
  3816. Stk$[Tmp+1] = ""
  3817. A = TRUE
  3818. END IF
  3819. NEXT
  3820. IF A = TRUE THEN CALL RemEmptyTokens
  3821. '*************************************************************************
  3822. ' needed when recursively calling parse() after <> has already translated
  3823. ' to != Otherwise, on pass 2, it emits as !== which is NOT desired.
  3824. '*************************************************************************
  3825. CompToken = 0
  3826. FOR Tmp = 1 TO Ndx
  3827. A = CheckLocal(Stk$[Tmp], &i)
  3828. IF A = vt_UNKNOWN THEN A = CheckGlobal(Stk$[Tmp], &i)
  3829. IF A = vt_STRUCT OR A = vt_UDT OR A = vt_UNION THEN
  3830. CompToken = 1
  3831. END IF
  3832. IF iMatchWrd(Stk$[Tmp],"int") AND Stk$[Tmp+1] = "(" THEN
  3833. Stk$[Tmp]= "fint"
  3834. ELSEIF iMatchWrd(Stk$[Tmp],"integer") THEN
  3835. Stk$[Tmp]= "int"
  3836. ELSEIF iMatchWrd(Stk$[Tmp],"fint") AND Stk$[Tmp+1]= ")" THEN
  3837. Stk$[Tmp]= "int"
  3838. END IF
  3839. NEXT
  3840. '*****************************
  3841. CompPtr = 0
  3842. FOR Tmp = 1 TO Ndx
  3843. Keyword$ = LCASE$(Stk$[Tmp])
  3844. a = INCHR("abcdefghijklmnopqrstuvwxyz", Keyword$)
  3845. SELECT CASE a
  3846. CASE 1
  3847. SELECT CASE Keyword$
  3848. CASE "abs"
  3849. Stk$[Tmp]= "abs" ' might need fabs
  3850. CASE "acos"
  3851. Stk$[Tmp]= "acos"
  3852. CASE "acosl"
  3853. Stk$[Tmp]= "acosl"
  3854. CASE "acosh"
  3855. Stk$[Tmp]= "acosh"
  3856. CASE "appexename$"
  3857. Stk$[Tmp] = "AppExeName$()"
  3858. Use_AppExeName = Use_BcxSplitPath = UseFlag = TRUE
  3859. CASE "appexepath$"
  3860. Stk$[Tmp] = "AppExePath$()"
  3861. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  3862. Stk$[Tmp+1] = ""
  3863. Stk$[Tmp+2] = ""
  3864. END IF
  3865. Use_AppExePath = Use_BcxSplitPath = UseFlag = TRUE
  3866. CASE "ansitowide"
  3867. Stk$[Tmp] = "AnsiToWide"
  3868. Use_AnsiToWide = UseFlag = TRUE
  3869. CASE "argc"
  3870. Stk$[Tmp]= "argc"
  3871. CASE "argv"
  3872. Stk$[Tmp]= "argv"
  3873. CASE "argv$"
  3874. Stk$[Tmp]= "argv$"
  3875. CASE "asc"
  3876. i=0
  3877. j=GetNumArgs(Tmp+2,&i)
  3878. IF *Stk[Tmp+2] = *DQ$ THEN
  3879. IF j > 0 OR *Stk[Tmp+3] <> ASC(")") THEN
  3880. Stk$[Tmp] = "asc"
  3881. Use_Asc = TRUE
  3882. ELSE
  3883. IF Stk$[Tmp+2] = DDQ$ THEN
  3884. Stk$[Tmp] = "0"
  3885. ELSE
  3886. Stk$[Tmp] = LTRIM$(STR$(ASC(Stk$[Tmp+2],1)))
  3887. END IF
  3888. Stk$[Tmp+1] = "" : Stk$[Tmp+2] = "" : Stk$[Tmp+3] = ""
  3889. END IF
  3890. ELSE
  3891. IF j > 0 THEN Stk$[i] = "+"
  3892. Stk$[Tmp] = "(UCHAR)*"
  3893. END IF
  3894. CASE "asin"
  3895. Stk$[Tmp]= "asin"
  3896. CASE "asinl"
  3897. Stk$[Tmp]= "asinl"
  3898. CASE "asinh"
  3899. Stk$[Tmp]= "asinh"
  3900. CASE "atanh"
  3901. Stk$[Tmp]= "atanh"
  3902. CASE "atn","atan"
  3903. Stk$[Tmp]= "atan"
  3904. CASE "atnl","atanl"
  3905. Stk$[Tmp]= "atanl"
  3906. CASE "auto"
  3907. IF iMatchWrd(Stk$[Tmp+1],"local") THEN
  3908. Stk$[Tmp] = "dim" : Stk$[Tmp+1] = "raw"
  3909. ELSE
  3910. Stk$[Tmp]= "auto"
  3911. END IF
  3912. END SELECT
  3913. CASE 2
  3914. SELECT CASE Keyword$
  3915. CASE "bcopy"
  3916. *Stk[1] = 0
  3917. FOR i = Tmp+1 TO Ndx
  3918. IF iMatchWrd(Stk$[i],"to") THEN EXIT FOR
  3919. CONCAT(Stk$[1], Stk$[i]) 'Source
  3920. NEXT
  3921. *Stk[2] = 0
  3922. FOR i = i+1 TO Ndx
  3923. CONCAT(Stk$[2], Stk$[i]) 'Destination
  3924. NEXT
  3925. Src$ = "memmove(&" + Stk$[2] + ",&" + Stk$[1] + ",sizeof(" + Stk$[2] + "))"
  3926. REMOVE "&*" FROM Src$
  3927. Ndx = 0
  3928. CALL XParse(Src$)
  3929. CASE "bel$"
  3930. Stk$[Tmp] = "BEL$"
  3931. Use_BEL = UseFlag = TRUE
  3932. CASE "bs$"
  3933. Stk$[Tmp] = "BS$"
  3934. Use_BS = UseFlag = TRUE
  3935. CASE "bool","boolean"
  3936. Stk$[Tmp]= "bool"
  3937. CASE "band"
  3938. Stk$[Tmp]= " BAND "
  3939. Use_Band = TRUE
  3940. CASE "bnot"
  3941. Stk$[Tmp] = " BNOT "
  3942. Use_Bnot = TRUE
  3943. ' *******************************************************************
  3944. ' Special Case Handler: Maintain case sensitivity for this structure
  3945. ' *******************************************************************
  3946. CASE "bcx_font"
  3947. Stk$[Tmp] = UCASE$(Stk$[Tmp])
  3948. DIM RAW tmp$
  3949. tmp$ = Clean$(UCASE$(Stk$[Tmp+1]))
  3950. SELECT CASE tmp$
  3951. CASE ".NAME" : Stk$[Tmp+1] = ".lf.lfFaceName$"
  3952. CASE ".BOLD" : Stk$[Tmp+1] = ".lf.lfWeight"
  3953. CASE ".UNDERLINE" : Stk$[Tmp+1] = ".lf.lfUnderline"
  3954. CASE ".STRIKEOUT" : Stk$[Tmp+1] = ".lf.lfStrikeOut"
  3955. CASE ".ITALIC" : Stk$[Tmp+1] = ".lf.lfItalic"
  3956. CASE ".CHARSET" : Stk$[Tmp+1] = ".lf.lfCharSet"
  3957. CASE ".SIZE", ".RGB" : Stk$[Tmp+1] = tmp$
  3958. CASE ELSE
  3959. Stk$[Tmp+1] = Clean$(Stk$[Tmp+1])
  3960. END SELECT
  3961. CASE "bcxsplitpath$"
  3962. Stk$[Tmp] = "$$BcxSplitPath$"
  3963. Use_BcxSplitPath = UseFlag = TRUE
  3964. CASE "bcxpath$"
  3965. UseFlag = TRUE
  3966. Stk$[Tmp] = "BcxPath$()"
  3967. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  3968. Stk$[Tmp+1] = ""
  3969. Stk$[Tmp+2] = ""
  3970. END IF
  3971. CASE "bcxfont"
  3972. Stk$[Tmp] = "BcxFont"
  3973. '/***** 2010-12-11 New Socket Keywords -AIR *****/
  3974. case "bcxsocket"
  3975. Stk$[Tmp] = "BcxSocket"
  3976. Use_Socket = true
  3977. case "bcxsocketsend"
  3978. Stk$[Tmp] = "BcxSocketSend"
  3979. case "bcxsocketread"
  3980. Stk$[Tmp] = "BcxSocketRead"
  3981. case "bcxsocketclose"
  3982. Stk$[Tmp] = "BcxSocketClose"
  3983. CASE "bcx_thread", "bcx_threadwait", "bcx_threadsuspend","bcx_threadresume","bcx_threadkill","bcx_threadend"
  3984. Stk$[Tmp] = UCASE$(Stk$[Tmp])
  3985. Use_Threads = TRUE
  3986. CASE "bin$"
  3987. Stk$[Tmp] = "$$Bin$"
  3988. Use_Bin = UseFlag = TRUE
  3989. CASE "bool$"
  3990. Stk$[Tmp] = "$$BoolStr$"
  3991. Use_Boolstr = UseFlag = TRUE
  3992. CASE "bin2dec"
  3993. Stk$[Tmp]= "Bin2Dec"
  3994. Use_Bin2dec = TRUE
  3995. CASE "boolean"
  3996. Stk$[Tmp]= "BOOLEAN"
  3997. CASE "bor"
  3998. Stk$[Tmp]= " BOR "
  3999. Use_Bor = TRUE
  4000. CASE "byte"
  4001. Stk$[Tmp]= "BYTE"
  4002. END SELECT
  4003. CASE 3
  4004. SELECT CASE Keyword$
  4005. CASE "containedin"
  4006. Stk$[Tmp] = "containedin"
  4007. Use_ContainedIn = TRUE
  4008. CASE "copyfile"
  4009. Use_CopyFile = TRUE
  4010. Use_Exist = Use_Lof = TRUE
  4011. CASE "cr$"
  4012. Stk$[Tmp] = "CR$"
  4013. Use_CR = UseFlag = TRUE
  4014. CASE "close#"
  4015. Stk$[Tmp] = "close"
  4016. CASE "close"
  4017. IF LEFT$(Stk$[Tmp+1],1)= "#" THEN
  4018. Stk$[Tmp+1] = MID$(Stk$[Tmp+1],2)
  4019. END IF
  4020. CASE "cvd"
  4021. Stk$[Tmp]="CVD"
  4022. Use_Cvd = TRUE
  4023. CASE "cvi"
  4024. Stk$[Tmp]="CVI"
  4025. Use_Cvi = TRUE
  4026. CASE "cvl"
  4027. Stk$[Tmp]="CVL"
  4028. Use_Cvl = TRUE
  4029. CASE "cvld"
  4030. Stk$[Tmp]="CVLD"
  4031. Use_Cvld = TRUE
  4032. CASE "cvs"
  4033. Stk$[Tmp]="CVS"
  4034. Use_Cvs = TRUE
  4035. CASE "concat"
  4036. Stk$[Tmp]= "strcat"
  4037. CASE "chr$"
  4038. Stk$[Tmp]= "$$chr$"
  4039. Use_Chr = UseFlag = TRUE
  4040. CASE "char"
  4041. Stk$[Tmp]= "char"
  4042. CASE "crlf$"
  4043. Stk$[Tmp] = "CRLF$"
  4044. Use_Crlf = UseFlag = TRUE
  4045. CASE "cbctl"
  4046. Stk$[Tmp]= "LOWORD(wParam)"
  4047. CASE "cbctlmsg"
  4048. Stk$[Tmp]= "HIWORD(wParam)"
  4049. CASE "cblparam"
  4050. Stk$[Tmp]= "lParam"
  4051. CASE "cbmsg"
  4052. Stk$[Tmp]= "Msg"
  4053. CASE "cbwparam"
  4054. Stk$[Tmp]= "wParam"
  4055. CASE "cdbl"
  4056. Stk$[Tmp]= "CDBL"
  4057. Use_Cdbl = TRUE
  4058. CASE "chdrive", "chdir"
  4059. Stk$[Tmp]= "chdir"
  4060. CASE "cint"
  4061. Stk$[Tmp]= "Cint"
  4062. Use_Cint = TRUE
  4063. CASE "cldbl"
  4064. Stk$[Tmp]= "CLDBL"
  4065. Use_Cldbl = TRUE
  4066. CASE "clng"
  4067. Stk$[Tmp]= "CLNG"
  4068. Use_Clng = TRUE
  4069. CASE "cls"
  4070. Stk$[Tmp]= "cls"
  4071. Use_Cls = Use_ESC = TRUE
  4072. CASE "color", "color_fg", "color_bg"
  4073. Stk$[Tmp] = LCASE$(Stk$[Tmp])
  4074. Use_Color = Use_Console = TRUE
  4075. CASE "command$"
  4076. Use_Command = Use_SPC = UseFlag = TRUE
  4077. Stk$[Tmp]= "command$(-1)"
  4078. IF Stk$ [Tmp+1] = "(" THEN
  4079. Stk$ [Tmp]= "command$"
  4080. END IF
  4081. CASE "colorref"
  4082. Stk$[Tmp]= "COLORREF"
  4083. CASE "cos"
  4084. Stk$[Tmp]= "cos"
  4085. CASE "cosl"
  4086. Stk$[Tmp]= "cosl"
  4087. CASE "cosh"
  4088. Stk$[Tmp]= "cosh"
  4089. CASE "cbool"
  4090. Stk$[Tmp] = "CBOOL"
  4091. DIM fp AS functionParse, i, t, expos = 0
  4092. IF SepFuncArgs(Tmp+1, &fp, TRUE) = 0 THEN Abort("No argument specified in CBOOL")
  4093. FOR i = fp.CommaPos[0] TO fp.CommaPos[1]
  4094. t = INCHR("!<>=", Stk$[i])
  4095. IF t THEN
  4096. IF t < 4 THEN
  4097. IF Stk$[i+1] = "=" THEN
  4098. Stk$[i] = Stk$[i] + Stk$[i+1]
  4099. Stk$[i+1] = ""
  4100. ELSEIF t = 1 AND Stk$[i] <> "!=" THEN
  4101. ITERATE
  4102. END IF
  4103. ELSE
  4104. IF Stk$[i+1] <> "=" THEN Stk$[i] = "=="
  4105. END IF
  4106. expos = i
  4107. EXIT FOR
  4108. END IF
  4109. NEXT
  4110. t = DataType(Stk$[expos-1])
  4111. IF t = vt_STRLIT OR t = vt_STRVAR THEN
  4112. IF expos THEN
  4113. Stk$[Tmp+1] = Stk$[Tmp+1] + "strcmp("
  4114. Stk$[fp.CommaPos[1]] = ")" + Stk$[expos] + "0)"
  4115. Stk$[expos] = ","
  4116. Src$ = ""
  4117. FOR i = 1 TO Ndx
  4118. Src$ = Src$ + Stk$[i] + SPC$
  4119. NEXT
  4120. FastLexer(Src$," ","(),")
  4121. END IF
  4122. END IF
  4123. CASE "csng"
  4124. Stk$[Tmp]= "CSNG"
  4125. Use_Csng = TRUE
  4126. CASE "curdir$"
  4127. Stk$[Tmp]= "curdir$()"
  4128. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  4129. Stk$[Tmp+1] = ""
  4130. Stk$[Tmp+2] = ""
  4131. END IF
  4132. Use_Curdir = UseFlag = TRUE
  4133. CASE "currency"
  4134. Stk$[Tmp] = "CURRENCY"
  4135. CASE "c_declare"
  4136. CallType$ = "__attribute__((cdecl)) "
  4137. Stk$[Tmp]= "declare"
  4138. IF iMatchWrd(Stk$[4], "lib") THEN
  4139. NoTypeDeclare = FALSE
  4140. ELSE
  4141. NoTypeDeclare = TRUE
  4142. END IF
  4143. END SELECT
  4144. CASE 4
  4145. SELECT CASE Keyword$
  4146. CASE "declare"
  4147. CallType$ = "__attribute__((stdcall)) "
  4148. Stk$[Tmp]= "declare"
  4149. IF NOT iMatchWrd(Stk$[4], "lib") THEN
  4150. NoTypeDeclare = TRUE
  4151. ELSE
  4152. NoTypeDeclare = FALSE
  4153. END IF
  4154. CASE "dq$"
  4155. Stk$[Tmp] = "DQ$"
  4156. Use_DQ = UseFlag = TRUE
  4157. CASE "ddq$"
  4158. Stk$[Tmp] = "DDQ$"
  4159. Use_DDQ = UseFlag = TRUE
  4160. CASE "data$"
  4161. Stk$[Tmp]= "DATA$"
  4162. CASE "date$"
  4163. Stk$[Tmp] = "$$timef$(12)"
  4164. Use_Time = UseFlag = TRUE
  4165. CASE "delete"
  4166. IF UseCpp = FALSE THEN Abort( "'DELETE' can only be used with C++" )
  4167. Stk$[Tmp]="delete "
  4168. CASE "del$"
  4169. Stk$[Tmp]= "del$"
  4170. Use_Del = UseFlag = TRUE
  4171. CASE "double"
  4172. Stk$[Tmp]= "double"
  4173. CASE "download"
  4174. Stk$[Tmp] = "Download"
  4175. Use_Download = Use_Dynacall = TRUE
  4176. CASE "dsplit"
  4177. Stk$[Tmp]= "DSplit"
  4178. Use_DSplit = TRUE
  4179. Use_Remove = TRUE
  4180. Use_StrStr = TRUE
  4181. Use_Mid = TRUE
  4182. Use_Left = TRUE
  4183. Use_Instr = TRUE
  4184. Use_Stristr = TRUE
  4185. UseLCaseTbl = TRUE
  4186. UseFlag = TRUE
  4187. CASE "dword"
  4188. Stk$[Tmp]= "DWORD"
  4189. END SELECT
  4190. CASE 5
  4191. SELECT CASE Keyword$
  4192. CASE "extern"
  4193. Stk$[Tmp] = "extern"
  4194. CASE "enc$"
  4195. Stk$[Tmp]= "$$enc$"
  4196. Use_Enclose = UseFlag = TRUE
  4197. CASE "extract$"
  4198. Stk$[Tmp]= "$$extract$"
  4199. Use_Extract = Use_StrStr = UseFlag = TRUE
  4200. CASE "eof$"
  4201. Stk$[Tmp] = "EF$"
  4202. Use_EOF = UseFlag = TRUE
  4203. CASE "eof"
  4204. Stk$[Tmp]= "EoF"
  4205. Use_Eof = UseFlag = TRUE
  4206. IF DataType(Stk$[Tmp + 2]) = vt_NUMBER THEN
  4207. Stk$[Tmp + 2] = "FP" + Stk$[Tmp + 2]
  4208. END IF
  4209. CASE "esc$"
  4210. Stk$[Tmp] = "ESC$"
  4211. Use_ESC = UseFlag = TRUE
  4212. CASE "enum"
  4213. '/***** 2011-03-09 Added support Named ENUMS -AIR *****/
  4214. '/***** SYNTAX: blah as ENUM *****/
  4215. IF Ndx = 1 OR iMatchWrd(Stk$[3],"enum") THEN
  4216. Use_EnumFile = TRUE
  4217. '******************************************************
  4218. ' We're dealing with a ENUM - END ENUM block
  4219. '******************************************************
  4220. DIM RAW EnumFlag = FALSE
  4221. FPRINT FP11,""
  4222. '/***** 2011-03-09 Added support Named ENUMS -AIR *****/
  4223. IF Ndx = 1 THEN
  4224. FPRINT FP11,"enum"
  4225. ELSE IF Ndx = 3 then
  4226. FPRINT FP11,"enum " + Stk$[1]
  4227. END IF
  4228. '/*****************************************************/
  4229. FPRINT FP11," {"
  4230. Src$ = ""
  4231. WHILE NOT iMatchLft(Src$,"end ")
  4232. IF EOF(SourceFile) THEN Abort ("Unbalanced ENUM")
  4233. LINE INPUT SourceFile,Src$
  4234. ModuleLineNos[ModuleNdx]++
  4235. CALL StripCode(Src$)
  4236. IF iMatchLft(Src$,"$comme") THEN
  4237. Directives()
  4238. ITERATE
  4239. END IF
  4240. Src$ = TRIM$(Src$)
  4241. IF Src$ = "" THEN ITERATE ' line starts with comment
  4242. IF LCASE$(LEFT$(Src$ + " ",4)) = "end " THEN
  4243. EXIT LOOP
  4244. ELSE
  4245. IF EnumFlag = FALSE THEN
  4246. EnumFlag = TRUE
  4247. ELSE
  4248. FPRINT FP11,","
  4249. END IF
  4250. END IF
  4251. FPRINT FP11," ",RTRIM$(Src$);
  4252. WEND
  4253. Src$ = ""
  4254. Ndx = 0
  4255. FPRINT FP11,""
  4256. FPRINT FP11," };\n"
  4257. EXIT SUB
  4258. END IF
  4259. '*************************************************************
  4260. ' We're dealing with a smaller, single line ENUM statement
  4261. '*************************************************************
  4262. Stk$[1] = "enum {"
  4263. FOR j = 2 TO Ndx
  4264. CONCAT (Stk$[1], Stk$[j])
  4265. NEXT
  4266. CONCAT (Stk$[1], "}")
  4267. Ndx = 1
  4268. CASE "environ$"
  4269. Stk$[Tmp]= "Environ$"
  4270. Use_Environ = UseFlag = TRUE
  4271. CASE "exist"
  4272. Stk$[Tmp]= "Exist"
  4273. Use_Exist = UseFlag = TRUE
  4274. CASE "exp"
  4275. Stk$[Tmp]= "Exp"
  4276. Use_Exp = TRUE
  4277. END SELECT
  4278. CASE 6
  4279. SELECT CASE Keyword$
  4280. CASE "freeglobals"
  4281. Stk$[Tmp] = "FreeGlobals"
  4282. CASE "ff$"
  4283. Stk$[Tmp] = "FF$"
  4284. Use_FF = UseFlag = TRUE
  4285. CASE "function"
  4286. IF Stk$[Tmp+1] = "=" THEN
  4287. IF Stk$[Tmp+2] = DDQ$ THEN Stk$[Tmp+2] = "NUL$"
  4288. Stk$[Tmp] = "functionreturn"
  4289. END IF
  4290. CASE "false"
  4291. Stk$[Tmp]= "FALSE"
  4292. CASE "file"
  4293. Stk$[Tmp]= "FILE"
  4294. CASE "findintype"
  4295. 'Convert this :FindInType(char *Token, Type.member, int c)
  4296. 'To this :FindInType(char *Token, Stptr + offsetof(Type,member), sizeof(Type), int c)
  4297. Stk$[Tmp]= "FindInType"
  4298. Use_FindInType = TRUE
  4299. DIM RAW StMem$, StName$, VarName$
  4300. DIM fp AS functionParse
  4301. CALL SepFuncArgs(Tmp, &fp, TRUE)
  4302. StMem$ = REMAIN$(Clean$(GetArg$(2, &fp)),".")
  4303. VarName$ = EXTRACT$(Clean$(GetArg$(2, &fp)),".")
  4304. FOR j = fp.CommaPos[1] + 1 TO fp.CommaPos[2] - 1
  4305. Stk$[j] = ""
  4306. NEXT
  4307. IF CheckLocal(VarName$,&i) <> vt_UNKNOWN THEN
  4308. StName$ = TypeDefs[LocalVars[i].VarDef].VarName$
  4309. ELSEIF CheckGlobal(VarName$,&i) <> vt_UNKNOWN THEN
  4310. StName$ = TypeDefs[GlobalVars[i].VarDef].VarName$
  4311. END IF
  4312. j = fp.CommaPos[1] + 1
  4313. Stk$[j] = "(char*)" & VarName$ & " + offsetof(" & StName$ & "," & StMem$ & "), sizeof(" & StName$ & ")"
  4314. CASE "farproc"
  4315. Stk$[Tmp] = "FARPROC"
  4316. CASE "fillarray"
  4317. Stk$[Tmp] = "fillarray"
  4318. Use_FillArray = TRUE
  4319. CASE "findfirst$"
  4320. Stk$[Tmp]= "findfirst$"
  4321. j = GetNumArgs(Tmp+2)
  4322. IF j = 0 THEN Stk$[Ndx] = ", &FindData)"
  4323. Use_Findfirst = Use_Like = TRUE
  4324. Use_BcxSplitPath = TRUE
  4325. Use_Join = TRUE
  4326. UseFlag = TRUE
  4327. CASE "findnext$"
  4328. Stk$[Tmp]= "findnext$"
  4329. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  4330. Stk$[Tmp+1] = "(&FindData"
  4331. ELSEIF Tmp = Ndx THEN
  4332. Ndx++
  4333. Stk$[Ndx] = "(&FindData)"
  4334. END IF
  4335. Use_Findnext = Use_Like = UseFlag = TRUE
  4336. Use_Join = TRUE
  4337. CASE "fint"
  4338. Stk$[Tmp]= "FINT"
  4339. Use_Fint = TRUE
  4340. CASE "fix"
  4341. Stk$[Tmp]= "FIX"
  4342. Use_Fix = TRUE
  4343. CASE "filelocked"
  4344. Stk$[Tmp]= "FileLocked"
  4345. Use_FileLocked = TRUE
  4346. CASE "flush"
  4347. Stk$[Tmp]= "fflush"
  4348. CASE "frac"
  4349. Stk$[Tmp]= "FRAC"
  4350. Use_Frac = TRUE
  4351. CASE "fracl"
  4352. Stk$[Tmp]= "FRACL"
  4353. Use_Fracl = TRUE
  4354. CASE "freefile"
  4355. Stk$[Tmp]= "FreeFile()"
  4356. Use_Freefile = TRUE
  4357. END SELECT
  4358. CASE 7
  4359. SELECT CASE Keyword$
  4360. CASE "getprocaddress"
  4361. LOCAL GlobalName$, s, ss, tempA$
  4362. GlobalName$ = Stk$[Tmp-2]
  4363. ss = HashNumber(GlobalName$)
  4364. WHILE GlobalVarHash[ss]
  4365. s = GlobalVarHash[ss]
  4366. IF GlobalName$ = GlobalVars[s].VarName$ THEN
  4367. tempA$ = TypeDefs[GlobalVars[s].VarDef].VarName$
  4368. IF GlobalVars[s].VarPntr THEN
  4369. tempA$=tempA$+" *"
  4370. END IF
  4371. END IF
  4372. ss = IMOD(ss + 1,MaxGlobalVars)
  4373. WEND
  4374. IF tempA$ = "" THEN
  4375. LOCAL LocalName$
  4376. LocalName$ = Stk$[Tmp-2]
  4377. IF LocalVarCnt THEN
  4378. FOR INTEGER i = 1 TO LocalVarCnt
  4379. IF LocalName$ = LocalVars[i].VarName$ THEN
  4380. tempA$ = TypeDefs[LocalVars[i].VarDef].VarName$
  4381. IF LocalVars[i].VarPntr THEN
  4382. tempA$ = tempA$ + " *"
  4383. END IF
  4384. EXIT FOR
  4385. END IF
  4386. NEXT
  4387. END IF
  4388. END IF
  4389. IF tempA$ <> "" THEN
  4390. '~ Stk$[Tmp]= "(" + tempA$ + ")GetProcAddress"
  4391. Stk$[Tmp]= "(" + tempA$ + ")dlsym"
  4392. ELSE
  4393. '~ Stk$[Tmp]= "GetProcAddress"
  4394. Stk$[Tmp]= "dlsym"
  4395. END IF
  4396. CASE "getattr"
  4397. Stk$[Tmp]= "GETATTR"
  4398. CASE "getbvalue"
  4399. Stk$[Tmp]= "GetBValue"
  4400. CASE "getc"
  4401. Stk$[Tmp]= "getc"
  4402. CASE "getgvalue"
  4403. Stk$[Tmp]= "GetGValue"
  4404. CASE "getrvalue"
  4405. Stk$[Tmp]= "GetRValue"
  4406. CASE "getresource"
  4407. Stk$[Tmp] = "GetResource"
  4408. Use_Embed = TRUE
  4409. END SELECT
  4410. CASE 8
  4411. SELECT CASE Keyword$
  4412. CASE "hiword"
  4413. Stk$[Tmp]= "HIWORD"
  4414. CASE "hex$"
  4415. Stk$[Tmp]= "hex$"
  4416. Use_Hex = UseFlag = TRUE
  4417. CASE "hex2dec"
  4418. Stk$[Tmp]= "Hex2Dec"
  4419. Use_Hex2Dec = UseLCaseTbl = TRUE
  4420. CASE "hibyte"
  4421. Stk$[Tmp]= "HIBYTE"
  4422. CASE "hide"
  4423. Stk$[Tmp]= "Hide"
  4424. CASE "hypot"
  4425. Stk$[Tmp]= "hypot"
  4426. END SELECT
  4427. CASE 9
  4428. SELECT CASE Keyword$
  4429. CASE "inherits"
  4430. Stk$[Tmp]="inherits"
  4431. CASE "instr"
  4432. Stk$[Tmp]= "instr_b"
  4433. Use_Instr = Use_StrStr = TRUE
  4434. Use_Stristr = UseLCaseTbl = TRUE
  4435. CASE "inchr"
  4436. Stk$[Tmp]= "inchr"
  4437. Use_Inchr = TRUE
  4438. CASE "imod"
  4439. Stk$[Tmp]= "imod"
  4440. Use_Imod = TRUE
  4441. CASE "iif"
  4442. Stk$[Tmp]= "iif"
  4443. Use_Iif = TRUE
  4444. FOR i = Tmp+1 TO Ndx
  4445. IF Stk$[i] = "=" THEN
  4446. IF Stk$[i-1] <> "<" AND Stk$[i-1] <> ">" THEN
  4447. Stk$[i] = "=="
  4448. END IF
  4449. END IF
  4450. NEXT
  4451. CASE "iif$"
  4452. Stk$[Tmp]= "sziif$"
  4453. Use_sziif = TRUE
  4454. FOR i = Tmp+1 TO Ndx
  4455. IF Stk$[i] = "=" THEN
  4456. IF Stk$[i-1] <> "<" AND Stk$[i-1] <> ">" THEN
  4457. Stk$[i] = "=="
  4458. END IF
  4459. END IF
  4460. NEXT
  4461. CASE "inkey"
  4462. Use_InkeyD = TRUE
  4463. Use_GetCh = TRUE
  4464. UseFlag = TRUE
  4465. Stk$[Tmp]= "inkeyd()"
  4466. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  4467. Stk$[Tmp+1] = ""
  4468. Stk$[Tmp+2] = ""
  4469. END IF
  4470. CASE "inkey$"
  4471. Use_Inkey = TRUE
  4472. Use_GetCh = TRUE
  4473. UseFlag = TRUE
  4474. Stk$[Tmp]= "inkey$()"
  4475. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  4476. Stk$[Tmp+1] = ""
  4477. Stk$[Tmp+2] = ""
  4478. END IF
  4479. CASE "ins$"
  4480. Stk$[Tmp]= "ins$"
  4481. Use_Ins = UseFlag = TRUE
  4482. CASE "instat"
  4483. Use_Instat = true
  4484. Stk$[Tmp]= "kbhit()"
  4485. CASE "instrrev"
  4486. Stk$[Tmp]= "InstrRev"
  4487. Use_Instrrev = TRUE
  4488. CASE "isptr"
  4489. Stk$[Tmp]= "IsPtr"
  4490. Use_Isptr = TRUE
  4491. CASE "ireplace$"
  4492. Stk$[Tmp]= "iReplace$"
  4493. Use_iReplace = Use_Stristr = UseFlag = TRUE
  4494. UseLCaseTbl = TRUE
  4495. CASE "iremove$"
  4496. Stk$[Tmp]= "IRemoveStr$"
  4497. Use_IRemove = UseFlag = TRUE
  4498. Use_Stristr = UseLCaseTbl = TRUE
  4499. CASE "iterate"
  4500. Stk$[Tmp]= "continue"
  4501. END SELECT
  4502. CASE 10
  4503. SELECT CASE Keyword$
  4504. CASE "join$"
  4505. Stk$[Tmp]= "$$join$"
  4506. Use_Join = UseFlag = TRUE
  4507. END SELECT
  4508. CASE 11
  4509. SELECT CASE Keyword$
  4510. CASE "keypress"
  4511. Stk$[Tmp] = "keypress()"
  4512. IF Stk$[Tmp+1] = "(" AND Stk$[Tmp+2]= ")" THEN
  4513. Stk$[Tmp+1] = ""
  4514. Stk$[Tmp+2] = ""
  4515. END IF
  4516. Use_Keypress = TRUE
  4517. Use_GetCh = TRUE
  4518. END SELECT
  4519. CASE 12
  4520. SELECT CASE Keyword$
  4521. CASE "loadfile$"
  4522. Stk$[Tmp]= "$$LoadFile$"
  4523. Use_LoadFile = Use_Get = UseFlag = TRUE
  4524. Use_Exist = Use_Lof = TRUE
  4525. CASE "lf$"
  4526. Stk$[Tmp] = "LF$"
  4527. Use_LF = UseFlag = TRUE
  4528. CASE "line"
  4529. IF iMatchWrd(Stk$[Tmp+1],"input") THEN
  4530. Use_Lineinput = TRUE
  4531. Stk$[Tmp] = "lineinput"
  4532. j = Tmp + 4
  4533. Stk$[Tmp+1] = "" ' Extract the file handle
  4534. FOR i = Tmp+2 TO Ndx
  4535. IF *Stk$[i] = ASC(",") THEN j=i+1 : EXIT FOR
  4536. Stk$[Tmp+1] = Stk$[Tmp+1] + Stk$[i]
  4537. Stk$[i] = ""
  4538. NEXT j
  4539. FOR i = j TO Ndx
  4540. Stk$[Tmp+2]= Stk$[Tmp+2] & Stk$[i]
  4541. NEXT
  4542. END IF
  4543. CASE "lcase$"
  4544. Stk$[Tmp] = "$$lcase$"
  4545. Use_Lcase = TRUE
  4546. Use_StrUpLow = UseFlag = TRUE
  4547. CASE "ldouble"
  4548. Stk$[Tmp] = "LDOUBLE"
  4549. Use_Ldouble = UseFlag = TRUE
  4550. CASE "left$"
  4551. Stk$[Tmp]= "$$left$"
  4552. Use_Left = TRUE
  4553. UseFlag = TRUE
  4554. CASE "long"
  4555. Stk$[Tmp]= "long"
  4556. CASE "longlong"
  4557. Stk$[Tmp] = "LONGLONG"
  4558. CASE "lpbyte"
  4559. Stk$[Tmp] = "LPBYTE"
  4560. CASE "len"
  4561. Stk$[Tmp]= "strlen"
  4562. CASE "lprint"
  4563. Stk$[Tmp]= "lprint"
  4564. IF Tmp = Ndx THEN
  4565. Ndx++
  4566. Stk$[Ndx] = ENC$ ("") ' Allow LPRINT with no args
  4567. END IF
  4568. CASE "lpad$"
  4569. Stk$[Tmp]= "$$lpad$"
  4570. Use_Lpad = UseFlag = TRUE
  4571. CASE "ltrim$"
  4572. Stk$[Tmp]= "$$ltrim$"
  4573. Use_Ltrim = UseFlag = TRUE
  4574. CASE "lof"
  4575. Stk$[Tmp]= "lof"
  4576. IF DataType(Stk$[Tmp + 2]) = vt_NUMBER THEN
  4577. Stk$[Tmp + 2] = "FP" + Stk$[Tmp + 2]
  4578. END IF
  4579. Use_Lof = TRUE
  4580. CASE "loadlibrary", "load_dll"
  4581. Stk$[Tmp]= "LoadLibrary"
  4582. CASE "like"
  4583. Stk$[Tmp] = "like"
  4584. Use_Like = TRUE
  4585. CASE "lobyte"
  4586. Stk$[Tmp]= "LOBYTE"
  4587. CASE "loc"
  4588. IF DataType(Stk$[Tmp + 2]) = vt_NUMBER THEN
  4589. Stk$[Tmp + 2] = "FP" + Stk$[Tmp + 2]
  4590. END IF
  4591. Stk$[Tmp] = "loc(" + Stk$[Tmp + 2] + "," + Stk$[Tmp + 2] + "len)"
  4592. Stk$[Tmp + 1] = ""
  4593. Stk$[Tmp + 2] = ""
  4594. Stk$[Tmp + 3] = ""
  4595. Use_Loc = TRUE
  4596. CASE "locate"
  4597. Use_Locate = TRUE
  4598. CASE "log"
  4599. Stk$[Tmp]= "log"
  4600. CASE "logl"
  4601. Stk$[Tmp]= "logl"
  4602. CASE "log10"
  4603. Stk$[Tmp]= "log10"
  4604. CASE "log10l"
  4605. Stk$[Tmp]= "log10l"
  4606. CASE "loword"
  4607. Stk$[Tmp]= "LOWORD"
  4608. CASE "lpstr"
  4609. Stk$[Tmp]= "PCHAR"
  4610. END SELECT
  4611. CASE 13
  4612. SELECT CASE Keyword$
  4613. CASE "mkd$"
  4614. IF Tmp > 2 THEN
  4615. IF INCHR(Stk$[Tmp-2],"$") AND *Stk$[Tmp-1] = ASC("=") THEN
  4616. Stk$[1] = "memcpy(" + Stk$[1]
  4617. Stk$[Tmp-1] = ","
  4618. Stk$[++Ndx] = ",9)"
  4619. END IF
  4620. END IF
  4621. Stk$[Tmp]="MKD"
  4622. Use_Mkd = UseFlag = TRUE
  4623. CASE "mki$"
  4624. IF Tmp > 2 THEN
  4625. IF INCHR(Stk$[Tmp-2],"$") AND *Stk$[Tmp-1] = ASC("=") THEN
  4626. Stk$[1] = "memcpy(" + Stk$[1]
  4627. Stk$[Tmp-1] = ","
  4628. Stk$[++Ndx] = ",3)"
  4629. END IF
  4630. END IF
  4631. Stk$[Tmp]="MKI"
  4632. Use_Mki = UseFlag = TRUE
  4633. CASE "mkl$"
  4634. IF Tmp > 2 THEN
  4635. IF INCHR(Stk$[Tmp-2],"$") AND *Stk$[Tmp-1] = ASC("=") THEN
  4636. Stk$[1] = "memcpy(" + Stk$[1]
  4637. Stk$[Tmp-1] = ","
  4638. Stk$[++Ndx] = ",5)"
  4639. END IF
  4640. END IF
  4641. Stk$[Tmp]="MKL"
  4642. Use_Mkl = UseFlag = TRUE
  4643. CASE "mkld$"
  4644. IF Tmp > 2 THEN
  4645. IF INCHR(Stk$[Tmp-2],"$") AND *Stk$[Tmp-1] = ASC("=") THEN
  4646. Stk$[1] = "memcpy(" + Stk$[1]
  4647. Stk$[Tmp-1] = ","
  4648. Stk$[++Ndx] = ",11)"
  4649. END IF
  4650. END IF
  4651. Stk$[Tmp]="MKLD"
  4652. Use_Mkld = UseFlag = TRUE
  4653. CASE "mks$"
  4654. IF Tmp > 2 THEN
  4655. IF INCHR(Stk$[Tmp-2],"$") AND *Stk$[Tmp-1] = ASC("=") THEN
  4656. Stk$[1] = "memcpy(" + Stk$[1]
  4657. Stk$[Tmp-1] = ","
  4658. Stk$[++Ndx] = ",5)"
  4659. END IF
  4660. END IF
  4661. Stk$[Tmp]="MKS"
  4662. Use_Mks = UseFlag = TRUE
  4663. CASE "mid$"
  4664. IF Tmp > 1 THEN
  4665. Stk$[Tmp]= "$$mid$"
  4666. Use_Mid = UseFlag = TRUE
  4667. ELSE
  4668. Stk$[Tmp]= "midstr"
  4669. Use_Midstr = UseFlag = TRUE
  4670. END IF
  4671. CASE "min"
  4672. Stk$[Tmp]= "_MIN_"
  4673. Use_Min = TRUE
  4674. CASE "main"
  4675. Stk$[Tmp]= "main"
  4676. CASE "makeintresource"
  4677. Stk$[Tmp]= "MAKEINTRESOURCE"
  4678. CASE "makelong"
  4679. Stk$[Tmp]= "MAKELONG"
  4680. CASE "makeword"
  4681. Stk$[Tmp]= "MAKEWORD"
  4682. CASE "max"
  4683. Stk$[Tmp]= "_MAX_"
  4684. Use_Max = TRUE
  4685. CASE "mcase$"
  4686. Stk$[Tmp] = "$$mcase$"
  4687. Use_Mcase = UseFlag = TRUE
  4688. Use_StrUpLow = TRUE
  4689. CASE "mkdir"
  4690. Stk$[Tmp]= "mkdir"
  4691. CASE "mod"
  4692. Stk$[Tmp]= "fmod"
  4693. END SELECT
  4694. CASE 14
  4695. SELECT CASE Keyword$
  4696. CASE "new"
  4697. IF iMatchWrd(Stk$[Tmp-1],"binary") THEN EXIT
  4698. IF UseCpp = FALSE THEN Abort( "'NEW' can only be used with C++" )
  4699. Stk$[Tmp] = "new "
  4700. CASE "nul$"
  4701. Stk$[Tmp] = "NUL$"
  4702. Use_NUL = UseFlag = TRUE
  4703. CASE "null"
  4704. Stk$[Tmp]= "NULL"
  4705. CASE "now$"
  4706. Stk$[Tmp]= "now$()"
  4707. Use_Now = UseFlag = TRUE
  4708. END SELECT
  4709. CASE 15
  4710. SELECT CASE Keyword$
  4711. CASE "open"
  4712. FOR A = Tmp+1 TO Ndx
  4713. IF LEFT$(Stk$[A],1) = "#" THEN
  4714. Stk$[A] = MID$(Stk$[A],2)
  4715. EXIT FOR
  4716. END IF
  4717. NEXT
  4718. CASE "oct$"
  4719. Stk$[Tmp]= "oct$"
  4720. Use_Oct = UseFlag = TRUE
  4721. CASE "osversion"
  4722. Stk$[Tmp]= "OSVersion()"
  4723. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  4724. Stk$[Tmp+1] = ""
  4725. Stk$[Tmp+2] = ""
  4726. END IF
  4727. Use_OSVersion = TRUE
  4728. END SELECT
  4729. CASE 16
  4730. SELECT CASE Keyword$
  4731. CASE "pause"
  4732. Stk$[Tmp] = "Pause()"
  4733. IF Stk$[Tmp+1] = "(" AND Stk$[Tmp+2]= ")" THEN
  4734. Stk$[Tmp+1] = ""
  4735. Stk$[Tmp+2] = ""
  4736. END IF
  4737. Use_Pause = Use_Keypress = TRUE
  4738. Use_GetCh = TRUE
  4739. CASE "preserve"
  4740. Stk$[Tmp] = "PRESERVE"
  4741. CASE "print#"
  4742. Stk$[Tmp] = "fprint"
  4743. CASE "print"
  4744. IF LEFT$(Stk$[Tmp+1],1)= "#" THEN
  4745. Stk$[Tmp] = "fprint"
  4746. Stk$[Tmp+1] = MID$(Stk$[Tmp+1],2)
  4747. END IF
  4748. CASE "ptr"
  4749. CompPtr = 1
  4750. Stk$[Tmp-1] = Stk$[Tmp-1] + "*"
  4751. Stk$[Tmp]= ""
  4752. IF Tmp = Ndx THEN
  4753. Ndx--
  4754. WHILE TALLY(Stk$[Ndx],"*") = LEN(Stk$[Ndx])
  4755. Stk$[Ndx-1] = Stk$[Ndx-1] + Stk$[Ndx]
  4756. Stk$[Ndx] = ""
  4757. Ndx--
  4758. WEND
  4759. ELSE
  4760. i = Tmp-1
  4761. WHILE TALLY(Stk$[i],"*") = LEN(Stk$[i])
  4762. Stk$[i-1] = Stk$[i-1] + Stk$[i]
  4763. Stk$[i] = ""
  4764. i--
  4765. WEND
  4766. END IF
  4767. CASE "peek$"
  4768. Stk$[Tmp]= "$$peekstr$"
  4769. Use_PeekStr = UseFlag = TRUE
  4770. CASE "poke"
  4771. Stk$[Tmp]= "memmove"
  4772. CASE "pow"
  4773. Stk$[Tmp]= "pow"
  4774. CASE "powl"
  4775. Stk$[Tmp]= "powl"
  4776. CASE "private"
  4777. IF UseCpp THEN
  4778. Stk$[Tmp]= "private"
  4779. END IF
  4780. IF iMatchWrd(Stk$[Tmp+1],"const") THEN
  4781. Stk$[Tmp]= "enum "
  4782. Stk$[Tmp+1]= Stk$[Tmp+2] + "{"
  4783. Ndx++
  4784. Stk$[Ndx]= "}"
  4785. END IF
  4786. CASE "public"
  4787. IF UseCpp THEN
  4788. Stk$[Tmp]= "public"
  4789. END IF
  4790. END SELECT
  4791. CASE 17
  4792. SELECT CASE Keyword$
  4793. CASE "qbcolor"
  4794. Stk$[Tmp]= "qbcolor"
  4795. Use_QBColor = TRUE
  4796. END SELECT
  4797. CASE 18
  4798. SELECT CASE Keyword$
  4799. '/***** 2012-12-12 New REGMATCH Keyword -AIR *****/
  4800. CASE "regmatch"
  4801. Stk$[Tmp] = "regmatch"
  4802. ' print "REGMATCH FOUND"
  4803. Use_PeekStr = Use_RegEx = TRUE
  4804. CASE "rewind"
  4805. Stk$[Tmp]= "rewind"
  4806. IF DataType(Stk$[Tmp + 2]) = vt_NUMBER THEN
  4807. Stk$[Tmp + 2] = "FP" + Stk$[Tmp + 2]
  4808. END IF
  4809. CASE "remove$"
  4810. Stk$[Tmp]= "$$RemoveStr$"
  4811. Use_Remove = Use_StrStr = UseFlag = TRUE
  4812. CASE "replace$"
  4813. Stk$[Tmp]= "$$replace$"
  4814. Use_Replace = Use_StrStr = UseFlag = TRUE
  4815. CASE "right$"
  4816. Stk$[Tmp]= "$$right$"
  4817. Use_Right = UseFlag = TRUE
  4818. CASE "rename"
  4819. Stk$[Tmp]= "rename"
  4820. CASE "register"
  4821. Stk$[Tmp]= "register"
  4822. CASE "randomize"
  4823. Stk$[Tmp]= "randomize"
  4824. Use_Randomize = TRUE
  4825. Use_Rnd = TRUE
  4826. IF Ndx = 1 THEN
  4827. Use_Timer = TRUE
  4828. Stk$[1] ="randomize(timer())"
  4829. END IF
  4830. CASE "rec"
  4831. IF DataType(Stk$[Tmp + 2]) = vt_NUMBER THEN
  4832. Stk$[Tmp + 2] = "FP" + Stk$[Tmp + 2]
  4833. END IF
  4834. Stk$[Tmp] = "rec(" + Stk$[Tmp + 2] + "," + Stk$[Tmp + 2] + "len)"
  4835. Stk$[Tmp + 1] = ""
  4836. Stk$[Tmp + 2] = ""
  4837. Stk$[Tmp + 3] = ""
  4838. Use_Rec = TRUE
  4839. CASE "reccount"
  4840. DIM RAW length$
  4841. IF DataType(Stk$[Tmp + 2]) = vt_NUMBER THEN
  4842. Stk$[Tmp + 2] = "FP" + Stk$[Tmp + 2]
  4843. END IF
  4844. Stk$[Tmp] = "reccount"
  4845. length$ = Stk$[Tmp + 2] + "len)"
  4846. FOR i = Tmp+1 TO Ndx
  4847. IF *Stk$[i] = ASC(")") THEN
  4848. Stk$[i] = ""
  4849. EXIT FOR
  4850. END IF
  4851. Stk$[Tmp] = Stk$[Tmp] + Stk$[i]
  4852. Stk$[i] = ""
  4853. NEXT i
  4854. Stk$[Tmp] = Stk$[Tmp] + "," + length$
  4855. Use_RecCount = TRUE
  4856. CASE "reclen"
  4857. Stk$[Tmp] = "reclen"
  4858. CASE "record"
  4859. Stk$[Tmp] = "record"
  4860. CASE "remain$"
  4861. Stk$[Tmp]= "$$remain$"
  4862. Use_Remain = UseFlag = TRUE
  4863. CASE "retain$"
  4864. Stk$[Tmp]= "$$Retain$"
  4865. Use_Retain = UseFlag = TRUE
  4866. CASE "repeat$"
  4867. Stk$[Tmp]= "$$repeat$"
  4868. Use_Repeat = UseFlag = TRUE
  4869. CASE "reverse$"
  4870. Stk$[Tmp]= "$$reverse$"
  4871. Use_Reverse = UseFlag = TRUE
  4872. CASE "rgb"
  4873. Stk$[Tmp]= "RGB"
  4874. CASE "rmdir"
  4875. Stk$[Tmp]= "rmdir"
  4876. CASE "rnd"
  4877. Stk$[Tmp]= "rnd()"
  4878. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  4879. Stk$[Tmp+1] = ""
  4880. Stk$[Tmp+2] = ""
  4881. END IF
  4882. Use_Rnd = TRUE
  4883. CASE "round"
  4884. Stk$[Tmp]= "Round"
  4885. Use_Round = TRUE
  4886. CASE "rpad$"
  4887. Stk$[Tmp]= "$$rpad$"
  4888. Use_Rpad = UseFlag = TRUE
  4889. CASE "rtrim$"
  4890. Stk$[Tmp]= "$$rtrim$"
  4891. Use_Rtrim = UseFlag = TRUE
  4892. CASE "run"
  4893. Stk$[Tmp]= "Run"
  4894. Use_Run = TRUE
  4895. END SELECT
  4896. CASE 19
  4897. SELECT CASE Keyword$
  4898. CASE "scanerror"
  4899. Stk$[Tmp] = "ScanError"
  4900. CASE "sprint"
  4901. Stk$[Tmp]= "sprint"
  4902. CASE "spc$"
  4903. Stk$[Tmp] = "SPC$"
  4904. Use_SPC = UseFlag = TRUE
  4905. CASE "str$"
  4906. Stk$[Tmp]= "$$str$"
  4907. Use_Str = UseFlag = TRUE
  4908. CASE "strl$"
  4909. Stk$[Tmp]= "$$strl$"
  4910. Use_Strl = UseFlag = TRUE
  4911. CASE "searchpath$"
  4912. Stk$[Tmp]= "$$SEARCHPATH$"
  4913. Use_SearchPath = UseFlag = TRUE
  4914. CASE "sizeof"
  4915. Stk$[Tmp]= "sizeof"
  4916. CASE "setattr"
  4917. Stk$[Tmp]= "SETATTR"
  4918. CASE "setwindowrtftext"
  4919. Stk$[Tmp] = "SetWindowRTFText"
  4920. CASE "sgn"
  4921. Stk$[Tmp]= "sgn"
  4922. Use_Sgn = TRUE
  4923. CASE "short"
  4924. Stk$[Tmp] = "short"
  4925. CASE "shell"
  4926. Use_Shell = TRUE
  4927. CASE "show"
  4928. Stk$[Tmp]= "Show"
  4929. CASE "sin"
  4930. Stk$[Tmp]= "sin"
  4931. CASE "sinl"
  4932. Stk$[Tmp]= "sinl"
  4933. CASE "single"
  4934. Stk$[Tmp]= "float"
  4935. CASE "sinh"
  4936. Stk$[Tmp]= "sinh"
  4937. CASE "sleep"
  4938. Stk$[Tmp]= "sleep"
  4939. CASE "space$"
  4940. Stk$[Tmp]= "$$space$"
  4941. Use_Space = UseFlag = TRUE
  4942. CASE "split"
  4943. Stk$[Tmp]= "Split"
  4944. Use_Split = UseFlag = TRUE
  4945. Use_Remove= TRUE
  4946. Use_StrStr= TRUE
  4947. Use_Mid = TRUE
  4948. Use_Left = TRUE
  4949. Use_Instr = TRUE
  4950. Use_Stristr = TRUE
  4951. UseLCaseTbl = TRUE
  4952. CASE "splitbarfg"
  4953. Stk$[Tmp]= "SplitBarFG"
  4954. CASE "splitbarbg"
  4955. Stk$[Tmp]= "SplitBarBG"
  4956. CASE "sqr","sqrt"
  4957. Stk$[Tmp]= "sqrt"
  4958. CASE "sqrl","sqrtl"
  4959. Stk$[Tmp]= "sqrtl"
  4960. CASE "strarray"
  4961. Stk$[Tmp]= "PCHAR*"
  4962. CASE "strim$"
  4963. Stk$[Tmp]= "$$strim$"
  4964. Use_Strim = UseFlag = TRUE
  4965. CASE "string"
  4966. Stk$[Tmp]= "string"
  4967. CASE "string$"
  4968. Stk$[Tmp]= "$$stringx$"
  4969. Use_String = UseFlag = TRUE
  4970. CASE "strptr"
  4971. Stk$[Tmp]= "STRPTR"
  4972. Use_Strptr = TRUE
  4973. CASE "strtoken$"
  4974. Stk$[Tmp]= "StrToken$"
  4975. Use_Strtoken = Use_Mid = Use_Left = Use_Extract = TRUE
  4976. Use_Instr =Use_Instrrev = Use_Stristr = Use_Tally = Use_Remove = TRUE
  4977. Use_StrStr = UseLCaseTbl = UseFlag = TRUE
  4978. CASE "swap"
  4979. Stk$[Tmp]= "swap"
  4980. Use_Swap = TRUE
  4981. CASE "sysdir$"
  4982. Stk$[Tmp]= "$$sysdir$()"
  4983. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  4984. Stk$[Tmp+1] = ""
  4985. Stk$[Tmp+2] = ""
  4986. END IF
  4987. Use_Sysdir = UseFlag = TRUE
  4988. CASE "sysstr"
  4989. Stk$[Tmp] = "SysStr"
  4990. Use_SysStr = TRUE
  4991. END SELECT
  4992. CASE 20
  4993. SELECT CASE Keyword$
  4994. CASE "tab$"
  4995. Stk$[Tmp] = "TAB$"
  4996. Use_TAB = UseFlag = TRUE
  4997. CASE "true"
  4998. Stk$[Tmp]= "TRUE"
  4999. CASE "trim$"
  5000. Stk$[Tmp]= "$$trim$"
  5001. Use_Trim = UseFlag = TRUE
  5002. CASE "tally"
  5003. Stk$[Tmp]= "tally"
  5004. Use_Tally = UseLCaseTbl = Use_Stristr = Use_StrStr = TRUE
  5005. CASE "tan"
  5006. Stk$[Tmp]= "tan"
  5007. CASE "tanh"
  5008. Stk$[Tmp]= "tanh"
  5009. CASE "tanl"
  5010. Stk$[Tmp]= "tanl"
  5011. CASE "tempdir$"
  5012. Stk$[Tmp]= "$$tempdir$()"
  5013. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  5014. Stk$[Tmp+1] = ""
  5015. Stk$[Tmp+2] = ""
  5016. END IF
  5017. Use_Tempdir = UseFlag = Use_Exist = TRUE
  5018. CASE "tempfilename$"
  5019. Stk$[Tmp] = "$$TempFileName$"
  5020. Use_TempFileName = UseFlag = TRUE
  5021. Use_Exist = Use_Rnd = TRUE
  5022. ' *********************************************************
  5023. ' Special Case Handler: Substitute "This." with "This->"
  5024. ' *********************************************************
  5025. CASE "this"
  5026. Stk$[Tmp] = "this"
  5027. IF *Stk[Tmp+1] = ASC(".") THEN
  5028. Stk$[Tmp+1] = "->" & MID$(Stk$[Tmp+1],2)
  5029. END IF
  5030. CASE "time$"
  5031. IF Stk$[Tmp+1] <> "(" THEN
  5032. Stk$[Tmp] = "$$timef$()"
  5033. ELSE
  5034. Stk$[Tmp] = "$$timef$"
  5035. END IF
  5036. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  5037. Stk$[Tmp+1] = ""
  5038. Stk$[Tmp+2] = ""
  5039. END IF
  5040. Use_Time = UseFlag = TRUE
  5041. CASE "timer"
  5042. Stk$[Tmp]= "timer()"
  5043. IF Stk$[Tmp+1]= "(" AND Stk$[Tmp+2]= ")" THEN
  5044. Stk$[Tmp+1] = ""
  5045. Stk$[Tmp+2] = ""
  5046. END IF
  5047. Use_Timer = TRUE
  5048. END SELECT
  5049. CASE 21
  5050. SELECT CASE Keyword$
  5051. CASE "uint"
  5052. Stk$[Tmp]= "UINT"
  5053. CASE "ushort"
  5054. Stk$[Tmp] = "USHORT"
  5055. CASE "ulong"
  5056. Stk$[Tmp] = "ULONG"
  5057. CASE "ulonglong"
  5058. Stk$[Tmp] = "ULONGLONG"
  5059. CASE "ucase$"
  5060. Stk$[Tmp]= "$$ucase$"
  5061. Use_Ucase = UseFlag = TRUE
  5062. Use_StrUpLow = TRUE
  5063. CASE "ubound"
  5064. Stk$[Tmp]= "ubound"
  5065. Use_Ubound = TRUE
  5066. CASE "using$"
  5067. Stk$[Tmp] = "$$Using$"
  5068. Use_Using = UseFlag = TRUE
  5069. '/***** 2010-11-18 Added for new Constructor/Desctructor syntax -AIR *****/
  5070. CASE "using"
  5071. Stk$[Tmp]= "using"
  5072. END SELECT
  5073. CASE 22
  5074. SELECT CASE Keyword$
  5075. CASE "val"
  5076. Stk$[Tmp]= "VAL"
  5077. Use_Val = TRUE
  5078. CASE "vall"
  5079. Stk$[Tmp]= "VALL"
  5080. Use_Vall = TRUE
  5081. CASE "variant"
  5082. Stk$[Tmp]= "VARIANT"
  5083. CASE "varptr"
  5084. Stk$[Tmp]= ""
  5085. CASE "vchr$"
  5086. Stk$[Tmp] = "$$vchr$"
  5087. Use_VChr = UseFlag = TRUE
  5088. '/***** 2010-12-01 Added to support Abstract Classes -AIR *****/
  5089. CASE "virtual"
  5090. Stk$[Tmp]="virtual"
  5091. Use_Virtual = TRUE
  5092. CASE "vt$"
  5093. Stk$[Tmp] = "VT$"
  5094. Use_VT = UseFlag = TRUE
  5095. CASE "verify"
  5096. Stk$[Tmp] = "Verify"
  5097. Use_Verify = Use_Mid = UseFlag = TRUE
  5098. END SELECT
  5099. CASE 23
  5100. SELECT CASE Keyword$
  5101. CASE "widetoansi$"
  5102. Stk$[Tmp] = "$$WideToAnsi$"
  5103. Use_WideToAnsi = UseFlag = TRUE
  5104. END SELECT
  5105. END SELECT
  5106. NEXT
  5107. IF CompPtr = 1 THEN CALL RemEmptyTokens
  5108. '************************************************************
  5109. ' Moved the WITH/END WITH handling here from the Emit sub
  5110. ' The ill formed variables would cause conflict with the new
  5111. ' AsmUnKnown structs function.
  5112. '************************************************************
  5113. IF WithCnt THEN
  5114. FOR i = 1 TO Ndx
  5115. 'IF LEFT$(Stk$[i],1) = "." AND NOT IsNumber(MID$(Stk$[i],2,1)) THEN
  5116. IF LEFT$(Stk$[i],2) = "->" OR (LEFT$(Stk$[i],1) = "." AND NOT IsNumber(MID$(Stk$[i],2,1))) THEN
  5117. IF WithVar$[WithCnt] = "this" THEN
  5118. Stk$[i] = "->" + MID$(Stk$[i],2)
  5119. END IF
  5120. IF i = 1 THEN
  5121. Stk$[i] = WithVar$[WithCnt] + Stk$[i]
  5122. ELSE
  5123. IF NOT IsReservedWord(Stk$[i-1]) THEN
  5124. IF NOT (isalpha(Stk[i-1][LEN(Stk$[i-1]-1)]) OR IsNumber(RIGHT$(Stk$[i-1],LEN(Stk$[i-1]-1)))) THEN
  5125. Stk$[i] = WithVar$[WithCnt] + Stk$[i]
  5126. END IF
  5127. ELSE
  5128. Stk$[i] = WithVar$[WithCnt] + Stk$[i]
  5129. END IF
  5130. END IF
  5131. WHILE (isalpha(*Stk[i+1]) OR *Stk[i+1] = ASC(".")) AND (i < Ndx)
  5132. INCR i
  5133. WEND
  5134. END IF
  5135. NEXT
  5136. END IF
  5137. '************************************************************
  5138. ' handle programming style global and locals using same name
  5139. '************************************************************
  5140. IF CompToken = 1 THEN
  5141. Keyword$ = LCASE$(Stk$[1])
  5142. SELECT CASE Keyword$
  5143. CASE "dim" : CompToken = 0
  5144. CASE "local" : CompToken = 0
  5145. CASE "global" : CompToken = 0
  5146. CASE "static" : CompToken = 0
  5147. CASE "shared" : CompToken = 0
  5148. CASE "raw" : CompToken = 0
  5149. CASE "dynamic" : CompToken = 0
  5150. CASE "free" : CompToken = 0
  5151. CASE "redim" : CompToken = 0
  5152. CASE "sub" : CompToken = 0
  5153. CASE "function" : CompToken = 0
  5154. CASE "overloaded" : CompToken = 0
  5155. CASE "public" : CompToken = 0
  5156. CASE "declare" : CompToken = 0
  5157. CASE "c_declare" : CompToken = 0
  5158. CASE "auto" : CompToken = 0
  5159. CASE "register" : CompToken = 0
  5160. CASE "extern" : CompToken = 0
  5161. CASE ELSE : CALL AsmUnknownStructs(1)
  5162. END SELECT
  5163. END IF
  5164. END SUB 'TokenSubstitutions
  5165. SUB JoinStrings( i, inif )
  5166. '************************
  5167. DIM RAW DoJoin = 0
  5168. DIM RAW InBrace = 0
  5169. DIM RAW OnlyPara = 0
  5170. DIM RAW j = 0
  5171. DIM RAW l = 0
  5172. DIM RAW sj = i
  5173. DIM RAW t$
  5174. DIM RAW vt
  5175. '************************
  5176. WHILE i <= Ndx
  5177. t$ = LCASE$(Stk$[i])
  5178. IF NOT j AND NOT OnlyPara AND NOT InBrace THEN
  5179. vt = DataType(t$)
  5180. IF vt = vt_STRVAR OR vt = vt_STRLIT THEN
  5181. sj = i
  5182. INCR i
  5183. ITERATE
  5184. END IF
  5185. END IF
  5186. SELECT CASE t$
  5187. CASE "&"
  5188. IF OnlyPara THEN EXIT SELECT
  5189. vt = DataType(Stk$[i+1])
  5190. IF vt <> vt_STRVAR AND vt <> vt_STRLIT THEN
  5191. vt = DataType(Stk$[i-1])
  5192. END IF
  5193. IF vt = vt_STRVAR OR vt = vt_STRLIT THEN
  5194. j++
  5195. Stk$[i] = ","
  5196. t$ = ""
  5197. END IF
  5198. CASE "["
  5199. INCR InBrace
  5200. CASE "]"
  5201. DECR InBrace
  5202. CASE "("
  5203. IF Stk$[i+1] <> "*" THEN
  5204. CALL JoinStrings(i+1, inif)
  5205. l = i-1
  5206. WHILE Stk$[i] <> ")"
  5207. Stk$[l] = Stk$[l] + Stk$[i] + " "
  5208. Stk$[i] = ""
  5209. i++
  5210. WEND
  5211. CONCAT(Stk$[l], Stk$[i])
  5212. Stk$[i] = ""
  5213. END IF
  5214. CASE ")"
  5215. IF j THEN
  5216. Stk$[sj] = "join$(" + STR$(j+1) + "," + Stk$[sj]
  5217. j = sj + 1
  5218. WHILE j < i
  5219. CONCAT(Stk$[sj], Stk$[j])
  5220. Stk$[j] = ""
  5221. j++
  5222. WEND
  5223. CONCAT(Stk$[sj], ")")
  5224. END IF
  5225. EXIT SUB
  5226. CASE "||"
  5227. Stk$[i] = " or "
  5228. DoJoin = TRUE
  5229. CASE "&&"
  5230. Stk$[i] = " and "
  5231. DoJoin = TRUE
  5232. CASE "then", "for"
  5233. DoJoin = TRUE
  5234. CASE "="
  5235. IF NOT inif THEN
  5236. OnlyPara = TRUE
  5237. ELSE
  5238. DoJoin = TRUE
  5239. END IF
  5240. CASE "if", "elseif", "while"
  5241. inif = TRUE
  5242. sj = i + 1
  5243. CASE "sprint", "lprint", "fprint", "fprintf", "print", "print#"
  5244. OnlyPara = TRUE
  5245. CASE ELSE
  5246. IF LEFT$(Stk$[i],2) = "]." OR LEFT$(Stk$[i],3) = "]->" THEN
  5247. DECR InBrace
  5248. END IF
  5249. END SELECT
  5250. IF (DoJoin OR INCHR(",+-*/^;:<>~|&", t$)) AND NOT OnlyPara AND NOT InBrace THEN
  5251. DoJoin = 0
  5252. IF j THEN
  5253. Stk$[sj] = "join$(" + STR$(j+1) + "," + Stk$[sj]
  5254. j = sj
  5255. j++
  5256. WHILE j < i
  5257. CONCAT(Stk$[sj], Stk$[j])
  5258. Stk$[j] = ""
  5259. j++
  5260. WEND
  5261. CONCAT(Stk$[sj], ")")
  5262. END IF
  5263. j = 0
  5264. sj = i + 1
  5265. END IF
  5266. INCR i
  5267. WEND
  5268. IF j THEN
  5269. Stk$[sj] = "join$(" + STR$(j+1) + "," + Stk$[sj]
  5270. j = sj
  5271. j++
  5272. WHILE j <= i
  5273. CONCAT(Stk$[sj], Stk$[j])
  5274. Stk$[j] = ""
  5275. j++
  5276. WEND
  5277. CONCAT(Stk$[sj], ")")
  5278. END IF
  5279. END SUB ' JoinStrings
  5280. SUB Transforms()
  5281. '****************
  5282. DIM RAW nBrace
  5283. DIM RAW CntMarker
  5284. DIM RAW IFCond
  5285. DIM RAW a
  5286. DIM RAW i
  5287. DIM RAW j
  5288. DIM RAW Keyword$
  5289. DIM RAW lszTmp$
  5290. '****************
  5291. Keyword$ = ""
  5292. lszTmp$ = ""
  5293. IF Ndx = 3 AND NOT WithCnt THEN
  5294. IF Stk$[2] = "+" AND Stk$[3] = "+" THEN
  5295. FPRINT Outfile,Scoot$,Clean$(Stk$[1]);"++;"
  5296. Ndx = 0
  5297. Statements++
  5298. EXIT SUB
  5299. END IF
  5300. IF Stk$[2] = "-" AND Stk$[3] = "-" THEN
  5301. FPRINT Outfile,Scoot$,Clean$(Stk$[1]);"--;"
  5302. Ndx = 0
  5303. Statements++
  5304. EXIT SUB
  5305. END IF
  5306. IF Stk$[1] = "+" AND Stk$[2] = "+" THEN
  5307. FPRINT Outfile,Scoot$,"++";Clean$(Stk$[3]);";"
  5308. Ndx = 0
  5309. Statements++
  5310. EXIT SUB
  5311. END IF
  5312. IF Stk$[1] = "-" AND Stk$[2] = "-" THEN
  5313. FPRINT Outfile,Scoot$,"--";Clean$(Stk$[3]);";"
  5314. Ndx = 0
  5315. Statements++
  5316. EXIT SUB
  5317. END IF
  5318. END IF
  5319. Keyword$ = LCASE$(Stk$[1])
  5320. a = INCHR("abcdefghijklmnopqrstuvwxyz$", Keyword$)
  5321. SELECT CASE a
  5322. CASE 3
  5323. IF Keyword$ = "case" THEN
  5324. nBrace = 0
  5325. CntMarker = 2
  5326. j = 0
  5327. FOR i = 2 TO Ndx
  5328. IF INCHR("([",Stk$[i]) THEN nBrace++
  5329. IF INCHR(")]",Stk$[i]) THEN nBrace--
  5330. IF Stk$[i] = "," THEN
  5331. IF nBrace=0 THEN CntMarker = i + 1
  5332. END IF
  5333. IF iMatchWrd(Stk$[i],"to") THEN
  5334. j = 1
  5335. Stk$[i] = " and <="
  5336. Stk$[CntMarker] = ">=" + Stk$[CntMarker]
  5337. END IF
  5338. NEXT
  5339. IF j=1 THEN
  5340. Src$ = ""
  5341. FOR i = 1 TO Ndx
  5342. Src$ = Src$ + Stk$[i] + " "
  5343. NEXT
  5344. CALL XParse(Src$)
  5345. END IF
  5346. EXIT SUB
  5347. END IF
  5348. CASE 4
  5349. '**************************************************************************
  5350. ' The following code introduces the following DLL declarations to BCX
  5351. '**************************************************************************
  5352. ' DECLARE FUNCTION Foo LIB "FOO.DLL" ALIAS "FooA" ( A$ )
  5353. ' OR
  5354. ' DECLARE FUNCTION Foo LIB "FOO.DLL" ( A$ ) - Alias will default to "FOO"
  5355. ' [5.08.1102] Foo = (BCXFPROTx)GetProcAddress(H_FOO, "FooA");
  5356. '**************************************************************************
  5357. IF Keyword$ = "declare" AND iMatchWrd(Stk$[4],"lib") THEN
  5358. DIM RAW alias$, i, idx=-1, AR_DllName$
  5359. REMOVE DQ$ FROM Stk$[5]
  5360. FOR i = 0 TO LoadLibsCnt - 1
  5361. IF Stk$[5] = Loadlibs$[i] THEN
  5362. idx = i
  5363. EXIT FOR
  5364. END IF
  5365. NEXT i
  5366. IF idx < 0 THEN
  5367. Loadlibs$[LoadLibsCnt] = Stk$[5]
  5368. INCR LoadLibsCnt
  5369. END IF
  5370. IF iMatchWrd(Stk$[6],"alias") THEN
  5371. alias$ = Stk$[7]
  5372. Stk$[6] = ""
  5373. Stk$[7] = ""
  5374. ELSE
  5375. alias$ = ENC$(Stk$[3])
  5376. END IF
  5377. INCR DllCnt
  5378. IF DllCnt > 799 THEN Abort("Maximum number of declarations exceded.")
  5379. IF INCHR(Stk$[5],"-") THEN
  5380. AR_DllName$ = EXTRACT$(Stk$[5], "-")
  5381. ELSEIF INCHR(Stk$[5],".") THEN
  5382. AR_DllName$ = EXTRACT$(Stk$[5], ".")
  5383. END IF
  5384. DllDecl$ [DllCnt] = "static BCXFPROT" + LTRIM$(STR$(DllCnt)) + SPC$ + Clean$(Stk$[3]) + "=(BCXFPROT" + LTRIM$(STR$(DllCnt)) + _
  5385. ")dlsym(H_" + UCASE$(AR_DllName$) + ", " + alias$ + ");"
  5386. Stk$[4] = ""
  5387. Stk$[5] = ""
  5388. EXIT SUB
  5389. END IF
  5390. CASE 7
  5391. IF Keyword$ = "get$" THEN
  5392. Stk$[1] = "~get"
  5393. EXIT SUB
  5394. END IF
  5395. IF Keyword$ = "global" AND iMatchWrd(Stk$[2],"dynamic") THEN
  5396. Stk$[1] = "global"
  5397. EXIT SUB
  5398. END IF
  5399. CASE 9
  5400. IF Keyword$ = "iremove" THEN
  5401. '***********************************************************
  5402. ' Translate IREMOVE UCASE$("aaa") FROM LTRIM$(RTRIM$(A$))
  5403. ' into A$ = IREMOVE$(LTRIM$(RTRIM$(A$)),UCASE$("aaa"))
  5404. '***********************************************************
  5405. DIM RAW Mat$, Fat$
  5406. Mat$ = "" : Fat$ = ""
  5407. FOR i = 2 TO Ndx
  5408. IF iMatchWrd(Stk$[i],"from") THEN
  5409. Stk$[i]= ""
  5410. EXIT FOR
  5411. END IF
  5412. NEXT
  5413. FOR j = 2 TO i
  5414. CONCAT(Mat$,Stk$[j]) ' build match string
  5415. NEXT
  5416. FOR j = i TO Ndx
  5417. CONCAT(Fat$,Stk$[j]) ' build fat source
  5418. NEXT
  5419. lszTmp$ = "=iremove$(" + Fat$ + "," + Mat$ + ")"
  5420. FastLexer(Fat$," ()","")
  5421. lszTmp$ = Stk$[Ndx] + lszTmp$
  5422. CALL XParse(lszTmp$)
  5423. CALL TokenSubstitutions
  5424. CALL Emit
  5425. Ndx = 0
  5426. EXIT SUB
  5427. END IF
  5428. IF Keyword$ = "ireplace" THEN
  5429. '**********************************************************
  5430. ' IREPLACE "this" WITH "that" IN A$ is transformed into
  5431. ' A$ = ireplace$ ( A$, "this", "that" )
  5432. ' BCX 3.73 introduces CASE INSENSITIVE REPLACE
  5433. '**********************************************************
  5434. IF Ndx < 6 THEN Abort("Problem with IREPLACE statement")
  5435. DIM RAW W, I, VV$, RR$, WW$
  5436. VV$ = "" : RR$ = "" : WW$ = ""
  5437. FOR W = 2 TO Ndx
  5438. IF iMatchWrd(Stk$[W],"with") THEN
  5439. Stk$[W]= ""
  5440. EXIT FOR
  5441. END IF
  5442. NEXT
  5443. FOR I = 2 TO Ndx
  5444. IF iMatchWrd(Stk$[I],"in") THEN
  5445. Stk$[I]= ""
  5446. EXIT FOR
  5447. END IF
  5448. NEXT
  5449. i = I+1
  5450. FOR j = i TO Ndx
  5451. CONCAT (VV$,Stk$[j])
  5452. NEXT
  5453. FOR j = 2 TO W
  5454. CONCAT (RR$,Stk$[j])
  5455. NEXT
  5456. i = W+1
  5457. FOR j = i TO I
  5458. CONCAT (WW$,Stk$[j])
  5459. NEXT
  5460. lszTmp$ = "=ireplace$(" + VV$ + "," + RR$ + "," + WW$ + ")"
  5461. FastLexer(VV$," ()","")
  5462. lszTmp$ = Stk$[Ndx] + lszTmp$
  5463. CALL XParse(lszTmp$)
  5464. CALL TokenSubstitutions
  5465. CALL Emit
  5466. Ndx = 0
  5467. EXIT SUB
  5468. END IF
  5469. CASE 12
  5470. IF Keyword$ = "local" AND iMatchWrd(Stk$[2],"dynamic") THEN
  5471. Stk$[1] = "dim"
  5472. EXIT SUB
  5473. END IF
  5474. CASE 16
  5475. IF Keyword$ = "put$" THEN
  5476. Stk$[1] = "~put"
  5477. EXIT SUB
  5478. END IF
  5479. CASE 18
  5480. IF Keyword$ = "remove" THEN
  5481. '***********************************************************
  5482. ' Translate REMOVE UCASE$("aaa") FROM LTRIM$(RTRIM$(A$))
  5483. ' into A$ = REMOVE$(LTRIM$(RTRIM$(A$)),UCASE$("aaa"))
  5484. '***********************************************************
  5485. DIM RAW Mat$, Fat$
  5486. Mat$ = ""
  5487. Fat$ = ""
  5488. FOR i = 2 TO Ndx
  5489. IF iMatchWrd(Stk$[i],"from") THEN
  5490. Stk$[i]= ""
  5491. EXIT FOR
  5492. END IF
  5493. NEXT
  5494. FOR j = 2 TO i
  5495. CONCAT(Mat$,Stk$[j]) ' build match string
  5496. NEXT
  5497. FOR j = i TO Ndx
  5498. CONCAT(Fat$,Stk$[j]) ' build fat source
  5499. NEXT
  5500. lszTmp$ = "=remove$(" + Fat$ + "," + Mat$ + ")"
  5501. FastLexer(Fat$," ()","")
  5502. lszTmp$ = Stk$[Ndx] + lszTmp$
  5503. CALL XParse(lszTmp$)
  5504. CALL TokenSubstitutions
  5505. CALL Emit
  5506. Ndx = 0
  5507. EXIT SUB
  5508. END IF
  5509. IF Keyword$ = "replace" THEN
  5510. '*******************************************************
  5511. ' REPLACE "this" WITH "that" IN A$ is transformed into
  5512. ' A$ = replace$ ( A$, "this", "that" )
  5513. ' BCX 2.93 allows expressions and arrays to be used
  5514. '*******************************************************
  5515. IF Ndx < 6 THEN Abort("Problem with REPLACE statement")
  5516. DIM RAW W, I, VV$, RR$, WW$
  5517. VV$ = ""
  5518. RR$ = ""
  5519. WW$ = ""
  5520. FOR W = 2 TO Ndx
  5521. IF iMatchWrd(Stk$[W],"with") THEN
  5522. Stk$[W]= ""
  5523. EXIT FOR
  5524. END IF
  5525. NEXT
  5526. FOR I = 2 TO Ndx
  5527. IF iMatchWrd(Stk$[I],"in") THEN
  5528. Stk$[I]= ""
  5529. EXIT FOR
  5530. END IF
  5531. NEXT
  5532. i = I+1
  5533. FOR j = i TO Ndx
  5534. CONCAT (VV$,Stk$[j])
  5535. NEXT
  5536. FOR j = 2 TO W
  5537. CONCAT (RR$,Stk$[j])
  5538. NEXT
  5539. i = W+1
  5540. FOR j = i TO I
  5541. CONCAT (WW$,Stk$[j])
  5542. NEXT
  5543. lszTmp$ = "=replace$(" + VV$ + "," + RR$ + "," + WW$ + ")"
  5544. FastLexer(VV$," ()","")
  5545. lszTmp$ = Stk$[Ndx] + lszTmp$
  5546. CALL XParse(lszTmp$)
  5547. CALL TokenSubstitutions
  5548. CALL Emit
  5549. Ndx = 0
  5550. EXIT SUB
  5551. END IF
  5552. CASE 27
  5553. SELECT CASE Keyword$
  5554. '**************************
  5555. CASE "$ifndef"
  5556. Stk$[1] = "~ifndef"
  5557. InConditional++
  5558. '**************************
  5559. CASE "$if","$ifdef"
  5560. Stk$[1] = "~if"
  5561. InConditional++
  5562. '**************************
  5563. CASE "$else"
  5564. Stk$[1] = "~else"
  5565. '**************************
  5566. CASE "$elseif"
  5567. Stk$[1] = "~elseif"
  5568. '**************************
  5569. CASE "$endif"
  5570. Stk$[1] = "~endif"
  5571. InConditional--
  5572. IF InConditional < 0 THEN 'simple check to see if to see if conditionals are balanced
  5573. Abort("To many $ENDIFs")
  5574. END IF
  5575. '**************************
  5576. CASE "$cpp"
  5577. Ndx = 0
  5578. UseCpp = TRUE
  5579. '**************************
  5580. CASE "$CPP"
  5581. Ndx = 0
  5582. UseCpp = TRUE
  5583. END SELECT
  5584. EXIT SUB
  5585. END SELECT
  5586. IFCond = 0
  5587. FOR i = 1 TO Ndx
  5588. IF iMatchWrd(Stk$[i],"if") THEN IFCond = i + 1
  5589. IF iMatchWrd(Stk$[i],"then") AND iMatchWrd(Stk$[i+1],"if") THEN
  5590. FOR j = i + 2 TO Ndx
  5591. IF iMatchWrd(Stk$[j],"else") THEN
  5592. EXIT FOR
  5593. END IF
  5594. NEXT
  5595. IF j > Ndx THEN ' safe to transform
  5596. FOR j = i TO IFCond + 1 STEP -1
  5597. Stk$[j] = Stk$[j - 1]
  5598. NEXT
  5599. Stk$[IFCond] = "("
  5600. i++
  5601. Stk$[i] = ")"
  5602. i++
  5603. FOR j = Ndx TO i STEP -1
  5604. Stk$[j + 2] = Stk$[j]
  5605. NEXT
  5606. Ndx++
  5607. Ndx++
  5608. Stk$[i] = "&&"
  5609. i++
  5610. Stk$[i] = "("
  5611. i++
  5612. FOR i = i TO Ndx
  5613. IF iMatchWrd(Stk$[i],"then") THEN
  5614. Ndx++
  5615. FOR j = Ndx TO i STEP -1
  5616. Stk$[j] = Stk$[j - 1]
  5617. NEXT
  5618. Stk$[i] = ")"
  5619. EXIT FOR
  5620. END IF
  5621. NEXT
  5622. i--
  5623. ELSE
  5624. EXIT FOR
  5625. END IF
  5626. END IF
  5627. NEXT
  5628. END SUB ' Transforms
  5629. SUB Parse(Arg$)
  5630. '****************
  5631. DIM RAW A, B
  5632. DIM RAW CommaCnt
  5633. DIM RAW Tmp
  5634. DIM RAW i
  5635. DIM RAW j
  5636. DIM RAW k
  5637. DIM RAW lszTmp$
  5638. DIM RAW L_Stk_1$
  5639. DIM RAW L_Stk_2$
  5640. DIM RAW Var1$
  5641. DIM RAW Plus2Amp = 0
  5642. DIM RAW vt
  5643. '****************
  5644. L_Stk_1$ = ""
  5645. L_Stk_2$ = ""
  5646. lszTmp$ = ""
  5647. Var1$ = ""
  5648. '****************
  5649. CALL XParse(Arg$)
  5650. PassOne = 0
  5651. IF NOT iMatchWrd(Stk$[1],"function") THEN
  5652. Plus2Amp = iMatchNQ(Arg$, "&")
  5653. FOR Tmp = 2 TO Ndx-1
  5654. IF Stk$[Tmp] = "+" THEN
  5655. vt = DataType(Stk$[Tmp+1])
  5656. IF vt = vt_STRVAR OR vt = vt_STRLIT THEN
  5657. Stk$[Tmp] = "&"
  5658. Plus2Amp = TRUE
  5659. ELSE
  5660. vt = DataType(Stk$[Tmp-1])
  5661. IF vt = vt_STRVAR OR vt = vt_STRLIT THEN
  5662. Stk$[Tmp] = "&"
  5663. Plus2Amp = TRUE
  5664. END IF
  5665. END IF
  5666. END IF
  5667. NEXT
  5668. IF Plus2Amp > 0 THEN
  5669. Use_Join = UseFlag = TRUE
  5670. j = 0
  5671. k = 0
  5672. FOR Tmp = 1 TO Ndx-1
  5673. A = CheckLocal(Stk$[Tmp], &i)
  5674. IF A = vt_UNKNOWN THEN A = CheckGlobal(Stk$[Tmp], &i)
  5675. IF A = vt_STRUCT OR A = vt_UDT OR A = vt_UNION THEN 'added vt_UNION 4.40
  5676. j = 1
  5677. END IF
  5678. IF Stk$[Tmp] = "&" THEN
  5679. A = DataType(Stk$[Tmp+1])
  5680. IF A = vt_STRVAR OR A = vt_STRLIT THEN
  5681. k = 1
  5682. ELSE
  5683. A = DataType(Stk$[Tmp-1])
  5684. IF A = vt_STRVAR OR A = vt_STRLIT THEN
  5685. k = 1
  5686. END IF
  5687. END IF
  5688. END IF
  5689. NEXT
  5690. IF k THEN
  5691. IF j THEN CALL AsmUnknownStructs(0)
  5692. CALL JoinStrings(1, 0)
  5693. Src$ = ""
  5694. FOR i = 1 TO Ndx
  5695. IF Stk[i][0] THEN
  5696. Src$ = Src$ + Stk$[i] + " "
  5697. END IF
  5698. NEXT
  5699. CALL XParse(Src$)
  5700. END IF
  5701. END IF
  5702. END IF
  5703. '***********************************************************
  5704. 'Moved here by Mike H. Was being applied too early.
  5705. 'causing lines with multiple statements to not receive the
  5706. 'conversion. i.e. sp->lpVtbl->Release(sp) : sp = NULL
  5707. '***********************************************************
  5708. IF UseCpp THEN
  5709. IF iMatchNQ(Src$,"->lpVtbl") THEN
  5710. FOR INTEGER i= 1 TO Ndx
  5711. IF iMatchRgt(Stk$[i],"->lpVtbl") THEN
  5712. Stk$[i] = EXTRACT$(Stk$[i],"->lpVtbl")
  5713. IF (Stk$[i+3] = Stk$[i-1] OR Stk$[i+3] = Stk$[i]) AND Stk$[i+3] <> ")" THEN
  5714. Stk$[i+3] = ""
  5715. IF Stk$[i+4] = "," THEN Stk$[i+4] = ""
  5716. END IF
  5717. END IF
  5718. NEXT
  5719. CALL RemEmptyTokens
  5720. END IF
  5721. END IF
  5722. '********************************************************************
  5723. ' At this point we have a fresh set of Stk$[] values, totaling Ndx
  5724. ' Start handling some unique situations
  5725. '********************************************************************
  5726. CALL TokenSubstitutions
  5727. IF Ndx = 0 THEN EXIT SUB
  5728. CALL Transforms
  5729. IF Ndx = 0 THEN EXIT SUB
  5730. '***********************************************************
  5731. 'Modification to allow 2 names as function types
  5732. '***********************************************************
  5733. IF iMatchWrd(Stk$[1],"function") THEN
  5734. IF iMatchWrd(Stk$[Ndx-2],"as") AND Stk$[Ndx] <> ")" THEN
  5735. IF NOT iMatchWrd(Stk$[Ndx],"export") AND NOT iMatchWrd(Stk$[Ndx],"stdcall") THEN
  5736. Stk$[Ndx-1] = Stk$[Ndx-1] + " " + Stk$[Ndx]
  5737. Ndx--
  5738. END IF
  5739. END IF
  5740. END IF
  5741. '********************************************************************
  5742. 'Modification to allow 2 names as argument types in sub or function
  5743. '********************************************************************
  5744. IF iMatchWrd(Stk$[1],"function") OR iMatchWrd(Stk$[1],"sub") THEN
  5745. DIM RAW offset
  5746. DIM RAW LastBrk = Ndx - 2
  5747. FOR i = Ndx TO 3 STEP -1
  5748. IF Stk$[i] = ")" THEN
  5749. LastBrk = i
  5750. EXIT FOR
  5751. END IF
  5752. NEXT
  5753. FOR i = 3 TO LastBrk
  5754. offset = 2
  5755. IF iMatchWrd(Stk$[i],"as") AND (i < LastBrk) AND Stk$[i + offset] <> "=" THEN
  5756. IF iMatchWrd(Stk$[i+1],"function") THEN offset = 3
  5757. IF NOT INCHR(Stk$[i + offset],")") AND NOT INCHR(Stk$[i + offset],",") THEN
  5758. IF LEN(Stk$[i + offset]) <> 0 AND NOT iMatchWrd(Stk$[i + 3],"as") THEN
  5759. Stk$[i+offset-1] = Stk$[i+offset-1] + " " + Stk$[i+offset]
  5760. Stk$[i + offset] = ""
  5761. END IF
  5762. END IF
  5763. END IF
  5764. NEXT
  5765. END IF
  5766. '***********************************************************
  5767. 'DynaCall Handler
  5768. IF NOT iMatchWrd(Stk$[1],"declare") THEN
  5769. FOR i = 1 TO Ndx
  5770. IF iMatchWrd(Stk$[i],"lib") THEN
  5771. IF Stk$[i-1] = "(" AND (DataType(Stk$[i+1]) = vt_STRLIT OR DataType(Stk$[i+1]) = vt_STRVAR) THEN
  5772. j = GetNumArgs(i+2)
  5773. lszTmp$ = "BCX_DynaCall"
  5774. IF NOT iMatchWrd(Stk$[1],"print") THEN 'print does its own casting
  5775. IF DataType(Stk$[i-2]) = vt_STRVAR OR DataType(Stk$[1]) = vt_STRVAR THEN
  5776. lszTmp$ = "(char*)" & lszTmp$
  5777. END IF
  5778. END IF
  5779. Var1$ = RIGHT$(Stk$[i-2], 1)
  5780. IF INCHR ("!$#¦%", Var1$) THEN
  5781. CONCAT (lszTmp$, Var1$)
  5782. Stk$[i] = ENC$(LEFT$(Stk$[i-2], LEN(Stk$[i-2]) - 1))
  5783. ELSE
  5784. Stk$[i] = ENC$(Stk$[i-2])
  5785. END IF
  5786. Stk$[i-2] = lszTmp$
  5787. FOR B = Ndx+3 TO i+3 STEP -1
  5788. Stk$[B] = Stk$[B-3]
  5789. NEXT
  5790. Stk$[i+2] = Stk$[i+1]
  5791. Stk$[i+1] = ","
  5792. Stk$[i+3] = ","
  5793. Stk$[i+4] = LTRIM$(STR$(j))
  5794. Stk$[i+5] = IIF$(j, ",", ")")
  5795. INCR Ndx, 3
  5796. Use_Dynacall = TRUE
  5797. END IF
  5798. END IF
  5799. NEXT
  5800. END IF
  5801. '****************[ Exponentiation Operator Handler ]******************
  5802. IF INCHR(Arg$,"^") THEN
  5803. DIM RAW lp = 0
  5804. DIM RAW rp = 0
  5805. Test = FALSE
  5806. FOR i = 1 TO Ndx
  5807. IF Stk$[i] = "^" THEN
  5808. Test = TRUE
  5809. IF Stk$[i+1] = "-" THEN
  5810. Ndx++
  5811. FOR A = Ndx TO i+2 STEP -1
  5812. Stk$[A] = Stk$[A-1]
  5813. NEXT
  5814. Stk$[i+1] = "("
  5815. B = i+3
  5816. IF Stk$[B] = "(" THEN
  5817. lp=0
  5818. rp=0
  5819. DO
  5820. IF Stk$[B] = "(" THEN lp++
  5821. IF Stk$[B] = ")" THEN rp++
  5822. B++
  5823. LOOP UNTIL lp = rp
  5824. Ndx++
  5825. j = B+1
  5826. FOR A = Ndx TO j STEP -1
  5827. Stk$[A] = Stk$[A-1]
  5828. NEXT
  5829. Stk$[B] = ")"
  5830. ELSE
  5831. B=i+4
  5832. IF INCHR("[",Stk$[B]) THEN
  5833. DO
  5834. B++
  5835. LOOP UNTIL INCHR("]",Stk$[B])
  5836. Ndx++
  5837. j = B+2
  5838. FOR A = Ndx TO j STEP -1
  5839. Stk$[A] = Stk$[A-1]
  5840. NEXT
  5841. Stk$[B+1] = ")"
  5842. ELSE
  5843. IF INCHR("(",Stk$[B]) THEN
  5844. DO
  5845. B++
  5846. LOOP UNTIL INCHR(")",Stk$[B])
  5847. Ndx++
  5848. j = B+2
  5849. FOR A = Ndx TO j STEP -1
  5850. Stk$[A] = Stk$[A-1]
  5851. NEXT
  5852. Stk$[B+1] = ")"
  5853. ELSE
  5854. Ndx++
  5855. j = B+1
  5856. FOR A = Ndx TO j STEP -1
  5857. Stk$[A] = Stk$[A-1]
  5858. NEXT
  5859. Stk$[B] = ")"
  5860. END IF
  5861. END IF
  5862. END IF
  5863. END IF
  5864. END IF
  5865. NEXT
  5866. IF Test THEN
  5867. FOR i = 1 TO Ndx
  5868. IF Stk$[i] = "^" THEN
  5869. A = i - 1
  5870. B = 0
  5871. WHILE Stk$[A] <> "="
  5872. IF Stk$[A] = "]" THEN B++
  5873. IF Stk$[A] = ")" THEN B++
  5874. IF Stk$[A] = "[" THEN B--
  5875. IF Stk$[A] = "(" THEN B--
  5876. IF B = 0 THEN EXIT WHILE
  5877. A--
  5878. WEND
  5879. IF Stk$[A] = "[" THEN A--
  5880. IF Stk$[A] = "=" THEN A++
  5881. IF Stk$[A] = "(" THEN
  5882. B = DataType(Stk$[A-1]) ' check if it's a function
  5883. IF NOT iMatchWrd(Stk$[A-1], "print") AND _
  5884. (B = vt_INTEGER OR B = vt_SINGLE OR B = vt_DOUBLE) THEN
  5885. A--
  5886. END IF
  5887. END IF
  5888. Arg$ = "pow("
  5889. B = A - 1
  5890. WHILE B > 0
  5891. Arg$ = Stk$[B] + " " + Arg$ + " "
  5892. B--
  5893. WEND
  5894. FOR B = A TO i - 1
  5895. Arg$ = Arg$ + " " + Stk$[B]
  5896. NEXT
  5897. CONCAT (Arg$, ",")
  5898. A = i + 1
  5899. B = DataType(Stk$[A])
  5900. IF (Stk$[A + 1] = "(" OR Stk$[A + 1] = "[") AND _
  5901. (B = vt_INTEGER OR B = vt_SINGLE OR B = vt_DOUBLE) THEN
  5902. A++
  5903. END IF
  5904. B = 0
  5905. WHILE A <= Ndx
  5906. IF Stk$[A] = "[" THEN B++
  5907. IF Stk$[A] = "(" THEN B++
  5908. IF Stk$[A] = "]" THEN B--
  5909. IF Stk$[A] = ")" THEN B--
  5910. IF NOT B THEN EXIT DO
  5911. A++
  5912. WEND
  5913. FOR B = i + 1 TO A
  5914. Arg$ = Arg$ + " " + Stk$[B]
  5915. NEXT
  5916. CONCAT(Arg$,")")
  5917. A++
  5918. WHILE A <= Ndx
  5919. Arg$ = Arg$ + " " + Stk$[A]
  5920. A++
  5921. WEND
  5922. EXIT FOR
  5923. END IF
  5924. NEXT
  5925. CALL Parse(Arg$)
  5926. END IF
  5927. END IF
  5928. '*****************************************************
  5929. L_Stk_1$ = LCASE$(Stk$[1]) ' Performance Optimizer
  5930. L_Stk_2$ = LCASE$(Stk$[2]) ' Performance Optimizer
  5931. '*****************************************************
  5932. IF L_Stk_1$ = "$dll" THEN
  5933. MakeDLL = NoMain = TRUE
  5934. IF IsApple then
  5935. LD_FLAGS$ = "-fPIC -shared $FILE$.so"
  5936. ELSE
  5937. LD_FLAGS$ = "-fPIC -shared -Wl,-soname,$FILE$.so"
  5938. END IF
  5939. Ndx = 0
  5940. '~ IF L_Stk_2$ = "stdcall" THEN
  5941. '~ UseStdCall = TRUE
  5942. '~ END IF
  5943. '~ IF NoDllMain THEN
  5944. '~ EXIT SUB
  5945. '~ END IF
  5946. '~ FPRINT Outfile,""
  5947. '~ FPRINT Outfile,"__declspec(dllexport) bool WINAPI DllMain (HINSTANCE hInst, DWORD Reason, LPVOID Reserved)"
  5948. '~ FPRINT Outfile,"{"
  5949. '~ FPRINT Outfile," switch (Reason)"
  5950. '~ FPRINT Outfile," {"
  5951. '~ FPRINT Outfile," case DLL_PROCESS_ATTACH:"
  5952. '~ FPRINT Outfile," BCX_hInstance = hInst;"
  5953. '~ FPRINT Outfile," break;"
  5954. '~ FPRINT Outfile," case DLL_PROCESS_DETACH:"
  5955. '~ FPRINT Outfile," break;"
  5956. '~ FPRINT Outfile," case DLL_THREAD_ATTACH:"
  5957. '~ FPRINT Outfile," break;"
  5958. '~ FPRINT Outfile," case DLL_THREAD_DETACH:"
  5959. '~ FPRINT Outfile," break;"
  5960. '~ FPRINT Outfile," }"
  5961. '~ FPRINT Outfile," return TRUE;"
  5962. '~ FPRINT Outfile,"}\n\n"
  5963. '~ Src$ = "GLOBAL BCX_hInstance AS HINSTANCE"
  5964. '~ Parse(Src$)
  5965. '~ Emit()
  5966. EXIT SUB
  5967. END IF
  5968. IsCallBack = 0
  5969. '******************************
  5970. IF iMatchWrd(Stk$[Ndx],"callback") THEN
  5971. IsCallBack = 1
  5972. Ndx--
  5973. END IF
  5974. '******************************
  5975. IF L_Stk_1$ = "open" THEN
  5976. FOR A = 1 TO Ndx
  5977. IF iMatchWrd(Stk$[A],"binary") THEN
  5978. EXIT FOR
  5979. END IF
  5980. NEXT
  5981. IF A < Ndx THEN
  5982. A++
  5983. Var1$ = LCASE$(Stk$[A])
  5984. IF Var1$ = "new" THEN
  5985. Stk$[A-1]= "binarynew"
  5986. FOR i = A+1 TO Ndx
  5987. Stk$[i-1]= Stk$[i]
  5988. NEXT
  5989. Ndx--
  5990. END IF
  5991. IF Var1$ = "append" THEN
  5992. Stk$[A-1]= "binaryappend"
  5993. FOR i = A+1 TO Ndx
  5994. Stk$[i-1]= Stk$[i]
  5995. NEXT
  5996. Ndx--
  5997. END IF
  5998. IF Var1$ = "input" THEN
  5999. Stk$[A-1]= "binaryinput"
  6000. FOR i = A+1 TO Ndx
  6001. Stk$[i-1]= Stk$[i]
  6002. NEXT
  6003. Ndx--
  6004. END IF
  6005. IF Var1$ = "output" THEN
  6006. Stk$[A-1]= "binaryoutput"
  6007. FOR i = A+1 TO Ndx
  6008. Stk$[i-1]= Stk$[i]
  6009. NEXT
  6010. Ndx--
  6011. END IF
  6012. END IF
  6013. END IF
  6014. IF L_Stk_1$ = "option" AND L_Stk_2$ = "base" THEN
  6015. OptionBase = VAL(Stk$[3])
  6016. Ndx = 0
  6017. EXIT SUB
  6018. END IF
  6019. '******************************
  6020. IF L_Stk_1$ = "dim" THEN
  6021. IF L_Stk_2$ = "shared" OR _
  6022. L_Stk_2$ = "dynamic" OR _
  6023. L_Stk_2$ = "raw" OR _
  6024. L_Stk_2$ = "local" OR _
  6025. L_Stk_2$ = "auto" OR _
  6026. L_Stk_2$ = "register" OR _
  6027. L_Stk_2$ = "static" THEN
  6028. Stk$[1] = L_Stk_2$
  6029. L_Stk_1$ = L_Stk_2$
  6030. FOR i = 3 TO Ndx
  6031. Stk$[i-1]= Stk$[i]
  6032. NEXT
  6033. Ndx--
  6034. END IF
  6035. END IF
  6036. '******************************
  6037. IF L_Stk_1$ = "public" THEN
  6038. IF L_Stk_2$ = "function" OR L_Stk_2$ = "sub" THEN
  6039. Stk$[1] = L_Stk_2$
  6040. L_Stk_1$ = L_Stk_2$
  6041. FOR i = 3 TO Ndx
  6042. Stk$[i-1] = Stk$[i]
  6043. NEXT
  6044. Ndx--
  6045. END IF
  6046. END IF
  6047. '******************************
  6048. ' creates a static function for use in $PROJECTs
  6049. IF L_Stk_1$ = "private" THEN
  6050. IF L_Stk_2$ = "function" OR L_Stk_2$ = "sub" THEN
  6051. Use_Static = TRUE
  6052. Stk$[1] = L_Stk_2$
  6053. L_Stk_1$ = L_Stk_2$
  6054. FOR i = 3 TO Ndx
  6055. Stk$[i-1] = Stk$[i]
  6056. NEXT
  6057. Ndx--
  6058. END IF
  6059. END IF
  6060. '******************************
  6061. IF L_Stk_1$ = "onexit" THEN
  6062. IF L_Stk_2$ = "sub" THEN
  6063. Use_ExitCode = TRUE
  6064. INCR ExitNdx
  6065. ExitSub$[ExitNdx] = Stk$[3]
  6066. Stk$[1] = L_Stk_2$
  6067. L_Stk_1$ = L_Stk_2$
  6068. FOR i = 3 TO Ndx
  6069. Stk$[i-1] = Stk$[i]
  6070. NEXT
  6071. Ndx--
  6072. END IF
  6073. END IF
  6074. '******************************
  6075. IF L_Stk_1$ = "onstart" THEN
  6076. IF L_Stk_2$ = "sub" THEN
  6077. Use_StartupCode = TRUE
  6078. INCR StartNdx
  6079. StartSub$[StartNdx] = Stk$[3]
  6080. Stk$[1] = L_Stk_2$
  6081. L_Stk_1$ = L_Stk_2$
  6082. FOR i = 3 TO Ndx
  6083. Stk$[i-1] = Stk$[i]
  6084. NEXT
  6085. Ndx--
  6086. END IF
  6087. END IF
  6088. '******************************
  6089. IF L_Stk_1$ = "overloaded" AND L_Stk_2$ = "function" THEN
  6090. Stk$[1] = "overloadedfunction"
  6091. L_Stk_1$ = "overloadedfunction"
  6092. FOR i = 3 TO Ndx
  6093. Stk$[i-1]= Stk$[i]
  6094. NEXT
  6095. Ndx--
  6096. END IF
  6097. '******************************
  6098. IF L_Stk_1$ = "overloadedfunction" AND Stk$[2] <> "=" THEN
  6099. OkayToSend = TRUE
  6100. END IF
  6101. '******************************
  6102. IF L_Stk_1$ = "overloaded" AND L_Stk_2$ = "sub" THEN
  6103. Stk$[1]= "overloadedsub"
  6104. FOR i = 3 TO Ndx
  6105. Stk$[i-1] = Stk$[i]
  6106. NEXT
  6107. Ndx--
  6108. END IF
  6109. '******************************
  6110. IF L_Stk_1$ = "function" AND iMatchWrd(Stk[3],"optional") THEN
  6111. Stk$[1]= "optfunction"
  6112. L_Stk_1$ = "optfunction"
  6113. FOR i = 4 TO Ndx
  6114. Stk$[i-1]= Stk$[i]
  6115. NEXT
  6116. Ndx--
  6117. END IF
  6118. '******************************
  6119. IF L_Stk_1$ = "optfunction" AND Stk$[2] <> "=" THEN
  6120. OkayToSend = TRUE
  6121. END IF
  6122. '******************************
  6123. IF L_Stk_1$ = "sub" AND iMatchWrd(Stk[3],"optional") THEN
  6124. L_Stk_1$ = "optsub"
  6125. Stk$[1]= "optsub"
  6126. FOR i = 4 TO Ndx
  6127. Stk$[i-1]= Stk$[i]
  6128. NEXT
  6129. Ndx--
  6130. END IF
  6131. '******************************
  6132. IF L_Stk_1$ = "end" AND Stk$[2] <> "=" THEN
  6133. Stk$[1]= L_Stk_1$ + L_Stk_2$
  6134. Ndx = 1
  6135. END IF
  6136. '******************************
  6137. IF L_Stk_1$ = "function" AND Stk$[2] <> "=" THEN
  6138. OkayToSend = TRUE
  6139. END IF
  6140. '******************************
  6141. IF L_Stk_1$ = "midstr" THEN
  6142. CommaCnt = 0
  6143. FOR i = 1 TO Ndx
  6144. IF Stk$[i] = "," THEN
  6145. INCR CommaCnt
  6146. ELSEIF Stk$[i]= "=" THEN
  6147. IF CommaCnt < 2 THEN
  6148. Stk$[i] = "-1,"
  6149. ELSE
  6150. Stk$[i]= ""
  6151. END IF
  6152. Stk$[i-1]= ","
  6153. Ndx++
  6154. Stk$[Ndx]= ")"
  6155. EXIT FOR
  6156. END IF
  6157. NEXT
  6158. END IF
  6159. '******************************
  6160. IF Stk$[2]= ":" THEN
  6161. IF Ndx = 2 THEN
  6162. Stk$[1]= UCASE$(Stk$[1]) + ":" 'preserve the GOTO labels
  6163. Ndx = 1
  6164. EXIT SUB
  6165. END IF
  6166. END IF
  6167. '******************************
  6168. IF L_Stk_1$ = "case" AND L_Stk_2$ = "else" THEN
  6169. Ndx = 1
  6170. Stk$[1]= "caseelse"
  6171. END IF
  6172. '******************************
  6173. FOR i = 1 TO Ndx
  6174. IF iMatchWrd(Stk$[i],"let") THEN
  6175. FOR j = i+1 TO Ndx
  6176. Stk$[j-1] = Stk$[j]
  6177. NEXT
  6178. Ndx--
  6179. END IF
  6180. NEXT
  6181. '******************************
  6182. IF Stk$[Ndx]= "*" THEN
  6183. Stk$[Ndx-1]= Stk$[Ndx-1] + "*"
  6184. Ndx--
  6185. END IF
  6186. '******************************
  6187. IF TestState = TRUE THEN
  6188. IF LastCmd = 0 THEN
  6189. IF Stk$[1] = "*" THEN
  6190. Z$ = Clean$(Stk$[2])
  6191. ELSE
  6192. Z$ = Clean$(Stk$[1])
  6193. END IF
  6194. IF LEFT$(Z$,1) = "*" THEN Z$ = MID$(Z$,2)
  6195. i = INCHR(Z$,".")
  6196. IF i = 0 THEN i = INSTR(Z$,"->")
  6197. IF i > 0 THEN
  6198. IF WithCnt THEN
  6199. Z$ = WithVar$[WithCnt]
  6200. ELSE
  6201. Z$ = LEFT$(Z$, i - 1)
  6202. END IF
  6203. END IF
  6204. IF INCHR(Z$,"[") THEN Z$ = EXTRACT$(Z$,"[")
  6205. IF CheckLocal(Z$, &j) = vt_UNKNOWN THEN
  6206. IF CheckGlobal(Z$, &j) = vt_UNKNOWN THEN
  6207. Z$ = LCASE$(Z$)
  6208. IF Stk$[2] = "=" AND Z$ <> "functionreturn" AND Z$ <> "bcx_retstr" AND Z$ <> "end" THEN
  6209. Warning("Assignment before Declaration in Line " + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + ": " + Src$)
  6210. END IF
  6211. END IF
  6212. END IF
  6213. END IF
  6214. END IF
  6215. END SUB ' Parse
  6216. SUB FuncSubDecs1(s$)
  6217. '*****************
  6218. DIM RAW i, j
  6219. '*****************
  6220. IF iMatchWrd(Stk$[1], s$) THEN
  6221. IF DataType(Stk$[2]) = vt_STRVAR THEN
  6222. Abort("Invalid " + s$ + "name")
  6223. END IF
  6224. END IF
  6225. FOR i = 1 TO Ndx
  6226. IF Stk$[i]= "[" AND Stk$[i+1]= "]" THEN
  6227. IF iMatchWrd(Stk$[i+2],"as") THEN
  6228. Stk$[i+3] = Stk$[i+3] + "*"
  6229. ELSEIF Stk$[i+2] = "[" THEN
  6230. j = i-1
  6231. WHILE i <= Ndx
  6232. IF iMatchWrd(Stk$[i],"as") THEN EXIT FOR
  6233. IF iMatchRgt(Stk$[j],"]") AND INCHR(",)=", Stk$[i]) THEN EXIT FOR
  6234. Stk$[j] = Stk$[j] + Stk$[i]
  6235. Stk$[i++] = ""
  6236. WEND
  6237. ITERATE
  6238. ELSE
  6239. IF DataType(Stk$[i-1]) = vt_STRVAR THEN
  6240. Stk$[i-1] = Stk$[i-1] + "[][65535]"
  6241. END IF
  6242. Stk$[i-1] = "*" + Stk$[i-1]
  6243. END IF
  6244. Stk$[i++] = "" : Stk$[i] = ""
  6245. END IF
  6246. NEXT
  6247. CALL RemEmptyTokens
  6248. IsExported = FALSE
  6249. IF iMatchWrd(Stk$[Ndx],"export") THEN
  6250. Ndx--
  6251. IsExported = TRUE
  6252. IF UseStdCall THEN
  6253. CallType$ = "__attribute__((stdcall)) "
  6254. ELSE
  6255. CallType$ = "__attribute__((cdecl)) "
  6256. END IF
  6257. END IF
  6258. END SUB ' FuncSubDecs1
  6259. SUB RemEmptyTokens()
  6260. DIM RAW i, j
  6261. FOR i = 1 TO Ndx
  6262. IF NOT *Stk[i] THEN
  6263. j = i
  6264. WHILE NOT *Stk[j] AND (j < Ndx)
  6265. INCR j
  6266. WEND
  6267. IF NOT *Stk[j] THEN EXIT FOR
  6268. Stk$[i] = Stk$[j]
  6269. Stk$[j] = ""
  6270. END IF
  6271. NEXT i
  6272. Ndx = i-1
  6273. END SUB
  6274. SUB FuncSubDecs2(s$, method)
  6275. IF iMatchWrd(Stk$[1], s$) THEN
  6276. IF iMatchWrd(Stk$[Ndx-1],"as") THEN
  6277. Abort("Attempted type assignment to " + s$)
  6278. END IF
  6279. VarCode.IsPtrFlag = 0
  6280. CurrentFuncType = vt_VOID
  6281. ELSE
  6282. IF iMatchWrd(Stk$[Ndx-1],"as") THEN
  6283. CurrentFuncType = CheckType(Stk$[Ndx])
  6284. VarCode.Token$ = Stk$[2]
  6285. VarCode.AsToken$ = Stk$[Ndx]
  6286. VarCode.IsPtrFlag = TALLY(Stk$[Ndx],"*")
  6287. Stk$[Ndx] = ""
  6288. Stk$[Ndx-1] = ""
  6289. Ndx--
  6290. Ndx--
  6291. ELSE
  6292. CurrentFuncType = DataType(Stk$[2])
  6293. VarCode.Token$ = Stk$[2]
  6294. 'print Stk$[2]
  6295. VarCode.IsPtrFlag = TALLY(Stk$[2],"*")
  6296. VarCode.AsToken$ = ""
  6297. END IF
  6298. END IF
  6299. VarCode.Proto$ = " ("
  6300. VarCode.Header$ = " ("
  6301. VarCode.Functype$ = ""
  6302. VarCode.Method% = method
  6303. VarCode.VarNo% = CurrentFuncType
  6304. CALL GetVarCode(&VarCode)
  6305. END SUB ' FuncSubDecs2
  6306. SUB FuncSubDecs3(varcode AS VARCODE PTR)
  6307. IF *Stk[Ndx-1] = ASC(".") THEN ' Allow Functions | Subs WITH one OR
  6308. varcode->Header$ = varcode->Header$ + "..." ' more "." TO produce the "..." needed
  6309. END IF
  6310. varcode->Header$ = RTRIM$(varcode->Header$)
  6311. IF iMatchRgt(varcode->Header$, ",") THEN
  6312. MID$(varcode->Header$, LEN(varcode->Header$)) = ")"
  6313. ELSE
  6314. CONCAT(varcode->Header$, ")")
  6315. END IF
  6316. REPLACE "()" WITH "(void)" IN varcode->Header$
  6317. varcode->Header$ = varcode->Functype$ + varcode->Token$ + varcode->Header$
  6318. IF varcode->Method% = 2 THEN
  6319. IF *Stk[Ndx-1] = ASC(".") THEN ' Allow Functions | Subs with one OR
  6320. varcode->Proto$ = varcode->Proto$ + "..." ' FOR variable argument declarations
  6321. END IF
  6322. varcode->Proto$ = RTRIM$(varcode->Proto$)
  6323. IF iMatchRgt(varcode->Proto$, ",") THEN
  6324. MID$(varcode->Proto$, LEN(varcode->Proto$)) = ")"
  6325. ELSE
  6326. CONCAT(varcode->Proto$, ")")
  6327. END IF
  6328. REPLACE "()" WITH "(void)" IN varcode->Proto$
  6329. varcode->Proto$ = varcode->Functype$ + varcode->Token$ + varcode->Proto$ + ";"
  6330. END IF
  6331. IF IsExported THEN
  6332. varcode->Proto$ = "C_EXPORT " + varcode->Proto$
  6333. varcode->Header$ = "C_EXPORT " + varcode->Header$
  6334. END IF
  6335. END SUB ' FuncSubDecs3
  6336. SUB AddTypeDefs(TypeName$, TDef)
  6337. TypeDefsCnt++
  6338. IF TypeDefsCnt = MaxTypes THEN Abort("Exceeded TYPE Limits.")
  6339. TypeDefs[TypeDefsCnt].VarName$ = TypeName$
  6340. TypeDefs[TypeDefsCnt].TypeofDef = TDef
  6341. TypeDefs[TypeDefsCnt].EleCnt = 0
  6342. END SUB ' AddTypeDefs
  6343. FUNCTION DefsID(ZZ$)
  6344. DIM RAW i
  6345. IF TypeDefsCnt > 0 THEN
  6346. FOR i = 1 TO TypeDefsCnt
  6347. IF ZZ$ = TypeDefs[i].VarName$ THEN
  6348. FUNCTION = i
  6349. END IF
  6350. NEXT
  6351. END IF
  6352. FUNCTION = 0
  6353. END FUNCTION ' DefsID
  6354. SUB GetTypeInfo(stk$, BYREF IsPointer, BYREF UdtIdx, BYREF vtCode)
  6355. DIM RAW Var1$
  6356. IsPointer = TALLY(stk$,"*")
  6357. Var1$ = REMOVE$(stk$,"*")
  6358. ' if it's a CLASS then get the structure information added 2008/10/07
  6359. IF RIGHT$(Var1$,6) = "_CLASS" THEN Var1$ = LEFT$(Var1$,LEN(Var1$)-6)
  6360. vtCode = CheckType(Var1$)
  6361. IF vtCode = vt_UNKNOWN THEN
  6362. CALL AddTypeDefs(Var1$, vt_UDT) 'windows def
  6363. vtCode = vt_UDT
  6364. END IF
  6365. UdtIdx = 0
  6366. IF vtCode = vt_STRUCT OR vtCode = vt_UNION OR vtCode = vt_UDT THEN
  6367. UdtIdx = DefsID(Var1$)
  6368. END IF
  6369. END SUB ' GetTypeInfo
  6370. SUB AddTypedefElement(WorkingTypeDefsCnt, ElType, EName$, EType$, EPtr)
  6371. DIM RAW TD AS UserTypeDefs PTR
  6372. TD = &(TypeDefs[WorkingTypeDefsCnt])
  6373. IF TD->EleCnt = MaxElements THEN Abort("Exceeded TYPE Element Limits.")
  6374. TD->Elements[TD->EleCnt].ElementType = ElType
  6375. TD->Elements[TD->EleCnt].ElementDynaPtr = EPtr
  6376. IF ElType = vt_STRUCT OR ElType = vt_UNION OR ElType = vt_UDT THEN
  6377. TD->Elements[TD->EleCnt].ElementID = DefsID(EType$)
  6378. ELSE
  6379. TD->Elements[TD->EleCnt].ElementID = 0
  6380. END IF
  6381. TD->Elements[TD->EleCnt].ElementName$ = EName$
  6382. TD->EleCnt = 1 + TD->EleCnt
  6383. END SUB ' AddTypedefElement
  6384. FUNCTION GetElement$(StartStk, BYREF vt, BYREF dms, id)
  6385. DIM RAW BC = 0, i, ZZ$
  6386. FOR i = StartStk+1 TO Ndx
  6387. IF Stk$[i] = "[" THEN
  6388. INCR BC
  6389. ELSEIF Stk$[i] = "]" THEN
  6390. DECR BC
  6391. ELSEIF BC = 0 THEN
  6392. IF iMatchLft(Stk$[i], "->") OR *Stk$[i] = ASC(".") THEN
  6393. ZZ$ = Clean$(Stk$[i])
  6394. RemoveAll(ZZ$, ".->(*)", 1)
  6395. vt = GetElementInfo(&id, &dms, ZZ$)
  6396. IF vt <> vt_STRUCT AND vt <> vt_UNION THEN EXIT FOR
  6397. END IF
  6398. END IF
  6399. NEXT
  6400. IF vt = vt_UDT OR vt = vt_UNION OR vt = vt_STRUCT THEN
  6401. ZZ$ = TypeDefs[id].VarName$
  6402. ELSE
  6403. ZZ$ = GetVarTypeName(vt)
  6404. END IF
  6405. FUNCTION = ZZ$
  6406. END FUNCTION
  6407. FUNCTION GetElementInfo(BYREF DefID, BYREF EPtr, Elename$)
  6408. DIM RAW i, id
  6409. id = DefID
  6410. FOR i = 0 TO TypeDefs[id].EleCnt - 1
  6411. IF Elename$ = TypeDefs[id].Elements[i].ElementName$ THEN
  6412. DefID = TypeDefs[id].Elements[i].ElementID
  6413. EPtr = TypeDefs[id].Elements[i].ElementDynaPtr
  6414. FUNCTION = TypeDefs[id].Elements[i].ElementType
  6415. END IF
  6416. NEXT
  6417. FUNCTION = 0
  6418. END FUNCTION
  6419. SUB HandleNonsense
  6420. DIM RAW i
  6421. FOR i = 1 TO Ndx ' tolerate nonsense like DIM A% as double
  6422. IF iMatchWrd(Stk$[i],"as") THEN Stk$[i - 1] = Clean$(Stk$[i - 1])
  6423. IF OptionBase THEN ' This was the easiest way I could see to do this!
  6424. IF Stk$[i] = "[" THEN Stk$[i+1] = LTRIM$(STR$(OptionBase)) + "+" + Stk$[i+1]
  6425. END IF
  6426. NEXT
  6427. END SUB ' HandleNonsense
  6428. SUB ValidVar(v$)
  6429. DIM RAW ZZ$
  6430. IF NOT isalpha(*v$) AND *v$ <> ASC("_") THEN
  6431. IF NOT iMatchLft(v$, "(*") THEN ' Allow byref format (*A).xxx
  6432. Abort("Invalid String Variable Name")
  6433. END IF
  6434. END IF
  6435. IF RestrictedWords(v$) AND TestState THEN
  6436. ZZ$ = "Variable " + v$ + " on line"
  6437. ZZ$ = ZZ$ + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + " is a Restricted Word"
  6438. CALL Warning(ZZ$)
  6439. END IF
  6440. END SUB ' ValidVar
  6441. SUB PointerFix
  6442. Stk$[Ndx-1] = Stk$[Ndx-1] + Stk$[Ndx]
  6443. Stk[Ndx][0] = 0
  6444. Ndx--
  6445. WHILE TALLY(Stk$[Ndx],"*") = LEN(Stk$[Ndx])
  6446. Stk$[Ndx-1] = Stk$[Ndx-1] + Stk$[Ndx]
  6447. Stk[Ndx][0] = 0
  6448. Ndx--
  6449. WEND
  6450. END SUB ' PointerFix
  6451. SUB DimDynaString(SVar$, DG, s)
  6452. DIM RAW A
  6453. DIM RAW DS$
  6454. DS$ = "if(" + SVar$ + ")free(" + SVar$ + ");"
  6455. IF InFunc AND (IsLocal OR IsDim OR IsRaw OR IsAuto OR IsRegister) AND DG = 0 THEN
  6456. LocalDynaCnt++
  6457. DynaStr$[LocalDynaCnt] = DS$
  6458. IF IsAuto THEN
  6459. FPRINT Outfile,Scoot$ ;"char *";SVar$;";"
  6460. ELSEIF IsRegister THEN
  6461. FPRINT Outfile,Scoot$ ;"register char *";SVar$;";"
  6462. ELSE
  6463. FPRINT Outfile,Scoot$ ;"char *";SVar$;";"
  6464. END IF
  6465. CALL AddLocal(SVar$, vt_CHAR, 0,"",1,0,0)
  6466. ELSE
  6467. IF Use_GenFree THEN
  6468. GlobalDynaCnt++
  6469. GlobalDynaStr$[GlobalDynaCnt] = DS$
  6470. END IF
  6471. IF DG = 2 THEN
  6472. CALL AddGlobal(SVar$, vt_CHAR, 0,"",1,0,1,0)
  6473. ELSE
  6474. IF s THEN
  6475. CALL AddGlobal(SVar$, vt_CHAR, 0,"",1,0,2,0)
  6476. ELSE
  6477. CALL AddGlobal(SVar$, vt_CHAR, 0,"",1,0,0,0)
  6478. END IF
  6479. END IF
  6480. END IF
  6481. IF DG <> 2 THEN
  6482. FPRINT Outfile,Scoot$ ; SVar$ ; "=(char*)calloc(256+";
  6483. FOR A = 4 TO Ndx
  6484. FPRINT Outfile,Clean$(Stk$[A]);
  6485. NEXT
  6486. FPRINT Outfile,",1);"
  6487. END IF
  6488. END SUB ' DimDynaString
  6489. FUNCTION SubFuncTest
  6490. IF iMatchWrd(Stk$[2],"function") OR iMatchWrd(Stk$[2],"sub") THEN
  6491. FUNCTION = 1
  6492. END IF
  6493. FUNCTION = 0
  6494. END FUNCTION ' SubFuncTest
  6495. FUNCTION DimSubFunc(IsDynamic)
  6496. '******************************
  6497. DIM RAW i
  6498. DIM RAW lszTmp$
  6499. DIM RAW StartPoint = 3
  6500. DIM RAW Funptr = 0
  6501. '******************************
  6502. lszTmp$ = ""
  6503. IF iMatchWrd(Stk$[Ndx],"stdcall") THEN
  6504. CallType$ = "__attribute__((stdcall)) "
  6505. Ndx--
  6506. IsStdFunc = TRUE
  6507. ELSE
  6508. CallType$ = "__attribute__((cdecl)) " ' Default calling convention
  6509. IsStdFunc = FALSE
  6510. END IF
  6511. GLOBAL SFPOINTER
  6512. DIM FP AS functionParse
  6513. '------------------------------------------------------
  6514. ' Find start of function body ( ... )
  6515. '------------------------------------------------------
  6516. CALL SepFuncArgs(3, &FP, TRUE)
  6517. StartPoint = MAX(FP.CommaPos[0], 3)
  6518. IF NOT InTypeDef THEN
  6519. SFPOINTER = TRUE
  6520. '------------------------------------------------------
  6521. ' Get intialized data " = xxx" or "= {xxx,xxx}"
  6522. '------------------------------------------------------
  6523. IF FP.NumArgs = 0 THEN
  6524. i = MIN(FP.CommaPos[1]+1, Ndx)
  6525. ELSE
  6526. i = MIN(FP.CommaPos[FP.NumArgs]+1, Ndx)
  6527. END IF
  6528. IF Stk$[i] = "=" THEN
  6529. Stk$[i++] = ""
  6530. WHILE NOT iMatchWrd(Stk$[i], "as") AND i <= Ndx
  6531. lszTmp$ = lszTmp$ +Stk$[i]
  6532. Stk$[i++] = ""
  6533. WEND
  6534. RemoveAll(lszTmp$, "{}", 1)
  6535. IF lszTmp$ <> "" THEN CALL RemEmptyTokens
  6536. END IF
  6537. '------------------------------------------------------
  6538. IF NOT InNameSpace THEN FPRINT FP4, MakeDecProto$(&FP), ";"
  6539. SFPOINTER = FALSE
  6540. Ndx = StartPoint
  6541. Stk$[2] = ""
  6542. IF lszTmp$ <> "" THEN
  6543. Stk$[Ndx++] = "="
  6544. Stk$[Ndx++] = "{"
  6545. Stk$[Ndx++] = Clean$(lszTmp$)
  6546. Stk$[Ndx++] = "}"
  6547. END IF
  6548. Stk$[Ndx++] = "as"
  6549. Stk$[Ndx] = Clean$(Stk$[3]) + "_TYPE" + STRING$(Funptr, ASC("*"))
  6550. CALL RemEmptyTokens
  6551. FUNCTION = FALSE
  6552. ELSE
  6553. '/***** 2010-11-15 Added Constructor/Destructor - AIR *****/
  6554. IF iMatchWrd(Stk$[2], "constructor") OR iMatchWrd(Stk$[2], "destructor") THEN
  6555. FPRINT Outfile, LF$, Scoot$, MakeDecProto$(&FP),";"
  6556. '/***** 2010-12-01 Added to support Abtract Classes - AIR *****/
  6557. ELSEIF Use_Virtual THEN
  6558. FPRINT Outfile, Scoot$, "virtual ", MakeDecProto$(&FP), vproc$, ";"
  6559. Use_Virtual = FALSE
  6560. ELSE
  6561. FPRINT Outfile, Scoot$, MakeDecProto$(&FP), ";"
  6562. END IF
  6563. END IF
  6564. FUNCTION = TRUE
  6565. END FUNCTION ' DimSubFunc
  6566. SUB Emit
  6567. '******************************
  6568. DIM RAW HasStorage = 0
  6569. DIM RAW A,B,i,j,Tmp
  6570. DIM RAW FuncRetnFlag
  6571. DIM RAW IsPointer = 0
  6572. DIM RAW VType
  6573. DIM RAW id = 0
  6574. DIM RAW k = 0
  6575. DIM RAW vt = 0
  6576. DIM RAW Arg$
  6577. DIM RAW CVar$
  6578. DIM RAW Keyword$
  6579. DIM RAW lszTmp$
  6580. DIM RAW Var1$
  6581. DIM RAW ZZ$
  6582. DIM RAW IsSubOrFuncPtr
  6583. DIM RAW dms
  6584. STATIC NoBreak
  6585. STATIC NoBreak2
  6586. '******************************
  6587. FuncRetnFlag = 0
  6588. lszTmp$ = ""
  6589. ZZ$ = ""
  6590. '******************************
  6591. '*************************************
  6592. ' Resets the break suppression flag if
  6593. ' any keyword follows other than these
  6594. '*************************************
  6595. Keyword$ = LCASE$(Stk$[1])
  6596. IF NoBreak2 AND NOT iMatchLft(Keyword$,"case") AND NOT iMatchWrd(Keyword$,"endselect") THEN
  6597. NoBreak2 = 0
  6598. END IF
  6599. '*********************
  6600. EmitAgain:
  6601. '*********************
  6602. IF Ndx = 0 THEN EXIT SUB
  6603. Statements++
  6604. IF iMatchRgt(Stk$[1], ":") THEN 'This Must Be A Label
  6605. FPRINT Outfile,""
  6606. FPRINT Outfile,UCASE$(Stk$[1]),";"
  6607. EXIT SUB
  6608. END IF
  6609. '--------- BEGIN INSERT ----------------
  6610. FOR i = 1 TO Ndx
  6611. REPLACE CHR$(-15) WITH ":" IN Stk$[i]
  6612. NEXT
  6613. '--------- END INSERT ----------------
  6614. IF (CurrentFuncType = vt_STRVAR) AND InFunc AND OkayToSend THEN
  6615. FPRINT Outfile,Scoot$,"char *BCX_RetStr={0};"
  6616. OkayToSend = 0
  6617. END IF
  6618. '**************************
  6619. ' SingleLineIfReEntry:
  6620. '**************************
  6621. Lookup$ = LCASE$(Stk$[1])
  6622. SELECT CASE Lookup$
  6623. '********************************************************************
  6624. CASE "fprint", "sprint"
  6625. '********************************************************************
  6626. DIM RAW IsLprint = FALSE
  6627. DIM RAW IsSprint = FALSE
  6628. IF iMatchWrd(Stk$[1],"sprint") THEN
  6629. IsSprint = TRUE
  6630. END IF
  6631. IF IsNumber(Stk$[2]) THEN
  6632. Stk$[2] = "FP" + Stk$[2]
  6633. END IF
  6634. IF IsSprint THEN
  6635. Handl$ = Clean$(Stk$[2])
  6636. ELSE
  6637. IF LCASE$(Stk$[2]) = "stderr" THEN
  6638. Handl$ = LCASE$(Stk$[2])
  6639. ELSE
  6640. IF CheckLocal(Stk$[2], &i) = vt_UNKNOWN THEN
  6641. IF CheckGlobal(Stk$[2], &i) = vt_UNKNOWN THEN
  6642. CALL AddGlobal(Stk$[2], vt_FILEPTR, 0,"",0,0,0,0)
  6643. END IF
  6644. END IF
  6645. Handl$ = ""
  6646. FOR i = 2 TO Ndx
  6647. IF *Stk$[i] = ASC(",") OR *Stk$[i] = ASC(";") THEN
  6648. Stk$[i] = ""
  6649. EXIT FOR
  6650. END IF
  6651. Handl$ = Handl$ + Stk$[i]
  6652. Stk$[i] = ""
  6653. NEXT i
  6654. Handl$ = Handl$ + "@"
  6655. END IF
  6656. END IF
  6657. Stk$[2] = "" 'get rid of handle
  6658. Stk$[3] = "" 'get rid of the Comma
  6659. IF IsSprint THEN
  6660. ZZ$ = "s" + PrintWriteFormat$(0)
  6661. REMOVE "\\n" FROM ZZ$
  6662. ELSE
  6663. ZZ$ = "f" + PrintWriteFormat$(0)
  6664. END IF
  6665. ZZ$ = LEFT$(ZZ$,8) + REMOVE$(Handl$,"@") + "," + MID$(ZZ$,9)
  6666. FPRINT Outfile,Scoot$, ZZ$
  6667. '***********************
  6668. CASE "end"
  6669. '***********************
  6670. IF Ndx = 1 THEN
  6671. FPRINT Outfile,Scoot$,"fflush(stdout);"
  6672. FPRINT Outfile,Scoot$,"exit(0);"
  6673. EXIT SELECT
  6674. END IF
  6675. IF Stk$[2] = "=" THEN
  6676. FPRINT Outfile,Scoot$,"fflush(stdout);"
  6677. FPRINT Outfile,Scoot$,"exit(";
  6678. FOR Tmp = 3 TO Ndx
  6679. FPRINT Outfile,Clean$(Stk$[Tmp]);
  6680. NEXT
  6681. FPRINT Outfile,");"
  6682. EXIT SELECT
  6683. END IF
  6684. IF iMatchWrd(Stk$[2],"if") THEN
  6685. CALL BumpDown
  6686. FPRINT Outfile,Scoot$,"}"
  6687. CALL BumpDown
  6688. EXIT SELECT
  6689. END IF
  6690. '***********************
  6691. CASE "endif"
  6692. '***********************
  6693. CALL BumpDown
  6694. FPRINT Outfile,Scoot$,"}"
  6695. CALL BumpDown
  6696. '***********************
  6697. CASE "if"
  6698. '***********************
  6699. CALL EmitIfCond("if")
  6700. '***********************
  6701. CASE "elseif"
  6702. '***********************
  6703. CALL BumpDown
  6704. FPRINT Outfile,Scoot$,"}"
  6705. CALL BumpDown
  6706. CALL EmitIfCond("else if")
  6707. '******************************************************
  6708. CASE "for"
  6709. '******************************************************
  6710. DIM RAW FFlg = 0
  6711. DIM RAW For1 = 0
  6712. DIM RAW For2 = 0
  6713. DIM RAW For3 = 0
  6714. DIM RAW For4 = 0
  6715. DIM RAW Reg$, xxx$, yyy$, zzz$, qqq$
  6716. Reg$ = ""
  6717. xxx$ = ""
  6718. yyy$ = ""
  6719. zzz$ = ""
  6720. qqq$ = ""
  6721. '******************************************************
  6722. FOR i = Ndx TO 1 STEP -1
  6723. IF iMatchWrd(Stk$[i],"step") THEN
  6724. FFlg = TRUE
  6725. EXIT FOR
  6726. END IF
  6727. NEXT
  6728. IF NOT FFlg THEN
  6729. Ndx++
  6730. Stk$[Ndx] = "step"
  6731. Ndx++
  6732. Stk$[Ndx] = "1"
  6733. END IF
  6734. '******************************************************
  6735. Test = FALSE
  6736. FOR i = 1 TO Ndx
  6737. IF Stk$[i]= "=" THEN Test = TRUE
  6738. NEXT
  6739. IF Test = FALSE THEN Abort("Missing =")
  6740. '******************************************************
  6741. Test = FALSE
  6742. FOR i = 1 TO Ndx
  6743. IF iMatchWrd(Stk$[i],"to") THEN Test = TRUE
  6744. NEXT
  6745. IF Test = FALSE THEN Abort("Missing TO")
  6746. '******************************************************
  6747. Reg$ = LCASE$(Stk$[2])
  6748. SELECT CASE Reg$
  6749. CASE "int","fint"
  6750. Reg$ = SPC$
  6751. LoopLocalVar[LoopLocalCnt++] = 1
  6752. FPRINT Outfile,Scoot$," {register int ";
  6753. CASE "single", "float"
  6754. Reg$ = SPC$
  6755. LoopLocalVar[LoopLocalCnt++] = 1
  6756. FPRINT Outfile,Scoot$," {float ";
  6757. CASE "double"
  6758. Reg$ = SPC$
  6759. LoopLocalVar[LoopLocalCnt++] = 1
  6760. FPRINT Outfile,Scoot$," {double ";
  6761. CASE "ldouble"
  6762. Reg$ = SPC$
  6763. LoopLocalVar[LoopLocalCnt++] = 1
  6764. FPRINT Outfile,Scoot$," {LDOUBLE ";
  6765. CASE ELSE
  6766. Reg$ = ""
  6767. LoopLocalVar[LoopLocalCnt++] = 0
  6768. END SELECT
  6769. IF LEN(Reg$) THEN
  6770. FOR j = 3 TO Ndx
  6771. Stk$[j-1] = Stk$[j]
  6772. NEXT
  6773. Ndx--
  6774. END IF
  6775. '******************************************************
  6776. ' Every statement now conforms to the following:
  6777. ' FOR xxx = yyy TO zzz STEP qqq
  6778. '******************************************************
  6779. FOR i = 2 TO Ndx
  6780. IF Stk$[i] = "=" THEN
  6781. For1 = i-1 'xxx spans from Stk$[2] to Stk$[For1]
  6782. EXIT FOR
  6783. END IF
  6784. NEXT
  6785. FOR i = For1+2 TO Ndx
  6786. IF iMatchWrd(Stk$[i],"to") THEN
  6787. For2 = i-1 'yyy spans from Stk$[For1+2] to Stk$[For2]
  6788. EXIT FOR
  6789. END IF
  6790. NEXT
  6791. FOR i = For2+2 TO Ndx
  6792. IF iMatchWrd(Stk$[i],"step") THEN
  6793. For3 = i-1 'zzz spans from Stk$[For2+2] to Stk$[For3]
  6794. EXIT FOR
  6795. END IF
  6796. NEXT
  6797. For4 = For3+2 'qqq spans from Stk$[For4] to Stk$[Ndx]
  6798. FOR i = 2 TO For1
  6799. CONCAT(xxx$,Stk$[i])
  6800. NEXT
  6801. FOR i = For1+2 TO For2
  6802. CONCAT(yyy$,Stk$[i])
  6803. NEXT
  6804. FOR i = For2+2 TO For3
  6805. CONCAT(zzz$,Stk$[i])
  6806. NEXT
  6807. FOR i = For4 TO Ndx
  6808. CONCAT(qqq$,Stk$[i])
  6809. NEXT
  6810. xxx$ = Clean$(xxx$)
  6811. yyy$ = Clean$(yyy$)
  6812. zzz$ = Clean$(zzz$)
  6813. qqq$ = Clean$(qqq$)
  6814. IF Reg$ = SPC$ THEN FPRINT Outfile, xxx$, ";"
  6815. Reg$ = ""
  6816. IF IsNumberEx (qqq$) THEN
  6817. IF LEFT$(qqq$,1) = "-" THEN
  6818. FPRINT Outfile,Scoot$,"for(", Reg$, xxx$, "=", yyy$, "; ", xxx$, ">=" , zzz$, "; " , xxx$, "+=" , qqq$, ")"
  6819. ELSE
  6820. FPRINT Outfile,Scoot$,"for(", Reg$, xxx$, "=", yyy$, "; ", xxx$, "<=" , zzz$, "; " , xxx$, "+=" , qqq$, ")"
  6821. END IF
  6822. ELSE
  6823. FPRINT Outfile,Scoot$,"for(", Reg$, xxx$, "=", yyy$, "; ", qqq$, ">=0 ? ", xxx$, "<=" , zzz$, " : ", xxx$, ">=", zzz$, "; " , xxx$, "+=" , qqq$, ")"
  6824. END IF
  6825. CALL BumpUp
  6826. FPRINT Outfile,Scoot$,"{"
  6827. CALL BumpUp
  6828. '***********************
  6829. CASE "next"
  6830. '***********************
  6831. CALL BumpDown
  6832. FPRINT Outfile,Scoot$,"}"
  6833. IF LoopLocalVar[--LoopLocalCnt] THEN FPRINT Outfile,Scoot$,"}"
  6834. IF LoopLocalCnt < 0 THEN Abort ("Next without For")
  6835. CALL BumpDown
  6836. '***********************
  6837. CASE "do"
  6838. '***********************
  6839. FPRINT Outfile,Scoot$,"for(;;)"
  6840. CALL BumpUp
  6841. FPRINT Outfile,Scoot$,"{"
  6842. CALL BumpUp
  6843. '***********************
  6844. CASE "loop"
  6845. '***********************
  6846. CALL BumpDown
  6847. FPRINT Outfile,Scoot$,"}"
  6848. CALL BumpDown
  6849. '***********************
  6850. CASE "caseelse"
  6851. '***********************
  6852. CaseElseFlag[Pusher] = TRUE
  6853. IF CaseFlag THEN
  6854. IF NoBreak2 = 0 THEN
  6855. FPRINT Outfile,Scoot$,"break;"
  6856. END IF
  6857. CALL BumpDown
  6858. FPRINT Outfile,Scoot$,"}"
  6859. FPRINT Outfile,Scoot$,"// case else"
  6860. FPRINT Outfile,Scoot$,"{"
  6861. CALL BumpUp
  6862. END IF
  6863. '***********************
  6864. CASE "endselect"
  6865. '***********************
  6866. IF CaseFlag THEN
  6867. CALL BumpDown
  6868. FPRINT Outfile,Scoot$,"}"
  6869. END IF
  6870. CALL BumpDown
  6871. ' Only suppress this break if the Case block contains
  6872. ' a "CASE ELSE" and the last statement is a redirection.
  6873. IF CaseElseFlag[Pusher] = 0 OR NoBreak2 = 0 THEN
  6874. FPRINT Outfile,Scoot$,"break;"
  6875. END IF
  6876. CALL BumpDown
  6877. FPRINT Outfile,Scoot$,"}"
  6878. NoBreak2 = CaseElseFlag[Pusher] = 0
  6879. CALL Pop(CaseVar$)
  6880. '***********************
  6881. CASE "else"
  6882. '***********************
  6883. CALL BumpDown
  6884. FPRINT Outfile,Scoot$,"}"
  6885. CALL BumpDown
  6886. FPRINT Outfile,Scoot$,"else"
  6887. CALL BumpUp
  6888. FPRINT Outfile,Scoot$,"{"
  6889. CALL BumpUp
  6890. ' **************
  6891. CASE "case"
  6892. ' **************
  6893. FOR i = 2 TO Ndx
  6894. IF Stk$[i] = "%" THEN Stk$[i] = " % " ' Added by MrBCX 3.36
  6895. IF Stk$[i] = "!=" THEN Stk$[i] = "<>"
  6896. IF Stk$[i] = "!" AND Stk$[i+1] = "=" THEN
  6897. Stk$[i] = "<>" : Stk$[i+1] = ""
  6898. END IF
  6899. IF isalpha(Stk[i][0]) THEN
  6900. CONCAT(Stk$[i]," ")
  6901. END IF
  6902. NEXT
  6903. szTmp$ = ""
  6904. Test = FALSE
  6905. IF DataType(CaseVar$) = vt_STRVAR THEN Test = TRUE
  6906. i = 0
  6907. FOR A = 2 TO Ndx
  6908. IF INCHR("([",Stk$[A]) THEN i++
  6909. IF INCHR(")]",Stk$[A]) THEN i--
  6910. IF i THEN
  6911. CONCAT(szTmp$, Stk$[A])
  6912. ITERATE
  6913. END IF
  6914. IF Stk$[A] = "," THEN ' comma
  6915. IF NOT INCHR("<>=",Stk$[A+1]) THEN
  6916. szTmp$ = szTmp$ + " or " + CaseVar$ + "="
  6917. ELSE
  6918. szTmp$ = szTmp$ + " or " + CaseVar$
  6919. END IF
  6920. Stk$[A] = ""
  6921. ITERATE
  6922. END IF
  6923. IF Stk$[A] = "&&" THEN
  6924. szTmp$ = szTmp$ + " and " + CaseVar$
  6925. Stk$[A]= ""
  6926. ELSEIF Stk$[A] = "||" THEN
  6927. szTmp$ = szTmp$ + " or " + CaseVar$
  6928. Stk$[A]= ""
  6929. ELSE
  6930. CONCAT(szTmp$, Stk$[A])
  6931. END IF
  6932. NEXT
  6933. IF CaseFlag = 0 THEN NoBreak = 0
  6934. IF CaseFlag THEN
  6935. IF NoBreak = 0 THEN
  6936. IF NoBreak2 = 0 THEN FPRINT Outfile,Scoot$;"break;"
  6937. END IF
  6938. CALL BumpDown()
  6939. FPRINT Outfile,Scoot$;"}"
  6940. CALL BumpDown()
  6941. END IF
  6942. CaseFlag = TRUE
  6943. IF iMatchLft(CaseVar$," BAND ") THEN
  6944. NoBreak = 1
  6945. Src$ = "IF " + szTmp$ + CaseVar$ + " Then "
  6946. ELSE
  6947. IF INCHR("<>=",szTmp$) AND NOT IsQuoted(szTmp$) THEN
  6948. Src$ = "IF " + CaseVar$ + szTmp$ + " Then "
  6949. ELSE
  6950. Src$ = "IF " + CaseVar$ + " = " + szTmp$ + " Then "
  6951. END IF
  6952. END IF
  6953. CALL Parse(Src$)
  6954. CALL Emit()
  6955. '***********************
  6956. CASE "delay"
  6957. '***********************
  6958. lszTmp$ = ""
  6959. FOR i = 2 TO Ndx ' Allow size to be an expression
  6960. CONCAT(lszTmp$, Clean$(Stk$[i]))
  6961. NEXT
  6962. FPRINT Outfile,Scoot$,"sleep(";lszTmp$;");"
  6963. '***********************
  6964. CASE "qsortidx"
  6965. '***********************
  6966. lszTmp$ = ""
  6967. Var$ = Clean$(Stk$[2]) 'index array
  6968. FOR i = 4 TO Ndx-4 'allow size to be an expression
  6969. CONCAT(lszTmp$, Stk$[i])
  6970. NEXT
  6971. lszTmp$ = Clean$(lszTmp$)
  6972. FPRINT Outfile,Scoot$,"Key = ",Stk[Ndx],";"
  6973. IF Var$ <> "0" THEN
  6974. FPRINT Outfile,Scoot$,"int iDx;"
  6975. FPRINT Outfile,Scoot$,"for(iDx=0; iDx<",lszTmp$,"; iDx+=1) ";
  6976. FPRINT Outfile, Var$,"[iDx]=iDx;"
  6977. END IF
  6978. IF NOT INCHR(Stk$[Ndx-2],".") THEN 'Check if this is a struct sort
  6979. Use_Idxqsort = TRUE
  6980. FPRINT Outfile,Scoot$,"pppStr = ",Clean$(Stk[Ndx-2]),";"
  6981. FPRINT Outfile,Scoot$,"qsort(";Var$;",";lszTmp$;",sizeof(int),IdxCompare);"
  6982. ELSE
  6983. DIM RAW Stptr$, StMem$, StName$
  6984. StMem$ = REMAIN$(Clean$(Stk$[Ndx-2]),".")
  6985. Stptr$ = EXTRACT$(Stk$[Ndx-2],".")
  6986. IF CheckLocal(Stptr,&i) <> vt_UNKNOWN THEN
  6987. StName$ = TypeDefs[LocalVars[i].VarDef].VarName$
  6988. ELSEIF CheckGlobal(Stptr,&i) <> vt_UNKNOWN THEN
  6989. StName$ = TypeDefs[GlobalVars[i].VarDef].VarName$
  6990. END IF
  6991. IF Var$ <> "0" THEN
  6992. Use_IdxqsortSt = TRUE
  6993. FPRINT Outfile,Scoot$,"cmp1 =(char*)(",Stptr$ ,") + offsetof(",StName$,",",StMem$,");"
  6994. FPRINT Outfile,Scoot$,"StructSize = sizeof(",StName$,");"
  6995. FPRINT Outfile,Scoot$,"qsort(",Var$;",",lszTmp$,",sizeof(int),IdxCompareSt);"
  6996. ELSE
  6997. Use_PtrqsortSt = TRUE
  6998. FPRINT Outfile,Scoot$,"OffSet = offsetof(",StName$,",",StMem$,");"
  6999. FPRINT Outfile,Scoot$,"qsort(",Stptr$;",",lszTmp$,",sizeof(",StName$,"),PtrCompareSt);"
  7000. END IF
  7001. END IF
  7002. '***********************
  7003. CASE "qsort"
  7004. '***********************
  7005. DIM RAW QST=0
  7006. DIM RAW order=0
  7007. IF iMatchWrd(Stk$[2],"dynamic") THEN
  7008. QST = TRUE
  7009. FOR j = 3 TO Ndx
  7010. Stk$ [j-1] = Stk$[j]
  7011. NEXT
  7012. Ndx--
  7013. END IF
  7014. IF LCASE$(Stk$[Ndx])= "ascending" THEN
  7015. order = 2
  7016. Ndx--
  7017. Ndx--
  7018. END IF
  7019. IF LCASE$(Stk$[Ndx])= "descending" THEN
  7020. order = 1
  7021. Ndx--
  7022. Ndx--
  7023. END IF
  7024. IF order = 0 THEN order = 2 'default to ascending
  7025. lszTmp$ = ""
  7026. FOR i = 4 TO Ndx 'allow size to be an expression
  7027. CONCAT(lszTmp$, Stk$[i])
  7028. NEXT
  7029. Var$ = Clean$(Stk$[2])
  7030. vt = DataType(Stk$[2])
  7031. IF vt <> vt_STRVAR AND vt <> vt_INTEGER AND vt <> vt_SINGLE AND vt <> vt_DOUBLE THEN
  7032. vt = CheckType(Stk$[2])
  7033. END IF
  7034. FPRINT Outfile,Scoot$,"qsort(";Var$;",";Clean$(lszTmp$);
  7035. SELECT CASE vt
  7036. CASE vt_STRVAR
  7037. IF NOT QST THEN
  7038. IF order = 1 THEN
  7039. FPRINT Outfile,",sizeof(";Var$;"[0]),StrCompareD);"
  7040. Use_Strqsortd = TRUE
  7041. ELSE
  7042. FPRINT Outfile,",sizeof(";Var$;"[0]),StrCompareA);"
  7043. Use_Strqsorta = TRUE
  7044. END IF
  7045. ELSE
  7046. IF order = 1 THEN
  7047. FPRINT Outfile,",sizeof(";Var$;"[0]),DynStrCompareD);"
  7048. Use_DynStrqsortd = TRUE
  7049. ELSE
  7050. FPRINT Outfile,",sizeof(";Var$;"[0]),DynStrCompareA);"
  7051. Use_DynStrqsorta = TRUE
  7052. END IF
  7053. END IF
  7054. CASE vt_INTEGER
  7055. IF order = 1 THEN
  7056. FPRINT Outfile,",sizeof(int),NumCompareDint);"
  7057. Use_Numqsortdint = TRUE
  7058. ELSE
  7059. FPRINT Outfile,",sizeof(int),NumCompareAint);"
  7060. Use_Numqsortaint = TRUE
  7061. END IF
  7062. CASE vt_SINGLE
  7063. IF order = 1 THEN
  7064. FPRINT Outfile,",sizeof(float),NumCompareDfloat);"
  7065. Use_Numqsortdfloat = TRUE
  7066. ELSE
  7067. FPRINT Outfile,",sizeof(float),NumCompareAfloat);"
  7068. Use_Numqsortafloat = TRUE
  7069. END IF
  7070. CASE vt_DOUBLE
  7071. IF order = 1 THEN
  7072. FPRINT Outfile,",sizeof(double),NumCompareDdouble);"
  7073. Use_Numqsortddouble = TRUE
  7074. ELSE
  7075. FPRINT Outfile,",sizeof(double),NumCompareAdouble);"
  7076. Use_Numqsortadouble = TRUE
  7077. END IF
  7078. CASE ELSE
  7079. IF order = 1 THEN
  7080. FPRINT Outfile,",sizeof(int),NumCompareDint);"
  7081. Use_Numqsortdint = TRUE
  7082. ELSE
  7083. FPRINT Outfile,",sizeof(int),NumCompareAint);"
  7084. Use_Numqsortaint = TRUE
  7085. END IF
  7086. END SELECT
  7087. '***********************
  7088. CASE "endprogram"
  7089. '***********************
  7090. FPRINT Outfile," return 0; // End of main program"
  7091. FPRINT Outfile,"}\n\n"
  7092. EndOfProgram = 1
  7093. '******************************
  7094. ' Allow Conditional Compilation
  7095. '******************************
  7096. '***********************
  7097. CASE "~ifndef"
  7098. '***********************
  7099. InIfDef$ = "#ifndef "
  7100. FOR i = 2 TO Ndx
  7101. InIfDef$ = InIfDef$ + Stk$[i] + " "
  7102. NEXT
  7103. InIfDef$ = TRIM$(InIfDef$)
  7104. IF InFunc OR InMain THEN
  7105. FPRINT Outfile,InIfDef$
  7106. ELSE
  7107. FPRINT FP6,InIfDef$
  7108. END IF
  7109. '***********************
  7110. CASE "~if"
  7111. '***********************
  7112. InIfDef$ = "#if defined "
  7113. FOR i = 2 TO Ndx
  7114. InIfDef$ = InIfDef$ + Stk$[i] + " "
  7115. NEXT
  7116. InIfDef$ = TRIM$(InIfDef$)
  7117. ConstLastDef$ = InIfDef$
  7118. IF InFunc THEN
  7119. IF Outfile = FP3 THEN FPRINT Outfile,"// FP3"
  7120. IF Outfile = FP2 THEN FPRINT Outfile,"// FP2"
  7121. FPRINT Outfile,InIfDef$,"// OUTFILE"
  7122. InIfDef$ = "FP3"
  7123. ELSEIF InMain THEN
  7124. FPRINT Outfile, InIfDef$, "// --FP2--"
  7125. END IF
  7126. '***********************
  7127. CASE "~else"
  7128. '***********************
  7129. InIfDef$ = "#else"
  7130. ConstLastDef$ = InIfDef$
  7131. IF InFunc OR InMain THEN
  7132. FPRINT Outfile,InIfDef$
  7133. ELSE
  7134. FPRINT FP6,InIfDef$
  7135. END IF
  7136. '***********************
  7137. CASE "~elseif"
  7138. '***********************
  7139. InIfDef$ = "#elif defined "
  7140. FOR i = 2 TO Ndx
  7141. InIfDef$ = InIfDef$ + Stk$[i] + " "
  7142. NEXT
  7143. InIfDef$ = TRIM$(InIfDef$)
  7144. ConstLastDef$ = InIfDef$
  7145. IF InFunc OR InMain THEN
  7146. FPRINT Outfile, InIfDef$
  7147. ELSE
  7148. FPRINT FP6, InIfDef$
  7149. END IF
  7150. '***********************
  7151. CASE "~endif"
  7152. '***********************
  7153. IF InIfDef$ = "FP3" THEN
  7154. FPRINT FP3, "#endif // FP3"
  7155. ELSE 'elseif InMain THEN
  7156. FPRINT Outfile, "#endif // Main"
  7157. END IF
  7158. IF ConstLastDef$ = "FP6" THEN
  7159. FPRINT FP6, "#endif // FP6"
  7160. END IF
  7161. InIfDef$ = "#endif // other"
  7162. IF InConditional = 0 THEN
  7163. InIfDef$ = ""
  7164. ConstLastDef$ = ""
  7165. 'DidConsts = 0
  7166. END IF
  7167. '***********************
  7168. CASE "incr"
  7169. '***********************
  7170. j=FALSE
  7171. FPRINT Outfile,Scoot$;
  7172. FOR i=2 TO Ndx
  7173. IF Stk$[i]="," THEN
  7174. FPRINT Outfile,"+=(";
  7175. j=TRUE
  7176. ELSE
  7177. FPRINT Outfile,Clean$(Stk$[i]);
  7178. END IF
  7179. NEXT
  7180. FPRINT Outfile,IIF$(j,");","++;")
  7181. '***********************
  7182. CASE "decr"
  7183. '***********************
  7184. j=FALSE
  7185. FPRINT Outfile,Scoot$;
  7186. FOR i=2 TO Ndx
  7187. IF Stk$[i]="," THEN
  7188. FPRINT Outfile,"-=(";
  7189. j=TRUE
  7190. ELSE
  7191. FPRINT Outfile,Clean$(Stk$[i]);
  7192. END IF
  7193. NEXT
  7194. FPRINT Outfile,IIF$(j,");","--;")
  7195. '***********************
  7196. CASE "seek"
  7197. '***********************
  7198. IF DataType(Stk$[2])= vt_NUMBER THEN
  7199. Stk$[2]= "FP" + Stk$[2]
  7200. END IF
  7201. IF CheckLocal(Stk$[2], &i) = vt_UNKNOWN THEN
  7202. CALL AddGlobal(Stk$[2], vt_FILEPTR, 0,"",0,0,0,0)
  7203. END IF
  7204. FPRINT Outfile,Scoot$,"fseek(";
  7205. FOR Tmp = 2 TO Ndx
  7206. FPRINT Outfile,Clean$(Stk$[Tmp]);
  7207. NEXT
  7208. FPRINT Outfile,",0);"
  7209. '***********************
  7210. CASE "select"
  7211. '***********************
  7212. CaseVar$ = ""
  7213. CaseFlag = 0
  7214. FOR A = 3 TO Ndx
  7215. CONCAT(CaseVar$, Stk$[A])
  7216. NEXT
  7217. CALL Push(CaseVar$)
  7218. FPRINT Outfile,Scoot$,"for(;;)"
  7219. FPRINT Outfile,Scoot$,"{"
  7220. CALL BumpUp
  7221. '***********************
  7222. CASE "~get"
  7223. '***********************
  7224. Use_Get = TRUE
  7225. IF DataType(Stk$[2])= vt_NUMBER THEN
  7226. Stk$[2]= "FP" + Stk$[2]
  7227. END IF
  7228. IF CheckLocal(Stk$[2], &i) = vt_UNKNOWN THEN
  7229. IF CheckGlobal(Stk$[2], &i) = vt_UNKNOWN THEN
  7230. CALL AddGlobal(Stk$[2], vt_FILEPTR, 0,"",0,0,0,0)
  7231. END IF
  7232. END IF
  7233. FPRINT Outfile,Scoot$,"GET(";
  7234. FOR Tmp = 2 TO Ndx
  7235. FPRINT Outfile,Clean$(Stk$[Tmp]);
  7236. NEXT
  7237. FPRINT Outfile,");"
  7238. '***********************
  7239. CASE "~put"
  7240. '***********************
  7241. Use_Put = TRUE
  7242. IF DataType(Stk$[2]) = vt_NUMBER THEN
  7243. Stk$[2]= "FP" + Stk$[2]
  7244. END IF
  7245. IF CheckLocal(Stk$[2], &i) = vt_UNKNOWN THEN
  7246. IF CheckGlobal(Stk$[2], &i) = vt_UNKNOWN THEN
  7247. CALL AddGlobal(Stk$[2], vt_FILEPTR, 0,"",0,0,0,0)
  7248. END IF
  7249. END IF
  7250. FPRINT Outfile,Scoot$,"PUT(";
  7251. FOR Tmp = 2 TO Ndx
  7252. FPRINT Outfile,Clean$(Stk$[Tmp]);
  7253. NEXT
  7254. FPRINT Outfile,");"
  7255. '***********************
  7256. CASE "gosub"
  7257. '***********************
  7258. Use_Gosub = TRUE
  7259. FPRINT Outfile,Scoot$,"if (setjmp(GosubStack[GosubNdx++])==0)";
  7260. FPRINT Outfile," goto ";UCASE$(Stk$[2]);";"
  7261. '***********************
  7262. CASE "return"
  7263. '***********************
  7264. Use_Gosub = TRUE
  7265. FPRINT Outfile,Scoot$,"longjmp (GosubStack [--GosubNdx],1 );"
  7266. FPRINT Outfile,""
  7267. '***********************
  7268. CASE "data"
  7269. '***********************
  7270. IF Stk$[Ndx] <> "," THEN
  7271. Stk$[Ndx+1] = ","
  7272. Ndx++
  7273. END IF
  7274. FOR A = 2 TO Ndx
  7275. IF INCHR(Stk$[A],DQ$) = 0 AND Stk$[A] <> "," THEN
  7276. Stk$[A] = ENC$(Stk$[A]) ' Allow unquoted text
  7277. END IF
  7278. FPRINT FP5,Stk$[A];
  7279. NEXT
  7280. FPRINT FP5,""
  7281. CASE "namespace"
  7282. UseCpp = TRUE
  7283. szTmp$ = MID$(Src$,INCHR(Src$," ")+1)
  7284. FPRINT Outfile,"namespace " + LTRIM$(szTmp$)
  7285. FPRINT Outfile,"{"
  7286. '/** 2010/11/30 Added -AIR **/
  7287. InNameSpace++
  7288. CALL BumpUp
  7289. CASE "endnamespace"
  7290. InNameSpace--
  7291. CALL BumpDown
  7292. FPRINT Outfile,Scoot$,"}"
  7293. '/****** ADDED 2010-11-14 AIR *****/
  7294. '***********************
  7295. CASE "class"
  7296. '***********************
  7297. IF InTypeDef = 0 THEN
  7298. SaveOutfileNum = Outfile
  7299. END IF
  7300. Outfile = FP4
  7301. InTypeDef++
  7302. TypeName$[InTypeDef] = Stk$[2]
  7303. IF Stk$[3] = "inherits" THEN Stk$[3] = ": public " + Stk$[4]
  7304. CALL AddTypeDefs(TypeName$[InTypeDef],vt_STRUCT)
  7305. BaseTypeDefsCnt[InTypeDef] = TypeDefsCnt
  7306. IF InTypeDef = 1 THEN
  7307. FPRINT Outfile,""
  7308. FPRINT Outfile,"class ";TypeName$[InTypeDef];Stk$[3];" {"
  7309. CALL BumpUp
  7310. END IF
  7311. '/****** ADDED 2010-11-14 AIR *****/
  7312. '***********************
  7313. CASE "endclass"
  7314. '***********************
  7315. CALL BumpDown
  7316. FPRINT Outfile,"};";LF$
  7317. InTypeDef--
  7318. '***********************
  7319. CASE "type"
  7320. '***********************
  7321. IF InTypeDef = 0 THEN
  7322. SaveOutfileNum = Outfile
  7323. END IF
  7324. Outfile = FP4
  7325. IF Ndx > 2 THEN
  7326. IF InTypeDef THEN
  7327. CALL Abort("Single line TYPE within type/union not supported")
  7328. END IF
  7329. FOR i = Ndx TO 1 STEP -1
  7330. IF iMatchWrd(Stk$[i],"as") THEN
  7331. EXIT FOR
  7332. END IF
  7333. NEXT
  7334. IF NOT iMatchWrd(Stk$[i],"as") THEN
  7335. CALL Abort("Missing AS TYPE")
  7336. END IF
  7337. FPRINT Outfile,"typedef ";
  7338. j = i-1
  7339. i++
  7340. WHILE i <= Ndx
  7341. FPRINT Outfile,Stk$[i];" ";
  7342. i++
  7343. WEND
  7344. FOR i = 2 TO j
  7345. FPRINT Outfile,Stk$[i];
  7346. NEXT
  7347. FPRINT Outfile,";"
  7348. Outfile = SaveOutfileNum
  7349. ELSE
  7350. InTypeDef++
  7351. TypeName$[InTypeDef] = Stk$[2]
  7352. CALL AddTypeDefs(TypeName$[InTypeDef],vt_STRUCT)
  7353. BaseTypeDefsCnt[InTypeDef] = TypeDefsCnt
  7354. IF InTypeDef = 1 THEN
  7355. FPRINT Outfile,""
  7356. FPRINT Outfile,"typedef struct _";TypeName$[InTypeDef]
  7357. FPRINT Outfile,"{"
  7358. CALL BumpUp
  7359. ELSE
  7360. FPRINT Outfile,Scoot$;"struct"
  7361. FPRINT Outfile,Scoot$;"{"
  7362. CALL AddTypedefElement(BaseTypeDefsCnt[InTypeDef-1],vt_STRUCT,TypeName$[InTypeDef],TypeName$[InTypeDef], 0)
  7363. CALL BumpUp
  7364. END IF
  7365. END IF
  7366. '***********************
  7367. CASE "endtype"
  7368. '***********************
  7369. IF InTypeDef = 1 THEN
  7370. CALL BumpDown
  7371. FPRINT Outfile,"}";TypeName$[InTypeDef];", *";"LP";UCASE$(TypeName$[InTypeDef]); ";"
  7372. FPRINT Outfile,""
  7373. Outfile = SaveOutfileNum
  7374. FPRINT FP6,Scoot$;"#define ",UCASE$(TypeName$[InTypeDef]),"_CLASS struct _",UCASE$(TypeName$[InTypeDef]),"*"
  7375. ELSE
  7376. CALL BumpDown
  7377. FPRINT Outfile,Scoot$;"} ";TypeName$[InTypeDef];";"
  7378. FPRINT Outfile,""
  7379. END IF
  7380. InTypeDef--
  7381. '***********************
  7382. CASE "union"
  7383. '***********************
  7384. IF InTypeDef = 0 THEN
  7385. SaveOutfileNum = Outfile
  7386. END IF
  7387. Outfile = FP4
  7388. InTypeDef++
  7389. TypeName$[InTypeDef] = Stk$[2]
  7390. CALL AddTypeDefs(TypeName$[InTypeDef],vt_UNION)
  7391. BaseTypeDefsCnt[InTypeDef] = TypeDefsCnt
  7392. IF InTypeDef = 1 THEN
  7393. FPRINT Outfile,""
  7394. FPRINT Outfile,"typedef union "
  7395. FPRINT Outfile,"{"
  7396. CALL BumpUp
  7397. ELSE
  7398. FPRINT Outfile,Scoot$;"union"
  7399. FPRINT Outfile,Scoot$;"{"
  7400. CALL AddTypedefElement(BaseTypeDefsCnt[InTypeDef-1],vt_UNION,TypeName$[InTypeDef],TypeName$[InTypeDef], 0)
  7401. CALL BumpUp
  7402. END IF
  7403. '***********************
  7404. CASE "endunion"
  7405. '***********************
  7406. IF InTypeDef = 1 THEN
  7407. CALL BumpDown
  7408. FPRINT Outfile,"} ";TypeName$[InTypeDef];", *";"LP";UCASE$(TypeName$[InTypeDef]); ";"
  7409. FPRINT Outfile,""
  7410. Outfile = SaveOutfileNum
  7411. ELSE
  7412. CALL BumpDown
  7413. FPRINT Outfile,Scoot$;"} ";TypeName$[InTypeDef];";"
  7414. FPRINT Outfile,""
  7415. END IF
  7416. InTypeDef--
  7417. '***********************
  7418. CASE "with"
  7419. '***********************
  7420. GLOBAL WithVar$[8]
  7421. GLOBAL WithCnt
  7422. WithCnt++
  7423. IF WithCnt = 8 THEN Abort("[With] depth exceeded")
  7424. WithVar$[WithCnt] = ""
  7425. FOR i = 2 TO Ndx
  7426. CONCAT(WithVar$[WithCnt],Stk$[i])
  7427. NEXT
  7428. '***********************
  7429. CASE "endwith"
  7430. '***********************
  7431. WithCnt--
  7432. '***********************
  7433. CASE "clear"
  7434. '***********************
  7435. Use_Clear = TRUE
  7436. FPRINT Outfile, Scoot$, "Clear ";
  7437. IF Stk$[2]<> "(" THEN FPRINT Outfile,"(";
  7438. FOR i = 2 TO Ndx
  7439. FPRINT Outfile,Clean$(Stk$[i]);
  7440. NEXT
  7441. IF Stk$[2]<> "(" THEN FPRINT Outfile,")";
  7442. FPRINT Outfile,";"
  7443. '***********************
  7444. CASE "repeat"
  7445. '***********************
  7446. lszTmp$ = ""
  7447. FOR i = 2 TO Ndx
  7448. CONCAT(lszTmp$, Stk$[i])
  7449. NEXT
  7450. lszTmp$ = Clean$(lszTmp$)
  7451. CALL BumpUp
  7452. IF INCHR(Stk$[2],"-") THEN
  7453. IF LEFT$(lszTmp$,1) = "-" THEN lszTmp$ = MID$(lszTmp$,2)
  7454. FPRINT Outfile,Scoot$,"{register int BCX_REPEAT;"
  7455. FPRINT Outfile,Scoot$,"for(BCX_REPEAT=";lszTmp$;";BCX_REPEAT>=1;BCX_REPEAT--)"
  7456. FPRINT Outfile,Scoot$,"{"
  7457. ELSE
  7458. FPRINT Outfile,Scoot$,"{register int BCX_REPEAT;"
  7459. FPRINT Outfile,Scoot$,"for(BCX_REPEAT=1;BCX_REPEAT<=";lszTmp$;";BCX_REPEAT++)"
  7460. FPRINT Outfile,Scoot$,"{"
  7461. END IF
  7462. CALL BumpUp
  7463. '***********************
  7464. CASE "endrepeat"
  7465. '***********************
  7466. CALL BumpDown
  7467. FPRINT Outfile,Scoot$,"}"
  7468. FPRINT Outfile,Scoot$,"}"
  7469. CALL BumpDown
  7470. CASE "const"
  7471. '***********************
  7472. DIM RAW Buffer$
  7473. DIM RAW Sep$
  7474. Buffer$ = ""
  7475. Sep$ = ""
  7476. Stk$[1] = ""
  7477. FOR i = 2 TO Ndx
  7478. IF Stk$[i] = "=" THEN
  7479. INCR i
  7480. EXIT FOR
  7481. ELSE
  7482. CONCAT(Stk$[1], Stk$[i])
  7483. END IF
  7484. NEXT
  7485. Stk$[1] = "#define " + Clean$(Stk$[1]) + SPC$
  7486. FOR i = i TO Ndx
  7487. IF isalpha(Stk[i][0]) OR (Stk[i][0] = ASC("_") AND _
  7488. isalpha(Stk[i+1][0])) OR Stk[i+1][0] = ASC("_") THEN Sep$ = " " ELSE Sep$ = ""
  7489. IF NOT IsQuoted(Stk$[i]) THEN REMOVE "$" FROM Stk$[i]
  7490. Buffer$ = Buffer$ + Stk$[i] + Sep$
  7491. NEXT
  7492. Buffer$ = Stk$[1] + Buffer$
  7493. IF InConditional THEN
  7494. IF InFunc THEN
  7495. FPRINT Outfile,Buffer$
  7496. ELSE
  7497. IF ConstLastDef$ <> "FP6" THEN
  7498. FPRINT FP6,InIfDef$,"// FP6"
  7499. ConstLastDef$ = "FP6"
  7500. END IF
  7501. FPRINT FP6,Buffer$
  7502. END IF
  7503. ELSE
  7504. FPRINT FP6,Buffer$
  7505. END IF
  7506. '***********************
  7507. CASE "kill"
  7508. '***********************
  7509. FPRINT Outfile,Scoot$,"remove (";
  7510. FOR A = 2 TO Ndx
  7511. FPRINT Outfile,Clean$(TRIM$(Stk$[A]));
  7512. NEXT
  7513. FPRINT Outfile,");"
  7514. '***********************
  7515. CASE "chdir", "_chdir", "rmdir", "_rmdir", "mkdir", "_mkdir"
  7516. '***********************
  7517. FPRINT Outfile,Scoot$,Lookup$;" (";
  7518. FOR A = 2 TO Ndx
  7519. FPRINT Outfile,Clean$(TRIM$(Stk$[A]));
  7520. NEXT
  7521. FPRINT Outfile,");"
  7522. '***********************
  7523. CASE "free"
  7524. '***********************
  7525. DIM RAW VI AS VarInfo PTR
  7526. A = 2
  7527. IF iMatchWrd(Stk$[2], "dynamic") THEN A = 3
  7528. IF Stk$[A] = "(" THEN
  7529. INCR A
  7530. DECR Ndx
  7531. END IF
  7532. CVar$ = Clean$(Stk$[A])
  7533. vt = CheckLocal(CVar$, &id)
  7534. IF vt = vt_UNKNOWN THEN
  7535. vt = CheckGlobal(CVar$, &id)
  7536. IF vt = vt_UNKNOWN THEN
  7537. Abort("Can not REDIM " + CVar$ + " not previously dimensioned")
  7538. END IF
  7539. VI = &GlobalVars[id]
  7540. ELSE
  7541. VI = &LocalVars[id]
  7542. Warning("Local dynamic variables are automatically freed.", 1)
  7543. END IF
  7544. CVar$ = ""
  7545. FOR i = A TO Ndx
  7546. CVar$ = CVar$ + Stk$[i]
  7547. NEXT
  7548. CVar$ = Clean$(CVar$)
  7549. IF vt = vt_STRUCT OR vt = vt_UNION THEN
  7550. GetElement$(2, &vt, &dms, VI->VarDef)
  7551. IF vt <> vt_UNKNOWN AND dms > 0 THEN
  7552. Use_DynamicA = TRUE
  7553. FPRINT Outfile,Scoot$,"if (", CVar$;
  7554. FPRINT Outfile,") { DestroyArr((void **)", CVar$, ",", dms, ", 1); ";
  7555. FPRINT Outfile,CVar$ ; "=NULL; }"
  7556. EXIT SELECT
  7557. END IF
  7558. END IF
  7559. IF VI->VarPntr > 1 THEN
  7560. Use_DynamicA = TRUE
  7561. FPRINT Outfile,Scoot$,"if (" ; CVar$ ;
  7562. FPRINT Outfile,") { DestroyArr((void **)" + CVar$ + "," + STR$(VI->VarPntr) + ", 1); ";
  7563. FPRINT Outfile,CVar$ ; "=NULL; }"
  7564. ELSE
  7565. FPRINT Outfile,Scoot$,"free(", CVar$, "), ", CVar$, "=NULL;"
  7566. END IF
  7567. '*************************************************************************
  7568. CASE "midstr"
  7569. '*************************************************************************
  7570. Src$ = ""
  7571. FOR A = 1 TO Ndx
  7572. CONCAT(Src$,Clean$(Stk$[A]))
  7573. NEXT
  7574. FPRINT Outfile,Scoot$, TRIM$(Src$), ";"
  7575. '***********************
  7576. CASE "swap"
  7577. '***********************
  7578. RAW VI1 AS VarInfo PTR
  7579. RAW VI2 AS VarInfo PTR
  7580. RAW indx AS INTEGER
  7581. FPRINT Outfile,Scoot$,"swap ((BYTE*)&";
  7582. FOR i = 2 TO Ndx
  7583. IF Stk$[i]= "," THEN EXIT FOR
  7584. FPRINT Outfile,Clean$(Stk$[i]);
  7585. NEXT
  7586. A = CheckLocal(Stk$[2], &indx)
  7587. IF A = vt_UNKNOWN THEN
  7588. A = CheckGlobal(Stk$[2], &indx)
  7589. IF A = vt_UNKNOWN THEN
  7590. Abort("Variable '"+Stk$[2]+"' in swap statement unknown")
  7591. END IF
  7592. VI1 = &GlobalVars[indx]
  7593. ELSE
  7594. VI1 = &LocalVars[indx]
  7595. END IF
  7596. IF RIGHT$(Stk$[i-1],1) <> "]" THEN
  7597. IF VI1->VarType = vt_CHAR AND VI1->VarPntr = 1 THEN FPRINT Outfile,"[0]";
  7598. END IF
  7599. FPRINT Outfile,",(BYTE*)&";
  7600. i++
  7601. FOR j = i TO Ndx
  7602. FPRINT Outfile,Clean$(Stk$[j]);
  7603. NEXT
  7604. A = CheckLocal(Stk$[i], &indx)
  7605. IF A = vt_UNKNOWN THEN
  7606. A = CheckGlobal(Stk$[i], &indx)
  7607. IF A = vt_UNKNOWN THEN
  7608. Abort("Variable '"+Stk$[i]+"' in swap statement unknown")
  7609. END IF
  7610. VI2 = &GlobalVars[indx]
  7611. ELSE
  7612. VI2 = &LocalVars[indx]
  7613. END IF
  7614. IF RIGHT$(Stk$[j-1],1) <> "]" THEN
  7615. IF VI2->VarType = vt_CHAR AND VI2->VarPntr = 1 THEN FPRINT Outfile,"[0]";
  7616. END IF
  7617. IF VI1->VarType <> VI2->VarType THEN
  7618. Warning("Possible size error in swap statement")
  7619. END IF
  7620. IF VI2->VarType = vt_STRVAR OR VI2->VarType = vt_CHAR THEN
  7621. FPRINT Outfile,",strlen(";
  7622. ELSE
  7623. FPRINT Outfile,",sizeof(";
  7624. END IF
  7625. FOR j = i TO Ndx
  7626. FPRINT Outfile,Clean$(Stk$[j]);
  7627. NEXT
  7628. FPRINT Outfile,"));"
  7629. '***********************
  7630. CASE "rename"
  7631. '***********************
  7632. FPRINT Outfile,Scoot$,"rename (";
  7633. FOR A = 2 TO Ndx
  7634. FPRINT Outfile,Clean$(TRIM$(Stk$[A]));
  7635. NEXT
  7636. FPRINT Outfile,");"
  7637. '***********************
  7638. CASE "copyfile"
  7639. '***********************
  7640. FPRINT Outfile,Scoot$,"CopyFile ";
  7641. IF Stk$[2] <> "(" THEN FPRINT Outfile, "(";
  7642. FOR A = 2 TO Ndx
  7643. FPRINT Outfile,Clean$(TRIM$(Stk$[A]));
  7644. NEXT
  7645. IF Stk$[Ndx] <> ")" THEN
  7646. FPRINT Outfile, ");"
  7647. ELSE
  7648. FPRINT Outfile, ";"
  7649. END IF
  7650. '***********************
  7651. CASE "shell"
  7652. '***********************
  7653. IF Ndx > 2 THEN
  7654. FOR A = 3 TO Ndx
  7655. Stk$[2] = Stk$[2] + Stk$[A]
  7656. NEXT
  7657. END IF
  7658. ZZ$ = Stk$[2]
  7659. IF ZZ$ = "" THEN ZZ$ = DDQ$
  7660. FPRINT Outfile,Scoot$ ; "Shell(" ; Clean$(ZZ$) ; ");"
  7661. '*****************************************************************************
  7662. CASE "lineinput"
  7663. ' LINEINPUT "prompt", A$ <<< Keyboard version 4.21
  7664. '*****************************************************************************
  7665. ' Test for new keyboard version of LINE INPUT
  7666. i = DataType(Stk$[2])
  7667. IF i = vt_STRLIT OR i = vt_STRVAR THEN
  7668. IF i <> vt_STRLIT THEN Stk$[2] = Clean$(Stk$[2])
  7669. FPRINT Outfile,Scoot$,"printf(", ENC$("%s"), ",", Stk$[2], ");"
  7670. FPRINT Outfile,Scoot$,"AR_fgets_retval=fgets(", Clean$(Stk$[3]), ",2048-1,stdin);"
  7671. FPRINT Outfile,Scoot$,Clean$(Stk$[3]),"[strlen(",Clean$(Stk$[3]),")-1]=0;"
  7672. EXIT SELECT
  7673. END IF
  7674. ' ********************* Okay, we're dealing with a file ************************
  7675. REMOVE "#" FROM Stk$[2]
  7676. IF DataType(Stk$[2]) = vt_NUMBER THEN
  7677. Stk$[2]= "FP" & Stk$[2]
  7678. END IF
  7679. Handl$ = EXTRACT$(Stk$[2], "[")
  7680. IF CheckLocal(Handl$, &i) = vt_UNKNOWN THEN
  7681. IF CheckGlobal(Handl$, &i) = vt_UNKNOWN THEN
  7682. CALL AddGlobal(Handl$, vt_FILEPTR, 0,"",0,0,0,0)
  7683. END IF
  7684. END IF
  7685. Var$ = Clean$(Stk$[3])
  7686. Var1$ = ""
  7687. CVar$ = Var$
  7688. IF INCHR( Var$, "[" ) AND INCHR( Var$, "]" ) THEN
  7689. IF INSTR( Var$, "[++" ) THEN
  7690. REPLACE "++" WITH "" IN CVar$
  7691. END IF
  7692. IF INSTR( Var$, "[--" ) THEN
  7693. REPLACE "--" WITH "" IN CVar$
  7694. END IF
  7695. IF INSTR( Var$, "++]" ) THEN
  7696. REPLACE "++" WITH "" IN CVar$
  7697. Var1$ = MID$(Var$,INCHR(Var$,"[")+1)
  7698. Var1$ = EXTRACT$(Var1$,"]")
  7699. Var$ = CVar$
  7700. END IF
  7701. IF INSTR( Var$, "--]" ) THEN
  7702. REPLACE "--" WITH "" IN CVar$
  7703. Var1$ = MID$(Var$,INCHR(Var$,"[")+1)
  7704. Var1$ = EXTRACT$(Var1$,"]")
  7705. Var$ = CVar$
  7706. END IF
  7707. END IF
  7708. FPRINT Outfile,Scoot$, Var$ ; "[0]=0;"
  7709. FPRINT Outfile,Scoot$, "AR_fgets_retval=fgets(" ; Var$ ; ",1048576,"; Clean$(Stk$[2]) ; ");"
  7710. FPRINT Outfile,Scoot$, "if(" ; CVar$ ; "[strlen(" ;CVar$ ; ")-1]==10)";
  7711. FPRINT Outfile,CVar$ ; "[strlen(" ; CVar$ ; ")-1]=0;"
  7712. IF Var1$ <> "" THEN
  7713. FPRINT Outfile,Var1$ ; ";"
  7714. END IF
  7715. '*************************************************************************
  7716. CASE "open"
  7717. '*************************************************************************
  7718. FOR A = 1 TO Ndx
  7719. Keyword$ = LCASE$(Stk$[A])
  7720. SELECT CASE Keyword$
  7721. CASE "open"
  7722. Stk$[A] = ""
  7723. CASE "for"
  7724. Stk$[A] = ""
  7725. Filnam$ = ""
  7726. FOR j = 2 TO A-1
  7727. CONCAT (Filnam$,Stk$[j])
  7728. NEXT
  7729. Filnam$ = Clean$(Filnam$)
  7730. CASE "as"
  7731. Stk$[A] = ""
  7732. IF DataType(Stk$[A + 1]) = vt_NUMBER THEN
  7733. Stk$[A + 1] = "FP" + Stk$[A + 1]
  7734. END IF
  7735. IF CheckLocal(Stk$[A + 1], &i) = vt_UNKNOWN THEN
  7736. IF CheckGlobal(Stk$[A + 1], &i) = vt_UNKNOWN THEN
  7737. CALL AddGlobal(Stk$[A + 1], vt_FILEPTR, 0,"",0,0,0,0)
  7738. END IF
  7739. END IF
  7740. Var$ = ""
  7741. FOR j = A+1 TO Ndx
  7742. IF iMatchWrd(Stk$[j], "reclen") THEN EXIT FOR
  7743. CONCAT (Var$,Stk$[j])
  7744. Stk$[j] = ""
  7745. NEXT
  7746. Handl$ = Var$ + "@"
  7747. CASE "network"
  7748. Use_Socket = TRUE
  7749. CASE "input"
  7750. Op$ = ENC$("r")
  7751. Stk$[A] = ""
  7752. CASE "output"
  7753. Op$ = ENC$("w")
  7754. Stk$[A] = ""
  7755. CASE "append"
  7756. Op$ = ENC$("a")
  7757. Stk$[A] = ""
  7758. CASE "binary"
  7759. Op$ = ENC$("rb+")
  7760. Stk$[A] = ""
  7761. CASE "binaryappend"
  7762. Op$ = ENC$("ab+")
  7763. Stk$[A] = ""
  7764. CASE "binarynew"
  7765. Op$ = ENC$("wb+")
  7766. Stk$[A] = ""
  7767. CASE "binaryinput"
  7768. Op$ = ENC$("rb")
  7769. Stk$[A] = ""
  7770. CASE "binaryoutput"
  7771. Op$ = ENC$("rb+")
  7772. Stk$[A] = ""
  7773. CASE "reclen"
  7774. IF Stk$[A+1] = "=" THEN
  7775. FOR j = A+2 TO Ndx
  7776. Stk$[j-1] = Stk$[j]
  7777. NEXT
  7778. Ndx--
  7779. END IF
  7780. Var$ = EXTRACT$(Clean$(Handl$), "[") + "len"
  7781. IF CheckLocal(Var$, &i) = vt_UNKNOWN THEN
  7782. CALL AddGlobal(Var$, vt_INTEGER , 0,"",0,0,0,0)
  7783. ELSE
  7784. IF CheckLocal(Var$, &i) = vt_UNKNOWN THEN
  7785. CALL AddLocal(Var$, vt_INTEGER , 0,"",0,0,0)
  7786. Var$ = "int " + Var$
  7787. END IF
  7788. END IF
  7789. i = CheckType(Stk$[A+1])
  7790. ZZ$ = LCASE$(Stk$[A+1])
  7791. IF i = vt_STRUCT OR i = vt_UNION OR ZZ$ = "int" OR ZZ$ = "double" OR ZZ$ = "float" THEN
  7792. FPRINT Outfile,Scoot$,Var$ + " = sizeof(";Stk$[A+1];");"
  7793. ELSE
  7794. FPRINT Outfile,Scoot$,Var$ + " = ";Clean$(Stk$[A+1]);";"
  7795. END IF
  7796. Stk$[A] = ""
  7797. Stk$[A + 1] = ""
  7798. END SELECT
  7799. NEXT
  7800. FPRINT Outfile,Scoot$,"if((";Clean$(Handl$);"=fopen(";Filnam$;",";Op$;"))==0)"
  7801. FPRINT Outfile,Scoot$," {"
  7802. lszTmp$ = ENC$("Can't open file %s\\n")
  7803. FPRINT Outfile,Scoot$," fprintf(stderr,";lszTmp$;",";Filnam$;");"
  7804. FPRINT Outfile,Scoot$," exit(1);"
  7805. FPRINT Outfile,Scoot$," }"
  7806. '*************************************************************************
  7807. ' Statement RECORD [#] filenumber,recordnumber [,location in record]
  7808. ' Definition: Position the file pointer anywhere in a file.
  7809. ' filenumber Filenumber from 1 to 99
  7810. ' record number RECORD number to point to. Default first record
  7811. ' location in record Optional location in RECORD. Default is Zero
  7812. ' RECORD fp1, 6[, 10]
  7813. '*************************************************************************
  7814. CASE "record"
  7815. DIM ffp AS functionParse
  7816. DIM RAW numargs = 0
  7817. IF DataType(Stk$[2]) = vt_NUMBER THEN
  7818. Stk$[2]= "FP" + Stk$[2]
  7819. END IF
  7820. IF Ndx > 1 THEN numargs = SepFuncArgs(1, &ffp, FALSE)
  7821. IF numargs < 1 THEN Abort("Missing required arguments to RECORD")
  7822. IF numargs > 4 THEN Abort("Too many arguments to RECORD")
  7823. IF numargs = 3 THEN
  7824. FPRINT Outfile,Scoot$,"fseek("; GetArg$(1, &ffp); _
  7825. ", ("; GetArg$(2, &ffp); " - 1) * ";Stk$[2];"len + ";GetArg$(3, &ffp);", SEEK_SET);"
  7826. ELSEIF numargs = 2 THEN
  7827. FPRINT Outfile,Scoot$,"fseek("; GetArg$(1, &ffp); _
  7828. ", ("; GetArg$(2, &ffp); " - 1) * ";Stk$[2];"len, SEEK_SET);"
  7829. ELSE
  7830. FPRINT Outfile,Scoot$,"fseek("; GetArg$(1, &ffp); ", 0, SEEK_SET);"
  7831. END IF
  7832. '***********************
  7833. CASE "fwrite"
  7834. '***********************
  7835. IF DataType(Stk$[2]) = vt_NUMBER THEN
  7836. Stk$[2] = "FP" + Stk$[Ndx]
  7837. END IF
  7838. IF CheckLocal(Stk$[2], &i) = vt_UNKNOWN THEN
  7839. CALL AddGlobal(Stk$[2], vt_FILEPTR, 0,"",0,0,0,0)
  7840. END IF
  7841. Handl$ = ""
  7842. FOR j = 2 TO Ndx
  7843. IF iMatchWrd(Stk$[j], ",") OR iMatchWrd(Stk$[j], ";") THEN
  7844. Stk$[j] = "" 'get rid of the Comma
  7845. EXIT FOR
  7846. END IF
  7847. Handl$ = Handl$ + Stk$[j]
  7848. Stk$[j] = "" 'get rid of handle
  7849. NEXT j
  7850. Handl$ = Handl$ + "@"
  7851. ZZ$ = "f" + PrintWriteFormat$(1)
  7852. ZZ$ = LEFT$(ZZ$,8) + Clean$(Handl$) + "," + MID$(ZZ$,9)
  7853. FPRINT Outfile,Scoot$, ZZ$
  7854. '***********************
  7855. CASE "close"
  7856. '***********************
  7857. IF Ndx = 1 THEN
  7858. FPRINT Outfile,Scoot$, "fcloseall();"
  7859. EXIT SELECT
  7860. END IF
  7861. IF DataType(Stk$[2]) = vt_NUMBER THEN
  7862. Stk$[2]= "FP" + Stk$[Ndx]
  7863. END IF
  7864. IF CheckLocal(Stk$[2], &i) = vt_UNKNOWN THEN
  7865. IF CheckGlobal(Stk$[2], &i) = vt_UNKNOWN THEN
  7866. CALL AddGlobal(Stk$[2], vt_FILEPTR, 0,"",0,0,0,0)
  7867. END IF
  7868. END IF
  7869. Handl$ = ""
  7870. FOR j = 2 TO Ndx
  7871. Handl$ = Handl$ + Stk$[j]
  7872. NEXT j
  7873. FPRINT Outfile,Scoot$,"if(",Handl$,")"
  7874. FPRINT Outfile,Scoot$," {"
  7875. FPRINT Outfile,Scoot$," fclose(";Handl$;");"
  7876. FPRINT Outfile,Scoot$," ";Handl$;"=NULL;"
  7877. FPRINT Outfile,Scoot$," }"
  7878. '***********************
  7879. CASE "call"
  7880. '***********************
  7881. lszTmp$ = ""
  7882. FOR Tmp = 2 TO Ndx
  7883. CONCAT(lszTmp$, Clean$(Stk$[Tmp]))
  7884. NEXT
  7885. IF NOT iMatchRgt(lszTmp$,")") THEN
  7886. CONCAT(lszTmp$, "()")
  7887. END IF
  7888. CONCAT(lszTmp$, ";")
  7889. FPRINT Outfile,Scoot$,lszTmp$
  7890. '*************************************************************************
  7891. CASE "declare"
  7892. '*************************************************************************
  7893. DIM FP AS functionParse
  7894. DIM RAW TempProto$
  7895. CALL FuncSubDecs1("sub") 'convert [] to pointer * and $[] to [][2048]
  7896. CALL SepFuncArgs(3, &FP, TRUE)
  7897. TempProto$ = MakeDecProto$(&FP)
  7898. IF NOT NoTypeDeclare THEN
  7899. FPRINT FP4, TempProto$, ";"
  7900. ELSE
  7901. ProtoCnt++
  7902. ProtoType[ProtoCnt].Prototype$ = TempProto$ + ";"
  7903. END IF
  7904. '*************************************************************************
  7905. '/***** 2010-11-16 Added Constructor/Destructor - AIR *****/
  7906. CASE "function", "sub", "constructor", "destructor"
  7907. '*************************************************************************
  7908. DIM CTOR_USE$, CTOR_SRC$, New_Ndx
  7909. IF Stk$[2] = "main" THEN
  7910. Stk$[1] = "function"
  7911. Stk$[2] = "main%"
  7912. ForceMainToFunc = TRUE
  7913. END IF
  7914. '/***** 2010-11-17 Added to change constructor/destructor to sub -AIR *****/
  7915. IF iMatchWrd(Stk$[1], "constructor") OR iMatchWrd(Stk$[1], "destructor") THEN
  7916. Stk$[1] = "sub"
  7917. '/***** 2010-11-18 this extracts the derived class method after "USING" keyword *****/
  7918. '/***** and stuffs it into CTOR_USE$ variable - AIR *****/
  7919. FOR INTEGER ct = 1 TO Ndx
  7920. IF Stk$[ct] = "using" THEN
  7921. New_Ndx = ct-1 '/*** SEE NEXT COMMENT!!! -AIR *****/
  7922. FOR INTEGER ut = ct TO Ndx
  7923. CTOR_USE$ = CTOR_USE$ + Stk$[ut]
  7924. NEXT
  7925. END IF
  7926. NEXT
  7927. IF LEN(CTOR_USE$) THEN
  7928. IREPLACE "using" WITH ":" IN CTOR_USE$
  7929. '/***** 2010-11-18 Truncates current line so that everything AFTER "USING" keyword is NOT *****/
  7930. '/***** processed by default FUNCTION/SUB parser! -AIR *****/
  7931. Ndx = New_Ndx
  7932. '/*********************************************************************************************/
  7933. END IF
  7934. Use_Ctor = TRUE
  7935. END IF
  7936. CALL FuncSubDecs1("sub")
  7937. IsStdFunc = FALSE
  7938. IF iMatchWrd(Stk$[Ndx],"stdcall") THEN
  7939. CallType$ = "__attribute__((stdcall)) "
  7940. Ndx--
  7941. IsStdFunc = TRUE
  7942. END IF
  7943. InFunc = TRUE
  7944. InMain = FALSE
  7945. LocalVarCnt = 0
  7946. '~ Outfile = FP3
  7947. '/** 2010/11/30 Added -AIR **/
  7948. IF InNameSpace THEN
  7949. Outfile = FP2
  7950. ELSE
  7951. Outfile = FP3
  7952. END IF
  7953. CALL FuncSubDecs2("sub", mt_FuncSubDecC_Dec)
  7954. ' to compensate previous substitution errors not fixed
  7955. VarCode.Functype$ = LTRIM$(VarCode.Functype$)
  7956. Funcname$ = Clean$(Stk$[2])
  7957. IF IsExported OR IsStdFunc THEN
  7958. Funcname$ = CallType$ + Funcname$
  7959. END IF
  7960. VarCode.Method% = mt_FuncSubDecC_Dec2
  7961. A = 3
  7962. WHILE A <= Ndx
  7963. IF Stk$[A+1] = "(" THEN ' sub/function ptr
  7964. FOR k = A+2 TO Ndx
  7965. IF Stk$[k] = ")" THEN
  7966. EXIT FOR
  7967. END IF
  7968. NEXT
  7969. IF iMatchWrd(Stk$[k+2], "sub") THEN
  7970. j = vt_VOID
  7971. VarCode.AsToken$ = "void"
  7972. ELSEIF iMatchWrd(Stk$[k+2], "function") THEN
  7973. CALL GetTypeInfo(Stk$[k+3], &IsPointer, &i, &j)
  7974. VarCode.AsToken$ = Stk$[k+3]
  7975. END IF
  7976. VarCode.Token$ = Stk$[A]
  7977. VarCode.VarNo% = j
  7978. VarCode.IsPtrFlag = 1
  7979. VarCode.Method% = mt_FuncSubx1
  7980. CALL GetVarCode(&VarCode)
  7981. Var$ = Clean$(Stk$[A])
  7982. lszTmp$ = ""
  7983. A += 2
  7984. WHILE A <= k
  7985. IF iMatchWrd(Stk$[A+1], "as") AND A < k THEN
  7986. Tmp = A + 2
  7987. WHILE Stk$[Tmp] <> "," AND Stk$[Tmp] <> ")"
  7988. CALL GetTypeInfo(Stk$[Tmp], &IsPointer, &i, &j)
  7989. CALL AddLocal(Stk$[A], j, i, "", IsPointer,0,0)
  7990. VarCode.Token$ = Stk$[A]
  7991. VarCode.AsToken$ = Stk$[Tmp]
  7992. VarCode.VarNo% = j
  7993. VarCode.IsPtrFlag = 1
  7994. VarCode.Method% = mt_FuncSubx2
  7995. CALL GetVarCode(&VarCode)
  7996. Tmp++
  7997. IF Stk$[Tmp] = "," THEN
  7998. CONCAT(VarCode.Proto$,",")
  7999. CONCAT(VarCode.Header$,",")
  8000. END IF
  8001. WEND
  8002. A = Tmp
  8003. ELSE
  8004. IF Stk$[A] <> "," AND Stk$[A] <> ")" THEN
  8005. IsPointer = TALLY((Stk$[A]), "*")
  8006. Var$ = REMOVE$(Stk$[A], "*") ' in case we used ptr
  8007. j = DataType(Var$)
  8008. IF j <> vt_UNKNOWN AND InFunc = TRUE AND Var[0] THEN
  8009. CALL AddLocal(Clean(Var$), j, 0, "", IsPointer,0,0)
  8010. END IF
  8011. VarCode.Token$ = Stk$[A]
  8012. VarCode.AsToken$ = ""
  8013. VarCode.VarNo% = j
  8014. VarCode.IsPtrFlag = IsPointer
  8015. VarCode.Method% = mt_FuncSubDecC_Dec2
  8016. CALL GetVarCode(&VarCode)
  8017. END IF
  8018. END IF
  8019. A++
  8020. WEND
  8021. A = k+3
  8022. IF VarCode.Method% = mt_FuncSubDecC_Dec2 THEN
  8023. MID$(VarCode.Proto$,LEN(VarCode.Proto$)-1,1) = ")"
  8024. MID$(VarCode.Header$,LEN(VarCode.Header$)-1,1) = ")"
  8025. ELSE
  8026. CONCAT(VarCode.Proto$,")")
  8027. CONCAT(VarCode.Header$,")")
  8028. END IF
  8029. VarCode.Method% = mt_FuncSubDecC_Dec2
  8030. ELSE
  8031. IF iMatchWrd(Stk$[A+1],"as") THEN
  8032. CALL GetTypeInfo(Stk$[A+2], &IsPointer, &i, &j)
  8033. Var$ = Clean$(Stk$[A])
  8034. CALL AddLocal(Var$, j, i, "", IsPointer,0,0)
  8035. VarCode.Token$ = Stk$[A]
  8036. VarCode.AsToken$ = Stk$[A+2]
  8037. VarCode.VarNo% = j
  8038. VarCode.IsPtrFlag = IsPointer
  8039. CALL GetVarCode(&VarCode)
  8040. Stk$[A+1] = ""
  8041. Stk$[A+2] = ""
  8042. A+=2
  8043. ELSE
  8044. IF INCHR("=", Stk$[A]) AND Stk$[A] <> "" THEN
  8045. CALL Abort("Illegal optional parameter found")
  8046. END IF
  8047. IF NOT INCHR(",().",Stk$[A]) AND Stk$[A] <> "" THEN
  8048. IsPointer = TALLY((Stk$[A]), "*")
  8049. Var$ = REMOVE$(Stk$[A], "*") ' in case we used ptr
  8050. j = DataType(Var$)
  8051. IF j <> vt_UNKNOWN AND Var[0] THEN
  8052. CALL AddLocal(Clean(Var$), j, 0, "", IsPointer,0,0)
  8053. END IF
  8054. VarCode.Token$ = Stk$[A]
  8055. VarCode.AsToken$ = ""
  8056. VarCode.VarNo% = j
  8057. VarCode.IsPtrFlag = IsPointer
  8058. CALL GetVarCode(&VarCode)
  8059. END IF
  8060. END IF
  8061. END IF
  8062. A++
  8063. WEND
  8064. VarCode.Method% = 2
  8065. VarCode.Token$ = Funcname$
  8066. FuncSubDecs3(&VarCode)
  8067. IF iMatchLft(VarCode.Header$,"main(") THEN
  8068. VarCode.Header$ = "int main(int argc, char *argv[])"
  8069. VarCode.Proto$ = "int main(int argc, char *argv[]);"
  8070. CurrentFuncType = vt_INTEGER
  8071. END IF
  8072. IF Use_Static THEN
  8073. VarCode.Header$ = "static " + VarCode.Header$
  8074. VarCode.Proto$ = "static " + VarCode.Proto$
  8075. END IF
  8076. '/** 2010/11/30 DON'T EMIT FUNCTION PROTOTYPE FOR NAMESPACE -AIR **/
  8077. IF NOT InNameSpace THEN
  8078. ProtoCnt++
  8079. ProtoType[ProtoCnt].Prototype$ = VarCode.Proto$
  8080. END IF
  8081. IF InIfDef$ = "FP3" THEN
  8082. IF ProtoCnt > 1 THEN
  8083. ProtoType[ProtoCnt].Condition$ = ProtoType[ProtoCnt-1].Condition$
  8084. ELSE
  8085. ProtoType[ProtoCnt].Condition$ = ""
  8086. END IF
  8087. ELSE
  8088. ProtoType[ProtoCnt].Condition$ = InIfDef$
  8089. END IF
  8090. ProtoType[ProtoCnt].CondLevel = InConditional
  8091. IF *InIfDef$ THEN
  8092. IF InIfDef$ <> "FP3" THEN
  8093. FPRINT Outfile,InIfDef$
  8094. PRINT InIfDef$
  8095. END IF
  8096. END IF
  8097. '/***** 2010-11-17 Check if Constructor/Destructor, if so remove VOID from Method Sig -AIR *****/
  8098. IF Use_Ctor THEN
  8099. REPLACE "void " WITH "" IN VarCode.Header$
  8100. REPLACE "void" WITH "" IN VarCode.Header$
  8101. '/***** 2010-11-18 Emit derived class methods via "USING" keyword if required -AIR *****/
  8102. IF LEN (CTOR_USE$) THEN
  8103. FPRINT Outfile,VarCode.Header$
  8104. FPRINT Outfile,Scoot$,CTOR_USE$
  8105. ELSE
  8106. FPRINT Outfile,VarCode.Header$
  8107. END IF
  8108. Use_Ctor = FALSE
  8109. '/** 2010/11/30 Added Wayne's fix for NAMESPACE -AIR **/
  8110. ELSEIF InNameSpace THEN
  8111. 'FPRINT Outfile,Scoot$;VarCode.Header$
  8112. RAW szCPP_SF1$
  8113. szCPP_SF1$ = ""
  8114. IF iMatchLft(Lookup$,"public") THEN szCPP_SF1$ = "public: virtual "
  8115. FPRINT Outfile,Scoot$;szCPP_SF1$;VarCode.Header$
  8116. ELSE
  8117. FPRINT Outfile,VarCode.Header$
  8118. END IF
  8119. FPRINT Outfile,Scoot$,"{"
  8120. CALL BumpUp
  8121. '***********************************************
  8122. CASE "optfunction", "optsub"
  8123. '***********************************************
  8124. CALL FuncSubDecs1("optsub")
  8125. InFunc = TRUE
  8126. LocalVarCnt = 0
  8127. Outfile = FP3
  8128. '/** Added -AIR **/
  8129. IF InNameSpace THEN
  8130. Outfile = FP2
  8131. ELSE
  8132. Outfile = FP3
  8133. END IF
  8134. CALL FuncSubDecs2("optsub", mt_Opts)
  8135. Funcname$ = Clean$(Stk$[2])
  8136. VarCode.Method% = mt_Opts2
  8137. A = 4
  8138. WHILE A < Ndx
  8139. IF Stk$[A] = "" THEN A++ : ITERATE
  8140. IF Stk$[A] = "," THEN
  8141. VarCode.Method% = mt_Opts3
  8142. VarCode.Token$ = Stk$[A]
  8143. CALL GetVarCode(&VarCode)
  8144. VarCode.Method% = mt_Opts2
  8145. ELSEIF Stk$[A] = "=" THEN
  8146. VarCode.Method% = mt_Opts3
  8147. IF Stk$[A + 1] = "-" THEN
  8148. VarCode.Token$ = Stk$[A] + Stk$[A + 1] + Stk$[A + 2]
  8149. Stk$[A + 1] = "" : Stk$[A + 2] = "" : A++
  8150. ELSE
  8151. VarCode.Token$ = Stk$[A] + Stk$[A + 1]
  8152. Stk$[A + 1] = ""
  8153. END IF
  8154. IF iMatchWrd(Stk$[A+2],"as") THEN
  8155. Stk$[A + 2] = "" : Stk$[A + 3] = ""
  8156. END IF
  8157. VarCode.VarNo% = j
  8158. VarCode.IsPtrFlag = IsPointer
  8159. CALL GetVarCode(&VarCode)
  8160. VarCode.Method% = mt_Opts2
  8161. ELSEIF iMatchWrd(Stk$[A+1],"as") THEN
  8162. CALL GetTypeInfo(Stk$[A+2], &IsPointer, &i, &j)
  8163. IF InFunc THEN
  8164. Var$ = Clean$(Stk$[A])
  8165. CALL AddLocal(Var$, j, i, "", IsPointer,0,0)
  8166. END IF
  8167. VarCode.VarNo% = j
  8168. VarCode.Token$ = Stk$[A]
  8169. VarCode.AsToken$ = Stk$[A+2]
  8170. VarCode.IsPtrFlag = IsPointer
  8171. CALL GetVarCode(&VarCode)
  8172. Stk$[A+1]= "" : Stk$[A+2]= ""
  8173. ELSE
  8174. IsPointer = TALLY((Stk$[A]),"*")
  8175. Var$ = REMOVE$(Stk$[A],"*") ' in case we used ptr
  8176. j = DataType(Var$)
  8177. IF j <> vt_UNKNOWN THEN
  8178. CALL AddLocal(Clean(Var$),j,0,"",IsPointer,0,0)
  8179. END IF
  8180. VarCode.VarNo% = j
  8181. VarCode.Token$ = Stk$[A]
  8182. VarCode.AsToken$ = ""
  8183. VarCode.IsPtrFlag = IsPointer
  8184. CALL GetVarCode(&VarCode)
  8185. END IF
  8186. A++
  8187. WEND
  8188. VarCode.Method% = 2
  8189. VarCode.Token$ = Funcname$
  8190. FuncSubDecs3(&VarCode)
  8191. IF Use_Static THEN
  8192. VarCode.Header$ = "static " + VarCode.Header$
  8193. VarCode.Proto$ = "static " + VarCode.Proto$
  8194. END IF
  8195. ProtoCnt++
  8196. ProtoType[ProtoCnt].Prototype$ = VarCode.Proto$
  8197. IF InIfDef$ = "FP3" THEN
  8198. ProtoType[ProtoCnt].Condition$ = ""
  8199. ELSE
  8200. ProtoType[ProtoCnt].Condition$ = InIfDef$
  8201. END IF
  8202. ProtoType[ProtoCnt].CondLevel = InConditional
  8203. FPRINT Outfile,VarCode.Header$
  8204. FPRINT Outfile,Scoot$,"{"
  8205. CALL BumpUp
  8206. '*******************************************
  8207. CASE "overloadedfunction", "overloadedsub"
  8208. '*******************************************
  8209. Use_Overloaded = TRUE
  8210. CALL FuncSubDecs1("overloadedsub")
  8211. InFunc = TRUE
  8212. InMain = FALSE
  8213. LocalVarCnt = 0
  8214. Outfile = FP8 '<<----- writing TO BCX.OVR
  8215. CALL FuncSubDecs2("overloadedsub", mt_OverLoad)
  8216. Funcname$ = Clean$(Stk$[2])
  8217. lszTmp$ = " overloaded " + Funcname$
  8218. Funcname$ = lszTmp$
  8219. VarCode.Method% = mt_OverLoad2
  8220. FOR A = 3 TO Ndx
  8221. IF iMatchWrd(Stk$[A+1],"as") THEN
  8222. CALL GetTypeInfo(Stk$[A+2], &IsPointer, &i, &j)
  8223. Var$ = Clean$(Stk$[A])
  8224. CALL AddLocal(Var$, j, i, "", IsPointer,0,0)
  8225. VarCode.AsToken$ = Stk$[A+2]
  8226. Stk$[A+1] = ""
  8227. Stk$[A+2] = ""
  8228. ELSE
  8229. Var$ = REMOVE$(Stk$[A],"*") ' in case we used ptr
  8230. j = DataType(Var$)
  8231. IF NOT INCHR(",().",Stk$[A]) AND Stk$[A] <> "" THEN
  8232. IsPointer = TALLY((Stk$[A]),"*")
  8233. IF j <> vt_UNKNOWN AND InFunc = TRUE AND Var[0] THEN
  8234. CALL AddLocal(Clean(Var$), j, 0, "", IsPointer,0,0)
  8235. END IF
  8236. END IF
  8237. VarCode.AsToken$ = ""
  8238. END IF
  8239. VarCode.VarNo% = j
  8240. VarCode.Token$ = Stk$[A]
  8241. CALL GetVarCode(&VarCode)
  8242. NEXT
  8243. VarCode.Method% = 1
  8244. VarCode.Token$ = Funcname$
  8245. FuncSubDecs3(&VarCode)
  8246. IF Use_Static THEN
  8247. VarCode.Header$ = "static " + VarCode.Header$
  8248. END IF
  8249. FPRINT Outfile,VarCode.Header$
  8250. FPRINT Outfile,Scoot$,"{"
  8251. CALL BumpUp
  8252. '*******************************************************************
  8253. CASE "functionreturn"
  8254. '*******************************************************************
  8255. IF CaseFlag THEN NoBreak2 = TRUE
  8256. lszTmp$ = ""
  8257. FOR A = 3 TO Ndx
  8258. lszTmp$ = lszTmp$ + Stk$[A] + " "
  8259. NEXT
  8260. IF CurrentFuncType = vt_STRVAR THEN
  8261. lszTmp$ = "BCX_RetStr$ = " + lszTmp$
  8262. FuncRetnFlag = 1 '1 = return a string
  8263. UseFlag = TRUE
  8264. ELSE
  8265. FuncRetnFlag = 2 '2 = return a number
  8266. END IF
  8267. IF FuncRetnFlag = 2 THEN
  8268. '*********************************
  8269. ' Clean up dynamic strings
  8270. '*********************************
  8271. IF LocalDynaCnt <> 0 THEN
  8272. FOR j = 1 TO LocalDynaCnt
  8273. FPRINT Outfile,Scoot$,DynaStr$[j]
  8274. NEXT
  8275. END IF
  8276. '*********************************
  8277. ' Clean up dynamic strings arrays
  8278. '*********************************
  8279. IF LocalDynArrCount <> 0 THEN
  8280. FOR i = 1 TO LocalDynArrCount
  8281. FPRINT Outfile,Scoot$,LocalDynArrName$[i]
  8282. NEXT
  8283. END IF
  8284. '*********************************
  8285. FPRINT Outfile,Scoot$,"return ";
  8286. LastCmd = 2
  8287. END IF
  8288. CALL Parse(lszTmp$)
  8289. LastCmd = 0
  8290. GOTO EmitAgain
  8291. '*******************************
  8292. '/***** 2010-11-16 Added endconstructor/enddestructor - AIR *****/
  8293. CASE "endfunction", "endsub", "endconstructor", "enddestructor"
  8294. '*******************************
  8295. IF iMatchWrd(Stk$[1],"endfunction") THEN
  8296. LocalDynaCnt = 0
  8297. LocalDynArrCount = 0
  8298. END IF
  8299. '/***** 2010-11-16 Added endconstructor/enddestructor - AIR *****/
  8300. IF iMatchWrd(Stk$[1],"endsub") OR iMatchWrd(Stk$[1],"endconstructor") OR iMatchWrd(Stk$[1],"enddestructor") THEN
  8301. '**************************
  8302. ' Clean up dynamic strings
  8303. '**************************
  8304. IF LocalDynaCnt <> 0 THEN
  8305. FOR j = 1 TO LocalDynaCnt
  8306. FPRINT Outfile,Scoot$,DynaStr$[j]
  8307. NEXT
  8308. LocalDynaCnt = 0
  8309. END IF
  8310. '*********************************
  8311. ' Clean up dynamic strings arrays
  8312. '*********************************
  8313. IF LocalDynArrCount <> 0 THEN
  8314. FOR i = 1 TO LocalDynArrCount
  8315. FPRINT Outfile,Scoot$,LocalDynArrName$[i]
  8316. NEXT
  8317. LocalDynArrCount = 0
  8318. END IF
  8319. END IF
  8320. '*********************************
  8321. IF ForceMainToFunc = TRUE THEN
  8322. FPRINT Outfile,Scoot$,"return 0;"
  8323. ForceMainToFunc = FALSE
  8324. END IF
  8325. CALL BumpDown
  8326. '~ FPRINT Outfile,Scoot$,"}\n\n"
  8327. '~ CALL BumpDown
  8328. //** 2010/11/30 Added FOR NAMESPACE -AIR **/
  8329. IF InNameSpace THEN
  8330. FPRINT FP2,Scoot$,"}\n"
  8331. ELSE
  8332. FPRINT Outfile,Scoot$,"}\n\n"
  8333. CALL BumpDown
  8334. END IF
  8335. InFunc = FALSE
  8336. Use_Static = FALSE
  8337. IF Outfile = FP3 THEN
  8338. InIfDef$ = "FP3"
  8339. END IF
  8340. Outfile = FP2
  8341. ByrefCnt = 0
  8342. '***********************
  8343. CASE "input"
  8344. '***********************
  8345. CALL EmitInputCode
  8346. '***********************
  8347. CASE "finput"
  8348. '***********************
  8349. CALL EmitFileInputCode
  8350. '***********************
  8351. CASE "dynamic"
  8352. '***********************
  8353. DIM RAW w = 0
  8354. DIM RAW SOF$
  8355. CALL HandleNonsense
  8356. CVar$ = Clean$(Stk$[2])
  8357. CALL ValidVar(CVar$)
  8358. IF Stk$[Ndx] = "*" THEN CALL PointerFix
  8359. IF Stk$[Ndx] = "&" THEN Stk$[Ndx--] = "" : CONCAT(Stk$[Ndx], "&")
  8360. ZZ$ = ""
  8361. IF iMatchWrd(Stk$[Ndx-1], "as") THEN
  8362. SOF$ = Stk$[Ndx]
  8363. GetTypeInfo(SOF$, &w, &id, &vt)
  8364. IF vt = vt_STRLIT OR vt = vt_DECFUNC OR vt = vt_NUMBER OR _
  8365. (vt = vt_VOID AND INCHR(Stk$[Ndx], "*") = 0) THEN
  8366. Abort(SOF$ + " is not a valid type")
  8367. END IF
  8368. IF vt = vt_FILEPTR AND INCHR(SOF$, "*") = 0 THEN SOF$ = SOF$ + "*"
  8369. Ndx -= 2
  8370. ELSE
  8371. vt = DataType(Stk$[2])
  8372. id = 0
  8373. SOF$ = GetVarTypeName$(vt)
  8374. END IF
  8375. Use_DynamicA = TRUE
  8376. FOR i = 3 TO Ndx
  8377. CONCAT(ZZ$, Stk$[i])
  8378. NEXT
  8379. dms = TALLY(ZZ$,"][") + 1
  8380. IF dms > 1 THEN REPLACE "][" WITH "," IN ZZ$
  8381. ZZ$ = Clean$(ZZ$)
  8382. RemoveAll(ZZ$,"[]")
  8383. IF vt = vt_STRVAR THEN
  8384. vt = vt_CHAR
  8385. SOF$ = "char"
  8386. IF InTypeDef THEN
  8387. IF Stk$[3] <> "[" THEN
  8388. DECR dms
  8389. ELSE
  8390. vt = vt_CHARPTR
  8391. END IF
  8392. END IF
  8393. dms++
  8394. CONCAT(ZZ$,",65535")
  8395. END IF
  8396. IF InTypeDef THEN
  8397. IF vt = vt_STRUCT THEN
  8398. FPRINT Outfile, Scoot$, "struct _", SOF$, " ", STRING$(dms,42), CVar$, ";"
  8399. ELSE
  8400. FPRINT Outfile, Scoot$, SOF$, " ", STRING$(dms,42), CVar$, ";"
  8401. END IF
  8402. CALL AddTypedefElement(BaseTypeDefsCnt[InTypeDef], vt, CVar$, SOF$, dms)
  8403. ELSEIF InFunc THEN
  8404. LocalDynArrCount++
  8405. LocalDynArrName$ [LocalDynArrCount] = "if (" + CVar$ + ") { DestroyArr((void **)" + CVar$ + "," + STR$(dms) + ", 1); " + CVar$ + "=NULL; }"
  8406. FPRINT Outfile,Scoot$,SOF$;" ";STRING$(dms,42);CVar$;"=0;"
  8407. CALL AddLocal(CVar$, vt, id,"",dms,0,0)
  8408. ELSE
  8409. IF Use_GenFree THEN
  8410. GlobalDynaCnt++
  8411. GlobalDynaStr$[GlobalDynaCnt] = "if (" + CVar$ + ") { DestroyArr((void **)" + CVar$ + "," + STR$(dms) + ", 1); " + CVar$ + "=NULL; }"
  8412. END IF
  8413. CALL AddGlobal(CVar$, vt, id,"",dms,0,0,0)
  8414. END IF
  8415. IF NOT InTypeDef THEN
  8416. FPRINT Outfile,Scoot$,CVar$ ; "= ("; SOF$ ;STRING$(dms,42);")CreateArr ("; CVar$ ; ",sizeof(";SOF$;"),0,";TRIM$(STR$(dms));"," ; ZZ$ ; ");"
  8417. END IF
  8418. '***********************
  8419. CASE "redim"
  8420. '***********************
  8421. 'REDIM b$ * 14
  8422. 'REDIM PRESERVE b$ * 20
  8423. 'REDIM a$[10]
  8424. 'REDIM PRESERVE a$[20]
  8425. '***********************
  8426. DIM RAW IsPreserve
  8427. DIM RAW SOF$
  8428. DIM RAW VI AS VarInfo PTR
  8429. DIM RAW vt1 = 0
  8430. DIM RAW IsSplat = 0
  8431. DIM RAW BC = 0
  8432. DIM RAW StartPoint
  8433. DIM RAW AsPos = Ndx
  8434. CALL HandleNonsense
  8435. IsPreserve = iMatchWrd(Stk$[2], "preserve")
  8436. StartPoint = 2 + IsPreserve
  8437. vt1 = DataType(Stk$[StartPoint])
  8438. CVar$ = Clean$(Stk$[StartPoint])
  8439. IsSplat = iMatchWrd(Stk$[StartPoint + 1], "*")
  8440. CALL ValidVar(CVar$)
  8441. FOR i = Ndx TO 1 STEP -1
  8442. IF iMatchWrd(Stk$[AsPos], "as") THEN
  8443. AsPos = i - 1
  8444. EXIT FOR
  8445. END IF
  8446. NEXT
  8447. DIM RAW L = AsPos, SP = 0
  8448. WHILE L > StartPoint
  8449. IF Stk$[L] = "[" THEN
  8450. DECR BC
  8451. ELSEIF Stk$[L] = "]" THEN
  8452. INCR BC
  8453. IF BC = 1 THEN DECR L : ITERATE
  8454. END IF
  8455. IF BC = 0 THEN
  8456. INCR SP
  8457. IF Stk$[L-1] <> "]" THEN EXIT WHILE
  8458. ZZ$ = "," + ZZ$
  8459. ELSE
  8460. ZZ$ = Stk$[L] + ZZ$
  8461. END IF
  8462. DECR L
  8463. WEND
  8464. 'get info
  8465. vt = CheckLocal(CVar$, &id)
  8466. IF vt = vt_UNKNOWN THEN
  8467. vt = CheckGlobal(CVar$, &id)
  8468. IF vt = vt_UNKNOWN THEN
  8469. Abort("Can not REDIM " + CVar$ + " not previously dimensioned")
  8470. END IF
  8471. VI = &GlobalVars[id]
  8472. ELSE
  8473. VI = &LocalVars[id]
  8474. END IF
  8475. dms = VI->VarPntr
  8476. IF vt = vt_STRUCT OR vt = vt_UDT OR vt = vt_UNION THEN 'added vt_UNION 4.40
  8477. SOF$ = GetElement$( StartPoint, &vt, &dms, VI->VarDef)
  8478. i = Ndx
  8479. Ndx = L-1
  8480. CALL AsmUnknownStructs(1)
  8481. Ndx = i
  8482. CALL RemEmptyTokens
  8483. CVar$ = Clean$(Stk$[StartPoint])
  8484. IsSplat = iMatchWrd(Stk$[StartPoint + 1], "*")
  8485. ELSE
  8486. SOF$ = GetVarTypeName$(vt)
  8487. END IF
  8488. IF iMatchWrd(Stk$[Ndx-1], "as") THEN
  8489. IF SOF$ <> Stk$[Ndx] AND NOT iMatchWrd(Stk$[Ndx], "string") THEN
  8490. Abort("Can not change types for variable " + CVar$ + " previously defined as " + SOF$ + " on line" + STR$(VI->VarLine))
  8491. END IF
  8492. IF iMatchWrd(Stk$[Ndx], "string") THEN
  8493. Ndx--
  8494. Stk$[Ndx] = "["
  8495. Stk$[++Ndx] = "65535"
  8496. Stk$[++Ndx] = "]"
  8497. ELSE
  8498. Ndx -= 2
  8499. END IF
  8500. ELSE
  8501. IF (vt = vt_CHAR AND vt1 = vt_STRVAR AND IsSplat = 0) OR vt = vt_CHARPTR THEN
  8502. Ndx++
  8503. Stk$[Ndx] = "["
  8504. Stk$[++Ndx] = "65535"
  8505. Stk$[++Ndx] = "]"
  8506. END IF
  8507. END IF
  8508. IF Stk$[3 + IsPreserve] = "[" THEN
  8509. IF IsPreserve THEN
  8510. StartPoint = 4
  8511. ELSE
  8512. FPRINT Outfile,Scoot$, "if (" + CVar$ + ") { DestroyArr((void **)" + CVar$ + "," + STR$(dms) + ", 1); " + CVar$ + "=NULL; }"
  8513. StartPoint = 3
  8514. END IF
  8515. Use_DynamicA =TRUE
  8516. A = 0
  8517. ZZ$ = ""
  8518. FOR i = StartPoint TO Ndx
  8519. IF Stk$[i] = "[" THEN
  8520. A++
  8521. i++
  8522. BC = 1
  8523. WHILE BC > 0
  8524. IF Stk$[i] = "[" THEN
  8525. BC++
  8526. CONCAT(ZZ$, Stk$[i])
  8527. ELSE
  8528. IF Stk$[i] = "]" THEN
  8529. BC--
  8530. IF BC = 0 AND i < Ndx THEN
  8531. CONCAT(ZZ$, ",")
  8532. END IF
  8533. IF BC THEN
  8534. CONCAT(ZZ$, Stk$[i])
  8535. END IF
  8536. ELSE
  8537. CONCAT(ZZ$, Stk$[i])
  8538. END IF
  8539. END IF
  8540. i++
  8541. WEND
  8542. i--
  8543. END IF
  8544. NEXT
  8545. ZZ$ = Clean$(ZZ$)
  8546. IF vt = vt_STRLIT OR vt = vt_DECFUNC OR vt = vt_NUMBER OR _
  8547. (vt = vt_VOID AND INCHR(Stk$[Ndx],"*") = 0) THEN
  8548. Abort(Stk$[Ndx] + " is not a valid type")
  8549. END IF
  8550. IF vt = vt_STRVAR THEN
  8551. SOF$ = "char"
  8552. A++
  8553. CONCAT(ZZ$,",65535")
  8554. END IF
  8555. IF A <> dms THEN
  8556. Abort("Mismatch in dimensions for " + CVar$ + ", orignally " + STR$(dms) + " found " + STR$(A))
  8557. END IF
  8558. FPRINT Outfile,Scoot$,CVar$ ; "= ("; SOF$ ;STRING$(dms,42);")CreateArr ("; CVar$ ; ",sizeof(";SOF$;"),";TRIM$(STR$(IsPreserve));",";dms;"," ; ZZ$ ; ");"
  8559. EXIT SELECT
  8560. END IF
  8561. IF Stk$[3]= "*" OR (IsPreserve AND Stk$[4]= "*") THEN ' DIM MySTRING$ * NumBytes
  8562. IF IsPreserve THEN
  8563. FPRINT Outfile,Scoot$ ; CVar$ ; "=(char*)realloc(";CVar$;",256+";
  8564. i = 5
  8565. ELSE
  8566. FPRINT Outfile,Scoot$ ; "free(" ; CVar$ ; ");"
  8567. FPRINT Outfile,Scoot$ ; CVar$ ; "=(char*)calloc(256+";
  8568. i = 4
  8569. END IF
  8570. FOR A = i TO Ndx
  8571. FPRINT Outfile,Clean$(Stk$[A]);
  8572. NEXT
  8573. IF IsPreserve THEN
  8574. FPRINT Outfile,");"
  8575. ELSE
  8576. FPRINT Outfile,",1);"
  8577. END IF
  8578. EXIT SELECT
  8579. END IF
  8580. Abort("Invalid REDIM statement")
  8581. '*********************************************************
  8582. CASE "dim", "local", "raw", "static", "auto", "register"
  8583. '********************************************************
  8584. ' DIM A$ * blah blah blah
  8585. ' DIM a%[1000] (integer)
  8586. ' DIM a![1000] (single)
  8587. ' DIM a#[1000] (double)
  8588. ' DIM a¦[1000] (long double)
  8589. ' DIM A$[1000] (string)
  8590. ' DIM r AS DATA_TYPE
  8591. ' DIM r[1][2]...[n] AS DATA_TYPE
  8592. ' DIM DYNAMIC A$[1000]
  8593. ' DIM a AS CONST CHAR PTR
  8594. '********************************************************
  8595. DIM RAW w = 0
  8596. DIM RAW UseStatic$
  8597. DIM RAW IsVolatile = 0
  8598. DIM RAW IV$
  8599. IsVolatile = iMatchWrd(Stk$[2],"volatile")
  8600. IF IsVolatile THEN
  8601. IV$ = "volatile "
  8602. ELSE
  8603. IV$ = ""
  8604. END IF
  8605. IsSubOrFuncPtr = SubFuncTest()
  8606. CALL HandleNonsense
  8607. IF Stk$[Ndx] = "*" THEN CALL PointerFix
  8608. IF Stk$[Ndx] = "&" THEN Stk$[Ndx--] = "" : CONCAT(Stk$[Ndx], "&")
  8609. IsRegister = IsAuto = IsDim = IsLocal = IsStatic = IsRaw = FALSE
  8610. Cmd$ = LCASE$(Stk$[1])
  8611. SELECT CASE Cmd$
  8612. CASE "dim" : IsDim = TRUE
  8613. CASE "local" : IsLocal = TRUE
  8614. CASE "static" : IsStatic = TRUE
  8615. CASE "raw" : IsRaw = TRUE
  8616. CASE "auto" : IsAuto = TRUE
  8617. CASE "register" : IsRegister = TRUE
  8618. END SELECT
  8619. '/***** 2010-11-15 Added support for public/protected/constructor/destructor in Classes -AIR
  8620. IF InTypeDef THEN
  8621. IF iMatchWrd(Stk$[2], "public") OR iMatchWrd(Stk$[2], "private") OR iMatchWrd(Stk$[2], "protected") THEN
  8622. FPRINT Outfile, LF$;LCASE$(Stk$[2]);":"
  8623. EXIT SELECT
  8624. ELSEIF iMatchWrd(Stk$[2], "constructor") OR iMatchWrd(Stk$[2], "destructor") THEN
  8625. 'ADD SUPPORT HERE FOR PARSING METHOD PARAMETERS
  8626. CALL DimSubFunc(0)
  8627. EXIT SELECT
  8628. '/***** 2010-12-01 -AIR *****/
  8629. ELSEIF iMatchWrd(Stk$[2], "virtual") THEN
  8630. vproc$ = ""
  8631. IF iMatchWrd(Stk$[Ndx-1],"=") and iMatchWrd(Stk$[Ndx], "0") THEN
  8632. ' Store the "=0"
  8633. vproc$ = Stk$[Ndx-1] + Stk$[Ndx]
  8634. '~ change Ndx to strip off "=0"
  8635. Ndx = Ndx-2
  8636. END IF
  8637. '~ STRIP OUT "VIRTUAL" AND LEFT SHIFT ENTIRE SOURCE
  8638. FOR integer act = 3 TO Ndx
  8639. Stk$[act-1] = Stk$[act]
  8640. NEXT
  8641. Ndx--
  8642. CALL DimSubFunc(0)
  8643. EXIT SELECT
  8644. END IF
  8645. END IF
  8646. '*************************************************************************
  8647. IF IsSubOrFuncPtr THEN
  8648. IF IsVolatile THEN Abort("volatile SUB/FUNCTION pointers not supported")
  8649. IF DimSubFunc(0) THEN EXIT SELECT
  8650. END IF
  8651. '*************************************************************************
  8652. CVar$ = Clean$(Stk$[2+IsVolatile])
  8653. CALL ValidVar(CVar$)
  8654. VType = DataType(Stk$[2+IsVolatile])
  8655. '***********************************************************************
  8656. IF Stk$[3+IsVolatile] = "*" THEN ' DIM MySTRING$ * NumBytes
  8657. IF IsVolatile THEN Abort("volatile dynamic strings not supported")
  8658. CALL DimDynaString(CVar$, 0, 0)
  8659. EXIT SELECT
  8660. END IF
  8661. RAW iASoffset = 0
  8662. RAW sConst$
  8663. RAW iIsConst
  8664. IF iMatchWrd(Stk$[Ndx-1],"as") THEN iASoffset = Ndx-1
  8665. IF iMatchWrd(Stk$[Ndx-2],"as") THEN iASoffset = Ndx-2
  8666. IF iASoffset THEN
  8667. iIsConst = 0
  8668. sConst$ = ""
  8669. IF iASoffset = Ndx-2 THEN
  8670. IF iMatchWrd(Stk$[Ndx-1],"const") THEN
  8671. sConst$ = "const"
  8672. iIsConst = 1
  8673. END IF
  8674. END IF
  8675. Var1$ = CVar$
  8676. IsPointer = TALLY(Stk$[Ndx],"*")
  8677. DimType$ = ""
  8678. lszTmp$ = ""
  8679. FOR i = 2+IsVolatile TO iASoffset-1
  8680. CONCAT(lszTmp$, Stk$[i])
  8681. IF i > 2+IsVolatile THEN CONCAT(DimType$, Stk$[i])
  8682. NEXT
  8683. Var$ = REMOVE$(Stk$[Ndx],"*")
  8684. GetTypeInfo(Var$, &w, &id, &vt)
  8685. IF vt = vt_STRVAR THEN
  8686. Stk$[Ndx] = "char"
  8687. Var$ = Stk$[Ndx]
  8688. CONCAT(DimType$, "[65535]")
  8689. CONCAT(lszTmp$, "[65535]")
  8690. END IF
  8691. IF InFunc OR InTypeDef THEN
  8692. IF IsRegister OR IsAuto THEN
  8693. IF IsRegister THEN
  8694. IF IsVolatile THEN Abort("Register volatile not supported")
  8695. IF vt = vt_FILEPTR THEN
  8696. FPRINT Outfile,Scoot$,"register FILE* ";
  8697. ELSE
  8698. FPRINT Outfile,Scoot$,"register ";sConst$;" ";Stk$[Ndx];" ";
  8699. END IF
  8700. ELSE
  8701. IF vt = vt_FILEPTR THEN
  8702. FPRINT Outfile,Scoot$,"auto ";IV$;" FILE* ";
  8703. ELSE
  8704. FPRINT Outfile,Scoot$,"auto ";IV$;" ";sConst$;" ";Stk$[Ndx];" ";
  8705. END IF
  8706. END IF
  8707. ELSE
  8708. IF IsRaw = TRUE THEN
  8709. IF vt = vt_FILEPTR THEN
  8710. FPRINT Outfile,Scoot$,"static ";IV$;" FILE* ";
  8711. ELSE
  8712. FPRINT Outfile,Scoot$,IV$;sConst$;" ";Stk$[Ndx];" ";
  8713. END IF
  8714. ELSE
  8715. IF InTypeDef THEN
  8716. UseStatic$ = ""
  8717. ELSE
  8718. UseStatic$ = "static "
  8719. END IF
  8720. IF vt = vt_STRUCT THEN
  8721. FPRINT Outfile,Scoot$,UseStatic$;IV$;sConst$;" ";"struct _" ; Stk$[Ndx]; " ";
  8722. ELSE
  8723. IF vt = vt_FILEPTR THEN
  8724. FPRINT Outfile,Scoot$,UseStatic$;IV$;"FILE *";
  8725. ELSE
  8726. FPRINT Outfile,Scoot$,UseStatic$;IV$;sConst$;" ";Stk$[Ndx] ; " ";
  8727. END IF
  8728. END IF
  8729. IF InTypeDef THEN
  8730. CALL AddTypedefElement(BaseTypeDefsCnt[InTypeDef], vt, CVar$, Var$, 0)
  8731. END IF
  8732. END IF
  8733. END IF
  8734. IF InFunc AND NOT InTypeDef THEN
  8735. CALL AddLocal(Var1$, vt, id, DimType$, IsPointer,0,0,iIsConst)
  8736. END IF
  8737. FPRINT Outfile,Clean$(lszTmp$); ";"
  8738. IF NOT InTypeDef AND NOT IsStatic AND NOT IsRaw AND NOT IsRegister AND NOT IsVolatile THEN
  8739. T$ = Clean$(EXTRACT$(lszTmp$,"["))
  8740. IF IsPointer THEN
  8741. FPRINT Outfile,Scoot$,"memset(&";T$;",0,sizeof(";Clean$(Var$) + " *";"));"
  8742. ELSE
  8743. FPRINT Outfile,Scoot$,"memset(&";T$;",0,sizeof(";T$;"));"
  8744. END IF
  8745. END IF
  8746. ELSE
  8747. IF IsVolatile THEN
  8748. CALL AddGlobal(Var1$, vt, id, DimType$,IsPointer,0,3,0,iIsConst)
  8749. ELSE
  8750. CALL AddGlobal(Var1$, vt, id, DimType$,IsPointer,0,0,0,iIsConst)
  8751. END IF
  8752. END IF
  8753. EXIT SELECT
  8754. END IF
  8755. '*************************************************************************
  8756. IF InFunc OR InTypeDef THEN
  8757. lszTmp$ = ""
  8758. IF iMatchWrd(Stk$[3+IsVolatile],"as") THEN
  8759. VType = CheckType(Stk$[4+IsVolatile])
  8760. IF VType = vt_CHAR THEN
  8761. IF Stk$[5] = "*" THEN
  8762. lszTmp$ = "[" + Stk$[6+IsVolatile] + "]"
  8763. END IF
  8764. END IF
  8765. ELSE
  8766. FOR i = 3+IsVolatile TO Ndx
  8767. CONCAT (lszTmp$, Stk$[i])
  8768. NEXT
  8769. lszTmp$ = LTRIM$(Clean$(lszTmp$))
  8770. IF VType = vt_STRVAR THEN 'AND ((Stk$[3+IsVolatile] = "" AND InTypeDef) OR (NOT InTypeDef)) THEN
  8771. 'print lszTmp$
  8772. IF lszTmp$ <> "[65535]" THEN CONCAT (lszTmp$, "[2048]")
  8773. 'print lszTmp$
  8774. END IF
  8775. END IF
  8776. j = (NOT InTypeDef AND NOT IsStatic AND NOT IsRaw AND NOT IsRegister)
  8777. IF j THEN
  8778. T$ = Clean$(EXTRACT$(CVar$,"["))
  8779. END IF
  8780. SELECT CASE VType
  8781. CASE vt_STRVAR
  8782. IF IsRaw THEN
  8783. FPRINT Outfile,Scoot$;IV$;"char ";CVar$;lszTmp$;";"
  8784. ELSEIF IsAuto THEN
  8785. FPRINT Outfile,Scoot$;"auto ";IV$;"char ";CVar$;lszTmp$;";"
  8786. ELSEIF IsRegister THEN
  8787. IF IsVolatile THEN Abort("register volatile not supported")
  8788. FPRINT Outfile,Scoot$;"register char ";CVar$;lszTmp$;";"
  8789. ELSE
  8790. IF InTypeDef THEN
  8791. FPRINT Outfile,Scoot$;IV$;"char ";CVar$;lszTmp$;";"
  8792. ELSE
  8793. FPRINT Outfile,Scoot$;"static ";IV$;"char ";CVar$;lszTmp$;";"
  8794. END IF
  8795. END IF
  8796. IF j AND NOT IsVolatile THEN
  8797. FPRINT Outfile,Scoot$;"memset(&";T$;",0,sizeof(";T$;"));"
  8798. END IF
  8799. CASE vt_VarMin TO vt_VarMax
  8800. ZZ$ = GetVarTypeName$(VType)
  8801. ZZ$ = RPAD$(ZZ$, 7)
  8802. IF IsRaw THEN
  8803. FPRINT Outfile,Scoot$;IV$;ZZ$;" ";CVar$;lszTmp$;";"
  8804. ELSEIF IsAuto THEN
  8805. FPRINT Outfile,Scoot$;"auto ";IV$;ZZ$;" ";CVar$;lszTmp$;";"
  8806. ELSEIF IsRegister THEN
  8807. IF IsVolatile THEN Abort("Regester volatile not supported")
  8808. FPRINT Outfile,Scoot$;"register ";ZZ$;" ";CVar$;lszTmp$;";"
  8809. ELSE
  8810. IF InTypeDef THEN
  8811. FPRINT Outfile,Scoot$;IV$;ZZ$;" ";CVar$;lszTmp$;";"
  8812. ELSE
  8813. FPRINT Outfile,Scoot$;"static ";IV$;ZZ$;" ";CVar$;lszTmp$;";"
  8814. END IF
  8815. END IF
  8816. IF j AND NOT IsVolatile THEN
  8817. FPRINT Outfile,Scoot$;"memset(&";T$;",0,sizeof(";T$;"));"
  8818. END IF
  8819. END SELECT
  8820. IF InFunc AND NOT InTypeDef THEN
  8821. CALL AddLocal(CVar$, VType, 0, lszTmp$,0,0,0)
  8822. END IF
  8823. IF InTypeDef THEN
  8824. CALL AddTypedefElement(BaseTypeDefsCnt[InTypeDef], VType, CVar$, Var$, 0)
  8825. END IF
  8826. EXIT SELECT
  8827. END IF
  8828. '************************************************************************
  8829. lszTmp$ = "" ' if we get here, we're creating with a GLOBAL variable
  8830. '************************************************************************
  8831. FOR i = 3+IsVolatile TO Ndx
  8832. CONCAT (lszTmp$, Stk$[i])
  8833. NEXT
  8834. IF VType = vt_STRVAR AND lszTmp$ <> "" THEN
  8835. CONCAT (lszTmp$, "[65535]")
  8836. END IF
  8837. IF IsVolatile THEN
  8838. CALL AddGlobal(CVar$, VType, 0,lszTmp$,0,0,3,0)
  8839. ELSE
  8840. CALL AddGlobal(CVar$, VType, 0,lszTmp$,0,0,0,0)
  8841. END IF
  8842. '***********************
  8843. CASE "extern"
  8844. '***********************
  8845. DIM RAW IsVolatile
  8846. IsSubOrFuncPtr = SubFuncTest()
  8847. CALL HandleNonsense
  8848. IsVolatile = iMatchWrd(Stk$[2],"volatile")
  8849. CVar$ = Clean$(Stk$[2+IsVolatile])
  8850. CALL ValidVar(CVar$)
  8851. IF Stk$[Ndx] = "*" THEN CALL PointerFix
  8852. IF Stk$[Ndx] = "&" THEN Stk$[Ndx--] = "" : CONCAT(Stk$[Ndx], "&")
  8853. IF Stk$[3+IsVolatile] = "*" THEN
  8854. IF IsVolatile THEN Abort("volatile dynamic strings not supported")
  8855. CALL DimDynaString(CVar$, 2, 0)
  8856. EXIT SELECT
  8857. END IF
  8858. IF IsSubOrFuncPtr THEN
  8859. IF IsVolatile THEN Abort("volatile SUB/FUNCTION pointers not supported")
  8860. IF DimSubFunc(0) THEN EXIT SELECT
  8861. END IF
  8862. Var$ = Clean$(Stk$[2+IsVolatile])
  8863. CALL ValidVar(Var$)
  8864. IsPointer = 0
  8865. DimType$ = ""
  8866. IF iMatchWrd(Stk$[Ndx-1],"as") THEN
  8867. GetTypeInfo(Stk$[Ndx], &IsPointer, &id, &vt)
  8868. Stk$[Ndx] = REMOVE$(Stk$[Ndx],"*")
  8869. FOR i = 3+IsVolatile TO Ndx-2
  8870. CONCAT (DimType$, Stk$[i])
  8871. NEXT
  8872. ELSE
  8873. i = 3+IsVolatile
  8874. WHILE i <= Ndx
  8875. CONCAT(DimType$,Stk$[i])
  8876. i++
  8877. WEND
  8878. vt = DataType(Stk$[2+IsVolatile])
  8879. id = 0
  8880. END IF
  8881. IF vt = vt_STRVAR THEN ' AND DimType$ <> "" THEN
  8882. CONCAT (DimType$, "[65535]")
  8883. END IF
  8884. IF IsVolatile THEN
  8885. CALL AddGlobal(Var$, vt, id, DimType$, IsPointer,0,4,0)
  8886. ELSE
  8887. CALL AddGlobal(Var$, vt, id, DimType$, IsPointer,0,1,0)
  8888. END IF
  8889. '*************************
  8890. CASE "shared", "global"
  8891. '*************************
  8892. DIM RAW w = 0
  8893. DIM RAW SOF$
  8894. DIM RAW IsShared
  8895. DIM RAW IsVolatile
  8896. IsSubOrFuncPtr = SubFuncTest()
  8897. CALL HandleNonsense
  8898. IsVolatile = iMatchWrd(Stk$[2],"volatile")
  8899. CVar$ = Clean$(Stk$[2+IsVolatile])
  8900. CALL ValidVar(CVar$)
  8901. IsShared = iMatchWrd(Stk$[1],"shared")
  8902. IF Stk$[Ndx] = "*" THEN CALL PointerFix
  8903. IF Stk$[Ndx] = "&" THEN Stk$[Ndx--] = "" : CONCAT(Stk$[Ndx], "&")
  8904. IF Stk$[3+IsVolatile] = "*" THEN
  8905. IF IsVolatile THEN Abort("volatile dynamic strings not supported")
  8906. CALL DimDynaString(CVar$, 1, IsShared)
  8907. EXIT SELECT
  8908. END IF
  8909. IF IsSubOrFuncPtr THEN
  8910. IF IsVolatile THEN Abort("volatile SUB/FUNCTION pointers not supported")
  8911. CALL DimSubFunc(0)
  8912. EXIT SELECT
  8913. END IF
  8914. IF iMatchWrd(Stk$[2],"dynamic") THEN
  8915. CVar$ = Clean$(Stk$[3])
  8916. CALL ValidVar(CVar$)
  8917. IF iMatchWrd(Stk$[Ndx-1],"as") THEN
  8918. SOF$ = Stk$[Ndx]
  8919. GetTypeInfo(SOF$, &w, &id, &vt)
  8920. IF vt = vt_STRLIT OR _
  8921. vt = vt_DECFUNC OR _
  8922. vt = vt_NUMBER OR _
  8923. (vt = vt_VOID AND INCHR(Stk$[Ndx],"*") = 0) THEN
  8924. Abort(Stk$[Ndx] + " is not a valid type")
  8925. END IF
  8926. Ndx -= 2
  8927. ELSE
  8928. vt = DataType(Stk$[3])
  8929. id = 0
  8930. SOF$ = GetVarTypeName$(vt)
  8931. END IF
  8932. Use_DynamicA = TRUE
  8933. ZZ$ = ""
  8934. FOR i = 4 TO Ndx
  8935. CONCAT(ZZ$, Stk$[i])
  8936. NEXT
  8937. dms = TALLY(ZZ$,"][") + 1
  8938. IF dms > 1 THEN REPLACE "][" WITH "," IN ZZ$
  8939. ZZ$ = Clean$(ZZ$)
  8940. RemoveAll(ZZ$,"[]")
  8941. IF vt = vt_STRVAR THEN
  8942. vt = vt_CHAR
  8943. SOF$ = "char"
  8944. dms++
  8945. CONCAT(ZZ$,",65535")
  8946. END IF
  8947. IF Use_GenFree THEN
  8948. GlobalDynaCnt++
  8949. GlobalDynaStr$[GlobalDynaCnt] = "if (" + CVar$ + ") { DestroyArr((void **)" + CVar$ + "," + STR$(dms) + ", 1); " + CVar$ + "=NULL; }"
  8950. END IF
  8951. CALL AddGlobal(CVar$, vt, id,"",dms,0,0,0)
  8952. FPRINT Outfile,Scoot$,CVar$ ; "= ("; SOF$ ;STRING$(dms,42);")CreateArr ("; CVar$ ; ",sizeof(";SOF$;"),0,";TRIM$(STR$(dms));"," ; ZZ$ ; ");"
  8953. EXIT SELECT
  8954. END IF
  8955. IsPointer = 0
  8956. Var$ = Clean$(Stk$[2+IsVolatile])
  8957. CALL ValidVar(Var$)
  8958. IF iMatchWrd(Stk$[Ndx-1],"as") THEN
  8959. IF INCHR(Stk$[Ndx],"*") THEN
  8960. IsPointer = TALLY(Stk$[Ndx],"*")
  8961. Stk$[Ndx] = REMOVE$(Stk$[Ndx],"*")
  8962. END IF
  8963. DimType$ = ""
  8964. FOR i = 3+IsVolatile TO Ndx-2
  8965. CONCAT (DimType$, Stk$[i])
  8966. NEXT
  8967. GetTypeInfo(Stk$[Ndx], &w, &id, &vt)
  8968. ELSE
  8969. DimType$ = ""
  8970. i = 3+IsVolatile
  8971. WHILE i <= Ndx
  8972. CONCAT(DimType$,Stk$[i])
  8973. i++
  8974. WEND
  8975. vt = DataType(Stk$[2+IsVolatile])
  8976. id = 0
  8977. END IF
  8978. IF vt = vt_STRVAR THEN
  8979. CONCAT (DimType$, "[65535]")
  8980. END IF
  8981. IF IsShared THEN
  8982. IF IsVolatile THEN
  8983. CALL AddGlobal(Var$, vt, id, DimType$, IsPointer,0,5,0)
  8984. ELSE
  8985. CALL AddGlobal(Var$, vt, id, DimType$, IsPointer,0,2,0)
  8986. END IF
  8987. ELSE
  8988. IF IsVolatile THEN
  8989. CALL AddGlobal(Var$, vt, id, DimType$, IsPointer,0,3,0)
  8990. ELSE
  8991. CALL AddGlobal(Var$, vt, id, DimType$, IsPointer,0,0,0)
  8992. END IF
  8993. END IF
  8994. '*********************************************************************
  8995. CASE "while"
  8996. CALL EmitIfCond("while")
  8997. '***********************
  8998. CASE "wend", "endwhile"
  8999. '***********************
  9000. CALL BumpDown
  9001. FPRINT Outfile,Scoot$,"}"
  9002. CALL BumpDown
  9003. '***********************
  9004. CASE "exit"
  9005. '***********************
  9006. IF CaseFlag THEN NoBreak2 = TRUE
  9007. IF iMatchWrd(Stk$[2],"sub") THEN
  9008. '*************************
  9009. ' Clean up dynamic strings
  9010. '*************************
  9011. IF LocalDynaCnt <> 0 THEN
  9012. FOR j = 1 TO LocalDynaCnt
  9013. FPRINT Outfile,Scoot$,DynaStr$[j]
  9014. NEXT
  9015. END IF
  9016. '*********************************
  9017. ' Clean up dynamic strings arrays
  9018. '*********************************
  9019. IF LocalDynArrCount <> 0 THEN
  9020. FOR i = 1 TO LocalDynArrCount
  9021. FPRINT Outfile,Scoot$, LocalDynArrName$[i]
  9022. NEXT
  9023. END IF
  9024. '*********************************
  9025. FPRINT Outfile,Scoot$,"return;"
  9026. EXIT SELECT
  9027. END IF
  9028. IF iMatchWrd(Stk$[2],"function") THEN
  9029. '*************************
  9030. ' Clean up dynamic strings
  9031. '*************************
  9032. IF LocalDynaCnt <> 0 THEN
  9033. FOR j = 1 TO LocalDynaCnt
  9034. FPRINT Outfile,Scoot$,DynaStr$[j]
  9035. NEXT
  9036. END IF
  9037. '*********************************
  9038. ' Clean up dynamic strings arrays
  9039. '*********************************
  9040. IF LocalDynArrCount <> 0 THEN
  9041. FOR i = 1 TO LocalDynArrCount
  9042. FPRINT Outfile,Scoot$, LocalDynArrName$[i]
  9043. NEXT
  9044. END IF
  9045. '*********************************
  9046. FPRINT Outfile,Scoot$,"return 0;"
  9047. ELSE
  9048. FPRINT Outfile,Scoot$,"break;"
  9049. END IF
  9050. '***********************
  9051. CASE "goto"
  9052. '***********************
  9053. IF CaseFlag THEN NoBreak2 = TRUE
  9054. FPRINT Outfile,Scoot$,"goto ";UCASE$(Stk$[2]);";"
  9055. '***********************
  9056. CASE "print"
  9057. '***********************
  9058. FPRINT Outfile,Scoot$, PrintWriteFormat$(0)
  9059. '***********************
  9060. CASE "write"
  9061. '***********************
  9062. FPRINT Outfile,Scoot$,PrintWriteFormat$(1)
  9063. '***********************
  9064. CASE "run"
  9065. '***********************
  9066. FPRINT Outfile,Scoot$,"Run (";
  9067. FOR A = 2 TO Ndx
  9068. FPRINT Outfile,Clean$(Stk$[A]);
  9069. NEXT
  9070. FPRINT Outfile,Scoot$,");"
  9071. '***********************
  9072. CASE "color"
  9073. '***********************
  9074. FPRINT Outfile,Scoot$,"color (";
  9075. FOR A = 2 TO Ndx
  9076. FPRINT Outfile,Clean$(Stk$[A]);
  9077. NEXT
  9078. FPRINT Outfile,");"
  9079. '***********************
  9080. CASE "locate"
  9081. '***********************
  9082. FPRINT Outfile,Scoot$,"locate (";
  9083. FOR A = 2 TO Ndx
  9084. FPRINT Outfile,Clean$(Stk$[A]);
  9085. NEXT
  9086. FPRINT Outfile,");"
  9087. '***********************
  9088. CASE "cls"
  9089. '***********************
  9090. FPRINT Outfile,Scoot$,"cls();"
  9091. '**********************************************************************
  9092. CASE ELSE
  9093. '**********************************************************************
  9094. ' "=" We MUST be processing an assignment statement if we get here!
  9095. ' or perhaps calling a SUB without using the CALL keyword
  9096. '**********************************************************************
  9097. FOR B = 1 TO Ndx
  9098. IF Stk$[B]= "=" THEN EXIT FOR
  9099. NEXT
  9100. '*************************************************************************
  9101. 'There's no "=" so we're either calling a SUB or this is a FUNCTION RETURN
  9102. '*************************************************************************
  9103. IF B-1 = Ndx THEN
  9104. lszTmp$ = ""
  9105. FOR Tmp = 1 TO Ndx
  9106. CONCAT(lszTmp$, Clean$(Stk$[Tmp]))
  9107. NEXT
  9108. CONCAT(lszTmp$, ";")
  9109. IF FuncRetnFlag = 2 THEN
  9110. FPRINT Outfile,lszTmp$
  9111. ELSE
  9112. FPRINT Outfile,Scoot$,lszTmp$
  9113. END IF
  9114. IF FuncRetnFlag = 2 THEN
  9115. FuncRetnFlag = 0
  9116. Stk$[1] = ""
  9117. EXIT SUB
  9118. END IF
  9119. EXIT SELECT
  9120. END IF
  9121. '*************************************************************************
  9122. ' It can only be one thing now -- a normal assignment statement
  9123. '*************************************************************************
  9124. FOR i = 2 TO B-1
  9125. CONCAT(Stk$[1], Stk$[i]) ' IF present, build the Array Variable
  9126. NEXT
  9127. A = INCHR(Stk$[1], "*")
  9128. IF A THEN
  9129. IF NOT ( INCHR(Stk$[1], "$") AND A > 1 ) THEN 'Exclude strings BYREF
  9130. RemoveAll(Stk$[1], "$")
  9131. GOTO ProcessNumeric
  9132. END IF
  9133. END IF
  9134. '*************************************************************************
  9135. ' 'processing a string equation
  9136. '*************************************************************************
  9137. LOCAL strtest, varid, vi AS VarInfo PTR, vr$, brcnt
  9138. strtest = DataType(Stk$[1])
  9139. IF strtest = vt_INTEGER THEN
  9140. brcnt = TALLY(Stk$[1], "[")
  9141. vr$ = EXTRACT$(Stk$[1], "[")
  9142. strtest = CheckLocal(vr$, &varid)
  9143. IF strtest = vt_UNKNOWN THEN
  9144. strtest = CheckGlobal(vr$, &varid)
  9145. vi = &(GlobalVars[varid])
  9146. ELSE
  9147. vi = &(LocalVars[varid])
  9148. END IF
  9149. IF strtest = vt_CHAR THEN
  9150. strtest = vt_STRVAR
  9151. END IF
  9152. IF strtest = vt_STRVAR THEN
  9153. IF vi->VarPntr <> 0 THEN
  9154. ' string pointer
  9155. GOTO ProcessNumeric
  9156. END IF
  9157. IF TALLY(vi->VarDim,"[") = brcnt THEN
  9158. ' the character within string
  9159. GOTO ProcessNumeric
  9160. END IF
  9161. IF TALLY(vi->VarDim,"[") <> brcnt+1 THEN
  9162. ' string pointer
  9163. GOTO ProcessNumeric
  9164. END IF
  9165. END IF
  9166. END IF
  9167. IF strtest = vt_STRVAR THEN
  9168. '*************************************************************************
  9169. IF B+1 = Ndx THEN
  9170. IF Stk$[Ndx] = DDQ$ THEN
  9171. FPRINT Outfile,Scoot$,"*",Clean$(Stk$[1]),"=0;"
  9172. GOTO StringExit
  9173. END IF
  9174. END IF
  9175. ' [ Speed up No. 1 ] ****************************************************
  9176. IF Ndx = 3 THEN
  9177. Stk$[1]=Clean$(Stk$[1])
  9178. Stk$[3]=Clean$(Stk$[3])
  9179. IF Stk$[1] = "BCX_RetStr" THEN
  9180. FPRINT Outfile,Scoot$,"BCX_RetStr=BCX_TmpStr(strlen(" ; Stk$[3] ; "));"
  9181. END IF
  9182. FPRINT Outfile,Scoot$,"strcpy(", Stk$[1], ",", Stk$[3], ");"
  9183. GOTO StringExit
  9184. END IF
  9185. '***********************
  9186. Arg$ = ""
  9187. lszTmp$ = ""
  9188. j=k=0
  9189. '***********************
  9190. IF iMatchLft(Stk$[3],"$$") THEN HasStorage = TRUE
  9191. Var$ = Clean$(Stk$[1])
  9192. IF Clean$(Stk$[B+1]) = Var$ THEN
  9193. k = TRUE
  9194. END IF
  9195. FOR A = B+1 TO Ndx ' B marks the position of the "=" char
  9196. IF Stk$[A]= "&" AND Stk$[A-1] <> "," AND Stk$[A-1] <> "(" THEN
  9197. INCR j
  9198. Arg$ = Arg$ + lszTmp$
  9199. lszTmp$ = ","
  9200. ELSE
  9201. CONCAT(lszTmp$, Clean$(Stk$[A]))
  9202. END IF
  9203. NEXT
  9204. IF *lszTmp <> 0 AND lszTmp$ <> "," THEN
  9205. Arg$ = Arg$ + lszTmp$
  9206. END IF
  9207. '*************************************************************************
  9208. ' Rules
  9209. '*************************************************************************
  9210. ' IF j = 0 & K = ANY THEN use strcpy
  9211. ' IF j = 1 & K = TRUE THEN use strcat
  9212. ' All else THEN use join
  9213. '*************************************************************************
  9214. RemoveAll(Var$, SPC$) 'Added this during the beta testing
  9215. '*** needs to be checked out still ***
  9216. 'stk[++i] is getting here as stk [ + + i ]
  9217. IF j = 0 THEN
  9218. IF Var$ = "BCX_RetStr" THEN
  9219. IF HasStorage THEN
  9220. FPRINT Outfile,Scoot$,"BCX_RetStr=", Arg$, ";"
  9221. GOTO StringExit
  9222. ELSE
  9223. FPRINT Outfile,Scoot$,"BCX_RetStr=BCX_TmpStr(strlen(" , Arg$ , "));"
  9224. END IF
  9225. END IF
  9226. FPRINT Outfile,Scoot$,"strcpy(", Var$ , "," , Arg$, ");"
  9227. GOTO StringExit
  9228. END IF
  9229. 'If we make it here then we should have 2 or more expressions
  9230. IF k = TRUE AND j = 1 THEN
  9231. FPRINT Outfile,Scoot$,"strcat(", Arg$ , ");"
  9232. GOTO StringExit
  9233. END IF
  9234. lszTmp$ = LTRIM$(STR$(++j))
  9235. Use_Join = TRUE
  9236. IF Var$ = "BCX_RetStr" THEN
  9237. FPRINT Outfile,Scoot$,"BCX_RetStr=join(" , lszTmp$ , "," , Arg$, ");"
  9238. ELSE
  9239. FPRINT Outfile,Scoot$,"strcpy(",Var$, ", join(" , lszTmp$ , "," , Arg$, "));"
  9240. END IF
  9241. StringExit:
  9242. EXIT SELECT
  9243. '***********************
  9244. ELSE
  9245. '***********************
  9246. ProcessNumeric:
  9247. '***********************
  9248. FOR i = 2 TO B
  9249. Stk$[i] = ""
  9250. NEXT
  9251. Stk$[B]= "=" 'This is necessary
  9252. ' change x = x ? c to x ?= c
  9253. IF Stk$[B + 1] = Stk$[1] AND Ndx = 5 THEN
  9254. IF Inset(Stk$[B + 2], "+-*/") AND Stk$[B + 3] <> ">" THEN
  9255. Stk$[B] = Stk$[B + 2] + Stk$[B]
  9256. Stk$[B + 1] = ""
  9257. Stk$[B + 2] = ""
  9258. END IF
  9259. END IF
  9260. FPRINT Outfile,Scoot$,Clean$(Stk$[1]);
  9261. FOR A = 2 TO Ndx
  9262. IF Stk$[A] = "!" THEN
  9263. FPRINT Outfile,"!";
  9264. ELSE
  9265. FPRINT Outfile,Clean$(Stk$[A]);
  9266. END IF
  9267. NEXT
  9268. FPRINT Outfile,";"
  9269. END IF
  9270. END SELECT
  9271. IF FuncRetnFlag = 1 THEN
  9272. IF LocalDynaCnt <> 0 THEN
  9273. FOR j = 1 TO LocalDynaCnt
  9274. FPRINT Outfile,Scoot$,DynaStr$[j]
  9275. NEXT
  9276. END IF
  9277. '******************************************************************
  9278. FPRINT Outfile,Scoot$,"return BCX_RetStr;" ' $ FUNCTION Return
  9279. '******************************************************************
  9280. END IF
  9281. END SUB ' Emit
  9282. SUB Abort(Z$)
  9283. DIM RAW i = 0
  9284. DIM RAW j = 0
  9285. DIM RAW k = 0
  9286. DIM RAW varnum = 0
  9287. DIM RAW t$
  9288. DIM RAW frmt$
  9289. WarnMsg$ = ""
  9290. IF LEFT$(AbortSrc$,11) = "$BCXVERSION" THEN
  9291. CONCAT(WarnMsg$,Z$)
  9292. ELSE
  9293. WarnMsg$ = WarnMsg$ + Z$ + " at line" + STR$(ModuleLineNos[ModuleNdx]) + " in Module: " + TRIM$(Modules$[ModuleNdx]) + CRLF$
  9294. WarnMsg$ = WarnMsg$ + "Original line" + CRLF$
  9295. WarnMsg$ = WarnMsg$ + AbortSrc$ + CRLF$
  9296. WarnMsg$ = WarnMsg$ + "==============" + CRLF$
  9297. WarnMsg$ = WarnMsg$ + "Current Tokens" + CRLF$
  9298. WarnMsg$ = WarnMsg$ + "==============" + CRLF$
  9299. FOR k = 1 TO Ndx
  9300. j = LEN(Stk$[k])
  9301. IF j < 40 THEN
  9302. j = 40 - j
  9303. ELSE
  9304. j = 8 - IMOD(j,8)
  9305. END IF
  9306. frmt$ = LPAD$(STR$(k),3)
  9307. WarnMsg$ = WarnMsg$ + frmt$ + " " + Stk$[k] + STRING$(j,32) + CRLF$
  9308. t$ = Clean$(Stk$[k])
  9309. i = CheckLocal(t$, &varnum)
  9310. IF i <> vt_UNKNOWN THEN
  9311. WarnMsg$ = WarnMsg$ + "is a LOCAL defined at line" + STR$(LocalVars[varnum].VarLine)
  9312. WarnMsg$ = WarnMsg$ + " in Module: " + LocalVars[varnum].VarModule + CRLF$
  9313. ELSE
  9314. i = CheckGlobal(t$, &varnum)
  9315. IF i <> vt_UNKNOWN THEN
  9316. WarnMsg$ = WarnMsg$ + "is a GLOBAL defined at line" + STR$(GlobalVars[varnum].VarLine)
  9317. WarnMsg$ = WarnMsg$ + " in Module: " + GlobalVars[varnum].VarModule + CRLF$
  9318. WarnMsg$ = WarnMsg$ + " " + Stk$[k] & GlobalVars[varnum].VarDim$ + " as "
  9319. IF GlobalVars[varnum].VarDef THEN
  9320. WarnMsg$ = WarnMsg$ + TRIM$(TypeDefs[GlobalVars[varnum].VarDef].VarName$) + CRLF$
  9321. ELSE
  9322. WarnMsg$ = WarnMsg$ + TRIM$(GetVarTypeName$(GlobalVars[varnum].VarType)) + CRLF$
  9323. END IF
  9324. ELSE
  9325. IF Stk[k][0] = 34 THEN
  9326. WarnMsg$ = WarnMsg$ + "is a STRING LITERAL" + CRLF$
  9327. END IF
  9328. END IF
  9329. END IF
  9330. NEXT
  9331. WarnMsg$ = WarnMsg$ + "===============" + CRLF$
  9332. WarnMsg$ = WarnMsg$ + "Original Tokens" + CRLF$
  9333. WarnMsg$ = WarnMsg$ + "===============" + CRLF$
  9334. CALL XParse(AbortSrc$)
  9335. FOR k = 1 TO Ndx
  9336. j = LEN(Stk$[k])
  9337. IF j < 40 THEN
  9338. j = 40 - j
  9339. ELSE
  9340. j = 8 - IMOD(j,8)
  9341. END IF
  9342. frmt$ = LPAD$(STR$(k),3)
  9343. WarnMsg$ = WarnMsg$ + frmt$ + " " + Stk$[k] + STRING$(j,32) + CRLF$
  9344. t$ = Clean$(Stk$[k])
  9345. i = CheckLocal(t$, &varnum)
  9346. IF i <> vt_UNKNOWN THEN
  9347. WarnMsg$ = WarnMsg$ + "is a LOCAL defined at line" + STR$(LocalVars[varnum].VarLine)
  9348. WarnMsg$ = WarnMsg$ + " in Module: " + LocalVars[varnum].VarModule + CRLF$
  9349. ELSE
  9350. i = CheckGlobal(t$, &varnum)
  9351. IF i <> vt_UNKNOWN THEN
  9352. WarnMsg$ = WarnMsg$ + "is a GLOBAL defined at line" + STR$(GlobalVars[varnum].VarLine)
  9353. WarnMsg$ = WarnMsg$ + " in Module: " + GlobalVars[varnum].VarModule + CRLF$
  9354. WarnMsg$ = WarnMsg$ + " " + Stk$[k] & GlobalVars[varnum].VarDim$ + " as "
  9355. IF GlobalVars[varnum].VarDef THEN
  9356. WarnMsg$ = WarnMsg$ + TypeDefs[GlobalVars[varnum].VarDef].VarName$ + CRLF$
  9357. ELSE
  9358. WarnMsg$ = WarnMsg$ + GetVarTypeName$(GlobalVars[varnum].VarType) + CRLF$
  9359. END IF
  9360. ELSE
  9361. IF Stk[k][0] = 34 THEN
  9362. WarnMsg$ = WarnMsg$ + "is a string literal" + CRLF$
  9363. END IF
  9364. END IF
  9365. END IF
  9366. NEXT
  9367. END IF
  9368. WarnMsg$ = WarnMsg$ + CRLF$
  9369. CALL CloseAll
  9370. KILL ovrFile$
  9371. KILL FileOut$
  9372. KILL prcFile$
  9373. KILL udtFile$
  9374. KILL hdrFile$
  9375. KILL cstFile$
  9376. KILL datFile$
  9377. KILL setFile$
  9378. KILL enuFile$
  9379. 'KILL resFile$
  9380. KILL "$t$e$m$p"
  9381. IF ErrFile THEN
  9382. OPEN FileErr$ FOR APPEND AS fpErr
  9383. FPRINT fpErr, Z$ ; " at line" ; ModuleLineNos[ModuleNdx] ; " in Module: "; TRIM$(Modules$[ModuleNdx]) 'LinesRead
  9384. CLOSE fpErr
  9385. END IF
  9386. PRINT "Error!",CRLF$, FileIn$,CRLF$, WarnMsg$
  9387. CALL FREEGLOBALS
  9388. END = 1
  9389. END SUB ' Abort
  9390. SUB BumpDown
  9391. Indent--
  9392. Indent--
  9393. IF Indent<0 THEN Indent = 0
  9394. Scoot$ = SPACE$(Indent)
  9395. END SUB ' BumpDown
  9396. SUB BumpUp
  9397. IF Indent<0 THEN Indent = 0
  9398. Indent++
  9399. Indent++
  9400. Scoot$ = SPACE$(Indent)
  9401. END SUB ' BumpUp
  9402. FUNCTION BraceCount( Arg$ )
  9403. DIM RAW p AS CHAR PTR
  9404. DIM RAW braces
  9405. p = Arg$
  9406. braces = 0
  9407. WHILE *p
  9408. IF *p = c_DblQt THEN
  9409. p++
  9410. WHILE *p <> c_DblQt
  9411. IF *p = 0 THEN FUNCTION = braces
  9412. p++
  9413. WEND
  9414. END IF
  9415. IF *p = ASC("}") THEN braces--
  9416. IF *p = ASC("{") THEN braces++
  9417. p++
  9418. WEND
  9419. FUNCTION = braces
  9420. END FUNCTION ' BraceCount
  9421. FUNCTION BracketHandler(Src$,l) AS CHAR PTR
  9422. DIM RAW s AS CHAR PTR
  9423. s = Src$
  9424. SELECT CASE l
  9425. CASE 0
  9426. DO
  9427. IF *s = 0 THEN EXIT LOOP
  9428. IF *s = c_DblQt THEN
  9429. s++
  9430. WHILE *s <> c_DblQt
  9431. IF *s = 0 THEN EXIT LOOP
  9432. s++
  9433. WEND
  9434. END IF
  9435. IF *s = c_LtBkt THEN
  9436. s++
  9437. s = BracketHandler(s,1)
  9438. END IF
  9439. IF *s = c_LPar THEN
  9440. s++
  9441. s = BracketHandler(s,2)
  9442. END IF
  9443. s++
  9444. LOOP
  9445. CASE 1
  9446. WHILE *s <> c_RtBkt
  9447. IF *s = c_DblQt THEN
  9448. s++
  9449. WHILE *s <> c_DblQt
  9450. IF *s = 0 THEN EXIT LOOP
  9451. s++
  9452. WEND
  9453. END IF
  9454. IF *s = c_LtBkt THEN
  9455. s++
  9456. s = BracketHandler(s, 1)
  9457. END IF
  9458. IF *s = c_LPar THEN
  9459. s++
  9460. s = BracketHandler(s, 2)
  9461. END IF
  9462. IF *s = c_Komma THEN *s = 1
  9463. IF *s = 0 THEN EXIT LOOP
  9464. s++
  9465. WEND
  9466. CASE 2
  9467. WHILE *s <> c_RPar
  9468. IF *s = c_DblQt THEN
  9469. s++
  9470. WHILE *s <> c_DblQt
  9471. IF *s = 0 THEN EXIT LOOP
  9472. s++
  9473. WEND
  9474. END IF
  9475. IF *s = c_LtBkt THEN
  9476. s++
  9477. s = BracketHandler(s, 1)
  9478. END IF
  9479. IF *s = c_LPar THEN
  9480. s++
  9481. s = BracketHandler(s, 2)
  9482. END IF
  9483. IF *s = 0 THEN EXIT LOOP
  9484. s++
  9485. WEND
  9486. END SELECT
  9487. IF l = 0 THEN
  9488. REPLACE CHR$(1) WITH "][" IN Src$
  9489. FUNCTION = Src
  9490. END IF
  9491. FUNCTION = s
  9492. END FUNCTION ' BracketHandler
  9493. SUB Push(Z$)
  9494. CaseStk$[++Pusher]= Z$
  9495. END SUB
  9496. SUB Pop(Z$)
  9497. Z$ = CaseStk$[--Pusher]
  9498. END SUB ' Pop
  9499. SUB EmitEpilog
  9500. IF NoMain + EndOfProgram = 0 THEN
  9501. FPRINT Outfile,"return 0; // End of main program"
  9502. CALL BumpDown
  9503. FPRINT Outfile,"}"
  9504. FLUSH(Outfile)
  9505. END IF
  9506. END SUB ' EmitEpilog
  9507. SUB EmitProlog
  9508. FPRINT Outfile,""
  9509. FPRINT Outfile,"int main(int argc, char *argv[])"
  9510. '*****************************************************************************
  9511. ' int main is conditionally removed later IN SUB AddProtos
  9512. '*****************************************************************************
  9513. FLUSH (Outfile)
  9514. END SUB ' EmitProlog
  9515. SUB DeclareVariables
  9516. DIM RAW i
  9517. DIM RAW A
  9518. DIM RAW P$
  9519. 'DIM RAW VAR$
  9520. DIM RAW VarName$
  9521. DIM RAW VarDim$
  9522. DIM RAW Storage$
  9523. OPEN FileOut$ FOR INPUT AS FP1
  9524. OPEN "$t$e$m$p" FOR OUTPUT AS Outfile
  9525. OPEN cstFile$ FOR INPUT AS FP3
  9526. IF LOF(cstFile$) > 0 THEN
  9527. FPRINT Outfile,""
  9528. FPRINT Outfile,"// *************************************************"
  9529. FPRINT Outfile,"// " + $BCX_STR_USR_CONST
  9530. FPRINT Outfile,"// *************************************************"
  9531. FPRINT Outfile,""
  9532. END IF
  9533. WHILE NOT EOF(FP3)
  9534. LINE INPUT FP3,Z$
  9535. FPRINT Outfile,LTRIM$(Z$)
  9536. WEND
  9537. CLOSE FP3
  9538. '/***** 2011-03-10 Moved ENUM Emmission so that Named Enums can be used with User Prototypes / Classes -AIR *****/
  9539. IF Use_EnumFile THEN
  9540. FPRINT Outfile,"// *************************************************"
  9541. FPRINT Outfile,"// User's GLOBAL ENUM blocks"
  9542. FPRINT Outfile,"// *************************************************"
  9543. OPEN enuFile$ FOR INPUT AS FP8
  9544. WHILE NOT EOF(FP8)
  9545. LINE INPUT FP8,Z$
  9546. FPRINT Outfile,Z$
  9547. WEND
  9548. CLOSE FP8
  9549. FPRINT Outfile,""
  9550. END IF
  9551. OPEN udtFile$ FOR INPUT AS FP3
  9552. IF LOF(udtFile$) > 0 THEN
  9553. FPRINT Outfile,""
  9554. FPRINT Outfile,"// *************************************************"
  9555. FPRINT Outfile,"// " + $BCX_STR_USR_TYPES
  9556. FPRINT Outfile,"// *************************************************"
  9557. WHILE NOT EOF(FP3)
  9558. LINE INPUT FP3,Z$
  9559. FPRINT Outfile,Scoot$,Z$
  9560. WEND
  9561. END IF
  9562. CLOSE FP3
  9563. IF HFileCnt > 0 THEN
  9564. FPRINT Outfile,""
  9565. FPRINT Outfile,"// *************************************************"
  9566. FPRINT Outfile,"// User Include Files"
  9567. FPRINT Outfile,"// *************************************************"
  9568. FPRINT Outfile,""
  9569. A = 0
  9570. WHILE A < HFileCnt
  9571. FPRINT Outfile,HFiles$[A]
  9572. A++
  9573. WEND
  9574. FPRINT Outfile,"#include <term.h>"
  9575. END IF
  9576. IF Use_SingleFile = TRUE THEN
  9577. FPRINT Outfile,""
  9578. FPRINT Outfile,"// *************************************************"
  9579. FPRINT Outfile,"// "+$BCX_STR_SYS_VARS
  9580. FPRINT Outfile,"// *************************************************"
  9581. FPRINT Outfile,""
  9582. IF Use_RegEx THEN
  9583. FPRINT Outfile,"typedef struct _REGEX"
  9584. FPRINT Outfile,"{"
  9585. FPRINT Outfile," int count;"
  9586. FPRINT Outfile," regmatch_t matches[1024];"
  9587. FPRINT Outfile," PCHAR results[1024];"
  9588. FPRINT Outfile,"}REGEX, *LPREGEX;\n"
  9589. END IF
  9590. IF Use_Time THEN
  9591. FPRINT Outfile,"enum TIME_OPTIONS"
  9592. FPRINT Outfile,"{"
  9593. FPRINT Outfile," TIME,"
  9594. FPRINT Outfile," HOUR,"
  9595. FPRINT Outfile," MINUTE,"
  9596. FPRINT Outfile," SECOND,"
  9597. FPRINT Outfile," APM,"
  9598. FPRINT Outfile," YEAR,"
  9599. FPRINT Outfile," MONTH,"
  9600. FPRINT Outfile," DAY,"
  9601. FPRINT Outfile," DAYNAME,"
  9602. FPRINT Outfile," WEEKDAY,"
  9603. FPRINT Outfile," YEARDAY,"
  9604. FPRINT Outfile," WEEKNUMBER,"
  9605. FPRINT Outfile," DATE,"
  9606. FPRINT Outfile," FULLDATE"
  9607. FPRINT Outfile," };\n"
  9608. END IF
  9609. IF Use_Findfirst OR Use_Findnext THEN
  9610. FPRINT Outfile,"typedef struct _FILE_FIND_DATA"
  9611. FPRINT Outfile,"{"
  9612. FPRINT Outfile," DWORD dwFileAttributes;"
  9613. FPRINT Outfile," DWORD ftCreationTime;"
  9614. FPRINT Outfile," DWORD ftLastAccessTime;"
  9615. FPRINT Outfile," DWORD ftLastWriteTime;"
  9616. FPRINT Outfile," DWORD nFileSizeHigh;"
  9617. FPRINT Outfile," DWORD nFileSizeLow;"
  9618. FPRINT Outfile," char cFileSpec[MAX_PATH];"
  9619. FPRINT Outfile," char cFileName[MAX_PATH];"
  9620. FPRINT Outfile," char path[MAX_PATH];"
  9621. FPRINT Outfile," DIR *FileHandle;"
  9622. FPRINT Outfile,"}FILE_FIND_DATA, *LPFILE_FIND_DATA;\n"
  9623. END IF
  9624. IF Use_Ldouble THEN
  9625. FPRINT Outfile,"#define LDOUBLE long double"
  9626. END IF
  9627. IF Use_Idxqsort THEN
  9628. FPRINT Outfile,"char*** pppStr;"
  9629. END IF
  9630. IF Use_Idxqsort OR Use_IdxqsortSt OR Use_PtrqsortSt THEN
  9631. FPRINT Outfile,"int Key;"
  9632. END IF
  9633. IF Use_IdxqsortSt THEN
  9634. FPRINT Outfile,"char* cmp1;"
  9635. FPRINT Outfile,"int StructSize;"
  9636. END IF
  9637. IF Use_PtrqsortSt THEN
  9638. FPRINT Outfile,"int OffSet;"
  9639. END IF
  9640. '********************************
  9641. ' PB Compatible String Constants
  9642. '********************************
  9643. IF Use_NUL THEN
  9644. FPRINT Outfile,"char NUL [1]={0}; // Null"
  9645. END IF
  9646. IF Use_BEL THEN
  9647. FPRINT Outfile,"char BEL [2]={7,0}; // Bell"
  9648. END IF
  9649. IF Use_BS THEN
  9650. FPRINT Outfile,"char BS [2]={8,0}; // Back Space"
  9651. END IF
  9652. IF Use_TAB THEN
  9653. FPRINT Outfile,"char TAB [2]={9,0}; // Horz Tab"
  9654. END IF
  9655. IF Use_LF THEN
  9656. FPRINT Outfile,"char LF [2]={10,0}; // Line Feed"
  9657. END IF
  9658. IF Use_VT THEN
  9659. FPRINT Outfile,"char VT [2]={11,0}; // Vert Tab"
  9660. END IF
  9661. IF Use_FF THEN
  9662. FPRINT Outfile,"char FF [2]={12,0}; // Form Feed"
  9663. END IF
  9664. IF Use_CR THEN
  9665. FPRINT Outfile,"char CR [2]={13,0}; // Carr Rtn"
  9666. END IF
  9667. IF Use_EOF THEN
  9668. FPRINT Outfile,"char EF [2]={26,0}; // End-of-File"
  9669. END IF
  9670. IF Use_ESC THEN
  9671. FPRINT Outfile,"char ESC [2]={27,0}; // Escape"
  9672. END IF
  9673. IF Use_SPC THEN
  9674. FPRINT Outfile,"char SPC [2]={32,0}; // Space"
  9675. END IF
  9676. IF Use_DQ THEN
  9677. FPRINT Outfile,"char DQ [2]={34,0}; // Double-Quote"
  9678. END IF
  9679. IF Use_DDQ THEN
  9680. FPRINT Outfile,"char DDQ [3]={34,34,0}; // Double-Double-Quote"
  9681. END IF
  9682. IF Use_Crlf THEN
  9683. FPRINT Outfile,"char CRLF[3]={13,10,0}; // Carr Rtn & Line Feed"
  9684. END IF
  9685. '********************************
  9686. IF Use_Console THEN
  9687. FPRINT Outfile,"int color_fg = 7;"
  9688. FPRINT Outfile,"int color_bg = 0;"
  9689. END IF
  9690. IF Use_Lineinput THEN
  9691. FPRINT Outfile,"char *AR_fgets_retval;"
  9692. END IF
  9693. IF Use_Scan THEN
  9694. FPRINT Outfile,"int ScanError;"
  9695. END IF
  9696. IF Use_Inputbuffer = TRUE THEN
  9697. FPRINT Outfile,"char InputBuffer[1048576];"
  9698. END IF
  9699. IF Use_Findfirst OR Use_Findnext THEN
  9700. FPRINT Outfile,"FILE_FIND_DATA FindData;"
  9701. END IF
  9702. IF Use_Gosub THEN
  9703. FPRINT Outfile,"jmp_buf GosubStack[32];"
  9704. FPRINT Outfile,"int GosubNdx;"
  9705. END IF
  9706. IF Use_Dynacall THEN
  9707. FPRINT Outfile,"HINSTANCE BCX_DllStore[256];"
  9708. END IF
  9709. '/***** 2013-06-26 New REGEX Keyword -AIR *****/
  9710. END IF
  9711. IF GlobalVarCnt THEN
  9712. FPRINT Outfile,""
  9713. FPRINT Outfile,"// *************************************************"
  9714. FPRINT Outfile,"// " + $BCX_STR_USR_VARS
  9715. FPRINT Outfile,"// *************************************************"
  9716. FPRINT Outfile,""
  9717. END IF
  9718. '*************************************
  9719. 'First we declare the simple Variables
  9720. '*************************************
  9721. FOR i = 1 TO GlobalVarCnt
  9722. IF GlobalVars[i].VarEmitFlag THEN ITERATE
  9723. IF "" = GlobalVars[i].VarDim$ AND GlobalVars[i].VarCondLevel = 0 THEN
  9724. P$ = ""
  9725. IF GlobalVars[i].VarPntr THEN P$ = STRING$(GlobalVars[i].VarPntr,42)
  9726. A = GlobalVars[i].VarType
  9727. IF GlobalVars[i].VarSF THEN
  9728. VarName$ = "(*" + GlobalVars[i].VarName$ + ")"
  9729. ELSE
  9730. VarName$ = GlobalVars[i].VarName$
  9731. END IF
  9732. Storage$ = VarStorage$[GlobalVars[i].VarExtn] & VarConst$[GlobalVars[i].VarConstant]
  9733. VarDim$ = GlobalVars[i].VarDim$
  9734. CALL PrintGlobal(A, i, Storage$, P$, VarName$, VarDim$)
  9735. END IF
  9736. NEXT
  9737. ' Next, we declare the Arrays
  9738. FOR i = 1 TO GlobalVarCnt
  9739. IF GlobalVars[i].VarEmitFlag THEN ITERATE
  9740. IF "" <> GlobalVars[i].VarDim$ AND GlobalVars[i].VarCondLevel = 0 THEN
  9741. IF INSTR(GlobalVars[i].VarDim,"{") = 0 THEN ' do uninitialized global arrays
  9742. P$ = ""
  9743. IF GlobalVars[i].VarPntr THEN P$ = STRING$(GlobalVars[i].VarPntr,42)
  9744. A = GlobalVars[i].VarType
  9745. IF GlobalVars[i].VarSF THEN
  9746. VarName$ = "(*" + GlobalVars[i].VarName$ + EXTRACT$(GlobalVars[i].VarDim,"(") + ")"
  9747. VarDim$ = MID$(GlobalVars[i].VarDim, INSTR(GlobalVars[i].VarDim,"("))
  9748. ELSE
  9749. VarName$ = GlobalVars[i].VarName$
  9750. VarDim$ = GlobalVars[i].VarDim$
  9751. END IF
  9752. Storage$ = VarStorage$[GlobalVars[i].VarExtn] & VarConst$[GlobalVars[i].VarConstant]
  9753. CALL PrintGlobal(A, i, Storage$, P$, VarName$, VarDim$)
  9754. END IF
  9755. END IF
  9756. NEXT
  9757. DIM RAW LastDef$
  9758. DIM RAW LastLevel
  9759. LastDef$ = ""
  9760. LastLevel = 1
  9761. FOR i = 1 TO GlobalVarCnt
  9762. IF GlobalVars[i].VarEmitFlag THEN ITERATE
  9763. IF GlobalVars[i].VarCondLevel THEN
  9764. IF LastDef$ = "" THEN
  9765. LastDef$ = GlobalVars[i].VarCondDef$
  9766. LastLevel = GlobalVars[i].VarCondLevel
  9767. FPRINT Outfile,LastDef$
  9768. END IF
  9769. IF LastDef$ <> GlobalVars[i].VarCondDef$ THEN
  9770. IF GlobalVars[i].VarCondDef$ = "#else" THEN
  9771. WHILE LastLevel > GlobalVars[i].VarCondLevel
  9772. FPRINT Outfile,"#endif"
  9773. LastLevel--
  9774. WEND
  9775. FPRINT Outfile,"#else"
  9776. LastDef$ = GlobalVars[i].VarCondDef$
  9777. ELSE
  9778. WHILE LastLevel => GlobalVars[i].VarCondLevel
  9779. FPRINT Outfile,"#endif"
  9780. LastLevel--
  9781. WEND
  9782. LastDef$ = GlobalVars[i].VarCondDef$
  9783. LastLevel = GlobalVars[i].VarCondLevel
  9784. FPRINT Outfile,LastDef$
  9785. END IF
  9786. END IF
  9787. P$ = ""
  9788. IF GlobalVars[i].VarPntr THEN P$ = STRING$(GlobalVars[i].VarPntr,42)
  9789. A = GlobalVars[i].VarType
  9790. IF GlobalVars[i].VarSF THEN
  9791. VarName$ = "(*" + GlobalVars[i].VarName$ + ")"
  9792. ELSE
  9793. VarName$ = GlobalVars[i].VarName$
  9794. END IF
  9795. VarDim$ = GlobalVars[i].VarDim
  9796. Storage$ = VarStorage$[GlobalVars[i].VarExtn] & VarConst$[GlobalVars[i].VarConstant]
  9797. CALL PrintGlobal(A, i, Storage$, P$, VarName$, VarDim$)
  9798. END IF
  9799. NEXT
  9800. IF *LastDef$ THEN
  9801. WHILE LastLevel
  9802. FPRINT Outfile,"#endif"
  9803. LastLevel--
  9804. WEND
  9805. END IF
  9806. FPRINT Outfile,""
  9807. '*************************************
  9808. 'Add Declared Dll variables
  9809. '*************************************
  9810. ' FPRINT Outfile, "// ****************************************"
  9811. ' FPRINT Outfile, ""
  9812. IF DllCnt THEN
  9813. DIM RAW i, AR_DllName$
  9814. FPRINT Outfile, ""
  9815. FPRINT Outfile, "// **********[ DLL Declarations ]**********"
  9816. FPRINT Outfile, ""
  9817. ''------------------------------------------------------------------------
  9818. '' Emit LoadLibrary assignments
  9819. '' HMODULE H_DLLNAME = LoadLibrary("DLLNAME.DLL");
  9820. '' Todo: Add a check for H_DLLNAME = NULL in case of failure to load the DLL.
  9821. ''------------------------------------------------------------------------
  9822. FOR i = 0 TO LoadLibsCnt - 1
  9823. IF INCHR(Loadlibs$[i],"-") THEN
  9824. AR_DllName$ = EXTRACT$(Loadlibs$[i],"-")
  9825. ELSEIF INCHR(Loadlibs$[i],".") THEN
  9826. AR_DllName$ = EXTRACT$(Loadlibs$[i],".")
  9827. END IF
  9828. '~ FPRINT Outfile, "void *H_", UCASE$(EXTRACT$(Loadlibs$[i], ".")), " = dlopen(", ENC$(Loadlibs$[i]), ", RTLD_LAZY);"
  9829. FPRINT Outfile, "void *H_", UCASE$(AR_DllName$), " = dlopen(", ENC$(Loadlibs$[i]), ", RTLD_LAZY);"
  9830. NEXT i
  9831. FOR i = 1 TO DllCnt
  9832. FPRINT Outfile, DllDecl$[i] ' Emit the users DLL Declarations
  9833. NEXT
  9834. FPRINT Outfile, ""
  9835. FPRINT Outfile, "// ****************************************"
  9836. FPRINT Outfile, ""
  9837. END IF
  9838. '********************************
  9839. ' Read In The Data Statement File
  9840. '********************************
  9841. OPEN datFile$ FOR INPUT AS FP5
  9842. IF LOF(datFile$) > 0 THEN
  9843. FPRINT Outfile,""
  9844. FPRINT Outfile,"// *************************************************"
  9845. FPRINT Outfile,"// User Data Statements"
  9846. FPRINT Outfile,"// *************************************************"
  9847. FPRINT Outfile,""
  9848. FPRINT Outfile,"char * DATA [] ="
  9849. FPRINT Outfile,"{"
  9850. WHILE NOT EOF(FP5)
  9851. LINE INPUT FP5,Z$
  9852. FPRINT Outfile,Z$
  9853. WEND
  9854. FPRINT Outfile,"};"
  9855. END IF
  9856. CLOSE FP5
  9857. WHILE NOT EOF(FP1)
  9858. LINE INPUT FP1,Z$
  9859. FPRINT Outfile,Z$
  9860. WEND
  9861. CALL CloseAll
  9862. KILL FileOut$
  9863. RENAME "$t$e$m$p", FileOut$
  9864. END SUB 'DeclareVariables
  9865. FUNCTION GetNumArgs OPTIONAL(Strt, NdxPos AS INTEGER PTR=NULL)
  9866. DIM RAW CountR = 0 '() counter
  9867. DIM RAW CountS = 0 '[] counter
  9868. DIM RAW i 'loop counter
  9869. DIM RAW j = 0 'comma counter
  9870. DIM RAW k = 1 'function end flag
  9871. FOR i = Strt TO Ndx
  9872. IF Stk$[i] = "(" THEN
  9873. CountR++
  9874. k++
  9875. ELSEIF Stk$[i] = ")" THEN
  9876. CountR--
  9877. k--
  9878. IF k = 0 THEN EXIT FOR
  9879. ELSEIF Stk$[i] = "[" THEN
  9880. CountS++
  9881. ELSEIF Stk$[i] = "]" THEN
  9882. CountS--
  9883. ELSEIF Stk$[i] = "," AND CountR = 0 AND CountS = 0 THEN
  9884. j++
  9885. IF NdxPos THEN *NdxPos = i
  9886. END IF
  9887. NEXT
  9888. FUNCTION = j 'No. of commas = No. of args
  9889. END FUNCTION ' GetNumArgs
  9890. SUB GetVarCode(varcode AS VARCODE PTR)
  9891. DIM RAW CB$, PT$, PTH$, VAR$, vn, RF$
  9892. IF varcode->Method% = mt_Opts3 THEN
  9893. varcode->Proto$ = varcode->Proto$ + varcode->Token$
  9894. IF varcode->Token$ = "," THEN
  9895. varcode->Header$ = varcode->Header$ + varcode->Token$
  9896. END IF
  9897. EXIT SUB
  9898. END IF
  9899. IF varcode->Method% = mt_FuncSubx1 THEN
  9900. varcode->Proto$ = varcode->Proto$ + varcode->AsToken$ + "(*)("
  9901. varcode->Header$ = varcode->Header$ + varcode->AsToken$ + " (*" + varcode->Token$ + ")("
  9902. EXIT SUB
  9903. END IF
  9904. IF varcode->Method% = mt_FuncSubx2 THEN
  9905. varcode->Proto$ = varcode->Proto$ + varcode->AsToken$
  9906. varcode->Header$ = varcode->Header$ + varcode->AsToken$ + " " + varcode->Token$
  9907. EXIT SUB
  9908. END IF
  9909. IF IsCallBack THEN
  9910. CB$ = "CALLBACK "
  9911. ELSE
  9912. CB$ = ""
  9913. END IF
  9914. IF INCHR(varcode->Token$,"*") OR INCHR(varcode->AsToken$,"*") OR varcode->IsPtrFlag THEN
  9915. RemoveAll(varcode->Token$, "*")
  9916. RemoveAll(varcode->AsToken$, "*")
  9917. PT$ = STRING$(varcode->IsPtrFlag, ASC("*")) + " "
  9918. PTH$ = PT$
  9919. ELSE
  9920. PTH$ = " "
  9921. PT$ = ""
  9922. END IF
  9923. IF INCHR(varcode->Token$,"&") THEN
  9924. RF$ = " &"
  9925. ELSE
  9926. RF$ = ""
  9927. END IF
  9928. vn = varcode->VarNo%
  9929. VAR$ = GetVarTypeName$(vn)
  9930. SELECT CASE vn
  9931. '************************************************************************
  9932. CASE vt_STRVAR
  9933. '************************************************************************
  9934. SELECT CASE varcode->Method%
  9935. CASE mt_ProcessSetCommand
  9936. varcode->StaticOut$ = "static char " + Clean$(varcode->Token$)
  9937. CASE mt_FuncSubDecC_Dec
  9938. varcode->Functype$ = "char * " + CB$
  9939. CASE mt_FuncSubDecC_Dec2
  9940. IF NOT INCHR(varcode->Token$, "[") THEN
  9941. varcode->Header$ = varcode->Header$ + "char *" + Clean$(varcode->Token$) + ", "
  9942. varcode->Proto$ = varcode->Proto$ + "char *, "
  9943. ELSE
  9944. varcode->Header$ = varcode->Header$ + "char " + REMOVE$(Clean$(varcode->Token$), "*") + ", "
  9945. varcode->Proto$ = varcode->Proto$ + "char [][65535], "
  9946. END IF
  9947. CASE mt_Opts
  9948. varcode->Functype$ = "char *"
  9949. CASE mt_Opts2
  9950. varcode->Header$ = varcode->Header$ + "char * " + Clean$(varcode->Token$)
  9951. varcode->Proto$ = varcode->Proto$ + "char* "
  9952. CASE mt_OverLoad
  9953. varcode->Functype$ = "char *"
  9954. CASE mt_OverLoad2
  9955. varcode->Header$ = varcode->Header$ + "char *" + Clean$(varcode->Token$) + ", "
  9956. END SELECT
  9957. '************************************************************************
  9958. CASE vt_BOOL,vt_BYTE,vt_COLORREF,vt_DOUBLE,vt_DWORD,vt_FARPROC,vt_HDC, _
  9959. vt_HANDLE,vt_HINSTANCE,vt_HWND,vt_INTEGER,vt_LONG,vt_LPBYTE,vt_LRESULT, _
  9960. vt_SHORT,vt_SINGLE,vt_UINT,vt_ULONG,vt_USHORT,vt_VARIANT,vt_VOID,vt_LDOUBLE
  9961. '************************************************************************
  9962. SELECT CASE varcode->Method%
  9963. CASE mt_ProcessSetCommand
  9964. varcode->StaticOut$ = "static " + VAR$ + " " + Clean$(varcode->Token$)
  9965. CASE mt_FuncSubDecC_Dec
  9966. varcode->Functype$ = VAR$ + PTH$ + CB$
  9967. CASE mt_FuncSubDecC_Dec2
  9968. varcode->Header$ = varcode->Header$ + VAR$ + PTH$ + Clean$(varcode->Token$) + ", "
  9969. varcode->Proto$ = varcode->Proto$ + VAR$ + RF$ + PT$ + ", "
  9970. CASE mt_Opts
  9971. varcode->Functype$ = VAR$ + PTH$
  9972. CASE mt_Opts2
  9973. varcode->Header$ = varcode->Header$ + VAR$ + PTH$ + Clean$(varcode->Token$)
  9974. varcode->Proto$ = varcode->Proto$ + VAR$ + RF$ + PT$
  9975. CASE mt_OverLoad
  9976. varcode->Functype$ = VAR$ + " "
  9977. CASE mt_OverLoad2
  9978. varcode->Header$ = varcode->Header$ + VAR$ + PTH$ + Clean$(varcode->Token$) + ", "
  9979. END SELECT
  9980. '************************************************************************
  9981. CASE vt_FILEPTR, vt_CHAR
  9982. '************************************************************************
  9983. SELECT CASE varcode->Method%
  9984. CASE mt_FuncSubDecC_Dec
  9985. varcode->Functype$ = VAR$ + PTH$ + CB$
  9986. CASE mt_FuncSubDecC_Dec2
  9987. varcode->Header$ = varcode->Header$ + VAR$ + PTH$ + Clean$(varcode->Token$) + ", "
  9988. varcode->Proto$ = varcode->Proto$ + VAR$ + PT$ + ", "
  9989. CASE mt_Opts
  9990. varcode->Functype$ = VAR$ + PTH$
  9991. CASE mt_Opts2
  9992. varcode->Header$ = varcode->Header$ + VAR$ + PTH$ + Clean$(varcode->Token$)
  9993. varcode->Proto$ = varcode->Proto$ + VAR$ + PT$
  9994. CASE mt_OverLoad
  9995. varcode->Functype$ = VAR$ + " "
  9996. CASE mt_OverLoad2
  9997. varcode->Header$ = varcode->Header$ + VAR$ + PTH$ + Clean$(varcode->Token$) + ", "
  9998. END SELECT
  9999. '************************************************************************
  10000. CASE vt_UDT, vt_STRUCT, vt_UNION
  10001. '************************************************************************
  10002. SELECT CASE varcode->Method%
  10003. CASE mt_ProcessSetCommand
  10004. IF vn = vt_UNION THEN
  10005. varcode->StaticOut$ = "static union " + Clean$(varcode->Token$)
  10006. ELSE
  10007. varcode->StaticOut$ = "static struct _" + Clean$(varcode->Token$) + " "
  10008. END IF
  10009. CASE mt_FuncSubDecC_Dec
  10010. varcode->Functype$ = varcode->AsToken$ + PTH$ + CB$
  10011. CASE mt_FuncSubDecC_Dec2
  10012. varcode->Header$ = varcode->Header$ + varcode->AsToken$ + PTH$ + Clean$(varcode->Token$) + ", "
  10013. varcode->Proto$ = varcode->Proto$ + varcode->AsToken$ + RF$ + PT$ + ", "
  10014. CASE mt_Opts
  10015. varcode->Functype$ = varcode->AsToken$ + PTH$
  10016. CASE mt_Opts2
  10017. varcode->Header$ = varcode->Header$ + Clean$(varcode->AsToken$) + PTH$ + " " + Clean$(varcode->Token$)
  10018. varcode->Proto$ = varcode->Proto$ + Clean$(varcode->AsToken$) + RF$ + PT$
  10019. CASE mt_OverLoad
  10020. varcode->Functype$ = VAR$ + " "
  10021. CASE mt_OverLoad2
  10022. varcode->Header$ = varcode->Header$ + varcode->AsToken$ + PTH$ + Clean$(varcode->Token$) + ", "
  10023. END SELECT
  10024. '************************************************************************
  10025. CASE ELSE
  10026. '***************************************