tclInt.h 189 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996
  1. /*
  2. * tclInt.h --
  3. *
  4. * Declarations of things used internally by the Tcl interpreter.
  5. *
  6. * Copyright (c) 1987-1993 The Regents of the University of California.
  7. * Copyright (c) 1993-1997 Lucent Technologies.
  8. * Copyright (c) 1994-1998 Sun Microsystems, Inc.
  9. * Copyright (c) 1998-1999 by Scriptics Corporation.
  10. * Copyright (c) 2001, 2002 by Kevin B. Kenny. All rights reserved.
  11. * Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
  12. * Copyright (c) 2006-2008 by Joe Mistachkin. All rights reserved.
  13. * Copyright (c) 2008 by Miguel Sofer. All rights reserved.
  14. *
  15. * See the file "license.terms" for information on usage and redistribution of
  16. * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  17. */
  18. #ifndef _TCLINT
  19. #define _TCLINT
  20. /*
  21. * Some numerics configuration options.
  22. */
  23. #undef ACCEPT_NAN
  24. /*
  25. * Common include files needed by most of the Tcl source files are included
  26. * here, so that system-dependent personalizations for the include files only
  27. * have to be made in once place. This results in a few extra includes, but
  28. * greater modularity. The order of the three groups of #includes is
  29. * important. For example, stdio.h is needed by tcl.h.
  30. */
  31. #include "tclPort.h"
  32. #include <stdio.h>
  33. #include <ctype.h>
  34. #ifdef NO_STDLIB_H
  35. # include "../compat/stdlib.h"
  36. #else
  37. # include <stdlib.h>
  38. #endif
  39. #ifdef NO_STRING_H
  40. #include "../compat/string.h"
  41. #else
  42. #include <string.h>
  43. #endif
  44. #if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \
  45. || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC)
  46. #include <stddef.h>
  47. #else
  48. typedef int ptrdiff_t;
  49. #endif
  50. /*
  51. * Ensure WORDS_BIGENDIAN is defined correctly:
  52. * Needs to happen here in addition to configure to work with fat compiles on
  53. * Darwin (where configure runs only once for multiple architectures).
  54. */
  55. #ifdef HAVE_SYS_TYPES_H
  56. # include <sys/types.h>
  57. #endif
  58. #ifdef HAVE_SYS_PARAM_H
  59. # include <sys/param.h>
  60. #endif
  61. #ifdef BYTE_ORDER
  62. # ifdef BIG_ENDIAN
  63. # if BYTE_ORDER == BIG_ENDIAN
  64. # undef WORDS_BIGENDIAN
  65. # define WORDS_BIGENDIAN 1
  66. # endif
  67. # endif
  68. # ifdef LITTLE_ENDIAN
  69. # if BYTE_ORDER == LITTLE_ENDIAN
  70. # undef WORDS_BIGENDIAN
  71. # endif
  72. # endif
  73. #endif
  74. /*
  75. * Used to tag functions that are only to be visible within the module being
  76. * built and not outside it (where this is supported by the linker).
  77. */
  78. #ifndef MODULE_SCOPE
  79. # ifdef __cplusplus
  80. # define MODULE_SCOPE extern "C"
  81. # else
  82. # define MODULE_SCOPE extern
  83. # endif
  84. #endif
  85. /*
  86. * Macros used to cast between pointers and integers (e.g. when storing an int
  87. * in ClientData), on 64-bit architectures they avoid gcc warning about "cast
  88. * to/from pointer from/to integer of different size".
  89. */
  90. #if !defined(INT2PTR) && !defined(PTR2INT)
  91. # if defined(HAVE_INTPTR_T) || defined(intptr_t)
  92. # define INT2PTR(p) ((void *)(intptr_t)(p))
  93. # define PTR2INT(p) ((int)(intptr_t)(p))
  94. # else
  95. # define INT2PTR(p) ((void *)(p))
  96. # define PTR2INT(p) ((int)(p))
  97. # endif
  98. #endif
  99. #if !defined(UINT2PTR) && !defined(PTR2UINT)
  100. # if defined(HAVE_UINTPTR_T) || defined(uintptr_t)
  101. # define UINT2PTR(p) ((void *)(uintptr_t)(p))
  102. # define PTR2UINT(p) ((unsigned int)(uintptr_t)(p))
  103. # else
  104. # define UINT2PTR(p) ((void *)(p))
  105. # define PTR2UINT(p) ((unsigned int)(p))
  106. # endif
  107. #endif
  108. #if defined(_WIN32) && defined(_MSC_VER)
  109. # define vsnprintf _vsnprintf
  110. #endif
  111. /*
  112. * The following procedures allow namespaces to be customized to support
  113. * special name resolution rules for commands/variables.
  114. */
  115. struct Tcl_ResolvedVarInfo;
  116. typedef Tcl_Var (Tcl_ResolveRuntimeVarProc)(Tcl_Interp *interp,
  117. struct Tcl_ResolvedVarInfo *vinfoPtr);
  118. typedef void (Tcl_ResolveVarDeleteProc)(struct Tcl_ResolvedVarInfo *vinfoPtr);
  119. /*
  120. * The following structure encapsulates the routines needed to resolve a
  121. * variable reference at runtime. Any variable specific state will typically
  122. * be appended to this structure.
  123. */
  124. typedef struct Tcl_ResolvedVarInfo {
  125. Tcl_ResolveRuntimeVarProc *fetchProc;
  126. Tcl_ResolveVarDeleteProc *deleteProc;
  127. } Tcl_ResolvedVarInfo;
  128. typedef int (Tcl_ResolveCompiledVarProc)(Tcl_Interp *interp,
  129. CONST84 char *name, int length, Tcl_Namespace *context,
  130. Tcl_ResolvedVarInfo **rPtr);
  131. typedef int (Tcl_ResolveVarProc)(Tcl_Interp *interp, CONST84 char *name,
  132. Tcl_Namespace *context, int flags, Tcl_Var *rPtr);
  133. typedef int (Tcl_ResolveCmdProc)(Tcl_Interp *interp, CONST84 char *name,
  134. Tcl_Namespace *context, int flags, Tcl_Command *rPtr);
  135. typedef struct Tcl_ResolverInfo {
  136. Tcl_ResolveCmdProc *cmdResProc;
  137. /* Procedure handling command name
  138. * resolution. */
  139. Tcl_ResolveVarProc *varResProc;
  140. /* Procedure handling variable name resolution
  141. * for variables that can only be handled at
  142. * runtime. */
  143. Tcl_ResolveCompiledVarProc *compiledVarResProc;
  144. /* Procedure handling variable name resolution
  145. * at compile time. */
  146. } Tcl_ResolverInfo;
  147. /*
  148. * This flag bit should not interfere with TCL_GLOBAL_ONLY,
  149. * TCL_NAMESPACE_ONLY, or TCL_LEAVE_ERR_MSG; it signals that the variable
  150. * lookup is performed for upvar (or similar) purposes, with slightly
  151. * different rules:
  152. * - Bug #696893 - variable is either proc-local or in the current
  153. * namespace; never follow the second (global) resolution path
  154. * - Bug #631741 - do not use special namespace or interp resolvers
  155. *
  156. * It should also not collide with the (deprecated) TCL_PARSE_PART1 flag
  157. * (Bug #835020)
  158. */
  159. #define TCL_AVOID_RESOLVERS 0x40000
  160. /*
  161. *----------------------------------------------------------------
  162. * Data structures related to namespaces.
  163. *----------------------------------------------------------------
  164. */
  165. typedef struct Tcl_Ensemble Tcl_Ensemble;
  166. typedef struct NamespacePathEntry NamespacePathEntry;
  167. /*
  168. * Special hashtable for variables: this is just a Tcl_HashTable with an nsPtr
  169. * field added at the end: in this way variables can find their namespace
  170. * without having to copy a pointer in their struct: they can access it via
  171. * their hPtr->tablePtr.
  172. */
  173. typedef struct TclVarHashTable {
  174. Tcl_HashTable table;
  175. struct Namespace *nsPtr;
  176. } TclVarHashTable;
  177. /*
  178. * This is for itcl - it likes to search our varTables directly :(
  179. */
  180. #define TclVarHashFindVar(tablePtr, key) \
  181. TclVarHashCreateVar((tablePtr), (key), NULL)
  182. /*
  183. * Define this to reduce the amount of space that the average namespace
  184. * consumes by only allocating the table of child namespaces when necessary.
  185. * Defining it breaks compatibility for Tcl extensions (e.g., itcl) which
  186. * reach directly into the Namespace structure.
  187. */
  188. #undef BREAK_NAMESPACE_COMPAT
  189. /*
  190. * The structure below defines a namespace.
  191. * Note: the first five fields must match exactly the fields in a
  192. * Tcl_Namespace structure (see tcl.h). If you change one, be sure to change
  193. * the other.
  194. */
  195. typedef struct Namespace {
  196. char *name; /* The namespace's simple (unqualified) name.
  197. * This contains no ::'s. The name of the
  198. * global namespace is "" although "::" is an
  199. * synonym. */
  200. char *fullName; /* The namespace's fully qualified name. This
  201. * starts with ::. */
  202. ClientData clientData; /* An arbitrary value associated with this
  203. * namespace. */
  204. Tcl_NamespaceDeleteProc *deleteProc;
  205. /* Procedure invoked when deleting the
  206. * namespace to, e.g., free clientData. */
  207. struct Namespace *parentPtr;/* Points to the namespace that contains this
  208. * one. NULL if this is the global
  209. * namespace. */
  210. #ifndef BREAK_NAMESPACE_COMPAT
  211. Tcl_HashTable childTable; /* Contains any child namespaces. Indexed by
  212. * strings; values have type (Namespace *). */
  213. #else
  214. Tcl_HashTable *childTablePtr;
  215. /* Contains any child namespaces. Indexed by
  216. * strings; values have type (Namespace *). If
  217. * NULL, there are no children. */
  218. #endif
  219. long nsId; /* Unique id for the namespace. */
  220. Tcl_Interp *interp; /* The interpreter containing this
  221. * namespace. */
  222. int flags; /* OR-ed combination of the namespace status
  223. * flags NS_DYING and NS_DEAD listed below. */
  224. int activationCount; /* Number of "activations" or active call
  225. * frames for this namespace that are on the
  226. * Tcl call stack. The namespace won't be
  227. * freed until activationCount becomes zero. */
  228. int refCount; /* Count of references by namespaceName
  229. * objects. The namespace can't be freed until
  230. * refCount becomes zero. */
  231. Tcl_HashTable cmdTable; /* Contains all the commands currently
  232. * registered in the namespace. Indexed by
  233. * strings; values have type (Command *).
  234. * Commands imported by Tcl_Import have
  235. * Command structures that point (via an
  236. * ImportedCmdRef structure) to the Command
  237. * structure in the source namespace's command
  238. * table. */
  239. TclVarHashTable varTable; /* Contains all the (global) variables
  240. * currently in this namespace. Indexed by
  241. * strings; values have type (Var *). */
  242. char **exportArrayPtr; /* Points to an array of string patterns
  243. * specifying which commands are exported. A
  244. * pattern may include "string match" style
  245. * wildcard characters to specify multiple
  246. * commands; however, no namespace qualifiers
  247. * are allowed. NULL if no export patterns are
  248. * registered. */
  249. int numExportPatterns; /* Number of export patterns currently
  250. * registered using "namespace export". */
  251. int maxExportPatterns; /* Mumber of export patterns for which space
  252. * is currently allocated. */
  253. int cmdRefEpoch; /* Incremented if a newly added command
  254. * shadows a command for which this namespace
  255. * has already cached a Command* pointer; this
  256. * causes all its cached Command* pointers to
  257. * be invalidated. */
  258. int resolverEpoch; /* Incremented whenever (a) the name
  259. * resolution rules change for this namespace
  260. * or (b) a newly added command shadows a
  261. * command that is compiled to bytecodes. This
  262. * invalidates all byte codes compiled in the
  263. * namespace, causing the code to be
  264. * recompiled under the new rules.*/
  265. Tcl_ResolveCmdProc *cmdResProc;
  266. /* If non-null, this procedure overrides the
  267. * usual command resolution mechanism in Tcl.
  268. * This procedure is invoked within
  269. * Tcl_FindCommand to resolve all command
  270. * references within the namespace. */
  271. Tcl_ResolveVarProc *varResProc;
  272. /* If non-null, this procedure overrides the
  273. * usual variable resolution mechanism in Tcl.
  274. * This procedure is invoked within
  275. * Tcl_FindNamespaceVar to resolve all
  276. * variable references within the namespace at
  277. * runtime. */
  278. Tcl_ResolveCompiledVarProc *compiledVarResProc;
  279. /* If non-null, this procedure overrides the
  280. * usual variable resolution mechanism in Tcl.
  281. * This procedure is invoked within
  282. * LookupCompiledLocal to resolve variable
  283. * references within the namespace at compile
  284. * time. */
  285. int exportLookupEpoch; /* Incremented whenever a command is added to
  286. * a namespace, removed from a namespace or
  287. * the exports of a namespace are changed.
  288. * Allows TIP#112-driven command lists to be
  289. * validated efficiently. */
  290. Tcl_Ensemble *ensembles; /* List of structures that contain the details
  291. * of the ensembles that are implemented on
  292. * top of this namespace. */
  293. Tcl_Obj *unknownHandlerPtr; /* A script fragment to be used when command
  294. * resolution in this namespace fails. TIP
  295. * 181. */
  296. int commandPathLength; /* The length of the explicit path. */
  297. NamespacePathEntry *commandPathArray;
  298. /* The explicit path of the namespace as an
  299. * array. */
  300. NamespacePathEntry *commandPathSourceList;
  301. /* Linked list of path entries that point to
  302. * this namespace. */
  303. Tcl_NamespaceDeleteProc *earlyDeleteProc;
  304. /* Just like the deleteProc field (and called
  305. * with the same clientData) but called at the
  306. * start of the deletion process, so there is
  307. * a chance for code to do stuff inside the
  308. * namespace before deletion completes. */
  309. } Namespace;
  310. /*
  311. * An entry on a namespace's command resolution path.
  312. */
  313. struct NamespacePathEntry {
  314. Namespace *nsPtr; /* What does this path entry point to? If it
  315. * is NULL, this path entry points is
  316. * redundant and should be skipped. */
  317. Namespace *creatorNsPtr; /* Where does this path entry point from? This
  318. * allows for efficient invalidation of
  319. * references when the path entry's target
  320. * updates its current list of defined
  321. * commands. */
  322. NamespacePathEntry *prevPtr, *nextPtr;
  323. /* Linked list pointers or NULL at either end
  324. * of the list that hangs off Namespace's
  325. * commandPathSourceList field. */
  326. };
  327. /*
  328. * Flags used to represent the status of a namespace:
  329. *
  330. * NS_DYING - 1 means Tcl_DeleteNamespace has been called to delete the
  331. * namespace but there are still active call frames on the Tcl
  332. * stack that refer to the namespace. When the last call frame
  333. * referring to it has been popped, it's variables and command
  334. * will be destroyed and it will be marked "dead" (NS_DEAD). The
  335. * namespace can no longer be looked up by name.
  336. * NS_DEAD - 1 means Tcl_DeleteNamespace has been called to delete the
  337. * namespace and no call frames still refer to it. Its variables
  338. * and command have already been destroyed. This bit allows the
  339. * namespace resolution code to recognize that the namespace is
  340. * "deleted". When the last namespaceName object in any byte code
  341. * unit that refers to the namespace has been freed (i.e., when
  342. * the namespace's refCount is 0), the namespace's storage will
  343. * be freed.
  344. * NS_KILLED - 1 means that TclTeardownNamespace has already been called on
  345. * this namespace and it should not be called again [Bug 1355942]
  346. * NS_SUPPRESS_COMPILATION -
  347. * Marks the commands in this namespace for not being compiled,
  348. * forcing them to be looked up every time.
  349. */
  350. #define NS_DYING 0x01
  351. #define NS_DEAD 0x02
  352. #define NS_KILLED 0x04
  353. #define NS_SUPPRESS_COMPILATION 0x08
  354. /*
  355. * Flags passed to TclGetNamespaceForQualName:
  356. *
  357. * TCL_GLOBAL_ONLY - (see tcl.h) Look only in the global ns.
  358. * TCL_NAMESPACE_ONLY - (see tcl.h) Look only in the context ns.
  359. * TCL_CREATE_NS_IF_UNKNOWN - Create unknown namespaces.
  360. * TCL_FIND_ONLY_NS - The name sought is a namespace name.
  361. */
  362. #define TCL_CREATE_NS_IF_UNKNOWN 0x800
  363. #define TCL_FIND_ONLY_NS 0x1000
  364. /*
  365. * The client data for an ensemble command. This consists of the table of
  366. * commands that are actually exported by the namespace, and an epoch counter
  367. * that, combined with the exportLookupEpoch field of the namespace structure,
  368. * defines whether the table contains valid data or will need to be recomputed
  369. * next time the ensemble command is called.
  370. */
  371. typedef struct EnsembleConfig {
  372. Namespace *nsPtr; /* The namespace backing this ensemble up. */
  373. Tcl_Command token; /* The token for the command that provides
  374. * ensemble support for the namespace, or NULL
  375. * if the command has been deleted (or never
  376. * existed; the global namespace never has an
  377. * ensemble command.) */
  378. int epoch; /* The epoch at which this ensemble's table of
  379. * exported commands is valid. */
  380. char **subcommandArrayPtr; /* Array of ensemble subcommand names. At all
  381. * consistent points, this will have the same
  382. * number of entries as there are entries in
  383. * the subcommandTable hash. */
  384. Tcl_HashTable subcommandTable;
  385. /* Hash table of ensemble subcommand names,
  386. * which are its keys so this also provides
  387. * the storage management for those subcommand
  388. * names. The contents of the entry values are
  389. * object version the prefix lists to use when
  390. * substituting for the command/subcommand to
  391. * build the ensemble implementation command.
  392. * Has to be stored here as well as in
  393. * subcommandDict because that field is NULL
  394. * when we are deriving the ensemble from the
  395. * namespace exports list. FUTURE WORK: use
  396. * object hash table here. */
  397. struct EnsembleConfig *next;/* The next ensemble in the linked list of
  398. * ensembles associated with a namespace. If
  399. * this field points to this ensemble, the
  400. * structure has already been unlinked from
  401. * all lists, and cannot be found by scanning
  402. * the list from the namespace's ensemble
  403. * field. */
  404. int flags; /* ORed combo of TCL_ENSEMBLE_PREFIX,
  405. * ENSEMBLE_DEAD and ENSEMBLE_COMPILE. */
  406. /* OBJECT FIELDS FOR ENSEMBLE CONFIGURATION */
  407. Tcl_Obj *subcommandDict; /* Dictionary providing mapping from
  408. * subcommands to their implementing command
  409. * prefixes, or NULL if we are to build the
  410. * map automatically from the namespace
  411. * exports. */
  412. Tcl_Obj *subcmdList; /* List of commands that this ensemble
  413. * actually provides, and whose implementation
  414. * will be built using the subcommandDict (if
  415. * present and defined) and by simple mapping
  416. * to the namespace otherwise. If NULL,
  417. * indicates that we are using the (dynamic)
  418. * list of currently exported commands. */
  419. Tcl_Obj *unknownHandler; /* Script prefix used to handle the case when
  420. * no match is found (according to the rule
  421. * defined by flag bit TCL_ENSEMBLE_PREFIX) or
  422. * NULL to use the default error-generating
  423. * behaviour. The script execution gets all
  424. * the arguments to the ensemble command
  425. * (including objv[0]) and will have the
  426. * results passed directly back to the caller
  427. * (including the error code) unless the code
  428. * is TCL_CONTINUE in which case the
  429. * subcommand will be reparsed by the ensemble
  430. * core, presumably because the ensemble
  431. * itself has been updated. */
  432. Tcl_Obj *parameterList; /* List of ensemble parameter names. */
  433. int numParameters; /* Cached number of parameters. This is either
  434. * 0 (if the parameterList field is NULL) or
  435. * the length of the list in the parameterList
  436. * field. */
  437. } EnsembleConfig;
  438. /*
  439. * Various bits for the EnsembleConfig.flags field.
  440. */
  441. #define ENSEMBLE_DEAD 0x1 /* Flag value to say that the ensemble is dead
  442. * and on its way out. */
  443. #define ENSEMBLE_COMPILE 0x4 /* Flag to enable bytecode compilation of an
  444. * ensemble. */
  445. /*
  446. *----------------------------------------------------------------
  447. * Data structures related to variables. These are used primarily in tclVar.c
  448. *----------------------------------------------------------------
  449. */
  450. /*
  451. * The following structure defines a variable trace, which is used to invoke a
  452. * specific C procedure whenever certain operations are performed on a
  453. * variable.
  454. */
  455. typedef struct VarTrace {
  456. Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given by
  457. * flags are performed on variable. */
  458. ClientData clientData; /* Argument to pass to proc. */
  459. int flags; /* What events the trace procedure is
  460. * interested in: OR-ed combination of
  461. * TCL_TRACE_READS, TCL_TRACE_WRITES,
  462. * TCL_TRACE_UNSETS and TCL_TRACE_ARRAY. */
  463. struct VarTrace *nextPtr; /* Next in list of traces associated with a
  464. * particular variable. */
  465. } VarTrace;
  466. /*
  467. * The following structure defines a command trace, which is used to invoke a
  468. * specific C procedure whenever certain operations are performed on a
  469. * command.
  470. */
  471. typedef struct CommandTrace {
  472. Tcl_CommandTraceProc *traceProc;
  473. /* Procedure to call when operations given by
  474. * flags are performed on command. */
  475. ClientData clientData; /* Argument to pass to proc. */
  476. int flags; /* What events the trace procedure is
  477. * interested in: OR-ed combination of
  478. * TCL_TRACE_RENAME, TCL_TRACE_DELETE. */
  479. struct CommandTrace *nextPtr;
  480. /* Next in list of traces associated with a
  481. * particular command. */
  482. int refCount; /* Used to ensure this structure is not
  483. * deleted too early. Keeps track of how many
  484. * pieces of code have a pointer to this
  485. * structure. */
  486. } CommandTrace;
  487. /*
  488. * When a command trace is active (i.e. its associated procedure is executing)
  489. * one of the following structures is linked into a list associated with the
  490. * command's interpreter. The information in the structure is needed in order
  491. * for Tcl to behave reasonably if traces are deleted while traces are active.
  492. */
  493. typedef struct ActiveCommandTrace {
  494. struct Command *cmdPtr; /* Command that's being traced. */
  495. struct ActiveCommandTrace *nextPtr;
  496. /* Next in list of all active command traces
  497. * for the interpreter, or NULL if no more. */
  498. CommandTrace *nextTracePtr; /* Next trace to check after current trace
  499. * procedure returns; if this trace gets
  500. * deleted, must update pointer to avoid using
  501. * free'd memory. */
  502. int reverseScan; /* Boolean set true when traces are scanning
  503. * in reverse order. */
  504. } ActiveCommandTrace;
  505. /*
  506. * When a variable trace is active (i.e. its associated procedure is
  507. * executing) one of the following structures is linked into a list associated
  508. * with the variable's interpreter. The information in the structure is needed
  509. * in order for Tcl to behave reasonably if traces are deleted while traces
  510. * are active.
  511. */
  512. typedef struct ActiveVarTrace {
  513. struct Var *varPtr; /* Variable that's being traced. */
  514. struct ActiveVarTrace *nextPtr;
  515. /* Next in list of all active variable traces
  516. * for the interpreter, or NULL if no more. */
  517. VarTrace *nextTracePtr; /* Next trace to check after current trace
  518. * procedure returns; if this trace gets
  519. * deleted, must update pointer to avoid using
  520. * free'd memory. */
  521. } ActiveVarTrace;
  522. /*
  523. * The structure below defines a variable, which associates a string name with
  524. * a Tcl_Obj value. These structures are kept in procedure call frames (for
  525. * local variables recognized by the compiler) or in the heap (for global
  526. * variables and any variable not known to the compiler). For each Var
  527. * structure in the heap, a hash table entry holds the variable name and a
  528. * pointer to the Var structure.
  529. */
  530. typedef struct Var {
  531. int flags; /* Miscellaneous bits of information about
  532. * variable. See below for definitions. */
  533. union {
  534. Tcl_Obj *objPtr; /* The variable's object value. Used for
  535. * scalar variables and array elements. */
  536. TclVarHashTable *tablePtr;/* For array variables, this points to
  537. * information about the hash table used to
  538. * implement the associative array. Points to
  539. * ckalloc-ed data. */
  540. struct Var *linkPtr; /* If this is a global variable being referred
  541. * to in a procedure, or a variable created by
  542. * "upvar", this field points to the
  543. * referenced variable's Var struct. */
  544. } value;
  545. } Var;
  546. typedef struct VarInHash {
  547. Var var;
  548. int refCount; /* Counts number of active uses of this
  549. * variable: 1 for the entry in the hash
  550. * table, 1 for each additional variable whose
  551. * linkPtr points here, 1 for each nested
  552. * trace active on variable, and 1 if the
  553. * variable is a namespace variable. This
  554. * record can't be deleted until refCount
  555. * becomes 0. */
  556. Tcl_HashEntry entry; /* The hash table entry that refers to this
  557. * variable. This is used to find the name of
  558. * the variable and to delete it from its
  559. * hashtable if it is no longer needed. It
  560. * also holds the variable's name. */
  561. } VarInHash;
  562. /*
  563. * Flag bits for variables. The first two (VAR_ARRAY and VAR_LINK) are
  564. * mutually exclusive and give the "type" of the variable. If none is set,
  565. * this is a scalar variable.
  566. *
  567. * VAR_ARRAY - 1 means this is an array variable rather than
  568. * a scalar variable or link. The "tablePtr"
  569. * field points to the array's hashtable for its
  570. * elements.
  571. * VAR_LINK - 1 means this Var structure contains a pointer
  572. * to another Var structure that either has the
  573. * real value or is itself another VAR_LINK
  574. * pointer. Variables like this come about
  575. * through "upvar" and "global" commands, or
  576. * through references to variables in enclosing
  577. * namespaces.
  578. *
  579. * Flags that indicate the type and status of storage; none is set for
  580. * compiled local variables (Var structs).
  581. *
  582. * VAR_IN_HASHTABLE - 1 means this variable is in a hashtable and
  583. * the Var structure is malloced. 0 if it is a
  584. * local variable that was assigned a slot in a
  585. * procedure frame by the compiler so the Var
  586. * storage is part of the call frame.
  587. * VAR_DEAD_HASH 1 means that this var's entry in the hashtable
  588. * has already been deleted.
  589. * VAR_ARRAY_ELEMENT - 1 means that this variable is an array
  590. * element, so it is not legal for it to be an
  591. * array itself (the VAR_ARRAY flag had better
  592. * not be set).
  593. * VAR_NAMESPACE_VAR - 1 means that this variable was declared as a
  594. * namespace variable. This flag ensures it
  595. * persists until its namespace is destroyed or
  596. * until the variable is unset; it will persist
  597. * even if it has not been initialized and is
  598. * marked undefined. The variable's refCount is
  599. * incremented to reflect the "reference" from
  600. * its namespace.
  601. *
  602. * Flag values relating to the variable's trace and search status.
  603. *
  604. * VAR_TRACED_READ
  605. * VAR_TRACED_WRITE
  606. * VAR_TRACED_UNSET
  607. * VAR_TRACED_ARRAY
  608. * VAR_TRACE_ACTIVE - 1 means that trace processing is currently
  609. * underway for a read or write access, so new
  610. * read or write accesses should not cause trace
  611. * procedures to be called and the variable can't
  612. * be deleted.
  613. * VAR_SEARCH_ACTIVE
  614. *
  615. * The following additional flags are used with the CompiledLocal type defined
  616. * below:
  617. *
  618. * VAR_ARGUMENT - 1 means that this variable holds a procedure
  619. * argument.
  620. * VAR_TEMPORARY - 1 if the local variable is an anonymous
  621. * temporary variable. Temporaries have a NULL
  622. * name.
  623. * VAR_RESOLVED - 1 if name resolution has been done for this
  624. * variable.
  625. * VAR_IS_ARGS 1 if this variable is the last argument and is
  626. * named "args".
  627. */
  628. /*
  629. * FLAGS RENUMBERED: everything breaks already, make things simpler.
  630. *
  631. * IMPORTANT: skip the values 0x10, 0x20, 0x40, 0x800 corresponding to
  632. * TCL_TRACE_(READS/WRITES/UNSETS/ARRAY): makes code simpler in tclTrace.c
  633. *
  634. * Keep the flag values for VAR_ARGUMENT and VAR_TEMPORARY so that old values
  635. * in precompiled scripts keep working.
  636. */
  637. /* Type of value (0 is scalar) */
  638. #define VAR_ARRAY 0x1
  639. #define VAR_LINK 0x2
  640. /* Type of storage (0 is compiled local) */
  641. #define VAR_IN_HASHTABLE 0x4
  642. #define VAR_DEAD_HASH 0x8
  643. #define VAR_ARRAY_ELEMENT 0x1000
  644. #define VAR_NAMESPACE_VAR 0x80 /* KEEP OLD VALUE for Itcl */
  645. #define VAR_ALL_HASH \
  646. (VAR_IN_HASHTABLE|VAR_DEAD_HASH|VAR_NAMESPACE_VAR|VAR_ARRAY_ELEMENT)
  647. /* Trace and search state. */
  648. #define VAR_TRACED_READ 0x10 /* TCL_TRACE_READS */
  649. #define VAR_TRACED_WRITE 0x20 /* TCL_TRACE_WRITES */
  650. #define VAR_TRACED_UNSET 0x40 /* TCL_TRACE_UNSETS */
  651. #define VAR_TRACED_ARRAY 0x800 /* TCL_TRACE_ARRAY */
  652. #define VAR_TRACE_ACTIVE 0x2000
  653. #define VAR_SEARCH_ACTIVE 0x4000
  654. #define VAR_ALL_TRACES \
  655. (VAR_TRACED_READ|VAR_TRACED_WRITE|VAR_TRACED_ARRAY|VAR_TRACED_UNSET)
  656. /* Special handling on initialisation (only CompiledLocal). */
  657. #define VAR_ARGUMENT 0x100 /* KEEP OLD VALUE! See tclProc.c */
  658. #define VAR_TEMPORARY 0x200 /* KEEP OLD VALUE! See tclProc.c */
  659. #define VAR_IS_ARGS 0x400
  660. #define VAR_RESOLVED 0x8000
  661. /*
  662. * Macros to ensure that various flag bits are set properly for variables.
  663. * The ANSI C "prototypes" for these macros are:
  664. *
  665. * MODULE_SCOPE void TclSetVarScalar(Var *varPtr);
  666. * MODULE_SCOPE void TclSetVarArray(Var *varPtr);
  667. * MODULE_SCOPE void TclSetVarLink(Var *varPtr);
  668. * MODULE_SCOPE void TclSetVarArrayElement(Var *varPtr);
  669. * MODULE_SCOPE void TclSetVarUndefined(Var *varPtr);
  670. * MODULE_SCOPE void TclClearVarUndefined(Var *varPtr);
  671. */
  672. #define TclSetVarScalar(varPtr) \
  673. (varPtr)->flags &= ~(VAR_ARRAY|VAR_LINK)
  674. #define TclSetVarArray(varPtr) \
  675. (varPtr)->flags = ((varPtr)->flags & ~VAR_LINK) | VAR_ARRAY
  676. #define TclSetVarLink(varPtr) \
  677. (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_LINK
  678. #define TclSetVarArrayElement(varPtr) \
  679. (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
  680. #define TclSetVarUndefined(varPtr) \
  681. (varPtr)->flags &= ~(VAR_ARRAY|VAR_LINK);\
  682. (varPtr)->value.objPtr = NULL
  683. #define TclClearVarUndefined(varPtr)
  684. #define TclSetVarTraceActive(varPtr) \
  685. (varPtr)->flags |= VAR_TRACE_ACTIVE
  686. #define TclClearVarTraceActive(varPtr) \
  687. (varPtr)->flags &= ~VAR_TRACE_ACTIVE
  688. #define TclSetVarNamespaceVar(varPtr) \
  689. if (!TclIsVarNamespaceVar(varPtr)) {\
  690. (varPtr)->flags |= VAR_NAMESPACE_VAR;\
  691. if (TclIsVarInHash(varPtr)) {\
  692. ((VarInHash *)(varPtr))->refCount++;\
  693. }\
  694. }
  695. #define TclClearVarNamespaceVar(varPtr) \
  696. if (TclIsVarNamespaceVar(varPtr)) {\
  697. (varPtr)->flags &= ~VAR_NAMESPACE_VAR;\
  698. if (TclIsVarInHash(varPtr)) {\
  699. ((VarInHash *)(varPtr))->refCount--;\
  700. }\
  701. }
  702. /*
  703. * Macros to read various flag bits of variables.
  704. * The ANSI C "prototypes" for these macros are:
  705. *
  706. * MODULE_SCOPE int TclIsVarScalar(Var *varPtr);
  707. * MODULE_SCOPE int TclIsVarLink(Var *varPtr);
  708. * MODULE_SCOPE int TclIsVarArray(Var *varPtr);
  709. * MODULE_SCOPE int TclIsVarUndefined(Var *varPtr);
  710. * MODULE_SCOPE int TclIsVarArrayElement(Var *varPtr);
  711. * MODULE_SCOPE int TclIsVarTemporary(Var *varPtr);
  712. * MODULE_SCOPE int TclIsVarArgument(Var *varPtr);
  713. * MODULE_SCOPE int TclIsVarResolved(Var *varPtr);
  714. */
  715. #define TclIsVarScalar(varPtr) \
  716. !((varPtr)->flags & (VAR_ARRAY|VAR_LINK))
  717. #define TclIsVarLink(varPtr) \
  718. ((varPtr)->flags & VAR_LINK)
  719. #define TclIsVarArray(varPtr) \
  720. ((varPtr)->flags & VAR_ARRAY)
  721. #define TclIsVarUndefined(varPtr) \
  722. ((varPtr)->value.objPtr == NULL)
  723. #define TclIsVarArrayElement(varPtr) \
  724. ((varPtr)->flags & VAR_ARRAY_ELEMENT)
  725. #define TclIsVarNamespaceVar(varPtr) \
  726. ((varPtr)->flags & VAR_NAMESPACE_VAR)
  727. #define TclIsVarTemporary(varPtr) \
  728. ((varPtr)->flags & VAR_TEMPORARY)
  729. #define TclIsVarArgument(varPtr) \
  730. ((varPtr)->flags & VAR_ARGUMENT)
  731. #define TclIsVarResolved(varPtr) \
  732. ((varPtr)->flags & VAR_RESOLVED)
  733. #define TclIsVarTraceActive(varPtr) \
  734. ((varPtr)->flags & VAR_TRACE_ACTIVE)
  735. #define TclIsVarTraced(varPtr) \
  736. ((varPtr)->flags & VAR_ALL_TRACES)
  737. #define TclIsVarInHash(varPtr) \
  738. ((varPtr)->flags & VAR_IN_HASHTABLE)
  739. #define TclIsVarDeadHash(varPtr) \
  740. ((varPtr)->flags & VAR_DEAD_HASH)
  741. #define TclGetVarNsPtr(varPtr) \
  742. (TclIsVarInHash(varPtr) \
  743. ? ((TclVarHashTable *) ((((VarInHash *) (varPtr))->entry.tablePtr)))->nsPtr \
  744. : NULL)
  745. #define VarHashRefCount(varPtr) \
  746. ((VarInHash *) (varPtr))->refCount
  747. /*
  748. * Macros for direct variable access by TEBC.
  749. */
  750. #define TclIsVarDirectReadable(varPtr) \
  751. ( !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ)) \
  752. && (varPtr)->value.objPtr)
  753. #define TclIsVarDirectWritable(varPtr) \
  754. !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_WRITE|VAR_DEAD_HASH))
  755. #define TclIsVarDirectUnsettable(varPtr) \
  756. !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ|VAR_TRACED_WRITE|VAR_TRACED_UNSET|VAR_DEAD_HASH))
  757. #define TclIsVarDirectModifyable(varPtr) \
  758. ( !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ|VAR_TRACED_WRITE)) \
  759. && (varPtr)->value.objPtr)
  760. #define TclIsVarDirectReadable2(varPtr, arrayPtr) \
  761. (TclIsVarDirectReadable(varPtr) &&\
  762. (!(arrayPtr) || !((arrayPtr)->flags & VAR_TRACED_READ)))
  763. #define TclIsVarDirectWritable2(varPtr, arrayPtr) \
  764. (TclIsVarDirectWritable(varPtr) &&\
  765. (!(arrayPtr) || !((arrayPtr)->flags & VAR_TRACED_WRITE)))
  766. #define TclIsVarDirectModifyable2(varPtr, arrayPtr) \
  767. (TclIsVarDirectModifyable(varPtr) &&\
  768. (!(arrayPtr) || !((arrayPtr)->flags & (VAR_TRACED_READ|VAR_TRACED_WRITE))))
  769. /*
  770. *----------------------------------------------------------------
  771. * Data structures related to procedures. These are used primarily in
  772. * tclProc.c, tclCompile.c, and tclExecute.c.
  773. *----------------------------------------------------------------
  774. */
  775. #if defined(__GNUC__) && (__GNUC__ > 2)
  776. # define TCLFLEXARRAY 0
  777. #else
  778. # define TCLFLEXARRAY 1
  779. #endif
  780. /*
  781. * Forward declaration to prevent an error when the forward reference to
  782. * Command is encountered in the Proc and ImportRef types declared below.
  783. */
  784. struct Command;
  785. /*
  786. * The variable-length structure below describes a local variable of a
  787. * procedure that was recognized by the compiler. These variables have a name,
  788. * an element in the array of compiler-assigned local variables in the
  789. * procedure's call frame, and various other items of information. If the
  790. * local variable is a formal argument, it may also have a default value. The
  791. * compiler can't recognize local variables whose names are expressions (these
  792. * names are only known at runtime when the expressions are evaluated) or
  793. * local variables that are created as a result of an "upvar" or "uplevel"
  794. * command. These other local variables are kept separately in a hash table in
  795. * the call frame.
  796. */
  797. typedef struct CompiledLocal {
  798. struct CompiledLocal *nextPtr;
  799. /* Next compiler-recognized local variable for
  800. * this procedure, or NULL if this is the last
  801. * local. */
  802. int nameLength; /* The number of bytes in local variable's name.
  803. * Among others used to speed up var lookups. */
  804. int frameIndex; /* Index in the array of compiler-assigned
  805. * variables in the procedure call frame. */
  806. int flags; /* Flag bits for the local variable. Same as
  807. * the flags for the Var structure above,
  808. * although only VAR_ARGUMENT, VAR_TEMPORARY,
  809. * and VAR_RESOLVED make sense. */
  810. Tcl_Obj *defValuePtr; /* Pointer to the default value of an
  811. * argument, if any. NULL if not an argument
  812. * or, if an argument, no default value. */
  813. Tcl_ResolvedVarInfo *resolveInfo;
  814. /* Customized variable resolution info
  815. * supplied by the Tcl_ResolveCompiledVarProc
  816. * associated with a namespace. Each variable
  817. * is marked by a unique ClientData tag during
  818. * compilation, and that same tag is used to
  819. * find the variable at runtime. */
  820. char name[TCLFLEXARRAY]; /* Name of the local variable starts here. If
  821. * the name is NULL, this will just be '\0'.
  822. * The actual size of this field will be large
  823. * enough to hold the name. MUST BE THE LAST
  824. * FIELD IN THE STRUCTURE! */
  825. } CompiledLocal;
  826. /*
  827. * The structure below defines a command procedure, which consists of a
  828. * collection of Tcl commands plus information about arguments and other local
  829. * variables recognized at compile time.
  830. */
  831. typedef struct Proc {
  832. struct Interp *iPtr; /* Interpreter for which this command is
  833. * defined. */
  834. int refCount; /* Reference count: 1 if still present in
  835. * command table plus 1 for each call to the
  836. * procedure that is currently active. This
  837. * structure can be freed when refCount
  838. * becomes zero. */
  839. struct Command *cmdPtr; /* Points to the Command structure for this
  840. * procedure. This is used to get the
  841. * namespace in which to execute the
  842. * procedure. */
  843. Tcl_Obj *bodyPtr; /* Points to the ByteCode object for
  844. * procedure's body command. */
  845. int numArgs; /* Number of formal parameters. */
  846. int numCompiledLocals; /* Count of local variables recognized by the
  847. * compiler including arguments and
  848. * temporaries. */
  849. CompiledLocal *firstLocalPtr;
  850. /* Pointer to first of the procedure's
  851. * compiler-allocated local variables, or NULL
  852. * if none. The first numArgs entries in this
  853. * list describe the procedure's formal
  854. * arguments. */
  855. CompiledLocal *lastLocalPtr;/* Pointer to the last allocated local
  856. * variable or NULL if none. This has frame
  857. * index (numCompiledLocals-1). */
  858. } Proc;
  859. /*
  860. * The type of functions called to process errors found during the execution
  861. * of a procedure (or lambda term or ...).
  862. */
  863. typedef void (ProcErrorProc)(Tcl_Interp *interp, Tcl_Obj *procNameObj);
  864. /*
  865. * The structure below defines a command trace. This is used to allow Tcl
  866. * clients to find out whenever a command is about to be executed.
  867. */
  868. typedef struct Trace {
  869. int level; /* Only trace commands at nesting level less
  870. * than or equal to this. */
  871. Tcl_CmdObjTraceProc *proc; /* Procedure to call to trace command. */
  872. ClientData clientData; /* Arbitrary value to pass to proc. */
  873. struct Trace *nextPtr; /* Next in list of traces for this interp. */
  874. int flags; /* Flags governing the trace - see
  875. * Tcl_CreateObjTrace for details. */
  876. Tcl_CmdObjTraceDeleteProc *delProc;
  877. /* Procedure to call when trace is deleted. */
  878. } Trace;
  879. /*
  880. * When an interpreter trace is active (i.e. its associated procedure is
  881. * executing), one of the following structures is linked into a list
  882. * associated with the interpreter. The information in the structure is needed
  883. * in order for Tcl to behave reasonably if traces are deleted while traces
  884. * are active.
  885. */
  886. typedef struct ActiveInterpTrace {
  887. struct ActiveInterpTrace *nextPtr;
  888. /* Next in list of all active command traces
  889. * for the interpreter, or NULL if no more. */
  890. Trace *nextTracePtr; /* Next trace to check after current trace
  891. * procedure returns; if this trace gets
  892. * deleted, must update pointer to avoid using
  893. * free'd memory. */
  894. int reverseScan; /* Boolean set true when traces are scanning
  895. * in reverse order. */
  896. } ActiveInterpTrace;
  897. /*
  898. * Flag values designating types of execution traces. See tclTrace.c for
  899. * related flag values.
  900. *
  901. * TCL_TRACE_ENTER_EXEC - triggers enter/enterstep traces.
  902. * - passed to Tcl_CreateObjTrace to set up
  903. * "enterstep" traces.
  904. * TCL_TRACE_LEAVE_EXEC - triggers leave/leavestep traces.
  905. * - passed to Tcl_CreateObjTrace to set up
  906. * "leavestep" traces.
  907. */
  908. #define TCL_TRACE_ENTER_EXEC 1
  909. #define TCL_TRACE_LEAVE_EXEC 2
  910. /*
  911. * The structure below defines an entry in the assocData hash table which is
  912. * associated with an interpreter. The entry contains a pointer to a function
  913. * to call when the interpreter is deleted, and a pointer to a user-defined
  914. * piece of data.
  915. */
  916. typedef struct AssocData {
  917. Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */
  918. ClientData clientData; /* Value to pass to proc. */
  919. } AssocData;
  920. /*
  921. * The structure below defines a call frame. A call frame defines a naming
  922. * context for a procedure call: its local naming scope (for local variables)
  923. * and its global naming scope (a namespace, perhaps the global :: namespace).
  924. * A call frame can also define the naming context for a namespace eval or
  925. * namespace inscope command: the namespace in which the command's code should
  926. * execute. The Tcl_CallFrame structures exist only while procedures or
  927. * namespace eval/inscope's are being executed, and provide a kind of Tcl call
  928. * stack.
  929. *
  930. * WARNING!! The structure definition must be kept consistent with the
  931. * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
  932. */
  933. /*
  934. * Will be grown to contain: pointers to the varnames (allocated at the end),
  935. * plus the init values for each variable (suitable to be memcopied on init)
  936. */
  937. typedef struct LocalCache {
  938. int refCount;
  939. int numVars;
  940. Tcl_Obj *varName0;
  941. } LocalCache;
  942. #define localName(framePtr, i) \
  943. ((&((framePtr)->localCachePtr->varName0))[(i)])
  944. MODULE_SCOPE void TclFreeLocalCache(Tcl_Interp *interp,
  945. LocalCache *localCachePtr);
  946. typedef struct CallFrame {
  947. Namespace *nsPtr; /* Points to the namespace used to resolve
  948. * commands and global variables. */
  949. int isProcCallFrame; /* If 0, the frame was pushed to execute a
  950. * namespace command and var references are
  951. * treated as references to namespace vars;
  952. * varTablePtr and compiledLocals are ignored.
  953. * If FRAME_IS_PROC is set, the frame was
  954. * pushed to execute a Tcl procedure and may
  955. * have local vars. */
  956. int objc; /* This and objv below describe the arguments
  957. * for this procedure call. */
  958. Tcl_Obj *const *objv; /* Array of argument objects. */
  959. struct CallFrame *callerPtr;
  960. /* Value of interp->framePtr when this
  961. * procedure was invoked (i.e. next higher in
  962. * stack of all active procedures). */
  963. struct CallFrame *callerVarPtr;
  964. /* Value of interp->varFramePtr when this
  965. * procedure was invoked (i.e. determines
  966. * variable scoping within caller). Same as
  967. * callerPtr unless an "uplevel" command or
  968. * something equivalent was active in the
  969. * caller). */
  970. int level; /* Level of this procedure, for "uplevel"
  971. * purposes (i.e. corresponds to nesting of
  972. * callerVarPtr's, not callerPtr's). 1 for
  973. * outermost procedure, 0 for top-level. */
  974. Proc *procPtr; /* Points to the structure defining the called
  975. * procedure. Used to get information such as
  976. * the number of compiled local variables
  977. * (local variables assigned entries ["slots"]
  978. * in the compiledLocals array below). */
  979. TclVarHashTable *varTablePtr;
  980. /* Hash table containing local variables not
  981. * recognized by the compiler, or created at
  982. * execution time through, e.g., upvar.
  983. * Initially NULL and created if needed. */
  984. int numCompiledLocals; /* Count of local variables recognized by the
  985. * compiler including arguments. */
  986. Var *compiledLocals; /* Points to the array of local variables
  987. * recognized by the compiler. The compiler
  988. * emits code that refers to these variables
  989. * using an index into this array. */
  990. ClientData clientData; /* Pointer to some context that is used by
  991. * object systems. The meaning of the contents
  992. * of this field is defined by the code that
  993. * sets it, and it should only ever be set by
  994. * the code that is pushing the frame. In that
  995. * case, the code that sets it should also
  996. * have some means of discovering what the
  997. * meaning of the value is, which we do not
  998. * specify. */
  999. LocalCache *localCachePtr;
  1000. Tcl_Obj *tailcallPtr;
  1001. /* NULL if no tailcall is scheduled */
  1002. } CallFrame;
  1003. #define FRAME_IS_PROC 0x1
  1004. #define FRAME_IS_LAMBDA 0x2
  1005. #define FRAME_IS_METHOD 0x4 /* The frame is a method body, and the frame's
  1006. * clientData field contains a CallContext
  1007. * reference. Part of TIP#257. */
  1008. #define FRAME_IS_OO_DEFINE 0x8 /* The frame is part of the inside workings of
  1009. * the [oo::define] command; the clientData
  1010. * field contains an Object reference that has
  1011. * been confirmed to refer to a class. Part of
  1012. * TIP#257. */
  1013. /*
  1014. * TIP #280
  1015. * The structure below defines a command frame. A command frame provides
  1016. * location information for all commands executing a tcl script (source, eval,
  1017. * uplevel, procedure bodies, ...). The runtime structure essentially contains
  1018. * the stack trace as it would be if the currently executing command were to
  1019. * throw an error.
  1020. *
  1021. * For commands where it makes sense it refers to the associated CallFrame as
  1022. * well.
  1023. *
  1024. * The structures are chained in a single list, with the top of the stack
  1025. * anchored in the Interp structure.
  1026. *
  1027. * Instances can be allocated on the C stack, or the heap, the former making
  1028. * cleanup a bit simpler.
  1029. */
  1030. typedef struct CmdFrame {
  1031. /*
  1032. * General data. Always available.
  1033. */
  1034. int type; /* Values see below. */
  1035. int level; /* Number of frames in stack, prevent O(n)
  1036. * scan of list. */
  1037. int *line; /* Lines the words of the command start on. */
  1038. int nline;
  1039. CallFrame *framePtr; /* Procedure activation record, may be
  1040. * NULL. */
  1041. struct CmdFrame *nextPtr; /* Link to calling frame. */
  1042. /*
  1043. * Data needed for Eval vs TEBC
  1044. *
  1045. * EXECUTION CONTEXTS and usage of CmdFrame
  1046. *
  1047. * Field TEBC EvalEx
  1048. * ======= ==== ======
  1049. * level yes yes
  1050. * type BC/PREBC SRC/EVAL
  1051. * line0 yes yes
  1052. * framePtr yes yes
  1053. * ======= ==== ======
  1054. *
  1055. * ======= ==== ========= union data
  1056. * line1 - yes
  1057. * line3 - yes
  1058. * path - yes
  1059. * ------- ---- ------
  1060. * codePtr yes -
  1061. * pc yes -
  1062. * ======= ==== ======
  1063. *
  1064. * ======= ==== ========= union cmd
  1065. * str.cmd yes yes
  1066. * str.len yes yes
  1067. * ------- ---- ------
  1068. */
  1069. union {
  1070. struct {
  1071. Tcl_Obj *path; /* Path of the sourced file the command is
  1072. * in. */
  1073. } eval;
  1074. struct {
  1075. const void *codePtr;/* Byte code currently executed... */
  1076. const char *pc; /* ... and instruction pointer. */
  1077. } tebc;
  1078. } data;
  1079. Tcl_Obj *cmdObj;
  1080. const char *cmd; /* The executed command, if possible... */
  1081. int len; /* ... and its length. */
  1082. const struct CFWordBC *litarg;
  1083. /* Link to set of literal arguments which have
  1084. * ben pushed on the lineLABCPtr stack by
  1085. * TclArgumentBCEnter(). These will be removed
  1086. * by TclArgumentBCRelease. */
  1087. } CmdFrame;
  1088. typedef struct CFWord {
  1089. CmdFrame *framePtr; /* CmdFrame to access. */
  1090. int word; /* Index of the word in the command. */
  1091. int refCount; /* Number of times the word is on the
  1092. * stack. */
  1093. } CFWord;
  1094. typedef struct CFWordBC {
  1095. CmdFrame *framePtr; /* CmdFrame to access. */
  1096. int pc; /* Instruction pointer of a command in
  1097. * ExtCmdLoc.loc[.] */
  1098. int word; /* Index of word in
  1099. * ExtCmdLoc.loc[cmd]->line[.] */
  1100. struct CFWordBC *prevPtr; /* Previous entry in stack for same Tcl_Obj. */
  1101. struct CFWordBC *nextPtr; /* Next entry for same command call. See
  1102. * CmdFrame litarg field for the list start. */
  1103. Tcl_Obj *obj; /* Back reference to hashtable key */
  1104. } CFWordBC;
  1105. /*
  1106. * Structure to record the locations of invisible continuation lines in
  1107. * literal scripts, as character offset from the beginning of the script. Both
  1108. * compiler and direct evaluator use this information to adjust their line
  1109. * counters when tracking through the script, because when it is invoked the
  1110. * continuation line marker as a whole has been removed already, meaning that
  1111. * the \n which was part of it is gone as well, breaking regular line
  1112. * tracking.
  1113. *
  1114. * These structures are allocated and filled by both the function
  1115. * TclSubstTokens() in the file "tclParse.c" and its caller TclEvalEx() in the
  1116. * file "tclBasic.c", and stored in the thread-global hashtable "lineCLPtr" in
  1117. * file "tclObj.c". They are used by the functions TclSetByteCodeFromAny() and
  1118. * TclCompileScript(), both found in the file "tclCompile.c". Their memory is
  1119. * released by the function TclFreeObj(), in the file "tclObj.c", and also by
  1120. * the function TclThreadFinalizeObjects(), in the same file.
  1121. */
  1122. #define CLL_END (-1)
  1123. typedef struct ContLineLoc {
  1124. int num; /* Number of entries in loc, not counting the
  1125. * final -1 marker entry. */
  1126. int loc[TCLFLEXARRAY];/* Table of locations, as character offsets.
  1127. * The table is allocated as part of the
  1128. * structure, extending behind the nominal end
  1129. * of the structure. An entry containing the
  1130. * value -1 is put after the last location, as
  1131. * end-marker/sentinel. */
  1132. } ContLineLoc;
  1133. /*
  1134. * The following macros define the allowed values for the type field of the
  1135. * CmdFrame structure above. Some of the values occur only in the extended
  1136. * location data referenced via the 'baseLocPtr'.
  1137. *
  1138. * TCL_LOCATION_EVAL : Frame is for a script evaluated by EvalEx.
  1139. * TCL_LOCATION_BC : Frame is for bytecode.
  1140. * TCL_LOCATION_PREBC : Frame is for precompiled bytecode.
  1141. * TCL_LOCATION_SOURCE : Frame is for a script evaluated by EvalEx, from a
  1142. * sourced file.
  1143. * TCL_LOCATION_PROC : Frame is for bytecode of a procedure.
  1144. *
  1145. * A TCL_LOCATION_BC type in a frame can be overridden by _SOURCE and _PROC
  1146. * types, per the context of the byte code in execution.
  1147. */
  1148. #define TCL_LOCATION_EVAL (0) /* Location in a dynamic eval script. */
  1149. #define TCL_LOCATION_BC (2) /* Location in byte code. */
  1150. #define TCL_LOCATION_PREBC (3) /* Location in precompiled byte code, no
  1151. * location. */
  1152. #define TCL_LOCATION_SOURCE (4) /* Location in a file. */
  1153. #define TCL_LOCATION_PROC (5) /* Location in a dynamic proc. */
  1154. #define TCL_LOCATION_LAST (6) /* Number of values in the enum. */
  1155. /*
  1156. * Structure passed to describe procedure-like "procedures" that are not
  1157. * procedures (e.g. a lambda) so that their details can be reported correctly
  1158. * by [info frame]. Contains a sub-structure for each extra field.
  1159. */
  1160. typedef Tcl_Obj * (GetFrameInfoValueProc)(ClientData clientData);
  1161. typedef struct {
  1162. const char *name; /* Name of this field. */
  1163. GetFrameInfoValueProc *proc; /* Function to generate a Tcl_Obj* from the
  1164. * clientData, or just use the clientData
  1165. * directly (after casting) if NULL. */
  1166. ClientData clientData; /* Context for above function, or Tcl_Obj* if
  1167. * proc field is NULL. */
  1168. } ExtraFrameInfoField;
  1169. typedef struct {
  1170. int length; /* Length of array. */
  1171. ExtraFrameInfoField fields[2];
  1172. /* Really as long as necessary, but this is
  1173. * long enough for nearly anything. */
  1174. } ExtraFrameInfo;
  1175. /*
  1176. *----------------------------------------------------------------
  1177. * Data structures and procedures related to TclHandles, which are a very
  1178. * lightweight method of preserving enough information to determine if an
  1179. * arbitrary malloc'd block has been deleted.
  1180. *----------------------------------------------------------------
  1181. */
  1182. typedef void **TclHandle;
  1183. /*
  1184. *----------------------------------------------------------------
  1185. * Experimental flag value passed to Tcl_GetRegExpFromObj. Intended for use
  1186. * only by Expect. It will probably go away in a later release.
  1187. *----------------------------------------------------------------
  1188. */
  1189. #define TCL_REG_BOSONLY 002000 /* Prepend \A to pattern so it only matches at
  1190. * the beginning of the string. */
  1191. /*
  1192. * These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet
  1193. * when threads are used, or an emulation if there are no threads. These are
  1194. * really internal and Tcl clients should use Tcl_GetThreadData.
  1195. */
  1196. MODULE_SCOPE void * TclThreadDataKeyGet(Tcl_ThreadDataKey *keyPtr);
  1197. MODULE_SCOPE void TclThreadDataKeySet(Tcl_ThreadDataKey *keyPtr,
  1198. void *data);
  1199. /*
  1200. * This is a convenience macro used to initialize a thread local storage ptr.
  1201. */
  1202. #define TCL_TSD_INIT(keyPtr) \
  1203. (ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData))
  1204. /*
  1205. *----------------------------------------------------------------
  1206. * Data structures related to bytecode compilation and execution. These are
  1207. * used primarily in tclCompile.c, tclExecute.c, and tclBasic.c.
  1208. *----------------------------------------------------------------
  1209. */
  1210. /*
  1211. * Forward declaration to prevent errors when the forward references to
  1212. * Tcl_Parse and CompileEnv are encountered in the procedure type CompileProc
  1213. * declared below.
  1214. */
  1215. struct CompileEnv;
  1216. /*
  1217. * The type of procedures called by the Tcl bytecode compiler to compile
  1218. * commands. Pointers to these procedures are kept in the Command structure
  1219. * describing each command. The integer value returned by a CompileProc must
  1220. * be one of the following:
  1221. *
  1222. * TCL_OK Compilation completed normally.
  1223. * TCL_ERROR Compilation could not be completed. This can be just a
  1224. * judgment by the CompileProc that the command is too
  1225. * complex to compile effectively, or it can indicate
  1226. * that in the current state of the interp, the command
  1227. * would raise an error. The bytecode compiler will not
  1228. * do any error reporting at compiler time. Error
  1229. * reporting is deferred until the actual runtime,
  1230. * because by then changes in the interp state may allow
  1231. * the command to be successfully evaluated.
  1232. * TCL_OUT_LINE_COMPILE A source-compatible alias for TCL_ERROR, kept for the
  1233. * sake of old code only.
  1234. */
  1235. #define TCL_OUT_LINE_COMPILE TCL_ERROR
  1236. typedef int (CompileProc)(Tcl_Interp *interp, Tcl_Parse *parsePtr,
  1237. struct Command *cmdPtr, struct CompileEnv *compEnvPtr);
  1238. /*
  1239. * The type of procedure called from the compilation hook point in
  1240. * SetByteCodeFromAny.
  1241. */
  1242. typedef int (CompileHookProc)(Tcl_Interp *interp,
  1243. struct CompileEnv *compEnvPtr, ClientData clientData);
  1244. /*
  1245. * The data structure for a (linked list of) execution stacks.
  1246. */
  1247. typedef struct ExecStack {
  1248. struct ExecStack *prevPtr;
  1249. struct ExecStack *nextPtr;
  1250. Tcl_Obj **markerPtr;
  1251. Tcl_Obj **endPtr;
  1252. Tcl_Obj **tosPtr;
  1253. Tcl_Obj *stackWords[TCLFLEXARRAY];
  1254. } ExecStack;
  1255. /*
  1256. * The data structure defining the execution environment for ByteCode's.
  1257. * There is one ExecEnv structure per Tcl interpreter. It holds the evaluation
  1258. * stack that holds command operands and results. The stack grows towards
  1259. * increasing addresses. The member stackPtr points to the stackItems of the
  1260. * currently active execution stack.
  1261. */
  1262. typedef struct CorContext {
  1263. struct CallFrame *framePtr;
  1264. struct CallFrame *varFramePtr;
  1265. struct CmdFrame *cmdFramePtr; /* See Interp.cmdFramePtr */
  1266. Tcl_HashTable *lineLABCPtr; /* See Interp.lineLABCPtr */
  1267. } CorContext;
  1268. typedef struct CoroutineData {
  1269. struct Command *cmdPtr; /* The command handle for the coroutine. */
  1270. struct ExecEnv *eePtr; /* The special execution environment (stacks,
  1271. * etc.) for the coroutine. */
  1272. struct ExecEnv *callerEEPtr;/* The execution environment for the caller of
  1273. * the coroutine, which might be the
  1274. * interpreter global environment or another
  1275. * coroutine. */
  1276. CorContext caller;
  1277. CorContext running;
  1278. Tcl_HashTable *lineLABCPtr; /* See Interp.lineLABCPtr */
  1279. void *stackLevel;
  1280. int auxNumLevels; /* While the coroutine is running the
  1281. * numLevels of the create/resume command is
  1282. * stored here; for suspended coroutines it
  1283. * holds the nesting numLevels at yield. */
  1284. int nargs; /* Number of args required for resuming this
  1285. * coroutine; -2 means "0 or 1" (default), -1
  1286. * means "any" */
  1287. } CoroutineData;
  1288. typedef struct ExecEnv {
  1289. ExecStack *execStackPtr; /* Points to the first item in the evaluation
  1290. * stack on the heap. */
  1291. Tcl_Obj *constants[2]; /* Pointers to constant "0" and "1" objs. */
  1292. struct Tcl_Interp *interp;
  1293. struct NRE_callback *callbackPtr;
  1294. /* Top callback in NRE's stack. */
  1295. struct CoroutineData *corPtr;
  1296. int rewind;
  1297. } ExecEnv;
  1298. #define COR_IS_SUSPENDED(corPtr) \
  1299. ((corPtr)->stackLevel == NULL)
  1300. /*
  1301. * The definitions for the LiteralTable and LiteralEntry structures. Each
  1302. * interpreter contains a LiteralTable. It is used to reduce the storage
  1303. * needed for all the Tcl objects that hold the literals of scripts compiled
  1304. * by the interpreter. A literal's object is shared by all the ByteCodes that
  1305. * refer to the literal. Each distinct literal has one LiteralEntry entry in
  1306. * the LiteralTable. A literal table is a specialized hash table that is
  1307. * indexed by the literal's string representation, which may contain null
  1308. * characters.
  1309. *
  1310. * Note that we reduce the space needed for literals by sharing literal
  1311. * objects both within a ByteCode (each ByteCode contains a local
  1312. * LiteralTable) and across all an interpreter's ByteCodes (with the
  1313. * interpreter's global LiteralTable).
  1314. */
  1315. typedef struct LiteralEntry {
  1316. struct LiteralEntry *nextPtr;
  1317. /* Points to next entry in this hash bucket or
  1318. * NULL if end of chain. */
  1319. Tcl_Obj *objPtr; /* Points to Tcl object that holds the
  1320. * literal's bytes and length. */
  1321. int refCount; /* If in an interpreter's global literal
  1322. * table, the number of ByteCode structures
  1323. * that share the literal object; the literal
  1324. * entry can be freed when refCount drops to
  1325. * 0. If in a local literal table, -1. */
  1326. Namespace *nsPtr; /* Namespace in which this literal is used. We
  1327. * try to avoid sharing literal non-FQ command
  1328. * names among different namespaces to reduce
  1329. * shimmering. */
  1330. } LiteralEntry;
  1331. typedef struct LiteralTable {
  1332. LiteralEntry **buckets; /* Pointer to bucket array. Each element
  1333. * points to first entry in bucket's hash
  1334. * chain, or NULL. */
  1335. LiteralEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
  1336. /* Bucket array used for small tables to avoid
  1337. * mallocs and frees. */
  1338. int numBuckets; /* Total number of buckets allocated at
  1339. * **buckets. */
  1340. int numEntries; /* Total number of entries present in
  1341. * table. */
  1342. int rebuildSize; /* Enlarge table when numEntries gets to be
  1343. * this large. */
  1344. int mask; /* Mask value used in hashing function. */
  1345. } LiteralTable;
  1346. /*
  1347. * The following structure defines for each Tcl interpreter various
  1348. * statistics-related information about the bytecode compiler and
  1349. * interpreter's operation in that interpreter.
  1350. */
  1351. #ifdef TCL_COMPILE_STATS
  1352. typedef struct ByteCodeStats {
  1353. long numExecutions; /* Number of ByteCodes executed. */
  1354. long numCompilations; /* Number of ByteCodes created. */
  1355. long numByteCodesFreed; /* Number of ByteCodes destroyed. */
  1356. long instructionCount[256]; /* Number of times each instruction was
  1357. * executed. */
  1358. double totalSrcBytes; /* Total source bytes ever compiled. */
  1359. double totalByteCodeBytes; /* Total bytes for all ByteCodes. */
  1360. double currentSrcBytes; /* Src bytes for all current ByteCodes. */
  1361. double currentByteCodeBytes;/* Code bytes in all current ByteCodes. */
  1362. long srcCount[32]; /* Source size distribution: # of srcs of
  1363. * size [2**(n-1)..2**n), n in [0..32). */
  1364. long byteCodeCount[32]; /* ByteCode size distribution. */
  1365. long lifetimeCount[32]; /* ByteCode lifetime distribution (ms). */
  1366. double currentInstBytes; /* Instruction bytes-current ByteCodes. */
  1367. double currentLitBytes; /* Current literal bytes. */
  1368. double currentExceptBytes; /* Current exception table bytes. */
  1369. double currentAuxBytes; /* Current auxiliary information bytes. */
  1370. double currentCmdMapBytes; /* Current src<->code map bytes. */
  1371. long numLiteralsCreated; /* Total literal objects ever compiled. */
  1372. double totalLitStringBytes; /* Total string bytes in all literals. */
  1373. double currentLitStringBytes;
  1374. /* String bytes in current literals. */
  1375. long literalCount[32]; /* Distribution of literal string sizes. */
  1376. } ByteCodeStats;
  1377. #endif /* TCL_COMPILE_STATS */
  1378. /*
  1379. * Structure used in implementation of those core ensembles which are
  1380. * partially compiled. Used as an array of these, with a terminating field
  1381. * whose 'name' is NULL.
  1382. */
  1383. typedef struct {
  1384. const char *name; /* The name of the subcommand. */
  1385. Tcl_ObjCmdProc *proc; /* The implementation of the subcommand. */
  1386. CompileProc *compileProc; /* The compiler for the subcommand. */
  1387. Tcl_ObjCmdProc *nreProc; /* NRE implementation of this command. */
  1388. ClientData clientData; /* Any clientData to give the command. */
  1389. int unsafe; /* Whether this command is to be hidden by
  1390. * default in a safe interpreter. */
  1391. } EnsembleImplMap;
  1392. /*
  1393. *----------------------------------------------------------------
  1394. * Data structures related to commands.
  1395. *----------------------------------------------------------------
  1396. */
  1397. /*
  1398. * An imported command is created in an namespace when it imports a "real"
  1399. * command from another namespace. An imported command has a Command structure
  1400. * that points (via its ClientData value) to the "real" Command structure in
  1401. * the source namespace's command table. The real command records all the
  1402. * imported commands that refer to it in a list of ImportRef structures so
  1403. * that they can be deleted when the real command is deleted.
  1404. */
  1405. typedef struct ImportRef {
  1406. struct Command *importedCmdPtr;
  1407. /* Points to the imported command created in
  1408. * an importing namespace; this command
  1409. * redirects its invocations to the "real"
  1410. * command. */
  1411. struct ImportRef *nextPtr; /* Next element on the linked list of imported
  1412. * commands that refer to the "real" command.
  1413. * The real command deletes these imported
  1414. * commands on this list when it is
  1415. * deleted. */
  1416. } ImportRef;
  1417. /*
  1418. * Data structure used as the ClientData of imported commands: commands
  1419. * created in an namespace when it imports a "real" command from another
  1420. * namespace.
  1421. */
  1422. typedef struct ImportedCmdData {
  1423. struct Command *realCmdPtr; /* "Real" command that this imported command
  1424. * refers to. */
  1425. struct Command *selfPtr; /* Pointer to this imported command. Needed
  1426. * only when deleting it in order to remove it
  1427. * from the real command's linked list of
  1428. * imported commands that refer to it. */
  1429. } ImportedCmdData;
  1430. /*
  1431. * A Command structure exists for each command in a namespace. The Tcl_Command
  1432. * opaque type actually refers to these structures.
  1433. */
  1434. typedef struct Command {
  1435. Tcl_HashEntry *hPtr; /* Pointer to the hash table entry that refers
  1436. * to this command. The hash table is either a
  1437. * namespace's command table or an
  1438. * interpreter's hidden command table. This
  1439. * pointer is used to get a command's name
  1440. * from its Tcl_Command handle. NULL means
  1441. * that the hash table entry has been removed
  1442. * already (this can happen if deleteProc
  1443. * causes the command to be deleted or
  1444. * recreated). */
  1445. Namespace *nsPtr; /* Points to the namespace containing this
  1446. * command. */
  1447. int refCount; /* 1 if in command hashtable plus 1 for each
  1448. * reference from a CmdName Tcl object
  1449. * representing a command's name in a ByteCode
  1450. * instruction sequence. This structure can be
  1451. * freed when refCount becomes zero. */
  1452. int cmdEpoch; /* Incremented to invalidate any references
  1453. * that point to this command when it is
  1454. * renamed, deleted, hidden, or exposed. */
  1455. CompileProc *compileProc; /* Procedure called to compile command. NULL
  1456. * if no compile proc exists for command. */
  1457. Tcl_ObjCmdProc *objProc; /* Object-based command procedure. */
  1458. ClientData objClientData; /* Arbitrary value passed to object proc. */
  1459. Tcl_CmdProc *proc; /* String-based command procedure. */
  1460. ClientData clientData; /* Arbitrary value passed to string proc. */
  1461. Tcl_CmdDeleteProc *deleteProc;
  1462. /* Procedure invoked when deleting command to,
  1463. * e.g., free all client data. */
  1464. ClientData deleteData; /* Arbitrary value passed to deleteProc. */
  1465. int flags; /* Miscellaneous bits of information about
  1466. * command. See below for definitions. */
  1467. ImportRef *importRefPtr; /* List of each imported Command created in
  1468. * another namespace when this command is
  1469. * imported. These imported commands redirect
  1470. * invocations back to this command. The list
  1471. * is used to remove all those imported
  1472. * commands when deleting this "real"
  1473. * command. */
  1474. CommandTrace *tracePtr; /* First in list of all traces set for this
  1475. * command. */
  1476. Tcl_ObjCmdProc *nreProc; /* NRE implementation of this command. */
  1477. } Command;
  1478. /*
  1479. * Flag bits for commands.
  1480. *
  1481. * CMD_IS_DELETED - Means that the command is in the process of
  1482. * being deleted (its deleteProc is currently
  1483. * executing). Other attempts to delete the
  1484. * command should be ignored.
  1485. * CMD_TRACE_ACTIVE - 1 means that trace processing is currently
  1486. * underway for a rename/delete change. See the
  1487. * two flags below for which is currently being
  1488. * processed.
  1489. * CMD_HAS_EXEC_TRACES - 1 means that this command has at least one
  1490. * execution trace (as opposed to simple
  1491. * delete/rename traces) in its tracePtr list.
  1492. * CMD_COMPILES_EXPANDED - 1 means that this command has a compiler that
  1493. * can handle expansion (provided it is not the
  1494. * first word).
  1495. * TCL_TRACE_RENAME - A rename trace is in progress. Further
  1496. * recursive renames will not be traced.
  1497. * TCL_TRACE_DELETE - A delete trace is in progress. Further
  1498. * recursive deletes will not be traced.
  1499. * (these last two flags are defined in tcl.h)
  1500. */
  1501. #define CMD_IS_DELETED 0x01
  1502. #define CMD_TRACE_ACTIVE 0x02
  1503. #define CMD_HAS_EXEC_TRACES 0x04
  1504. #define CMD_COMPILES_EXPANDED 0x08
  1505. #define CMD_REDEF_IN_PROGRESS 0x10
  1506. #define CMD_VIA_RESOLVER 0x20
  1507. #define CMD_DEAD 0x40
  1508. /*
  1509. *----------------------------------------------------------------
  1510. * Data structures related to name resolution procedures.
  1511. *----------------------------------------------------------------
  1512. */
  1513. /*
  1514. * The interpreter keeps a linked list of name resolution schemes. The scheme
  1515. * for a namespace is consulted first, followed by the list of schemes in an
  1516. * interpreter, followed by the default name resolution in Tcl. Schemes are
  1517. * added/removed from the interpreter's list by calling Tcl_AddInterpResolver
  1518. * and Tcl_RemoveInterpResolver.
  1519. */
  1520. typedef struct ResolverScheme {
  1521. char *name; /* Name identifying this scheme. */
  1522. Tcl_ResolveCmdProc *cmdResProc;
  1523. /* Procedure handling command name
  1524. * resolution. */
  1525. Tcl_ResolveVarProc *varResProc;
  1526. /* Procedure handling variable name resolution
  1527. * for variables that can only be handled at
  1528. * runtime. */
  1529. Tcl_ResolveCompiledVarProc *compiledVarResProc;
  1530. /* Procedure handling variable name resolution
  1531. * at compile time. */
  1532. struct ResolverScheme *nextPtr;
  1533. /* Pointer to next record in linked list. */
  1534. } ResolverScheme;
  1535. /*
  1536. * Forward declaration of the TIP#143 limit handler structure.
  1537. */
  1538. typedef struct LimitHandler LimitHandler;
  1539. /*
  1540. * TIP #268.
  1541. * Values for the selection mode, i.e the package require preferences.
  1542. */
  1543. enum PkgPreferOptions {
  1544. PKG_PREFER_LATEST, PKG_PREFER_STABLE
  1545. };
  1546. /*
  1547. *----------------------------------------------------------------
  1548. * This structure shadows the first few fields of the memory cache for the
  1549. * allocator defined in tclThreadAlloc.c; it has to be kept in sync with the
  1550. * definition there.
  1551. * Some macros require knowledge of some fields in the struct in order to
  1552. * avoid hitting the TSD unnecessarily. In order to facilitate this, a pointer
  1553. * to the relevant fields is kept in the allocCache field in struct Interp.
  1554. *----------------------------------------------------------------
  1555. */
  1556. typedef struct AllocCache {
  1557. struct Cache *nextPtr; /* Linked list of cache entries. */
  1558. Tcl_ThreadId owner; /* Which thread's cache is this? */
  1559. Tcl_Obj *firstObjPtr; /* List of free objects for thread. */
  1560. int numObjects; /* Number of objects for thread. */
  1561. } AllocCache;
  1562. /*
  1563. *----------------------------------------------------------------
  1564. * This structure defines an interpreter, which is a collection of commands
  1565. * plus other state information related to interpreting commands, such as
  1566. * variable storage. Primary responsibility for this data structure is in
  1567. * tclBasic.c, but almost every Tcl source file uses something in here.
  1568. *----------------------------------------------------------------
  1569. */
  1570. typedef struct Interp {
  1571. /*
  1572. * Note: the first three fields must match exactly the fields in a
  1573. * Tcl_Interp struct (see tcl.h). If you change one, be sure to change the
  1574. * other.
  1575. *
  1576. * The interpreter's result is held in both the string and the
  1577. * objResultPtr fields. These fields hold, respectively, the result's
  1578. * string or object value. The interpreter's result is always in the
  1579. * result field if that is non-empty, otherwise it is in objResultPtr.
  1580. * The two fields are kept consistent unless some C code sets
  1581. * interp->result directly. Programs should not access result and
  1582. * objResultPtr directly; instead, they should always get and set the
  1583. * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult, and
  1584. * Tcl_GetStringResult. See the SetResult man page for details.
  1585. */
  1586. char *result; /* If the last command returned a string
  1587. * result, this points to it. Should not be
  1588. * accessed directly; see comment above. */
  1589. Tcl_FreeProc *freeProc; /* Zero means a string result is statically
  1590. * allocated. TCL_DYNAMIC means string result
  1591. * was allocated with ckalloc and should be
  1592. * freed with ckfree. Other values give
  1593. * address of procedure to invoke to free the
  1594. * string result. Tcl_Eval must free it before
  1595. * executing next command. */
  1596. int errorLine; /* When TCL_ERROR is returned, this gives the
  1597. * line number in the command where the error
  1598. * occurred (1 means first line). */
  1599. const struct TclStubs *stubTable;
  1600. /* Pointer to the exported Tcl stub table. On
  1601. * previous versions of Tcl this is a pointer
  1602. * to the objResultPtr or a pointer to a
  1603. * buckets array in a hash table. We therefore
  1604. * have to do some careful checking before we
  1605. * can use this. */
  1606. TclHandle handle; /* Handle used to keep track of when this
  1607. * interp is deleted. */
  1608. Namespace *globalNsPtr; /* The interpreter's global namespace. */
  1609. Tcl_HashTable *hiddenCmdTablePtr;
  1610. /* Hash table used by tclBasic.c to keep track
  1611. * of hidden commands on a per-interp
  1612. * basis. */
  1613. ClientData interpInfo; /* Information used by tclInterp.c to keep
  1614. * track of parent/child interps on a
  1615. * per-interp basis. */
  1616. union {
  1617. void (*optimizer)(void *envPtr);
  1618. Tcl_HashTable unused2; /* No longer used (was mathFuncTable). The
  1619. * unused space in interp was repurposed for
  1620. * pluggable bytecode optimizers. The core
  1621. * contains one optimizer, which can be
  1622. * selectively overridden by extensions. */
  1623. } extra;
  1624. /*
  1625. * Information related to procedures and variables. See tclProc.c and
  1626. * tclVar.c for usage.
  1627. */
  1628. int numLevels; /* Keeps track of how many nested calls to
  1629. * Tcl_Eval are in progress for this
  1630. * interpreter. It's used to delay deletion of
  1631. * the table until all Tcl_Eval invocations
  1632. * are completed. */
  1633. int maxNestingDepth; /* If numLevels exceeds this value then Tcl
  1634. * assumes that infinite recursion has
  1635. * occurred and it generates an error. */
  1636. CallFrame *framePtr; /* Points to top-most in stack of all nested
  1637. * procedure invocations. */
  1638. CallFrame *varFramePtr; /* Points to the call frame whose variables
  1639. * are currently in use (same as framePtr
  1640. * unless an "uplevel" command is
  1641. * executing). */
  1642. ActiveVarTrace *activeVarTracePtr;
  1643. /* First in list of active traces for interp,
  1644. * or NULL if no active traces. */
  1645. int returnCode; /* [return -code] parameter. */
  1646. CallFrame *rootFramePtr; /* Global frame pointer for this
  1647. * interpreter. */
  1648. Namespace *lookupNsPtr; /* Namespace to use ONLY on the next
  1649. * TCL_EVAL_INVOKE call to Tcl_EvalObjv. */
  1650. /*
  1651. * Information used by Tcl_AppendResult to keep track of partial results.
  1652. * See Tcl_AppendResult code for details.
  1653. */
  1654. char *appendResult; /* Storage space for results generated by
  1655. * Tcl_AppendResult. Ckalloc-ed. NULL means
  1656. * not yet allocated. */
  1657. int appendAvl; /* Total amount of space available at
  1658. * partialResult. */
  1659. int appendUsed; /* Number of non-null bytes currently stored
  1660. * at partialResult. */
  1661. /*
  1662. * Information about packages. Used only in tclPkg.c.
  1663. */
  1664. Tcl_HashTable packageTable; /* Describes all of the packages loaded in or
  1665. * available to this interpreter. Keys are
  1666. * package names, values are (Package *)
  1667. * pointers. */
  1668. char *packageUnknown; /* Command to invoke during "package require"
  1669. * commands for packages that aren't described
  1670. * in packageTable. Ckalloc'ed, may be
  1671. * NULL. */
  1672. /*
  1673. * Miscellaneous information:
  1674. */
  1675. int cmdCount; /* Total number of times a command procedure
  1676. * has been called for this interpreter. */
  1677. int evalFlags; /* Flags to control next call to Tcl_Eval.
  1678. * Normally zero, but may be set before
  1679. * calling Tcl_Eval. See below for valid
  1680. * values. */
  1681. int unused1; /* No longer used (was termOffset) */
  1682. LiteralTable literalTable; /* Contains LiteralEntry's describing all Tcl
  1683. * objects holding literals of scripts
  1684. * compiled by the interpreter. Indexed by the
  1685. * string representations of literals. Used to
  1686. * avoid creating duplicate objects. */
  1687. int compileEpoch; /* Holds the current "compilation epoch" for
  1688. * this interpreter. This is incremented to
  1689. * invalidate existing ByteCodes when, e.g., a
  1690. * command with a compile procedure is
  1691. * redefined. */
  1692. Proc *compiledProcPtr; /* If a procedure is being compiled, a pointer
  1693. * to its Proc structure; otherwise, this is
  1694. * NULL. Set by ObjInterpProc in tclProc.c and
  1695. * used by tclCompile.c to process local
  1696. * variables appropriately. */
  1697. ResolverScheme *resolverPtr;
  1698. /* Linked list of name resolution schemes
  1699. * added to this interpreter. Schemes are
  1700. * added and removed by calling
  1701. * Tcl_AddInterpResolvers and
  1702. * Tcl_RemoveInterpResolver respectively. */
  1703. Tcl_Obj *scriptFile; /* NULL means there is no nested source
  1704. * command active; otherwise this points to
  1705. * pathPtr of the file being sourced. */
  1706. int flags; /* Various flag bits. See below. */
  1707. long randSeed; /* Seed used for rand() function. */
  1708. Trace *tracePtr; /* List of traces for this interpreter. */
  1709. Tcl_HashTable *assocData; /* Hash table for associating data with this
  1710. * interpreter. Cleaned up when this
  1711. * interpreter is deleted. */
  1712. struct ExecEnv *execEnvPtr; /* Execution environment for Tcl bytecode
  1713. * execution. Contains a pointer to the Tcl
  1714. * evaluation stack. */
  1715. Tcl_Obj *emptyObjPtr; /* Points to an object holding an empty
  1716. * string. Returned by Tcl_ObjSetVar2 when
  1717. * variable traces change a variable in a
  1718. * gross way. */
  1719. char resultSpace[TCL_RESULT_SIZE+1];
  1720. /* Static space holding small results. */
  1721. Tcl_Obj *objResultPtr; /* If the last command returned an object
  1722. * result, this points to it. Should not be
  1723. * accessed directly; see comment above. */
  1724. Tcl_ThreadId threadId; /* ID of thread that owns the interpreter. */
  1725. ActiveCommandTrace *activeCmdTracePtr;
  1726. /* First in list of active command traces for
  1727. * interp, or NULL if no active traces. */
  1728. ActiveInterpTrace *activeInterpTracePtr;
  1729. /* First in list of active traces for interp,
  1730. * or NULL if no active traces. */
  1731. int tracesForbiddingInline; /* Count of traces (in the list headed by
  1732. * tracePtr) that forbid inline bytecode
  1733. * compilation. */
  1734. /*
  1735. * Fields used to manage extensible return options (TIP 90).
  1736. */
  1737. Tcl_Obj *returnOpts; /* A dictionary holding the options to the
  1738. * last [return] command. */
  1739. Tcl_Obj *errorInfo; /* errorInfo value (now as a Tcl_Obj). */
  1740. Tcl_Obj *eiVar; /* cached ref to ::errorInfo variable. */
  1741. Tcl_Obj *errorCode; /* errorCode value (now as a Tcl_Obj). */
  1742. Tcl_Obj *ecVar; /* cached ref to ::errorInfo variable. */
  1743. int returnLevel; /* [return -level] parameter. */
  1744. /*
  1745. * Resource limiting framework support (TIP#143).
  1746. */
  1747. struct {
  1748. int active; /* Flag values defining which limits have been
  1749. * set. */
  1750. int granularityTicker; /* Counter used to determine how often to
  1751. * check the limits. */
  1752. int exceeded; /* Which limits have been exceeded, described
  1753. * as flag values the same as the 'active'
  1754. * field. */
  1755. int cmdCount; /* Limit for how many commands to execute in
  1756. * the interpreter. */
  1757. LimitHandler *cmdHandlers;
  1758. /* Handlers to execute when the limit is
  1759. * reached. */
  1760. int cmdGranularity; /* Mod factor used to determine how often to
  1761. * evaluate the limit check. */
  1762. Tcl_Time time; /* Time limit for execution within the
  1763. * interpreter. */
  1764. LimitHandler *timeHandlers;
  1765. /* Handlers to execute when the limit is
  1766. * reached. */
  1767. int timeGranularity; /* Mod factor used to determine how often to
  1768. * evaluate the limit check. */
  1769. Tcl_TimerToken timeEvent;
  1770. /* Handle for a timer callback that will occur
  1771. * when the time-limit is exceeded. */
  1772. Tcl_HashTable callbacks;/* Mapping from (interp,type) pair to data
  1773. * used to install a limit handler callback to
  1774. * run in _this_ interp when the limit is
  1775. * exceeded. */
  1776. } limit;
  1777. /*
  1778. * Information for improved default error generation from ensembles
  1779. * (TIP#112).
  1780. */
  1781. struct {
  1782. Tcl_Obj *const *sourceObjs;
  1783. /* What arguments were actually input into the
  1784. * *root* ensemble command? (Nested ensembles
  1785. * don't rewrite this.) NULL if we're not
  1786. * processing an ensemble. */
  1787. int numRemovedObjs; /* How many arguments have been stripped off
  1788. * because of ensemble processing. */
  1789. int numInsertedObjs; /* How many of the current arguments were
  1790. * inserted by an ensemble. */
  1791. } ensembleRewrite;
  1792. /*
  1793. * TIP #219: Global info for the I/O system.
  1794. */
  1795. Tcl_Obj *chanMsg; /* Error message set by channel drivers, for
  1796. * the propagation of arbitrary Tcl errors.
  1797. * This information, if present (chanMsg not
  1798. * NULL), takes precedence over a POSIX error
  1799. * code returned by a channel operation. */
  1800. /*
  1801. * Source code origin information (TIP #280).
  1802. */
  1803. CmdFrame *cmdFramePtr; /* Points to the command frame containing the
  1804. * location information for the current
  1805. * command. */
  1806. const CmdFrame *invokeCmdFramePtr;
  1807. /* Points to the command frame which is the
  1808. * invoking context of the bytecode compiler.
  1809. * NULL when the byte code compiler is not
  1810. * active. */
  1811. int invokeWord; /* Index of the word in the command which
  1812. * is getting compiled. */
  1813. Tcl_HashTable *linePBodyPtr;/* This table remembers for each statically
  1814. * defined procedure the location information
  1815. * for its body. It is keyed by the address of
  1816. * the Proc structure for a procedure. The
  1817. * values are "struct CmdFrame*". */
  1818. Tcl_HashTable *lineBCPtr; /* This table remembers for each ByteCode
  1819. * object the location information for its
  1820. * body. It is keyed by the address of the
  1821. * Proc structure for a procedure. The values
  1822. * are "struct ExtCmdLoc*". (See
  1823. * tclCompile.h) */
  1824. Tcl_HashTable *lineLABCPtr;
  1825. Tcl_HashTable *lineLAPtr; /* This table remembers for each argument of a
  1826. * command on the execution stack the index of
  1827. * the argument in the command, and the
  1828. * location data of the command. It is keyed
  1829. * by the address of the Tcl_Obj containing
  1830. * the argument. The values are "struct
  1831. * CFWord*" (See tclBasic.c). This allows
  1832. * commands like uplevel, eval, etc. to find
  1833. * location information for their arguments,
  1834. * if they are a proper literal argument to an
  1835. * invoking command. Alt view: An index to the
  1836. * CmdFrame stack keyed by command argument
  1837. * holders. */
  1838. ContLineLoc *scriptCLLocPtr;/* This table points to the location data for
  1839. * invisible continuation lines in the script,
  1840. * if any. This pointer is set by the function
  1841. * TclEvalObjEx() in file "tclBasic.c", and
  1842. * used by function ...() in the same file.
  1843. * It does for the eval/direct path of script
  1844. * execution what CompileEnv.clLoc does for
  1845. * the bytecode compiler.
  1846. */
  1847. /*
  1848. * TIP #268. The currently active selection mode, i.e. the package require
  1849. * preferences.
  1850. */
  1851. int packagePrefer; /* Current package selection mode. */
  1852. /*
  1853. * Hashtables for variable traces and searches.
  1854. */
  1855. Tcl_HashTable varTraces; /* Hashtable holding the start of a variable's
  1856. * active trace list; varPtr is the key. */
  1857. Tcl_HashTable varSearches; /* Hashtable holding the start of a variable's
  1858. * active searches list; varPtr is the key. */
  1859. /*
  1860. * The thread-specific data ekeko: cache pointers or values that
  1861. * (a) do not change during the thread's lifetime
  1862. * (b) require access to TSD to determine at runtime
  1863. * (c) are accessed very often (e.g., at each command call)
  1864. *
  1865. * Note that these are the same for all interps in the same thread. They
  1866. * just have to be initialised for the thread's parent interp, children
  1867. * inherit the value.
  1868. *
  1869. * They are used by the macros defined below.
  1870. */
  1871. AllocCache *allocCache;
  1872. void *pendingObjDataPtr; /* Pointer to the Cache and PendingObjData
  1873. * structs for this interp's thread; see
  1874. * tclObj.c and tclThreadAlloc.c */
  1875. int *asyncReadyPtr; /* Pointer to the asyncReady indicator for
  1876. * this interp's thread; see tclAsync.c */
  1877. /*
  1878. * The pointer to the object system root ekeko. c.f. TIP #257.
  1879. */
  1880. void *objectFoundation; /* Pointer to the Foundation structure of the
  1881. * object system, which contains things like
  1882. * references to key namespaces. See
  1883. * tclOOInt.h and tclOO.c for real definition
  1884. * and setup. */
  1885. struct NRE_callback *deferredCallbacks;
  1886. /* Callbacks that are set previous to a call
  1887. * to some Eval function but that actually
  1888. * belong to the command that is about to be
  1889. * called - i.e., they should be run *before*
  1890. * any tailcall is invoked. */
  1891. /*
  1892. * TIP #285, Script cancellation support.
  1893. */
  1894. Tcl_AsyncHandler asyncCancel;
  1895. /* Async handler token for Tcl_CancelEval. */
  1896. Tcl_Obj *asyncCancelMsg; /* Error message set by async cancel handler
  1897. * for the propagation of arbitrary Tcl
  1898. * errors. This information, if present
  1899. * (asyncCancelMsg not NULL), takes precedence
  1900. * over the default error messages returned by
  1901. * a script cancellation operation. */
  1902. /*
  1903. * TIP #348 IMPLEMENTATION - Substituted error stack
  1904. */
  1905. Tcl_Obj *errorStack; /* [info errorstack] value (as a Tcl_Obj). */
  1906. Tcl_Obj *upLiteral; /* "UP" literal for [info errorstack] */
  1907. Tcl_Obj *callLiteral; /* "CALL" literal for [info errorstack] */
  1908. Tcl_Obj *innerLiteral; /* "INNER" literal for [info errorstack] */
  1909. Tcl_Obj *innerContext; /* cached list for fast reallocation */
  1910. int resetErrorStack; /* controls cleaning up of ::errorStack */
  1911. #ifdef TCL_COMPILE_STATS
  1912. /*
  1913. * Statistical information about the bytecode compiler and interpreter's
  1914. * operation. This should be the last field of Interp.
  1915. */
  1916. ByteCodeStats stats; /* Holds compilation and execution statistics
  1917. * for this interpreter. */
  1918. #endif /* TCL_COMPILE_STATS */
  1919. } Interp;
  1920. /*
  1921. * Macros that use the TSD-ekeko.
  1922. */
  1923. #define TclAsyncReady(iPtr) \
  1924. *((iPtr)->asyncReadyPtr)
  1925. /*
  1926. * Macros for script cancellation support (TIP #285).
  1927. */
  1928. #define TclCanceled(iPtr) \
  1929. (((iPtr)->flags & CANCELED) || ((iPtr)->flags & TCL_CANCEL_UNWIND))
  1930. #define TclSetCancelFlags(iPtr, cancelFlags) \
  1931. (iPtr)->flags |= CANCELED; \
  1932. if ((cancelFlags) & TCL_CANCEL_UNWIND) { \
  1933. (iPtr)->flags |= TCL_CANCEL_UNWIND; \
  1934. }
  1935. #define TclUnsetCancelFlags(iPtr) \
  1936. (iPtr)->flags &= (~(CANCELED | TCL_CANCEL_UNWIND))
  1937. /*
  1938. * Macros for splicing into and out of doubly linked lists. They assume
  1939. * existence of struct items 'prevPtr' and 'nextPtr'.
  1940. *
  1941. * a = element to add or remove.
  1942. * b = list head.
  1943. *
  1944. * TclSpliceIn adds to the head of the list.
  1945. */
  1946. #define TclSpliceIn(a,b) \
  1947. (a)->nextPtr = (b); \
  1948. if ((b) != NULL) { \
  1949. (b)->prevPtr = (a); \
  1950. } \
  1951. (a)->prevPtr = NULL, (b) = (a);
  1952. #define TclSpliceOut(a,b) \
  1953. if ((a)->prevPtr != NULL) { \
  1954. (a)->prevPtr->nextPtr = (a)->nextPtr; \
  1955. } else { \
  1956. (b) = (a)->nextPtr; \
  1957. } \
  1958. if ((a)->nextPtr != NULL) { \
  1959. (a)->nextPtr->prevPtr = (a)->prevPtr; \
  1960. }
  1961. /*
  1962. * EvalFlag bits for Interp structures:
  1963. *
  1964. * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with a
  1965. * code other than TCL_OK or TCL_ERROR; 0 means codes
  1966. * other than these should be turned into errors.
  1967. */
  1968. #define TCL_ALLOW_EXCEPTIONS 0x04
  1969. #define TCL_EVAL_FILE 0x02
  1970. #define TCL_EVAL_SOURCE_IN_FRAME 0x10
  1971. #define TCL_EVAL_NORESOLVE 0x20
  1972. #define TCL_EVAL_DISCARD_RESULT 0x40
  1973. /*
  1974. * Flag bits for Interp structures:
  1975. *
  1976. * DELETED: Non-zero means the interpreter has been deleted:
  1977. * don't process any more commands for it, and destroy
  1978. * the structure as soon as all nested invocations of
  1979. * Tcl_Eval are done.
  1980. * ERR_ALREADY_LOGGED: Non-zero means information has already been logged in
  1981. * iPtr->errorInfo for the current Tcl_Eval instance, so
  1982. * Tcl_Eval needn't log it (used to implement the "error
  1983. * message log" command).
  1984. * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler should
  1985. * not compile any commands into an inline sequence of
  1986. * instructions. This is set 1, for example, when command
  1987. * traces are requested.
  1988. * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the interp
  1989. * has not be initialized. This is set 1 when we first
  1990. * use the rand() or srand() functions.
  1991. * SAFE_INTERP: Non zero means that the current interp is a safe
  1992. * interp (i.e. it has only the safe commands installed,
  1993. * less privilege than a regular interp).
  1994. * INTERP_DEBUG_FRAME: Used for switching on various extra interpreter
  1995. * debug/info mechanisms (e.g. info frame eval/uplevel
  1996. * tracing) which are performance intensive.
  1997. * INTERP_TRACE_IN_PROGRESS: Non-zero means that an interp trace is currently
  1998. * active; so no further trace callbacks should be
  1999. * invoked.
  2000. * INTERP_ALTERNATE_WRONG_ARGS: Used for listing second and subsequent forms
  2001. * of the wrong-num-args string in Tcl_WrongNumArgs.
  2002. * Makes it append instead of replacing and uses
  2003. * different intermediate text.
  2004. * CANCELED: Non-zero means that the script in progress should be
  2005. * canceled as soon as possible. This can be checked by
  2006. * extensions (and the core itself) by calling
  2007. * Tcl_Canceled and checking if TCL_ERROR is returned.
  2008. * This is a one-shot flag that is reset immediately upon
  2009. * being detected; however, if the TCL_CANCEL_UNWIND flag
  2010. * is set Tcl_Canceled will continue to report that the
  2011. * script in progress has been canceled thereby allowing
  2012. * the evaluation stack for the interp to be fully
  2013. * unwound.
  2014. *
  2015. * WARNING: For the sake of some extensions that have made use of former
  2016. * internal values, do not re-use the flag values 2 (formerly ERR_IN_PROGRESS)
  2017. * or 8 (formerly ERROR_CODE_SET).
  2018. */
  2019. #define DELETED 1
  2020. #define ERR_ALREADY_LOGGED 4
  2021. #define INTERP_DEBUG_FRAME 0x10
  2022. #define DONT_COMPILE_CMDS_INLINE 0x20
  2023. #define RAND_SEED_INITIALIZED 0x40
  2024. #define SAFE_INTERP 0x80
  2025. #define INTERP_TRACE_IN_PROGRESS 0x200
  2026. #define INTERP_ALTERNATE_WRONG_ARGS 0x400
  2027. #define ERR_LEGACY_COPY 0x800
  2028. #define CANCELED 0x1000
  2029. /*
  2030. * Maximum number of levels of nesting permitted in Tcl commands (used to
  2031. * catch infinite recursion).
  2032. */
  2033. #define MAX_NESTING_DEPTH 1000
  2034. /*
  2035. * The macro below is used to modify a "char" value (e.g. by casting it to an
  2036. * unsigned character) so that it can be used safely with macros such as
  2037. * isspace.
  2038. */
  2039. #define UCHAR(c) ((unsigned char) (c))
  2040. /*
  2041. * This macro is used to properly align the memory allocated by Tcl, giving
  2042. * the same alignment as the native malloc.
  2043. */
  2044. #if defined(__APPLE__)
  2045. #define TCL_ALLOCALIGN 16
  2046. #else
  2047. #define TCL_ALLOCALIGN (2*sizeof(void *))
  2048. #endif
  2049. /*
  2050. * This macro is used to determine the offset needed to safely allocate any
  2051. * data structure in memory. Given a starting offset or size, it "rounds up"
  2052. * or "aligns" the offset to the next 8-byte boundary so that any data
  2053. * structure can be placed at the resulting offset without fear of an
  2054. * alignment error.
  2055. *
  2056. * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce the
  2057. * wrong result on platforms that allocate addresses that are divisible by 4
  2058. * or 2. Only use it for offsets or sizes.
  2059. *
  2060. * This macro is only used by tclCompile.c in the core (Bug 926445). It
  2061. * however not be made file static, as extensions that touch bytecodes
  2062. * (notably tbcload) require it.
  2063. */
  2064. #define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
  2065. /*
  2066. * The following enum values are used to specify the runtime platform setting
  2067. * of the tclPlatform variable.
  2068. */
  2069. typedef enum {
  2070. TCL_PLATFORM_UNIX = 0, /* Any Unix-like OS. */
  2071. TCL_PLATFORM_WINDOWS = 2 /* Any Microsoft Windows OS. */
  2072. } TclPlatformType;
  2073. /*
  2074. * The following enum values are used to indicate the translation of a Tcl
  2075. * channel. Declared here so that each platform can define
  2076. * TCL_PLATFORM_TRANSLATION to the native translation on that platform.
  2077. */
  2078. typedef enum TclEolTranslation {
  2079. TCL_TRANSLATE_AUTO, /* Eol == \r, \n and \r\n. */
  2080. TCL_TRANSLATE_CR, /* Eol == \r. */
  2081. TCL_TRANSLATE_LF, /* Eol == \n. */
  2082. TCL_TRANSLATE_CRLF /* Eol == \r\n. */
  2083. } TclEolTranslation;
  2084. /*
  2085. * Flags for TclInvoke:
  2086. *
  2087. * TCL_INVOKE_HIDDEN Invoke a hidden command; if not set, invokes
  2088. * an exposed command.
  2089. * TCL_INVOKE_NO_UNKNOWN If set, "unknown" is not invoked if the
  2090. * command to be invoked is not found. Only has
  2091. * an effect if invoking an exposed command,
  2092. * i.e. if TCL_INVOKE_HIDDEN is not also set.
  2093. * TCL_INVOKE_NO_TRACEBACK Does not record traceback information if the
  2094. * invoked command returns an error. Used if the
  2095. * caller plans on recording its own traceback
  2096. * information.
  2097. */
  2098. #define TCL_INVOKE_HIDDEN (1<<0)
  2099. #define TCL_INVOKE_NO_UNKNOWN (1<<1)
  2100. #define TCL_INVOKE_NO_TRACEBACK (1<<2)
  2101. /*
  2102. * The structure used as the internal representation of Tcl list objects. This
  2103. * struct is grown (reallocated and copied) as necessary to hold all the
  2104. * list's element pointers. The struct might contain more slots than currently
  2105. * used to hold all element pointers. This is done to make append operations
  2106. * faster.
  2107. */
  2108. typedef struct List {
  2109. int refCount;
  2110. int maxElemCount; /* Total number of element array slots. */
  2111. int elemCount; /* Current number of list elements. */
  2112. int canonicalFlag; /* Set if the string representation was
  2113. * derived from the list representation. May
  2114. * be ignored if there is no string rep at
  2115. * all.*/
  2116. Tcl_Obj *elements; /* First list element; the struct is grown to
  2117. * accommodate all elements. */
  2118. } List;
  2119. #define LIST_MAX \
  2120. (1 + (int)(((size_t)UINT_MAX - sizeof(List))/sizeof(Tcl_Obj *)))
  2121. #define LIST_SIZE(numElems) \
  2122. (unsigned)(sizeof(List) + (((numElems) - 1) * sizeof(Tcl_Obj *)))
  2123. /*
  2124. * Macro used to get the elements of a list object.
  2125. */
  2126. #define ListRepPtr(listPtr) \
  2127. ((List *) (listPtr)->internalRep.twoPtrValue.ptr1)
  2128. /* Not used any more */
  2129. #define ListSetIntRep(objPtr, listRepPtr) \
  2130. (objPtr)->internalRep.twoPtrValue.ptr1 = (void *)(listRepPtr), \
  2131. (objPtr)->internalRep.twoPtrValue.ptr2 = NULL, \
  2132. (listRepPtr)->refCount++, \
  2133. (objPtr)->typePtr = &tclListType
  2134. #define ListObjGetElements(listPtr, objc, objv) \
  2135. ((objv) = &(ListRepPtr(listPtr)->elements), \
  2136. (objc) = ListRepPtr(listPtr)->elemCount)
  2137. #define ListObjLength(listPtr, len) \
  2138. ((len) = ListRepPtr(listPtr)->elemCount)
  2139. #define ListObjIsCanonical(listPtr) \
  2140. (((listPtr)->bytes == NULL) || ListRepPtr(listPtr)->canonicalFlag)
  2141. #define TclListObjGetElements(interp, listPtr, objcPtr, objvPtr) \
  2142. (((listPtr)->typePtr == &tclListType) \
  2143. ? ((ListObjGetElements((listPtr), *(objcPtr), *(objvPtr))), TCL_OK)\
  2144. : Tcl_ListObjGetElements((interp), (listPtr), (objcPtr), (objvPtr)))
  2145. #define TclListObjLength(interp, listPtr, lenPtr) \
  2146. (((listPtr)->typePtr == &tclListType) \
  2147. ? ((ListObjLength((listPtr), *(lenPtr))), TCL_OK)\
  2148. : Tcl_ListObjLength((interp), (listPtr), (lenPtr)))
  2149. #define TclListObjIsCanonical(listPtr) \
  2150. (((listPtr)->typePtr == &tclListType) ? ListObjIsCanonical((listPtr)) : 0)
  2151. /*
  2152. * Modes for collecting (or not) in the implementations of TclNRForeachCmd,
  2153. * TclNRLmapCmd and their compilations.
  2154. */
  2155. #define TCL_EACH_KEEP_NONE 0 /* Discard iteration result like [foreach] */
  2156. #define TCL_EACH_COLLECT 1 /* Collect iteration result like [lmap] */
  2157. /*
  2158. * Macros providing a faster path to integers: Tcl_GetLongFromObj,
  2159. * Tcl_GetIntFromObj and TclGetIntForIndex.
  2160. *
  2161. * WARNING: these macros eval their args more than once.
  2162. */
  2163. #define TclGetLongFromObj(interp, objPtr, longPtr) \
  2164. (((objPtr)->typePtr == &tclIntType) \
  2165. ? ((*(longPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
  2166. : Tcl_GetLongFromObj((interp), (objPtr), (longPtr)))
  2167. #if (LONG_MAX == INT_MAX)
  2168. #define TclGetIntFromObj(interp, objPtr, intPtr) \
  2169. (((objPtr)->typePtr == &tclIntType) \
  2170. ? ((*(intPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
  2171. : Tcl_GetIntFromObj((interp), (objPtr), (intPtr)))
  2172. #define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \
  2173. (((objPtr)->typePtr == &tclIntType) \
  2174. ? ((*(idxPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
  2175. : TclGetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
  2176. #else
  2177. #define TclGetIntFromObj(interp, objPtr, intPtr) \
  2178. (((objPtr)->typePtr == &tclIntType \
  2179. && (objPtr)->internalRep.longValue >= -(Tcl_WideInt)(UINT_MAX) \
  2180. && (objPtr)->internalRep.longValue <= (Tcl_WideInt)(UINT_MAX)) \
  2181. ? ((*(intPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
  2182. : Tcl_GetIntFromObj((interp), (objPtr), (intPtr)))
  2183. #define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \
  2184. (((objPtr)->typePtr == &tclIntType \
  2185. && (objPtr)->internalRep.longValue >= INT_MIN \
  2186. && (objPtr)->internalRep.longValue <= INT_MAX) \
  2187. ? ((*(idxPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
  2188. : TclGetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
  2189. #endif
  2190. /*
  2191. * Macro used to save a function call for common uses of
  2192. * Tcl_GetWideIntFromObj(). The ANSI C "prototype" is:
  2193. *
  2194. * MODULE_SCOPE int TclGetWideIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
  2195. * Tcl_WideInt *wideIntPtr);
  2196. */
  2197. #ifdef TCL_WIDE_INT_IS_LONG
  2198. #define TclGetWideIntFromObj(interp, objPtr, wideIntPtr) \
  2199. (((objPtr)->typePtr == &tclIntType) \
  2200. ? (*(wideIntPtr) = (Tcl_WideInt) \
  2201. ((objPtr)->internalRep.longValue), TCL_OK) : \
  2202. Tcl_GetWideIntFromObj((interp), (objPtr), (wideIntPtr)))
  2203. #else /* !TCL_WIDE_INT_IS_LONG */
  2204. #define TclGetWideIntFromObj(interp, objPtr, wideIntPtr) \
  2205. (((objPtr)->typePtr == &tclWideIntType) \
  2206. ? (*(wideIntPtr) = (objPtr)->internalRep.wideValue, TCL_OK) : \
  2207. ((objPtr)->typePtr == &tclIntType) \
  2208. ? (*(wideIntPtr) = (Tcl_WideInt) \
  2209. ((objPtr)->internalRep.longValue), TCL_OK) : \
  2210. Tcl_GetWideIntFromObj((interp), (objPtr), (wideIntPtr)))
  2211. #endif /* TCL_WIDE_INT_IS_LONG */
  2212. /*
  2213. * Flag values for TclTraceDictPath().
  2214. *
  2215. * DICT_PATH_READ indicates that all entries on the path must exist but no
  2216. * updates will be needed.
  2217. *
  2218. * DICT_PATH_UPDATE indicates that we are going to be doing an update at the
  2219. * tip of the path, so duplication of shared objects should be done along the
  2220. * way.
  2221. *
  2222. * DICT_PATH_EXISTS indicates that we are performing an existence test and a
  2223. * lookup failure should therefore not be an error. If (and only if) this flag
  2224. * is set, TclTraceDictPath() will return the special value
  2225. * DICT_PATH_NON_EXISTENT if the path is not traceable.
  2226. *
  2227. * DICT_PATH_CREATE (which also requires the DICT_PATH_UPDATE bit to be set)
  2228. * indicates that we are to create non-existent dictionaries on the path.
  2229. */
  2230. #define DICT_PATH_READ 0
  2231. #define DICT_PATH_UPDATE 1
  2232. #define DICT_PATH_EXISTS 2
  2233. #define DICT_PATH_CREATE 5
  2234. #define DICT_PATH_NON_EXISTENT ((Tcl_Obj *) (void *) 1)
  2235. /*
  2236. *----------------------------------------------------------------
  2237. * Data structures related to the filesystem internals
  2238. *----------------------------------------------------------------
  2239. */
  2240. /*
  2241. * The version_2 filesystem is private to Tcl. As and when these changes have
  2242. * been thoroughly tested and investigated a new public filesystem interface
  2243. * will be released. The aim is more versatile virtual filesystem interfaces,
  2244. * more efficiency in 'path' manipulation and usage, and cleaner filesystem
  2245. * code internally.
  2246. */
  2247. #define TCL_FILESYSTEM_VERSION_2 ((Tcl_FSVersion) 0x2)
  2248. typedef ClientData (TclFSGetCwdProc2)(ClientData clientData);
  2249. typedef int (Tcl_FSLoadFileProc2) (Tcl_Interp *interp, Tcl_Obj *pathPtr,
  2250. Tcl_LoadHandle *handlePtr, Tcl_FSUnloadFileProc **unloadProcPtr, int flags);
  2251. /*
  2252. * The following types are used for getting and storing platform-specific file
  2253. * attributes in tclFCmd.c and the various platform-versions of that file.
  2254. * This is done to have as much common code as possible in the file attributes
  2255. * code. For more information about the callbacks, see TclFileAttrsCmd in
  2256. * tclFCmd.c.
  2257. */
  2258. typedef int (TclGetFileAttrProc)(Tcl_Interp *interp, int objIndex,
  2259. Tcl_Obj *fileName, Tcl_Obj **attrObjPtrPtr);
  2260. typedef int (TclSetFileAttrProc)(Tcl_Interp *interp, int objIndex,
  2261. Tcl_Obj *fileName, Tcl_Obj *attrObjPtr);
  2262. typedef struct TclFileAttrProcs {
  2263. TclGetFileAttrProc *getProc;/* The procedure for getting attrs. */
  2264. TclSetFileAttrProc *setProc;/* The procedure for setting attrs. */
  2265. } TclFileAttrProcs;
  2266. /*
  2267. * Opaque handle used in pipeline routines to encapsulate platform-dependent
  2268. * state.
  2269. */
  2270. typedef struct TclFile_ *TclFile;
  2271. /*
  2272. * The "globParameters" argument of the function TclGlob is an or'ed
  2273. * combination of the following values:
  2274. */
  2275. #define TCL_GLOBMODE_NO_COMPLAIN 1
  2276. #define TCL_GLOBMODE_JOIN 2
  2277. #define TCL_GLOBMODE_DIR 4
  2278. #define TCL_GLOBMODE_TAILS 8
  2279. typedef enum Tcl_PathPart {
  2280. TCL_PATH_DIRNAME,
  2281. TCL_PATH_TAIL,
  2282. TCL_PATH_EXTENSION,
  2283. TCL_PATH_ROOT
  2284. } Tcl_PathPart;
  2285. /*
  2286. *----------------------------------------------------------------
  2287. * Data structures related to obsolete filesystem hooks
  2288. *----------------------------------------------------------------
  2289. */
  2290. typedef int (TclStatProc_)(const char *path, struct stat *buf);
  2291. typedef int (TclAccessProc_)(const char *path, int mode);
  2292. typedef Tcl_Channel (TclOpenFileChannelProc_)(Tcl_Interp *interp,
  2293. const char *fileName, const char *modeString, int permissions);
  2294. /*
  2295. *----------------------------------------------------------------
  2296. * Data structures related to procedures
  2297. *----------------------------------------------------------------
  2298. */
  2299. typedef Tcl_CmdProc *TclCmdProcType;
  2300. typedef Tcl_ObjCmdProc *TclObjCmdProcType;
  2301. /*
  2302. *----------------------------------------------------------------
  2303. * Data structures for process-global values.
  2304. *----------------------------------------------------------------
  2305. */
  2306. typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, int *lengthPtr,
  2307. Tcl_Encoding *encodingPtr);
  2308. /*
  2309. * A ProcessGlobalValue struct exists for each internal value in Tcl that is
  2310. * to be shared among several threads. Each thread sees a (Tcl_Obj) copy of
  2311. * the value, and the gobal value is kept as a counted string, with epoch and
  2312. * mutex control. Each ProcessGlobalValue struct should be a static variable in
  2313. * some file.
  2314. */
  2315. typedef struct ProcessGlobalValue {
  2316. int epoch; /* Epoch counter to detect changes in the
  2317. * global value. */
  2318. int numBytes; /* Length of the global string. */
  2319. char *value; /* The global string value. */
  2320. Tcl_Encoding encoding; /* system encoding when global string was
  2321. * initialized. */
  2322. TclInitProcessGlobalValueProc *proc;
  2323. /* A procedure to initialize the global string
  2324. * copy when a "get" request comes in before
  2325. * any "set" request has been received. */
  2326. Tcl_Mutex mutex; /* Enforce orderly access from multiple
  2327. * threads. */
  2328. Tcl_ThreadDataKey key; /* Key for per-thread data holding the
  2329. * (Tcl_Obj) copy for each thread. */
  2330. } ProcessGlobalValue;
  2331. /*
  2332. *----------------------------------------------------------------------
  2333. * Flags for TclParseNumber
  2334. *----------------------------------------------------------------------
  2335. */
  2336. #define TCL_PARSE_DECIMAL_ONLY 1
  2337. /* Leading zero doesn't denote octal or
  2338. * hex. */
  2339. #define TCL_PARSE_OCTAL_ONLY 2
  2340. /* Parse octal even without prefix. */
  2341. #define TCL_PARSE_HEXADECIMAL_ONLY 4
  2342. /* Parse hexadecimal even without prefix. */
  2343. #define TCL_PARSE_INTEGER_ONLY 8
  2344. /* Disable floating point parsing. */
  2345. #define TCL_PARSE_SCAN_PREFIXES 16
  2346. /* Use [scan] rules dealing with 0?
  2347. * prefixes. */
  2348. #define TCL_PARSE_NO_WHITESPACE 32
  2349. /* Reject leading/trailing whitespace. */
  2350. #define TCL_PARSE_BINARY_ONLY 64
  2351. /* Parse binary even without prefix. */
  2352. /*
  2353. *----------------------------------------------------------------------
  2354. * Type values TclGetNumberFromObj
  2355. *----------------------------------------------------------------------
  2356. */
  2357. #define TCL_NUMBER_LONG 1
  2358. #define TCL_NUMBER_WIDE 2
  2359. #define TCL_NUMBER_BIG 3
  2360. #define TCL_NUMBER_DOUBLE 4
  2361. #define TCL_NUMBER_NAN 5
  2362. /*
  2363. *----------------------------------------------------------------
  2364. * Variables shared among Tcl modules but not used by the outside world.
  2365. *----------------------------------------------------------------
  2366. */
  2367. MODULE_SCOPE char *tclNativeExecutableName;
  2368. MODULE_SCOPE int tclFindExecutableSearchDone;
  2369. MODULE_SCOPE char *tclMemDumpFileName;
  2370. MODULE_SCOPE TclPlatformType tclPlatform;
  2371. MODULE_SCOPE Tcl_NotifierProcs tclNotifierHooks;
  2372. MODULE_SCOPE Tcl_Encoding tclIdentityEncoding;
  2373. /*
  2374. * TIP #233 (Virtualized Time)
  2375. * Data for the time hooks, if any.
  2376. */
  2377. MODULE_SCOPE Tcl_GetTimeProc *tclGetTimeProcPtr;
  2378. MODULE_SCOPE Tcl_ScaleTimeProc *tclScaleTimeProcPtr;
  2379. MODULE_SCOPE ClientData tclTimeClientData;
  2380. /*
  2381. * Variables denoting the Tcl object types defined in the core.
  2382. */
  2383. MODULE_SCOPE const Tcl_ObjType tclBignumType;
  2384. MODULE_SCOPE const Tcl_ObjType tclBooleanType;
  2385. MODULE_SCOPE const Tcl_ObjType tclByteArrayType;
  2386. MODULE_SCOPE const Tcl_ObjType tclByteCodeType;
  2387. MODULE_SCOPE const Tcl_ObjType tclDoubleType;
  2388. MODULE_SCOPE const Tcl_ObjType tclEndOffsetType;
  2389. MODULE_SCOPE const Tcl_ObjType tclIntType;
  2390. MODULE_SCOPE const Tcl_ObjType tclListType;
  2391. MODULE_SCOPE const Tcl_ObjType tclDictType;
  2392. MODULE_SCOPE const Tcl_ObjType tclProcBodyType;
  2393. MODULE_SCOPE const Tcl_ObjType tclStringType;
  2394. MODULE_SCOPE const Tcl_ObjType tclArraySearchType;
  2395. MODULE_SCOPE const Tcl_ObjType tclEnsembleCmdType;
  2396. #ifndef TCL_WIDE_INT_IS_LONG
  2397. MODULE_SCOPE const Tcl_ObjType tclWideIntType;
  2398. #endif
  2399. MODULE_SCOPE const Tcl_ObjType tclRegexpType;
  2400. MODULE_SCOPE Tcl_ObjType tclCmdNameType;
  2401. /*
  2402. * Variables denoting the hash key types defined in the core.
  2403. */
  2404. MODULE_SCOPE const Tcl_HashKeyType tclArrayHashKeyType;
  2405. MODULE_SCOPE const Tcl_HashKeyType tclOneWordHashKeyType;
  2406. MODULE_SCOPE const Tcl_HashKeyType tclStringHashKeyType;
  2407. MODULE_SCOPE const Tcl_HashKeyType tclObjHashKeyType;
  2408. /*
  2409. * The head of the list of free Tcl objects, and the total number of Tcl
  2410. * objects ever allocated and freed.
  2411. */
  2412. MODULE_SCOPE Tcl_Obj * tclFreeObjList;
  2413. #ifdef TCL_COMPILE_STATS
  2414. MODULE_SCOPE long tclObjsAlloced;
  2415. MODULE_SCOPE long tclObjsFreed;
  2416. #define TCL_MAX_SHARED_OBJ_STATS 5
  2417. MODULE_SCOPE long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS];
  2418. #endif /* TCL_COMPILE_STATS */
  2419. /*
  2420. * Pointer to a heap-allocated string of length zero that the Tcl core uses as
  2421. * the value of an empty string representation for an object. This value is
  2422. * shared by all new objects allocated by Tcl_NewObj.
  2423. */
  2424. MODULE_SCOPE char * tclEmptyStringRep;
  2425. MODULE_SCOPE char tclEmptyString;
  2426. enum CheckEmptyStringResult {
  2427. TCL_EMPTYSTRING_UNKNOWN = -1, TCL_EMPTYSTRING_NO, TCL_EMPTYSTRING_YES
  2428. };
  2429. /*
  2430. *----------------------------------------------------------------
  2431. * Procedures shared among Tcl modules but not used by the outside world,
  2432. * introduced by/for NRE.
  2433. *----------------------------------------------------------------
  2434. */
  2435. MODULE_SCOPE Tcl_ObjCmdProc TclNRApplyObjCmd;
  2436. MODULE_SCOPE Tcl_ObjCmdProc TclNREvalObjCmd;
  2437. MODULE_SCOPE Tcl_ObjCmdProc TclNRCatchObjCmd;
  2438. MODULE_SCOPE Tcl_ObjCmdProc TclNRExprObjCmd;
  2439. MODULE_SCOPE Tcl_ObjCmdProc TclNRForObjCmd;
  2440. MODULE_SCOPE Tcl_ObjCmdProc TclNRForeachCmd;
  2441. MODULE_SCOPE Tcl_ObjCmdProc TclNRIfObjCmd;
  2442. MODULE_SCOPE Tcl_ObjCmdProc TclNRLmapCmd;
  2443. MODULE_SCOPE Tcl_ObjCmdProc TclNRPackageObjCmd;
  2444. MODULE_SCOPE Tcl_ObjCmdProc TclNRSourceObjCmd;
  2445. MODULE_SCOPE Tcl_ObjCmdProc TclNRSubstObjCmd;
  2446. MODULE_SCOPE Tcl_ObjCmdProc TclNRSwitchObjCmd;
  2447. MODULE_SCOPE Tcl_ObjCmdProc TclNRTryObjCmd;
  2448. MODULE_SCOPE Tcl_ObjCmdProc TclNRUplevelObjCmd;
  2449. MODULE_SCOPE Tcl_ObjCmdProc TclNRWhileObjCmd;
  2450. MODULE_SCOPE Tcl_NRPostProc TclNRForIterCallback;
  2451. MODULE_SCOPE Tcl_NRPostProc TclNRCoroutineActivateCallback;
  2452. MODULE_SCOPE Tcl_ObjCmdProc TclNRTailcallObjCmd;
  2453. MODULE_SCOPE Tcl_NRPostProc TclNRTailcallEval;
  2454. MODULE_SCOPE Tcl_ObjCmdProc TclNRCoroutineObjCmd;
  2455. MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldObjCmd;
  2456. MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldmObjCmd;
  2457. MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldToObjCmd;
  2458. MODULE_SCOPE Tcl_ObjCmdProc TclNRInvoke;
  2459. MODULE_SCOPE Tcl_NRPostProc TclNRReleaseValues;
  2460. MODULE_SCOPE void TclSetTailcall(Tcl_Interp *interp, Tcl_Obj *tailcallPtr);
  2461. MODULE_SCOPE void TclPushTailcallPoint(Tcl_Interp *interp);
  2462. /* These two can be considered for the public api */
  2463. MODULE_SCOPE void TclMarkTailcall(Tcl_Interp *interp);
  2464. MODULE_SCOPE void TclSkipTailcall(Tcl_Interp *interp);
  2465. /*
  2466. * This structure holds the data for the various iteration callbacks used to
  2467. * NRE the 'for' and 'while' commands. We need a separate structure because we
  2468. * have more than the 4 client data entries we can provide directly thorugh
  2469. * the callback API. It is the 'word' information which puts us over the
  2470. * limit. It is needed because the loop body is argument 4 of 'for' and
  2471. * argument 2 of 'while'. Not providing the correct index confuses the #280
  2472. * code. We TclSmallAlloc/Free this.
  2473. */
  2474. typedef struct ForIterData {
  2475. Tcl_Obj *cond; /* Loop condition expression. */
  2476. Tcl_Obj *body; /* Loop body. */
  2477. Tcl_Obj *next; /* Loop step script, NULL for 'while'. */
  2478. const char *msg; /* Error message part. */
  2479. int word; /* Index of the body script in the command */
  2480. } ForIterData;
  2481. /* TIP #357 - Structure doing the bookkeeping of handles for Tcl_LoadFile
  2482. * and Tcl_FindSymbol. This structure corresponds to an opaque
  2483. * typedef in tcl.h */
  2484. typedef void* TclFindSymbolProc(Tcl_Interp* interp, Tcl_LoadHandle loadHandle,
  2485. const char* symbol);
  2486. struct Tcl_LoadHandle_ {
  2487. ClientData clientData; /* Client data is the load handle in the
  2488. * native filesystem if a module was loaded
  2489. * there, or an opaque pointer to a structure
  2490. * for further bookkeeping on load-from-VFS
  2491. * and load-from-memory */
  2492. TclFindSymbolProc* findSymbolProcPtr;
  2493. /* Procedure that resolves symbols in a
  2494. * loaded module */
  2495. Tcl_FSUnloadFileProc* unloadFileProcPtr;
  2496. /* Procedure that unloads a loaded module */
  2497. };
  2498. /* Flags for conversion of doubles to digit strings */
  2499. #define TCL_DD_SHORTEST 0x4
  2500. /* Use the shortest possible string */
  2501. #define TCL_DD_STEELE 0x5
  2502. /* Use the original Steele&White algorithm */
  2503. #define TCL_DD_E_FORMAT 0x2
  2504. /* Use a fixed-length string of digits,
  2505. * suitable for E format*/
  2506. #define TCL_DD_F_FORMAT 0x3
  2507. /* Use a fixed number of digits after the
  2508. * decimal point, suitable for F format */
  2509. #define TCL_DD_SHORTEN_FLAG 0x4
  2510. /* Allow return of a shorter digit string
  2511. * if it converts losslessly */
  2512. #define TCL_DD_NO_QUICK 0x8
  2513. /* Debug flag: forbid quick FP conversion */
  2514. #define TCL_DD_CONVERSION_TYPE_MASK 0x3
  2515. /* Mask to isolate the conversion type */
  2516. #define TCL_DD_STEELE0 0x1
  2517. /* 'Steele&White' after masking */
  2518. #define TCL_DD_SHORTEST0 0x0
  2519. /* 'Shortest possible' after masking */
  2520. /*
  2521. *----------------------------------------------------------------
  2522. * Procedures shared among Tcl modules but not used by the outside world:
  2523. *----------------------------------------------------------------
  2524. */
  2525. MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr,
  2526. const unsigned char *bytes, int len);
  2527. MODULE_SCOPE int TclNREvalCmd(Tcl_Interp *interp, Tcl_Obj *objPtr,
  2528. int flags);
  2529. MODULE_SCOPE void TclAdvanceContinuations(int *line, int **next,
  2530. int loc);
  2531. MODULE_SCOPE void TclAdvanceLines(int *line, const char *start,
  2532. const char *end);
  2533. MODULE_SCOPE void TclArgumentEnter(Tcl_Interp *interp,
  2534. Tcl_Obj *objv[], int objc, CmdFrame *cf);
  2535. MODULE_SCOPE void TclArgumentRelease(Tcl_Interp *interp,
  2536. Tcl_Obj *objv[], int objc);
  2537. MODULE_SCOPE void TclArgumentBCEnter(Tcl_Interp *interp,
  2538. Tcl_Obj *objv[], int objc,
  2539. void *codePtr, CmdFrame *cfPtr, int cmd, int pc);
  2540. MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp,
  2541. CmdFrame *cfPtr);
  2542. MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj,
  2543. CmdFrame **cfPtrPtr, int *wordPtr);
  2544. MODULE_SCOPE double TclBignumToDouble(const mp_int *bignum);
  2545. MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string,
  2546. int strLen, const unsigned char *pattern,
  2547. int ptnLen, int flags);
  2548. MODULE_SCOPE double TclCeil(const mp_int *a);
  2549. MODULE_SCOPE void TclChannelPreserve(Tcl_Channel chan);
  2550. MODULE_SCOPE void TclChannelRelease(Tcl_Channel chan);
  2551. MODULE_SCOPE int TclCheckArrayTraces(Tcl_Interp *interp, Var *varPtr,
  2552. Var *arrayPtr, Tcl_Obj *name, int index);
  2553. MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp,
  2554. const char *value);
  2555. MODULE_SCOPE int TclCheckEmptyString(Tcl_Obj *objPtr);
  2556. MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp,
  2557. Tcl_Channel chan);
  2558. MODULE_SCOPE Tcl_ObjCmdProc TclChannelNamesCmd;
  2559. MODULE_SCOPE Tcl_NRPostProc TclClearRootEnsemble;
  2560. MODULE_SCOPE ContLineLoc *TclContinuationsEnter(Tcl_Obj *objPtr, int num,
  2561. int *loc);
  2562. MODULE_SCOPE void TclContinuationsEnterDerived(Tcl_Obj *objPtr,
  2563. int start, int *clNext);
  2564. MODULE_SCOPE ContLineLoc *TclContinuationsGet(Tcl_Obj *objPtr);
  2565. MODULE_SCOPE void TclContinuationsCopy(Tcl_Obj *objPtr,
  2566. Tcl_Obj *originObjPtr);
  2567. MODULE_SCOPE int TclConvertElement(const char *src, int length,
  2568. char *dst, int flags);
  2569. MODULE_SCOPE Tcl_Command TclCreateObjCommandInNs (
  2570. Tcl_Interp *interp,
  2571. const char *cmdName,
  2572. Tcl_Namespace *nsPtr,
  2573. Tcl_ObjCmdProc *proc,
  2574. ClientData clientData,
  2575. Tcl_CmdDeleteProc *deleteProc);
  2576. MODULE_SCOPE Tcl_Command TclCreateEnsembleInNs(
  2577. Tcl_Interp *interp,
  2578. const char *name,
  2579. Tcl_Namespace *nameNamespacePtr,
  2580. Tcl_Namespace *ensembleNamespacePtr,
  2581. int flags);
  2582. MODULE_SCOPE void TclDeleteNamespaceVars(Namespace *nsPtr);
  2583. MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp,
  2584. const char *dict, int dictLength,
  2585. const char **elementPtr, const char **nextPtr,
  2586. int *sizePtr, int *literalPtr);
  2587. /* TIP #280 - Modified token based evulation, with line information. */
  2588. MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script,
  2589. int numBytes, int flags, int line,
  2590. int *clNextOuter, const char *outerScript);
  2591. MODULE_SCOPE Tcl_ObjCmdProc TclFileAttrsCmd;
  2592. MODULE_SCOPE Tcl_ObjCmdProc TclFileCopyCmd;
  2593. MODULE_SCOPE Tcl_ObjCmdProc TclFileDeleteCmd;
  2594. MODULE_SCOPE Tcl_ObjCmdProc TclFileLinkCmd;
  2595. MODULE_SCOPE Tcl_ObjCmdProc TclFileMakeDirsCmd;
  2596. MODULE_SCOPE Tcl_ObjCmdProc TclFileReadLinkCmd;
  2597. MODULE_SCOPE Tcl_ObjCmdProc TclFileRenameCmd;
  2598. MODULE_SCOPE Tcl_ObjCmdProc TclFileTemporaryCmd;
  2599. MODULE_SCOPE void TclCreateLateExitHandler(Tcl_ExitProc *proc,
  2600. ClientData clientData);
  2601. MODULE_SCOPE void TclDeleteLateExitHandler(Tcl_ExitProc *proc,
  2602. ClientData clientData);
  2603. MODULE_SCOPE char * TclDStringAppendObj(Tcl_DString *dsPtr,
  2604. Tcl_Obj *objPtr);
  2605. MODULE_SCOPE char * TclDStringAppendDString(Tcl_DString *dsPtr,
  2606. Tcl_DString *toAppendPtr);
  2607. MODULE_SCOPE Tcl_Obj * TclDStringToObj(Tcl_DString *dsPtr);
  2608. MODULE_SCOPE Tcl_Obj *const * TclFetchEnsembleRoot(Tcl_Interp *interp,
  2609. Tcl_Obj *const *objv, int objc, int *objcPtr);
  2610. MODULE_SCOPE Tcl_Obj *const *TclEnsembleGetRewriteValues(Tcl_Interp *interp);
  2611. MODULE_SCOPE Tcl_Namespace *TclEnsureNamespace(Tcl_Interp *interp,
  2612. Tcl_Namespace *namespacePtr);
  2613. MODULE_SCOPE void TclFinalizeAllocSubsystem(void);
  2614. MODULE_SCOPE void TclFinalizeAsync(void);
  2615. MODULE_SCOPE void TclFinalizeDoubleConversion(void);
  2616. MODULE_SCOPE void TclFinalizeEncodingSubsystem(void);
  2617. MODULE_SCOPE void TclFinalizeEnvironment(void);
  2618. MODULE_SCOPE void TclFinalizeEvaluation(void);
  2619. MODULE_SCOPE void TclFinalizeExecution(void);
  2620. MODULE_SCOPE void TclFinalizeIOSubsystem(void);
  2621. MODULE_SCOPE void TclFinalizeFilesystem(void);
  2622. MODULE_SCOPE void TclResetFilesystem(void);
  2623. MODULE_SCOPE void TclFinalizeLoad(void);
  2624. MODULE_SCOPE void TclFinalizeLock(void);
  2625. MODULE_SCOPE void TclFinalizeMemorySubsystem(void);
  2626. MODULE_SCOPE void TclFinalizeNotifier(void);
  2627. MODULE_SCOPE void TclFinalizeObjects(void);
  2628. MODULE_SCOPE void TclFinalizePreserve(void);
  2629. MODULE_SCOPE void TclFinalizeSynchronization(void);
  2630. MODULE_SCOPE void TclFinalizeThreadAlloc(void);
  2631. MODULE_SCOPE void TclFinalizeThreadAllocThread(void);
  2632. MODULE_SCOPE void TclFinalizeThreadData(int quick);
  2633. MODULE_SCOPE void TclFinalizeThreadObjects(void);
  2634. MODULE_SCOPE double TclFloor(const mp_int *a);
  2635. MODULE_SCOPE void TclFormatNaN(double value, char *buffer);
  2636. MODULE_SCOPE int TclFSFileAttrIndex(Tcl_Obj *pathPtr,
  2637. const char *attributeName, int *indexPtr);
  2638. MODULE_SCOPE Tcl_Command TclNRCreateCommandInNs (
  2639. Tcl_Interp *interp,
  2640. const char *cmdName,
  2641. Tcl_Namespace *nsPtr,
  2642. Tcl_ObjCmdProc *proc,
  2643. Tcl_ObjCmdProc *nreProc,
  2644. ClientData clientData,
  2645. Tcl_CmdDeleteProc *deleteProc);
  2646. MODULE_SCOPE int TclNREvalFile(Tcl_Interp *interp, Tcl_Obj *pathPtr,
  2647. const char *encodingName);
  2648. MODULE_SCOPE void TclFSUnloadTempFile(Tcl_LoadHandle loadHandle);
  2649. MODULE_SCOPE int * TclGetAsyncReadyPtr(void);
  2650. MODULE_SCOPE Tcl_Obj * TclGetBgErrorHandler(Tcl_Interp *interp);
  2651. MODULE_SCOPE int TclGetChannelFromObj(Tcl_Interp *interp,
  2652. Tcl_Obj *objPtr, Tcl_Channel *chanPtr,
  2653. int *modePtr, int flags);
  2654. MODULE_SCOPE CmdFrame * TclGetCmdFrameForProcedure(Proc *procPtr);
  2655. MODULE_SCOPE int TclGetCompletionCodeFromObj(Tcl_Interp *interp,
  2656. Tcl_Obj *value, int *code);
  2657. MODULE_SCOPE int TclGetNumberFromObj(Tcl_Interp *interp,
  2658. Tcl_Obj *objPtr, ClientData *clientDataPtr,
  2659. int *typePtr);
  2660. MODULE_SCOPE int TclGetOpenModeEx(Tcl_Interp *interp,
  2661. const char *modeString, int *seekFlagPtr,
  2662. int *binaryPtr);
  2663. MODULE_SCOPE Tcl_Obj * TclGetProcessGlobalValue(ProcessGlobalValue *pgvPtr);
  2664. MODULE_SCOPE Tcl_Obj * TclGetSourceFromFrame(CmdFrame *cfPtr, int objc,
  2665. Tcl_Obj *const objv[]);
  2666. MODULE_SCOPE char * TclGetStringStorage(Tcl_Obj *objPtr,
  2667. unsigned int *sizePtr);
  2668. MODULE_SCOPE int TclGlob(Tcl_Interp *interp, char *pattern,
  2669. Tcl_Obj *unquotedPrefix, int globFlags,
  2670. Tcl_GlobTypeData *types);
  2671. MODULE_SCOPE int TclIncrObj(Tcl_Interp *interp, Tcl_Obj *valuePtr,
  2672. Tcl_Obj *incrPtr);
  2673. MODULE_SCOPE Tcl_Obj * TclIncrObjVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr,
  2674. Tcl_Obj *part2Ptr, Tcl_Obj *incrPtr, int flags);
  2675. MODULE_SCOPE int TclInfoExistsCmd(ClientData dummy, Tcl_Interp *interp,
  2676. int objc, Tcl_Obj *const objv[]);
  2677. MODULE_SCOPE int TclInfoCoroutineCmd(ClientData dummy, Tcl_Interp *interp,
  2678. int objc, Tcl_Obj *const objv[]);
  2679. MODULE_SCOPE Tcl_Obj * TclInfoFrame(Tcl_Interp *interp, CmdFrame *framePtr);
  2680. MODULE_SCOPE int TclInfoGlobalsCmd(ClientData dummy, Tcl_Interp *interp,
  2681. int objc, Tcl_Obj *const objv[]);
  2682. MODULE_SCOPE int TclInfoLocalsCmd(ClientData dummy, Tcl_Interp *interp,
  2683. int objc, Tcl_Obj *const objv[]);
  2684. MODULE_SCOPE int TclInfoVarsCmd(ClientData dummy, Tcl_Interp *interp,
  2685. int objc, Tcl_Obj *const objv[]);
  2686. MODULE_SCOPE void TclInitAlloc(void);
  2687. MODULE_SCOPE void TclInitDbCkalloc(void);
  2688. MODULE_SCOPE void TclInitDoubleConversion(void);
  2689. MODULE_SCOPE void TclInitEmbeddedConfigurationInformation(
  2690. Tcl_Interp *interp);
  2691. MODULE_SCOPE void TclInitEncodingSubsystem(void);
  2692. MODULE_SCOPE void TclInitIOSubsystem(void);
  2693. MODULE_SCOPE void TclInitLimitSupport(Tcl_Interp *interp);
  2694. MODULE_SCOPE void TclInitNamespaceSubsystem(void);
  2695. MODULE_SCOPE void TclInitNotifier(void);
  2696. MODULE_SCOPE void TclInitObjSubsystem(void);
  2697. MODULE_SCOPE void TclInitSubsystems(void);
  2698. MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp);
  2699. MODULE_SCOPE int TclIsBareword(int byte);
  2700. MODULE_SCOPE Tcl_Obj * TclJoinPath(int elements, Tcl_Obj * const objv[],
  2701. int forceRelative);
  2702. MODULE_SCOPE int TclJoinThread(Tcl_ThreadId id, int *result);
  2703. MODULE_SCOPE void TclLimitRemoveAllHandlers(Tcl_Interp *interp);
  2704. MODULE_SCOPE Tcl_Obj * TclLindexList(Tcl_Interp *interp,
  2705. Tcl_Obj *listPtr, Tcl_Obj *argPtr);
  2706. MODULE_SCOPE Tcl_Obj * TclLindexFlat(Tcl_Interp *interp, Tcl_Obj *listPtr,
  2707. int indexCount, Tcl_Obj *const indexArray[]);
  2708. /* TIP #280 */
  2709. MODULE_SCOPE void TclListLines(Tcl_Obj *listObj, int line, int n,
  2710. int *lines, Tcl_Obj *const *elems);
  2711. MODULE_SCOPE Tcl_Obj * TclListObjCopy(Tcl_Interp *interp, Tcl_Obj *listPtr);
  2712. MODULE_SCOPE Tcl_Obj * TclLsetList(Tcl_Interp *interp, Tcl_Obj *listPtr,
  2713. Tcl_Obj *indexPtr, Tcl_Obj *valuePtr);
  2714. MODULE_SCOPE Tcl_Obj * TclLsetFlat(Tcl_Interp *interp, Tcl_Obj *listPtr,
  2715. int indexCount, Tcl_Obj *const indexArray[],
  2716. Tcl_Obj *valuePtr);
  2717. MODULE_SCOPE Tcl_Command TclMakeEnsemble(Tcl_Interp *interp, const char *name,
  2718. const EnsembleImplMap map[]);
  2719. MODULE_SCOPE int TclMaxListLength(const char *bytes, int numBytes,
  2720. const char **endPtr);
  2721. MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc,
  2722. Tcl_Obj *const objv[], Tcl_Obj **optionsPtrPtr,
  2723. int *codePtr, int *levelPtr);
  2724. MODULE_SCOPE Tcl_Obj * TclNoErrorStack(Tcl_Interp *interp, Tcl_Obj *options);
  2725. MODULE_SCOPE int TclNokia770Doubles(void);
  2726. MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr);
  2727. MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr);
  2728. MODULE_SCOPE int TclNamespaceDeleted(Namespace *nsPtr);
  2729. MODULE_SCOPE void TclObjVarErrMsg(Tcl_Interp *interp, Tcl_Obj *part1Ptr,
  2730. Tcl_Obj *part2Ptr, const char *operation,
  2731. const char *reason, int index);
  2732. MODULE_SCOPE int TclObjInvokeNamespace(Tcl_Interp *interp,
  2733. int objc, Tcl_Obj *const objv[],
  2734. Tcl_Namespace *nsPtr, int flags);
  2735. MODULE_SCOPE int TclObjUnsetVar2(Tcl_Interp *interp,
  2736. Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags);
  2737. MODULE_SCOPE int TclParseBackslash(const char *src,
  2738. int numBytes, int *readPtr, char *dst);
  2739. MODULE_SCOPE int TclParseNumber(Tcl_Interp *interp, Tcl_Obj *objPtr,
  2740. const char *expected, const char *bytes,
  2741. int numBytes, const char **endPtrPtr, int flags);
  2742. MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string,
  2743. int numBytes, Tcl_Parse *parsePtr);
  2744. MODULE_SCOPE int TclParseAllWhiteSpace(const char *src, int numBytes);
  2745. MODULE_SCOPE int TclProcessReturn(Tcl_Interp *interp,
  2746. int code, int level, Tcl_Obj *returnOpts);
  2747. MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf);
  2748. MODULE_SCOPE Tcl_Obj * TclpTempFileName(void);
  2749. MODULE_SCOPE Tcl_Obj * TclpTempFileNameForLibrary(Tcl_Interp *interp, Tcl_Obj* pathPtr);
  2750. MODULE_SCOPE Tcl_Obj * TclNewFSPathObj(Tcl_Obj *dirPtr, const char *addStrRep,
  2751. int len);
  2752. MODULE_SCOPE int TclpDeleteFile(const void *path);
  2753. MODULE_SCOPE void TclpFinalizeCondition(Tcl_Condition *condPtr);
  2754. MODULE_SCOPE void TclpFinalizeMutex(Tcl_Mutex *mutexPtr);
  2755. MODULE_SCOPE void TclpFinalizePipes(void);
  2756. MODULE_SCOPE void TclpFinalizeSockets(void);
  2757. MODULE_SCOPE int TclCreateSocketAddress(Tcl_Interp *interp,
  2758. struct addrinfo **addrlist,
  2759. const char *host, int port, int willBind,
  2760. const char **errorMsgPtr);
  2761. MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr,
  2762. Tcl_ThreadCreateProc *proc, ClientData clientData,
  2763. int stackSize, int flags);
  2764. MODULE_SCOPE int TclpFindVariable(const char *name, int *lengthPtr);
  2765. MODULE_SCOPE void TclpInitLibraryPath(char **valuePtr,
  2766. int *lengthPtr, Tcl_Encoding *encodingPtr);
  2767. MODULE_SCOPE void TclpInitLock(void);
  2768. MODULE_SCOPE void TclpInitPlatform(void);
  2769. MODULE_SCOPE void TclpInitUnlock(void);
  2770. MODULE_SCOPE Tcl_Obj * TclpObjListVolumes(void);
  2771. MODULE_SCOPE void TclpGlobalLock(void);
  2772. MODULE_SCOPE void TclpGlobalUnlock(void);
  2773. MODULE_SCOPE int TclpMatchFiles(Tcl_Interp *interp, char *separators,
  2774. Tcl_DString *dirPtr, char *pattern, char *tail);
  2775. MODULE_SCOPE int TclpObjNormalizePath(Tcl_Interp *interp,
  2776. Tcl_Obj *pathPtr, int nextCheckpoint);
  2777. MODULE_SCOPE void TclpNativeJoinPath(Tcl_Obj *prefix, const char *joining);
  2778. MODULE_SCOPE Tcl_Obj * TclpNativeSplitPath(Tcl_Obj *pathPtr, int *lenPtr);
  2779. MODULE_SCOPE Tcl_PathType TclpGetNativePathType(Tcl_Obj *pathPtr,
  2780. int *driveNameLengthPtr, Tcl_Obj **driveNameRef);
  2781. MODULE_SCOPE int TclCrossFilesystemCopy(Tcl_Interp *interp,
  2782. Tcl_Obj *source, Tcl_Obj *target);
  2783. MODULE_SCOPE int TclpMatchInDirectory(Tcl_Interp *interp,
  2784. Tcl_Obj *resultPtr, Tcl_Obj *pathPtr,
  2785. const char *pattern, Tcl_GlobTypeData *types);
  2786. MODULE_SCOPE ClientData TclpGetNativeCwd(ClientData clientData);
  2787. MODULE_SCOPE Tcl_FSDupInternalRepProc TclNativeDupInternalRep;
  2788. MODULE_SCOPE Tcl_Obj * TclpObjLink(Tcl_Obj *pathPtr, Tcl_Obj *toPtr,
  2789. int linkType);
  2790. MODULE_SCOPE int TclpObjChdir(Tcl_Obj *pathPtr);
  2791. MODULE_SCOPE Tcl_Channel TclpOpenTemporaryFile(Tcl_Obj *dirObj,
  2792. Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
  2793. Tcl_Obj *resultingNameObj);
  2794. MODULE_SCOPE Tcl_Obj * TclPathPart(Tcl_Interp *interp, Tcl_Obj *pathPtr,
  2795. Tcl_PathPart portion);
  2796. MODULE_SCOPE char * TclpReadlink(const char *fileName,
  2797. Tcl_DString *linkPtr);
  2798. MODULE_SCOPE void TclpSetVariables(Tcl_Interp *interp);
  2799. MODULE_SCOPE void * TclThreadStorageKeyGet(Tcl_ThreadDataKey *keyPtr);
  2800. MODULE_SCOPE void TclThreadStorageKeySet(Tcl_ThreadDataKey *keyPtr,
  2801. void *data);
  2802. MODULE_SCOPE void TclpThreadExit(int status);
  2803. MODULE_SCOPE void TclRememberCondition(Tcl_Condition *mutex);
  2804. MODULE_SCOPE void TclRememberJoinableThread(Tcl_ThreadId id);
  2805. MODULE_SCOPE void TclRememberMutex(Tcl_Mutex *mutex);
  2806. MODULE_SCOPE void TclRemoveScriptLimitCallbacks(Tcl_Interp *interp);
  2807. MODULE_SCOPE int TclReToGlob(Tcl_Interp *interp, const char *reStr,
  2808. int reStrLen, Tcl_DString *dsPtr, int *flagsPtr,
  2809. int *quantifiersFoundPtr);
  2810. MODULE_SCOPE int TclScanElement(const char *string, int length,
  2811. char *flagPtr);
  2812. MODULE_SCOPE void TclSetBgErrorHandler(Tcl_Interp *interp,
  2813. Tcl_Obj *cmdPrefix);
  2814. MODULE_SCOPE void TclSetBignumInternalRep(Tcl_Obj *objPtr,
  2815. mp_int *bignumValue);
  2816. MODULE_SCOPE int TclSetBooleanFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
  2817. MODULE_SCOPE void TclSetCmdNameObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
  2818. Command *cmdPtr);
  2819. MODULE_SCOPE void TclSetDuplicateObj(Tcl_Obj *dupPtr, Tcl_Obj *objPtr);
  2820. MODULE_SCOPE void TclSetProcessGlobalValue(ProcessGlobalValue *pgvPtr,
  2821. Tcl_Obj *newValue, Tcl_Encoding encoding);
  2822. MODULE_SCOPE void TclSignalExitThread(Tcl_ThreadId id, int result);
  2823. MODULE_SCOPE void TclSpellFix(Tcl_Interp *interp,
  2824. Tcl_Obj *const *objv, int objc, int subIdx,
  2825. Tcl_Obj *bad, Tcl_Obj *fix);
  2826. MODULE_SCOPE void * TclStackRealloc(Tcl_Interp *interp, void *ptr,
  2827. int numBytes);
  2828. typedef int (*memCmpFn_t)(const void*, const void*, size_t);
  2829. MODULE_SCOPE int TclStringCmp (Tcl_Obj *value1Ptr, Tcl_Obj *value2Ptr,
  2830. int checkEq, int nocase, int reqlength);
  2831. MODULE_SCOPE int TclStringCmpOpts (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[],
  2832. int *nocase, int *reqlength);
  2833. MODULE_SCOPE int TclStringMatch(const char *str, int strLen,
  2834. const char *pattern, int ptnLen, int flags);
  2835. MODULE_SCOPE int TclStringMatchObj(Tcl_Obj *stringObj,
  2836. Tcl_Obj *patternObj, int flags);
  2837. MODULE_SCOPE Tcl_Obj * TclStringReverse(Tcl_Obj *objPtr);
  2838. MODULE_SCOPE void TclSubstCompile(Tcl_Interp *interp, const char *bytes,
  2839. int numBytes, int flags, int line,
  2840. struct CompileEnv *envPtr);
  2841. MODULE_SCOPE int TclSubstOptions(Tcl_Interp *interp, int numOpts,
  2842. Tcl_Obj *const opts[], int *flagPtr);
  2843. MODULE_SCOPE void TclSubstParse(Tcl_Interp *interp, const char *bytes,
  2844. int numBytes, int flags, Tcl_Parse *parsePtr,
  2845. Tcl_InterpState *statePtr);
  2846. MODULE_SCOPE int TclSubstTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr,
  2847. int count, int *tokensLeftPtr, int line,
  2848. int *clNextOuter, const char *outerScript);
  2849. MODULE_SCOPE int TclTrim(const char *bytes, int numBytes,
  2850. const char *trim, int numTrim, int *trimRight);
  2851. MODULE_SCOPE int TclTrimLeft(const char *bytes, int numBytes,
  2852. const char *trim, int numTrim);
  2853. MODULE_SCOPE int TclTrimRight(const char *bytes, int numBytes,
  2854. const char *trim, int numTrim);
  2855. MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct);
  2856. MODULE_SCOPE int TclUtfToUCS4(const char *, int *);
  2857. MODULE_SCOPE int TclUCS4ToUtf(int, char *);
  2858. MODULE_SCOPE int TclUCS4ToLower(int ch);
  2859. #if TCL_UTF_MAX == 4
  2860. MODULE_SCOPE int TclGetUCS4(Tcl_Obj *, int);
  2861. MODULE_SCOPE int TclUniCharToUCS4(const Tcl_UniChar *, int *);
  2862. #else
  2863. # define TclGetUCS4 Tcl_GetUniChar
  2864. # define TclUniCharToUCS4(src, ptr) (*ptr = *(src),1)
  2865. #endif
  2866. /*
  2867. * Bytes F0-F4 are start-bytes for 4-byte sequences.
  2868. * Byte 0xED can be the start-byte of an upper surrogate. In that case,
  2869. * TclUtfToUCS4() might read the lower surrogate following it too.
  2870. */
  2871. # define TclUCS4Complete(src, length) (((unsigned)(UCHAR(*(src)) - 0xF0) < 5) \
  2872. ? ((length) >= 4) : (UCHAR(*(src)) == 0xED) ? ((length) >= 6) : Tcl_UtfCharComplete((src), (length)))
  2873. MODULE_SCOPE Tcl_Obj * TclpNativeToNormalized(ClientData clientData);
  2874. MODULE_SCOPE Tcl_Obj * TclpFilesystemPathType(Tcl_Obj *pathPtr);
  2875. MODULE_SCOPE int TclpDlopen(Tcl_Interp *interp, Tcl_Obj *pathPtr,
  2876. Tcl_LoadHandle *loadHandle,
  2877. Tcl_FSUnloadFileProc **unloadProcPtr, int flags);
  2878. MODULE_SCOPE int TclpUtime(Tcl_Obj *pathPtr, struct utimbuf *tval);
  2879. #ifdef TCL_LOAD_FROM_MEMORY
  2880. MODULE_SCOPE void * TclpLoadMemoryGetBuffer(Tcl_Interp *interp, int size);
  2881. MODULE_SCOPE int TclpLoadMemory(Tcl_Interp *interp, void *buffer,
  2882. int size, int codeSize, Tcl_LoadHandle *loadHandle,
  2883. Tcl_FSUnloadFileProc **unloadProcPtr, int flags);
  2884. #endif
  2885. MODULE_SCOPE void TclInitThreadStorage(void);
  2886. MODULE_SCOPE void TclFinalizeThreadDataThread(void);
  2887. MODULE_SCOPE void TclFinalizeThreadStorage(void);
  2888. /* TclWideMUInt -- wide integer used for measurement calculations: */
  2889. #if (!defined(_WIN32) || !defined(_MSC_VER) || (_MSC_VER >= 1400))
  2890. # define TclWideMUInt Tcl_WideUInt
  2891. #else
  2892. /* older MSVS may not allow conversions between unsigned __int64 and double) */
  2893. # define TclWideMUInt Tcl_WideInt
  2894. #endif
  2895. #ifdef TCL_WIDE_CLICKS
  2896. MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void);
  2897. MODULE_SCOPE double TclpWideClicksToNanoseconds(Tcl_WideInt clicks);
  2898. MODULE_SCOPE double TclpWideClickInMicrosec(void);
  2899. #else
  2900. # ifdef _WIN32
  2901. # define TCL_WIDE_CLICKS 1
  2902. MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void);
  2903. MODULE_SCOPE double TclpWideClickInMicrosec(void);
  2904. # define TclpWideClicksToNanoseconds(clicks) \
  2905. ((double)(clicks) * TclpWideClickInMicrosec() * 1000)
  2906. # endif
  2907. #endif
  2908. MODULE_SCOPE Tcl_WideInt TclpGetMicroseconds(void);
  2909. MODULE_SCOPE int TclZlibInit(Tcl_Interp *interp);
  2910. MODULE_SCOPE void * TclpThreadCreateKey(void);
  2911. MODULE_SCOPE void TclpThreadDeleteKey(void *keyPtr);
  2912. MODULE_SCOPE void TclpThreadSetGlobalTSD(void *tsdKeyPtr, void *ptr);
  2913. MODULE_SCOPE void * TclpThreadGetGlobalTSD(void *tsdKeyPtr);
  2914. MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, const char *msg, int length);
  2915. /*
  2916. * Many parsing tasks need a common definition of whitespace.
  2917. * Use this routine and macro to achieve that and place
  2918. * optimization (fragile on changes) in one place.
  2919. */
  2920. MODULE_SCOPE int TclIsSpaceProc(int byte);
  2921. # define TclIsSpaceProcM(byte) \
  2922. (((byte) > 0x20) ? 0 : TclIsSpaceProc(byte))
  2923. /*
  2924. *----------------------------------------------------------------
  2925. * Command procedures in the generic core:
  2926. *----------------------------------------------------------------
  2927. */
  2928. MODULE_SCOPE int Tcl_AfterObjCmd(ClientData clientData,
  2929. Tcl_Interp *interp, int objc,
  2930. Tcl_Obj *const objv[]);
  2931. MODULE_SCOPE int Tcl_AppendObjCmd(ClientData clientData,
  2932. Tcl_Interp *interp, int objc,
  2933. Tcl_Obj *const objv[]);
  2934. MODULE_SCOPE int Tcl_ApplyObjCmd(ClientData clientData,
  2935. Tcl_Interp *interp, int objc,
  2936. Tcl_Obj *const objv[]);
  2937. MODULE_SCOPE Tcl_Command TclInitArrayCmd(Tcl_Interp *interp);
  2938. MODULE_SCOPE Tcl_Command TclInitBinaryCmd(Tcl_Interp *interp);
  2939. MODULE_SCOPE int Tcl_BreakObjCmd(ClientData clientData,
  2940. Tcl_Interp *interp, int objc,
  2941. Tcl_Obj *const objv[]);
  2942. MODULE_SCOPE int Tcl_CaseObjCmd(ClientData clientData,
  2943. Tcl_Interp *interp, int objc,
  2944. Tcl_Obj *const objv[]);
  2945. MODULE_SCOPE int Tcl_CatchObjCmd(ClientData clientData,
  2946. Tcl_Interp *interp, int objc,
  2947. Tcl_Obj *const objv[]);
  2948. MODULE_SCOPE int Tcl_CdObjCmd(ClientData clientData,
  2949. Tcl_Interp *interp, int objc,
  2950. Tcl_Obj *const objv[]);
  2951. MODULE_SCOPE Tcl_Command TclInitChanCmd(Tcl_Interp *interp);
  2952. MODULE_SCOPE int TclChanCreateObjCmd(ClientData clientData,
  2953. Tcl_Interp *interp, int objc,
  2954. Tcl_Obj *const objv[]);
  2955. MODULE_SCOPE int TclChanPostEventObjCmd(ClientData clientData,
  2956. Tcl_Interp *interp, int objc,
  2957. Tcl_Obj *const objv[]);
  2958. MODULE_SCOPE int TclChanPopObjCmd(ClientData clientData,
  2959. Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
  2960. MODULE_SCOPE int TclChanPushObjCmd(ClientData clientData,
  2961. Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
  2962. MODULE_SCOPE void TclClockInit(Tcl_Interp *interp);
  2963. MODULE_SCOPE int TclClockOldscanObjCmd(
  2964. ClientData clientData, Tcl_Interp *interp,
  2965. int objc, Tcl_Obj *const objv[]);
  2966. MODULE_SCOPE int Tcl_CloseObjCmd(ClientData clientData,
  2967. Tcl_Interp *interp, int objc,
  2968. Tcl_Obj *const objv[]);
  2969. MODULE_SCOPE int Tcl_ConcatObjCmd(ClientData clientData,
  2970. Tcl_Interp *interp, int objc,
  2971. Tcl_Obj *const objv[]);
  2972. MODULE_SCOPE int Tcl_ContinueObjCmd(ClientData clientData,
  2973. Tcl_Interp *interp, int objc,
  2974. Tcl_Obj *const objv[]);
  2975. MODULE_SCOPE Tcl_TimerToken TclCreateAbsoluteTimerHandler(
  2976. Tcl_Time *timePtr, Tcl_TimerProc *proc,
  2977. ClientData clientData);
  2978. MODULE_SCOPE int TclDefaultBgErrorHandlerObjCmd(
  2979. ClientData clientData, Tcl_Interp *interp,
  2980. int objc, Tcl_Obj *const objv[]);
  2981. MODULE_SCOPE Tcl_Command TclInitDictCmd(Tcl_Interp *interp);
  2982. MODULE_SCOPE int TclDictWithFinish(Tcl_Interp *interp, Var *varPtr,
  2983. Var *arrayPtr, Tcl_Obj *part1Ptr,
  2984. Tcl_Obj *part2Ptr, int index, int pathc,
  2985. Tcl_Obj *const pathv[], Tcl_Obj *keysPtr);
  2986. MODULE_SCOPE Tcl_Obj * TclDictWithInit(Tcl_Interp *interp, Tcl_Obj *dictPtr,
  2987. int pathc, Tcl_Obj *const pathv[]);
  2988. MODULE_SCOPE int Tcl_DisassembleObjCmd(ClientData clientData,
  2989. Tcl_Interp *interp, int objc,
  2990. Tcl_Obj *const objv[]);
  2991. /* Assemble command function */
  2992. MODULE_SCOPE int Tcl_AssembleObjCmd(ClientData clientData,
  2993. Tcl_Interp *interp, int objc,
  2994. Tcl_Obj *const objv[]);
  2995. MODULE_SCOPE int TclNRAssembleObjCmd(ClientData clientData,
  2996. Tcl_Interp *interp, int objc,
  2997. Tcl_Obj *const objv[]);
  2998. MODULE_SCOPE Tcl_Command TclInitEncodingCmd(Tcl_Interp *interp);
  2999. MODULE_SCOPE int TclMakeEncodingCommandSafe(Tcl_Interp *interp);
  3000. MODULE_SCOPE int Tcl_EofObjCmd(ClientData clientData,
  3001. Tcl_Interp *interp, int objc,
  3002. Tcl_Obj *const objv[]);
  3003. MODULE_SCOPE int Tcl_ErrorObjCmd(ClientData clientData,
  3004. Tcl_Interp *interp, int objc,
  3005. Tcl_Obj *const objv[]);
  3006. MODULE_SCOPE int Tcl_EvalObjCmd(ClientData clientData,
  3007. Tcl_Interp *interp, int objc,
  3008. Tcl_Obj *const objv[]);
  3009. MODULE_SCOPE int Tcl_ExecObjCmd(ClientData clientData,
  3010. Tcl_Interp *interp, int objc,
  3011. Tcl_Obj *const objv[]);
  3012. MODULE_SCOPE int Tcl_ExitObjCmd(ClientData clientData,
  3013. Tcl_Interp *interp, int objc,
  3014. Tcl_Obj *const objv[]);
  3015. MODULE_SCOPE int Tcl_ExprObjCmd(ClientData clientData,
  3016. Tcl_Interp *interp, int objc,
  3017. Tcl_Obj *const objv[]);
  3018. MODULE_SCOPE int Tcl_FblockedObjCmd(ClientData clientData,
  3019. Tcl_Interp *interp, int objc,
  3020. Tcl_Obj *const objv[]);
  3021. MODULE_SCOPE int Tcl_FconfigureObjCmd(
  3022. ClientData clientData, Tcl_Interp *interp,
  3023. int objc, Tcl_Obj *const objv[]);
  3024. MODULE_SCOPE int Tcl_FcopyObjCmd(ClientData dummy,
  3025. Tcl_Interp *interp, int objc,
  3026. Tcl_Obj *const objv[]);
  3027. MODULE_SCOPE Tcl_Command TclInitFileCmd(Tcl_Interp *interp);
  3028. MODULE_SCOPE int TclMakeFileCommandSafe(Tcl_Interp *interp);
  3029. MODULE_SCOPE int Tcl_FileEventObjCmd(ClientData clientData,
  3030. Tcl_Interp *interp, int objc,
  3031. Tcl_Obj *const objv[]);
  3032. MODULE_SCOPE int Tcl_FlushObjCmd(ClientData clientData,
  3033. Tcl_Interp *interp, int objc,
  3034. Tcl_Obj *const objv[]);
  3035. MODULE_SCOPE int Tcl_ForObjCmd(ClientData clientData,
  3036. Tcl_Interp *interp, int objc,
  3037. Tcl_Obj *const objv[]);
  3038. MODULE_SCOPE int Tcl_ForeachObjCmd(ClientData clientData,
  3039. Tcl_Interp *interp, int objc,
  3040. Tcl_Obj *const objv[]);
  3041. MODULE_SCOPE int Tcl_FormatObjCmd(ClientData dummy,
  3042. Tcl_Interp *interp, int objc,
  3043. Tcl_Obj *const objv[]);
  3044. MODULE_SCOPE int Tcl_GetsObjCmd(ClientData clientData,
  3045. Tcl_Interp *interp, int objc,
  3046. Tcl_Obj *const objv[]);
  3047. MODULE_SCOPE int Tcl_GlobalObjCmd(ClientData clientData,
  3048. Tcl_Interp *interp, int objc,
  3049. Tcl_Obj *const objv[]);
  3050. MODULE_SCOPE int Tcl_GlobObjCmd(ClientData clientData,
  3051. Tcl_Interp *interp, int objc,
  3052. Tcl_Obj *const objv[]);
  3053. MODULE_SCOPE int Tcl_IfObjCmd(ClientData clientData,
  3054. Tcl_Interp *interp, int objc,
  3055. Tcl_Obj *const objv[]);
  3056. MODULE_SCOPE int Tcl_IncrObjCmd(ClientData clientData,
  3057. Tcl_Interp *interp, int objc,
  3058. Tcl_Obj *const objv[]);
  3059. MODULE_SCOPE Tcl_Command TclInitInfoCmd(Tcl_Interp *interp);
  3060. MODULE_SCOPE int Tcl_InterpObjCmd(ClientData clientData,
  3061. Tcl_Interp *interp, int argc,
  3062. Tcl_Obj *const objv[]);
  3063. MODULE_SCOPE int Tcl_JoinObjCmd(ClientData clientData,
  3064. Tcl_Interp *interp, int objc,
  3065. Tcl_Obj *const objv[]);
  3066. MODULE_SCOPE int Tcl_LappendObjCmd(ClientData clientData,
  3067. Tcl_Interp *interp, int objc,
  3068. Tcl_Obj *const objv[]);
  3069. MODULE_SCOPE int Tcl_LassignObjCmd(ClientData clientData,
  3070. Tcl_Interp *interp, int objc,
  3071. Tcl_Obj *const objv[]);
  3072. MODULE_SCOPE int Tcl_LindexObjCmd(ClientData clientData,
  3073. Tcl_Interp *interp, int objc,
  3074. Tcl_Obj *const objv[]);
  3075. MODULE_SCOPE int Tcl_LinsertObjCmd(ClientData clientData,
  3076. Tcl_Interp *interp, int objc,
  3077. Tcl_Obj *const objv[]);
  3078. MODULE_SCOPE int Tcl_LlengthObjCmd(ClientData clientData,
  3079. Tcl_Interp *interp, int objc,
  3080. Tcl_Obj *const objv[]);
  3081. MODULE_SCOPE int Tcl_ListObjCmd(ClientData clientData,
  3082. Tcl_Interp *interp, int objc,
  3083. Tcl_Obj *const objv[]);
  3084. MODULE_SCOPE int Tcl_LmapObjCmd(ClientData clientData,
  3085. Tcl_Interp *interp, int objc,
  3086. Tcl_Obj *const objv[]);
  3087. MODULE_SCOPE int Tcl_LoadObjCmd(ClientData clientData,
  3088. Tcl_Interp *interp, int objc,
  3089. Tcl_Obj *const objv[]);
  3090. MODULE_SCOPE int Tcl_LrangeObjCmd(ClientData clientData,
  3091. Tcl_Interp *interp, int objc,
  3092. Tcl_Obj *const objv[]);
  3093. MODULE_SCOPE int Tcl_LrepeatObjCmd(ClientData clientData,
  3094. Tcl_Interp *interp, int objc,
  3095. Tcl_Obj *const objv[]);
  3096. MODULE_SCOPE int Tcl_LreplaceObjCmd(ClientData clientData,
  3097. Tcl_Interp *interp, int objc,
  3098. Tcl_Obj *const objv[]);
  3099. MODULE_SCOPE int Tcl_LreverseObjCmd(ClientData clientData,
  3100. Tcl_Interp *interp, int objc,
  3101. Tcl_Obj *const objv[]);
  3102. MODULE_SCOPE int Tcl_LsearchObjCmd(ClientData clientData,
  3103. Tcl_Interp *interp, int objc,
  3104. Tcl_Obj *const objv[]);
  3105. MODULE_SCOPE int Tcl_LsetObjCmd(ClientData clientData,
  3106. Tcl_Interp *interp, int objc,
  3107. Tcl_Obj *const objv[]);
  3108. MODULE_SCOPE int Tcl_LsortObjCmd(ClientData clientData,
  3109. Tcl_Interp *interp, int objc,
  3110. Tcl_Obj *const objv[]);
  3111. MODULE_SCOPE Tcl_Command TclInitNamespaceCmd(Tcl_Interp *interp);
  3112. MODULE_SCOPE int TclNamespaceEnsembleCmd(ClientData dummy,
  3113. Tcl_Interp *interp, int objc,
  3114. Tcl_Obj *const objv[]);
  3115. MODULE_SCOPE int Tcl_OpenObjCmd(ClientData clientData,
  3116. Tcl_Interp *interp, int objc,
  3117. Tcl_Obj *const objv[]);
  3118. MODULE_SCOPE int Tcl_PackageObjCmd(ClientData clientData,
  3119. Tcl_Interp *interp, int objc,
  3120. Tcl_Obj *const objv[]);
  3121. MODULE_SCOPE int Tcl_PidObjCmd(ClientData clientData,
  3122. Tcl_Interp *interp, int objc,
  3123. Tcl_Obj *const objv[]);
  3124. MODULE_SCOPE Tcl_Command TclInitPrefixCmd(Tcl_Interp *interp);
  3125. MODULE_SCOPE int Tcl_PutsObjCmd(ClientData clientData,
  3126. Tcl_Interp *interp, int objc,
  3127. Tcl_Obj *const objv[]);
  3128. MODULE_SCOPE int Tcl_PwdObjCmd(ClientData clientData,
  3129. Tcl_Interp *interp, int objc,
  3130. Tcl_Obj *const objv[]);
  3131. MODULE_SCOPE int Tcl_ReadObjCmd(ClientData clientData,
  3132. Tcl_Interp *interp, int objc,
  3133. Tcl_Obj *const objv[]);
  3134. MODULE_SCOPE int Tcl_RegexpObjCmd(ClientData clientData,
  3135. Tcl_Interp *interp, int objc,
  3136. Tcl_Obj *const objv[]);
  3137. MODULE_SCOPE int Tcl_RegsubObjCmd(ClientData clientData,
  3138. Tcl_Interp *interp, int objc,
  3139. Tcl_Obj *const objv[]);
  3140. MODULE_SCOPE int Tcl_RenameObjCmd(ClientData clientData,
  3141. Tcl_Interp *interp, int objc,
  3142. Tcl_Obj *const objv[]);
  3143. MODULE_SCOPE int Tcl_RepresentationCmd(ClientData clientData,
  3144. Tcl_Interp *interp, int objc,
  3145. Tcl_Obj *const objv[]);
  3146. MODULE_SCOPE int Tcl_ReturnObjCmd(ClientData clientData,
  3147. Tcl_Interp *interp, int objc,
  3148. Tcl_Obj *const objv[]);
  3149. MODULE_SCOPE int Tcl_ScanObjCmd(ClientData clientData,
  3150. Tcl_Interp *interp, int objc,
  3151. Tcl_Obj *const objv[]);
  3152. MODULE_SCOPE int Tcl_SeekObjCmd(ClientData clientData,
  3153. Tcl_Interp *interp, int objc,
  3154. Tcl_Obj *const objv[]);
  3155. MODULE_SCOPE int Tcl_SetObjCmd(ClientData clientData,
  3156. Tcl_Interp *interp, int objc,
  3157. Tcl_Obj *const objv[]);
  3158. MODULE_SCOPE int Tcl_SplitObjCmd(ClientData clientData,
  3159. Tcl_Interp *interp, int objc,
  3160. Tcl_Obj *const objv[]);
  3161. MODULE_SCOPE int Tcl_SocketObjCmd(ClientData clientData,
  3162. Tcl_Interp *interp, int objc,
  3163. Tcl_Obj *const objv[]);
  3164. MODULE_SCOPE int Tcl_SourceObjCmd(ClientData clientData,
  3165. Tcl_Interp *interp, int objc,
  3166. Tcl_Obj *const objv[]);
  3167. MODULE_SCOPE Tcl_Command TclInitStringCmd(Tcl_Interp *interp);
  3168. MODULE_SCOPE int Tcl_SubstObjCmd(ClientData clientData,
  3169. Tcl_Interp *interp, int objc,
  3170. Tcl_Obj *const objv[]);
  3171. MODULE_SCOPE int Tcl_SwitchObjCmd(ClientData clientData,
  3172. Tcl_Interp *interp, int objc,
  3173. Tcl_Obj *const objv[]);
  3174. MODULE_SCOPE int Tcl_TellObjCmd(ClientData clientData,
  3175. Tcl_Interp *interp, int objc,
  3176. Tcl_Obj *const objv[]);
  3177. MODULE_SCOPE int Tcl_ThrowObjCmd(ClientData dummy, Tcl_Interp *interp,
  3178. int objc, Tcl_Obj *const objv[]);
  3179. MODULE_SCOPE int Tcl_TimeObjCmd(ClientData clientData,
  3180. Tcl_Interp *interp, int objc,
  3181. Tcl_Obj *const objv[]);
  3182. MODULE_SCOPE int Tcl_TimeRateObjCmd(ClientData clientData,
  3183. Tcl_Interp *interp, int objc,
  3184. Tcl_Obj *const objv[]);
  3185. MODULE_SCOPE int Tcl_TraceObjCmd(ClientData clientData,
  3186. Tcl_Interp *interp, int objc,
  3187. Tcl_Obj *const objv[]);
  3188. MODULE_SCOPE int Tcl_TryObjCmd(ClientData clientData,
  3189. Tcl_Interp *interp, int objc,
  3190. Tcl_Obj *const objv[]);
  3191. MODULE_SCOPE int Tcl_UnloadObjCmd(ClientData clientData,
  3192. Tcl_Interp *interp, int objc,
  3193. Tcl_Obj *const objv[]);
  3194. MODULE_SCOPE int Tcl_UnsetObjCmd(ClientData clientData,
  3195. Tcl_Interp *interp, int objc,
  3196. Tcl_Obj *const objv[]);
  3197. MODULE_SCOPE int Tcl_UpdateObjCmd(ClientData clientData,
  3198. Tcl_Interp *interp, int objc,
  3199. Tcl_Obj *const objv[]);
  3200. MODULE_SCOPE int Tcl_UplevelObjCmd(ClientData clientData,
  3201. Tcl_Interp *interp, int objc,
  3202. Tcl_Obj *const objv[]);
  3203. MODULE_SCOPE int Tcl_UpvarObjCmd(ClientData clientData,
  3204. Tcl_Interp *interp, int objc,
  3205. Tcl_Obj *const objv[]);
  3206. MODULE_SCOPE int Tcl_VariableObjCmd(ClientData clientData,
  3207. Tcl_Interp *interp, int objc,
  3208. Tcl_Obj *const objv[]);
  3209. MODULE_SCOPE int Tcl_VwaitObjCmd(ClientData clientData,
  3210. Tcl_Interp *interp, int objc,
  3211. Tcl_Obj *const objv[]);
  3212. MODULE_SCOPE int Tcl_WhileObjCmd(ClientData clientData,
  3213. Tcl_Interp *interp, int objc,
  3214. Tcl_Obj *const objv[]);
  3215. /*
  3216. *----------------------------------------------------------------
  3217. * Compilation procedures for commands in the generic core:
  3218. *----------------------------------------------------------------
  3219. */
  3220. MODULE_SCOPE int TclCompileAppendCmd(Tcl_Interp *interp,
  3221. Tcl_Parse *parsePtr, Command *cmdPtr,
  3222. struct CompileEnv *envPtr);
  3223. MODULE_SCOPE int TclCompileArrayExistsCmd(Tcl_Interp *interp,
  3224. Tcl_Parse *parsePtr, Command *cmdPtr,
  3225. struct CompileEnv *envPtr);
  3226. MODULE_SCOPE int TclCompileArraySetCmd(Tcl_Interp *interp,
  3227. Tcl_Parse *parsePtr, Command *cmdPtr,
  3228. struct CompileEnv *envPtr);
  3229. MODULE_SCOPE int TclCompileArrayUnsetCmd(Tcl_Interp *interp,
  3230. Tcl_Parse *parsePtr, Command *cmdPtr,
  3231. struct CompileEnv *envPtr);
  3232. MODULE_SCOPE int TclCompileBreakCmd(Tcl_Interp *interp,
  3233. Tcl_Parse *parsePtr, Command *cmdPtr,
  3234. struct CompileEnv *envPtr);
  3235. MODULE_SCOPE int TclCompileCatchCmd(Tcl_Interp *interp,
  3236. Tcl_Parse *parsePtr, Command *cmdPtr,
  3237. struct CompileEnv *envPtr);
  3238. MODULE_SCOPE int TclCompileClockClicksCmd(Tcl_Interp *interp,
  3239. Tcl_Parse *parsePtr, Command *cmdPtr,
  3240. struct CompileEnv *envPtr);
  3241. MODULE_SCOPE int TclCompileClockReadingCmd(Tcl_Interp *interp,
  3242. Tcl_Parse *parsePtr, Command *cmdPtr,
  3243. struct CompileEnv *envPtr);
  3244. MODULE_SCOPE int TclCompileConcatCmd(Tcl_Interp *interp,
  3245. Tcl_Parse *parsePtr, Command *cmdPtr,
  3246. struct CompileEnv *envPtr);
  3247. MODULE_SCOPE int TclCompileContinueCmd(Tcl_Interp *interp,
  3248. Tcl_Parse *parsePtr, Command *cmdPtr,
  3249. struct CompileEnv *envPtr);
  3250. MODULE_SCOPE int TclCompileDictAppendCmd(Tcl_Interp *interp,
  3251. Tcl_Parse *parsePtr, Command *cmdPtr,
  3252. struct CompileEnv *envPtr);
  3253. MODULE_SCOPE int TclCompileDictCreateCmd(Tcl_Interp *interp,
  3254. Tcl_Parse *parsePtr, Command *cmdPtr,
  3255. struct CompileEnv *envPtr);
  3256. MODULE_SCOPE int TclCompileDictExistsCmd(Tcl_Interp *interp,
  3257. Tcl_Parse *parsePtr, Command *cmdPtr,
  3258. struct CompileEnv *envPtr);
  3259. MODULE_SCOPE int TclCompileDictForCmd(Tcl_Interp *interp,
  3260. Tcl_Parse *parsePtr, Command *cmdPtr,
  3261. struct CompileEnv *envPtr);
  3262. MODULE_SCOPE int TclCompileDictGetCmd(Tcl_Interp *interp,
  3263. Tcl_Parse *parsePtr, Command *cmdPtr,
  3264. struct CompileEnv *envPtr);
  3265. MODULE_SCOPE int TclCompileDictIncrCmd(Tcl_Interp *interp,
  3266. Tcl_Parse *parsePtr, Command *cmdPtr,
  3267. struct CompileEnv *envPtr);
  3268. MODULE_SCOPE int TclCompileDictLappendCmd(Tcl_Interp *interp,
  3269. Tcl_Parse *parsePtr, Command *cmdPtr,
  3270. struct CompileEnv *envPtr);
  3271. MODULE_SCOPE int TclCompileDictMapCmd(Tcl_Interp *interp,
  3272. Tcl_Parse *parsePtr, Command *cmdPtr,
  3273. struct CompileEnv *envPtr);
  3274. MODULE_SCOPE int TclCompileDictMergeCmd(Tcl_Interp *interp,
  3275. Tcl_Parse *parsePtr, Command *cmdPtr,
  3276. struct CompileEnv *envPtr);
  3277. MODULE_SCOPE int TclCompileDictSetCmd(Tcl_Interp *interp,
  3278. Tcl_Parse *parsePtr, Command *cmdPtr,
  3279. struct CompileEnv *envPtr);
  3280. MODULE_SCOPE int TclCompileDictUnsetCmd(Tcl_Interp *interp,
  3281. Tcl_Parse *parsePtr, Command *cmdPtr,
  3282. struct CompileEnv *envPtr);
  3283. MODULE_SCOPE int TclCompileDictUpdateCmd(Tcl_Interp *interp,
  3284. Tcl_Parse *parsePtr, Command *cmdPtr,
  3285. struct CompileEnv *envPtr);
  3286. MODULE_SCOPE int TclCompileDictWithCmd(Tcl_Interp *interp,
  3287. Tcl_Parse *parsePtr, Command *cmdPtr,
  3288. struct CompileEnv *envPtr);
  3289. MODULE_SCOPE int TclCompileEnsemble(Tcl_Interp *interp,
  3290. Tcl_Parse *parsePtr, Command *cmdPtr,
  3291. struct CompileEnv *envPtr);
  3292. MODULE_SCOPE int TclCompileErrorCmd(Tcl_Interp *interp,
  3293. Tcl_Parse *parsePtr, Command *cmdPtr,
  3294. struct CompileEnv *envPtr);
  3295. MODULE_SCOPE int TclCompileExprCmd(Tcl_Interp *interp,
  3296. Tcl_Parse *parsePtr, Command *cmdPtr,
  3297. struct CompileEnv *envPtr);
  3298. MODULE_SCOPE int TclCompileForCmd(Tcl_Interp *interp,
  3299. Tcl_Parse *parsePtr, Command *cmdPtr,
  3300. struct CompileEnv *envPtr);
  3301. MODULE_SCOPE int TclCompileForeachCmd(Tcl_Interp *interp,
  3302. Tcl_Parse *parsePtr, Command *cmdPtr,
  3303. struct CompileEnv *envPtr);
  3304. MODULE_SCOPE int TclCompileFormatCmd(Tcl_Interp *interp,
  3305. Tcl_Parse *parsePtr, Command *cmdPtr,
  3306. struct CompileEnv *envPtr);
  3307. MODULE_SCOPE int TclCompileGlobalCmd(Tcl_Interp *interp,
  3308. Tcl_Parse *parsePtr, Command *cmdPtr,
  3309. struct CompileEnv *envPtr);
  3310. MODULE_SCOPE int TclCompileIfCmd(Tcl_Interp *interp,
  3311. Tcl_Parse *parsePtr, Command *cmdPtr,
  3312. struct CompileEnv *envPtr);
  3313. MODULE_SCOPE int TclCompileInfoCommandsCmd(Tcl_Interp *interp,
  3314. Tcl_Parse *parsePtr, Command *cmdPtr,
  3315. struct CompileEnv *envPtr);
  3316. MODULE_SCOPE int TclCompileInfoCoroutineCmd(Tcl_Interp *interp,
  3317. Tcl_Parse *parsePtr, Command *cmdPtr,
  3318. struct CompileEnv *envPtr);
  3319. MODULE_SCOPE int TclCompileInfoExistsCmd(Tcl_Interp *interp,
  3320. Tcl_Parse *parsePtr, Command *cmdPtr,
  3321. struct CompileEnv *envPtr);
  3322. MODULE_SCOPE int TclCompileInfoLevelCmd(Tcl_Interp *interp,
  3323. Tcl_Parse *parsePtr, Command *cmdPtr,
  3324. struct CompileEnv *envPtr);
  3325. MODULE_SCOPE int TclCompileInfoObjectClassCmd(Tcl_Interp *interp,
  3326. Tcl_Parse *parsePtr, Command *cmdPtr,
  3327. struct CompileEnv *envPtr);
  3328. MODULE_SCOPE int TclCompileInfoObjectIsACmd(Tcl_Interp *interp,
  3329. Tcl_Parse *parsePtr, Command *cmdPtr,
  3330. struct CompileEnv *envPtr);
  3331. MODULE_SCOPE int TclCompileInfoObjectNamespaceCmd(Tcl_Interp *interp,
  3332. Tcl_Parse *parsePtr, Command *cmdPtr,
  3333. struct CompileEnv *envPtr);
  3334. MODULE_SCOPE int TclCompileIncrCmd(Tcl_Interp *interp,
  3335. Tcl_Parse *parsePtr, Command *cmdPtr,
  3336. struct CompileEnv *envPtr);
  3337. MODULE_SCOPE int TclCompileLappendCmd(Tcl_Interp *interp,
  3338. Tcl_Parse *parsePtr, Command *cmdPtr,
  3339. struct CompileEnv *envPtr);
  3340. MODULE_SCOPE int TclCompileLassignCmd(Tcl_Interp *interp,
  3341. Tcl_Parse *parsePtr, Command *cmdPtr,
  3342. struct CompileEnv *envPtr);
  3343. MODULE_SCOPE int TclCompileLindexCmd(Tcl_Interp *interp,
  3344. Tcl_Parse *parsePtr, Command *cmdPtr,
  3345. struct CompileEnv *envPtr);
  3346. MODULE_SCOPE int TclCompileLinsertCmd(Tcl_Interp *interp,
  3347. Tcl_Parse *parsePtr, Command *cmdPtr,
  3348. struct CompileEnv *envPtr);
  3349. MODULE_SCOPE int TclCompileListCmd(Tcl_Interp *interp,
  3350. Tcl_Parse *parsePtr, Command *cmdPtr,
  3351. struct CompileEnv *envPtr);
  3352. MODULE_SCOPE int TclCompileLlengthCmd(Tcl_Interp *interp,
  3353. Tcl_Parse *parsePtr, Command *cmdPtr,
  3354. struct CompileEnv *envPtr);
  3355. MODULE_SCOPE int TclCompileLmapCmd(Tcl_Interp *interp,
  3356. Tcl_Parse *parsePtr, Command *cmdPtr,
  3357. struct CompileEnv *envPtr);
  3358. MODULE_SCOPE int TclCompileLrangeCmd(Tcl_Interp *interp,
  3359. Tcl_Parse *parsePtr, Command *cmdPtr,
  3360. struct CompileEnv *envPtr);
  3361. MODULE_SCOPE int TclCompileLreplaceCmd(Tcl_Interp *interp,
  3362. Tcl_Parse *parsePtr, Command *cmdPtr,
  3363. struct CompileEnv *envPtr);
  3364. MODULE_SCOPE int TclCompileLsetCmd(Tcl_Interp *interp,
  3365. Tcl_Parse *parsePtr, Command *cmdPtr,
  3366. struct CompileEnv *envPtr);
  3367. MODULE_SCOPE int TclCompileNamespaceCodeCmd(Tcl_Interp *interp,
  3368. Tcl_Parse *parsePtr, Command *cmdPtr,
  3369. struct CompileEnv *envPtr);
  3370. MODULE_SCOPE int TclCompileNamespaceCurrentCmd(Tcl_Interp *interp,
  3371. Tcl_Parse *parsePtr, Command *cmdPtr,
  3372. struct CompileEnv *envPtr);
  3373. MODULE_SCOPE int TclCompileNamespaceOriginCmd(Tcl_Interp *interp,
  3374. Tcl_Parse *parsePtr, Command *cmdPtr,
  3375. struct CompileEnv *envPtr);
  3376. MODULE_SCOPE int TclCompileNamespaceQualifiersCmd(Tcl_Interp *interp,
  3377. Tcl_Parse *parsePtr, Command *cmdPtr,
  3378. struct CompileEnv *envPtr);
  3379. MODULE_SCOPE int TclCompileNamespaceTailCmd(Tcl_Interp *interp,
  3380. Tcl_Parse *parsePtr, Command *cmdPtr,
  3381. struct CompileEnv *envPtr);
  3382. MODULE_SCOPE int TclCompileNamespaceUpvarCmd(Tcl_Interp *interp,
  3383. Tcl_Parse *parsePtr, Command *cmdPtr,
  3384. struct CompileEnv *envPtr);
  3385. MODULE_SCOPE int TclCompileNamespaceWhichCmd(Tcl_Interp *interp,
  3386. Tcl_Parse *parsePtr, Command *cmdPtr,
  3387. struct CompileEnv *envPtr);
  3388. MODULE_SCOPE int TclCompileNoOp(Tcl_Interp *interp,
  3389. Tcl_Parse *parsePtr, Command *cmdPtr,
  3390. struct CompileEnv *envPtr);
  3391. MODULE_SCOPE int TclCompileObjectNextCmd(Tcl_Interp *interp,
  3392. Tcl_Parse *parsePtr, Command *cmdPtr,
  3393. struct CompileEnv *envPtr);
  3394. MODULE_SCOPE int TclCompileObjectNextToCmd(Tcl_Interp *interp,
  3395. Tcl_Parse *parsePtr, Command *cmdPtr,
  3396. struct CompileEnv *envPtr);
  3397. MODULE_SCOPE int TclCompileObjectSelfCmd(Tcl_Interp *interp,
  3398. Tcl_Parse *parsePtr, Command *cmdPtr,
  3399. struct CompileEnv *envPtr);
  3400. MODULE_SCOPE int TclCompileRegexpCmd(Tcl_Interp *interp,
  3401. Tcl_Parse *parsePtr, Command *cmdPtr,
  3402. struct CompileEnv *envPtr);
  3403. MODULE_SCOPE int TclCompileRegsubCmd(Tcl_Interp *interp,
  3404. Tcl_Parse *parsePtr, Command *cmdPtr,
  3405. struct CompileEnv *envPtr);
  3406. MODULE_SCOPE int TclCompileReturnCmd(Tcl_Interp *interp,
  3407. Tcl_Parse *parsePtr, Command *cmdPtr,
  3408. struct CompileEnv *envPtr);
  3409. MODULE_SCOPE int TclCompileSetCmd(Tcl_Interp *interp,
  3410. Tcl_Parse *parsePtr, Command *cmdPtr,
  3411. struct CompileEnv *envPtr);
  3412. MODULE_SCOPE int TclCompileStringCatCmd(Tcl_Interp *interp,
  3413. Tcl_Parse *parsePtr, Command *cmdPtr,
  3414. struct CompileEnv *envPtr);
  3415. MODULE_SCOPE int TclCompileStringCmpCmd(Tcl_Interp *interp,
  3416. Tcl_Parse *parsePtr, Command *cmdPtr,
  3417. struct CompileEnv *envPtr);
  3418. MODULE_SCOPE int TclCompileStringEqualCmd(Tcl_Interp *interp,
  3419. Tcl_Parse *parsePtr, Command *cmdPtr,
  3420. struct CompileEnv *envPtr);
  3421. MODULE_SCOPE int TclCompileStringFirstCmd(Tcl_Interp *interp,
  3422. Tcl_Parse *parsePtr, Command *cmdPtr,
  3423. struct CompileEnv *envPtr);
  3424. MODULE_SCOPE int TclCompileStringIndexCmd(Tcl_Interp *interp,
  3425. Tcl_Parse *parsePtr, Command *cmdPtr,
  3426. struct CompileEnv *envPtr);
  3427. MODULE_SCOPE int TclCompileStringIsCmd(Tcl_Interp *interp,
  3428. Tcl_Parse *parsePtr, Command *cmdPtr,
  3429. struct CompileEnv *envPtr);
  3430. MODULE_SCOPE int TclCompileStringLastCmd(Tcl_Interp *interp,
  3431. Tcl_Parse *parsePtr, Command *cmdPtr,
  3432. struct CompileEnv *envPtr);
  3433. MODULE_SCOPE int TclCompileStringLenCmd(Tcl_Interp *interp,
  3434. Tcl_Parse *parsePtr, Command *cmdPtr,
  3435. struct CompileEnv *envPtr);
  3436. MODULE_SCOPE int TclCompileStringMapCmd(Tcl_Interp *interp,
  3437. Tcl_Parse *parsePtr, Command *cmdPtr,
  3438. struct CompileEnv *envPtr);
  3439. MODULE_SCOPE int TclCompileStringMatchCmd(Tcl_Interp *interp,
  3440. Tcl_Parse *parsePtr, Command *cmdPtr,
  3441. struct CompileEnv *envPtr);
  3442. MODULE_SCOPE int TclCompileStringRangeCmd(Tcl_Interp *interp,
  3443. Tcl_Parse *parsePtr, Command *cmdPtr,
  3444. struct CompileEnv *envPtr);
  3445. MODULE_SCOPE int TclCompileStringReplaceCmd(Tcl_Interp *interp,
  3446. Tcl_Parse *parsePtr, Command *cmdPtr,
  3447. struct CompileEnv *envPtr);
  3448. MODULE_SCOPE int TclCompileStringToLowerCmd(Tcl_Interp *interp,
  3449. Tcl_Parse *parsePtr, Command *cmdPtr,
  3450. struct CompileEnv *envPtr);
  3451. MODULE_SCOPE int TclCompileStringToTitleCmd(Tcl_Interp *interp,
  3452. Tcl_Parse *parsePtr, Command *cmdPtr,
  3453. struct CompileEnv *envPtr);
  3454. MODULE_SCOPE int TclCompileStringToUpperCmd(Tcl_Interp *interp,
  3455. Tcl_Parse *parsePtr, Command *cmdPtr,
  3456. struct CompileEnv *envPtr);
  3457. MODULE_SCOPE int TclCompileStringTrimCmd(Tcl_Interp *interp,
  3458. Tcl_Parse *parsePtr, Command *cmdPtr,
  3459. struct CompileEnv *envPtr);
  3460. MODULE_SCOPE int TclCompileStringTrimLCmd(Tcl_Interp *interp,
  3461. Tcl_Parse *parsePtr, Command *cmdPtr,
  3462. struct CompileEnv *envPtr);
  3463. MODULE_SCOPE int TclCompileStringTrimRCmd(Tcl_Interp *interp,
  3464. Tcl_Parse *parsePtr, Command *cmdPtr,
  3465. struct CompileEnv *envPtr);
  3466. MODULE_SCOPE int TclCompileSubstCmd(Tcl_Interp *interp,
  3467. Tcl_Parse *parsePtr, Command *cmdPtr,
  3468. struct CompileEnv *envPtr);
  3469. MODULE_SCOPE int TclCompileSwitchCmd(Tcl_Interp *interp,
  3470. Tcl_Parse *parsePtr, Command *cmdPtr,
  3471. struct CompileEnv *envPtr);
  3472. MODULE_SCOPE int TclCompileTailcallCmd(Tcl_Interp *interp,
  3473. Tcl_Parse *parsePtr, Command *cmdPtr,
  3474. struct CompileEnv *envPtr);
  3475. MODULE_SCOPE int TclCompileThrowCmd(Tcl_Interp *interp,
  3476. Tcl_Parse *parsePtr, Command *cmdPtr,
  3477. struct CompileEnv *envPtr);
  3478. MODULE_SCOPE int TclCompileTryCmd(Tcl_Interp *interp,
  3479. Tcl_Parse *parsePtr, Command *cmdPtr,
  3480. struct CompileEnv *envPtr);
  3481. MODULE_SCOPE int TclCompileUnsetCmd(Tcl_Interp *interp,
  3482. Tcl_Parse *parsePtr, Command *cmdPtr,
  3483. struct CompileEnv *envPtr);
  3484. MODULE_SCOPE int TclCompileUpvarCmd(Tcl_Interp *interp,
  3485. Tcl_Parse *parsePtr, Command *cmdPtr,
  3486. struct CompileEnv *envPtr);
  3487. MODULE_SCOPE int TclCompileVariableCmd(Tcl_Interp *interp,
  3488. Tcl_Parse *parsePtr, Command *cmdPtr,
  3489. struct CompileEnv *envPtr);
  3490. MODULE_SCOPE int TclCompileWhileCmd(Tcl_Interp *interp,
  3491. Tcl_Parse *parsePtr, Command *cmdPtr,
  3492. struct CompileEnv *envPtr);
  3493. MODULE_SCOPE int TclCompileYieldCmd(Tcl_Interp *interp,
  3494. Tcl_Parse *parsePtr, Command *cmdPtr,
  3495. struct CompileEnv *envPtr);
  3496. MODULE_SCOPE int TclCompileYieldToCmd(Tcl_Interp *interp,
  3497. Tcl_Parse *parsePtr, Command *cmdPtr,
  3498. struct CompileEnv *envPtr);
  3499. MODULE_SCOPE int TclCompileBasic0ArgCmd(Tcl_Interp *interp,
  3500. Tcl_Parse *parsePtr, Command *cmdPtr,
  3501. struct CompileEnv *envPtr);
  3502. MODULE_SCOPE int TclCompileBasic1ArgCmd(Tcl_Interp *interp,
  3503. Tcl_Parse *parsePtr, Command *cmdPtr,
  3504. struct CompileEnv *envPtr);
  3505. MODULE_SCOPE int TclCompileBasic2ArgCmd(Tcl_Interp *interp,
  3506. Tcl_Parse *parsePtr, Command *cmdPtr,
  3507. struct CompileEnv *envPtr);
  3508. MODULE_SCOPE int TclCompileBasic3ArgCmd(Tcl_Interp *interp,
  3509. Tcl_Parse *parsePtr, Command *cmdPtr,
  3510. struct CompileEnv *envPtr);
  3511. MODULE_SCOPE int TclCompileBasic0Or1ArgCmd(Tcl_Interp *interp,
  3512. Tcl_Parse *parsePtr, Command *cmdPtr,
  3513. struct CompileEnv *envPtr);
  3514. MODULE_SCOPE int TclCompileBasic1Or2ArgCmd(Tcl_Interp *interp,
  3515. Tcl_Parse *parsePtr, Command *cmdPtr,
  3516. struct CompileEnv *envPtr);
  3517. MODULE_SCOPE int TclCompileBasic2Or3ArgCmd(Tcl_Interp *interp,
  3518. Tcl_Parse *parsePtr, Command *cmdPtr,
  3519. struct CompileEnv *envPtr);
  3520. MODULE_SCOPE int TclCompileBasic0To2ArgCmd(Tcl_Interp *interp,
  3521. Tcl_Parse *parsePtr, Command *cmdPtr,
  3522. struct CompileEnv *envPtr);
  3523. MODULE_SCOPE int TclCompileBasic1To3ArgCmd(Tcl_Interp *interp,
  3524. Tcl_Parse *parsePtr, Command *cmdPtr,
  3525. struct CompileEnv *envPtr);
  3526. MODULE_SCOPE int TclCompileBasicMin0ArgCmd(Tcl_Interp *interp,
  3527. Tcl_Parse *parsePtr, Command *cmdPtr,
  3528. struct CompileEnv *envPtr);
  3529. MODULE_SCOPE int TclCompileBasicMin1ArgCmd(Tcl_Interp *interp,
  3530. Tcl_Parse *parsePtr, Command *cmdPtr,
  3531. struct CompileEnv *envPtr);
  3532. MODULE_SCOPE int TclCompileBasicMin2ArgCmd(Tcl_Interp *interp,
  3533. Tcl_Parse *parsePtr, Command *cmdPtr,
  3534. struct CompileEnv *envPtr);
  3535. MODULE_SCOPE int TclInvertOpCmd(ClientData clientData,
  3536. Tcl_Interp *interp, int objc,
  3537. Tcl_Obj *const objv[]);
  3538. MODULE_SCOPE int TclCompileInvertOpCmd(Tcl_Interp *interp,
  3539. Tcl_Parse *parsePtr, Command *cmdPtr,
  3540. struct CompileEnv *envPtr);
  3541. MODULE_SCOPE int TclNotOpCmd(ClientData clientData,
  3542. Tcl_Interp *interp, int objc,
  3543. Tcl_Obj *const objv[]);
  3544. MODULE_SCOPE int TclCompileNotOpCmd(Tcl_Interp *interp,
  3545. Tcl_Parse *parsePtr, Command *cmdPtr,
  3546. struct CompileEnv *envPtr);
  3547. MODULE_SCOPE int TclAddOpCmd(ClientData clientData,
  3548. Tcl_Interp *interp, int objc,
  3549. Tcl_Obj *const objv[]);
  3550. MODULE_SCOPE int TclCompileAddOpCmd(Tcl_Interp *interp,
  3551. Tcl_Parse *parsePtr, Command *cmdPtr,
  3552. struct CompileEnv *envPtr);
  3553. MODULE_SCOPE int TclMulOpCmd(ClientData clientData,
  3554. Tcl_Interp *interp, int objc,
  3555. Tcl_Obj *const objv[]);
  3556. MODULE_SCOPE int TclCompileMulOpCmd(Tcl_Interp *interp,
  3557. Tcl_Parse *parsePtr, Command *cmdPtr,
  3558. struct CompileEnv *envPtr);
  3559. MODULE_SCOPE int TclAndOpCmd(ClientData clientData,
  3560. Tcl_Interp *interp, int objc,
  3561. Tcl_Obj *const objv[]);
  3562. MODULE_SCOPE int TclCompileAndOpCmd(Tcl_Interp *interp,
  3563. Tcl_Parse *parsePtr, Command *cmdPtr,
  3564. struct CompileEnv *envPtr);
  3565. MODULE_SCOPE int TclOrOpCmd(ClientData clientData,
  3566. Tcl_Interp *interp, int objc,
  3567. Tcl_Obj *const objv[]);
  3568. MODULE_SCOPE int TclCompileOrOpCmd(Tcl_Interp *interp,
  3569. Tcl_Parse *parsePtr, Command *cmdPtr,
  3570. struct CompileEnv *envPtr);
  3571. MODULE_SCOPE int TclXorOpCmd(ClientData clientData,
  3572. Tcl_Interp *interp, int objc,
  3573. Tcl_Obj *const objv[]);
  3574. MODULE_SCOPE int TclCompileXorOpCmd(Tcl_Interp *interp,
  3575. Tcl_Parse *parsePtr, Command *cmdPtr,
  3576. struct CompileEnv *envPtr);
  3577. MODULE_SCOPE int TclPowOpCmd(ClientData clientData,
  3578. Tcl_Interp *interp, int objc,
  3579. Tcl_Obj *const objv[]);
  3580. MODULE_SCOPE int TclCompilePowOpCmd(Tcl_Interp *interp,
  3581. Tcl_Parse *parsePtr, Command *cmdPtr,
  3582. struct CompileEnv *envPtr);
  3583. MODULE_SCOPE int TclLshiftOpCmd(ClientData clientData,
  3584. Tcl_Interp *interp, int objc,
  3585. Tcl_Obj *const objv[]);
  3586. MODULE_SCOPE int TclCompileLshiftOpCmd(Tcl_Interp *interp,
  3587. Tcl_Parse *parsePtr, Command *cmdPtr,
  3588. struct CompileEnv *envPtr);
  3589. MODULE_SCOPE int TclRshiftOpCmd(ClientData clientData,
  3590. Tcl_Interp *interp, int objc,
  3591. Tcl_Obj *const objv[]);
  3592. MODULE_SCOPE int TclCompileRshiftOpCmd(Tcl_Interp *interp,
  3593. Tcl_Parse *parsePtr, Command *cmdPtr,
  3594. struct CompileEnv *envPtr);
  3595. MODULE_SCOPE int TclModOpCmd(ClientData clientData,
  3596. Tcl_Interp *interp, int objc,
  3597. Tcl_Obj *const objv[]);
  3598. MODULE_SCOPE int TclCompileModOpCmd(Tcl_Interp *interp,
  3599. Tcl_Parse *parsePtr, Command *cmdPtr,
  3600. struct CompileEnv *envPtr);
  3601. MODULE_SCOPE int TclNeqOpCmd(ClientData clientData,
  3602. Tcl_Interp *interp, int objc,
  3603. Tcl_Obj *const objv[]);
  3604. MODULE_SCOPE int TclCompileNeqOpCmd(Tcl_Interp *interp,
  3605. Tcl_Parse *parsePtr, Command *cmdPtr,
  3606. struct CompileEnv *envPtr);
  3607. MODULE_SCOPE int TclStrneqOpCmd(ClientData clientData,
  3608. Tcl_Interp *interp, int objc,
  3609. Tcl_Obj *const objv[]);
  3610. MODULE_SCOPE int TclCompileStrneqOpCmd(Tcl_Interp *interp,
  3611. Tcl_Parse *parsePtr, Command *cmdPtr,
  3612. struct CompileEnv *envPtr);
  3613. MODULE_SCOPE int TclInOpCmd(ClientData clientData,
  3614. Tcl_Interp *interp, int objc,
  3615. Tcl_Obj *const objv[]);
  3616. MODULE_SCOPE int TclCompileInOpCmd(Tcl_Interp *interp,
  3617. Tcl_Parse *parsePtr, Command *cmdPtr,
  3618. struct CompileEnv *envPtr);
  3619. MODULE_SCOPE int TclNiOpCmd(ClientData clientData,
  3620. Tcl_Interp *interp, int objc,
  3621. Tcl_Obj *const objv[]);
  3622. MODULE_SCOPE int TclCompileNiOpCmd(Tcl_Interp *interp,
  3623. Tcl_Parse *parsePtr, Command *cmdPtr,
  3624. struct CompileEnv *envPtr);
  3625. MODULE_SCOPE int TclMinusOpCmd(ClientData clientData,
  3626. Tcl_Interp *interp, int objc,
  3627. Tcl_Obj *const objv[]);
  3628. MODULE_SCOPE int TclCompileMinusOpCmd(Tcl_Interp *interp,
  3629. Tcl_Parse *parsePtr, Command *cmdPtr,
  3630. struct CompileEnv *envPtr);
  3631. MODULE_SCOPE int TclDivOpCmd(ClientData clientData,
  3632. Tcl_Interp *interp, int objc,
  3633. Tcl_Obj *const objv[]);
  3634. MODULE_SCOPE int TclCompileDivOpCmd(Tcl_Interp *interp,
  3635. Tcl_Parse *parsePtr, Command *cmdPtr,
  3636. struct CompileEnv *envPtr);
  3637. MODULE_SCOPE int TclCompileLessOpCmd(Tcl_Interp *interp,
  3638. Tcl_Parse *parsePtr, Command *cmdPtr,
  3639. struct CompileEnv *envPtr);
  3640. MODULE_SCOPE int TclCompileLeqOpCmd(Tcl_Interp *interp,
  3641. Tcl_Parse *parsePtr, Command *cmdPtr,
  3642. struct CompileEnv *envPtr);
  3643. MODULE_SCOPE int TclCompileGreaterOpCmd(Tcl_Interp *interp,
  3644. Tcl_Parse *parsePtr, Command *cmdPtr,
  3645. struct CompileEnv *envPtr);
  3646. MODULE_SCOPE int TclCompileGeqOpCmd(Tcl_Interp *interp,
  3647. Tcl_Parse *parsePtr, Command *cmdPtr,
  3648. struct CompileEnv *envPtr);
  3649. MODULE_SCOPE int TclCompileEqOpCmd(Tcl_Interp *interp,
  3650. Tcl_Parse *parsePtr, Command *cmdPtr,
  3651. struct CompileEnv *envPtr);
  3652. MODULE_SCOPE int TclCompileStreqOpCmd(Tcl_Interp *interp,
  3653. Tcl_Parse *parsePtr, Command *cmdPtr,
  3654. struct CompileEnv *envPtr);
  3655. MODULE_SCOPE int TclCompileAssembleCmd(Tcl_Interp *interp,
  3656. Tcl_Parse *parsePtr, Command *cmdPtr,
  3657. struct CompileEnv *envPtr);
  3658. /*
  3659. * Functions defined in generic/tclVar.c and currently exported only for use
  3660. * by the bytecode compiler and engine. Some of these could later be placed in
  3661. * the public interface.
  3662. */
  3663. MODULE_SCOPE Var * TclObjLookupVarEx(Tcl_Interp * interp,
  3664. Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags,
  3665. const char *msg, const int createPart1,
  3666. const int createPart2, Var **arrayPtrPtr);
  3667. MODULE_SCOPE Var * TclLookupArrayElement(Tcl_Interp *interp,
  3668. Tcl_Obj *arrayNamePtr, Tcl_Obj *elNamePtr,
  3669. const int flags, const char *msg,
  3670. const int createPart1, const int createPart2,
  3671. Var *arrayPtr, int index);
  3672. MODULE_SCOPE Tcl_Obj * TclPtrGetVarIdx(Tcl_Interp *interp,
  3673. Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr,
  3674. Tcl_Obj *part2Ptr, const int flags, int index);
  3675. MODULE_SCOPE Tcl_Obj * TclPtrSetVarIdx(Tcl_Interp *interp,
  3676. Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr,
  3677. Tcl_Obj *part2Ptr, Tcl_Obj *newValuePtr,
  3678. const int flags, int index);
  3679. MODULE_SCOPE Tcl_Obj * TclPtrIncrObjVarIdx(Tcl_Interp *interp,
  3680. Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr,
  3681. Tcl_Obj *part2Ptr, Tcl_Obj *incrPtr,
  3682. const int flags, int index);
  3683. MODULE_SCOPE int TclPtrObjMakeUpvarIdx(Tcl_Interp *interp,
  3684. Var *otherPtr, Tcl_Obj *myNamePtr, int myFlags,
  3685. int index);
  3686. MODULE_SCOPE int TclPtrUnsetVarIdx(Tcl_Interp *interp, Var *varPtr,
  3687. Var *arrayPtr, Tcl_Obj *part1Ptr,
  3688. Tcl_Obj *part2Ptr, const int flags,
  3689. int index);
  3690. MODULE_SCOPE void TclInvalidateNsPath(Namespace *nsPtr);
  3691. MODULE_SCOPE void TclFindArrayPtrElements(Var *arrayPtr,
  3692. Tcl_HashTable *tablePtr);
  3693. /*
  3694. * The new extended interface to the variable traces.
  3695. */
  3696. MODULE_SCOPE int TclObjCallVarTraces(Interp *iPtr, Var *arrayPtr,
  3697. Var *varPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
  3698. int flags, int leaveErrMsg, int index);
  3699. /*
  3700. * So tclObj.c and tclDictObj.c can share these implementations.
  3701. */
  3702. MODULE_SCOPE int TclCompareObjKeys(void *keyPtr, Tcl_HashEntry *hPtr);
  3703. MODULE_SCOPE void TclFreeObjEntry(Tcl_HashEntry *hPtr);
  3704. MODULE_SCOPE unsigned TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr);
  3705. MODULE_SCOPE int TclFullFinalizationRequested(void);
  3706. /*
  3707. * Utility routines for encoding index values as integers. Used by both
  3708. * some of the command compilers and by [lsort] and [lsearch].
  3709. */
  3710. MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr,
  3711. int before, int after, int *indexPtr);
  3712. MODULE_SCOPE int TclIndexDecode(int encoded, int endValue);
  3713. MODULE_SCOPE void TclBN_s_mp_reverse(unsigned char *s, size_t len);
  3714. /* Constants used in index value encoding routines. */
  3715. #define TCL_INDEX_END (-2)
  3716. #define TCL_INDEX_BEFORE (-1)
  3717. #define TCL_INDEX_START (0)
  3718. #define TCL_INDEX_AFTER (INT_MAX)
  3719. /*
  3720. *----------------------------------------------------------------
  3721. * Macros used by the Tcl core to create and release Tcl objects.
  3722. * TclNewObj(objPtr) creates a new object denoting an empty string.
  3723. * TclDecrRefCount(objPtr) decrements the object's reference count, and frees
  3724. * the object if its reference count is zero. These macros are inline versions
  3725. * of Tcl_NewObj() and Tcl_DecrRefCount(). Notice that the names differ in not
  3726. * having a "_" after the "Tcl". Notice also that these macros reference their
  3727. * argument more than once, so you should avoid calling them with an
  3728. * expression that is expensive to compute or has side effects. The ANSI C
  3729. * "prototypes" for these macros are:
  3730. *
  3731. * MODULE_SCOPE void TclNewObj(Tcl_Obj *objPtr);
  3732. * MODULE_SCOPE void TclDecrRefCount(Tcl_Obj *objPtr);
  3733. *
  3734. * These macros are defined in terms of two macros that depend on memory
  3735. * allocator in use: TclAllocObjStorage, TclFreeObjStorage. They are defined
  3736. * below.
  3737. *----------------------------------------------------------------
  3738. */
  3739. /*
  3740. * DTrace object allocation probe macros.
  3741. */
  3742. #ifdef USE_DTRACE
  3743. #ifndef _TCLDTRACE_H
  3744. #include "tclDTrace.h"
  3745. #endif
  3746. #define TCL_DTRACE_OBJ_CREATE(objPtr) TCL_OBJ_CREATE(objPtr)
  3747. #define TCL_DTRACE_OBJ_FREE(objPtr) TCL_OBJ_FREE(objPtr)
  3748. #else /* USE_DTRACE */
  3749. #define TCL_DTRACE_OBJ_CREATE(objPtr) {}
  3750. #define TCL_DTRACE_OBJ_FREE(objPtr) {}
  3751. #endif /* USE_DTRACE */
  3752. #ifdef TCL_COMPILE_STATS
  3753. # define TclIncrObjsAllocated() \
  3754. tclObjsAlloced++
  3755. # define TclIncrObjsFreed() \
  3756. tclObjsFreed++
  3757. #else
  3758. # define TclIncrObjsAllocated()
  3759. # define TclIncrObjsFreed()
  3760. #endif /* TCL_COMPILE_STATS */
  3761. # define TclAllocObjStorage(objPtr) \
  3762. TclAllocObjStorageEx(NULL, (objPtr))
  3763. # define TclFreeObjStorage(objPtr) \
  3764. TclFreeObjStorageEx(NULL, (objPtr))
  3765. #ifndef TCL_MEM_DEBUG
  3766. # define TclNewObj(objPtr) \
  3767. TclIncrObjsAllocated(); \
  3768. TclAllocObjStorage(objPtr); \
  3769. (objPtr)->refCount = 0; \
  3770. (objPtr)->bytes = tclEmptyStringRep; \
  3771. (objPtr)->length = 0; \
  3772. (objPtr)->typePtr = NULL; \
  3773. TCL_DTRACE_OBJ_CREATE(objPtr)
  3774. /*
  3775. * Invalidate the string rep first so we can use the bytes value for our
  3776. * pointer chain, and signal an obj deletion (as opposed to shimmering) with
  3777. * 'length == -1'.
  3778. * Use empty 'if ; else' to handle use in unbraced outer if/else conditions.
  3779. */
  3780. # define TclDecrRefCount(objPtr) \
  3781. if ((objPtr)->refCount-- > 1) ; else { \
  3782. if (!(objPtr)->typePtr || !(objPtr)->typePtr->freeIntRepProc) { \
  3783. TCL_DTRACE_OBJ_FREE(objPtr); \
  3784. if ((objPtr)->bytes \
  3785. && ((objPtr)->bytes != tclEmptyStringRep)) { \
  3786. ckfree((char *) (objPtr)->bytes); \
  3787. } \
  3788. (objPtr)->length = -1; \
  3789. TclFreeObjStorage(objPtr); \
  3790. TclIncrObjsFreed(); \
  3791. } else { \
  3792. TclFreeObj(objPtr); \
  3793. } \
  3794. }
  3795. #if defined(PURIFY)
  3796. /*
  3797. * The PURIFY mode is like the regular mode, but instead of doing block
  3798. * Tcl_Obj allocation and keeping a freed list for efficiency, it always
  3799. * allocates and frees a single Tcl_Obj so that tools like Purify can better
  3800. * track memory leaks.
  3801. */
  3802. # define TclAllocObjStorageEx(interp, objPtr) \
  3803. (objPtr) = (Tcl_Obj *) ckalloc(sizeof(Tcl_Obj))
  3804. # define TclFreeObjStorageEx(interp, objPtr) \
  3805. ckfree((char *) (objPtr))
  3806. #undef USE_THREAD_ALLOC
  3807. #undef USE_TCLALLOC
  3808. #elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
  3809. /*
  3810. * The TCL_THREADS mode is like the regular mode but allocates Tcl_Obj's from
  3811. * per-thread caches.
  3812. */
  3813. MODULE_SCOPE Tcl_Obj * TclThreadAllocObj(void);
  3814. MODULE_SCOPE void TclThreadFreeObj(Tcl_Obj *);
  3815. MODULE_SCOPE Tcl_Mutex *TclpNewAllocMutex(void);
  3816. MODULE_SCOPE void TclFreeAllocCache(void *);
  3817. MODULE_SCOPE void * TclpGetAllocCache(void);
  3818. MODULE_SCOPE void TclpSetAllocCache(void *);
  3819. MODULE_SCOPE void TclpFreeAllocMutex(Tcl_Mutex *mutex);
  3820. MODULE_SCOPE void TclpFreeAllocCache(void *);
  3821. /*
  3822. * These macros need to be kept in sync with the code of TclThreadAllocObj()
  3823. * and TclThreadFreeObj().
  3824. *
  3825. * Note that the optimiser should resolve the case (interp==NULL) at compile
  3826. * time.
  3827. */
  3828. # define ALLOC_NOBJHIGH 1200
  3829. # define TclAllocObjStorageEx(interp, objPtr) \
  3830. do { \
  3831. AllocCache *cachePtr; \
  3832. if (((interp) == NULL) || \
  3833. ((cachePtr = ((Interp *)(interp))->allocCache), \
  3834. (cachePtr->numObjects == 0))) { \
  3835. (objPtr) = TclThreadAllocObj(); \
  3836. } else { \
  3837. (objPtr) = cachePtr->firstObjPtr; \
  3838. cachePtr->firstObjPtr = (Tcl_Obj *)(objPtr)->internalRep.twoPtrValue.ptr1; \
  3839. --cachePtr->numObjects; \
  3840. } \
  3841. } while (0)
  3842. # define TclFreeObjStorageEx(interp, objPtr) \
  3843. do { \
  3844. AllocCache *cachePtr; \
  3845. if (((interp) == NULL) || \
  3846. ((cachePtr = ((Interp *)(interp))->allocCache), \
  3847. ((cachePtr->numObjects == 0) || \
  3848. (cachePtr->numObjects >= ALLOC_NOBJHIGH)))) { \
  3849. TclThreadFreeObj(objPtr); \
  3850. } else { \
  3851. (objPtr)->internalRep.twoPtrValue.ptr1 = cachePtr->firstObjPtr; \
  3852. cachePtr->firstObjPtr = objPtr; \
  3853. ++cachePtr->numObjects; \
  3854. } \
  3855. } while (0)
  3856. #else /* not PURIFY or USE_THREAD_ALLOC */
  3857. #if defined(USE_TCLALLOC) && USE_TCLALLOC
  3858. MODULE_SCOPE void TclFinalizeAllocSubsystem();
  3859. MODULE_SCOPE void TclInitAlloc();
  3860. #else
  3861. # define USE_TCLALLOC 0
  3862. #endif
  3863. #ifdef TCL_THREADS
  3864. /* declared in tclObj.c */
  3865. MODULE_SCOPE Tcl_Mutex tclObjMutex;
  3866. #endif
  3867. # define TclAllocObjStorageEx(interp, objPtr) \
  3868. do { \
  3869. Tcl_MutexLock(&tclObjMutex); \
  3870. if (tclFreeObjList == NULL) { \
  3871. TclAllocateFreeObjects(); \
  3872. } \
  3873. (objPtr) = tclFreeObjList; \
  3874. tclFreeObjList = (Tcl_Obj *) \
  3875. tclFreeObjList->internalRep.twoPtrValue.ptr1; \
  3876. Tcl_MutexUnlock(&tclObjMutex); \
  3877. } while (0)
  3878. # define TclFreeObjStorageEx(interp, objPtr) \
  3879. do { \
  3880. Tcl_MutexLock(&tclObjMutex); \
  3881. (objPtr)->internalRep.twoPtrValue.ptr1 = (void *) tclFreeObjList; \
  3882. tclFreeObjList = (objPtr); \
  3883. Tcl_MutexUnlock(&tclObjMutex); \
  3884. } while (0)
  3885. #endif
  3886. #else /* TCL_MEM_DEBUG */
  3887. MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
  3888. int line);
  3889. # define TclDbNewObj(objPtr, file, line) \
  3890. do { \
  3891. TclIncrObjsAllocated(); \
  3892. (objPtr) = (Tcl_Obj *) \
  3893. Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
  3894. TclDbInitNewObj((objPtr), (file), (line)); \
  3895. TCL_DTRACE_OBJ_CREATE(objPtr); \
  3896. } while (0)
  3897. # define TclNewObj(objPtr) \
  3898. TclDbNewObj(objPtr, __FILE__, __LINE__);
  3899. # define TclDecrRefCount(objPtr) \
  3900. Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
  3901. # define TclNewListObjDirect(objc, objv) \
  3902. TclDbNewListObjDirect(objc, objv, __FILE__, __LINE__)
  3903. #undef USE_THREAD_ALLOC
  3904. #endif /* TCL_MEM_DEBUG */
  3905. /*
  3906. *----------------------------------------------------------------
  3907. * Macro used by the Tcl core to set a Tcl_Obj's string representation to a
  3908. * copy of the "len" bytes starting at "bytePtr". This code works even if the
  3909. * byte array contains NULLs as long as the length is correct. Because "len"
  3910. * is referenced multiple times, it should be as simple an expression as
  3911. * possible. The ANSI C "prototype" for this macro is:
  3912. *
  3913. * MODULE_SCOPE void TclInitStringRep(Tcl_Obj *objPtr, char *bytePtr, int len);
  3914. *
  3915. * This macro should only be called on an unshared objPtr where
  3916. * objPtr->typePtr->freeIntRepProc == NULL
  3917. *----------------------------------------------------------------
  3918. */
  3919. #define TclInitStringRep(objPtr, bytePtr, len) \
  3920. if ((len) == 0) { \
  3921. (objPtr)->bytes = tclEmptyStringRep; \
  3922. (objPtr)->length = 0; \
  3923. } else { \
  3924. (objPtr)->bytes = (char *) ckalloc((len) + 1); \
  3925. memcpy((objPtr)->bytes, (bytePtr), (len)); \
  3926. (objPtr)->bytes[len] = '\0'; \
  3927. (objPtr)->length = (len); \
  3928. }
  3929. /*
  3930. *----------------------------------------------------------------
  3931. * Macro used by the Tcl core to get the string representation's byte array
  3932. * pointer from a Tcl_Obj. This is an inline version of Tcl_GetString(). The
  3933. * macro's expression result is the string rep's byte pointer which might be
  3934. * NULL. The bytes referenced by this pointer must not be modified by the
  3935. * caller. The ANSI C "prototype" for this macro is:
  3936. *
  3937. * MODULE_SCOPE char * TclGetString(Tcl_Obj *objPtr);
  3938. *----------------------------------------------------------------
  3939. */
  3940. #define TclGetString(objPtr) \
  3941. ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr)))
  3942. #define TclGetStringFromObj(objPtr, lenPtr) \
  3943. ((objPtr)->bytes \
  3944. ? (*(lenPtr) = (objPtr)->length, (objPtr)->bytes) \
  3945. : Tcl_GetStringFromObj((objPtr), (lenPtr)))
  3946. /*
  3947. *----------------------------------------------------------------
  3948. * Macro used by the Tcl core to clean out an object's internal
  3949. * representation. Does not actually reset the rep's bytes. The ANSI C
  3950. * "prototype" for this macro is:
  3951. *
  3952. * MODULE_SCOPE void TclFreeIntRep(Tcl_Obj *objPtr);
  3953. *----------------------------------------------------------------
  3954. */
  3955. #define TclFreeIntRep(objPtr) \
  3956. if ((objPtr)->typePtr != NULL) { \
  3957. if ((objPtr)->typePtr->freeIntRepProc != NULL) { \
  3958. (objPtr)->typePtr->freeIntRepProc(objPtr); \
  3959. } \
  3960. (objPtr)->typePtr = NULL; \
  3961. }
  3962. /*
  3963. *----------------------------------------------------------------
  3964. * Macro used by the Tcl core to clean out an object's string representation.
  3965. * The ANSI C "prototype" for this macro is:
  3966. *
  3967. * MODULE_SCOPE void TclInvalidateStringRep(Tcl_Obj *objPtr);
  3968. *----------------------------------------------------------------
  3969. */
  3970. #define TclInvalidateStringRep(objPtr) \
  3971. do { \
  3972. Tcl_Obj *_isobjPtr = (Tcl_Obj *)(objPtr); \
  3973. if (_isobjPtr->bytes != NULL) { \
  3974. if (_isobjPtr->bytes != tclEmptyStringRep) { \
  3975. ckfree((char *)_isobjPtr->bytes); \
  3976. } \
  3977. _isobjPtr->bytes = NULL; \
  3978. } \
  3979. } while (0)
  3980. #define TclHasStringRep(objPtr) \
  3981. ((objPtr)->bytes != NULL)
  3982. /*
  3983. *----------------------------------------------------------------
  3984. * Macros used by the Tcl core to grow Tcl_Token arrays. They use the same
  3985. * growth algorithm as used in tclStringObj.c for growing strings. The ANSI C
  3986. * "prototype" for this macro is:
  3987. *
  3988. * MODULE_SCOPE void TclGrowTokenArray(Tcl_Token *tokenPtr, int used,
  3989. * int available, int append,
  3990. * Tcl_Token *staticPtr);
  3991. * MODULE_SCOPE void TclGrowParseTokenArray(Tcl_Parse *parsePtr,
  3992. * int append);
  3993. *----------------------------------------------------------------
  3994. */
  3995. /* General tuning for minimum growth in Tcl growth algorithms */
  3996. #ifndef TCL_MIN_GROWTH
  3997. # ifdef TCL_GROWTH_MIN_ALLOC
  3998. /* Support for any legacy tuners */
  3999. # define TCL_MIN_GROWTH TCL_GROWTH_MIN_ALLOC
  4000. # else
  4001. # define TCL_MIN_GROWTH 1024
  4002. # endif
  4003. #endif
  4004. /* Token growth tuning, default to the general value. */
  4005. #ifndef TCL_MIN_TOKEN_GROWTH
  4006. #define TCL_MIN_TOKEN_GROWTH TCL_MIN_GROWTH/sizeof(Tcl_Token)
  4007. #endif
  4008. #define TCL_MAX_TOKENS (int)(UINT_MAX / sizeof(Tcl_Token))
  4009. #define TclGrowTokenArray(tokenPtr, used, available, append, staticPtr) \
  4010. do { \
  4011. int _needed = (used) + (append); \
  4012. if (_needed > TCL_MAX_TOKENS) { \
  4013. Tcl_Panic("max # of tokens for a Tcl parse (%d) exceeded", \
  4014. TCL_MAX_TOKENS); \
  4015. } \
  4016. if (_needed > (available)) { \
  4017. int allocated = 2 * _needed; \
  4018. Tcl_Token *oldPtr = (tokenPtr); \
  4019. Tcl_Token *newPtr; \
  4020. if (oldPtr == (staticPtr)) { \
  4021. oldPtr = NULL; \
  4022. } \
  4023. if (allocated > TCL_MAX_TOKENS) { \
  4024. allocated = TCL_MAX_TOKENS; \
  4025. } \
  4026. newPtr = (Tcl_Token *) attemptckrealloc((char *) oldPtr, \
  4027. (unsigned int) (allocated * sizeof(Tcl_Token))); \
  4028. if (newPtr == NULL) { \
  4029. allocated = _needed + (append) + TCL_MIN_TOKEN_GROWTH; \
  4030. if (allocated > TCL_MAX_TOKENS) { \
  4031. allocated = TCL_MAX_TOKENS; \
  4032. } \
  4033. newPtr = (Tcl_Token *) ckrealloc((char *) oldPtr, \
  4034. (unsigned int) (allocated * sizeof(Tcl_Token))); \
  4035. } \
  4036. (available) = allocated; \
  4037. if (oldPtr == NULL) { \
  4038. memcpy(newPtr, staticPtr, \
  4039. (size_t) ((used) * sizeof(Tcl_Token))); \
  4040. } \
  4041. (tokenPtr) = newPtr; \
  4042. } \
  4043. } while (0)
  4044. #define TclGrowParseTokenArray(parsePtr, append) \
  4045. TclGrowTokenArray((parsePtr)->tokenPtr, (parsePtr)->numTokens, \
  4046. (parsePtr)->tokensAvailable, (append), \
  4047. (parsePtr)->staticTokens)
  4048. /*
  4049. *----------------------------------------------------------------
  4050. * Macro used by the Tcl core get a unicode char from a utf string. It checks
  4051. * to see if we have a one-byte utf char before calling the real
  4052. * Tcl_UtfToUniChar, as this will save a lot of time for primarily ASCII
  4053. * string handling. The macro's expression result is 1 for the 1-byte case or
  4054. * the result of Tcl_UtfToUniChar. The ANSI C "prototype" for this macro is:
  4055. *
  4056. * MODULE_SCOPE int TclUtfToUniChar(const char *string, Tcl_UniChar *ch);
  4057. *----------------------------------------------------------------
  4058. */
  4059. #define TclUtfToUniChar(str, chPtr) \
  4060. (((UCHAR(*(str))) < 0x80) ? \
  4061. ((*(chPtr) = UCHAR(*(str))), 1) \
  4062. : Tcl_UtfToUniChar(str, chPtr))
  4063. /*
  4064. *----------------------------------------------------------------
  4065. * Macro counterpart of the Tcl_NumUtfChars() function. To be used in speed-
  4066. * -sensitive points where it pays to avoid a function call in the common case
  4067. * of counting along a string of all one-byte characters. The ANSI C
  4068. * "prototype" for this macro is:
  4069. *
  4070. * MODULE_SCOPE void TclNumUtfChars(int numChars, const char *bytes,
  4071. * int numBytes);
  4072. *----------------------------------------------------------------
  4073. */
  4074. #define TclNumUtfChars(numChars, bytes, numBytes) \
  4075. do { \
  4076. int _count, _i = (numBytes); \
  4077. unsigned char *_str = (unsigned char *) (bytes); \
  4078. while (_i && (*_str < 0xC0)) { _i--; _str++; } \
  4079. _count = (numBytes) - _i; \
  4080. if (_i) { \
  4081. _count += Tcl_NumUtfChars((bytes) + _count, _i); \
  4082. } \
  4083. (numChars) = _count; \
  4084. } while (0);
  4085. #define TclUtfPrev(src, start) \
  4086. (((src) < (start)+2) ? (start) : \
  4087. (UCHAR(*((src) - 1))) < 0x80 ? (src)-1 : \
  4088. Tcl_UtfPrev(src, start))
  4089. /*
  4090. *----------------------------------------------------------------
  4091. * Macro that encapsulates the logic that determines when it is safe to
  4092. * interpret a string as a byte array directly. In summary, the object must be
  4093. * a byte array and must not have a string representation (as the operations
  4094. * that it is used in are defined on strings, not byte arrays). Theoretically
  4095. * it is possible to also be efficient in the case where the object's bytes
  4096. * field is filled by generation from the byte array (c.f. list canonicality)
  4097. * but we don't do that at the moment since this is purely about efficiency.
  4098. * The ANSI C "prototype" for this macro is:
  4099. *
  4100. * MODULE_SCOPE int TclIsPureByteArray(Tcl_Obj *objPtr);
  4101. *----------------------------------------------------------------
  4102. */
  4103. #define TclIsPureByteArray(objPtr) \
  4104. (((objPtr)->typePtr==&tclByteArrayType) && ((objPtr)->bytes==NULL))
  4105. #define TclIsPureDict(objPtr) \
  4106. (((objPtr)->bytes==NULL) && ((objPtr)->typePtr==&tclDictType))
  4107. #define TclIsPureList(objPtr) \
  4108. (((objPtr)->bytes==NULL) && ((objPtr)->typePtr==&tclListType))
  4109. /*
  4110. *----------------------------------------------------------------
  4111. * Macro used by the Tcl core to compare Unicode strings. On big-endian
  4112. * systems we can use the more efficient memcmp, but this would not be
  4113. * lexically correct on little-endian systems. The ANSI C "prototype" for
  4114. * this macro is:
  4115. *
  4116. * MODULE_SCOPE int TclUniCharNcmp(const Tcl_UniChar *cs,
  4117. * const Tcl_UniChar *ct, unsigned long n);
  4118. *----------------------------------------------------------------
  4119. */
  4120. #if defined(WORDS_BIGENDIAN) && (TCL_UTF_MAX != 4)
  4121. # define TclUniCharNcmp(cs,ct,n) memcmp((cs),(ct),(n)*sizeof(Tcl_UniChar))
  4122. #else /* !WORDS_BIGENDIAN */
  4123. # define TclUniCharNcmp Tcl_UniCharNcmp
  4124. #endif /* WORDS_BIGENDIAN */
  4125. /*
  4126. *----------------------------------------------------------------
  4127. * Macro used by the Tcl core to increment a namespace's export epoch
  4128. * counter. The ANSI C "prototype" for this macro is:
  4129. *
  4130. * MODULE_SCOPE void TclInvalidateNsCmdLookup(Namespace *nsPtr);
  4131. *----------------------------------------------------------------
  4132. */
  4133. #define TclInvalidateNsCmdLookup(nsPtr) \
  4134. if ((nsPtr)->numExportPatterns) { \
  4135. (nsPtr)->exportLookupEpoch++; \
  4136. } \
  4137. if ((nsPtr)->commandPathLength) { \
  4138. (nsPtr)->cmdRefEpoch++; \
  4139. }
  4140. /*
  4141. *----------------------------------------------------------------------
  4142. *
  4143. * Core procedure added to libtommath for bignum manipulation.
  4144. *
  4145. *----------------------------------------------------------------------
  4146. */
  4147. MODULE_SCOPE Tcl_PackageInitProc TclTommath_Init;
  4148. /*
  4149. *----------------------------------------------------------------------
  4150. *
  4151. * External (platform specific) initialization routine, these declarations
  4152. * explicitly don't use EXTERN since this code does not get compiled into the
  4153. * library:
  4154. *
  4155. *----------------------------------------------------------------------
  4156. */
  4157. MODULE_SCOPE Tcl_PackageInitProc TclplatformtestInit;
  4158. MODULE_SCOPE Tcl_PackageInitProc TclObjTest_Init;
  4159. MODULE_SCOPE Tcl_PackageInitProc TclThread_Init;
  4160. MODULE_SCOPE Tcl_PackageInitProc Procbodytest_Init;
  4161. MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
  4162. /*
  4163. *----------------------------------------------------------------
  4164. * Macro used by the Tcl core to check whether a pattern has any characters
  4165. * special to [string match]. The ANSI C "prototype" for this macro is:
  4166. *
  4167. * MODULE_SCOPE int TclMatchIsTrivial(const char *pattern);
  4168. *----------------------------------------------------------------
  4169. */
  4170. #define TclMatchIsTrivial(pattern) \
  4171. (strpbrk((pattern), "*[?\\") == NULL)
  4172. /*
  4173. *----------------------------------------------------------------
  4174. * Macros used by the Tcl core to set a Tcl_Obj's numeric representation
  4175. * avoiding the corresponding function calls in time critical parts of the
  4176. * core. They should only be called on unshared objects. The ANSI C
  4177. * "prototypes" for these macros are:
  4178. *
  4179. * MODULE_SCOPE void TclSetIntObj(Tcl_Obj *objPtr, int intValue);
  4180. * MODULE_SCOPE void TclSetLongObj(Tcl_Obj *objPtr, long longValue);
  4181. * MODULE_SCOPE void TclSetBooleanObj(Tcl_Obj *objPtr, long boolValue);
  4182. * MODULE_SCOPE void TclSetWideIntObj(Tcl_Obj *objPtr, Tcl_WideInt w);
  4183. * MODULE_SCOPE void TclSetDoubleObj(Tcl_Obj *objPtr, double d);
  4184. *----------------------------------------------------------------
  4185. */
  4186. #define TclSetLongObj(objPtr, i) \
  4187. do { \
  4188. TclInvalidateStringRep(objPtr); \
  4189. TclFreeIntRep(objPtr); \
  4190. (objPtr)->internalRep.longValue = (long)(i); \
  4191. (objPtr)->typePtr = &tclIntType; \
  4192. } while (0)
  4193. #define TclSetIntObj(objPtr, l) \
  4194. TclSetLongObj(objPtr, l)
  4195. /*
  4196. * NOTE: There is to be no such thing as a "pure" boolean. Boolean values set
  4197. * programmatically go straight to being "int" Tcl_Obj's, with value 0 or 1.
  4198. * The only "boolean" Tcl_Obj's shall be those holding the cached boolean
  4199. * value of strings like: "yes", "no", "true", "false", "on", "off".
  4200. */
  4201. #define TclSetBooleanObj(objPtr, b) \
  4202. TclSetLongObj(objPtr, (b)!=0);
  4203. #ifndef TCL_WIDE_INT_IS_LONG
  4204. #define TclSetWideIntObj(objPtr, w) \
  4205. do { \
  4206. TclInvalidateStringRep(objPtr); \
  4207. TclFreeIntRep(objPtr); \
  4208. (objPtr)->internalRep.wideValue = (Tcl_WideInt)(w); \
  4209. (objPtr)->typePtr = &tclWideIntType; \
  4210. } while (0)
  4211. #endif
  4212. #define TclSetDoubleObj(objPtr, d) \
  4213. do { \
  4214. TclInvalidateStringRep(objPtr); \
  4215. TclFreeIntRep(objPtr); \
  4216. (objPtr)->internalRep.doubleValue = (double)(d); \
  4217. (objPtr)->typePtr = &tclDoubleType; \
  4218. } while (0)
  4219. /*
  4220. *----------------------------------------------------------------
  4221. * Macros used by the Tcl core to create and initialise objects of standard
  4222. * types, avoiding the corresponding function calls in time critical parts of
  4223. * the core. The ANSI C "prototypes" for these macros are:
  4224. *
  4225. * MODULE_SCOPE void TclNewIntObj(Tcl_Obj *objPtr, int i);
  4226. * MODULE_SCOPE void TclNewLongObj(Tcl_Obj *objPtr, long l);
  4227. * MODULE_SCOPE void TclNewBooleanObj(Tcl_Obj *objPtr, int b);
  4228. * MODULE_SCOPE void TclNewWideObj(Tcl_Obj *objPtr, Tcl_WideInt w);
  4229. * MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d);
  4230. * MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, char *s, int len);
  4231. * MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, char*sLiteral);
  4232. *
  4233. *----------------------------------------------------------------
  4234. */
  4235. #ifndef TCL_MEM_DEBUG
  4236. #define TclNewLongObj(objPtr, i) \
  4237. do { \
  4238. TclIncrObjsAllocated(); \
  4239. TclAllocObjStorage(objPtr); \
  4240. (objPtr)->refCount = 0; \
  4241. (objPtr)->bytes = NULL; \
  4242. (objPtr)->internalRep.longValue = (long)(i); \
  4243. (objPtr)->typePtr = &tclIntType; \
  4244. TCL_DTRACE_OBJ_CREATE(objPtr); \
  4245. } while (0)
  4246. #define TclNewIntObj(objPtr, l) \
  4247. TclNewLongObj(objPtr, l)
  4248. /*
  4249. * NOTE: There is to be no such thing as a "pure" boolean.
  4250. * See comment above TclSetBooleanObj macro above.
  4251. */
  4252. #define TclNewBooleanObj(objPtr, b) \
  4253. TclNewLongObj((objPtr), (b)!=0)
  4254. #define TclNewDoubleObj(objPtr, d) \
  4255. do { \
  4256. TclIncrObjsAllocated(); \
  4257. TclAllocObjStorage(objPtr); \
  4258. (objPtr)->refCount = 0; \
  4259. (objPtr)->bytes = NULL; \
  4260. (objPtr)->internalRep.doubleValue = (double)(d); \
  4261. (objPtr)->typePtr = &tclDoubleType; \
  4262. TCL_DTRACE_OBJ_CREATE(objPtr); \
  4263. } while (0)
  4264. #define TclNewStringObj(objPtr, s, len) \
  4265. do { \
  4266. TclIncrObjsAllocated(); \
  4267. TclAllocObjStorage(objPtr); \
  4268. (objPtr)->refCount = 0; \
  4269. TclInitStringRep((objPtr), (s), (len)); \
  4270. (objPtr)->typePtr = NULL; \
  4271. TCL_DTRACE_OBJ_CREATE(objPtr); \
  4272. } while (0)
  4273. #else /* TCL_MEM_DEBUG */
  4274. #define TclNewIntObj(objPtr, i) \
  4275. (objPtr) = Tcl_NewIntObj(i)
  4276. #define TclNewLongObj(objPtr, l) \
  4277. (objPtr) = Tcl_NewLongObj(l)
  4278. #define TclNewBooleanObj(objPtr, b) \
  4279. (objPtr) = Tcl_NewBooleanObj(b)
  4280. #define TclNewDoubleObj(objPtr, d) \
  4281. (objPtr) = Tcl_NewDoubleObj(d)
  4282. #define TclNewStringObj(objPtr, s, len) \
  4283. (objPtr) = Tcl_NewStringObj((s), (len))
  4284. #endif /* TCL_MEM_DEBUG */
  4285. /*
  4286. * The sLiteral argument *must* be a string literal; the incantation with
  4287. * sizeof(sLiteral "") will fail to compile otherwise.
  4288. */
  4289. #define TclNewLiteralStringObj(objPtr, sLiteral) \
  4290. TclNewStringObj((objPtr), (sLiteral), (int) (sizeof(sLiteral "") - 1))
  4291. /*
  4292. *----------------------------------------------------------------
  4293. * Convenience macros for DStrings.
  4294. * The ANSI C "prototypes" for these macros are:
  4295. *
  4296. * MODULE_SCOPE char * TclDStringAppendLiteral(Tcl_DString *dsPtr,
  4297. * const char *sLiteral);
  4298. * MODULE_SCOPE void TclDStringClear(Tcl_DString *dsPtr);
  4299. */
  4300. #define TclDStringAppendLiteral(dsPtr, sLiteral) \
  4301. Tcl_DStringAppend((dsPtr), (sLiteral), (int) (sizeof(sLiteral "") - 1))
  4302. #define TclDStringClear(dsPtr) \
  4303. Tcl_DStringSetLength((dsPtr), 0)
  4304. /*
  4305. *----------------------------------------------------------------
  4306. * Macros used by the Tcl core to test for some special double values.
  4307. * The ANSI C "prototypes" for these macros are:
  4308. *
  4309. * MODULE_SCOPE int TclIsInfinite(double d);
  4310. * MODULE_SCOPE int TclIsNaN(double d);
  4311. */
  4312. #ifdef _MSC_VER
  4313. # define TclIsInfinite(d) (!(_finite((d))))
  4314. # define TclIsNaN(d) (_isnan((d)))
  4315. #else
  4316. # define TclIsInfinite(d) ((d) > DBL_MAX || (d) < -DBL_MAX)
  4317. # ifdef NO_ISNAN
  4318. # define TclIsNaN(d) ((d) != (d))
  4319. # else
  4320. # define TclIsNaN(d) (isnan(d))
  4321. # endif
  4322. #endif
  4323. /*
  4324. * ----------------------------------------------------------------------
  4325. * Macro to use to find the offset of a field in a structure. Computes number
  4326. * of bytes from beginning of structure to a given field.
  4327. */
  4328. #ifdef offsetof
  4329. #define TclOffset(type, field) ((int) offsetof(type, field))
  4330. #else
  4331. #define TclOffset(type, field) ((int) ((char *) &((type *) 0)->field))
  4332. #endif
  4333. /*
  4334. *----------------------------------------------------------------
  4335. * Inline version of Tcl_GetCurrentNamespace and Tcl_GetGlobalNamespace.
  4336. */
  4337. #define TclGetCurrentNamespace(interp) \
  4338. (Tcl_Namespace *) ((Interp *)(interp))->varFramePtr->nsPtr
  4339. #define TclGetGlobalNamespace(interp) \
  4340. (Tcl_Namespace *) ((Interp *)(interp))->globalNsPtr
  4341. /*
  4342. *----------------------------------------------------------------
  4343. * Inline version of TclCleanupCommand; still need the function as it is in
  4344. * the internal stubs, but the core can use the macro instead.
  4345. */
  4346. #define TclCleanupCommandMacro(cmdPtr) \
  4347. if ((cmdPtr)->refCount-- <= 1) { \
  4348. ckfree((char *) (cmdPtr));\
  4349. }
  4350. /*
  4351. *----------------------------------------------------------------
  4352. * Inline versions of Tcl_LimitReady() and Tcl_LimitExceeded to limit number
  4353. * of calls out of the critical path. Note that this code isn't particularly
  4354. * readable; the non-inline version (in tclInterp.c) is much easier to
  4355. * understand. Note also that these macros takes different args (iPtr->limit)
  4356. * to the non-inline version.
  4357. */
  4358. #define TclLimitExceeded(limit) ((limit).exceeded != 0)
  4359. #define TclLimitReady(limit) \
  4360. (((limit).active == 0) ? 0 : \
  4361. (++(limit).granularityTicker, \
  4362. ((((limit).active & TCL_LIMIT_COMMANDS) && \
  4363. (((limit).cmdGranularity == 1) || \
  4364. ((limit).granularityTicker % (limit).cmdGranularity == 0))) \
  4365. ? 1 : \
  4366. (((limit).active & TCL_LIMIT_TIME) && \
  4367. (((limit).timeGranularity == 1) || \
  4368. ((limit).granularityTicker % (limit).timeGranularity == 0)))\
  4369. ? 1 : 0)))
  4370. /*
  4371. * Compile-time assertions: these produce a compile time error if the
  4372. * expression is not known to be true at compile time. If the assertion is
  4373. * known to be false, the compiler (or optimizer?) will error out with
  4374. * "division by zero". If the assertion cannot be evaluated at compile time,
  4375. * the compiler will error out with "non-static initializer".
  4376. *
  4377. * Adapted with permission from
  4378. * http://www.pixelbeat.org/programming/gcc/static_assert.html
  4379. */
  4380. #define TCL_CT_ASSERT(e) \
  4381. {enum { ct_assert_value = 1/(!!(e)) };}
  4382. /*
  4383. *----------------------------------------------------------------
  4384. * Allocator for small structs (<=sizeof(Tcl_Obj)) using the Tcl_Obj pool.
  4385. * Only checked at compile time.
  4386. *
  4387. * ONLY USE FOR CONSTANT nBytes.
  4388. *
  4389. * DO NOT LET THEM CROSS THREAD BOUNDARIES
  4390. *----------------------------------------------------------------
  4391. */
  4392. #define TclSmallAlloc(nbytes, memPtr) \
  4393. TclSmallAllocEx(NULL, (nbytes), (memPtr))
  4394. #define TclSmallFree(memPtr) \
  4395. TclSmallFreeEx(NULL, (memPtr))
  4396. #ifndef TCL_MEM_DEBUG
  4397. #define TclSmallAllocEx(interp, nbytes, memPtr) \
  4398. do { \
  4399. Tcl_Obj *_objPtr; \
  4400. TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \
  4401. TclIncrObjsAllocated(); \
  4402. TclAllocObjStorageEx((interp), (_objPtr)); \
  4403. memPtr = (ClientData) (_objPtr); \
  4404. } while (0)
  4405. #define TclSmallFreeEx(interp, memPtr) \
  4406. do { \
  4407. TclFreeObjStorageEx((interp), (Tcl_Obj *) (memPtr)); \
  4408. TclIncrObjsFreed(); \
  4409. } while (0)
  4410. #else /* TCL_MEM_DEBUG */
  4411. #define TclSmallAllocEx(interp, nbytes, memPtr) \
  4412. do { \
  4413. Tcl_Obj *_objPtr; \
  4414. TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \
  4415. TclNewObj(_objPtr); \
  4416. memPtr = (ClientData) _objPtr; \
  4417. } while (0)
  4418. #define TclSmallFreeEx(interp, memPtr) \
  4419. do { \
  4420. Tcl_Obj *_objPtr = (Tcl_Obj *) memPtr; \
  4421. _objPtr->bytes = NULL; \
  4422. _objPtr->typePtr = NULL; \
  4423. _objPtr->refCount = 1; \
  4424. TclDecrRefCount(_objPtr); \
  4425. } while (0)
  4426. #endif /* TCL_MEM_DEBUG */
  4427. /*
  4428. * Support for Clang Static Analyzer <http://clang-analyzer.llvm.org>
  4429. */
  4430. #if defined(PURIFY) && defined(__clang__)
  4431. #if __has_feature(attribute_analyzer_noreturn) && \
  4432. !defined(Tcl_Panic) && defined(Tcl_Panic_TCL_DECLARED)
  4433. void Tcl_Panic(const char *, ...) __attribute__((analyzer_noreturn));
  4434. #endif
  4435. #if !defined(CLANG_ASSERT)
  4436. #include <assert.h>
  4437. #define CLANG_ASSERT(x) assert(x)
  4438. #endif
  4439. #elif !defined(CLANG_ASSERT)
  4440. #define CLANG_ASSERT(x)
  4441. #endif /* PURIFY && __clang__ */
  4442. /*
  4443. *----------------------------------------------------------------
  4444. * Parameters, structs and macros for the non-recursive engine (NRE)
  4445. *----------------------------------------------------------------
  4446. */
  4447. #define NRE_USE_SMALL_ALLOC 1 /* Only turn off for debugging purposes. */
  4448. #ifndef NRE_ENABLE_ASSERTS
  4449. #define NRE_ENABLE_ASSERTS 0
  4450. #endif
  4451. /*
  4452. * This is the main data struct for representing NR commands. It is designed
  4453. * to fit in sizeof(Tcl_Obj) in order to exploit the fastest memory allocator
  4454. * available.
  4455. */
  4456. typedef struct NRE_callback {
  4457. Tcl_NRPostProc *procPtr;
  4458. ClientData data[4];
  4459. struct NRE_callback *nextPtr;
  4460. } NRE_callback;
  4461. #define TOP_CB(iPtr) (((Interp *)(iPtr))->execEnvPtr->callbackPtr)
  4462. /*
  4463. * Inline version of Tcl_NRAddCallback.
  4464. */
  4465. #define TclNRAddCallback(interp,postProcPtr,data0,data1,data2,data3) \
  4466. do { \
  4467. NRE_callback *_callbackPtr; \
  4468. TCLNR_ALLOC((interp), (_callbackPtr)); \
  4469. _callbackPtr->procPtr = (postProcPtr); \
  4470. _callbackPtr->data[0] = (ClientData)(data0); \
  4471. _callbackPtr->data[1] = (ClientData)(data1); \
  4472. _callbackPtr->data[2] = (ClientData)(data2); \
  4473. _callbackPtr->data[3] = (ClientData)(data3); \
  4474. _callbackPtr->nextPtr = TOP_CB(interp); \
  4475. TOP_CB(interp) = _callbackPtr; \
  4476. } while (0)
  4477. #if NRE_USE_SMALL_ALLOC
  4478. #define TCLNR_ALLOC(interp, ptr) \
  4479. TclSmallAllocEx(interp, sizeof(NRE_callback), (ptr))
  4480. #define TCLNR_FREE(interp, ptr) TclSmallFreeEx((interp), (ptr))
  4481. #else
  4482. #define TCLNR_ALLOC(interp, ptr) \
  4483. (ptr = ((ClientData) ckalloc(sizeof(NRE_callback))))
  4484. #define TCLNR_FREE(interp, ptr) ckfree((char *) (ptr))
  4485. #endif
  4486. #if NRE_ENABLE_ASSERTS
  4487. #define NRE_ASSERT(expr) assert((expr))
  4488. #else
  4489. #define NRE_ASSERT(expr)
  4490. #endif
  4491. #include "tclIntDecls.h"
  4492. #include "tclIntPlatDecls.h"
  4493. #include "tclTomMathDecls.h"
  4494. #if !defined(USE_TCL_STUBS) && !defined(TCL_MEM_DEBUG)
  4495. #define Tcl_AttemptAlloc(size) TclpAlloc(size)
  4496. #define Tcl_AttemptRealloc(ptr, size) TclpRealloc((ptr), (size))
  4497. #define Tcl_Free(ptr) TclpFree(ptr)
  4498. #endif
  4499. /*
  4500. * Other externals.
  4501. */
  4502. MODULE_SCOPE size_t TclEnvEpoch; /* Epoch of the tcl environment
  4503. * (if changed with tcl-env). */
  4504. #endif /* _TCLINT */
  4505. /*
  4506. * Local Variables:
  4507. * mode: c
  4508. * c-basic-offset: 4
  4509. * fill-column: 78
  4510. * End:
  4511. */